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
|
/*
Copyright (C) 2001-2004 Stephane Magnenat & Luc-Olivier de Charrière
for any question or comment contact us at <stephane at magnenat dot net> or <NuageBleu at gmail dot com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __CHOOSE_MAP_SCREEN_H
#define __CHOOSE_MAP_SCREEN_H
#include "MapHeader.h"
#include "GameHeader.h"
#include "Glob2Screen.h"
#include <GUINumber.h>
namespace GAGGUI
{
class Button;
class TextButton;
class Text;
class Number;
class OnOffButton;
}
class Glob2FileList;
class MapPreview;
//! This screen is the basic screen used to selected map and games, Can have an alternate directory if desired
class ChooseMapScreen : public Glob2Screen
{
public:
/// Constructor. Directory is the source of the listed files.
/// extension is the file extension to show. If recurse is true,
/// subdirectoried are shown and can be opened.
ChooseMapScreen(const char *directory, const char *extension, bool recurse, const char* alternateDirectory=NULL, const char* alternateExtension=NULL, const bool alternateRecurse=NULL);
//! Destructor
virtual ~ChooseMapScreen();
virtual void onAction(Widget *source, Action action, int par1, int par2);
/// Returns the mapHeader of the map that is currently selected
MapHeader& getMapHeader();
/// Returns the gameHeader, with all of the customized options,
/// for the currently selected map.
GameHeader& getGameHeader();
enum
{
//! Value returned upon screen execution completion when a valid map/game is selected
OK = 1,
//! Value returned upon screen execution completion when the map/game selection is canceled
CANCEL = 2,
//! Value returned if screen is for games and delete button has been pressed
DELETEGAME = 3,
//! Value returned if screen if the button to switch between games and maps has been pressed
SWITCHTYPE = 4,
};
protected:
/// Handle called when a valid map has been selected.
/// This is to be overwritten by the derived class.
virtual void validMapSelectedhandler(void) { }
/// The map header of the currently selected map
MapHeader mapHeader;
/// The game header of the currently selected map
GameHeader gameHeader;
private:
enum DirectoryMode
{
DisplayRegular,
DisplayAlternate,
} currentDirectoryMode;
//! Title of the screen, depends on the directory given in parameter
Text *title;
//! The ok button
Button *ok;
//! The cancel button
Button *cancel;
//! the delete map button
Button *deleteMap;
//! the switch type button
TextButton *switchType;
//! The list of maps or games
Glob2FileList *fileList;
//! The alternate list of maps or games
Glob2FileList *alternateFileList;
//! The widget that will show a preview of the selection map
MapPreview *mapPreview;
//! The textual informations about the selected map
Text *mapName, *mapInfo, *mapVersion, *mapSize, *mapDate, *varPrestigeText;
//! True when the selected map is valid
bool validMapSelected;
/// Called after a new mapHeader and gameHeader have been loaded.
void updateMapInformation();
/// Designates whether there will be verbose debugging output.
static const bool verbose = false;
};
#endif
|