Menu-FN: Throw up a panel for when you get disconnect from a server for one reason or another
This commit is contained in:
parent
b7346e6593
commit
f1141d3b11
3 changed files with 64 additions and 1 deletions
|
@ -79,10 +79,19 @@ Menu_PlayStartupVideos(void)
|
|||
//localcmd("playvideo av:media/sierra.avi av:media/valve.avi\n");
|
||||
}
|
||||
|
||||
|
||||
CDialog main_dgDisconnect;
|
||||
CMainButton main_btnRefOK;
|
||||
var bool serverDisconnect = false;
|
||||
|
||||
/* called upon menu init/restart */
|
||||
void
|
||||
m_init(void)
|
||||
{
|
||||
void m_init_okdisconnect(void) {
|
||||
serverDisconnect = false;
|
||||
}
|
||||
|
||||
string menuMap;
|
||||
|
||||
print("--------- Initializing Menu ----------\n");
|
||||
|
@ -162,6 +171,15 @@ m_init(void)
|
|||
if (Menu_HasStartupVideos() == true)
|
||||
Menu_PlayStartupVideos();
|
||||
|
||||
/* init the disconnect dialog */
|
||||
main_dgDisconnect = spawn(CDialog);
|
||||
main_btnRefOK = spawn(CMainButton);
|
||||
main_btnRefOK.SetImage(BTN_OK);
|
||||
main_btnRefOK.SetPos(233,291);
|
||||
main_btnRefOK.SetLength(68);
|
||||
main_btnRefOK.SetExecute(m_init_okdisconnect);
|
||||
Widget_Add(main_dgDisconnect, main_btnRefOK);
|
||||
|
||||
g_initialized = true;
|
||||
}
|
||||
|
||||
|
@ -295,6 +313,21 @@ m_draw(vector screensize)
|
|||
/* draw the actual widgets */
|
||||
main_draw();
|
||||
|
||||
/* did the server disconnect us?...*/
|
||||
if (Error_ServerDisconnected() == true) {
|
||||
serverDisconnect = true;
|
||||
}
|
||||
|
||||
/* if that happened, throw up a panel with an OK button. */
|
||||
if (serverDisconnect == true) {
|
||||
main_dgDisconnect.Draw();
|
||||
Widget_Draw(main_dgDisconnect);
|
||||
WField_Static(162, 180, "Disconnected", 320, 260,
|
||||
col_prompt_text, 1.0f, 2, font_label_p);
|
||||
WField_Static(162, 220, Error_GetDisconnectReason(), 320, 260,
|
||||
col_prompt_title, 1.0f, 2, font_label_p);
|
||||
}
|
||||
|
||||
oldtime = time;
|
||||
}
|
||||
|
||||
|
@ -330,7 +363,11 @@ Menu_InputEvent(float evtype, float scanx, float chary, float devid)
|
|||
break;
|
||||
}
|
||||
|
||||
main_input(evtype, scanx, chary, devid);
|
||||
if (serverDisconnect)
|
||||
Widget_Input(main_dgDisconnect, evtype, scanx, chary, devid);
|
||||
else
|
||||
main_input(evtype, scanx, chary, devid);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "updates.h"
|
||||
#include "gamelibrary.h"
|
||||
#include "maplibrary.h"
|
||||
#include "error.h"
|
||||
|
||||
/** Definitions for FTE's internal package manager. We don't want you to talk to this one directly within Nuclide. */
|
||||
typedef enum
|
||||
|
|
25
src/platform/error.h
Normal file
25
src/platform/error.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
var string g_lastDisconnectReason = "";
|
||||
|
||||
bool
|
||||
Error_ServerDisconnected(void)
|
||||
{
|
||||
string disconnectReason;
|
||||
|
||||
disconnectReason = cvar_string("_cl_disconnectreason");
|
||||
|
||||
/* still empty */
|
||||
if (disconnectReason == "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* save to cache */
|
||||
g_lastDisconnectReason = disconnectReason;
|
||||
cvar_set("_cl_disconnectreason", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
string
|
||||
Error_GetDisconnectReason(void)
|
||||
{
|
||||
return g_lastDisconnectReason;
|
||||
}
|
Loading…
Reference in a new issue