|
@@ -190,117 +190,118 @@ bool DoZoomInOutWindow(ZoomStateChange h
|
|
|
void ZoomInOrOutToCursorWindow(bool in, Window *w)
|
|
|
{
|
|
|
assert(w != NULL);
|
|
|
|
|
|
if (_game_mode != GM_MENU) {
|
|
|
ViewPort *vp = w->viewport;
|
|
|
if ((in && vp->zoom <= _settings_client.gui.zoom_min) || (!in && vp->zoom >= _settings_client.gui.zoom_max)) return;
|
|
|
|
|
|
Point pt = GetTileZoomCenterWindow(in, w);
|
|
|
if (pt.x != -1) {
|
|
|
ScrollWindowTo(pt.x, pt.y, -1, w, true);
|
|
|
|
|
|
DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static const struct NWidgetPart _nested_main_window_widgets[] = {
|
|
|
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_M_VIEWPORT), SetResize(1, 1),
|
|
|
};
|
|
|
|
|
|
enum {
|
|
|
GHK_QUIT,
|
|
|
GHK_ABANDON,
|
|
|
GHK_CONSOLE,
|
|
|
GHK_BOUNDING_BOXES,
|
|
|
GHK_DIRTY_BLOCKS,
|
|
|
GHK_CENTER,
|
|
|
GHK_CENTER_ZOOM,
|
|
|
GHK_RESET_OBJECT_TO_PLACE,
|
|
|
GHK_DELETE_WINDOWS,
|
|
|
GHK_DELETE_NONVITAL_WINDOWS,
|
|
|
GHK_REFRESH_SCREEN,
|
|
|
GHK_CRASH,
|
|
|
GHK_MONEY,
|
|
|
GHK_UPDATE_COORDS,
|
|
|
GHK_TOGGLE_TRANSPARENCY,
|
|
|
GHK_TOGGLE_INVISIBILITY = GHK_TOGGLE_TRANSPARENCY + 9,
|
|
|
GHK_TRANSPARENCY_TOOLBAR = GHK_TOGGLE_INVISIBILITY + 8,
|
|
|
GHK_TRANSPARANCY,
|
|
|
GHK_CHAT,
|
|
|
GHK_CHAT_ALL,
|
|
|
GHK_CHAT_COMPANY,
|
|
|
GHK_CHAT_SERVER,
|
|
|
};
|
|
|
|
|
|
struct MainWindow : Window
|
|
|
{
|
|
|
uint refresh;
|
|
|
int refresh;
|
|
|
|
|
|
static const uint LINKGRAPH_REFRESH_PERIOD = 0xff;
|
|
|
static const uint LINKGRAPH_DELAY = 0xf;
|
|
|
/* Refresh times in milliseconds */
|
|
|
static const uint LINKGRAPH_REFRESH_PERIOD = 7650;
|
|
|
static const uint LINKGRAPH_DELAY = 450;
|
|
|
|
|
|
MainWindow(WindowDesc *desc) : Window(desc)
|
|
|
{
|
|
|
this->InitNested(0);
|
|
|
CLRBITS(this->flags, WF_WHITE_BORDER);
|
|
|
ResizeWindow(this, _screen.width, _screen.height);
|
|
|
|
|
|
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_M_VIEWPORT);
|
|
|
nvp->InitializeViewport(this, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
|
|
|
|
|
|
this->viewport->overlay = new LinkGraphOverlay(this, WID_M_VIEWPORT, 0, 0, 3);
|
|
|
this->refresh = LINKGRAPH_DELAY;
|
|
|
}
|
|
|
|
|
|
virtual void OnTick()
|
|
|
virtual void OnRealtimeTick(uint delta_ms)
|
|
|
{
|
|
|
if (--this->refresh > 0) return;
|
|
|
if (!TimerElapsed(this->refresh, delta_ms)) return;
|
|
|
|
|
|
this->refresh = LINKGRAPH_REFRESH_PERIOD;
|
|
|
|
|
|
if (this->viewport->overlay->GetCargoMask() == 0 ||
|
|
|
this->viewport->overlay->GetCompanyMask() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this->viewport->overlay->RebuildCache();
|
|
|
this->GetWidget<NWidgetBase>(WID_M_VIEWPORT)->SetDirty(this);
|
|
|
}
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
this->DrawWidgets();
|
|
|
if (_game_mode == GM_MENU) {
|
|
|
static const SpriteID title_sprites[] = {SPR_OTTD_O, SPR_OTTD_P, SPR_OTTD_E, SPR_OTTD_N, SPR_OTTD_T, SPR_OTTD_T, SPR_OTTD_D};
|
|
|
static const uint LETTER_SPACING = 10;
|
|
|
int name_width = (lengthof(title_sprites) - 1) * LETTER_SPACING;
|
|
|
|
|
|
for (uint i = 0; i < lengthof(title_sprites); i++) {
|
|
|
name_width += GetSpriteSize(title_sprites[i]).width;
|
|
|
}
|
|
|
int off_x = (this->width - name_width) / 2;
|
|
|
|
|
|
for (uint i = 0; i < lengthof(title_sprites); i++) {
|
|
|
DrawSprite(title_sprites[i], PAL_NONE, off_x, 50);
|
|
|
off_x += GetSpriteSize(title_sprites[i]).width + LETTER_SPACING;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual EventState OnHotkey(int hotkey)
|
|
|
{
|
|
|
if (hotkey == GHK_QUIT) {
|
|
|
HandleExitGameRequest();
|
|
|
return ES_HANDLED;
|
|
|
}
|
|
|
|
|
|
/* Disable all key shortcuts, except quit shortcuts when
|
|
|
* generating the world, otherwise they create threading
|
|
|
* problem during the generating, resulting in random
|
|
|
* assertions that are hard to trigger and debug */
|
|
|
if (HasModalProgress()) return ES_NOT_HANDLED;
|
|
|
|
|
|
switch (hotkey) {
|
|
|
case GHK_ABANDON:
|
|
|
/* No point returning from the main menu to itself */
|