|
|
@ -214,11 +214,16 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w)
|
|
|
|
|
|
|
|
|
|
|
|
extern void UpdateAllStationVirtCoord();
|
|
|
|
extern void UpdateAllStationVirtCoord();
|
|
|
|
|
|
|
|
|
|
|
|
static void MainWindowWndProc(Window *w, WindowEvent *e)
|
|
|
|
struct MainWindow : Window
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (e->event) {
|
|
|
|
MainWindow(int width, int height) : Window(0, 0, width, height, NULL, WC_MAIN_WINDOW, NULL)
|
|
|
|
case WE_PAINT:
|
|
|
|
{
|
|
|
|
DrawWindowViewport(w);
|
|
|
|
InitializeWindowViewport(this, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DrawWindowViewport(this);
|
|
|
|
if (_game_mode == GM_MENU) {
|
|
|
|
if (_game_mode == GM_MENU) {
|
|
|
|
int off_x = _screen.width / 2;
|
|
|
|
int off_x = _screen.width / 2;
|
|
|
|
|
|
|
|
|
|
|
@ -231,44 +236,43 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
|
|
|
|
DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 65, 50);
|
|
|
|
DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 65, 50);
|
|
|
|
DrawSprite(SPR_OTTD_D, PAL_NONE, off_x + 96, 50);
|
|
|
|
DrawSprite(SPR_OTTD_D, PAL_NONE, off_x + 96, 50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_KEYPRESS:
|
|
|
|
virtual bool OnKeyPress(uint16 key, uint16 keycode)
|
|
|
|
switch (e->we.keypress.keycode) {
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (keycode) {
|
|
|
|
case 'Q' | WKC_CTRL:
|
|
|
|
case 'Q' | WKC_CTRL:
|
|
|
|
case 'Q' | WKC_META:
|
|
|
|
case 'Q' | WKC_META:
|
|
|
|
HandleExitGameRequest();
|
|
|
|
HandleExitGameRequest();
|
|
|
|
break;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Disable all key shortcuts, except quit shortcuts when
|
|
|
|
/* Disable all key shortcuts, except quit shortcuts when
|
|
|
|
* generating the world, otherwise they create threading
|
|
|
|
* generating the world, otherwise they create threading
|
|
|
|
* problem during the generating, resulting in random
|
|
|
|
* problem during the generating, resulting in random
|
|
|
|
* assertions that are hard to trigger and debug */
|
|
|
|
* assertions that are hard to trigger and debug */
|
|
|
|
if (IsGeneratingWorld()) break;
|
|
|
|
if (IsGeneratingWorld()) return true;
|
|
|
|
|
|
|
|
|
|
|
|
if (e->we.keypress.keycode == WKC_BACKQUOTE) {
|
|
|
|
if (keycode == WKC_BACKQUOTE) {
|
|
|
|
IConsoleSwitch();
|
|
|
|
IConsoleSwitch();
|
|
|
|
e->we.keypress.cont = false;
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (e->we.keypress.keycode == ('B' | WKC_CTRL)) {
|
|
|
|
if (keycode == ('B' | WKC_CTRL)) {
|
|
|
|
e->we.keypress.cont = false;
|
|
|
|
|
|
|
|
extern bool _draw_bounding_boxes;
|
|
|
|
extern bool _draw_bounding_boxes;
|
|
|
|
_draw_bounding_boxes = !_draw_bounding_boxes;
|
|
|
|
_draw_bounding_boxes = !_draw_bounding_boxes;
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
break;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_game_mode == GM_MENU) break;
|
|
|
|
if (_game_mode == GM_MENU) return true;
|
|
|
|
|
|
|
|
|
|
|
|
switch (e->we.keypress.keycode) {
|
|
|
|
switch (keycode) {
|
|
|
|
case 'C':
|
|
|
|
case 'C':
|
|
|
|
case 'Z': {
|
|
|
|
case 'Z': {
|
|
|
|
Point pt = GetTileBelowCursor();
|
|
|
|
Point pt = GetTileBelowCursor();
|
|
|
|
if (pt.x != -1) {
|
|
|
|
if (pt.x != -1) {
|
|
|
|
if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w);
|
|
|
|
if (keycode == 'Z') MaxZoomInOut(ZOOM_IN, this);
|
|
|
|
ScrollMainWindowTo(pt.x, pt.y);
|
|
|
|
ScrollMainWindowTo(pt.x, pt.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -305,7 +309,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
|
|
|
|
case '8' | WKC_CTRL:
|
|
|
|
case '8' | WKC_CTRL:
|
|
|
|
case '9' | WKC_CTRL:
|
|
|
|
case '9' | WKC_CTRL:
|
|
|
|
/* Transparency toggle hot keys */
|
|
|
|
/* Transparency toggle hot keys */
|
|
|
|
ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL)));
|
|
|
|
ToggleTransparency((TransparencyOption)(keycode - ('1' | WKC_CTRL)));
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -318,7 +322,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
|
|
|
|
case '7' | WKC_CTRL | WKC_SHIFT:
|
|
|
|
case '7' | WKC_CTRL | WKC_SHIFT:
|
|
|
|
case '8' | WKC_CTRL | WKC_SHIFT:
|
|
|
|
case '8' | WKC_CTRL | WKC_SHIFT:
|
|
|
|
/* Invisibility toggle hot keys */
|
|
|
|
/* Invisibility toggle hot keys */
|
|
|
|
ToggleInvisibilityWithTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL | WKC_SHIFT)));
|
|
|
|
ToggleInvisibilityWithTransparency((TransparencyOption)(keycode - ('1' | WKC_CTRL | WKC_SHIFT)));
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -367,35 +371,37 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
default: return;
|
|
|
|
default: return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e->we.keypress.cont = false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case WE_SCROLL: {
|
|
|
|
virtual void OnScroll(Point delta)
|
|
|
|
ViewPort *vp = IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y);
|
|
|
|
{
|
|
|
|
|
|
|
|
ViewPort *vp = IsPtInWindowViewport(this, _cursor.pos.x, _cursor.pos.y);
|
|
|
|
|
|
|
|
|
|
|
|
if (vp == NULL) {
|
|
|
|
if (vp == NULL) {
|
|
|
|
_cursor.fix_at = false;
|
|
|
|
_cursor.fix_at = false;
|
|
|
|
_scrolling_viewport = false;
|
|
|
|
_scrolling_viewport = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
w->viewport->scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
|
|
|
|
this->viewport->scrollpos_x += ScaleByZoom(delta.x, vp->zoom);
|
|
|
|
w->viewport->scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
|
|
|
|
this->viewport->scrollpos_y += ScaleByZoom(delta.y, vp->zoom);
|
|
|
|
w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
|
|
|
|
this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x;
|
|
|
|
w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
|
|
|
|
this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y;
|
|
|
|
} break;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
case WE_MOUSEWHEEL:
|
|
|
|
virtual void OnMouseWheel(int wheel)
|
|
|
|
ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w);
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
ZoomInOrOutToCursorWindow(wheel < 0, this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_INVALIDATE_DATA:
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* Forward the message to the appropiate toolbar (ingame or scenario editor) */
|
|
|
|
/* Forward the message to the appropiate toolbar (ingame or scenario editor) */
|
|
|
|
InvalidateWindowData(WC_MAIN_TOOLBAR, 0, e->we.invalidate.data);
|
|
|
|
InvalidateWindowData(WC_MAIN_TOOLBAR, 0, data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ShowSelectGameWindow();
|
|
|
|
void ShowSelectGameWindow();
|
|
|
@ -409,11 +415,7 @@ void SetupColorsAndInitialWindow()
|
|
|
|
memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i]));
|
|
|
|
memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int width = _screen.width;
|
|
|
|
new MainWindow(_screen.width, _screen.height);
|
|
|
|
int height = _screen.height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Window *w = new Window(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
|
|
|
|
|
|
|
|
InitializeWindowViewport(w, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX: these are not done */
|
|
|
|
/* XXX: these are not done */
|
|
|
|
switch (_game_mode) {
|
|
|
|
switch (_game_mode) {
|
|
|
|