From 2d57f82b254fa797a0deab0109a8567287e0bb77 Mon Sep 17 00:00:00 2001 From: "Miso Zmiric (Mike Squinter)" Date: Sat, 30 May 2015 04:33:29 +0100 Subject: [PATCH] add the base for the twitch window --- data/language/english_uk.txt | 5 +- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/interface/window.h | 2 + src/localisation/string_ids.h | 4 + src/windows/options.c | 3 +- src/windows/twitch.c | 148 ++++++++++++++++++++++++++++++ 7 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 src/windows/twitch.c diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index ce815fca10..3409b5461d 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3593,4 +3593,7 @@ STR_5256 :Create a new theme to make changes to STR_5257 :{SMALLFONT}{BLACK}Create a new theme based on the current one STR_5258 :{SMALLFONT}{BLACK}Delete the current theme STR_5259 :{SMALLFONT}{BLACK}Rename the current theme -STR_5260 :Giant Screenshot \ No newline at end of file +STR_5260 :Giant Screenshot +STR_5261 :Twitch Integration Options +STR_5262 :Log in with Twtich +STR_5263 :{SMALLFONT}{BLACK}Authenticate the game with your Twitch account to enable Twitch features diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 7ffaf599b9..f882581273 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -143,6 +143,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index b4708cd894..ca95f5524f 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -456,6 +456,9 @@ Source\Windows + + Source\Windows + diff --git a/src/interface/window.h b/src/interface/window.h index 9bae78e466..fd371b88ab 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -406,6 +406,7 @@ enum { WC_TITLE_OPTIONS = 117, WC_LAND_RIGHTS = 118, WC_THEMES = 119, + WC_TWITCH = 120, // Only used for colour schemes WC_STAFF = 220, @@ -513,6 +514,7 @@ void window_resize_gui_scenario_editor(int width, int height); void window_top_toolbar_open(); void window_game_bottom_toolbar_open(); void window_about_open(); +void window_twitch_open(); void window_footpath_open(); void window_save_prompt_open(); void window_title_menu_open(); diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 07a7470199..bc8207eb61 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -1426,6 +1426,10 @@ enum { STR_GIANT_SCREENSHOT = 5260, + STR_TWITCH_WINDOW_TITLE = 5261, + STR_TWITCH_AUTH = 5262, + STR_TWITCH_AUTH_TIP = 5263, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/windows/options.c b/src/windows/options.c index 3491a2816e..32099721d0 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -350,7 +350,8 @@ static void window_options_mouseup() window_shortcut_keys_open(); break; case WIDX_CHANNEL_BUTTON: - window_text_input_raw_open(w, widgetIndex, STR_TWITCH_NAME, STR_TWITCH_NAME_DESC, gConfigTwitch.channel, 32); + //window_text_input_raw_open(w, widgetIndex, STR_TWITCH_NAME, STR_TWITCH_NAME_DESC, gConfigTwitch.channel, 32); + window_twitch_open(); break; case WIDX_SCREEN_EDGE_SCROLLING: gConfigGeneral.edge_scrolling ^= 1; diff --git a/src/windows/twitch.c b/src/windows/twitch.c new file mode 100644 index 0000000000..9d5c61ebb5 --- /dev/null +++ b/src/windows/twitch.c @@ -0,0 +1,148 @@ +/***************************************************************************** +* 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 "../addresses.h" +#include "../localisation/localisation.h" +#include "../sprites.h" +#include "../interface/widget.h" +#include "../interface/window.h" + +enum window_twitch_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_TWITCH_AUTH +}; + +rct_widget window_twitch_widgets[] = { + { WWT_FRAME, 0, 0, 399, 0, 329, 0x0FFFFFFFF, STR_NONE }, // panel / background + { WWT_CAPTION, 0, 1, 398, 1, 14, STR_TWITCH_WINDOW_TITLE, STR_WINDOW_TITLE_TIP }, // title bar + { WWT_CLOSEBOX, 0, 387, 397, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button + { WWT_DROPDOWN_BUTTON, 1, 100, 299, 53, 64, STR_TWITCH_AUTH, STR_TWITCH_AUTH_TIP }, // twitch auth + { WIDGETS_END }, +}; + +static void window_twitch_emptysub() { } +static void window_twitch_mouseup(); +static void window_twitch_paint(); + +static void* window_twitch_events[] = { + window_twitch_emptysub, + window_twitch_mouseup, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_emptysub, + window_twitch_paint, + window_twitch_emptysub +}; + +/** +* +* rct2: 0x0066D2AC +*/ +void window_twitch_open() +{ + rct_window* window; + + // Check if window is already open + window = window_bring_to_front_by_class(WC_TWITCH); + if (window != NULL) + return; + + window = window_create_centred( + 400, + 330, + (uint32*)window_twitch_events, + WC_TWITCH, + 0 + ); + window->widgets = window_twitch_widgets; + window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_TWITCH_AUTH); + + window_init_scroll_widgets(window); + window->colours[0] = 7; + window->colours[1] = 7; + window->colours[2] = 7; +} + +/** +* +* rct2: 0x0066D4D5 +*/ +static void window_twitch_mouseup() +{ + short widgetIndex; + rct_window *w; + + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + } +} + +/** +* +* rct2: 0x0066D321 +*/ +static void window_twitch_paint() +{ + int x, y; + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + + x = w->x + 180; + y = w->y + 17; + + gfx_draw_sprite(dpi, SPR_G2_TAB_TWITCH, x, y, 0); + + x = w->x + 280; + y = w->y + 315; + + gfx_draw_string_left(dpi, STR_TWITCH_POWERDBY, NULL, 12, x, y); + +}