mirror of https://github.com/OpenTTD/OpenTTD
(svn r13132) -Codechange: make a class of the GenerateProgressWindow.
parent
5b54c9e373
commit
5199f5ff47
|
@ -811,13 +811,21 @@ void ShowCreateScenario()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const Widget _show_terrain_progress_widgets[] = {
|
static const Widget _generate_progress_widgets[] = {
|
||||||
{ WWT_CAPTION, RESIZE_NONE, 14, 0, 180, 0, 13, STR_GENERATION_WORLD, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, RESIZE_NONE, 14, 0, 180, 0, 13, STR_GENERATION_WORLD, STR_018C_WINDOW_TITLE_DRAG_THIS}, // GPWW_CAPTION
|
||||||
{ WWT_PANEL, RESIZE_NONE, 14, 0, 180, 14, 96, 0x0, STR_NULL},
|
{ WWT_PANEL, RESIZE_NONE, 14, 0, 180, 14, 96, 0x0, STR_NULL}, // GPWW_BACKGROUND
|
||||||
{ WWT_TEXTBTN, RESIZE_NONE, 15, 20, 161, 74, 85, STR_GENERATION_ABORT, STR_NULL}, // Abort button
|
{ WWT_TEXTBTN, RESIZE_NONE, 15, 20, 161, 74, 85, STR_GENERATION_ABORT, STR_NULL}, // GPWW_ABORT
|
||||||
{ WIDGETS_END},
|
{ WIDGETS_END},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
struct tp_info {
|
struct tp_info {
|
||||||
uint percent;
|
uint percent;
|
||||||
StringID cls;
|
StringID cls;
|
||||||
|
@ -837,29 +845,39 @@ static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowTerrainProgressProc(Window* w, WindowEvent* e)
|
struct GenerateProgressWindow : public Window {
|
||||||
|
private:
|
||||||
|
enum GenerationProgressWindowWidgets {
|
||||||
|
GPWW_CAPTION,
|
||||||
|
GPWW_BACKGROUND,
|
||||||
|
GPWW_ABORT,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
GenerateProgressWindow() : Window(&_generate_progress_desc) {};
|
||||||
|
|
||||||
|
virtual void OnClick(Point pt, int widget)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (widget) {
|
||||||
case WE_CLICK:
|
case GPWW_ABORT:
|
||||||
switch (e->we.click.widget) {
|
|
||||||
case 2:
|
|
||||||
if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
|
if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
|
||||||
ShowQuery(
|
ShowQuery(
|
||||||
STR_GENERATION_ABORT_CAPTION,
|
STR_GENERATION_ABORT_CAPTION,
|
||||||
STR_GENERATION_ABORT_MESSAGE,
|
STR_GENERATION_ABORT_MESSAGE,
|
||||||
w,
|
this,
|
||||||
AbortGeneratingWorldCallback
|
AbortGeneratingWorldCallback
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
|
||||||
case WE_PAINT:
|
virtual void OnPaint()
|
||||||
DrawWindowWidgets(w);
|
{
|
||||||
|
DrawWindowWidgets(this);
|
||||||
|
|
||||||
/* Draw the % complete with a bar and a text */
|
/* Draw the % complete with a bar and a text */
|
||||||
DrawFrameRect(19, 20, (w->width - 18), 37, 14, FR_BORDERONLY);
|
DrawFrameRect(19, 20, (this->width - 18), 37, 14, FR_BORDERONLY);
|
||||||
DrawFrameRect(20, 21, (int)((w->width - 40) * _tp.percent / 100) + 20, 36, 10, FR_NONE);
|
DrawFrameRect(20, 21, (int)((this->width - 40) * _tp.percent / 100) + 20, 36, 10, FR_NONE);
|
||||||
SetDParam(0, _tp.percent);
|
SetDParam(0, _tp.percent);
|
||||||
DrawStringCentered(90, 25, STR_PROGRESS, TC_FROMSTRING);
|
DrawStringCentered(90, 25, STR_PROGRESS, TC_FROMSTRING);
|
||||||
|
|
||||||
|
@ -871,17 +889,8 @@ static void ShowTerrainProgressProc(Window* w, WindowEvent* e)
|
||||||
SetDParam(1, _tp.total);
|
SetDParam(1, _tp.total);
|
||||||
DrawStringCentered(90, 58, STR_GENERATION_PROGRESS, TC_FROMSTRING);
|
DrawStringCentered(90, 58, STR_GENERATION_PROGRESS, TC_FROMSTRING);
|
||||||
|
|
||||||
w->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static const WindowDesc _show_terrain_progress_desc = {
|
|
||||||
WDP_CENTER, WDP_CENTER, 181, 97, 181, 97,
|
|
||||||
WC_GENERATE_PROGRESS_WINDOW, WC_NONE,
|
|
||||||
WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
||||||
_show_terrain_progress_widgets,
|
|
||||||
ShowTerrainProgressProc
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -901,7 +910,8 @@ void PrepareGenerateWorldProgress()
|
||||||
*/
|
*/
|
||||||
void ShowGenerateWorldProgress()
|
void ShowGenerateWorldProgress()
|
||||||
{
|
{
|
||||||
AllocateWindowDescFront<Window>(&_show_terrain_progress_desc, 0);
|
if (BringWindowToFrontById(WC_GENERATE_PROGRESS_WINDOW, 0)) return;
|
||||||
|
new GenerateProgressWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _SetGeneratingWorldProgress(gwp_class cls, uint progress, uint total)
|
static void _SetGeneratingWorldProgress(gwp_class cls, uint progress, uint total)
|
||||||
|
|
Loading…
Reference in New Issue