add connected/disconnected events for plugins

This commit is contained in:
UnknownShadow200 2019-02-13 21:21:21 +11:00
parent 6e3ea84eaf
commit 399e73e861
5 changed files with 13 additions and 3 deletions

View File

@ -12,6 +12,7 @@ struct _ChatEventsList ChatEvents;
struct _WindowEventsList WindowEvents;
struct _KeyEventsList KeyEvents;
struct _MouseEventsList MouseEvents;
struct _NetEventsList NetEvents;
void Event_Register(struct Event_Void* handlers, void* obj, Event_Void_Callback handler) {
int i;

View File

@ -187,4 +187,9 @@ CC_VAR extern struct _MouseEventsList {
struct Event_Int Up; /* Mouse button is released (Arg is MouseButton member) */
struct Event_Float Wheel; /* Mouse wheel is moved/scrolled (Arg is wheel delta) */
} MouseEvents;
CC_VAR extern struct _NetEventsList {
struct Event_Void Connected; /* Connection to a server was established. */
struct Event_Void Disconnected; /* Connection to the server was lost. */
} NetEvents;
#endif

View File

@ -168,8 +168,10 @@ void Game_UpdateProjection(void) {
}
void Game_Disconnect(const String* title, const String* reason) {
Event_RaiseVoid(&NetEvents.Disconnected);
World_Reset();
Event_RaiseVoid(&WorldEvents.NewMap);
Gui_FreeActive();
Gui_SetActive(DisconnectScreen_MakeInstance(title, reason));
Game_Reset();

View File

@ -265,8 +265,10 @@ static TimeMS net_connectTimeout;
static void Server_Free(void);
static void MPConnection_FinishConnect(void) {
net_connecting = false;
Event_RaiseVoid(&NetEvents.Connected);
Event_RaiseFloat(&WorldEvents.Loading, 0.0f);
net_readCurrent = net_readBuffer;
net_readCurrent = net_readBuffer;
Server.WriteBuffer = net_writeBuffer;
Handlers_Reset();

View File

@ -58,7 +58,7 @@ static Rect2D prev_bounds; /* Used to restore previous size when leaving fullscr
/*########################################################################################################################*
*-----------------------------------------------------Private details-----------------------------------------------------*
*#########################################################################################################################*/
static uint8_t key_map[14 * 16] = {
const static uint8_t key_map[14 * 16] = {
0, 0, 0, 0, 0, 0, 0, 0, KEY_BACKSPACE, KEY_TAB, 0, 0, 0, KEY_ENTER, 0, 0,
0, 0, 0, KEY_PAUSE, KEY_CAPSLOCK, 0, 0, 0, 0, 0, 0, KEY_ESCAPE, 0, 0, 0, 0,
KEY_SPACE, KEY_PAGEUP, KEY_PAGEDOWN, KEY_END, KEY_HOME, KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN, 0, KEY_PRINTSCREEN, 0, KEY_PRINTSCREEN, KEY_INSERT, KEY_DELETE, 0,
@ -1739,7 +1739,7 @@ static bool ctx_pendingWindowed, ctx_pendingFullscreen;
*-----------------------------------------------------Private details-----------------------------------------------------*
*#########################################################################################################################*/
/* Sourced from https://www.meandmark.com/keycodes.html */
static uint8_t key_map[8 * 16] = {
const static uint8_t key_map[8 * 16] = {
'A', 'S', 'D', 'F', 'H', 'G', 'Z', 'X', 'C', 'V', 0, 'B', 'Q', 'W', 'E', 'R',
'Y', 'T', '1', '2', '3', '4', '6', '5', KEY_PLUS, '9', '7', KEY_MINUS, '8', '0', KEY_RBRACKET, 'O',
'U', KEY_LBRACKET, 'I', 'P', KEY_ENTER, 'L', 'J', KEY_QUOTE, 'K', KEY_SEMICOLON, KEY_BACKSLASH, KEY_COMMA, KEY_SLASH, 'N', 'M', KEY_PERIOD,