Skip to content

Commit

Permalink
Client: Add auto-skin selection buttons that were missing in team menus.
Browse files Browse the repository at this point in the history
  • Loading branch information
eukara committed Apr 19, 2023
1 parent 1c3d265 commit 3858bfb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/client/vgui_changeclass_ct.qc
Expand Up @@ -26,6 +26,9 @@ CSClassCT_Init(void)
g_classDescrGSG9 = textfile_to_string("classes/gsg9.txt");
g_classDescrSAS = textfile_to_string("classes/sas.txt");
g_classDescrGIGN = textfile_to_string("classes/gign.txt");

if (!g_classDescrAuto)
g_classDescrAuto = textfile_to_string("classes/autoselect.txt");
}

static VGUIWindow winClassSelectionCT;
Expand All @@ -51,6 +54,11 @@ void
CSClassButtonCT::OnMouseUp(void)
{
int classSelection = GetTag();

/* auto-select, aka random really */
if (classSelection == 5)
classSelection = floor(random(1, 5));

sendevent("JoinTeam", "f", (float)classSelection + 4);
winClassSelectionCT.Hide();
}
Expand Down Expand Up @@ -81,6 +89,11 @@ CSClassButtonCT::OnMouseEntered(void)
imgClassPreview.SetImage("gfx/vgui/640_gign");
lblClassDescription.SetTitle(g_classDescrGIGN);
break;
case 5:
lblClassTitle.SetTitle(Titles_GetTextBody("Auto_Select"));
imgClassPreview.SetImage("gfx/vgui/640_ct_random");
lblClassDescription.SetTitle(g_classDescrAuto);
break;
}
}

Expand All @@ -94,6 +107,7 @@ VGUI_ChooseClassCT(void)
static CSClassButtonCT btnGSG9;
static CSClassButtonCT btnSAS;
static CSClassButtonCT btnGIGN;
static CSClassButtonCT btnAuto;

if (!initialized) {
vector btnpos = [40,80];
Expand Down Expand Up @@ -163,11 +177,18 @@ VGUI_ChooseClassCT(void)
btnGIGN.SetPos([40, 176]);
btnGIGN.SetTag(4);
btnGIGN.SetKeyEquivalent("4");
btnAuto = spawn(CSClassButtonCT);
btnAuto.SetTitle(Titles_GetTextBody("Auto_Select"));
btnAuto.SetSize([124, 24]);
btnAuto.SetPos([40, 240]);
btnAuto.SetTag(5);
btnAuto.SetKeyEquivalent("5");

winClassSelectionCT.Add(btnSeal);
winClassSelectionCT.Add(btnGSG9);
winClassSelectionCT.Add(btnSAS);
winClassSelectionCT.Add(btnGIGN);
winClassSelectionCT.Add(btnAuto);
}

winClassSelectionCT.Show();
Expand Down
22 changes: 22 additions & 0 deletions src/client/vgui_changeclass_t.qc
Expand Up @@ -18,6 +18,7 @@ static string g_classDescrPhoenix;
static string g_classDescrLeet;
static string g_classDescrArctic;
static string g_classDescrGuerilla;
string g_classDescrAuto;

static void
CSClassT_Init(void)
Expand All @@ -26,6 +27,9 @@ CSClassT_Init(void)
g_classDescrLeet = textfile_to_string("classes/leet.txt");
g_classDescrArctic = textfile_to_string("classes/arctic.txt");
g_classDescrGuerilla = textfile_to_string("classes/guerilla.txt");

if (g_classDescrAuto)
g_classDescrAuto = textfile_to_string("classes/autoselect.txt");
}

static VGUIWindow winClassSelection;
Expand All @@ -51,6 +55,11 @@ void
CSClassButtonT::OnMouseUp(void)
{
int classSelection = GetTag();

/* auto-select, aka random really */
if (classSelection == 5)
classSelection = floor(random(1, 5));

sendevent("JoinTeam", "f", (float)classSelection);
winClassSelection.Hide();
}
Expand Down Expand Up @@ -81,6 +90,11 @@ CSClassButtonT::OnMouseEntered(void)
imgClassPreview.SetImage("gfx/vgui/640_guerilla");
lblClassDescription.SetTitle(g_classDescrGuerilla);
break;
case 5:
lblClassTitle.SetTitle(Titles_GetTextBody("Auto_Select"));
imgClassPreview.SetImage("gfx/vgui/640_t_random");
lblClassDescription.SetTitle(g_classDescrAuto);
break;
}
}

Expand All @@ -94,6 +108,7 @@ VGUI_ChooseClassT(void)
static CSClassButtonT btnLeet;
static CSClassButtonT btnArctic;
static CSClassButtonT btnGuerilla;
static CSClassButtonT btnAuto;

if (!initialized) {
vector btnpos = [40,80];
Expand Down Expand Up @@ -163,11 +178,18 @@ VGUI_ChooseClassT(void)
btnGuerilla.SetPos([40, 176]);
btnGuerilla.SetTag(4);
btnGuerilla.SetKeyEquivalent("4");
btnAuto = spawn(CSClassButtonT);
btnAuto.SetTitle(Titles_GetTextBody("Auto_Select"));
btnAuto.SetSize([124, 24]);
btnAuto.SetPos([40, 240]);
btnAuto.SetTag(5);
btnAuto.SetKeyEquivalent("5");

winClassSelection.Add(btnPhoenix);
winClassSelection.Add(btnLeet);
winClassSelection.Add(btnArctic);
winClassSelection.Add(btnGuerilla);
winClassSelection.Add(btnAuto);
}

winClassSelection.Show();
Expand Down

0 comments on commit 3858bfb

Please sign in to comment.