Newfile_gump.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000 The Exult Team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef NEWFILE_GUMP_H
00020 #define NEWFILE_GUMP_H
00021 
00022 #include "Modal_gump.h"
00023 
00024 class Shape_file;
00025 class Image_buffer;
00026 
00027 #define MAX_SAVEGAME_NAME_LEN 0x50
00028 
00029 struct SaveGame_Details
00030 {
00031   // Time that the game was saved (needed????)
00032   char  real_minute;  // 1
00033   char  real_hour;  // 2
00034   char  real_day; // 3
00035   char  real_month; // 4
00036   short real_year;  // 6
00037 
00038   // The Game Time that the save was done at
00039   char  game_minute;  // 7
00040   char  game_hour;  // 8
00041   short game_day; // 10
00042 
00043   short save_count; // 12
00044   char  party_size; // 13
00045 
00046   char  unused;   // 14 Quite literally unused
00047 
00048   char  real_second;  // 15
00049 
00050   //Incase we want to add more later
00051   char    reserved0;  // 16
00052   char  reserved1[48];  // 64
00053 };
00054 
00055 struct SaveGame_Party
00056 {
00057   char    name[18]; // 18
00058   short   shape;    // 20
00059   unsigned int  exp;    // 24
00060   unsigned int  flags;    // 28
00061   unsigned int  flags2;   // 32
00062 
00063   unsigned char food;   // 33
00064   unsigned char str;    // 34
00065   unsigned char combat;   // 35
00066   unsigned char dext;   // 36
00067   unsigned char intel;    // 37
00068   unsigned char magic;    // 38
00069   unsigned char mana;   // 39
00070   unsigned char training; // 40
00071   short   health;   // 42
00072 
00073   short   shape_file; // 44
00074 
00075   //Incase we want to add more later
00076   int   reserved1;  // 48
00077   int   reserved2;  // 52
00078   int   reserved3;  // 56
00079   int   reserved4;  // 60
00080   int   reserved5;  // 64
00081 };
00082 
00083 /*
00084  *  The file save/load box:
00085  */
00086 class Newfile_gump : public Modal_gump
00087 {
00088   UNREPLICATABLE_CLASS_I(Newfile_gump,Modal_gump(0,0,0,0));
00089 
00090 public:
00091   struct SaveInfo {
00092 
00093     int     num;
00094     char      *filename;
00095     char      *savename;
00096     bool      readable;
00097     SaveGame_Details  *details;
00098     SaveGame_Party    *party;
00099     Shape_file    *screenshot;
00100 
00101     static int    CompareGames(const void *a, const void *b);
00102     int     CompareThis(const SaveInfo *other) const;
00103     void      SetSeqNumber();
00104 
00105     SaveInfo();
00106     ~SaveInfo();
00107 
00108   };
00109 
00110 protected:
00111   Gump_button *buttons[8];  // 2 sets of 4 buttons
00112   static const short btn_cols[5]; // x-coord of each button.
00113   static const short btn_rows[5]; // y-coord of each button.
00114 
00115   // Text field info
00116   static const short fieldx;  // Start Y of each field
00117   static const short fieldy;  // Start X of first
00118   static const short fieldw;  // Width of each field
00119   static const short fieldh;  // Height of each field
00120   static const short fieldgap;  // Gap between fields
00121   static const short fieldcount;  // Number of fields
00122   static const short textx; // X Offset in field
00123   static const short texty; // Y Offset in field
00124   static const short textw; // Maximum allowable width of text
00125   static const short iconx; // X Offset in field
00126   static const short icony; // Y Offset in field
00127 
00128   // Scrollbar and Slider Info
00129   static const short scrollx; // X Offset
00130   static const short scrolly; // Y Offset
00131   static const short scrollh; // Height of Scroll Bar
00132   static const short sliderw; // Width of Slider
00133   static const short sliderh; // Height of Slider
00134 
00135   // Side Text
00136   static const short infox; // X Offset for info
00137   static const short infoy; // Y Offset for info
00138   static const short infow; // Width of info box
00139   static const short infoh; // Height of info box
00140   static const char infostring[]; // Text format for info
00141 
00142   static const char *months[12];  // Names of the months
00143 
00144   unsigned char restored;   // Set to 1 if we restored a game.
00145 
00146   Image_buffer  *back;
00147 
00148   SaveInfo  *games;   // The list of savegames
00149   int   num_games;  // Number of save games
00150   int   first_free; // The number of the first free savegame
00151 
00152   Shape_file *cur_shot;   // Screenshot for current game
00153   SaveGame_Details *cur_details;  // Details of current game
00154   SaveGame_Party *cur_party;  // Party of current game
00155 
00156   // Gamedat is being used as a 'quicksave'
00157   Shape_file *gd_shot;    // Screenshot in Gamedat
00158   SaveGame_Details *gd_details; // Details in Gamedat
00159   SaveGame_Party *gd_party; // Parts in Gamedat
00160 
00161   Shape_file *screenshot;   // The picture to be drawn
00162   SaveGame_Details *details;  // The game details to show
00163   SaveGame_Party *party;    // The party to show
00164   bool is_readable;   // Is the save game readable
00165   const char *filename;   // Filename of the savegame, if exists
00166 
00167   int list_position;    // The position in the savegame list (top game)
00168   int selected;   // The savegame that has been selected (num in list)
00169   int cursor;     // The position of the cursor
00170   int slide_start;    // Pixel (v) where a slide started
00171   char  newname[MAX_SAVEGAME_NAME_LEN]; // The new name for the game
00172    
00173   int BackspacePressed();
00174   int DeletePressed();
00175   int MoveCursor(int count);
00176   int AddCharacter(char c);
00177 
00178   void  LoadSaveGameDetails();  // Loads (and sorts) all the savegame details
00179   void  FreeSaveGameDetails();  // Frees all the savegame details
00180 
00181   void  PaintSaveName (int line);
00182 
00183 public:
00184   Newfile_gump();
00185   ~Newfile_gump();
00186 
00187   void load();      // 'Load' was clicked.
00188   void save();      // 'Save' was clicked.
00189   void delete_file();   // 'Delete' was clicked.
00190 
00191   void scroll_line(int dir);  // Scroll Line Button Pressed
00192   void scroll_page(int dir);  // Scroll Page Button Pressed.
00193   
00194   int restored_game()   // 1 if user restored.
00195     { return restored; }
00196           // Paint it and its contents.
00197   virtual void paint();
00198   virtual void close()
00199     { done = 1; }
00200           // Handle events:
00201   virtual void mouse_down(int mx, int my);
00202   virtual void mouse_up(int mx, int my);
00203   virtual void mouse_drag(int mx, int my);
00204   virtual void text_input(int chr, int unicode); // Character typed.
00205 
00206   virtual void mousewheel_up();
00207   virtual void mousewheel_down();
00208 };
00209 
00210 #endif //NEWFILE_GUMP_H

Generated on Mon Jul 9 14:42:46 2007 for ExultEngine by  doxygen 1.5.1