From aad8d044e488c3d13219a8782b16ac874a490f2a Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Tue, 18 Apr 2023 14:27:48 -0700 Subject: [PATCH] Client: add support for the infokey 'vgui_menus', so if that's set you'll now use VGUI based menus for team selection --- src/client/cmds.qc | 18 +- src/client/init.qc | 18 +- src/client/progs.src | 5 +- src/client/vgui_changeclass_ct.qc | 175 +++++++++++++++++++ src/client/vgui_changeclass_t.qc | 175 +++++++++++++++++++ src/client/vgui_chooseteam.qc | 279 +++++++++++++----------------- src/client/vgui_motd.qc | 72 ++++++++ 7 files changed, 576 insertions(+), 166 deletions(-) create mode 100644 src/client/vgui_changeclass_ct.qc create mode 100644 src/client/vgui_changeclass_t.qc create mode 100644 src/client/vgui_motd.qc diff --git a/src/client/cmds.qc b/src/client/cmds.qc index 293ad88..f7ea1af 100644 --- a/src/client/cmds.qc +++ b/src/client/cmds.qc @@ -14,13 +14,27 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +void VGUI_ChooseTeam(void); + +void +CMD_ChooseTeam(void) +{ + if (serverkeyfloat("sv_playerslots") <= 1) + return; + + /* handle both VGUI and text menus */ + if (ClientGame_IsUsingVGUI()) + VGUI_ChooseTeam(); + else + Textmenu_Toggle("TEAM_SELECT"); +} + int ClientGame_ConsoleCommand(void) { switch(argv(0)) { case "chooseteam": - if (serverkeyfloat("sv_playerslots") > 1) - Textmenu_Toggle("TEAM_SELECT"); + CMD_ChooseTeam(); break; case "buy": Textmenu_Toggle("BUY"); diff --git a/src/client/init.qc b/src/client/init.qc index 8aea7b5..8344ea0 100644 --- a/src/client/init.qc +++ b/src/client/init.qc @@ -112,14 +112,26 @@ ClientGame_Init(float apilevel, string enginename, float engineversion) Sound_Precache("nvg.off"); } +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) - Textmenu_Call("TEAM_SELECT"); - - VGUI_ShowMOTD(); + VGUI_ShowMOTD(); } void diff --git a/src/client/progs.src b/src/client/progs.src index a486245..188ae62 100644 --- a/src/client/progs.src +++ b/src/client/progs.src @@ -42,6 +42,9 @@ radio.qc ../../../valve/src/client/modelevent.qc ../../../src/client/include.src -../../../valve/src/client/vgui_motd.qc +vgui_motd.qc +vgui_changeclass_t.qc +vgui_changeclass_ct.qc +vgui_chooseteam.qc ../../../src/shared/include.src #endlist diff --git a/src/client/vgui_changeclass_ct.qc b/src/client/vgui_changeclass_ct.qc new file mode 100644 index 0000000..b38307a --- /dev/null +++ b/src/client/vgui_changeclass_ct.qc @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2016-2020 Marco Cawthorne + * + * 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 string g_classDescrSeal; +static string g_classDescrGSG9; +static string g_classDescrSAS; +static string g_classDescrGIGN; + +static void +CSClassCT_Init(void) +{ + g_classDescrSeal = textfile_to_string("classes/urban.txt"); + g_classDescrGSG9 = textfile_to_string("classes/gsg9.txt"); + g_classDescrSAS = textfile_to_string("classes/sas.txt"); + g_classDescrGIGN = textfile_to_string("classes/gign.txt"); +} + +static VGUIWindow winClassSelectionCT; +static VGUIPic imgClassPreview; +static VGUILabel lblClassTitle; +static VGUILabel lblClassDescription; +static VGUILabel lblClassCounter; + +class CSClassButtonCT:VGUIButton +{ + void CSClassButtonCT(void); + + virtual void OnMouseUp(void); + virtual void OnMouseEntered(void); +}; + +void +CSClassButtonCT::CSClassButtonCT(void) +{ +} + +void +CSClassButtonCT::OnMouseUp(void) +{ + int classSelection = GetTag(); + sendevent("JoinTeam", "f", (float)classSelection + 4); + winClassSelectionCT.Hide(); +} + +void +CSClassButtonCT::OnMouseEntered(void) +{ + int classSelection = GetTag(); + + switch (classSelection) { + case 1: + lblClassTitle.SetTitle(Titles_GetTextBody("Title_seal_team")); + imgClassPreview.SetImage("gfx/vgui/640_urban"); + lblClassDescription.SetTitle(g_classDescrSeal); + break; + case 2: + lblClassTitle.SetTitle(Titles_GetTextBody("Title_gsg9")); + imgClassPreview.SetImage("gfx/vgui/640_gsg9"); + lblClassDescription.SetTitle(g_classDescrGSG9); + break; + case 3: + lblClassTitle.SetTitle(Titles_GetTextBody("Title_sas")); + imgClassPreview.SetImage("gfx/vgui/640_sas"); + lblClassDescription.SetTitle(g_classDescrSAS); + break; + case 4: + lblClassTitle.SetTitle(Titles_GetTextBody("Title_gign")); + imgClassPreview.SetImage("gfx/vgui/640_gign"); + lblClassDescription.SetTitle(g_classDescrGIGN); + break; + } +} + +void +VGUI_ChooseClassCT(void) +{ + static int initialized; + static VGUILabel lblSelectClass; + static VGUIFrame frmClassInfo; + static CSClassButtonCT btnSeal; + static CSClassButtonCT btnGSG9; + static CSClassButtonCT btnSAS; + static CSClassButtonCT btnGIGN; + + if (!initialized) { + vector btnpos = [40,80]; + initialized = TRUE; + + CSClassCT_Init(); + + winClassSelectionCT = spawn(VGUIWindow); + winClassSelectionCT.SetSize([640, 480]); + winClassSelectionCT.SetStyleMask(VGUIWindowBorderless | VGUIWindowFullscreen); + + lblSelectClass = spawn(VGUILabel); + lblSelectClass.SetTitle(Titles_GetTextBody("Title_ct_model_selection")); + lblSelectClass.SetTextSize(19); + lblSelectClass.SetPos([40, 38]); + lblSelectClass.SetSize([400, 24]); + + frmClassInfo = spawn(VGUIFrame); + frmClassInfo.SetPos([176, 80]); + frmClassInfo.SetSize([424, 312]); + + imgClassPreview = spawn(VGUIPic); + imgClassPreview.SetPos([190, 90]); + + lblClassTitle = spawn(VGUILabel); + lblClassTitle.SetPos([338, 90]); + lblClassTitle.SetTextSize(19); + lblClassTitle.SetSize([320, 24]); + + lblClassCounter = spawn(VGUILabel); + lblClassCounter.SetPos([338, 90 + 32]); + lblClassCounter.SetSize([320, 18]); + + lblClassDescription = spawn(VGUILabel); + lblClassDescription.SetPos([338, 90 + 32 + 32]); + lblClassDescription.SetSize([250, 240]); + + g_uiDesktop.Add(winClassSelectionCT); + winClassSelectionCT.Add(lblSelectClass); + winClassSelectionCT.Add(frmClassInfo); + winClassSelectionCT.Add(imgClassPreview); + winClassSelectionCT.Add(lblClassTitle); + winClassSelectionCT.Add(lblClassCounter); + winClassSelectionCT.Add(lblClassDescription); + + btnSeal = spawn(CSClassButtonCT); + btnSeal.SetTitle(Titles_GetTextBody("Seal_Team_6")); + btnSeal.SetSize([124, 24]); + btnSeal.SetPos([40, 80]); + btnSeal.SetTag(1); + btnSeal.SetKeyEquivalent("1"); + btnGSG9 = spawn(CSClassButtonCT); + btnGSG9.SetTitle(Titles_GetTextBody("GSG_9")); + btnGSG9.SetSize([124, 24]); + btnGSG9.SetPos([40, 112]); + btnGSG9.SetTag(2); + btnGSG9.SetKeyEquivalent("2"); + btnSAS = spawn(CSClassButtonCT); + btnSAS.SetTitle(Titles_GetTextBody("SAS")); + btnSAS.SetSize([124, 24]); + btnSAS.SetPos([40, 144]); + btnSAS.SetTag(3); + btnSAS.SetKeyEquivalent("3"); + btnGIGN = spawn(CSClassButtonCT); + btnGIGN.SetTitle(Titles_GetTextBody("GIGN")); + btnGIGN.SetSize([124, 24]); + btnGIGN.SetPos([40, 176]); + btnGIGN.SetTag(4); + btnGIGN.SetKeyEquivalent("4"); + + winClassSelectionCT.Add(btnSeal); + winClassSelectionCT.Add(btnGSG9); + winClassSelectionCT.Add(btnSAS); + winClassSelectionCT.Add(btnGIGN); + } + + winClassSelectionCT.Show(); + winClassSelectionCT.SetPos((video_res / 2) - (winClassSelectionCT.GetSize() / 2)); +} \ No newline at end of file diff --git a/src/client/vgui_changeclass_t.qc b/src/client/vgui_changeclass_t.qc new file mode 100644 index 0000000..292b6f4 --- /dev/null +++ b/src/client/vgui_changeclass_t.qc @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2016-2020 Marco Cawthorne + * + * 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 string g_classDescrPhoenix; +static string g_classDescrLeet; +static string g_classDescrArctic; +static string g_classDescrGuerilla; + +static void +CSClassT_Init(void) +{ + g_classDescrPhoenix = textfile_to_string("classes/terror.txt"); + g_classDescrLeet = textfile_to_string("classes/leet.txt"); + g_classDescrArctic = textfile_to_string("classes/arctic.txt"); + g_classDescrGuerilla = textfile_to_string("classes/guerilla.txt"); +} + +static VGUIWindow winClassSelection; +static VGUIPic imgClassPreview; +static VGUILabel lblClassTitle; +static VGUILabel lblClassDescription; +static VGUILabel lblClassCounter; + +class CSClassButtonT:VGUIButton +{ + void CSClassButtonT(void); + + virtual void OnMouseUp(void); + virtual void OnMouseEntered(void); +}; + +void +CSClassButtonT::CSClassButtonT(void) +{ +} + +void +CSClassButtonT::OnMouseUp(void) +{ + int classSelection = GetTag(); + sendevent("JoinTeam", "f", (float)classSelection); + winClassSelection.Hide(); +} + +void +CSClassButtonT::OnMouseEntered(void) +{ + int classSelection = GetTag(); + + switch (classSelection) { + case 1: + lblClassTitle.SetTitle(Titles_GetTextBody("Phoenix_Connexion")); + imgClassPreview.SetImage("gfx/vgui/640_terror"); + lblClassDescription.SetTitle(g_classDescrPhoenix); + break; + case 2: + lblClassTitle.SetTitle(Titles_GetTextBody("L337_Krew")); + imgClassPreview.SetImage("gfx/vgui/640_leet"); + lblClassDescription.SetTitle(g_classDescrLeet); + break; + case 3: + lblClassTitle.SetTitle(Titles_GetTextBody("Arctic_Avengers")); + imgClassPreview.SetImage("gfx/vgui/640_arctic"); + lblClassDescription.SetTitle(g_classDescrArctic); + break; + case 4: + lblClassTitle.SetTitle(Titles_GetTextBody("Guerilla_Warfare")); + imgClassPreview.SetImage("gfx/vgui/640_guerilla"); + lblClassDescription.SetTitle(g_classDescrGuerilla); + break; + } +} + +void +VGUI_ChooseClassT(void) +{ + static int initialized; + static VGUILabel lblSelectClass; + static VGUIFrame frmClassInfo; + static CSClassButtonT btnPhoenix; + static CSClassButtonT btnLeet; + static CSClassButtonT btnArctic; + static CSClassButtonT btnGuerilla; + + if (!initialized) { + vector btnpos = [40,80]; + initialized = TRUE; + + CSClassT_Init(); + + winClassSelection = spawn(VGUIWindow); + winClassSelection.SetSize([640, 480]); + winClassSelection.SetStyleMask(VGUIWindowBorderless | VGUIWindowFullscreen); + + lblSelectClass = spawn(VGUILabel); + lblSelectClass.SetTitle(Titles_GetTextBody("Title_terrorist_model_selection")); + lblSelectClass.SetTextSize(19); + lblSelectClass.SetPos([40, 38]); + lblSelectClass.SetSize([400, 24]); + + frmClassInfo = spawn(VGUIFrame); + frmClassInfo.SetPos([176, 80]); + frmClassInfo.SetSize([424, 312]); + + imgClassPreview = spawn(VGUIPic); + imgClassPreview.SetPos([190, 90]); + + lblClassTitle = spawn(VGUILabel); + lblClassTitle.SetPos([338, 90]); + lblClassTitle.SetTextSize(19); + lblClassTitle.SetSize([320, 24]); + + lblClassCounter = spawn(VGUILabel); + lblClassCounter.SetPos([338, 90 + 32]); + lblClassCounter.SetSize([320, 18]); + + lblClassDescription = spawn(VGUILabel); + lblClassDescription.SetPos([338, 90 + 32 + 32]); + lblClassDescription.SetSize([250, 240]); + + g_uiDesktop.Add(winClassSelection); + winClassSelection.Add(lblSelectClass); + winClassSelection.Add(frmClassInfo); + winClassSelection.Add(imgClassPreview); + winClassSelection.Add(lblClassTitle); + winClassSelection.Add(lblClassCounter); + winClassSelection.Add(lblClassDescription); + + btnPhoenix = spawn(CSClassButtonT); + btnPhoenix.SetTitle(Titles_GetTextBody("Phoenix_Connexion")); + btnPhoenix.SetSize([124, 24]); + btnPhoenix.SetPos([40, 80]); + btnPhoenix.SetTag(1); + btnPhoenix.SetKeyEquivalent("1"); + btnLeet = spawn(CSClassButtonT); + btnLeet.SetTitle(Titles_GetTextBody("L337_Krew")); + btnLeet.SetSize([124, 24]); + btnLeet.SetPos([40, 112]); + btnLeet.SetTag(2); + btnLeet.SetKeyEquivalent("2"); + btnArctic = spawn(CSClassButtonT); + btnArctic.SetTitle(Titles_GetTextBody("Arctic_Avengers")); + btnArctic.SetSize([124, 24]); + btnArctic.SetPos([40, 144]); + btnArctic.SetTag(3); + btnArctic.SetKeyEquivalent("3"); + btnGuerilla = spawn(CSClassButtonT); + btnGuerilla.SetTitle(Titles_GetTextBody("Guerilla_Warfare")); + btnGuerilla.SetSize([124, 24]); + btnGuerilla.SetPos([40, 176]); + btnGuerilla.SetTag(4); + btnGuerilla.SetKeyEquivalent("4"); + + winClassSelection.Add(btnPhoenix); + winClassSelection.Add(btnLeet); + winClassSelection.Add(btnArctic); + winClassSelection.Add(btnGuerilla); + } + + winClassSelection.Show(); + winClassSelection.SetPos((video_res / 2) - (winClassSelection.GetSize() / 2)); +} \ No newline at end of file diff --git a/src/client/vgui_chooseteam.qc b/src/client/vgui_chooseteam.qc index 35e8b22..f3135e2 100644 --- a/src/client/vgui_chooseteam.qc +++ b/src/client/vgui_chooseteam.qc @@ -14,192 +14,151 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -static CUIWindow winChooseTeam; -static CUIWindow winCTTeam; -static CUIWindow winTTeam; +static VGUIWindow winChooseTeam; -void -T_Skin1(void) +string +VGUI_ChooseTeam_MapInfo(void) { - sendevent("GamePlayerSpawn", "f", 1); - winTTeam.Hide(); -} -void -T_Skin2(void) -{ - sendevent("GamePlayerSpawn", "f", 2); - winTTeam.Hide(); -} -void -T_Skin3(void) -{ - sendevent("GamePlayerSpawn", "f", 3); - winTTeam.Hide(); -} -void -T_Skin4(void) -{ - sendevent("GamePlayerSpawn", "f", 4); - winTTeam.Hide(); -} + static string mapinfo = __NULL__; -void -CT_Skin1(void) -{ - sendevent("GamePlayerSpawn", "f", 5); - winCTTeam.Hide(); -} -void -CT_Skin2(void) -{ - sendevent("GamePlayerSpawn", "f", 6); - winCTTeam.Hide(); -} -void -CT_Skin3(void) -{ - sendevent("GamePlayerSpawn", "f", 7); - winCTTeam.Hide(); -} -void -CT_Skin4(void) -{ - sendevent("GamePlayerSpawn", "f", 8); - winCTTeam.Hide(); -} -void -VGUI_GoSpectator(void) -{ - sendevent("GamePlayerSpawn", "f", 0); - winChooseTeam.Hide(); -} + if (mapinfo != __NULL__) + return mapinfo; + + filestream fileMap = fopen(strcat("maps/", mapname, ".txt"), FILE_READ); + string temp; -void -VGUI_ChooseTeam_CT(void) -{ - static int initialized; - static CUIButton btnSkin1; - static CUIButton btnSkin2; - static CUIButton btnSkin3; - static CUIButton btnSkin4; - - if (!initialized) { - initialized = TRUE; - winCTTeam = spawn(CUIWindow); - winCTTeam.SetTitle("Choose Skin"); - winCTTeam.SetSize([420,320]); - - btnSkin1 = spawn(CUIButton); - btnSkin1.SetTitle("Skin 1"); - btnSkin1.SetPos([8,132]); - btnSkin1.SetFunc(CT_Skin1); - - btnSkin2 = spawn(CUIButton); - btnSkin2.SetTitle("Skin 2"); - btnSkin2.SetPos([8,132+30]); - btnSkin2.SetFunc(CT_Skin2); - - btnSkin3 = spawn(CUIButton); - btnSkin3.SetTitle("Skin 3"); - btnSkin3.SetPos([8,132+30+30]); - btnSkin3.SetFunc(CT_Skin3); - - btnSkin4 = spawn(CUIButton); - btnSkin4.SetTitle("Skin 4"); - btnSkin4.SetPos([8,132+30+30+30]); - btnSkin4.SetFunc(CT_Skin4); - - g_uiDesktop.Add(winCTTeam); - winCTTeam.Add(btnSkin1); - winCTTeam.Add(btnSkin2); - winCTTeam.Add(btnSkin3); - winCTTeam.Add(btnSkin4); + if (fileMap != -1) { + while ((temp = fgets(fileMap))) { + mapinfo = strcat(mapinfo, temp, "\n"); + } + } else { + mapinfo = "No map info available."; } - winChooseTeam.Hide(); - winCTTeam.Show(); - winCTTeam.SetPos((video_res / 2) - (winCTTeam.GetSize() / 2)); + return mapinfo; } -void -VGUI_ChooseTeam_T(void) +/* returns true if you should join CT, else T */ +bool +VGUI_ChooseTeam_AutoQuery(void) { - static int initialized; - static CUIButton btnSkin1; - static CUIButton btnSkin2; - static CUIButton btnSkin3; - static CUIButton btnSkin4; + int teamT = 0; + int teamCT = 0; - if (!initialized) { - initialized = TRUE; - winTTeam = spawn(CUIWindow); - winTTeam.SetTitle("Choose Skin"); - winTTeam.SetSize([420,320]); - - btnSkin1 = spawn(CUIButton); - btnSkin1.SetTitle("Skin 1"); - btnSkin1.SetPos([8,132]); - btnSkin1.SetFunc(T_Skin1); - - btnSkin2 = spawn(CUIButton); - btnSkin2.SetTitle("Skin 2"); - btnSkin2.SetPos([8,132+30]); - btnSkin2.SetFunc(T_Skin2); - - btnSkin3 = spawn(CUIButton); - btnSkin3.SetTitle("Skin 3"); - btnSkin3.SetPos([8,132+30+30]); - btnSkin3.SetFunc(T_Skin3); - - btnSkin4 = spawn(CUIButton); - btnSkin4.SetTitle("Skin 4"); - btnSkin4.SetPos([8,132+30+30+30]); - btnSkin4.SetFunc(T_Skin4); - - g_uiDesktop.Add(winTTeam); - winTTeam.Add(btnSkin1); - winTTeam.Add(btnSkin2); - winTTeam.Add(btnSkin3); - winTTeam.Add(btnSkin4); + for (int i = -1; i > -32; i--) { + if (getplayerkeyfloat(i, "*team") == 1) { + teamT++; + } else if (getplayerkeyfloat(i, "*team") == 2) { + teamCT++; + } } - winChooseTeam.Hide(); - winTTeam.Show(); - winTTeam.SetPos((video_res / 2) - (winTTeam.GetSize() / 2)); + if (teamT > teamCT) + return true; + + return false; } void VGUI_ChooseTeam(void) { static int initialized; - static CUIButton btnGoCT; - static CUIButton btnGoT; - static CUIButton btnGoSpectator; + static VGUIButton btnJoinT; + static VGUIButton btnJoinCT; + static VGUIButton btnAutoAssign; + static VGUIButton btnGoSpectator; + static VGUIFrame frmMapInfo; + static VGUILabel lblSelectTeam; + static VGUILabel lblMapName; + static VGUILabel lblMapInfo; + + static void VGUI_ChooseTeam_CT(void) { + VGUI_ChooseClassCT(); + winChooseTeam.Hide(); + } + + static void VGUI_ChooseTeam_T(void) { + VGUI_ChooseClassT(); + winChooseTeam.Hide(); + } + + static void VGUI_ChooseTeam_Auto(void) { + if (VGUI_ChooseTeam_AutoQuery()) + VGUI_ChooseTeam_CT(); + else + VGUI_ChooseTeam_T(); + } + + static void VGUI_ChooseTeam_Spec(void) { + //sendevent("JoinAuto", ""); + winChooseTeam.Hide(); + } if (!initialized) { + vector btnpos = [40,80]; + initialized = TRUE; - winChooseTeam = spawn(CUIWindow); - winChooseTeam.SetTitle("Choose Team"); - winChooseTeam.SetSize('420 320'); + winChooseTeam = spawn(VGUIWindow); + winChooseTeam.SetSize('640 480'); + winChooseTeam.SetStyleMask(VGUIWindowBorderless | VGUIWindowFullscreen); - btnGoCT = spawn(CUIButton); - btnGoCT.SetTitle("Counter-Terrorists"); - btnGoCT.SetPos('8 132'); - btnGoCT.SetFunc(VGUI_ChooseTeam_CT); + lblSelectTeam = spawn(VGUILabel); + lblSelectTeam.SetTitle("Select Your Team"); + lblSelectTeam.SetTextSize(19); + lblSelectTeam.SetPos([40, 38]); + lblSelectTeam.SetSize('400 24'); - btnGoT = spawn(CUIButton); - btnGoT.SetTitle("Terrorists"); - btnGoT.SetPos('8 162'); - btnGoT.SetFunc(VGUI_ChooseTeam_T); + frmMapInfo = spawn(VGUIFrame); + frmMapInfo.SetPos('176 80'); + frmMapInfo.SetSize('424 312'); - btnGoSpectator = spawn(CUIButton); - btnGoSpectator.SetTitle("Spectator"); - btnGoSpectator.SetPos('8 192'); - btnGoSpectator.SetFunc(VGUI_GoSpectator); + 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'); + + btnJoinT = spawn(VGUIButton); + btnJoinT.SetTitle("Terrorist Forces"); + btnJoinT.SetPos('40 80'); + btnJoinT.SetSize('124 24'); + btnJoinT.SetKeyEquivalent("1"); + btnJoinT.SetFunc(VGUI_ChooseTeam_T); + + btnJoinCT = spawn(VGUIButton); + btnJoinCT.SetTitle("CT Forces"); + btnJoinCT.SetPos('40 112'); + btnJoinCT.SetSize('124 24'); + btnJoinCT.SetKeyEquivalent("2"); + btnJoinCT.SetFunc(VGUI_ChooseTeam_CT); + + btnAutoAssign = spawn(VGUIButton); + btnAutoAssign.SetTitle("Auto Assign"); + btnAutoAssign.SetPos('40 208'); + btnAutoAssign.SetSize('124 24'); + btnAutoAssign.SetKeyEquivalent("5"); + btnAutoAssign.SetFunc(VGUI_ChooseTeam_Auto); + + btnGoSpectator = spawn(VGUIButton); + btnGoSpectator.SetTitle("Spectate"); + btnGoSpectator.SetPos('40 272'); + btnGoSpectator.SetSize('124 24'); + btnGoSpectator.SetKeyEquivalent("6"); + btnGoSpectator.SetFunc(VGUI_ChooseTeam_Spec); g_uiDesktop.Add(winChooseTeam); - winChooseTeam.Add(btnGoCT); - winChooseTeam.Add(btnGoT); + winChooseTeam.Add(frmMapInfo); + winChooseTeam.Add(lblSelectTeam); + winChooseTeam.Add(lblMapName); + winChooseTeam.Add(lblMapInfo); + winChooseTeam.Add(btnJoinT); + winChooseTeam.Add(btnJoinCT); + winChooseTeam.Add(btnAutoAssign); winChooseTeam.Add(btnGoSpectator); } diff --git a/src/client/vgui_motd.qc b/src/client/vgui_motd.qc new file mode 100644 index 0000000..26c022d --- /dev/null +++ b/src/client/vgui_motd.qc @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 Marco Cawthorne + * + * 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 VGUIWindow winMotd; + static VGUILabel winMotdHostname; + static VGUILabel winMotdBody; + static VGUIFrame frmWindow; + + 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.SetStyleMask(VGUIWindowBorderless | VGUIWindowFullscreen); + winMotd.SetSize('424 312'); + + frmWindow = spawn(VGUIFrame); + frmWindow.SetPos('0 0'); + frmWindow.SetSize('424 312'); + + winMotdClose = spawn(VGUIButton); + winMotdClose.SetTitle("OK"); + winMotdClose.SetPos([16, 266]); + winMotdClose.SetSize([160, 30]); + winMotdClose.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(frmWindow); + winMotd.Add(winMotdClose); + winMotd.Add(winMotdHostname); + winMotd.Add(winMotdBody); + } + + winMotd.Show(); + winMotd.SetPos((video_res / 2) - (winMotd.GetSize() / 2)); +}