1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Chat toggle button (#8648)

* Add chat_available()

* Add appropriate strings

* Add new Chat icon

* Implement Chat button

* CS

* Fix chat icon

* Make chat icon a bit smaller and less bright

* Update chat icon

* Update changelog
This commit is contained in:
Tom Lankhorst
2019-02-03 23:30:34 +01:00
committed by Michał Janiszewski
parent 604da7ce01
commit 521948139c
12 changed files with 72 additions and 6 deletions

View File

@@ -3727,6 +3727,10 @@ STR_6276 :{RED}{STRINGID} has guests getting stuck, possibly due to invalid r
STR_6277 :{WINDOW_COLOUR_2}Station index: {BLACK}{COMMA16} STR_6277 :{WINDOW_COLOUR_2}Station index: {BLACK}{COMMA16}
STR_6278 :Autosave amount STR_6278 :Autosave amount
STR_6279 :{SMALLFONT}{BLACK}Number of autosaves that should be kept STR_6279 :{SMALLFONT}{BLACK}Number of autosaves that should be kept
STR_6280 :{SMALLFONT}{BLACK}Chat
STR_6281 :{SMALLFONT}{BLACK}Show a separate button for the Chat window in the toolbar
STR_6282 :Chat
STR_6283 :Chat not available at this time. Are you connected to a server?
############# #############
# Scenarios # # Scenarios #

View File

@@ -17,6 +17,7 @@
- Feature: [#8377] Add option to adjust amount of autosaves to keep. - Feature: [#8377] Add option to adjust amount of autosaves to keep.
- Feature: [#8458] Add sprite sorting benchmark. - Feature: [#8458] Add sprite sorting benchmark.
- Feature: [#8583] Add boosters to water coaster. - Feature: [#8583] Add boosters to water coaster.
- Feature: [#8648] Add optional chat button to top toolbar in multiplayer games.
- Change: [#7961] Add new object types: station, terrain surface, and terrain edge. - Change: [#7961] Add new object types: station, terrain surface, and terrain edge.
- Change: [#8222] The climate setting has been moved from objective options to scenario options. - Change: [#8222] The climate setting has been moved from objective options to scenario options.
- Change: [#8647] Increased 'guest generation probability' thresholds of marketing campaigns. - Change: [#8647] Increased 'guest generation probability' thresholds of marketing campaigns.

BIN
resources/g2/icons/chat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -389,6 +389,11 @@
"x_offset": 5, "x_offset": 5,
"y_offset": 5 "y_offset": 5
}, },
{
"path": "icons/chat.png",
"x_offset": 2,
"y_offset": 1
},
{ {
"path": "font/latin/ae-uc-small.png", "path": "font/latin/ae-uc-small.png",
"y_offset": 0, "y_offset": 0,

View File

@@ -150,6 +150,7 @@ enum WINDOW_OPTIONS_WIDGET_IDX {
WIDX_TOOLBAR_SHOW_CHEATS, WIDX_TOOLBAR_SHOW_CHEATS,
WIDX_TOOLBAR_SHOW_NEWS, WIDX_TOOLBAR_SHOW_NEWS,
WIDX_TOOLBAR_SHOW_MUTE, WIDX_TOOLBAR_SHOW_MUTE,
WIDX_TOOLBAR_SHOW_CHAT,
// Misc // Misc
WIDX_TITLE_SEQUENCE_GROUP = WIDX_PAGE_START, WIDX_TITLE_SEQUENCE_GROUP = WIDX_PAGE_START,
@@ -319,6 +320,7 @@ static rct_widget window_options_controls_and_interface_widgets[] = {
{ WWT_CHECKBOX, 2, 155, 299, TOOLBAR_GROUP_START + 31, TOOLBAR_GROUP_START + 42, STR_CHEATS_BUTTON_ON_TOOLBAR, STR_CHEATS_BUTTON_ON_TOOLBAR_TIP }, // Cheats { WWT_CHECKBOX, 2, 155, 299, TOOLBAR_GROUP_START + 31, TOOLBAR_GROUP_START + 42, STR_CHEATS_BUTTON_ON_TOOLBAR, STR_CHEATS_BUTTON_ON_TOOLBAR_TIP }, // Cheats
{ WWT_CHECKBOX, 2, 155, 299, TOOLBAR_GROUP_START + 46, TOOLBAR_GROUP_START + 57, STR_SHOW_RECENT_MESSAGES_ON_TOOLBAR, STR_SHOW_RECENT_MESSAGES_ON_TOOLBAR_TIP }, // Recent messages { WWT_CHECKBOX, 2, 155, 299, TOOLBAR_GROUP_START + 46, TOOLBAR_GROUP_START + 57, STR_SHOW_RECENT_MESSAGES_ON_TOOLBAR, STR_SHOW_RECENT_MESSAGES_ON_TOOLBAR_TIP }, // Recent messages
{ WWT_CHECKBOX, 2, 24, 185, TOOLBAR_GROUP_START + 61, TOOLBAR_GROUP_START + 72, STR_MUTE_BUTTON_ON_TOOLBAR, STR_MUTE_BUTTON_ON_TOOLBAR_TIP }, // Mute { WWT_CHECKBOX, 2, 24, 185, TOOLBAR_GROUP_START + 61, TOOLBAR_GROUP_START + 72, STR_MUTE_BUTTON_ON_TOOLBAR, STR_MUTE_BUTTON_ON_TOOLBAR_TIP }, // Mute
{ WWT_CHECKBOX, 2, 155, 299, TOOLBAR_GROUP_START + 61, TOOLBAR_GROUP_START + 72, STR_CHAT_BUTTON_ON_TOOLBAR, STR_CHAT_BUTTON_ON_TOOLBAR_TIP }, // Chat
{ WIDGETS_END }, { WIDGETS_END },
#undef TOOLBAR_GROUP_START #undef TOOLBAR_GROUP_START
}; };
@@ -577,7 +579,8 @@ static uint64_t window_options_page_enabled_widgets[] = {
(1 << WIDX_THEMES) | (1 << WIDX_THEMES) |
(1 << WIDX_THEMES_DROPDOWN) | (1 << WIDX_THEMES_DROPDOWN) |
(1 << WIDX_THEMES_BUTTON) | (1 << WIDX_THEMES_BUTTON) |
(1 << WIDX_TOOLBAR_SHOW_MUTE), (1 << WIDX_TOOLBAR_SHOW_MUTE) |
(1 << WIDX_TOOLBAR_SHOW_CHAT) |
MAIN_OPTIONS_ENABLED_WIDGETS | MAIN_OPTIONS_ENABLED_WIDGETS |
(1 << WIDX_REAL_NAME_CHECKBOX) | (1 << WIDX_REAL_NAME_CHECKBOX) |
@@ -852,6 +855,12 @@ static void window_options_mouseup(rct_window* w, rct_widgetindex widgetIndex)
window_invalidate(w); window_invalidate(w);
window_invalidate_by_class(WC_TOP_TOOLBAR); window_invalidate_by_class(WC_TOP_TOOLBAR);
break; break;
case WIDX_TOOLBAR_SHOW_CHAT:
gConfigInterface.toolbar_show_chat ^= 1;
config_save_default();
window_invalidate(w);
window_invalidate_by_class(WC_TOP_TOOLBAR);
break;
case WIDX_INVERT_DRAG: case WIDX_INVERT_DRAG:
gConfigGeneral.invert_viewport_drag ^= 1; gConfigGeneral.invert_viewport_drag ^= 1;
config_save_default(); config_save_default();
@@ -1857,6 +1866,7 @@ static void window_options_invalidate(rct_window* w)
widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_CHEATS, gConfigInterface.toolbar_show_cheats); widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_CHEATS, gConfigInterface.toolbar_show_cheats);
widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_NEWS, gConfigInterface.toolbar_show_news); widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_NEWS, gConfigInterface.toolbar_show_news);
widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_MUTE, gConfigInterface.toolbar_show_mute); widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_MUTE, gConfigInterface.toolbar_show_mute);
widget_set_checkbox_value(w, WIDX_TOOLBAR_SHOW_CHAT, gConfigInterface.toolbar_show_chat);
size_t activeAvailableThemeIndex = theme_manager_get_active_available_theme_index(); size_t activeAvailableThemeIndex = theme_manager_get_active_available_theme_index();
const utf8* activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex); const utf8* activeThemeName = theme_manager_get_available_theme_name(activeAvailableThemeIndex);

View File

@@ -28,6 +28,7 @@
#include <openrct2/actions/ClearAction.hpp> #include <openrct2/actions/ClearAction.hpp>
#include <openrct2/audio/audio.h> #include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h> #include <openrct2/config/Config.h>
#include <openrct2/interface/Chat.h>
#include <openrct2/interface/InteractiveConsole.h> #include <openrct2/interface/InteractiveConsole.h>
#include <openrct2/interface/Screenshot.h> #include <openrct2/interface/Screenshot.h>
#include <openrct2/network/network.h> #include <openrct2/network/network.h>
@@ -78,6 +79,7 @@ enum {
WIDX_RESEARCH, WIDX_RESEARCH,
WIDX_NEWS, WIDX_NEWS,
WIDX_NETWORK, WIDX_NETWORK,
WIDX_CHAT,
WIDX_SEPARATOR, WIDX_SEPARATOR,
}; };
@@ -165,6 +167,7 @@ static constexpr const int32_t left_aligned_widgets_order[] = {
WIDX_FILE_MENU, WIDX_FILE_MENU,
WIDX_MUTE, WIDX_MUTE,
WIDX_NETWORK, WIDX_NETWORK,
WIDX_CHAT,
WIDX_CHEATS, WIDX_CHEATS,
WIDX_DEBUG, WIDX_DEBUG,
@@ -226,6 +229,7 @@ static rct_widget window_top_toolbar_widgets[] = {
{ WWT_TRNBTN, 3, 0x001E, 0x003B, 0, TOP_TOOLBAR_HEIGHT, IMAGE_TYPE_REMAP | SPR_TAB_TOOLBAR, STR_FINANCES_RESEARCH_TIP }, // Research { WWT_TRNBTN, 3, 0x001E, 0x003B, 0, TOP_TOOLBAR_HEIGHT, IMAGE_TYPE_REMAP | SPR_TAB_TOOLBAR, STR_FINANCES_RESEARCH_TIP }, // Research
{ WWT_TRNBTN, 3, 0x001E, 0x003B, 0, TOP_TOOLBAR_HEIGHT, IMAGE_TYPE_REMAP | SPR_TAB_TOOLBAR, STR_SHOW_RECENT_MESSAGES_TIP }, // News { WWT_TRNBTN, 3, 0x001E, 0x003B, 0, TOP_TOOLBAR_HEIGHT, IMAGE_TYPE_REMAP | SPR_TAB_TOOLBAR, STR_SHOW_RECENT_MESSAGES_TIP }, // News
{ WWT_TRNBTN, 0, 0x001E, 0x003B, 0, TOP_TOOLBAR_HEIGHT, IMAGE_TYPE_REMAP | SPR_TAB_TOOLBAR, STR_SHOW_MULTIPLAYER_STATUS_TIP }, // Network { WWT_TRNBTN, 0, 0x001E, 0x003B, 0, TOP_TOOLBAR_HEIGHT, IMAGE_TYPE_REMAP | SPR_TAB_TOOLBAR, STR_SHOW_MULTIPLAYER_STATUS_TIP }, // Network
{ WWT_TRNBTN, 0, 0x001E, 0x003B, 0, TOP_TOOLBAR_HEIGHT, IMAGE_TYPE_REMAP | SPR_TAB_TOOLBAR, STR_TOOLBAR_CHAT_TIP }, // Chat
{ WWT_EMPTY, 0, 0, 10-1, 0, 0, 0xFFFFFFFF, STR_NONE }, // Artificial widget separator { WWT_EMPTY, 0, 0, 10-1, 0, 0, 0xFFFFFFFF, STR_NONE }, // Artificial widget separator
{ WIDGETS_END }, { WIDGETS_END },
@@ -389,6 +393,16 @@ static void window_top_toolbar_mouseup(rct_window* w, rct_widgetindex widgetInde
case WIDX_MUTE: case WIDX_MUTE:
audio_toggle_all_sounds(); audio_toggle_all_sounds();
break; break;
case WIDX_CHAT:
if (chat_available())
{
chat_toggle();
}
else
{
context_show_error(STR_CHAT_UNAVAILABLE, STR_NONE);
}
break;
} }
} }
@@ -689,6 +703,7 @@ static void window_top_toolbar_invalidate(rct_window* w)
window_top_toolbar_widgets[WIDX_VIEW_MENU].type = WWT_TRNBTN; window_top_toolbar_widgets[WIDX_VIEW_MENU].type = WWT_TRNBTN;
window_top_toolbar_widgets[WIDX_MAP].type = WWT_TRNBTN; window_top_toolbar_widgets[WIDX_MAP].type = WWT_TRNBTN;
window_top_toolbar_widgets[WIDX_MUTE].type = WWT_TRNBTN; window_top_toolbar_widgets[WIDX_MUTE].type = WWT_TRNBTN;
window_top_toolbar_widgets[WIDX_CHAT].type = WWT_TRNBTN;
window_top_toolbar_widgets[WIDX_LAND].type = WWT_TRNBTN; window_top_toolbar_widgets[WIDX_LAND].type = WWT_TRNBTN;
window_top_toolbar_widgets[WIDX_WATER].type = WWT_TRNBTN; window_top_toolbar_widgets[WIDX_WATER].type = WWT_TRNBTN;
window_top_toolbar_widgets[WIDX_SCENERY].type = WWT_TRNBTN; window_top_toolbar_widgets[WIDX_SCENERY].type = WWT_TRNBTN;
@@ -712,6 +727,11 @@ static void window_top_toolbar_invalidate(rct_window* w)
window_top_toolbar_widgets[WIDX_MUTE].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_MUTE].type = WWT_EMPTY;
} }
if (!gConfigInterface.toolbar_show_chat)
{
window_top_toolbar_widgets[WIDX_CHAT].type = WWT_EMPTY;
}
if (gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) if (gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
{ {
window_top_toolbar_widgets[WIDX_PAUSE].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_PAUSE].type = WWT_EMPTY;
@@ -767,6 +787,7 @@ static void window_top_toolbar_invalidate(rct_window* w)
{ {
case NETWORK_MODE_NONE: case NETWORK_MODE_NONE:
window_top_toolbar_widgets[WIDX_NETWORK].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_NETWORK].type = WWT_EMPTY;
window_top_toolbar_widgets[WIDX_CHAT].type = WWT_EMPTY;
break; break;
case NETWORK_MODE_CLIENT: case NETWORK_MODE_CLIENT:
window_top_toolbar_widgets[WIDX_PAUSE].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_PAUSE].type = WWT_EMPTY;
@@ -778,7 +799,7 @@ static void window_top_toolbar_invalidate(rct_window* w)
} }
enabledWidgets = 0; enabledWidgets = 0;
for (int i = WIDX_PAUSE; i <= WIDX_NETWORK; i++) for (int i = WIDX_PAUSE; i <= WIDX_CHAT; i++)
if (window_top_toolbar_widgets[i].type != WWT_EMPTY) if (window_top_toolbar_widgets[i].type != WWT_EMPTY)
enabledWidgets |= (1 << i); enabledWidgets |= (1 << i);
w->enabled_widgets = enabledWidgets; w->enabled_widgets = enabledWidgets;
@@ -910,6 +931,17 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi)
gfx_draw_sprite(dpi, imgId, x, y, 3); gfx_draw_sprite(dpi, imgId, x, y, 3);
} }
// Draw chat button
if (window_top_toolbar_widgets[WIDX_CHAT].type != WWT_EMPTY)
{
x = w->x + window_top_toolbar_widgets[WIDX_CHAT].left;
y = w->y + window_top_toolbar_widgets[WIDX_CHAT].top - 2;
if (widget_is_pressed(w, WIDX_CHAT))
y++;
imgId = SPR_G2_CHAT;
gfx_draw_sprite(dpi, imgId, x, y, 3);
}
// Draw debug button // Draw debug button
if (window_top_toolbar_widgets[WIDX_DEBUG].type != WWT_EMPTY) if (window_top_toolbar_widgets[WIDX_DEBUG].type != WWT_EMPTY)
{ {

View File

@@ -298,6 +298,7 @@ namespace Config
model->toolbar_show_cheats = reader->GetBoolean("toolbar_show_cheats", false); model->toolbar_show_cheats = reader->GetBoolean("toolbar_show_cheats", false);
model->toolbar_show_news = reader->GetBoolean("toolbar_show_news", false); model->toolbar_show_news = reader->GetBoolean("toolbar_show_news", false);
model->toolbar_show_mute = reader->GetBoolean("toolbar_show_mute", false); model->toolbar_show_mute = reader->GetBoolean("toolbar_show_mute", false);
model->toolbar_show_chat = reader->GetBoolean("toolbar_show_chat", false);
model->console_small_font = reader->GetBoolean("console_small_font", false); model->console_small_font = reader->GetBoolean("console_small_font", false);
model->current_theme_preset = reader->GetCString("current_theme", "*RCT2"); model->current_theme_preset = reader->GetCString("current_theme", "*RCT2");
model->current_title_sequence_preset = reader->GetCString("current_title_sequence", "*OPENRCT2"); model->current_title_sequence_preset = reader->GetCString("current_title_sequence", "*OPENRCT2");
@@ -314,6 +315,7 @@ namespace Config
writer->WriteBoolean("toolbar_show_cheats", model->toolbar_show_cheats); writer->WriteBoolean("toolbar_show_cheats", model->toolbar_show_cheats);
writer->WriteBoolean("toolbar_show_news", model->toolbar_show_news); writer->WriteBoolean("toolbar_show_news", model->toolbar_show_news);
writer->WriteBoolean("toolbar_show_mute", model->toolbar_show_mute); writer->WriteBoolean("toolbar_show_mute", model->toolbar_show_mute);
writer->WriteBoolean("toolbar_show_chat", model->toolbar_show_chat);
writer->WriteBoolean("console_small_font", model->console_small_font); writer->WriteBoolean("console_small_font", model->console_small_font);
writer->WriteString("current_theme", model->current_theme_preset); writer->WriteString("current_theme", model->current_theme_preset);
writer->WriteString("current_title_sequence", model->current_title_sequence_preset); writer->WriteString("current_title_sequence", model->current_title_sequence_preset);

View File

@@ -102,6 +102,7 @@ struct InterfaceConfiguration
bool toolbar_show_cheats; bool toolbar_show_cheats;
bool toolbar_show_news; bool toolbar_show_news;
bool toolbar_show_mute; bool toolbar_show_mute;
bool toolbar_show_chat;
bool console_small_font; bool console_small_font;
utf8* current_theme_preset; utf8* current_theme_preset;
utf8* current_title_sequence_preset; utf8* current_title_sequence_preset;

View File

@@ -38,6 +38,12 @@ static const char* chat_history_get(uint32_t index);
static uint32_t chat_history_get_time(uint32_t index); static uint32_t chat_history_get_time(uint32_t index);
static void chat_clear_input(); static void chat_clear_input();
bool chat_available()
{
return network_get_mode() != NETWORK_MODE_NONE && network_get_status() == NETWORK_STATUS_CONNECTED
&& network_get_authstatus() == NETWORK_AUTH_OK;
}
void chat_open() void chat_open()
{ {
gChatOpen = true; gChatOpen = true;
@@ -76,8 +82,7 @@ void chat_update()
void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor) void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
{ {
if (network_get_mode() == NETWORK_MODE_NONE || network_get_status() != NETWORK_STATUS_CONNECTED if (!chat_available())
|| network_get_authstatus() != NETWORK_AUTH_OK)
{ {
gChatOpen = false; gChatOpen = false;
return; return;

View File

@@ -28,6 +28,7 @@ enum CHAT_INPUT
extern bool gChatOpen; extern bool gChatOpen;
bool chat_available();
void chat_open(); void chat_open();
void chat_close(); void chat_close();
void chat_toggle(); void chat_toggle();

View File

@@ -3901,6 +3901,11 @@ enum
STR_AUTOSAVE_AMOUNT = 6278, STR_AUTOSAVE_AMOUNT = 6278,
STR_AUTOSAVE_AMOUNT_TIP = 6279, STR_AUTOSAVE_AMOUNT_TIP = 6279,
STR_TOOLBAR_CHAT_TIP = 6280,
STR_CHAT_BUTTON_ON_TOOLBAR_TIP = 6281,
STR_CHAT_BUTTON_ON_TOOLBAR = 6282,
STR_CHAT_UNAVAILABLE = 6283,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768 STR_COUNT = 32768
}; };

View File

@@ -827,8 +827,9 @@ enum
SPR_G2_SELECTION_EDGE_SE = SPR_G2_BEGIN + 111, SPR_G2_SELECTION_EDGE_SE = SPR_G2_BEGIN + 111,
SPR_G2_EYEDROPPER = SPR_G2_BEGIN + 112, SPR_G2_EYEDROPPER = SPR_G2_BEGIN + 112,
SPR_G2_CHAT = SPR_G2_BEGIN + 113,
SPR_G2_CHAR_BEGIN = SPR_G2_BEGIN + 113, SPR_G2_CHAR_BEGIN = SPR_G2_BEGIN + 114,
SPR_G2_AE_UPPER = SPR_G2_CHAR_BEGIN, SPR_G2_AE_UPPER = SPR_G2_CHAR_BEGIN,
SPR_G2_AE_LOWER = SPR_G2_CHAR_BEGIN + 1, SPR_G2_AE_LOWER = SPR_G2_CHAR_BEGIN + 1,
@@ -918,7 +919,6 @@ enum
SPR_G2_E_CARON_LOWER = SPR_G2_CHAR_BEGIN + 73, SPR_G2_E_CARON_LOWER = SPR_G2_CHAR_BEGIN + 73,
SPR_G2_ROUBLE_SIGN = SPR_G2_CHAR_BEGIN + 74, SPR_G2_ROUBLE_SIGN = SPR_G2_CHAR_BEGIN + 74,
SPR_G2_CHAR_END = SPR_G2_ROUBLE_SIGN, SPR_G2_CHAR_END = SPR_G2_ROUBLE_SIGN,
SPR_G2_GLYPH_COUNT = (SPR_G2_CHAR_END - SPR_G2_CHAR_BEGIN) + 1, SPR_G2_GLYPH_COUNT = (SPR_G2_CHAR_END - SPR_G2_CHAR_BEGIN) + 1,