VGUI: my crummy inital implementation
This commit is contained in:
parent
0b1ca19ef7
commit
d637769e15
3 changed files with 307 additions and 0 deletions
78
src/client/init.qc
Normal file
78
src/client/init.qc
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2021 Marco Cawthorne <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
=================
|
||||
ClientGame_Init
|
||||
|
||||
Comparable to worldspawn in SSQC in that it's mostly used for precaches
|
||||
=================
|
||||
*/
|
||||
void
|
||||
ClientGame_Init(float apilevel, string enginename, float engineversion)
|
||||
{
|
||||
Obituary_Init();
|
||||
registercommand("+sciscore");
|
||||
registercommand("-sciscore");
|
||||
registercommand("chooseteam");
|
||||
}
|
||||
|
||||
bool
|
||||
ClientGame_IsUsingVGUI(void)
|
||||
{
|
||||
/* FTE has a bug with _ infokeys, so we'll accept both formats in case
|
||||
that gets fixed in the future :/ */
|
||||
if (getplayerkeyfloat(player_localnum, "vgui_menus") == 1)
|
||||
return true;
|
||||
if (getplayerkeyfloat(player_localnum, "_vgui_menus") == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void VGUI_ShowMOTD(void);
|
||||
void CMD_ChooseTeam(void);
|
||||
void
|
||||
ClientGame_InitDone(void)
|
||||
{
|
||||
if (serverkeyfloat("sv_playerslots") > 1)
|
||||
VGUI_ShowMOTD();
|
||||
}
|
||||
|
||||
void
|
||||
ClientGame_RendererRestart(string rstr)
|
||||
{
|
||||
precache_model("models/shell.mdl");
|
||||
precache_model("models/shotgunshell.mdl");
|
||||
|
||||
/* there's also muzzleflash.spr, but that's just MUZZLE_SMALL again */
|
||||
MUZZLE_RIFLE = (int)getmodelindex("sprites/muzzleflash1.spr");
|
||||
MUZZLE_SMALL = (int)getmodelindex("sprites/muzzleflash2.spr");
|
||||
MUZZLE_WEIRD = (int)getmodelindex("sprites/muzzleflash3.spr");
|
||||
|
||||
Damage_Precache();
|
||||
Obituary_Precache();
|
||||
|
||||
FX_Blood_Init();
|
||||
FX_BreakModel_Init();
|
||||
FX_Explosion_Init();
|
||||
FX_GibHuman_Init();
|
||||
FX_Spark_Init();
|
||||
FX_Impact_Init();
|
||||
FX_GaussBeam_Init();
|
||||
|
||||
BEAM_TRIPMINE = particleeffectnum("weapon_tripmine.beam");
|
||||
}
|
150
src/client/vgui_chooseteam.qc
Normal file
150
src/client/vgui_chooseteam.qc
Normal file
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
static VGUIWindow winChooseTeam;
|
||||
|
||||
class TFTeamButton:VGUIButton
|
||||
{
|
||||
void TFTeamButton(void);
|
||||
|
||||
virtual void OnMouseUp(void);
|
||||
};
|
||||
|
||||
void
|
||||
TFTeamButton::TFTeamButton(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TFTeamButton::OnMouseUp(void)
|
||||
{
|
||||
int tag = GetTag();
|
||||
|
||||
localcmd("changeclass\n");
|
||||
sendevent("TeamJoin", "f", (float)tag);
|
||||
winChooseTeam.Hide();
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
VGUI_ChooseTeam_MapInfo(void)
|
||||
{
|
||||
static string mapinfo = __NULL__;
|
||||
|
||||
if (mapinfo != __NULL__)
|
||||
return mapinfo;
|
||||
|
||||
filestream fileMap = fopen(strcat("maps/", mapname, ".txt"), FILE_READ);
|
||||
string temp;
|
||||
|
||||
if (fileMap != -1) {
|
||||
while ((temp = fgets(fileMap))) {
|
||||
mapinfo = strcat(mapinfo, temp, "\n");
|
||||
}
|
||||
} else {
|
||||
mapinfo = "No map info available.";
|
||||
}
|
||||
|
||||
return mapinfo;
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_ChooseTeam(void)
|
||||
{
|
||||
static int initialized;
|
||||
static VGUIButton btnTeamBlue;
|
||||
static VGUIButton btnTeamRed;
|
||||
static VGUIButton btnAutoAssign;
|
||||
static VGUIButton btnGoSpectator;
|
||||
static VGUIFrame frmMapInfo;
|
||||
static VGUILabel lblSelectTeam;
|
||||
static VGUILabel lblMapName;
|
||||
static VGUILabel lblMapInfo;
|
||||
|
||||
if (!initialized) {
|
||||
vector btnpos = [40,80];
|
||||
|
||||
initialized = TRUE;
|
||||
winChooseTeam = spawn(VGUIWindow);
|
||||
winChooseTeam.SetSize('640 480');
|
||||
winChooseTeam.SetStyleMask(VGUIWindowBorderless | VGUIWindowFullscreen);
|
||||
|
||||
lblSelectTeam = spawn(VGUILabel);
|
||||
lblSelectTeam.SetTitle("SELECT YOUR TEAM");
|
||||
lblSelectTeam.SetTextSize(19);
|
||||
lblSelectTeam.SetPos([40, 38]);
|
||||
lblSelectTeam.SetSize('400 24');
|
||||
|
||||
frmMapInfo = spawn(VGUIFrame);
|
||||
frmMapInfo.SetPos('176 80');
|
||||
frmMapInfo.SetSize('424 312');
|
||||
|
||||
lblMapName = spawn(VGUILabel);
|
||||
lblMapName.SetTitle(mapname);
|
||||
lblMapName.SetTextSize(19);
|
||||
lblMapName.SetPos('194 105');
|
||||
lblMapName.SetSize('250 312');
|
||||
|
||||
lblMapInfo = spawn(VGUILabel);
|
||||
lblMapInfo.SetTitle(VGUI_ChooseTeam_MapInfo());
|
||||
lblMapInfo.SetPos('194 129');
|
||||
lblMapInfo.SetSize('375 250');
|
||||
|
||||
btnTeamBlue = spawn(VGUIButton);
|
||||
btnTeamBlue.SetTitle("BLUE");
|
||||
btnTeamBlue.SetPos(btnpos);
|
||||
btnTeamBlue.SetSize('124 24');
|
||||
btnTeamBlue.SetKeyEquivalent("1");
|
||||
//btnAutoAssign.SetFunc(VGUI_AutoAssign);
|
||||
btnpos[1] += 32;
|
||||
|
||||
btnTeamRed = spawn(VGUIButton);
|
||||
btnTeamRed.SetTitle("RED");
|
||||
btnTeamRed.SetPos(btnpos);
|
||||
btnTeamRed.SetSize('124 24');
|
||||
btnTeamRed.SetKeyEquivalent("2");
|
||||
//btnAutoAssign.SetFunc(VGUI_AutoAssign);
|
||||
btnpos[1] += 32;
|
||||
|
||||
btnAutoAssign = spawn(VGUIButton);
|
||||
btnAutoAssign.SetTitle("AUTO ASSIGN");
|
||||
btnAutoAssign.SetPos(btnpos);
|
||||
btnAutoAssign.SetSize('124 24');
|
||||
btnAutoAssign.SetKeyEquivalent("5");
|
||||
//btnAutoAssign.SetFunc(VGUI_AutoAssign);
|
||||
btnpos[1] += 32;
|
||||
|
||||
btnGoSpectator = spawn(VGUIButton);
|
||||
btnGoSpectator.SetTitle("SPECTATE");
|
||||
btnGoSpectator.SetPos(btnpos);
|
||||
btnGoSpectator.SetSize('124 24');
|
||||
btnGoSpectator.SetKeyEquivalent("6");
|
||||
//btnGoSpectator.SetFunc(VGUI_GoSpectator);
|
||||
|
||||
g_uiDesktop.Add(winChooseTeam);
|
||||
winChooseTeam.Add(frmMapInfo);
|
||||
winChooseTeam.Add(lblSelectTeam);
|
||||
winChooseTeam.Add(lblMapName);
|
||||
winChooseTeam.Add(lblMapInfo);
|
||||
winChooseTeam.Add(btnTeamBlue);
|
||||
winChooseTeam.Add(btnTeamRed);
|
||||
winChooseTeam.Add(btnAutoAssign);
|
||||
winChooseTeam.Add(btnGoSpectator);
|
||||
}
|
||||
|
||||
winChooseTeam.Show();
|
||||
winChooseTeam.SetPos((video_res / 2) - (winChooseTeam.GetSize() / 2));
|
||||
}
|
79
src/client/vgui_motd.qc
Normal file
79
src/client/vgui_motd.qc
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Marco Cawthorne <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
void
|
||||
VGUI_ShowMOTD(void)
|
||||
{
|
||||
static int initialized;
|
||||
static VGUIButton winMotdClose;
|
||||
// static VGUIButton winMotdMapInfo;
|
||||
static VGUIWindow winMotd;
|
||||
static VGUILabel winMotdHostname;
|
||||
static VGUILabel winMotdBody;
|
||||
|
||||
static void VGUI_ShowMOTD_Close(void)
|
||||
{
|
||||
CMD_ChooseTeam();
|
||||
winMotd.Hide();
|
||||
}
|
||||
|
||||
if (MOTD_GetLineCount() < 1i)
|
||||
return;
|
||||
|
||||
if (!initialized) {
|
||||
initialized = TRUE;
|
||||
winMotd = spawn(VGUIWindow);
|
||||
winMotd.SetTitle("Message Of The Day");
|
||||
winMotd.SetSize('424 312');
|
||||
winMotd.SetStyleMask(0);
|
||||
|
||||
winMotdClose = spawn(VGUIButton);
|
||||
winMotdClose.SetTitle("OK");
|
||||
winMotdClose.SetPos([16, 266]);
|
||||
winMotdClose.SetSize([160, 30]);
|
||||
winMotdClose.SetFunc(VGUI_ShowMOTD_Close);
|
||||
|
||||
/* TODO An experiment with how to display map readme
|
||||
* files for non team games
|
||||
if (serverkeyfloat("teams") < 1) {
|
||||
winMotdMapInfo = spawn(VGUIButton);
|
||||
winMotdMapInfo.SetTitle("Map Info");
|
||||
winMotdMapInfo.SetPos([196, 266]);
|
||||
winMotdMapInfo.SetSize([160, 30]);
|
||||
//winMotdMapInfo.SetFunc(VGUI_ShowMOTD_Close);
|
||||
}
|
||||
*/
|
||||
|
||||
winMotdHostname = spawn(VGUILabel);
|
||||
winMotdHostname.SetTitle(serverkey("hostname"));
|
||||
winMotdHostname.SetTextSize(19);
|
||||
winMotdHostname.SetPos([16, 20]);
|
||||
|
||||
winMotdBody = spawn(VGUILabel);
|
||||
winMotdBody.SetTitle(MOTD_GetTextBody());
|
||||
winMotdBody.SetPos([16, 48]);
|
||||
winMotdBody.SetSize([392, 210]);
|
||||
|
||||
g_uiDesktop.Add(winMotd);
|
||||
winMotd.Add(winMotdClose);
|
||||
// winMotd.Add(winMotdMapInfo);
|
||||
winMotd.Add(winMotdHostname);
|
||||
winMotd.Add(winMotdBody);
|
||||
}
|
||||
|
||||
winMotd.Show();
|
||||
winMotd.SetPos((video_res / 2) - (winMotd.GetSize() / 2));
|
||||
}
|
Loading…
Reference in a new issue