|
@@ -55,40 +55,40 @@ struct EndGameHighScoreBaseWindow : Wind
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** Return the coordinate of the screen such that a window of 640x480 is centered at the screen. */
|
|
|
Point GetTopLeft(int x, int y)
|
|
|
{
|
|
|
Point pt = {std::max(0, (_screen.width / 2) - (x / 2)), std::max(0, (_screen.height / 2) - (y / 2))};
|
|
|
return pt;
|
|
|
}
|
|
|
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
|
|
{
|
|
|
delete this;
|
|
|
this->Close();
|
|
|
}
|
|
|
|
|
|
EventState OnKeyPress(WChar key, uint16 keycode) override
|
|
|
{
|
|
|
/* All keys are 'handled' by this window but we want to make
|
|
|
* sure that 'quit' still works correctly. Not handling the
|
|
|
* quit key is enough so the main toolbar can handle it. */
|
|
|
if (IsQuitKey(keycode)) return ES_NOT_HANDLED;
|
|
|
|
|
|
switch (keycode) {
|
|
|
/* Keys for telling we want to go on */
|
|
|
case WKC_RETURN:
|
|
|
case WKC_ESC:
|
|
|
case WKC_SPACE:
|
|
|
delete this;
|
|
|
this->Close();
|
|
|
return ES_HANDLED;
|
|
|
|
|
|
default:
|
|
|
/* We want to handle all keys; we don't want windows in
|
|
|
* the background to open. Especially the ones that do
|
|
|
* locate themselves based on the status-/toolbars. */
|
|
|
return ES_HANDLED;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/** End game window shown at the end of the game */
|
|
@@ -113,28 +113,29 @@ struct EndGameWindow : EndGameHighScoreB
|
|
|
this->window_number = SP_MULTIPLAYER;
|
|
|
this->rank = SaveHighScoreValueNetwork();
|
|
|
} else {
|
|
|
/* in singleplayer mode _local company is always valid */
|
|
|
const Company *c = Company::Get(_local_company);
|
|
|
this->window_number = SP_CUSTOM;
|
|
|
this->rank = SaveHighScoreValue(c);
|
|
|
}
|
|
|
|
|
|
MarkWholeScreenDirty();
|
|
|
}
|
|
|
|
|
|
~EndGameWindow()
|
|
|
void Close() override
|
|
|
{
|
|
|
if (!_networking) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause
|
|
|
ShowHighscoreTable(this->window_number, this->rank);
|
|
|
this->EndGameHighScoreBaseWindow::Close();
|
|
|
}
|
|
|
|
|
|
void OnPaint() override
|
|
|
{
|
|
|
this->SetupHighScoreEndWindow();
|
|
|
Point pt = this->GetTopLeft(ScaleGUITrad(640), ScaleGUITrad(480));
|
|
|
|
|
|
const Company *c = Company::GetIfValid(_local_company);
|
|
|
if (c == nullptr) return;
|
|
|
|
|
|
/* We need to get performance from last year because the image is shown
|
|
|
* at the start of the new year when these things have already been copied */
|
|
@@ -160,29 +161,31 @@ struct HighScoreWindow : EndGameHighScor
|
|
|
this->game_paused_by_player = _pause_mode == PM_PAUSED_NORMAL;
|
|
|
if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
|
|
|
|
|
|
/* Close all always on-top windows to get a clean screen */
|
|
|
if (_game_mode != GM_MENU) HideVitalWindows();
|
|
|
|
|
|
MarkWholeScreenDirty();
|
|
|
this->window_number = difficulty; // show highscore chart for difficulty...
|
|
|
this->background_img = SPR_HIGHSCORE_CHART_BEGIN; // which background to show
|
|
|
this->rank = ranking;
|
|
|
}
|
|
|
|
|
|
~HighScoreWindow()
|
|
|
void Close() override
|
|
|
{
|
|
|
if (_game_mode != GM_MENU) ShowVitalWindows();
|
|
|
|
|
|
if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause
|
|
|
|
|
|
this->EndGameHighScoreBaseWindow::Close();
|
|
|
}
|
|
|
|
|
|
void OnPaint() override
|
|
|
{
|
|
|
const HighScore *hs = _highscore_table[this->window_number];
|
|
|
|
|
|
this->SetupHighScoreEndWindow();
|
|
|
Point pt = this->GetTopLeft(ScaleGUITrad(640), ScaleGUITrad(480));
|
|
|
|
|
|
SetDParam(0, _settings_game.game_creation.ending_year);
|
|
|
DrawStringMultiLine(pt.x + ScaleGUITrad(70), pt.x + ScaleGUITrad(570), pt.y, pt.y + ScaleGUITrad(140), !_networking ? STR_HIGHSCORE_TOP_COMPANIES_WHO_REACHED : STR_HIGHSCORE_TOP_COMPANIES_NETWORK_GAME, TC_FROMSTRING, SA_CENTER);
|
|
|
|