summaryrefslogtreecommitdiffstats
path: root/kgoldrunner/src/kgoldrunner.h
blob: d96fd707f69323494569c4c95a6d31dc64fea4c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
 * Copyright (C) 2003 Ian Wadham and Marco Krüger <ianw2@optusnet.com.au>
 */

#ifndef _KGOLDRUNNER_H_
#define _KGOLDRUNNER_H_

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// Status bar
const int ID_LIVES      = 0;            // Field IDs in KDE status bar.
const int ID_SCORE      = 1;
const int ID_LEVEL      = 2;
const int ID_HINTAVL    = 3;
const int ID_MSG        = 4;

const int L_LIVES       = 15;		// Lengths of fields.
const int L_SCORE       = 17;
const int L_LEVEL       = 15;

#include <kapplication.h>
#include <kmainwindow.h>
#include <kstandarddirs.h>
#include <kaction.h>

class KGrGame;
class KGrCanvas;
class KGrHero;

/**
 * This class serves as the main window for KGoldrunner.  It handles the
 * menus, toolbars, and status bars.
 *
 * @short Main window class
 * @author $AUTHOR <$EMAIL>
 * @version $APP_VERSION
 */
class KGoldrunner : public TDEMainWindow
{
    Q_OBJECT
  
public:
    /**
     * Default Constructor
     */
    KGoldrunner();

    /**
     * Default Destructor
     */
    virtual ~KGoldrunner();

    bool startedOK() {return (startupOK);}

protected:
    /**
     * This function is called when it is time for the app to save its
     * properties for session management purposes.
     */
    void saveProperties(TDEConfig *);

    /**
     * This function is called when this app is restored.  The TDEConfig
     * object points to the session management config file that was saved
     * with @ref saveProperties.
     */
    void readProperties(TDEConfig *);

    bool queryClose ();		// To save edits before closing.

private slots:
    // Slot to pause or restart the game.
    void stopStart();

    // Local slots to create or edit game information.
    void createGame();
    void editGameInfo();

    // Local slots to set the landscape (colour scheme).
    void lsKGoldrunner();
    void lsApple2();
    void lsIceCave();
    void lsMidnight();
    void lsKDEKool();

    // Local slots to set mouse/keyboard control of the hero.
    void setMouseMode();
    void setKeyBoardMode();

    // Local slots to set game speed.
    void normalSpeed();
    void beginSpeed();
    void champSpeed();
    void incSpeed();
    void decSpeed();

    // Slots to set Traditional or KGoldrunner rules.
    void setTradRules();
    void setKGrRules();

    // Local slots to make playing area larger or smaller.
    void makeLarger();
    void makeSmaller();

    // Local slots for hero control keys.
    void goUp();
    void goR();
    void goDown();
    void goL();
    void stop();
    void digR();
    void digL();

    void setKey (KBAction movement);

    // Local slots for authors' debugging aids.
    void showEnemy0();
    void showEnemy1();
    void showEnemy2();
    void showEnemy3();
    void showEnemy4();
    void showEnemy5();
    void showEnemy6();

    void optionsShowToolbar();
    void optionsShowStatusbar();
    void optionsConfigureKeys();
    void optionsConfigureToolbars();
    void optionsPreferences();
    void newToolbarConfig();

    void changeStatusbar(const TQString& text);
    void changeCaption(const TQString& text);

    void showLevel (int);		// Show the current level number.
    void showLives (long);		// Show how many lives are remaining.
    void showScore (long);		// Show the player's score.
    void gameFreeze (bool);		// Status feedback on freeze/unfreeze.

    void adjustHintAction (bool);	// Enable/disable "Hint" action.
    void markRuleType (char ruleType);	// Check game's rule type in the menu.
    void setEditMenu (bool on_off);	// Enable/disable "Save Edits" action.

private:
    void setupAccel();
    void setupActions();
    void initStatusBar();
    void makeEditToolbar();
    void setButton (int btn);

private:
    bool startupOK;

    KGrCanvas *	view;
    KGrGame *	game;

    bool getDirectories();		// Get directory paths, as below.
    TQString systemHTMLDir;		// Where the manual is stored.
    TQString systemDataDir;		// Where the system levels are stored.
    TQString userDataDir;		// Where the user levels are stored.

    TDEAction *		saveGame;	// Save game, level, lives and score.

    TDEAction *		myPause;	// Pause or resume the game.
    TQString		pauseKeys;	// Keystroke names to put in status bar.

    TDEAction *		hintAction;	// Display a hint, if available.
    TDEAction *		killHero;	// Kill hero (disabled during edits).
    TDEAction *		highScore;	// High scores (disabled during edits).

    TDEAction *		saveEdits;	// Save a level that has been edited.

    TDERadioAction *	setKGoldrunner;	// Show default "KGoldrunner" landscape.
    TDERadioAction *	setAppleII;	// Show "Apple II" landscape.
    TDERadioAction *	setIceCave;	// Show "Ice Cave" landscape.
    TDERadioAction *	setMidnight;	// Show "Midnight" landscape.
    TDERadioAction *	setKDEKool;	// Show "KDE Kool" landscape.

    TDERadioAction *	setMouse;	// Show mouse/keyboard mode on menu.
    TDERadioAction *	setKeyboard;	// Show mouse/keyboard mode on menu.

    TDERadioAction *	tradRules;	// Set Traditional rules.
    TDERadioAction *	kgrRules;	// Set KGoldrunner rules.

    KGrHero *	hero;			// Pointer to the hero.

    // TDEToggleAction *	m_toolbarAction;
    // TDEToggleAction *	m_statusbarAction;

    TDEToolBar *		editToolbar;	// Toolbar for creating/editing levels.
    int			pressedButton;	// ID of currently set toolbar button.

private slots:
    void freeSlot();			// Set editObj to Free Space.
    void edheroSlot();			// Set editObj to Hero.
    void edenemySlot();			// Set editObj to Enemy.
    void brickSlot();			// Set editObj to Brick.
    void betonSlot();			// Set editObj to Concrete.
    void fbrickSlot();			// Set editObj to Fall-through Brick.
    void ladderSlot();			// Set editObj to Ladder.
    void hladderSlot();			// Set editObj to Hidden Ladder.
    void poleSlot();			// Set editObj to Pole (or Bar).
    void nuggetSlot();			// Set editObj to Gold Nugget.
    void defaultEditObj();		// Set editObj to default (brick).
};

#endif // _KGOLDRUNNER_H_