diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj
index 65dc2c25c5..e9b9025b4f 100644
--- a/projects/openrct2.vcxproj
+++ b/projects/openrct2.vcxproj
@@ -88,6 +88,7 @@
+
diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters
index 320e75abdf..4f7eea0b40 100644
--- a/projects/openrct2.vcxproj.filters
+++ b/projects/openrct2.vcxproj.filters
@@ -269,6 +269,9 @@
Source Files
+
+ Windows
+
diff --git a/src/game.c b/src/game.c
index e8bafaeb33..c108aaffad 100644
--- a/src/game.c
+++ b/src/game.c
@@ -875,6 +875,9 @@ void handle_shortcut(int key)
break;
}
}
+ if (key == SDL_SCANCODE_M) {
+ key = key;
+ }
}
/**
@@ -930,7 +933,7 @@ void game_handle_keyboard_input()
// Handle key input
while ((key = get_next_key()) != 0) {
- if (key == 255 || key == 0x10 || key == 0x11)
+ if (key == 255)
continue;
key |= RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) << 8;
diff --git a/src/strings.h b/src/strings.h
index a5432c8d99..f664887074 100644
--- a/src/strings.h
+++ b/src/strings.h
@@ -334,6 +334,7 @@ enum {
SPR_BUY_CONSTRUCTION_RIGHTS_TIP = 2326,
STR_PARK_INFORMATION_TIP = 2233,
+ STR_RECENT_MESSAGES = 2234,
STR_MONTH_JANUARY = 2236,
STR_MONTH_FEBRUARY = STR_MONTH_JANUARY + 1,
diff --git a/src/window.c b/src/window.c
index da21178b58..a1644e98c8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -631,6 +631,7 @@ void window_init_scroll_widgets(rct_window *w)
rct_widget* widget;
rct_scroll* scroll;
int widget_index, scroll_index;
+ int width, height;
widget_index = 0;
scroll_index = 0;
@@ -641,16 +642,11 @@ void window_init_scroll_widgets(rct_window *w)
}
scroll = &w->scrolls[scroll_index];
-
- {
- int _eax = 0, _ebx = scroll_index * sizeof(rct_scroll), _ecx = 0, _edx = 0, _esi = w, _edi = widget_index * sizeof(rct_widget), _ebp = 0;
- RCT2_CALLFUNC_X(w->event_handlers[WE_SCROLL_GETSIZE], & _eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp);
-
- scroll->h_left = 0;
- scroll->h_right = _ecx + 1;
- scroll->v_top = 0;
- scroll->v_bottom = _edx + 1;
- }
+ window_get_scroll_size(w, scroll_index, &width, &height);
+ scroll->h_left = 0;
+ scroll->h_right = width + 1;
+ scroll->v_top = 0;
+ scroll->v_bottom = height + 1;
if (widget->image & 0x01)
scroll->flags |= HSCROLLBAR_VISIBLE;
@@ -675,6 +671,18 @@ void window_update_scroll_widgets(rct_window *w)
RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, w, 0, 0);
}
+int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *height)
+{
+ rct_widget *widget = window_get_scroll_widget(w, scrollIndex);
+ int widgetIndex = window_get_widget_index(w, widget);
+
+ int eax = 0, ebx = scrollIndex * sizeof(rct_scroll), ecx = 0, edx = 0, esi = w, edi = widgetIndex * sizeof(rct_widget), ebp = 0;
+ RCT2_CALLFUNC_X(w->event_handlers[WE_SCROLL_GETSIZE], & eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
+ *width = ecx;
+ *height = edx;
+ return 1;
+}
+
int window_get_scroll_data_index(rct_window *w, int widget_index)
{
int i, result;
diff --git a/src/window.h b/src/window.h
index 9fab72b82c..2bc443c7f7 100644
--- a/src/window.h
+++ b/src/window.h
@@ -298,6 +298,7 @@ void widget_invalidate(rct_windowclass cls, rct_windownumber number, int widgetI
void window_init_scroll_widgets(rct_window *w);
void window_update_scroll_widgets(rct_window *w);
int window_get_scroll_data_index(rct_window *w, int widget_index);
+int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *height);
rct_window *window_bring_to_front_by_id(rct_windowclass cls, rct_windownumber number);
rct_window *window_bring_to_front(rct_window *w);
@@ -334,6 +335,7 @@ void window_save_prompt_open();
void window_title_menu_open();
void window_title_exit_open();
void window_title_logo_open();
+void window_news_open();
void window_scenarioselect_open();
void window_clear_scenery_open();
void window_land_open();
diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c
index 2ce92865ed..32b4a01251 100644
--- a/src/window_game_bottom_toolbar.c
+++ b/src/window_game_bottom_toolbar.c
@@ -195,7 +195,7 @@ static void window_game_bottom_toolbar_mouseup()
break;
case WIDX_RIGHT_OUTSET:
case WIDX_DATE:
- RCT2_CALLPROC_EBPSAFE(0x0066E464);
+ window_news_open();
break;
}
}
diff --git a/src/window_news.c b/src/window_news.c
new file mode 100644
index 0000000000..46888608ed
--- /dev/null
+++ b/src/window_news.c
@@ -0,0 +1,387 @@
+/*****************************************************************************
+ * Copyright (c) 2014 Ted John
+ * OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
+ *
+ * This file is part of OpenRCT2.
+ *
+ * OpenRCT2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *****************************************************************************/
+
+#include
+#include "addresses.h"
+#include "audio.h"
+#include "news_item.h"
+#include "strings.h"
+#include "sprite.h"
+#include "sprites.h"
+#include "widget.h"
+#include "window.h"
+
+static enum WINDOW_NEWS_WIDGET_IDX {
+ WIDX_BACKGROUND,
+ WIDX_TITLE,
+ WIDX_CLOSE,
+ WIDX_SCROLL
+};
+
+static rct_widget window_news_widgets[] = {
+ { WWT_FRAME, 0, 0, 399, 0, 299, 0x0FFFFFFFF, STR_NONE }, // panel / background
+ { WWT_CAPTION, 0, 1, 398, 1, 14, STR_RECENT_MESSAGES, STR_WINDOW_TITLE_TIP }, // title bar
+ { WWT_CLOSEBOX, 0, 387, 397, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
+ { WWT_SCROLL, 0, 4, 395, 18, 295, 2, STR_NONE }, // scroll
+ { WIDGETS_END },
+};
+
+static void window_news_emptysub() { }
+static void window_news_mouseup();
+static void window_news_update();
+static void window_news_scrollgetsize();
+static void window_news_scrollmousedown();
+static void window_news_tooltip();
+static void window_news_paint();
+static void window_news_scrollpaint();
+
+static uint32 window_news_events[] = {
+ window_news_emptysub,
+ window_news_mouseup,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_update,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_scrollgetsize,
+ window_news_scrollmousedown,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_tooltip,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_emptysub,
+ window_news_paint,
+ window_news_scrollpaint
+};
+
+/**
+ *
+ * rct2: 0x0066E464
+ */
+void window_news_open()
+{
+ int x, y;
+ rct_window* window;
+
+ // Check if window is already open
+ window = window_bring_to_front_by_id(WC_RECENT_NEWS, 0);
+ if (window == NULL) {
+ window = window_create_auto_pos(
+ 400,
+ 300,
+ window_news_events,
+ WC_ABOUT,
+ 0
+ );
+ window->widgets = window_news_widgets;
+ window->enabled_widgets = (1 << WIDX_CLOSE);
+ window_init_scroll_widgets(window);
+ window->colours[0] = 1;
+ window->colours[1] = 1;
+ window->colours[2] = 0;
+ window->var_480 = -1;
+ }
+
+// sub_66E4BA:
+ int width, height;
+ rct_widget *widget;
+
+ window_get_scroll_size(window, 0, &width, &height);
+ widget = &window_news_widgets[WIDX_SCROLL];
+ window->scrolls[0].v_top = max(0, height - (widget->bottom - widget->top - 1));
+ widget_scroll_update_thumbs(window, WIDX_SCROLL);
+}
+
+/**
+ *
+ * rct2: 0x0066D4D5
+ */
+static void window_news_mouseup()
+{
+ int i;
+ short widgetIndex;
+ rct_window *w;
+
+ __asm mov widgetIndex, dx
+ __asm mov w, esi
+
+ if (widgetIndex == WIDX_CLOSE)
+ window_close(w);
+}
+
+/**
+ *
+ * rct2: 0x0066EAB8
+ */
+static void window_news_update()
+{
+ int i, j, x, y, z;
+ rct_window *w;
+ rct_news_item *newsItems;
+
+ __asm mov w, esi
+
+ if (w->var_480 == -1)
+ return;
+ if (--w->var_484 != 0)
+ return;
+
+ window_invalidate(w);
+ sound_play_panned(5, w->x + (w->width / 2));
+
+ newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item);
+ j = w->var_480;
+ w->var_480 = -1;
+ for (i = 11; i < 61; i++) {
+ if (newsItems[i].type == NEWS_ITEM_NULL)
+ return;
+
+ if (j == 0) {
+ if (newsItems[i].flags & 1)
+ return;
+ if (w->var_482 == 1) {
+ RCT2_CALLPROC_X(0x0066EBE6, 0, newsItems[i].type, newsItems[i].assoc, 0, 0, 0, 0);
+ return;
+ } else if (w->var_482 > 1) {
+ news_item_get_subject_location(newsItems[i].type, newsItems[i].assoc, &x, &y, &z);
+ if (x != SPRITE_LOCATION_NULL)
+ if ((w = window_get_main()) != NULL)
+ window_scroll_to_location(w, x, y, z);
+ return;
+ }
+ }
+ j--;
+ }
+}
+
+/**
+ *
+ * rct2: 0x0066EA3C
+ */
+static void window_news_scrollgetsize()
+{
+ int i, height;
+ rct_news_item *newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item);
+
+ height = 0;
+ for (i = 11; i < 61; i++) {
+ if (newsItems[i].type == NEWS_ITEM_NULL)
+ break;
+
+ height += 42;
+ }
+
+ __asm mov edx, height
+}
+
+/**
+ *
+ * rct2: 0x0066EA5C
+ */
+static void window_news_scrollmousedown()
+{
+ int i, buttonIndex;
+ short x, y;
+ rct_window *w;
+ rct_news_item *newsItems;
+
+ __asm mov x, cx
+ __asm mov y, dx
+ __asm mov w, esi
+
+ buttonIndex = 0;
+ newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item);
+ for (i = 11; i < 61; i++) {
+ if (newsItems[i].type == NEWS_ITEM_NULL)
+ break;
+
+ if (y < 42) {
+ if (newsItems[i].flags & 1) {
+ buttonIndex = 0;
+ break;
+ } else if (y < 14) {
+ buttonIndex = 0;
+ break;
+ } else if (y >= 38) {
+ buttonIndex = 0;
+ break;
+ } else if (x < 328) {
+ buttonIndex = 0;
+ break;
+ } else if (x < 351) {
+ if (RCT2_ADDRESS(0x0097BE7C, uint8)[newsItems[i].type] & 2) {
+ buttonIndex = 1;
+ break;
+ }
+ } else if (x < 376) {
+ if (RCT2_ADDRESS(0x0097BE7C, uint8)[newsItems[i].type] & 1) {
+ buttonIndex = 2;
+ break;
+ }
+ }
+ }
+ y -= 42;
+ }
+
+ if (buttonIndex != 0) {
+ w->var_480 = i - 11;
+ w->var_482 = buttonIndex;
+ w->var_484 = 4;
+ window_invalidate(w);
+ sound_play_panned(4, w->x + (w->width / 2));
+ }
+}
+
+/**
+ *
+ * rct2: 0x0066EAAE
+ */
+static void window_news_tooltip()
+{
+ RCT2_GLOBAL(0x013CE952, uint16) = 3159;
+}
+
+/**
+ *
+ * rct2: 0x0066E4E8
+ */
+static void window_news_paint()
+{
+ int x, y;
+ rct_window *w;
+ rct_drawpixelinfo *dpi;
+
+ __asm mov w, esi
+ __asm mov dpi, edi
+
+ window_draw_widgets(w, dpi);
+}
+
+/**
+ *
+ * rct2: 0x0066E4EE
+ */
+static void window_news_scrollpaint()
+{
+ int i, x, y, yy, press;
+ rct_window *w;
+ rct_drawpixelinfo *dpi;
+ rct_news_item *newsItems, *newsItem, *newsItem2;
+
+ __asm mov w, esi
+ __asm mov dpi, edi
+
+ y = 0;
+ newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item);
+ for (i = 11; i < 61; i++) {
+ newsItem = &newsItems[i];
+ if (newsItem->type == NEWS_ITEM_NULL)
+ break;
+ if (y >= dpi->y + dpi->height)
+ break;
+ if (y + 42 < dpi->y) {
+ y += 42;
+ continue;
+ }
+
+ // Background
+ gfx_fill_rect_inset(dpi, -1, y, 383, y + 41, w->colours[1], 0x24);
+
+ // Date text
+ RCT2_GLOBAL(0x013CE952, uint16) = STR_DATE_DAY_1 + newsItem->day - 1;
+ RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_MONTH_MARCH + (newsItem->month % 8);
+ gfx_draw_string_left(dpi, 2235, 0x013CE952, 2, 4, y);
+
+ // Item text
+ RCT2_GLOBAL(0x009B5F2C, uint8) = newsItem->colour;
+ strcpy(0x009B5F2D, newsItem->text);
+ gfx_draw_string_left_wrapped(dpi, 0, 2, y + 10, 325, 1926, 14);
+
+ // Subject button
+ if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 2) && !(newsItem->flags & 1)) {
+ x = 328;
+ yy = y + 14;
+
+ press = 0;
+ if (w->var_480 != -1) {
+ newsItem2 = &newsItems[11 + w->var_480];
+ if (newsItem == newsItem2 && w->var_482 == 1)
+ press = 0x20;
+ }
+ gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);
+
+ switch (newsItem->type) {
+ case NEWS_ITEM_RIDE:
+ gfx_draw_sprite(dpi, SPR_RIDE, x, yy);
+ break;
+ case NEWS_ITEM_PEEP_ON_RIDE:
+ // TODO
+ break;
+ case NEWS_ITEM_PEEP:
+ // TODO
+ break;
+ case NEWS_ITEM_MONEY:
+ gfx_draw_sprite(dpi, SPR_FINANCE, x, yy);
+ break;
+ case NEWS_ITEM_SCENERY:
+ gfx_draw_sprite(dpi, newsItem->assoc < 0x10000 ? SPR_NEW_RIDE : SPR_SCENERY, x, yy);
+ break;
+ case NEWS_ITEM_PEEPS:
+ gfx_draw_sprite(dpi, SPR_GUESTS, x, yy);
+ break;
+ case NEWS_ITEM_AWARD:
+ gfx_draw_sprite(dpi, SPR_AWARD, x, yy);
+ break;
+ case NEWS_ITEM_GRAPH:
+ gfx_draw_sprite(dpi, SPR_GRAPH, x, yy);
+ break;
+ }
+ }
+
+ // Location button
+ if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 1) && !(newsItem->flags & 1)) {
+ x = 352;
+ yy = y + 14;
+
+ press = 0;
+ if (w->var_480 != -1) {
+ newsItem2 = &newsItems[11 + w->var_480];
+ if (newsItem == newsItem2 && w->var_482 == 2)
+ press = 0x20;
+ }
+ gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);
+ gfx_draw_sprite(dpi, SPR_LOCATE, x, yy);
+ }
+
+ y += 42;
+ }
+}
\ No newline at end of file