mirror of https://github.com/OpenRCT2/OpenRCT2.git
add chat feature
This commit is contained in:
parent
196e6eb675
commit
99f2b87043
|
@ -3831,3 +3831,6 @@ STR_5489 :{SMALLFONT}{BLACK}Show only tracked guests
|
|||
STR_5490 :Disable audio on focus loss
|
||||
STR_5491 :Inventions list
|
||||
STR_5492 :Scenario options
|
||||
|
||||
STR_6000 :Send Message
|
||||
STR_6001 :Type the message you would like to send.
|
||||
|
|
|
@ -986,6 +986,7 @@ static const uint16 _defaultShortcutKeys[SHORTCUT_COUNT] = {
|
|||
SDL_SCANCODE_EQUALS, // SHORTCUT_INCREASE_GAME_SPEED,
|
||||
CTRL | ALT | SDL_SCANCODE_C, // SHORTCUT_OPEN_CHEAT_WINDOW,
|
||||
SDL_SCANCODE_T, // SHORTCUT_REMOVE_TOP_BOTTOM_TOOLBAR_TOGGLE,
|
||||
SDL_SCANCODE_C // SHORTCUT_OPEN_CHAT_WINDOW
|
||||
SDL_SCANCODE_UP, // SHORTCUT_SCROLL_MAP_UP
|
||||
SDL_SCANCODE_LEFT, // SHORTCUT_SCROLL_MAP_LEFT
|
||||
SDL_SCANCODE_DOWN, // SHORTCUT_SCROLL_MAP_DOWN
|
||||
|
|
|
@ -72,6 +72,7 @@ enum {
|
|||
SHORTCUT_INCREASE_GAME_SPEED,
|
||||
SHORTCUT_OPEN_CHEAT_WINDOW,
|
||||
SHORTCUT_REMOVE_TOP_BOTTOM_TOOLBAR_TOGGLE,
|
||||
SHORTCUT_OPEN_CHAT_WINDOW,
|
||||
SHORTCUT_SCROLL_MAP_UP,
|
||||
SHORTCUT_SCROLL_MAP_LEFT,
|
||||
SHORTCUT_SCROLL_MAP_DOWN,
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "../game.h"
|
||||
#include "../input.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../network/network.h"
|
||||
#include "keyboard_shortcut.h"
|
||||
#include "viewport.h"
|
||||
#include "window.h"
|
||||
|
@ -493,6 +494,11 @@ static void shortcut_open_cheat_window()
|
|||
window_cheats_open();
|
||||
}
|
||||
|
||||
static void shortcut_open_chat_window()
|
||||
{
|
||||
network_open_chat_box();
|
||||
}
|
||||
|
||||
static const shortcut_action shortcut_table[SHORTCUT_COUNT] = {
|
||||
shortcut_close_top_most_window,
|
||||
shortcut_close_all_floating_windows,
|
||||
|
@ -533,6 +539,7 @@ static const shortcut_action shortcut_table[SHORTCUT_COUNT] = {
|
|||
shortcut_increase_game_speed,
|
||||
shortcut_open_cheat_window,
|
||||
shortcut_remove_top_bottom_toolbar_toggle,
|
||||
shortcut_open_chat_window
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -446,12 +446,12 @@ enum {
|
|||
WC_CHANGELOG = 121,
|
||||
WC_TITLE_EDITOR = 122,
|
||||
WC_TITLE_COMMAND_EDITOR = 123,
|
||||
WC_CHAT_HOST = 124,
|
||||
|
||||
// Only used for colour schemes
|
||||
WC_STAFF = 220,
|
||||
WC_EDITOR_TRACK_BOTTOM_TOOLBAR = 221,
|
||||
WC_EDITOR_SCENARIO_BOTTOM_TOOLBAR = 222,
|
||||
|
||||
} WINDOW_CLASS;
|
||||
|
||||
enum PROMPT_MODE {
|
||||
|
|
|
@ -434,3 +434,20 @@ void news_item_disable_news(uint8 type, uint32 assoc)
|
|||
}
|
||||
}
|
||||
|
||||
void news_item_add_to_queue_custom(rct_news_item *newNewsItem)
|
||||
{
|
||||
int i = 0;
|
||||
rct_news_item *newsItem = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item);
|
||||
|
||||
// Find first open slot
|
||||
while (newsItem->type != NEWS_ITEM_NULL) {
|
||||
if (newsItem + 1 >= (rct_news_item*)0x013CB1CC)
|
||||
news_item_close_current();
|
||||
else
|
||||
newsItem++;
|
||||
}
|
||||
|
||||
*newsItem = *newNewsItem;
|
||||
newsItem++;
|
||||
newsItem->type = 0;
|
||||
}
|
||||
|
|
|
@ -66,4 +66,6 @@ bool news_item_is_empty(int index);
|
|||
bool news_item_is_queue_empty();
|
||||
bool news_item_is_valid_idx(int index);
|
||||
|
||||
void news_item_add_to_queue_custom(rct_news_item *newNewsItem);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,12 @@
|
|||
|
||||
#ifndef DISABLE_NETWORK
|
||||
|
||||
#include "../addresses.h"
|
||||
#include "../game.h"
|
||||
#include "../interface/window.h"
|
||||
#include "../localisation/date.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../management/news_item.h"
|
||||
#include "network.h"
|
||||
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
@ -220,14 +225,30 @@ static void network_process_packet(network_packet *packet)
|
|||
{
|
||||
uint32 *args;
|
||||
int command;
|
||||
rct_news_item newsItem;
|
||||
|
||||
args = (uint32*)&packet->data;
|
||||
command = args[0];
|
||||
|
||||
if (gNetworkStatus == NETWORK_CLIENT)
|
||||
command |= (1 << 31);
|
||||
switch (command) {
|
||||
case 700:
|
||||
newsItem.type = NEWS_ITEM_BLANK;
|
||||
newsItem.flags = 1;
|
||||
newsItem.assoc = 0;
|
||||
newsItem.ticks = 0;
|
||||
newsItem.month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
|
||||
newsItem.day = ((days_in_month[(newsItem.month_year & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16) + 1;
|
||||
newsItem.colour = FORMAT_TOPAZ;
|
||||
strcpy(newsItem.text, packet->data + 4);
|
||||
news_item_add_to_queue_custom(&newsItem);
|
||||
break;
|
||||
default:
|
||||
if (gNetworkStatus == NETWORK_CLIENT)
|
||||
command |= (1 << 31);
|
||||
|
||||
game_do_command_p(command, &args[1], &args[2], &args[3], &args[4], &args[5], &args[6], &args[7]);
|
||||
game_do_command_p(command, &args[1], &args[2], &args[3], &args[4], &args[5], &args[6], &args[7]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void network_send_packet(network_packet *packet)
|
||||
|
@ -249,4 +270,70 @@ void network_print_error()
|
|||
LocalFree(s);
|
||||
}
|
||||
|
||||
static void window_chat_host_emptysub() { }
|
||||
|
||||
static void window_chat_host_textinput()
|
||||
{
|
||||
rct_window *w;
|
||||
short widgetIndex;
|
||||
uint8 result;
|
||||
char *text;
|
||||
|
||||
window_textinput_get_registers(w, widgetIndex, result, text);
|
||||
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
network_packet packet;
|
||||
packet.size = 4 + strlen(text) + 1;
|
||||
*((uint32*)packet.data) = 700;
|
||||
strcpy(packet.data + 4, text);
|
||||
|
||||
network_send_packet(&packet);
|
||||
|
||||
window_close(w);
|
||||
}
|
||||
|
||||
static void* window_chat_host_events[] = {
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_textinput,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub,
|
||||
window_chat_host_emptysub
|
||||
};
|
||||
|
||||
void network_open_chat_box()
|
||||
{
|
||||
rct_window *w;
|
||||
w = window_create(0, 0, 0, 0, (uint32*)window_chat_host_events, WC_CHAT_HOST, 0);
|
||||
w->colours[0] = 1;
|
||||
w->colours[1] = 1;
|
||||
w->colours[2] = 0;
|
||||
w->number = 0;
|
||||
window_text_input_open(w, 0, 6000, 6001, STR_NONE, 0, 64);
|
||||
}
|
||||
|
||||
#endif /* DISABLE_NETWORK */
|
|
@ -61,6 +61,8 @@ void network_end_server();
|
|||
void network_update();
|
||||
void network_send_packet(network_packet *packet);
|
||||
|
||||
void network_open_chat_box();
|
||||
|
||||
void network_print_error();
|
||||
|
||||
#endif /* DISABLE_NETWORK */
|
||||
|
|
Loading…
Reference in New Issue