00001 /* 00002 * hack4u 00003 * Copyright (C) 2004-2006 emuWorks 00004 * http://games.technoplaza.net/ 00005 * 00006 * This file is part of hack4u. 00007 * 00008 * hack4u is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * hack4u is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with hack4u; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 // $Id: MainFrame.hh,v 1.39 2006/03/21 12:00:18 technoplaza Exp $ 00024 00025 #ifndef _MAINFRAME_HH_ 00026 #define _MAINFRAME_HH_ 00027 00028 #include "model/ModelConstants.hh" 00029 00030 namespace hack4u { 00031 class SaveSlot; 00032 class SRAMFile; 00033 00034 /// the possible locations for the location menu 00035 enum Location { 00036 LMOONGLOW, LBRITAIN, LJHELOM, LYEW, LMINOC, LTRINSIC, LSKARABRAE, 00037 LMAGINCIA, LLYCAEUM, LEMPATHABBEY, LSERPENTSHOLD, LPAWS, LVESPER, 00038 LBUCCANEERSDEN, LCOVE 00039 }; 00040 00041 /** 00042 * The main frame of the application. 00043 */ 00044 class MainFrame : public wxFrame { 00045 DECLARE_CLASS(MainFrame) 00046 DECLARE_EVENT_TABLE() 00047 00048 friend class FileDropTarget; 00049 00050 private: 00051 wxCheckBox *itemEquippedCheck[6]; 00052 wxChoice *itemChoice[6]; 00053 wxChoice *memberChoice[4]; 00054 wxString sramFile; 00055 SaveSlot *saveslot; 00056 SRAMFile *sram; 00057 enum Location location; 00058 int gameMenu, locationMenu; 00059 bool ignoreEvents; 00060 bool open; 00061 00062 /// Array of the character class names. 00063 static const wxString CHARACTER_NAMES[]; 00064 00065 /// Array of the names of the eight cities of virtue. 00066 static const wxString CITY_NAMES[]; 00067 00068 /// Array of locations for the balloon 00069 static const std::pair<int, int> BALLOON_LOCATIONS[]; 00070 00071 /// Array of locations for the pirate ships 00072 static const std::pair<int, int> PIRATESHIP_LOCATIONS[]; 00073 00074 /// Array of indicies mapping start locations to choice selection 00075 static const int INN_INDEX[]; 00076 00077 /** 00078 * Sets up the controls for this Frame. 00079 */ 00080 void CreateControls(); 00081 00082 /** 00083 * Sets the equipment value for a particular slot. 00084 * 00085 * @param slot The slot to set (0-5). 00086 */ 00087 void setEquipment(int slot); 00088 00089 /** 00090 * Changes the options for the Felucca moon control depending upon the 00091 * phase of Trammel. 00092 * 00093 * @param trammel The phase of trammel. 00094 */ 00095 void setFeluccaOptions(enum City trammel); 00096 00097 /** 00098 * Checks if an SRAM file is currently open. 00099 * 00100 * @return true if open; false otherwise. 00101 */ 00102 bool isOpen(); 00103 00104 /** 00105 * Checks if a character has valid equipment. 00106 * 00107 * @param character The character. 00108 * 00109 * @return true if valid; false otherwise. 00110 */ 00111 bool hasValidEquipment(enum Character character) const; 00112 00113 /** 00114 * Checks if the current party formation is valid. 00115 * 00116 * @return true if valid; false otherwise. 00117 */ 00118 bool isValidParty() const; 00119 00120 /** 00121 * Closes the current SRAM file. 00122 * 00123 * @return true if closed; false otherwise. 00124 */ 00125 bool close(); 00126 00127 /** 00128 * Loads an SRAM file. 00129 * 00130 * @param filename The SRAM file. 00131 */ 00132 void load(const wxString &filename); 00133 00134 /** 00135 * Loads the game values into the frame controls. 00136 * 00137 * @param game The game number to load (0, 1, or 2). 00138 */ 00139 void loadGame(int game); 00140 00141 /** 00142 * Loads the stats of a particular character into the character tab. 00143 * 00144 * @param character The character. 00145 */ 00146 void loadStats(enum Character character); 00147 00148 /** 00149 * Saves the SRAM to disk. 00150 * 00151 * @param filename The filename to save the SRAM to. 00152 * 00153 * @return true if saved; false otherwise. 00154 */ 00155 bool save(const wxString &filename); 00156 00157 /** 00158 * Callback when the Balloon's location is changed. 00159 * 00160 * @param event The associated command event. 00161 */ 00162 void onBalloonChange(wxCommandEvent &event); 00163 00164 /** 00165 * Callback when one of the characters is selected. 00166 * 00167 * @param event The associated command event. 00168 */ 00169 void onCharacterChange(wxCommandEvent &event); 00170 00171 /** 00172 * Callback when a characters equipment is changed. 00173 * 00174 * @param event The associated command event. 00175 */ 00176 void onEquipmentChange(wxCommandEvent &event); 00177 00178 /** 00179 * Callback when a character's equipped item is changed. 00180 * 00181 * @param event The associated command event. 00182 */ 00183 void onEquippedChange(wxCommandEvent &event); 00184 00185 /** 00186 * Callback to update the equipped checkboxes. 00187 * 00188 * @param event The associated update UI event. 00189 */ 00190 void onEquippedUpdate(wxUpdateUIEvent &event); 00191 00192 /** 00193 * Callback when close is selected from the file menu. 00194 * 00195 * @param event The associated command event. 00196 */ 00197 void onFileClose(wxCommandEvent &event); 00198 00199 /** 00200 * Callback when exit is selected from the file menu. 00201 * 00202 * @param event The associated command event. 00203 */ 00204 void onFileExit(wxCommandEvent &event); 00205 00206 /** 00207 * Callback when open is selected from the file menu. 00208 * 00209 * @param event The associated command event. 00210 */ 00211 void onFileOpen(wxCommandEvent &event); 00212 00213 /** 00214 * Callback when save is selected from the file menu. 00215 * 00216 * @param event The associated command event. 00217 */ 00218 void onFileSave(wxCommandEvent &event); 00219 00220 /** 00221 * Callback when save as is selected from the file menu. 00222 * 00223 * @param event The associated command event. 00224 */ 00225 void onFileSaveAs(wxCommandEvent &event); 00226 00227 /** 00228 * Callback when one of the game menu items are selected. 00229 * 00230 * @param event The associated command event. 00231 */ 00232 void onGameChange(wxCommandEvent &event); 00233 00234 /** 00235 * Callback when the game menu needs updated. 00236 * 00237 * @param event The associated update UI event. 00238 */ 00239 void onGameMenuUpdate(wxUpdateUIEvent &event); 00240 00241 /** 00242 * Callback when the gold amount is changed. 00243 * 00244 * @param event The associated command event. 00245 */ 00246 void onGoldChange(wxCommandEvent &event); 00247 00248 /** 00249 * Callback when about is selected from the help menu. 00250 * 00251 * @param event The associated command event. 00252 */ 00253 void onHelpAbout(wxCommandEvent &event); 00254 00255 /** 00256 * Callback when one of the herbs is changed. 00257 * 00258 * @param event The associated scroll event. 00259 */ 00260 void onHerbChange(wxScrollEvent &event); 00261 00262 /** 00263 * Callback when the hero's name is changed. 00264 * 00265 * @param event The associated command event. 00266 */ 00267 void onHerosNameChange(wxCommandEvent &event); 00268 00269 /** 00270 * Callback when one of the joined members is changed. 00271 * 00272 * @param event The associated command event. 00273 */ 00274 void onJoinedChange(wxCommandEvent &event); 00275 00276 /** 00277 * Callback when balloon is selected from the location menu. 00278 * 00279 * @param event The associated command event. 00280 */ 00281 void onLocationBalloon(wxCommandEvent &event); 00282 00283 /** 00284 * Callback when the location place is changed. 00285 * 00286 * @param event The associated command event. 00287 */ 00288 void onLocationPlaceChange(wxCommandEvent &event); 00289 00290 /** 00291 * Callback when a ship is selected from the location menu. 00292 * 00293 * @param event The associated command event. 00294 */ 00295 void onLocationShip(wxCommandEvent &event); 00296 00297 /** 00298 * Callback when one of the magics is changed. 00299 * 00300 * @param event The associated command event. 00301 */ 00302 void onMagicChange(wxCommandEvent &event); 00303 00304 /** 00305 * Callback when one of the member's classes is changed. 00306 * 00307 * @param event The associated command event. 00308 */ 00309 void onMemberClassChange(wxCommandEvent &event); 00310 00311 /** 00312 * Callback when the party member choices need updated. 00313 * 00314 * @param event The associated update UI event. 00315 */ 00316 void onMemberUpdate(wxUpdateUIEvent &event); 00317 00318 /** 00319 * Callback when one of the moon phases is changed. 00320 * 00321 * @param event The associated command event. 00322 */ 00323 void onPhaseChange(wxCommandEvent &event); 00324 00325 /** 00326 * Callback when one of the runes is changed. 00327 * 00328 * @param event The associated command event. 00329 */ 00330 void onRuneChange(wxCommandEvent &event); 00331 00332 /** 00333 * Callback when the save or close file menu items need updating. 00334 * 00335 * @param event The associated update UI event. 00336 */ 00337 void onSaveCloseUpdate(wxUpdateUIEvent &event); 00338 00339 /** 00340 * Callback when the save as file menu item needs updating. 00341 * 00342 * @param event The associated update UI event. 00343 */ 00344 void onSaveUpdate(wxUpdateUIEvent &event); 00345 00346 /** 00347 * Callback when one the pirate ships is changed. 00348 * 00349 * @param event The associated command event. 00350 */ 00351 void onShipChange(wxCommandEvent &event); 00352 00353 /** 00354 * Callback when the location of a pirate ship is changed. 00355 * 00356 * @param event The associated command event. 00357 */ 00358 void onShipLocationChange(wxCommandEvent &event); 00359 00360 /** 00361 * Callback when a ship location item needs updating. 00362 * 00363 * @param event The associated update UI event. 00364 */ 00365 void onShipUpdate(wxUpdateUIEvent &event); 00366 00367 /** 00368 * Callback when the start location is changed. 00369 * 00370 * @param event The associated command event. 00371 */ 00372 void onStartLocationChange(wxCommandEvent &event); 00373 00374 /** 00375 * Callback when one of the character stats is changed. 00376 * 00377 * @param event The associated command event. 00378 */ 00379 void onStatChange(wxCommandEvent &event); 00380 00381 /** 00382 * Callback when one of the stones is changed. 00383 * 00384 * @param event The associated command event. 00385 */ 00386 void onStoneChange(wxCommandEvent &event); 00387 00388 /** 00389 * Callback when one of the have/have not tools is changed. 00390 * 00391 * @param event The associated command event. 00392 */ 00393 void onToolHaveChange(wxCommandEvent &event); 00394 00395 /** 00396 * Callback when one of the quantity tools is changed. 00397 * 00398 * @param event The associated scroll event. 00399 */ 00400 void onToolQuantityChange(wxScrollEvent &event); 00401 00402 /** 00403 * Callback when one of the virtue values is changed. 00404 * 00405 * @param event The associated scroll event. 00406 */ 00407 void onVirtueChange(wxScrollEvent &event); 00408 00409 /** 00410 * Callback when the whirlpool's location is changed. 00411 * 00412 * @param event The associated command event. 00413 */ 00414 void onWhirlpoolChange(wxCommandEvent &event); 00415 00416 /** 00417 * Callback when the window is closing. 00418 * 00419 * @param event The associated close event. 00420 */ 00421 void onWindowClosing(wxCloseEvent &event); 00422 00423 public: 00424 /** 00425 * Constructor for the MainFrame. 00426 */ 00427 MainFrame(); 00428 }; 00429 00430 inline bool MainFrame::isOpen() { return open; } 00431 inline void MainFrame::onCharacterChange(wxCommandEvent &event) 00432 { loadStats(static_cast<enum Character>(event.GetSelection())); } 00433 inline void MainFrame::onFileClose(wxCommandEvent &) { close(); } 00434 inline void MainFrame::onFileSave(wxCommandEvent &) { save(sramFile); } 00435 inline void MainFrame::onSaveCloseUpdate(wxUpdateUIEvent &event) 00436 { event.Enable(isOpen()); } 00437 } 00438 00439 #endif 00440