Changeset - r11516:e0a9123a8cce
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2009-03-28 16:35:33
alberth@openttd.org
(svn r15882) -Codechange: New widgets for generation progress window.
1 file changed with 18 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/genworld_gui.cpp
Show inline comments
 
@@ -886,67 +886,77 @@ static const WindowDesc _create_scenario
 
	WDP_CENTER, WDP_CENTER, 338, 170, 338, 170,
 
	WC_GENERATE_LANDSCAPE, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
 
	_create_scenario_widgets
 
);
 

	
 
void ShowCreateScenario()
 
{
 
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
 
	new CreateScenarioWindow(&_create_scenario_desc, GLWP_SCENARIO);
 
}
 

	
 
enum GenerationProgressWindowWidgets {
 
	GPWW_CAPTION,
 
	GPWW_BACKGROUND,
 
	GPWW_ABORT,
 
};
 

	
 
static const Widget _generate_progress_widgets[] = {
 
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    0,   180,     0,    13, STR_GENERATION_WORLD,   STR_018C_WINDOW_TITLE_DRAG_THIS}, // GPWW_CAPTION
 
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,    0,   180,    14,    96, 0x0,                    STR_NULL},                        // GPWW_BACKGROUND
 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_WHITE,  20,   161,    74,    85, STR_GENERATION_ABORT,   STR_NULL},                        // GPWW_ABORT
 
{   WIDGETS_END},
 
};
 

	
 
static const NWidgetPart _nested_generate_progress_widgets[] = {
 
	NWidget(WWT_CAPTION, COLOUR_GREY, GPWW_CAPTION), SetDataTip(STR_GENERATION_WORLD, STR_018C_WINDOW_TITLE_DRAG_THIS),
 
	NWidget(WWT_PANEL, COLOUR_GREY, GPWW_BACKGROUND),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 60),
 
		NWidget(NWID_HORIZONTAL), SetPIP(20, 0, 19),
 
			NWidget(WWT_TEXTBTN, COLOUR_WHITE, GPWW_ABORT), SetMinimalSize(142, 12), SetDataTip(STR_GENERATION_ABORT, STR_NULL),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 11),
 
	EndContainer(),
 
};
 

	
 

	
 
static const WindowDesc _generate_progress_desc(
 
	WDP_CENTER, WDP_CENTER, 181, 97, 181, 97,
 
	WC_GENERATE_PROGRESS_WINDOW, WC_NONE,
 
	WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
 
	_generate_progress_widgets
 
	_generate_progress_widgets, _nested_generate_progress_widgets, lengthof(_nested_generate_progress_widgets)
 
);
 

	
 
struct tp_info {
 
	uint percent;
 
	StringID cls;
 
	uint current;
 
	uint total;
 
	int timer;
 
};
 

	
 
static tp_info _tp;
 

	
 
static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
 
{
 
	if (confirmed) {
 
		AbortGeneratingWorld();
 
	} else if (IsGeneratingWorld() && !IsGeneratingWorldAborted()) {
 
		SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
 
	}
 
}
 

	
 
struct GenerateProgressWindow : public Window {
 
private:
 
	enum GenerationProgressWindowWidgets {
 
		GPWW_CAPTION,
 
		GPWW_BACKGROUND,
 
		GPWW_ABORT,
 
	};
 

	
 
public:
 
	GenerateProgressWindow() : Window(&_generate_progress_desc)
 
	{
 
		this->FindWindowPlacementAndResize(&_generate_progress_desc);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case GPWW_ABORT:
 
				if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
 
				ShowQuery(
 
					STR_GENERATION_ABORT_CAPTION,
0 comments (0 inline, 0 general)