src/genworld_gui.cpp
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6505 abcb0580d976
child 9906 6f41b8713b65
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
    27 #include "newgrf_config.h"
    27 #include "newgrf_config.h"
    28 
    28 
    29 /**
    29 /**
    30  * In what 'mode' the GenerateLandscapeWindowProc is.
    30  * In what 'mode' the GenerateLandscapeWindowProc is.
    31  */
    31  */
    32 typedef enum glwp_modes {
    32 enum glwp_modes {
    33 	GLWP_GENERATE,
    33 	GLWP_GENERATE,
    34 	GLWP_HEIGHTMAP,
    34 	GLWP_HEIGHTMAP,
    35 	GLWP_SCENARIO,
    35 	GLWP_SCENARIO,
    36 	GLWP_END
    36 	GLWP_END
    37 } glwp_modes;
    37 };
    38 
    38 
    39 static uint _heightmap_x = 0;
    39 static uint _heightmap_x = 0;
    40 static uint _heightmap_y = 0;
    40 static uint _heightmap_y = 0;
    41 static StringID _heightmap_str = STR_NULL;
    41 static StringID _heightmap_str = STR_NULL;
    42 
    42 
   531 	Window *w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
   531 	Window *w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
   532 
   532 
   533 	if (w != NULL) InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
   533 	if (w != NULL) InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
   534 }
   534 }
   535 
   535 
   536 void ShowGenerateLandscape(void)
   536 void ShowGenerateLandscape()
   537 {
   537 {
   538 	_ShowGenerateLandscape(GLWP_GENERATE);
   538 	_ShowGenerateLandscape(GLWP_GENERATE);
   539 }
   539 }
   540 
   540 
   541 void ShowHeightmapLoad(void)
   541 void ShowHeightmapLoad()
   542 {
   542 {
   543 	_ShowGenerateLandscape(GLWP_HEIGHTMAP);
   543 	_ShowGenerateLandscape(GLWP_HEIGHTMAP);
   544 }
   544 }
   545 
   545 
   546 void StartScenarioEditor(void)
   546 void StartScenarioEditor()
   547 {
   547 {
   548 	StartGeneratingLandscape(GLWP_SCENARIO);
   548 	StartGeneratingLandscape(GLWP_SCENARIO);
   549 }
   549 }
   550 
   550 
   551 void StartNewGameWithoutGUI(uint seed)
   551 void StartNewGameWithoutGUI(uint seed)
   724 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
   724 	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
   725 	_create_scenario_widgets,
   725 	_create_scenario_widgets,
   726 	CreateScenarioWndProc,
   726 	CreateScenarioWndProc,
   727 };
   727 };
   728 
   728 
   729 void ShowCreateScenario(void)
   729 void ShowCreateScenario()
   730 {
   730 {
   731 	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
   731 	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
   732 	AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
   732 	AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
   733 }
   733 }
   734 
   734 
   738 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   180,    14,    96, 0x0,                    STR_NULL},
   738 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   180,    14,    96, 0x0,                    STR_NULL},
   739 {    WWT_TEXTBTN,   RESIZE_NONE,    15,    20,   161,    74,    85, STR_GENERATION_ABORT,   STR_NULL}, // Abort button
   739 {    WWT_TEXTBTN,   RESIZE_NONE,    15,    20,   161,    74,    85, STR_GENERATION_ABORT,   STR_NULL}, // Abort button
   740 {   WIDGETS_END},
   740 {   WIDGETS_END},
   741 };
   741 };
   742 
   742 
   743 typedef struct tp_info {
   743 struct tp_info {
   744 	uint percent;
   744 	uint percent;
   745 	StringID cls;
   745 	StringID cls;
   746 	uint current;
   746 	uint current;
   747 	uint total;
   747 	uint total;
   748 	int timer;
   748 	int timer;
   749 } tp_info;
   749 };
   750 
   750 
   751 static tp_info _tp;
   751 static tp_info _tp;
   752 
   752 
   753 static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
   753 static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
   754 {
   754 {
   807 };
   807 };
   808 
   808 
   809 /**
   809 /**
   810  * Initializes the progress counters to the starting point.
   810  * Initializes the progress counters to the starting point.
   811  */
   811  */
   812 void PrepareGenerateWorldProgress(void)
   812 void PrepareGenerateWorldProgress()
   813 {
   813 {
   814 	_tp.cls   = STR_WORLD_GENERATION;
   814 	_tp.cls   = STR_WORLD_GENERATION;
   815 	_tp.current = 0;
   815 	_tp.current = 0;
   816 	_tp.total   = 0;
   816 	_tp.total   = 0;
   817 	_tp.percent = 0;
   817 	_tp.percent = 0;
   819 }
   819 }
   820 
   820 
   821 /**
   821 /**
   822  * Show the window where a user can follow the process of the map generation.
   822  * Show the window where a user can follow the process of the map generation.
   823  */
   823  */
   824 void ShowGenerateWorldProgress(void)
   824 void ShowGenerateWorldProgress()
   825 {
   825 {
   826 	AllocateWindowDescFront(&_show_terrain_progress_desc, 0);
   826 	AllocateWindowDescFront(&_show_terrain_progress_desc, 0);
   827 }
   827 }
   828 
   828 
   829 static void _SetGeneratingWorldProgress(gwp_class cls, uint progress, uint total)
   829 static void _SetGeneratingWorldProgress(gwp_class cls, uint progress, uint total)