Changeset - r11500:817525332fdf
[Not reviewed]
master
0 1 0
yexo - 16 years ago 2009-03-28 02:11:41
yexo@openttd.org
(svn r15866) -Codechange: New widgets for the difficulty window.
1 file changed with 54 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/settings_gui.cpp
Show inline comments
 
@@ -373,83 +373,120 @@ static const WindowDesc _game_options_de
 
	_game_options_widgets
 
);
 

	
 

	
 
void ShowGameOptions()
 
{
 
	DeleteWindowById(WC_GAME_OPTIONS, 0);
 
	new GameOptionsWindow(&_game_options_desc);
 
}
 

	
 
extern void StartupEconomy();
 

	
 

	
 
/* Names of the game difficulty settings window */
 
enum GameDifficultyWidgets {
 
	GDW_CLOSEBOX = 0,
 
	GDW_CAPTION,
 
	GDW_UPPER_BG,
 
	GDW_LVL_EASY,
 
	GDW_LVL_MEDIUM,
 
	GDW_LVL_HARD,
 
	GDW_LVL_CUSTOM,
 
	GDW_HIGHSCORE,
 
	GDW_SETTING_BG,
 
	GDW_LOWER_BG,
 
	GDW_ACCEPT,
 
	GDW_CANCEL,
 
};
 

	
 
/* Widget definition for the game difficulty settings window */
 
static const Widget _game_difficulty_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_MAUVE,      0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},           // GDW_CLOSEBOX
 
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_MAUVE,     11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS}, // GDW_CAPTION
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_MAUVE,      0,   369,    14,    41, 0x0,                          STR_NULL},                        // GDW_UPPER_BG
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_YELLOW,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},                        // GDW_LVL_EASY
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_YELLOW,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},                        // GDW_LVL_MEDIUM
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_YELLOW,   184,   270,    16,    27, STR_6803_HARD,                STR_NULL},                        // GDW_LVL_HARD
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_YELLOW,   271,   357,    16,    27, STR_6804_CUSTOM,              STR_NULL},                        // GDW_LVL_CUSTOM
 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREEN,     10,   357,    28,    39, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL},                        // GDW_HIGHSCORE
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_MAUVE,      0,   369,    42,   262, 0x0,                          STR_NULL},                        // GDW_SETTING_BG
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_MAUVE,      0,   369,   263,   278, 0x0,                          STR_NULL},                        // GDW_LOWER_BG
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_YELLOW,   105,   185,   265,   276, STR_OPTIONS_SAVE_CHANGES,     STR_NULL},                        // GDW_ACCEPT
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_YELLOW,   186,   266,   265,   276, STR_012E_CANCEL,              STR_NULL},                        // GDW_CANCEL
 
{   WIDGETS_END},
 
};
 

	
 
static const NWidgetPart _nested_game_difficulty_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_MAUVE, GDW_CLOSEBOX),
 
		NWidget(WWT_CAPTION, COLOUR_MAUVE, GDW_CAPTION), SetMinimalSize(359, 14), SetDataTip(STR_6800_DIFFICULTY_LEVEL, STR_018C_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE, GDW_UPPER_BG),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(10, 0),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, GDW_LVL_EASY), SetMinimalSize(87, 12), SetDataTip(STR_6801_EASY, STR_NULL),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, GDW_LVL_MEDIUM), SetMinimalSize(87, 12), SetDataTip(STR_6802_MEDIUM, STR_NULL),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, GDW_LVL_HARD), SetMinimalSize(87, 12), SetDataTip(STR_6803_HARD, STR_NULL),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, GDW_LVL_CUSTOM), SetMinimalSize(87, 12), SetDataTip(STR_6804_CUSTOM, STR_NULL),
 
			NWidget(NWID_SPACER), SetMinimalSize(12, 0),
 
		EndContainer(),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(10, 0),
 
			NWidget(WWT_TEXTBTN, COLOUR_GREEN, GDW_HIGHSCORE), SetMinimalSize(348, 12), SetDataTip(STR_6838_SHOW_HI_SCORE_CHART, STR_NULL),
 
			NWidget(NWID_SPACER), SetMinimalSize(12, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE, GDW_SETTING_BG), SetMinimalSize(370, 221),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_MAUVE, GDW_LOWER_BG),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(105, 0),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, GDW_ACCEPT), SetMinimalSize(81, 12), SetDataTip(STR_OPTIONS_SAVE_CHANGES, STR_NULL),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, GDW_CANCEL), SetMinimalSize(81, 12), SetDataTip(STR_012E_CANCEL, STR_NULL),
 
			NWidget(NWID_SPACER), SetMinimalSize(103, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
	EndContainer(),
 
};
 

	
 
/* Window definition for the game difficulty settings window */
 
static const WindowDesc _game_difficulty_desc(
 
	WDP_CENTER, WDP_CENTER, 370, 279, 370, 279,
 
	WC_GAME_OPTIONS, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	_game_difficulty_widgets
 
	_game_difficulty_widgets, _nested_game_difficulty_widgets, lengthof(_nested_game_difficulty_widgets)
 
);
 

	
 
void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
 

	
 
struct GameDifficultyWindow : public Window {
 
private:
 
	static const uint GAME_DIFFICULTY_NUM = 18;
 
	bool clicked_increase;
 
	uint8 clicked_button;
 
	uint8 timeout;
 

	
 
	/* Temporary holding place of values in the difficulty window until 'Save' is clicked */
 
	GameSettings opt_mod_temp;
 

	
 
	enum {
 
		GAMEDIFF_WND_TOP_OFFSET = 45,
 
		GAMEDIFF_WND_ROWSIZE    = 9,
 
		NO_SETTINGS_BUTTON = 0xFF,
 
	};
 

	
 
	/* Names of the game difficulty settings window */
 
	enum GameDifficultyWidgets {
 
		GDW_CLOSEBOX = 0,
 
		GDW_CAPTION,
 
		GDW_UPPER_BG,
 
		GDW_LVL_EASY,
 
		GDW_LVL_MEDIUM,
 
		GDW_LVL_HARD,
 
		GDW_LVL_CUSTOM,
 
		GDW_HIGHSCORE,
 
		GDW_SETTING_BG,
 
		GDW_LOWER_BG,
 
		GDW_ACCEPT,
 
		GDW_CANCEL,
 
	};
 

	
 
public:
 
	GameDifficultyWindow() : Window(&_game_difficulty_desc)
 
	{
 
		/* Copy current settings (ingame or in intro) to temporary holding place
 
		 * change that when setting stuff, copy back on clicking 'OK' */
 
		this->opt_mod_temp = (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
 
		this->clicked_increase = false;
 
		this->clicked_button = NO_SETTINGS_BUTTON;
 
		this->timeout = 0;
 
		/* Hide the closebox to make sure that the user aborts or confirms his changes */
 
		this->HideWidget(GDW_CLOSEBOX);
 
		this->widget[GDW_CAPTION].left = 0;
0 comments (0 inline, 0 general)