clean some stuff, fix some bugs
[exterlulz-kokomonds.git] / src / GameController.h
blobb6d7091ce5c9e248b0012caed5da299ed1fb9f1f
1 /* ----====----====----====----====----====----====----====----====----====----
2 GameController.h (jeweltoy)
4 JewelToy is a simple game played against the clock.
5 Copyright (C) 2001 Giles Williams
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 ----====----====----====----====----====----====----====----====----====---- */
22 /* kokomonds is a fork of JewelToy.
23 * repository: http://github.com/exterlulz/kokomonds
26 // TODO: clean
28 #import <Cocoa/Cocoa.h>
30 // TODO: replace with enum
31 #define GAMESTATE_GAMEOVER 1
32 #define GAMESTATE_AWAITINGFIRSTCLICK 2
33 #define GAMESTATE_AWAITINGSECONDCLICK 3
34 #define GAMESTATE_FRACULATING 4
35 #define GAMESTATE_SWAPPING 5
36 #define GAMESTATE_FADING 6
37 #define GAMESTATE_FALLING 7
38 #define GAMESTATE_UNSWAPPING 8
39 #define GAMESTATE_EXPLODING 9
40 #define GAMESTATE_FINISHEDFRACULATING 10
42 #define GEM_GRAPHIC_SIZE 48
43 #define GEM_MOVE_SPEED 6
45 #define GEMS_FOR_BONUS 100.0
46 #define SPEED_LIMIT 5000
48 #define TIMER_INTERVAL 0.04
50 @class Game, GameView, MyTimerView;
52 @interface GameController : NSObject
54 IBOutlet NSPanel *aboutPanel, *prefsPanel;
55 IBOutlet GameView *gameView;
56 IBOutlet NSButton *prefsStandardGraphicsButton, *prefsAlternateGraphicsButton;
57 IBOutlet NSImageView *prefsAlternateGraphicsImageView;
58 IBOutlet NSButton *prefsCustomBackgroundCheckbox, *prefsSelectFolderButton;
59 IBOutlet NSTextField *prefsCustomBackgroundFolderTextField;
60 IBOutlet NSImageView *iv1, *iv2, *iv3, *iv4, *iv5, *iv6, *iv7;
61 IBOutlet NSButton *easyGameButton, *hardGameButton, *toughGameButton;
62 IBOutlet NSMenuItem *easyGameMenuItem, *hardGameMenuItem, *toughGameMenuItem;
63 IBOutlet NSButton *abortGameButton, *pauseGameButton, *muteButton;
64 IBOutlet NSMenuItem *abortGameMenuItem, *pauseGameMenuItem, *muteMenuItem;
65 IBOutlet NSMenuItem *freePlayMenuItem, *showHighScoresMenuItem, *resetHighScoresMenuItem;
66 IBOutlet NSTextField *scoreTextField, *bonusTextField;
67 IBOutlet MyTimerView *timerView;
68 IBOutlet NSWindow *gameWindow;
69 IBOutlet NSPanel *hiScorePanel;
70 IBOutlet NSTextField *hiScorePanelScoreTextField, *hiScorePanelNameTextField;
72 NSLock *animationTimerLock;
74 NSArray *hiScores;
75 NSMutableArray *gameScores, *gameNames;
77 int *hintTimeSeconds;
79 NSString *noMoreMovesString, *jeweltoyStartString, *gameOverString;
80 NSImage *titleImage;
82 BOOL abortGame;
83 NSTimer *timer;
84 Game *game;
85 int gameLevel;
86 float gameSpeed;
87 float gameTime;
88 int gemMoveSpeed, gemMoveSteps, gemMoveSize;
90 BOOL useAlternateGraphics, useImportedGraphics, useCustomBackgrounds;
91 BOOL paused, freePlay, muted, animationStatus;
93 NSString *customBackgroundFolderPath;
95 int gameState, gemsSoFar, chx1, chy1, chx2, chy2;
96 SEL whatNext;
99 - (id) init;
100 - (void) dealloc;
102 - (void)awakeFromNib;
104 - (void)windowWillClose:(NSNotification *)aNotification;
105 - (IBAction)prefsGraphicDropAction:(id)sender;
106 - (IBAction)prefsCustomBackgroundCheckboxAction:(id)sender;
107 - (IBAction)prefsSelectFolderButtonAction:(id)sender;
109 - (BOOL) validateMenuItem: (NSMenuItem*) aMenuItem;
111 - (IBAction)startNewGame:(id)sender;
112 - (IBAction)abortGame:(id)sender;
113 - (IBAction)receiveHiScoreName:(id)sender;
114 - (IBAction)togglePauseMode:(id)sender;
115 - (IBAction)toggleMute:(id)sender;
116 - (IBAction)orderFrontAboutPanel:(id)sender;
117 - (IBAction)orderFrontPreferencesPanel:(id)sender;
118 - (IBAction)showHighScores:(id)sender;
119 - (IBAction)resetHighScores:(id)sender;
121 - (NSArray *)makeBlankHiScoresWith:(NSArray *)oldScores;
123 - (void)runOutOfTime;
124 - (void)checkHiScores;
125 - (void)bonusAwarded;
127 - (void)startAnimation:(SEL)andThenSelector;
128 - (void)animationEnded;
130 - (void)waitForNewGame;
131 - (void)newBoard1;
132 - (void)newBoard2;
133 - (void)waitForFirstClick;
134 - (void)receiveClickAt:(int)x:(int)y;
135 - (void)tryMoveSwapping:(int)x1:(int)y1 and:(int)x2:(int)y2;
136 // test for threes
137 - (void)testForThrees;
138 // if there are threes:
140 //// repeat: remove threes
141 - (void)removeThreesAndReplaceGems;
142 //// replace gems
143 - (void)testForThreesAgain;
144 //// test for threes
145 //// until there are no threes
146 - (void)unSwap;
147 // else swap them back
149 - (int) gameState;
150 - (BOOL) gameIsPaused;
151 - (BOOL) useCustomBackgrounds;
152 - (NSPoint) crossHair1Position;
153 - (NSPoint) crossHair2Position;
154 @end