VGUI new system for MoTD, major pre-spawn UI cleanup
This commit is contained in:
parent
0af2292d70
commit
3b37190955
25 changed files with 742 additions and 536 deletions
|
@ -104,7 +104,7 @@ ClientGame_ConsoleCommand(void)
|
|||
|
||||
break;
|
||||
case "chooseteam":
|
||||
//VGUI_ChooseTeam();
|
||||
|
||||
break;
|
||||
|
||||
//TAGGG - CRITICAL
|
||||
|
|
|
@ -32,8 +32,7 @@ vector g_hudres;
|
|||
// Yes using old VGUI is kinda crappy but good for now.
|
||||
vector vHUDColor; // Defined in HUD_Draw (HUD.c)
|
||||
*/
|
||||
vector vVGUIColor; // Defined in HUD_Draw (VGUI.c)
|
||||
vector vCrossColor; // Defined in HUD_Draw (HUDCrosshair.c)
|
||||
vector g_UI_Color;
|
||||
|
||||
// Global var to store the current screen size. If it changes, the font should be re-loaded to fit it.
|
||||
var vector g_videoResPrev;
|
||||
|
|
|
@ -126,7 +126,7 @@ HUD_Draw(void)
|
|||
drawTimer();
|
||||
|
||||
// Links to drawing the MoTD and buymenu when appropriate
|
||||
UI_Draw(pl);
|
||||
UI_Draw();
|
||||
|
||||
}// pl.iState check
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ ClientGame_Init(float apilevel, string enginename, float engineversion)
|
|||
// using the new VGUI approach.
|
||||
// That also includes mentions of fonts in ts/src/client/vgui.qc
|
||||
|
||||
// Also see ts/src/client/vgui.qc where UI_Draw checks to see if the screen
|
||||
// Also see ts/src/client/ui.qc where UI_Draw checks to see if the screen
|
||||
// size has been changed or this is the first time drawing (some FONTs having ID -1).
|
||||
// In either case, they're loaded and sized per screen height over there.
|
||||
FONT_ARIAL = -1; //specify me at draw startup instead, if this is safe.
|
||||
|
|
|
@ -10,8 +10,6 @@ drawWeaponOptionBar(
|
|||
drawfill( arg_vDrawOrigin, [128, 19], clrPaleBlue, arg_opac - 0.55f );
|
||||
Gfx_Text( [arg_vDrawOrigin.x + 2, arg_vDrawOrigin.y + 4], arg_sOptionName, vButtonFontSize, clrPaleBlue, 0.90f, DRAWFLAG_ADDITIVE, FONT_ARIAL_STD );
|
||||
|
||||
//arg_vDrawOrigin.y -= 20;
|
||||
//will not work.
|
||||
vector tempVec = [arg_vDrawOrigin.x + 112, arg_vDrawOrigin.y + 1];
|
||||
|
||||
if(arg_fBrightLight){
|
||||
|
@ -247,8 +245,8 @@ drawPlayerInventory(BOOL arg_fBuyMode)
|
|||
drawPlayerInventory_place(akimboRef.iInventorySlot-1, ary_slotRowYet[akimboRef.iInventorySlot-1], akimboRef.sIconFilePath, sWeaponDisplayName, arg_fBuyMode, ammoCount, hasAnyAmmo, bitsUpgradeOpts );
|
||||
ary_slotRowYet[akimboRef.iInventorySlot-1]++; //ditto for the akimbo slot.
|
||||
}
|
||||
}//END OF for all ary_myWeapons (within softMax)
|
||||
}//END OF drawPlayerInveotry_buy
|
||||
}// for all ary_myWeapons (within softMax)
|
||||
}// drawPlayerInveotry_buy
|
||||
|
||||
|
||||
// "hasAnyAmmo" is, whether this weapon has any ammo in the clip or the ammo pool.
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#define CLASSIC_VGUI
|
||||
#define GS_RENDERFX
|
||||
|
||||
// NEW. If defined, uses the new VGUI system.
|
||||
// By default, the old pseudo-way made of primitive draw calls is used
|
||||
#define MOTD_NEW_VGUI
|
||||
|
||||
// NEW. When present, the origin is exactly at the center of the player, no further offsets.
|
||||
// Keeps the view identical on the player dying and becoming spectator in place.
|
||||
|
@ -58,10 +61,7 @@ hud.h
|
|||
../shared/inventory_logic.qc
|
||||
|
||||
//TAGGG - NEW
|
||||
vguiobjects.qc
|
||||
vgui_motd.qc
|
||||
ui_buymenu.qc
|
||||
ui.qc
|
||||
// old location of UI draw stuff
|
||||
|
||||
hud_crosshair.qc
|
||||
hud_scope.qc
|
||||
|
@ -107,6 +107,10 @@ precache.qc
|
|||
../../../src/client/include.src
|
||||
../../../src/shared/include.src
|
||||
|
||||
vguiobjects.qc
|
||||
ui_eventgrabber.qc
|
||||
ui_motd.qc
|
||||
ui_buymenu.qc
|
||||
ui.qc
|
||||
|
||||
#endlist
|
||||
|
|
|
@ -39,6 +39,8 @@ struct
|
|||
|
||||
ClientInfo_t m_clientinfo;
|
||||
|
||||
float flBlockSpawnTime;
|
||||
|
||||
} g_seatslocal[4], *pSeatLocal;
|
||||
|
||||
void pSeatLocal_init(void);
|
||||
|
|
|
@ -10,6 +10,6 @@ pSeatLocal_init(void)
|
|||
|
||||
pSeatLocal->m_inputKeyTapped = 0;
|
||||
pSeatLocal->m_inputKeyDown = 0;
|
||||
pSeatLocal->m_inputMouseClicked = 0;
|
||||
pSeatLocal->m_inputMouseClicked = FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
|
||||
|
||||
#define VGUI_WINDOW_BGCOLOR '0.0 0.0 0.0'
|
||||
#define VGUI_WINDOW_FGCOLOR '1.0 0.5 0.0'
|
||||
#define VGUI_WINDOW_BGALPHA 0.76
|
||||
#define VGUI_WINDOW_FGALPHA 1.0
|
||||
|
||||
vector vVGUIWindowPos;
|
||||
vector vVGUIWindowSiz;
|
||||
var vector g_UI_WindowPos;
|
||||
var vector g_UI_WindowSize;
|
||||
var float g_fontSizeMulti;
|
||||
var BOOL g_UI_queueInit = FALSE;
|
||||
|
||||
string sMOTDString[25];
|
||||
string sMapString[35];
|
||||
|
||||
var string sMOTD_total;
|
||||
|
||||
class player;
|
||||
var string sMapString_total;
|
||||
|
||||
|
||||
// Keep in synch with the vguiMenus array of vgui.c
|
||||
// Keep in synch with the ary_UI_Screen array of ui.qc
|
||||
enum UI_SCREEN{
|
||||
NONE = 0,
|
||||
MOTD,
|
||||
|
@ -24,24 +24,32 @@ enum UI_SCREEN{
|
|||
};
|
||||
|
||||
typedef struct {
|
||||
string sTitle;
|
||||
// start at FALSE, set to TRUE if done before
|
||||
BOOL bInitializedYet;
|
||||
|
||||
// Whether to do a VGUI_Window call to draw a window.
|
||||
// Not very customizable for now, intended only for the MoTD, but adapts to different screen sizes.
|
||||
// Could have other settings added later, or even be handled per screen's draw call too for completely re-doing
|
||||
// ---This will be removed on the move to the new VGUI.
|
||||
BOOLEAN fDrawMainWindowAuto;
|
||||
|
||||
// Custom draw script for a particular screen choice
|
||||
//TAGGG - now accepts how much to change the font size (and adjust other things) by.
|
||||
// Also accepts the player for getting other info from.
|
||||
void(player arg_player, vector vPos, vector vWindowSiz, float fFontSizeMulti ) vDraw;
|
||||
void(void) funInit;
|
||||
void(void) funShow;
|
||||
void(void) funHide;
|
||||
void(void) funDraw;
|
||||
void(void) funOnMouseClick;
|
||||
void(void) funOnKeyDown;
|
||||
// What to do the moment the screen is changed to this.
|
||||
void(void) vOnInit;
|
||||
} vguiwindow_t;
|
||||
} ui_screen_t;
|
||||
|
||||
|
||||
|
||||
void UI_Init(void);
|
||||
float UI_Draw( player arg_player);
|
||||
void UI_Draw(void);
|
||||
void UI_MouseClick(void);
|
||||
void UI_KeyDown(void);
|
||||
void UI_ChangeScreen(UI_SCREEN fNewScreenID);
|
||||
BOOL UI_CheckMouse(vector vPos, vector vReg);
|
||||
|
||||
void UI_determineDrawGlobals(void);
|
||||
|
||||
|
|
407
src/client/ui.qc
407
src/client/ui.qc
|
@ -22,29 +22,83 @@
|
|||
// The identifier and value for that language will show up.
|
||||
// In this case, VGUI_TITLE_MODT won't be used. This new way mimicks the original The
|
||||
// Specialists initial screen a little more.
|
||||
// We can't use logic stuff in a global scope like this. This (vguiMenus[0].sTitle) can
|
||||
// be set in an init method instead.
|
||||
|
||||
|
||||
// Keep in synch with vgui.h's UI_SCREEN enum choices, besides the NONE choice.
|
||||
|
||||
//font_s FONT_ARIAL_TITLE_EX;
|
||||
|
||||
|
||||
// Keep in synch with ui.h's UI_SCREEN enum choices, besides the NONE choice.
|
||||
// That isn't represented, not even by a dummy.
|
||||
var vguiwindow_t vguiMenus[] = {
|
||||
//{ _("VGUI_TITLE_MOTD"), VGUI_MessageOfTheDay },
|
||||
{ "", TRUE, VGUI_MessageOfTheDay, NULL },
|
||||
{ "", FALSE, UI_BuyMenu_Update, UI_BuyMenu_OnInit}
|
||||
var ui_screen_t ary_UI_Screen[] = {
|
||||
{
|
||||
FALSE,
|
||||
TRUE,
|
||||
UI_MOTD_Init,
|
||||
UI_MOTD_Show,
|
||||
UI_MOTD_Hide,
|
||||
UI_MOTD_Draw,
|
||||
UI_MOTD_OnMouseClick,
|
||||
UI_MOTD_OnKeyDown
|
||||
},
|
||||
{
|
||||
FALSE,
|
||||
FALSE,
|
||||
UI_BuyMenu_Init,
|
||||
UI_BuyMenu_Show,
|
||||
UI_BuyMenu_Hide,
|
||||
UI_BuyMenu_Draw,
|
||||
UI_BuyMenu_OnMouseClick,
|
||||
UI_BuyMenu_OnKeyDown
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//var float nextPrintoutTime = -1;
|
||||
|
||||
|
||||
// Actually sees if funInit should be called (first time going to that screen),
|
||||
// also calls funShow.
|
||||
void
|
||||
UI_InitCheck(void){
|
||||
if(
|
||||
!ary_UI_Screen[pSeatLocal->m_flUI_Display-1].bInitializedYet &&
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funInit != NULL
|
||||
){
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funInit();
|
||||
}
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].bInitializedYet = TRUE;
|
||||
if(
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funShow != NULL
|
||||
){
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funShow();
|
||||
}
|
||||
g_UI_queueInit = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
UI_ChangeScreen(UI_SCREEN arg_NewScreenID)
|
||||
{
|
||||
g_UI_queueInit = FALSE;
|
||||
|
||||
if(
|
||||
pSeatLocal->m_flUI_Display != UI_SCREEN::NONE &&
|
||||
arg_NewScreenID != pSeatLocal->m_flUI_Display
|
||||
){
|
||||
// First, check the existing m_flUI_Display. If valid, call funHide for it
|
||||
// (does not apply to setting the screen to the same choice)
|
||||
if(
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funHide != NULL
|
||||
){
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funHide();
|
||||
}
|
||||
}
|
||||
|
||||
pSeatLocal->m_flUI_Display = (float)arg_NewScreenID;
|
||||
|
||||
printfline("UI_ChangeScreen:: arg_NewScreenID? %d", arg_NewScreenID);
|
||||
|
||||
if(arg_NewScreenID <= UI_SCREEN::NONE){
|
||||
if(arg_NewScreenID == UI_SCREEN::NONE){
|
||||
// If at NONE or below, also do nothing. This has no "vOnInit" behavior.
|
||||
// Besides obligatory cleanup if we choose (which may as well be done right here)
|
||||
// And turn the cursor lock off.
|
||||
|
@ -52,6 +106,14 @@ UI_ChangeScreen(UI_SCREEN arg_NewScreenID)
|
|||
// And don't let Nuclide's src/client/entry.qc try to re-lock the mouse!
|
||||
printfline("TURN SCREEN OFF.");
|
||||
gFun_UI_EventGrabber_Hide();
|
||||
|
||||
// Don't allow the same click to spawn the player, likely not intentional.
|
||||
// Unless we want to deviate from original TS and let buymenu-closing orders
|
||||
// count as spawn requests.
|
||||
// Questionably effective but better than nothing maybe.
|
||||
player pl = (player)pSeat->m_ePlayer;
|
||||
pl.gflags |= GF_SEMI_TOGGLED;
|
||||
pSeatLocal->flBlockSpawnTime = time + 0.20;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,30 +128,112 @@ UI_ChangeScreen(UI_SCREEN arg_NewScreenID)
|
|||
// And let the event grabber be shown so that entry.qc doesn't try to undo the mouse lock.
|
||||
gFun_UI_EventGrabber_Show();
|
||||
|
||||
printfline("TURN SCREEN ON?? WHy. %d", arg_NewScreenID);
|
||||
if(vguiMenus[arg_NewScreenID - 1].vOnInit != NULL){
|
||||
vguiMenus[arg_NewScreenID - 1].vOnInit();
|
||||
if(video_res[0] == 0){
|
||||
// haven't set the screen resolution vars yet?
|
||||
// STOP: handle this as soon as possible.
|
||||
g_UI_queueInit = TRUE;
|
||||
return;
|
||||
}
|
||||
}//changeScreen
|
||||
|
||||
UI_InitCheck();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
UI_Draw
|
||||
|
||||
This is the entry point for FreeTS's (cloned from FreeCS) own "VGUI" implementation
|
||||
Run every frame
|
||||
=================
|
||||
*/
|
||||
float
|
||||
UI_Draw(player arg_player)
|
||||
void
|
||||
UI_Init(void)
|
||||
{
|
||||
if ( pSeatLocal->m_flUI_Display == UI_SCREEN::NONE ) {
|
||||
setcursormode( FALSE );
|
||||
return FALSE;
|
||||
string sTemp;
|
||||
int iMOTDLength;
|
||||
int i;
|
||||
int s;
|
||||
|
||||
filestream fmMapDescr;
|
||||
|
||||
// First load the MESSAGE OF THE DAY from the sever
|
||||
//sMOTD_total = serverkey("motd_total");
|
||||
|
||||
sMOTD_total = "";
|
||||
|
||||
iMOTDLength = stof( serverkey( "motdlength" ) );
|
||||
for (i = 0; i < iMOTDLength; i++ ) {
|
||||
sMOTDString[ i ] = serverkey( sprintf( "motdline%i", i ) );
|
||||
|
||||
if ( sMOTDString[ i ] == "/" ) {
|
||||
sMOTD_total = strcat(sMOTD_total, "\n" );
|
||||
}else{
|
||||
sMOTD_total = strcat(sMOTD_total, sprintf("%s\n", sMOTDString[ i ]) );
|
||||
}
|
||||
}
|
||||
//int geh = vguiMenus.length;
|
||||
//vTextPos[1] += 14;
|
||||
// color it
|
||||
// NOPE! Let this be handled elsewhere in case of a different color choice!
|
||||
//sMOTD_total = strcat("^xFA0", sMOTD_total);
|
||||
|
||||
|
||||
// Now load the MAP DESCRIPTION
|
||||
// TAGGG
|
||||
// Do we have any use for this though? Check original TS, the "Select Team"
|
||||
// screen does (press enter to close or after closing the MoTD, probably)
|
||||
|
||||
sMapString_total = "";
|
||||
|
||||
//printfline("MAPNAME READS: %s", mapname);
|
||||
// TODO! If the mapname ends in .bsp, remove that portion, that causes
|
||||
// the appended ".txt" to work wrongly, "mymap.bsp.txt" instead of "mymap.txt"
|
||||
|
||||
fmMapDescr = fopen( sprintf( "maps/%s.txt", mapname ), FILE_READ );
|
||||
if ( fmMapDescr != -1 ) {
|
||||
for (i = 0; i < 35; i++ ) {
|
||||
sTemp = fgets( fmMapDescr );
|
||||
if not ( sTemp ) {
|
||||
break;
|
||||
}
|
||||
sMapString[ i ] = sTemp;
|
||||
|
||||
/*
|
||||
if (sMapString[ i ] == "/" ) {
|
||||
sMapString_total = strcat(sMOTD_total, "\n" );
|
||||
}else{
|
||||
sMapString_total = strcat(sMapString_total, sprintf("%s\n", sMapString[ i ]) );
|
||||
}
|
||||
*/
|
||||
sMapString_total = strcat(sMapString_total, sprintf("%s\n", sMapString[ i ]) );
|
||||
|
||||
}
|
||||
fclose( fmMapDescr );
|
||||
}
|
||||
|
||||
//printfline("MAP DESCRIPTOR?");
|
||||
//printfline("%s", sMapString_total);
|
||||
|
||||
|
||||
gFun_UI_EventGrabber_Initialize();
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// FOR NOW, a lazy way of init for all seats.
|
||||
// Apply to all seats, not worrying about what numclientseats is because this is tiny.
|
||||
if (serverkeyfloat("slots") != 1) {
|
||||
// We start on the MOTD, always
|
||||
for (s = 0; s < g_seats.length; s++){
|
||||
pSeat = &g_seats[s];
|
||||
pSeatLocal = &g_seatslocal[s];
|
||||
UI_ChangeScreen(UI_SCREEN::MOTD);
|
||||
}
|
||||
}else{
|
||||
// make all pSeats start at the NONE screen instead
|
||||
for (s = 0; s < g_seats.length; s++){
|
||||
pSeat = &g_seats[s];
|
||||
pSeatLocal = &g_seatslocal[s];
|
||||
UI_ChangeScreen(UI_SCREEN::NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// big ugly method
|
||||
void
|
||||
UI_determineDrawGlobals(void){
|
||||
|
||||
float fontSizeMulti;
|
||||
|
||||
|
@ -115,7 +259,7 @@ UI_Draw(player arg_player)
|
|||
fontSizeMulti = 0.1429 + 0.001 * 1.0 * video_res[1];
|
||||
|
||||
|
||||
}//END OF screen height check
|
||||
}// screen height check
|
||||
|
||||
//
|
||||
if(FONT_ARIAL == -1 || g_videoResPrev != video_res){
|
||||
|
@ -135,6 +279,21 @@ UI_Draw(player arg_player)
|
|||
FONT_ARIAL = loadfont( "game", "arial", str_font_arial_size, -1 );
|
||||
FONT_ARIAL_TITLE = loadfont( "game", "arial", str_font_arial_title_size, -1 );
|
||||
|
||||
|
||||
// NEW!!!
|
||||
// TODO - use Font_Load to properly fill these fields from some kind of
|
||||
// font script file most likely, see examples in other codebaes.
|
||||
//Font_Load("folder/some_file.ext", &FONT_ARIAL_TITLE_TEST);
|
||||
|
||||
// This works, but not completely. Want some things to have differnet fonts,
|
||||
// like the _title and normal variants of FONT_ARIAL above.
|
||||
/*
|
||||
Font_Load_Easy("arial", (int)font_arial_title_size, FONT_ARIAL_TITLE_EX);
|
||||
g_fntDefault = FONT_ARIAL_TITLE_EX;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//print( sprintf("CHANGE height:%i fontm:%.2f fontref:%i match:(%i, %i) totalmatch:%i\n", (int)video_res[1], fontSizeMulti, (int)FONT_ARIAL, (int)(g_videoResPrev[0]==video_res[0]), (int)(g_videoResPrev[1]==video_res[1]), (int)(g_videoResPrev==video_res)) );
|
||||
}
|
||||
|
||||
|
@ -146,106 +305,126 @@ UI_Draw(player arg_player)
|
|||
}
|
||||
*/
|
||||
|
||||
vVGUIColor = autocvar_vgui_color * ( 1 / 255 );
|
||||
// Oh, there is a Nuclide-provided CVar called 'vgui_color'.
|
||||
// Keep this as it is?
|
||||
g_UI_Color = autocvar_vgui_color * ( 1 / 255 );
|
||||
|
||||
// Align the window to the center
|
||||
vVGUIWindowPos = video_mins;
|
||||
//vVGUIWindowPos[0] += ( video_res[0] / 2 ) - 320;
|
||||
//vVGUIWindowPos[1] += ( video_res[1] / 2 ) - 240;
|
||||
vVGUIWindowPos[0] += window_pad_x;
|
||||
vVGUIWindowPos[1] += window_pad_y;
|
||||
g_UI_WindowPos = video_mins;
|
||||
g_UI_WindowPos[0] += window_pad_x;
|
||||
g_UI_WindowPos[1] += window_pad_y;
|
||||
|
||||
g_UI_WindowSize[0] = window_width_x;
|
||||
g_UI_WindowSize[1] = window_height_y;
|
||||
|
||||
vVGUIWindowSiz[0] = window_width_x;
|
||||
vVGUIWindowSiz[1] = window_height_y;
|
||||
|
||||
// draw the window only if this screen says to.
|
||||
if(vguiMenus[ pSeatLocal->m_flUI_Display - 1 ].fDrawMainWindowAuto){
|
||||
VGUI_Window( vVGUIWindowPos, vVGUIWindowSiz, vguiMenus[ pSeatLocal->m_flUI_Display - 1 ].sTitle, [fontSizeMulti*32,fontSizeMulti*32] );
|
||||
g_fontSizeMulti = fontSizeMulti;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
UI_Draw(void)
|
||||
{
|
||||
if ( pSeatLocal->m_flUI_Display == UI_SCREEN::NONE ) {
|
||||
setcursormode( FALSE );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(g_UI_queueInit){
|
||||
// do it then!
|
||||
UI_InitCheck();
|
||||
}
|
||||
|
||||
if(!ary_UI_Screen[pSeatLocal->m_flUI_Display-1].bInitializedYet){
|
||||
// no drawing uninitialized UI. Is this even possible?
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UI_determineDrawGlobals();
|
||||
//printfline("UI SIZE B! %.1f %.1f", g_UI_WindowSize[0], g_UI_WindowSize[1]);
|
||||
|
||||
#ifndef MOTD_NEW_VGUI
|
||||
// draw the window only if this screen says to.
|
||||
if(ary_UI_Screen[pSeatLocal->m_flUI_Display-1].fDrawMainWindowAuto){
|
||||
VGUI_Window( g_UI_WindowPos, g_UI_WindowSize, [g_fontSizeMulti*32,g_fontSizeMulti*32] );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Display the contents of whatever we have selected
|
||||
vguiMenus[ pSeatLocal->m_flUI_Display - 1 ].vDraw( arg_player, vVGUIWindowPos, vVGUIWindowSiz, fontSizeMulti );
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funDraw();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
UI_Init
|
||||
|
||||
Initialize all there is
|
||||
=================
|
||||
*/
|
||||
// NOTE! Not a built-in method, manually called by client init (ClientGame_Init).
|
||||
// ALSO - this means once for the entire client, so handle all pSeat choices
|
||||
// individually as it does.
|
||||
void
|
||||
UI_Init(void)
|
||||
UI_MouseClick(void)
|
||||
{
|
||||
string sTemp;
|
||||
int iMOTDLength;
|
||||
int i;
|
||||
int s;
|
||||
|
||||
filestream fmMapDescr;
|
||||
|
||||
// only the first screen choice will use its 'sTitle'
|
||||
vguiMenus[0].sTitle = sprintf("%s - %s", "Free Specialists", serverkey("hostname"));
|
||||
|
||||
// First load the MESSAGE OF THE DAY
|
||||
// TODO: Move this to the server and put strings into infokeys
|
||||
|
||||
//sMOTD_total = serverkey("motd_total");
|
||||
|
||||
sMOTD_total = "";
|
||||
|
||||
iMOTDLength = stof( serverkey( "motdlength" ) );
|
||||
for (i = 0; i < iMOTDLength; i++ ) {
|
||||
sMOTDString[ i ] = serverkey( sprintf( "motdline%i", i ) );
|
||||
|
||||
if ( sMOTDString[ i ] == "/" ) {
|
||||
sMOTD_total = strcat(sMOTD_total, "\n" );
|
||||
}else{
|
||||
sMOTD_total = strcat(sMOTD_total, sprintf("%s\n", sMOTDString[ i ]) );
|
||||
}
|
||||
}
|
||||
|
||||
// color it
|
||||
// NOPE! Let this be handled elsewhere in case of a different VGUI color!
|
||||
//sMOTD_total = strcat("^xFA0", sMOTD_total);
|
||||
|
||||
// Now load the MAP DESCRIPTION
|
||||
fmMapDescr = fopen( sprintf( "maps/%s.txt", mapname ), FILE_READ );
|
||||
if ( fmMapDescr != -1 ) {
|
||||
for (i = 0; i < 35; i++ ) {
|
||||
sTemp = fgets( fmMapDescr );
|
||||
if not ( sTemp ) {
|
||||
break;
|
||||
}
|
||||
sMapString[ i ] = sTemp;
|
||||
}
|
||||
fclose( fmMapDescr );
|
||||
}
|
||||
|
||||
gFun_UI_EventGrabber_Initialize();
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// FOR NOW, a lazy way of init for all seats.
|
||||
// Apply to all seats, not worrying about what numclientseats is because this is tiny.
|
||||
if (serverkeyfloat("slots") != 1) {
|
||||
// We start on the MOTD, always
|
||||
for (s = 0; s < g_seats.length; s++){
|
||||
pSeat = &g_seats[s];
|
||||
pSeatLocal = &g_seatslocal[s];
|
||||
UI_ChangeScreen(UI_SCREEN::MOTD);
|
||||
}
|
||||
}else{
|
||||
// make all pSeats start at the NONE screen instead
|
||||
for (s = 0; s < g_seats.length; s++){
|
||||
pSeat = &g_seats[s];
|
||||
pSeatLocal = &g_seatslocal[s];
|
||||
UI_ChangeScreen(UI_SCREEN::NONE);
|
||||
if(pSeatLocal->m_flUI_Display != UI_SCREEN::NONE){
|
||||
if(
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].bInitializedYet &&
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funOnMouseClick != NULL
|
||||
){
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funOnMouseClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UI_KeyDown(void)
|
||||
{
|
||||
if(pSeatLocal->m_flUI_Display != UI_SCREEN::NONE){
|
||||
if(
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].bInitializedYet &&
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funOnKeyDown != NULL)
|
||||
{
|
||||
ary_UI_Screen[pSeatLocal->m_flUI_Display-1].funOnKeyDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
UI_CheckMouse
|
||||
|
||||
Returns whether or not our mouse cursor hovers over a region
|
||||
====================
|
||||
*/
|
||||
BOOL
|
||||
UI_CheckMouse(vector vPos, vector vReg)
|
||||
{
|
||||
vector vSMins, vSMaxs;
|
||||
|
||||
vSMins = vPos;
|
||||
vSMaxs = vPos;
|
||||
vSMins[0] = vPos[0];
|
||||
vSMaxs[1] = vPos[1] - 1;
|
||||
|
||||
vSMaxs[0] = vPos[0] + vReg[0];
|
||||
vSMaxs[1] = vPos[1] + vReg[1];
|
||||
|
||||
if ( mouse_pos[0] >= vSMins[0] && mouse_pos[0] <= vSMaxs[0] ) {
|
||||
if (mouse_pos[1] >= vSMins[1] && mouse_pos[1] <= vSMaxs[1] ) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convenience method for now. Based off of Nuclide's src/vgui Font_Load method,
|
||||
// uses its font_s type
|
||||
void
|
||||
Font_Load_Easy(string strFontPath, int iFontScale, font_s &fntNew)
|
||||
{
|
||||
fntNew.iScale = iFontScale;
|
||||
fntNew.vecColor = [1,1,1];
|
||||
fntNew.flAlpha = 1.0f;
|
||||
fntNew.iFlags = 0;
|
||||
fntNew.iID = (int)loadfont("", strFontPath, ftos((float)fntNew.iScale), -1, 0, 0);
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
|
||||
extern var BOOL UI_BuyMenu_InitDone;
|
||||
void UI_BuyMenu_onInputEvent(void);
|
|
@ -37,9 +37,6 @@
|
|||
class CBuyMenu_BasicButton;
|
||||
|
||||
|
||||
// set to TRUE if this screen has ever been brought up before.
|
||||
var BOOL UI_BuyMenu_InitDone = FALSE;
|
||||
|
||||
var int iWeaponTempID = -1;
|
||||
|
||||
//What upgrades has the player purchased for the currently open weapon in the buy menu?
|
||||
|
@ -75,15 +72,15 @@ float determineHotkeyFromChar(string arg_sHotkeyDisplay);
|
|||
|
||||
|
||||
|
||||
//Each button ever created must be added to this list. Can be one automatically...
|
||||
//struct's don't have constructors though. Call for this at startup I suppose.
|
||||
// Each button ever created must be added to this list. Can be one automatically.
|
||||
// struct's don't have constructors though. Call for this at startup I suppose.
|
||||
var CBuyMenu_BasicButton* ary_btnTotal[128];
|
||||
var int ary_btnTotal_softLength = 0;
|
||||
|
||||
var CBuyMenu_BasicButton* ary_layerButtonChoice[16]; //16 layers max. Not that nearly this many should be used.
|
||||
//var int ary_layerButtonChoiceIndex[16i]; //alternative approach.
|
||||
|
||||
//Any buttons in the first layer must be recorded here.
|
||||
// Any buttons in the first layer must be recorded here.
|
||||
var CBuyMenu_BasicButton* ary_layerFirstButton[16];
|
||||
var int ary_layerFirstButton_softLength = 0;
|
||||
|
||||
|
@ -174,6 +171,8 @@ var CBuyMenu_WeaponButton buymenu_btn_Buy_SEALKNIFE;
|
|||
// Notice that the buttons do not have location/size information. They are
|
||||
// drawn wherever as needed, checks for clicks need that supplied to know where
|
||||
// to check.
|
||||
// NOTE: any method names involving "click" also happen when the button's hotkey
|
||||
// is pressed.
|
||||
class CBuyMenu_BasicButton{
|
||||
|
||||
// yes. really.
|
||||
|
@ -274,11 +273,32 @@ CBuyMenu_RemoveWeaponButton::CBuyMenu_RemoveWeaponButton(void)
|
|||
|
||||
}
|
||||
|
||||
|
||||
// Being called implies the mouse was clicked. Calls OnClick_Base if the mouse is
|
||||
// within the button bounds.
|
||||
BOOL
|
||||
checkBuyMenuButtonClicked(
|
||||
CBuyMenu_BasicButton* arg_someBtn, vector vPosition,
|
||||
vector vSize
|
||||
CBuyMenu_BasicButton* arg_someBtn, vector vPosition, vector vSize
|
||||
)
|
||||
{
|
||||
CBuyMenu_BasicButton deref = *arg_someBtn;
|
||||
|
||||
if(UI_CheckMouse( vPosition, vSize )){
|
||||
// What button is being hovered over?
|
||||
iHoveredButtonIndex = deref.iGlobalIndex;
|
||||
|
||||
(*arg_someBtn).vOnClick_Base();
|
||||
|
||||
pSeatLocal->m_inputMouseClicked = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}// checkBuyMenuButtonClicked
|
||||
|
||||
// Is the recent input key a match for this button's hotkey?
|
||||
BOOL
|
||||
checkBuyMenuButtonHotKeyPressed(
|
||||
CBuyMenu_BasicButton* arg_someBtn
|
||||
)
|
||||
{
|
||||
CBuyMenu_BasicButton deref = *arg_someBtn;
|
||||
|
@ -290,52 +310,26 @@ checkBuyMenuButtonClicked(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if ( pSeatLocal->m_inputMouseClicked == TRUE ) {
|
||||
if(VGUI_CheckMouse( vPosition, vSize )){
|
||||
// What button is being hovered over?
|
||||
iHoveredButtonIndex = deref.iGlobalIndex;
|
||||
|
||||
(*arg_someBtn).vOnClick_Base();
|
||||
|
||||
pSeatLocal->m_inputMouseClicked = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}// checkBuyMenuButtonClicked
|
||||
}// checkBuyMenuButtonHotKeyPressed
|
||||
|
||||
|
||||
|
||||
// Called by ui_eventgrabber on detecting input from a keypress or mouse.
|
||||
// TODO - still a little sloppy to check for both the recently pressed key
|
||||
// matching the hotkey and a mouse-click for coords when each event can only be
|
||||
// either of these things, not both.
|
||||
// But that would mean cloning this method with the only difference being
|
||||
// checkBuyMenuButtonClicked for "checkBuyMenuButtonHotKey" insetad,
|
||||
// and Clicked loses the hotkey check.
|
||||
void UI_BuyMenu_onInputEvent(void){
|
||||
if(!UI_BuyMenu_InitDone){
|
||||
// Not allowed yet!
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
UI_BuyMenu_OnMouseClick(void)
|
||||
{
|
||||
int i2;
|
||||
// Generate the button bounds to be checked on each click call.
|
||||
vector vButtonPos = [video_mins[0] + 5, video_mins[1] + video_res[1]/2, 0];
|
||||
vector vBtnPos = [0,0,0];
|
||||
int currentLayerSelectedIndex;
|
||||
int btnToRender_index_global;
|
||||
CBuyMenu_BasicButton someThing;
|
||||
CBuyMenu_BasicButton previousLayerButton;
|
||||
BOOL fIsSelected;
|
||||
|
||||
if(iActiveLayer == 0){
|
||||
vBtnPos.x = (int)vButtonPos.x; //default pos.
|
||||
vBtnPos.y = (int)vButtonPos.y;
|
||||
|
||||
|
||||
for(int i2 = 0i; i2 < ary_layerFirstButton_softLength; i2++){
|
||||
CBuyMenu_BasicButton tempButton = *ary_layerFirstButton[i2];
|
||||
|
||||
for(i2 = 0i; i2 < ary_layerFirstButton_softLength; i2++){
|
||||
checkBuyMenuButtonClicked(ary_layerFirstButton[i2], vBtnPos, vButtonSizStandard);
|
||||
vBtnPos.y += (vButtonSizStandard.y + 1);
|
||||
}
|
||||
|
@ -347,17 +341,22 @@ void UI_BuyMenu_onInputEvent(void){
|
|||
|
||||
previousLayerButton = *ary_layerButtonChoice[iActiveLayer - 1i];
|
||||
|
||||
for(i2 = 0i; i2 < previousLayerButton.ary_btn_softLength; i2 = i2+1i){
|
||||
|
||||
for(int i2 = 0i; i2 < previousLayerButton.ary_btn_softLength; i2 = i2+1i){
|
||||
|
||||
// CONCLUSION... maybe.
|
||||
// So much as this local var, "btnCheck", being set to a dereferenced ary_btnTotal element,
|
||||
// and this btnCheck being used in checkBuyMenubuttonClicked instead of just that ary_btnTotal element (a pointer already)
|
||||
// is enough to trigger this odd error, where the next frame (or if this for loop gets so much as an extra iteration
|
||||
// that resets btnCheck... test with the "if(theThingHappened)continue;" bit above moved to after these lines below too...
|
||||
// Anyways, this makes the difference between whether the real thing the ary_btnTotal element links to stays
|
||||
// consistent between at least loop iterations or not even those. Staying consistent between frames is definitely out.
|
||||
// When this method ends, or really this scope (?), that thing the ary_btnTotal element is pointing at blanks out.
|
||||
// CONCLUSION
|
||||
// So much as this local var, "btnCheck", being set to a dereferenced
|
||||
// ary_btnTotal element, and this btnCheck being used in
|
||||
// checkBuyMenubuttonClicked instead of just that ary_btnTotal element
|
||||
// (a pointer already) is enough to trigger this odd error, where the next
|
||||
// frame (or if this for loop gets so much as an extra iteration that resets
|
||||
// btnCheck... test with the "if(theThingHappened)continue;" bit above moved
|
||||
// to after these lines below too...
|
||||
// Anyways, this makes the difference between whether the real thing the
|
||||
// ary_btnTotal element links to stays consistent between at least loop
|
||||
// iterations or not even those. Staying consistent between frames is
|
||||
// definitely out.
|
||||
// When this method ends, or really this scope (?), that thing the
|
||||
// ary_btnTotal element is pointing at blanks out.
|
||||
|
||||
btnToRender_index_global = previousLayerButton.ary_btn_index[i2];
|
||||
|
||||
|
@ -379,8 +378,44 @@ void UI_BuyMenu_onInputEvent(void){
|
|||
|
||||
// Check the "0. Cancel" button.
|
||||
checkBuyMenuButtonClicked(&buymenu_btn_Back, vBtnPos, vButtonSizStandard);
|
||||
vBtnPos.y += (vButtonSizStandard.y + 1);
|
||||
}// UI_BuyMenu_onInputEvent
|
||||
// no point on bumping Y, end of method
|
||||
//vBtnPos.y += (vButtonSizStandard.y + 1);
|
||||
}// UI_BuyMenu_OnMouseClick
|
||||
|
||||
|
||||
// Check for the hotkey of any buttons in existence instead.
|
||||
// No need to involve button bounds for that
|
||||
void
|
||||
UI_BuyMenu_OnKeyDown(void)
|
||||
{
|
||||
int i2;
|
||||
int btnToRender_index_global;
|
||||
CBuyMenu_BasicButton previousLayerButton;
|
||||
|
||||
if(iActiveLayer == 0){
|
||||
for(i2 = 0i; i2 < ary_layerFirstButton_softLength; i2++){
|
||||
checkBuyMenuButtonHotKeyPressed(ary_layerFirstButton[i2]);
|
||||
}
|
||||
}else{
|
||||
// All other layers only render buttons that the previous layer (selected button there) tells them to.
|
||||
previousLayerButton = *ary_layerButtonChoice[iActiveLayer - 1i];
|
||||
|
||||
for(i2 = 0i; i2 < previousLayerButton.ary_btn_softLength; i2 = i2+1i){
|
||||
btnToRender_index_global = previousLayerButton.ary_btn_index[i2];
|
||||
|
||||
CBuyMenu_BasicButton tempButton2 = *ary_btnTotal[btnToRender_index_global];
|
||||
if(tempButton2.bActive == FALSE){
|
||||
// let the next button be tried instead.
|
||||
continue;
|
||||
}
|
||||
|
||||
checkBuyMenuButtonHotKeyPressed(ary_btnTotal[btnToRender_index_global]);
|
||||
}// for i2 in this layer's buttons.
|
||||
}
|
||||
|
||||
// Check the "0. Cancel" button.
|
||||
checkBuyMenuButtonHotKeyPressed(&buymenu_btn_Back);
|
||||
}//UI_BuyMenu_OnKeyDown
|
||||
|
||||
|
||||
|
||||
|
@ -486,16 +521,6 @@ drawBuyButton(
|
|||
mouseHovered = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
// NO BORDERS FOR THE WICKED.
|
||||
// last two parameters were these constants before: vVGUIColor, VGUI_WINDOW_FGALPHA
|
||||
//Now the draw stuff.
|
||||
drawfill( vPosition, [vSize[0], 1], '255 0 0', 1.0 );
|
||||
drawfill( [vPosition[0], vPosition[1] + vSize[1] - 1], [vSize[0], 1], '255 0 0', 1.0 );
|
||||
drawfill( vPosition, [1, vSize[1]], '255 0 0', 1.0 );
|
||||
drawfill( [vPosition[0] + vSize[0] - 1, vPosition[1]], [1, vSize[1]], '255 0 0', 1.0 );
|
||||
*/
|
||||
|
||||
//iActiveLayer == iLayer &&
|
||||
if(mouseHovered){
|
||||
// Draw the background
|
||||
|
@ -1265,35 +1290,37 @@ buymenu_btn_FullLoad_clicked(CBuyMenu_BasicButton* arg_this)
|
|||
|
||||
|
||||
void
|
||||
UI_BuyMenu_OnInit(void)
|
||||
UI_BuyMenu_Show(void)
|
||||
{
|
||||
// for macros below.
|
||||
float flDeterminedHotkey;
|
||||
|
||||
//safety.
|
||||
// safety.
|
||||
UI_BuyMenu_ResetTempVariables();
|
||||
|
||||
//haven't yet.
|
||||
// haven't yet.
|
||||
boughtAnything = FALSE;
|
||||
|
||||
if(UI_BuyMenu_InitDone == FALSE){
|
||||
//looks like we need to do this. proceed.
|
||||
}else{
|
||||
//nevermind.
|
||||
//Keep in mind some stuff (what's above) can run on any init call, even subsequent ones (re-opening the buy menu), since we might want to default some stuff
|
||||
//like what was selected, temp buyopts clicked, etc.
|
||||
return;
|
||||
}
|
||||
|
||||
iActiveLayer = 0i;
|
||||
ary_btnTotal_softLength = 0i;
|
||||
ary_layerFirstButton_softLength = 0i;
|
||||
buymenu_btn_Back_updateText();
|
||||
|
||||
// just in case?
|
||||
for(int i = 0i; i < ary_layerButtonChoice.length; i+=1i){
|
||||
ary_layerButtonChoice[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UI_BuyMenu_Hide(void)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
void
|
||||
UI_BuyMenu_Init(void)
|
||||
{
|
||||
// for macros below.
|
||||
float flDeterminedHotkey;
|
||||
|
||||
ary_btnTotal_softLength = 0i;
|
||||
ary_layerFirstButton_softLength = 0i;
|
||||
|
||||
// buymenu_btn_Back = spawn(CBuyMenu_BasicButton);
|
||||
// if the 1st layer is active (drawn to that one). Says "Cancel" there, but if on any deeper layer it reads "Go Back".
|
||||
|
@ -1301,7 +1328,6 @@ UI_BuyMenu_OnInit(void)
|
|||
|
||||
INITIALIZE_BASICBUTTON(Back, "Cancel", "0", clrPaleBluePurple, &buymenu_btn_Back_clicked)
|
||||
|
||||
|
||||
//INITIALIZE_BASICBUTTON(Buy, "2 Buy", 48+2, NULL, 0, NULL)
|
||||
INITIALIZE_BASICBUTTON(Recentconfig, "Use New Config", "1", clrGreen, &buymenu_btn_UseNewConfig_clicked)
|
||||
INITIALIZE_BASICBUTTON(Buy, "Buy", "2", clrPaleBlue, NULL)
|
||||
|
@ -1424,17 +1450,14 @@ UI_BuyMenu_OnInit(void)
|
|||
|
||||
setupRemoveButtonList();
|
||||
|
||||
// don't do this init process again.
|
||||
UI_BuyMenu_InitDone = TRUE;
|
||||
|
||||
}// UI_BuyMenu_OnInit
|
||||
}// UI_BuyMenu_Init
|
||||
|
||||
|
||||
|
||||
//var float lastPrintoutTime = 0.0f;
|
||||
|
||||
void
|
||||
UI_BuyMenu_Update(player arg_player, vector vPos, vector vWindowSiz, float fFontSizeMulti)
|
||||
UI_BuyMenu_Draw(void)
|
||||
{
|
||||
// If we leave spectator view (spawned and walking/aiming), disallow the buy menu.
|
||||
// (could also check for "player.iState == PLAYER_STATE::SPAWNED" )
|
||||
|
@ -1453,8 +1476,6 @@ UI_BuyMenu_Update(player arg_player, vector vPos, vector vWindowSiz, float fFont
|
|||
CBuyMenu_BasicButton previousLayerButton;
|
||||
BOOL fIsSelected;
|
||||
|
||||
// VGUI_Text( sprintf("%s - %s", "Free Specialists", serverkey("hostname") ), vPos + '16 64 0', '12 12', FONT_CON );
|
||||
|
||||
|
||||
// Checks for clicks be done separately
|
||||
// Only check for buttons from the active layer.
|
||||
|
@ -1470,8 +1491,6 @@ UI_BuyMenu_Update(player arg_player, vector vPos, vector vWindowSiz, float fFont
|
|||
}
|
||||
*/
|
||||
|
||||
//UI_BuyMenu_onInputEvent();
|
||||
|
||||
drawPlayerInventory(TRUE);
|
||||
|
||||
for(int i = 0i; i <= iActiveLayer; i = i + 1i){
|
||||
|
@ -1565,7 +1584,7 @@ UI_BuyMenu_Update(player arg_player, vector vPos, vector vWindowSiz, float fFont
|
|||
|
||||
drawPlayerInventory_TopBar(-1, TRUE);
|
||||
|
||||
}//UI_BuyMenu_Update
|
||||
}//UI_BuyMenu_Draw
|
||||
|
||||
|
||||
// Given a single-character string, like "3" or "A", determine the keycode that
|
||||
|
|
|
@ -22,6 +22,13 @@ class CUIEventGrabber:CUIWidget
|
|||
};
|
||||
|
||||
|
||||
// Could include this a lot earlier, but no point as it's useless without being
|
||||
// able to call methods of it until CUIEventGrabber is defined (which requires
|
||||
// UIWidget, which requires all nuclide stuff to be included, which happens late
|
||||
// into the compile)
|
||||
var CUIEventGrabber g_UI_EventGrabber;
|
||||
|
||||
|
||||
void
|
||||
CUIEventGrabber::Draw(void)
|
||||
{
|
||||
|
@ -40,17 +47,17 @@ CUIEventGrabber::Input(float flEVType, float flKey, float flChar, float flDevID)
|
|||
|
||||
case IE_KEYDOWN:
|
||||
printf("CUIEventGrabber::Input %d time:%.2f\n", flKey, time);
|
||||
if (flKey == K_MOUSE1) {
|
||||
pSeatLocal->m_inputMouseClicked = TRUE;
|
||||
}
|
||||
|
||||
pSeatLocal->m_inputKeyDown = flKey;
|
||||
pSeatLocal->m_inputKeyTapped = flKey; //lasts only this frame
|
||||
|
||||
// TODO TODO TODO! Check for mouse-clicks (K_MOUSE1) and key presses by separate methods?
|
||||
// Checking for keypresses on a mouse-click or for mouse-coords on a keypress on every
|
||||
// single button (even a mouse, yes/no check every time) is unnecessary.
|
||||
if(pSeatLocal->m_flUI_Display == UI_SCREEN::BUYMENU){
|
||||
UI_BuyMenu_onInputEvent();
|
||||
if (flKey == K_MOUSE1) {
|
||||
// mouse click event!
|
||||
pSeatLocal->m_inputMouseClicked = TRUE;
|
||||
UI_MouseClick();
|
||||
}else{
|
||||
// key press event!
|
||||
UI_KeyDown();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -63,14 +70,8 @@ CUIEventGrabber::Input(float flEVType, float flKey, float flChar, float flDevID)
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Could include this a lot earlier, but no point as it's useless without being
|
||||
// able to call methods of it until CUIEventGrabber is defined (which requires
|
||||
// UIWidget, which requires all nuclide stuff to be included, which happens late
|
||||
// into the compile)
|
||||
var CUIEventGrabber g_UI_EventGrabber;
|
||||
|
||||
|
||||
void gFun_UI_EventGrabber_Initialize(void){
|
||||
|
|
190
src/client/ui_motd.qc
Normal file
190
src/client/ui_motd.qc
Normal file
|
@ -0,0 +1,190 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
|
||||
*
|
||||
* See the file LICENSE attached with the sources for usage details.
|
||||
*
|
||||
****/
|
||||
|
||||
// TODO - NEW_VGUI support should be better, need different fonts between
|
||||
// the title and label text (really just different sizes of the same font)
|
||||
// and support for color choices from CVar, see g_UI_Color and how it is
|
||||
// formed
|
||||
|
||||
|
||||
#ifdef MOTD_NEW_VGUI
|
||||
CUIButton UI_MOTD_btnOK;
|
||||
CUIWindow UI_MOTD_win;
|
||||
CUILabel UI_MOTD_label;
|
||||
#endif
|
||||
|
||||
var BOOL g_UI_MOTD_everClosed = FALSE;
|
||||
var string g_MOTD_windowTitle;
|
||||
|
||||
|
||||
|
||||
void UI_MOTD_btnOK_Clicked( void ){
|
||||
if(!g_UI_MOTD_everClosed){
|
||||
UI_ChangeScreen(UI_SCREEN::BUYMENU);
|
||||
}else{
|
||||
UI_ChangeScreen(UI_SCREEN::NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UI_MOTD_Init(void)
|
||||
{
|
||||
#ifdef MOTD_NEW_VGUI
|
||||
//printfline("UI SIZE A! %.1f %.1f", g_UI_WindowSize[0], g_UI_WindowSize[1]);
|
||||
|
||||
UI_MOTD_win = spawn(CUIWindow);
|
||||
// something absurd for now.
|
||||
UI_MOTD_win.SetMaxSize([3000, 2000]);
|
||||
|
||||
UI_MOTD_btnOK = spawn(CUIButton);
|
||||
UI_MOTD_btnOK.SetTitle(_("VGUI_OK"));
|
||||
UI_MOTD_btnOK.SetSize([100, 30]);
|
||||
UI_MOTD_btnOK.SetFunc(UI_MOTD_btnOK_Clicked);
|
||||
|
||||
UI_MOTD_label = spawn(CUILabel);
|
||||
//UI_MOTD_label.SetMaxSize([3000, 2000]);
|
||||
|
||||
g_uiDesktop.Add(UI_MOTD_win);
|
||||
UI_MOTD_win.Add(UI_MOTD_btnOK);
|
||||
UI_MOTD_win.Add(UI_MOTD_label);
|
||||
|
||||
|
||||
UI_MOTD_win.Hide();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
UI_MOTD_Show(void)
|
||||
{
|
||||
|
||||
g_MOTD_windowTitle = sprintf("%s - %s", "Free Specialists", serverkey("hostname"));
|
||||
|
||||
#ifdef MOTD_NEW_VGUI
|
||||
// For g_UI_WindowSize to be formed at least.
|
||||
// Use "vSizeEffective" instead to work with whatever size ends up
|
||||
// happening, it might be different in some cases if the min/max
|
||||
// sizes are not followed.
|
||||
// No need for the WindowPos one, all coords of in-window elements are
|
||||
// relative to the window, and centering whatever window size again
|
||||
// is easy.
|
||||
UI_determineDrawGlobals();
|
||||
|
||||
//???.Hide();
|
||||
UI_MOTD_win.SetTitle(g_MOTD_windowTitle);
|
||||
//UI_MOTD_win.SetPos(g_UI_WindowPos);
|
||||
UI_MOTD_win.SetSize(g_UI_WindowSize);
|
||||
vector vSizeEffective = UI_MOTD_win.GetSize();
|
||||
UI_MOTD_win.SetPos((video_res / 2) - (vSizeEffective / 2));
|
||||
|
||||
|
||||
UI_MOTD_btnOK.SetPos([0 + 16, 0 + vSizeEffective.y - 30 - 16]);
|
||||
|
||||
|
||||
|
||||
//UI_MOTD_label.SetTitle("abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc");
|
||||
string tempText = sprintf("%s%s", Colors_RGB8_to_HEX(g_UI_Color), sMOTD_total);
|
||||
UI_MOTD_label.SetTitle(tempText);
|
||||
|
||||
vector labelSiz = [300, 300];
|
||||
UI_MOTD_label.SetSize(labelSiz);
|
||||
//UI_MOTD_label.SetPos((vSizeEffective / 2) - (labelSiz / 2));
|
||||
vector vTextPos = [16, 64];
|
||||
UI_MOTD_label.SetPos(vTextPos);
|
||||
UI_MOTD_label.SetSize(vSizeEffective - (vTextPos * 2));
|
||||
|
||||
UI_MOTD_win.Show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
UI_MOTD_Hide(void)
|
||||
{
|
||||
// be aware that this is not the first time being closed
|
||||
g_UI_MOTD_everClosed = TRUE;
|
||||
#ifdef MOTD_NEW_VGUI
|
||||
// hides the window
|
||||
UI_MOTD_win.FlagRemove(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
UI_MOTD_Draw(void)
|
||||
{
|
||||
|
||||
#ifdef MOTD_NEW_VGUI
|
||||
if(!(UI_MOTD_win.m_iFlags & 1) && !g_UI_MOTD_everClosed){
|
||||
// this means the window was hidden by closing with the X button.
|
||||
// The OK button sets that flag so that this can't be reached that way.
|
||||
// The point is, closing the MoTD the first time by any means should lead
|
||||
// to the buy menu
|
||||
UI_MOTD_btnOK_Clicked();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
// Draw the window title
|
||||
// Also use DRAWFLAG_NORMAL to stop the transparency from not being a solid color choice.
|
||||
// ADDITIVE interprets any darker color than as bright as possible as transparency.
|
||||
// The wordwrapped text does not support this, so let them both be solid.
|
||||
// No benefit to transparent text anyway.
|
||||
// title text font size depends on the height of the window.
|
||||
|
||||
Gfx_Text( g_UI_WindowPos + [16, 16], g_MOTD_windowTitle, g_fontSizeMulti*32, g_UI_Color, VGUI_WINDOW_FGALPHA, DRAWFLAG_NORMAL, FONT_ARIAL_TITLE );
|
||||
|
||||
//Gfx_TextLineWrap( vPosition + '16 16', vSize - ('16 64 0' * 2) , DRAWTEXTFIELD_ALIGN_LEFT_TOP, sTitle, FONT_ARIAL_STD );
|
||||
|
||||
vector vTextPos = g_UI_WindowPos + [16, 64];
|
||||
|
||||
// apply the VGUI color, since TextLineWrap (route to FTE method drawtextfield)
|
||||
// does not offer color, but in-text markup can offer this.
|
||||
// PENDING: if this is done a lot, offer it as a utility method?
|
||||
// That can take a color vector and apply this hex step for us.
|
||||
// Just beware that this applies to all text after the affected text as well,
|
||||
// markup only stops when overridden by other markup as read from left to right.
|
||||
// example:
|
||||
// ^x0F0 term1 term2
|
||||
// ...colors term1 and term2 green, even if this was not intentional for term2.
|
||||
// ^x0F0 term1 ^xF00 term2
|
||||
// ...colors term1 green, but term2 red.
|
||||
string tempText = sprintf("%s%s", Colors_RGB8_to_HEX(g_UI_Color), sMOTD_total);
|
||||
|
||||
// Oh, and no transparency it seems, so no slight show-through that the title text gets.
|
||||
// So you have to invent your own wordwrap to get that?? Let's just skip that.
|
||||
Gfx_TextLineWrap( vTextPos, g_UI_WindowSize - ([16, 64] * 2) , DRAWTEXTFIELD_ALIGN_LEFT_TOP, tempText, FONT_ARIAL );
|
||||
|
||||
VGUI_Button( _("VGUI_OK"), [g_UI_WindowPos.x + 16, g_UI_WindowPos.y + g_UI_WindowSize.y - 30 - 16, 0], '100 30 0' );
|
||||
|
||||
#endif// else of ifdef MOTD_NEW_VGUI
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UI_MOTD_OnMouseClick(void)
|
||||
{
|
||||
#ifndef MOTD_NEW_VGUI
|
||||
vector vPosition = [g_UI_WindowPos.x + 16, g_UI_WindowPos.y + g_UI_WindowSize.y - 30 - 16, 0]
|
||||
|
||||
if ( UI_CheckMouse( vPosition, g_UI_WindowSize ) ) {
|
||||
UI_MOTD_btnOK_Clicked();
|
||||
pSeatLocal->m_inputMouseClicked = FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void
|
||||
UI_MOTD_OnKeyDown(void)
|
||||
{
|
||||
// pressing enter here works too.
|
||||
if(pSeatLocal->m_inputKeyTapped == 13){
|
||||
UI_MOTD_btnOK_Clicked();
|
||||
pSeatLocal->m_inputKeyTapped = 0; //why do we have to do this, no clue
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,5 +94,5 @@ void Gfx_Text(vector vPos, string sText, vector vSize, vector vRGB, float flAlph
|
|||
void Gfx_TextLineWrap( vector vPos, vector vSize, float fAlignFlags, string sText, float flFont );
|
||||
void Gfx_RotScalePic( string sImage, vector arg_vDrawPos, vector arg_vDrawPivot, vector vSize, float flAngle, vector vScale, vector vRGB, float flOpac );
|
||||
void Gfx_ScalePicPreserveBounds(string sImage, vector arg_vDrawPos, vector vSize, vector vScale, vector vInset, vector vRGB, float flOpac);
|
||||
|
||||
string Colors_RGB8_to_HEX(vector color);
|
||||
|
||||
|
|
|
@ -108,10 +108,11 @@ drawSpriteNumber(
|
|||
|
||||
|
||||
|
||||
// Convenience methods for drawing without any font-related struct, just some font's load ID.
|
||||
// Otherwise close to the engine-provided drawstring and drawtextfield methods.
|
||||
// "drawfont" is a global provided by the engine (fteextensions.qc)
|
||||
// Compare with vgui/font.cpp's "Font_DrawText" and "Font_DrawField" which take a font struct.
|
||||
// Convenience methods for drawing without any font-related struct, just some font's
|
||||
// load ID. Otherwise close to the engine-provided drawstring and drawtextfield
|
||||
// methods. "drawfont" is a global provided by the engine (fteextensions.qc).
|
||||
// Compare with src/vgui/font.cpp's "Font_DrawText" and "Font_DrawField" which take a
|
||||
// font struct.
|
||||
void
|
||||
Gfx_Text(vector vPos, string sText, vector vSize, vector vRGB, float flAlpha, float flDrawFlag, float flFont)
|
||||
{
|
||||
|
@ -174,3 +175,42 @@ Gfx_ScalePicPreserveBounds(string sImage, vector arg_vDrawPos, vector vSize, vec
|
|||
drawsubpic(arg_vDrawPos + vecOff, sz, sImage, srcpos, srcsz, vRGB, flOpac); //, 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Cloned from src/menu-fn/w_label.qc
|
||||
string
|
||||
Colors_RGB8_to_HEX(vector color)
|
||||
{
|
||||
string out = "^x";
|
||||
//string out = "";
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
string a = "";
|
||||
float b = rint(color[i] * 15);
|
||||
|
||||
switch (b) {
|
||||
case 10:
|
||||
a = "A";
|
||||
break;
|
||||
case 11:
|
||||
a = "B";
|
||||
break;
|
||||
case 12:
|
||||
a = "C";
|
||||
break;
|
||||
case 13:
|
||||
a = "D";
|
||||
break;
|
||||
case 14:
|
||||
a = "E";
|
||||
break;
|
||||
case 15:
|
||||
a = "F";
|
||||
break;
|
||||
default:
|
||||
a = ftos(b);
|
||||
}
|
||||
out = sprintf("%s%s", out, a);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
|
||||
*
|
||||
* See the file LICENSE attached with the sources for usage details.
|
||||
*
|
||||
****/
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
VGUI_MessageOfTheDay
|
||||
|
||||
The MOTD screen.
|
||||
|
||||
TODO: Networking still needs to be done.
|
||||
You can't store motds in infokey strings because
|
||||
newline chars are not supported. You could hack it to use
|
||||
an array of infokeys, but that'll clutter things up
|
||||
====================
|
||||
*/
|
||||
|
||||
// Cloned from src/menu-fn/w_label.qc, HACKY
|
||||
string
|
||||
Colors_RGB8_to_HEX(vector color)
|
||||
{
|
||||
string out = "^x";
|
||||
//string out = "";
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
string a = "";
|
||||
float b = rint(color[i] * 15);
|
||||
|
||||
switch (b) {
|
||||
case 10:
|
||||
a = "A";
|
||||
break;
|
||||
case 11:
|
||||
a = "B";
|
||||
break;
|
||||
case 12:
|
||||
a = "C";
|
||||
break;
|
||||
case 13:
|
||||
a = "D";
|
||||
break;
|
||||
case 14:
|
||||
a = "E";
|
||||
break;
|
||||
case 15:
|
||||
a = "F";
|
||||
break;
|
||||
default:
|
||||
a = ftos(b);
|
||||
}
|
||||
out = sprintf("%s%s", out, a);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VGUI_MessageOfTheDay(player arg_player, vector vPos, vector vWindowSiz, float fFontSizeMulti ) {
|
||||
|
||||
static void MessageOfTheDay_ButtonOK( void ) {
|
||||
printfline("HEY ButtonOK got CLICKED");
|
||||
UI_ChangeScreen(UI_SCREEN::BUYMENU);
|
||||
}
|
||||
|
||||
//TAGGG - start from this location instead.
|
||||
//vector vTextPos = vPos + '16 116 0';
|
||||
vector vTextPos = vPos + '16 64 0';
|
||||
|
||||
// apply the VGUI color, since TextLineWrap (route to FTE method drawtextfield)
|
||||
// does not offer color, but in-text markup can offer this.
|
||||
// PENDING: if this is done a lot, offer it as a utility method?
|
||||
// That can take a color vector and apply this hex step for us.
|
||||
// Just beware that this applies to all text after the affected text as well,
|
||||
// markup only stops when overridden by other markup as read from left to right.
|
||||
// example:
|
||||
// ^x0F0 term1 term2
|
||||
// ...colors term1 and term2 green, even if this was not intentional for term2.
|
||||
// ^x0F0 term1 ^xF00 term2
|
||||
// ...colors term1 green, but term2 red.
|
||||
string tempText = sprintf("%s%s", Colors_RGB8_to_HEX(vVGUIColor), sMOTD_total);
|
||||
|
||||
// Oh, and no transparency it seems, so no slight show-through that the title text gets.
|
||||
// So you have to invent your own wordwrap to get that?? Let's just skip that.
|
||||
Gfx_TextLineWrap( vTextPos, vWindowSiz - ('16 64 0' * 2) , DRAWTEXTFIELD_ALIGN_LEFT_TOP, tempText, FONT_ARIAL );
|
||||
|
||||
if(pSeatLocal->m_inputKeyTapped == 13){
|
||||
//pressing enter here works too.
|
||||
MessageOfTheDay_ButtonOK();
|
||||
pSeatLocal->m_inputKeyTapped = 0; //why do we have to do this, no clue
|
||||
}
|
||||
|
||||
VGUI_Button( _("VGUI_OK"), MessageOfTheDay_ButtonOK, [vPos.x + 16, vPos.y + vWindowSiz.y - 30 - 16, 0], '100 30 0' );
|
||||
}
|
||||
|
||||
|
|
@ -6,34 +6,10 @@
|
|||
*
|
||||
****/
|
||||
|
||||
/*
|
||||
====================
|
||||
VGUI_CheckMouse
|
||||
|
||||
Returns whether or not our mouse cursor hovers over a region
|
||||
====================
|
||||
*/
|
||||
float VGUI_CheckMouse( vector vPos, vector vReg ) {
|
||||
vector vSMins, vSMaxs;
|
||||
|
||||
vSMins = vPos;
|
||||
vSMaxs = vPos;
|
||||
vSMins[0] = vPos[0];
|
||||
vSMaxs[1] = vPos[1] - 1;
|
||||
|
||||
vSMaxs[0] = vPos[0] + vReg[0];
|
||||
vSMaxs[1] = vPos[1] + vReg[1];
|
||||
|
||||
if ( mouse_pos[0] >= vSMins[0] && mouse_pos[0] <= vSMaxs[0] ) {
|
||||
if (mouse_pos[1] >= vSMins[1] && mouse_pos[1] <= vSMaxs[1] ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// PENDING DELETION - these are only used for the old pseudo VGUI
|
||||
|
||||
|
||||
#ifndef MOTD_NEW_VGUI
|
||||
/*
|
||||
====================
|
||||
VGUI_Window
|
||||
|
@ -42,64 +18,21 @@ Draws window with outline, border and title
|
|||
====================
|
||||
*/
|
||||
|
||||
/*
|
||||
//TAGGG - NEW. This is the old parameters. Sends to VGUI_WINDOW to draw the string with a default font size
|
||||
// (the default font size was actually 16, it has been increased to 24)
|
||||
// Order in the new overload further below also puts things in a different order.
|
||||
inline void VGUI_Window( string sTitle, vector vPosition, vector vSize ) {
|
||||
VGUI_Window(vPosition, vSize, sTitle, [24, 24]);
|
||||
}
|
||||
*/
|
||||
|
||||
void VGUI_Window( vector vPosition, vector vSize, string sTitle, vector vFontSize ) {
|
||||
void VGUI_Window( vector vPosition, vector vSize, vector vFontSize ) {
|
||||
// Draw the background
|
||||
drawfill( vPosition, vSize, VGUI_WINDOW_BGCOLOR, VGUI_WINDOW_BGALPHA );
|
||||
|
||||
// Sides
|
||||
drawfill( vPosition, [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0], vPosition[1] + vSize[1] - 1], [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition, [1, vSize[1]], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0] + vSize[0] - 1, vPosition[1]], [1, vSize[1]], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition, [vSize[0], 1], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0], vPosition[1] + vSize[1] - 1], [vSize[0], 1], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition, [1, vSize[1]], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0] + vSize[0] - 1, vPosition[1]], [1, vSize[1]], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
|
||||
// Draw the window title
|
||||
//TAGGG - little bigger.
|
||||
// Also use DRAWFLAG_NORMAL to stop the transparency from not being a solid color choice.
|
||||
// ADDITIVE interprets any darker color than as bright as possible as transparency.
|
||||
// The wordwrapped text does not support this, so let them both be solid.
|
||||
// No benefit to transparent text anyway.
|
||||
//title text font size depends on the height of the window.
|
||||
//Gfx_Text( vPosition + '16 16', sTitle, '12 12', vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
Gfx_Text( vPosition + '16 16', sTitle, vFontSize, vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_NORMAL, FONT_ARIAL_TITLE );
|
||||
|
||||
//Gfx_TextLineWrap( vPosition + '16 16', vSize - ('16 64 0' * 2) , DRAWTEXTFIELD_ALIGN_LEFT_TOP, sTitle, FONT_ARIAL_STD );
|
||||
|
||||
|
||||
drawfill( vPosition + '0 48', [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition + '0 48', [vSize[0], 1], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
VGUI_WindowSmall
|
||||
|
||||
Draws smaller window with outline, border and title
|
||||
====================
|
||||
*/
|
||||
void VGUI_WindowSmall( string sTitle, vector vPosition, vector vSize ) {
|
||||
// Draw the background
|
||||
drawfill( vPosition, vSize, VGUI_WINDOW_BGCOLOR, VGUI_WINDOW_BGALPHA );
|
||||
|
||||
// Sides
|
||||
drawfill( vPosition, [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0], vPosition[1] + vSize[1] - 1], [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition, [1, vSize[1]], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0] + vSize[0] - 1, vPosition[1]], [1, vSize[1]], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
|
||||
// Draw the window title
|
||||
Gfx_Text( vPosition + '8 8', sTitle, '12 12', vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
drawfill( vPosition + '0 24', [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
VGUI_Button
|
||||
|
@ -109,14 +42,14 @@ Draws a button, returns whether or not a mouse is hovering over it (for inherita
|
|||
*/
|
||||
|
||||
//*** NOTE! BuyMenu buttons don't use this! Only the MoTD close button, at least so far.
|
||||
float VGUI_Button( string sLabel, void() vFunction, vector vPosition, vector vSize) {
|
||||
float VGUI_Button( string sLabel, vector vPosition, vector vSize) {
|
||||
vector vLabelPos;
|
||||
|
||||
|
||||
drawfill( vPosition, [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0], vPosition[1] + vSize[1] - 1], [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition, [1, vSize[1]], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0] + vSize[0] - 1, vPosition[1]], [1, vSize[1]], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition, [vSize[0], 1], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0], vPosition[1] + vSize[1] - 1], [vSize[0], 1], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition, [1, vSize[1]], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0] + vSize[0] - 1, vPosition[1]], [1, vSize[1]], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
|
||||
// Draw the button label
|
||||
vLabelPos[0] = vPosition[0] + 16;
|
||||
|
@ -124,65 +57,14 @@ float VGUI_Button( string sLabel, void() vFunction, vector vPosition, vector vSi
|
|||
|
||||
|
||||
|
||||
if ( VGUI_CheckMouse( vPosition, vSize ) ) {
|
||||
//pSeatLocal->m_flUI_Display
|
||||
|
||||
if (pSeatLocal->m_inputMouseClicked == TRUE) {
|
||||
vFunction();
|
||||
pSeatLocal->m_inputMouseClicked = FALSE;
|
||||
}
|
||||
|
||||
Gfx_Text( vLabelPos, sLabel, vButtonFontSize, vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_ARIAL_STD );
|
||||
drawfill( vLabelPos + '0 10 0', [ stringwidth( sLabel, TRUE, '12 12' ), 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
if ( UI_CheckMouse( vPosition, vSize ) ) {
|
||||
Gfx_Text( vLabelPos, sLabel, vButtonFontSize, g_UI_Color, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_ARIAL_STD );
|
||||
drawfill( vLabelPos + '0 10 0', [ stringwidth( sLabel, TRUE, '12 12' ), 1], g_UI_Color, VGUI_WINDOW_FGALPHA );
|
||||
return TRUE;
|
||||
} else {
|
||||
Gfx_Text( vLabelPos, sLabel, vButtonFontSize, vVGUIColor * 0.8, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_ARIAL_STD );
|
||||
Gfx_Text( vLabelPos, sLabel, vButtonFontSize, g_UI_Color * 0.8, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_ARIAL_STD );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
VGUI_FakeButton
|
||||
|
||||
Looks like a button, doesn't function though. Meant for dead buttons
|
||||
====================
|
||||
*/
|
||||
void VGUI_FakeButton( string sLabel, vector vPosition, vector vSize ) {
|
||||
vector vLabelPos;
|
||||
|
||||
drawfill( vPosition, [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0], vPosition[1] + vSize[1] - 1], [vSize[0], 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( vPosition, [1, vSize[1]], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
drawfill( [vPosition[0] + vSize[0] - 1, vPosition[1]], [1, vSize[1]], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
|
||||
// Draw the button label
|
||||
vLabelPos[0] = vPosition[0] + 16;
|
||||
vLabelPos[1] = vPosition[1] + ( ( vSize[1] / 2 ) - 4 );
|
||||
|
||||
Gfx_Text( vLabelPos, sLabel, '12 12', vVGUIColor * 0.5, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
VGUI_Text
|
||||
|
||||
Wrapper for simple GUI text labels
|
||||
====================
|
||||
*/
|
||||
void VGUI_Text( string sText, vector vPos, vector vSize, float fFont ) {
|
||||
Gfx_Text( vPos, sText, vSize, vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, fFont );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
VGUI_RightText
|
||||
|
||||
Right-aligned version of above
|
||||
====================
|
||||
*/
|
||||
void VGUI_RightText( vector vPos, string sText, vector vSize, vector vColor, float fFont ) {
|
||||
vPos[0] -= stringwidth( sText, FALSE, vSize );
|
||||
Gfx_Text( vPos, sText, vSize, vColor, 1, 0, fFont );
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -191,7 +191,7 @@ Game_Worldspawn(void)
|
|||
|
||||
// The message of the day.
|
||||
// This saves the contents of the MoTD text file (path given by CVar motdfile) to a series of
|
||||
// serverinfo entries named motdline0, 1, 2, ... for reading back in client/vgui.c from the server
|
||||
// serverinfo entries named motdline0, 1, 2, ... for reading back in client/ui.qc from the server
|
||||
// at client-connect time (UI_Init) to go in the MoTD window whenever needed.
|
||||
localcmd(sprintf("echo [MOTD] Loading %s.\n", autocvar_motdfile));
|
||||
filestream fmMOTD = fopen(autocvar_motdfile, FILE_READ);
|
||||
|
|
|
@ -52,14 +52,8 @@ TS_Weapon_Draw(player pl, int weaponEquipped, BOOL useAkimbo ) {
|
|||
//weapondynamic_t dynaRef;
|
||||
//weapondynamic_t dynaRefPRE;
|
||||
|
||||
// Anything equipped already? Call vOnUnEquip of that weapon first
|
||||
// Anything equipped already?
|
||||
if(pl.inventoryEquippedIndex != -1){
|
||||
/*
|
||||
dynaRefPRE = pl.ary_myWeapons[pl.inventoryEquippedIndex];
|
||||
weapondata_basic_t* basicP = pl.getEquippedWeaponData();
|
||||
|
||||
(*basicP).vOnUnEquip(pl, dynaRefPRE);
|
||||
*/
|
||||
// How about Nuclide's 'Holster' instead?
|
||||
Weapons_Holster();
|
||||
pl.equippedWeaponDeleteCheck();
|
||||
|
@ -116,23 +110,13 @@ TS_Weapon_Draw(player pl, int weaponEquipped, BOOL useAkimbo ) {
|
|||
void
|
||||
TS_Weapon_Drop() {
|
||||
player pl = (player)self;
|
||||
|
||||
if(pl.inventoryEquippedIndex == -1){
|
||||
//stop. nothing to drop.. ?
|
||||
// stop. nothing to drop?
|
||||
return;
|
||||
}
|
||||
|
||||
// in case vOnUnEquip alters the weapon equipped, like a grenade switching out.
|
||||
int currentWeaponMem = pl.inventoryEquippedIndex;
|
||||
|
||||
// like equipping a new weapon, we have to let the existing equipped
|
||||
// weapon know that it's about to be unequipped.
|
||||
if(currentWeaponMem != -1){
|
||||
pl.dropWeapon(currentWeaponMem, FALSE);
|
||||
if(pl.inventoryEquippedIndex != -1){
|
||||
pl.dropWeapon(pl.inventoryEquippedIndex, FALSE);
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
}//TS_Weapon_Drop
|
||||
#endif
|
||||
|
||||
|
|
|
@ -32,18 +32,34 @@ void processInputs(void);
|
|||
void
|
||||
Game_Input(void)
|
||||
{
|
||||
// We can trust "self" here, right?
|
||||
// If not, grab pSeat->m_ePlayer instead!
|
||||
player pl = (player)self;
|
||||
|
||||
if(pl.iState != PLAYER_STATE::SPAWNED){
|
||||
// not ingame (fake spectator)? Do another check instead: spawning.
|
||||
#ifdef CLIENT
|
||||
if((input_buttons & INPUT_BUTTON0) && !(pl.gflags & GF_SEMI_TOGGLED) ){
|
||||
if(pSeatLocal->m_flUI_Display == UI_SCREEN::NONE && pl.iState != PLAYER_STATE::SPAWNED){
|
||||
sendevent( "GamePlayerSpawn", "");
|
||||
}
|
||||
|
||||
|
||||
if(
|
||||
pSeatLocal->m_flUI_Display == UI_SCREEN::NONE &&
|
||||
(input_buttons & INPUT_BUTTON0) &&
|
||||
!(pl.gflags & GF_SEMI_TOGGLED) &&
|
||||
pSeatLocal->flBlockSpawnTime <= time
|
||||
){
|
||||
sendevent( "GamePlayerSpawn", "");
|
||||
}
|
||||
|
||||
/*
|
||||
if(
|
||||
((input_buttons & INPUT_BUTTON0) && pSeatLocal->flBlockSpawnTime > time) ||
|
||||
pSeat->m_flInputBlockTime > time
|
||||
)
|
||||
{
|
||||
pSeatLocal->flBlockSpawnTime = time + 0.20f;
|
||||
pl.gflags |= GF_SEMI_TOGGLED;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
// since the rest of this method is about to be skipped.
|
||||
if(input_buttons & INPUT_BUTTON0){
|
||||
pl.gflags |= GF_SEMI_TOGGLED;
|
||||
|
@ -185,6 +201,7 @@ Game_Input(void)
|
|||
// An override for this to go in CSQC_Input_Frame would be very nice I think,
|
||||
// unless there is some other way that I'm missing.
|
||||
/*
|
||||
#ifdef CSQC
|
||||
if (pSeatLocal->m_iInputSpeed == TRUE) {
|
||||
//input_buttons |= INPUT_BUTTON9;
|
||||
input_buttons |= INPUT_BUTTON7;
|
||||
|
@ -192,9 +209,10 @@ Game_Input(void)
|
|||
}else{
|
||||
//self.flags &= ~FL_SNEAK;
|
||||
}
|
||||
#endif
|
||||
//printfline("input_buttons: %d", (INPUT_BUTTON7 & input_buttons) );
|
||||
*/
|
||||
|
||||
|
||||
// TS way, weapon thinks happen alongside checking inputs
|
||||
pl.callWeaponThink();
|
||||
|
||||
|
|
|
@ -32,15 +32,10 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef CLIENT
|
||||
// has the player purchased anything? Used to tell whether to print "order canceled" on exiting.
|
||||
var BOOL boughtAnything;
|
||||
|
||||
// this must be set by the client at the start of the buymenu.
|
||||
// It might look strange to have to set this and rely on this every time instead of just fetching the player by "player something = (player)self" the usual way, but this is because "self" will lead to some VGUI button instead clientside... straaaaange stuff. Just leave this this way
|
||||
|
||||
// These mirror the macros from earlier, but are for methods dealing with the local player config instead.
|
||||
|
||||
#define CONFIG_PLAYER_INVENTORY_GENERIC pSeatLocal->m_clientinfo.weaponconfig_temp.ary_myWeapons
|
||||
|
|
|
@ -1722,7 +1722,6 @@ player::dropWeapon(int arg_weaponID, BOOL completeDrop){
|
|||
// be dropped. Throwables with a count of 0 (?) would prefer to be drop-less.
|
||||
deletedCurrentWeapon = inventoryWeaponDeleteCheck(arg_weaponID);
|
||||
}
|
||||
//(*basicP).vOnUnEquip(this, dynaRefPRE);
|
||||
|
||||
// back to using the singular form unless otherwise noted.
|
||||
// CRITICAL. Should still be able to use the akimbo version for stats all the same,
|
||||
|
|
|
@ -408,15 +408,6 @@ typedef struct{
|
|||
} ironsightdata_t;
|
||||
|
||||
|
||||
|
||||
// TODO - PENDING! Remove vOnPrimaryAttack and vOnSecondaryAttack here and from all weapons,
|
||||
// Nudlie's Primary/Secondary fire calls work in place of those.
|
||||
// funOnPrimaryAttackRelease and funOnSecondaryAttackRelease are still useless it turns out,
|
||||
// but they can just lose the "hasAmmo" parameters at least.
|
||||
// ALSO: vOnEquip, vOnUnEquip, vOnDrawHUD, and vOnReload will be removed, Nuclide calls mean these are
|
||||
// no longer used.
|
||||
// AND: remove BOOL return types from the remaining methods, those will never be used.
|
||||
|
||||
// This struct only contains the bare minimum variables a class needs. Any other behavior should be
|
||||
// handled by the custom methods.
|
||||
// But note that weapondata_melee_t is identical for adding absolutely nothing.
|
||||
|
|
|
@ -372,7 +372,7 @@ w_karate_hud(void)
|
|||
|
||||
//draw the stamina bar
|
||||
drawfill( vEquippedWeaponInfoDraw, [128, 19], clrPaleBlue, 0.86f - 0.60f );
|
||||
// oh no. not minus 0, it is my weakness. .......... ???????????????????
|
||||
|
||||
//drawfill( vEquippedWeaponInfoDraw + [0,0], [(128-0) * pl.fKarateStamina, 19-2], clrPaleBlue, 0.86f - 0.55f );
|
||||
drawfill( vEquippedWeaponInfoDraw + [0,0], [(128) * pl.fKarateStamina, 19-2], clrPaleBlue, 0.86f - 0.45f );
|
||||
vEquippedWeaponInfoDraw.y -= 20;
|
||||
|
|
Loading…
Reference in a new issue