• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

  • libtdegames
kstdgameaction.cpp
1/*
2 This file is part of the TDE games library
3 Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "kstdgameaction.h"
21
22#include <tdelocale.h>
23#include <tdeaction.h>
24#include <tdestdaccel.h>
25#include <tdeconfig.h>
26#include <kdebug.h>
27
28
29KStdGameAction::KStdGameAction()
30{}
31
32KStdGameAction::~KStdGameAction()
33{}
34
35TDEAction *KStdGameAction::action(StdGameAction act_enum, const TQObject *recvr,
36 const char *slot, TDEActionCollection *parent,
37 const char *name)
38{
39 return create( act_enum, name, recvr, slot, parent );
40}
41
42const char* KStdGameAction::stdName(StdGameAction act_enum)
43{
44 return name(act_enum);
45}
46
47struct KStdGameActionInfo
48{
49 KStdGameAction::StdGameAction id;
50 TDEStdAccel::StdAccel globalAccel; // if we reuse a global accel
51 int shortcut; // specific shortcut (NH: should be configurable)
52 const char* psName;
53 const char* psLabel;
54 const char* psWhatsThis;
55 const char* psIconName;
56};
57
58const KStdGameActionInfo g_rgActionInfo[] = {
59// "game" menu
60 { KStdGameAction::New, TDEStdAccel::New, 0, "game_new", I18N_NOOP2("new game", "&New"), 0, "document-new" },
61 { KStdGameAction::Load, TDEStdAccel::Open, 0, "game_load", I18N_NOOP("&Load..."), 0, "document-open" },
62 { KStdGameAction::LoadRecent, TDEStdAccel::AccelNone, 0, "game_load_recent", I18N_NOOP("Load &Recent"), 0, 0 },
63 { KStdGameAction::Restart, TDEStdAccel::Reload, 0, "game_restart", I18N_NOOP("Restart &Game"), 0, "reload" },
64 { KStdGameAction::Save, TDEStdAccel::Save, 0, "game_save", I18N_NOOP("&Save"), 0, "document-save" },
65 { KStdGameAction::SaveAs, TDEStdAccel::AccelNone, 0, "game_save_as", I18N_NOOP("Save &As..."), 0, "document-save-as" },
66 { KStdGameAction::End, TDEStdAccel::End, 0, "game_end", I18N_NOOP("&End Game"), 0, "window-close" },
67 { KStdGameAction::Pause, TDEStdAccel::AccelNone, TQt::Key_P, "game_pause", I18N_NOOP("Pa&use"), 0, "media-playback-pause" },
68 { KStdGameAction::Highscores, TDEStdAccel::AccelNone, TQt::CTRL+TQt::Key_H, "game_highscores", I18N_NOOP("Show &Highscores"), 0, "highscore" },
69 { KStdGameAction::Print, TDEStdAccel::Print, 0, "game_print", I18N_NOOP("&Print..."), 0, "document-print" },
70 { KStdGameAction::Quit, TDEStdAccel::Quit, 0, "game_quit", I18N_NOOP("&Quit"), 0, "application-exit" },
71// "move" menu
72 { KStdGameAction::Repeat, TDEStdAccel::AccelNone, 0, "move_repeat", I18N_NOOP("Repeat"), 0, 0 },
73 { KStdGameAction::Undo, TDEStdAccel::Undo, 0, "move_undo", I18N_NOOP("Und&o"), 0, "edit-undo" },
74 { KStdGameAction::Redo, TDEStdAccel::Redo, 0, "move_redo", I18N_NOOP("Re&do"), 0, "edit-redo" },
75 { KStdGameAction::Roll, TDEStdAccel::AccelNone, TQt::CTRL+TQt::Key_R, "move_roll", I18N_NOOP("&Roll Dice"), 0, "roll" },
76 { KStdGameAction::EndTurn, TDEStdAccel::AccelNone, 0, "move_end_turn", I18N_NOOP("End Turn"), 0, "endturn" },
77 { KStdGameAction::Hint, TDEStdAccel::AccelNone, TQt::Key_H, "move_hint", I18N_NOOP("&Hint"), 0, "idea" },
78 { KStdGameAction::Demo, TDEStdAccel::AccelNone, TQt::Key_D, "move_demo", I18N_NOOP("&Demo"), 0, "1rightarrow" },
79 { KStdGameAction::Solve, TDEStdAccel::AccelNone, 0, "move_solve", I18N_NOOP("&Solve"), 0, "wizard" },
80// "settings" menu
81 { KStdGameAction::ChooseGameType, TDEStdAccel::AccelNone, 0, "options_choose_game_type", I18N_NOOP("Choose Game &Type"), 0, 0 },
82 { KStdGameAction::Carddecks, TDEStdAccel::AccelNone, 0, "options_configure_carddecks", I18N_NOOP("Configure &Carddecks..."), 0, 0 },
83 { KStdGameAction::ConfigureHighscores, TDEStdAccel::AccelNone, 0, "options_configure_highscores", I18N_NOOP("Configure &Highscores..."), 0, 0 },
84
85 { KStdGameAction::ActionNone, TDEStdAccel::AccelNone, 0, 0, 0, 0, 0 }
86};
87
88static const KStdGameActionInfo* infoPtr( KStdGameAction::StdGameAction id )
89{
90 for (uint i = 0; g_rgActionInfo[i].id!=KStdGameAction::ActionNone; i++) {
91 if( g_rgActionInfo[i].id == id )
92 return &g_rgActionInfo[i];
93 }
94 return 0;
95}
96
97
98TDEAction* KStdGameAction::create(StdGameAction id, const char *name,
99 const TQObject *recvr, const char *slot,
100 TDEActionCollection* parent )
101{
102 TDEAction* pAction = 0;
103 const KStdGameActionInfo* pInfo = infoPtr( id );
104 kdDebug(125) << "KStdGameAction::create( " << id << "=" << (pInfo ? pInfo->psName : (const char*)0) << ", " << parent << ", " << name << " )" << endl;
105 if( pInfo ) {
106 TQString sLabel = i18n(pInfo->psLabel);
107 TDEShortcut cut = (pInfo->globalAccel==TDEStdAccel::AccelNone
108 ? TDEShortcut(pInfo->shortcut)
109 : TDEStdAccel::shortcut(pInfo->globalAccel));
110 const char *n = name ? name : pInfo->psName;
111 switch( id ) {
112 case LoadRecent:
113 pAction =
114 new TDERecentFilesAction(sLabel, cut, recvr, slot, parent, n);
115 break;
116 case Pause:
117 case Demo:
118 pAction = new TDEToggleAction( sLabel, pInfo->psIconName, cut,
119 recvr, slot, parent, n);
120 break;
121 case ChooseGameType:
122 pAction = new TDESelectAction( sLabel, pInfo->psIconName, cut,
123 recvr, slot, parent, n);
124 break;
125 default:
126 pAction = new TDEAction( sLabel, pInfo->psIconName, cut,
127 recvr, slot, parent, n);
128 break;
129 }
130 }
131 return pAction;
132}
133
134const char* KStdGameAction::name( StdGameAction id )
135{
136 const KStdGameActionInfo* pInfo = infoPtr( id );
137 return (pInfo) ? pInfo->psName : 0;
138}
139
140TDEAction *KStdGameAction::gameNew(const TQObject *recvr, const char *slot,
141 TDEActionCollection *parent, const char *name )
142{ return KStdGameAction::create(New, name, recvr, slot, parent); }
143TDEAction *KStdGameAction::load(const TQObject *recvr, const char *slot,
144 TDEActionCollection *parent, const char *name )
145{ return KStdGameAction::create(Load, name, recvr, slot, parent); }
146TDERecentFilesAction *KStdGameAction::loadRecent(const TQObject *recvr, const char *slot,
147 TDEActionCollection *parent, const char *name )
148{ return static_cast<TDERecentFilesAction *>(KStdGameAction::create(LoadRecent, name, recvr, slot, parent)); }
149TDEAction *KStdGameAction::save(const TQObject *recvr, const char *slot,
150 TDEActionCollection *parent, const char *name )
151{ return KStdGameAction::create(Save, name, recvr, slot, parent); }
152TDEAction *KStdGameAction::saveAs(const TQObject *recvr, const char *slot,
153 TDEActionCollection *parent, const char *name )
154{ return KStdGameAction::create(SaveAs, name, recvr, slot, parent); }
155TDEAction *KStdGameAction::end(const TQObject *recvr, const char *slot,
156 TDEActionCollection *parent, const char *name )
157{ return KStdGameAction::create(End, name, recvr, slot, parent); }
158TDEToggleAction *KStdGameAction::pause(const TQObject *recvr, const char *slot,
159 TDEActionCollection *parent, const char *name )
160{ return static_cast<TDEToggleAction *>(KStdGameAction::create(Pause, name, recvr, slot, parent)); }
161TDEAction *KStdGameAction::highscores(const TQObject *recvr, const char *slot,
162 TDEActionCollection *parent, const char *name )
163{ return KStdGameAction::create(Highscores, name, recvr, slot, parent); }
164TDEAction *KStdGameAction::print(const TQObject *recvr, const char *slot,
165 TDEActionCollection *parent, const char *name )
166{ return KStdGameAction::create(Print, name, recvr, slot, parent); }
167TDEAction *KStdGameAction::quit(const TQObject *recvr, const char *slot,
168 TDEActionCollection *parent, const char *name )
169{ return KStdGameAction::create(Quit, name, recvr, slot, parent); }
170
171TDEAction *KStdGameAction::repeat(const TQObject *recvr, const char *slot,
172 TDEActionCollection *parent, const char *name )
173{ return KStdGameAction::create(Repeat, name, recvr, slot, parent); }
174TDEAction *KStdGameAction::undo(const TQObject *recvr, const char *slot,
175 TDEActionCollection *parent, const char *name )
176{ return KStdGameAction::create(Undo, name, recvr, slot, parent); }
177
178TDEAction *KStdGameAction::redo(const TQObject *recvr, const char *slot,
179 TDEActionCollection *parent, const char *name )
180{ return KStdGameAction::create(Redo, name, recvr, slot, parent); }
181
182TDEAction *KStdGameAction::roll(const TQObject *recvr, const char *slot,
183 TDEActionCollection *parent, const char *name )
184{ return KStdGameAction::create(Roll, name, recvr, slot, parent); }
185TDEAction *KStdGameAction::endTurn(const TQObject *recvr, const char *slot,
186 TDEActionCollection *parent, const char *name )
187{ return KStdGameAction::create(EndTurn, name, recvr, slot, parent); }
188
189TDEAction *KStdGameAction::carddecks(const TQObject *recvr, const char *slot,
190 TDEActionCollection *parent, const char *name )
191{ return KStdGameAction::create(Carddecks, name, recvr, slot, parent); }
192TDEAction *KStdGameAction::configureHighscores(const TQObject*recvr, const char *slot,
193 TDEActionCollection *parent, const char *name)
194{ return KStdGameAction::create(ConfigureHighscores, name, recvr, slot, parent); }
195TDEAction *KStdGameAction::hint(const TQObject*recvr, const char *slot,
196 TDEActionCollection *parent, const char *name)
197{ return KStdGameAction::create(Hint, name, recvr, slot, parent); }
198TDEToggleAction *KStdGameAction::demo(const TQObject*recvr, const char *slot,
199 TDEActionCollection *parent, const char *name)
200{ return static_cast<TDEToggleAction *>(KStdGameAction::create(Demo, name, recvr, slot, parent)); }
201TDEAction *KStdGameAction::solve(const TQObject*recvr, const char *slot,
202 TDEActionCollection *parent, const char *name)
203{ return KStdGameAction::create(Solve, name, recvr, slot, parent); }
204TDESelectAction *KStdGameAction::chooseGameType(const TQObject*recvr, const char *slot,
205 TDEActionCollection *parent, const char *name)
206{ return static_cast<TDESelectAction *>(KStdGameAction::create(ChooseGameType, name, recvr, slot, parent)); }
207TDEAction *KStdGameAction::restart(const TQObject*recvr, const char *slot,
208 TDEActionCollection *parent, const char *name)
209{ return KStdGameAction::create(Restart, name, recvr, slot, parent); }
KStdGameAction::quit
static TDEAction * quit(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Quit the game.
Definition: kstdgameaction.cpp:167
KStdGameAction::pause
static TDEToggleAction * pause(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Pause the game.
Definition: kstdgameaction.cpp:158
KStdGameAction::load
static TDEAction * load(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Load a previousely saved game.
Definition: kstdgameaction.cpp:143
KStdGameAction::redo
static TDEAction * redo(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Redo the last move (which has been undone)
Definition: kstdgameaction.cpp:178
KStdGameAction::print
static TDEAction * print(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Print the current screen? Game? Whatever - hardly used in games but there is at least one example (kt...
Definition: kstdgameaction.cpp:164
KStdGameAction::name
static const char * name(StdGameAction id)
This will return the internal name of a given standard action.
Definition: kstdgameaction.cpp:134
KStdGameAction::create
static TDEAction * create(StdGameAction id, const char *name, const TQObject *recvr, const char *slot, TDEActionCollection *parent)
Creates an action corresponding to the KStdAction::StdAction enum.
Definition: kstdgameaction.cpp:98
KStdGameAction::restart
static TDEAction * restart(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Restart game.
Definition: kstdgameaction.cpp:207
KStdGameAction::configureHighscores
static TDEAction * configureHighscores(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Display configure highscores dialog.
Definition: kstdgameaction.cpp:192
KStdGameAction::StdGameAction
StdGameAction
The standard menubar and toolbar actions.
Definition: kstdgameaction.h:54
KStdGameAction::endTurn
static TDEAction * endTurn(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
End the current turn (not the game).
Definition: kstdgameaction.cpp:185
KStdGameAction::action
static TDEAction * action(StdGameAction act_enum, const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Retrieve the action corresponding to the KStdGameAction::StdGameAction enum.
Definition: kstdgameaction.cpp:35
KStdGameAction::repeat
static TDEAction * repeat(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Repeat the last move.
Definition: kstdgameaction.cpp:171
KStdGameAction::gameNew
static TDEAction * gameNew(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Start a new game.
Definition: kstdgameaction.cpp:140
KStdGameAction::roll
static TDEAction * roll(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Roll die or dice.
Definition: kstdgameaction.cpp:182
KStdGameAction::carddecks
static TDEAction * carddecks(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Display configure carddecks dialog.
Definition: kstdgameaction.cpp:189
KStdGameAction::saveAs
static TDEAction * saveAs(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Save the current game under a different filename.
Definition: kstdgameaction.cpp:152
KStdGameAction::highscores
static TDEAction * highscores(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Show the highscores.
Definition: kstdgameaction.cpp:161
KStdGameAction::end
static TDEAction * end(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
End the current game, but do not quit the program.
Definition: kstdgameaction.cpp:155
KStdGameAction::loadRecent
static TDERecentFilesAction * loadRecent(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Load a recently loaded game.
Definition: kstdgameaction.cpp:146
KStdGameAction::chooseGameType
static TDESelectAction * chooseGameType(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Choose game type.
Definition: kstdgameaction.cpp:204
KStdGameAction::solve
static TDEAction * solve(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Solve the game.
Definition: kstdgameaction.cpp:201
KStdGameAction::hint
static TDEAction * hint(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Give an advice/hint.
Definition: kstdgameaction.cpp:195
KStdGameAction::undo
static TDEAction * undo(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Undo the last move.
Definition: kstdgameaction.cpp:174
KStdGameAction::stdName
static const char * stdName(StdGameAction act_enum)
This will return the internal name of a given standard action.
Definition: kstdgameaction.cpp:42
KStdGameAction::demo
static TDEToggleAction * demo(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Show a demo.
Definition: kstdgameaction.cpp:198
KStdGameAction::save
static TDEAction * save(const TQObject *recvr=0, const char *slot=0, TDEActionCollection *parent=0, const char *name=0L)
Save the current game.
Definition: kstdgameaction.cpp:149

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.9.4
This website is maintained by Timothy Pearson.