From b26329a9fb59a0915106c1f49825ec7d91971f2f Mon Sep 17 00:00:00 2001 From: Samual Date: Sun, 15 Jan 2012 16:42:20 -0500 Subject: [PATCH] Add confirmation dialog to go to the hud editor when there is no map currently running --- qcsrc/menu/classes.c | 1 + qcsrc/menu/skin-customizables.inc | 1 + .../xonotic/dialog_multiplayer_playersetup.c | 34 +++++++--------- ...ialog_multiplayer_playersetup_hudconfirm.c | 40 +++++++++++++++++++ qcsrc/menu/xonotic/mainwindow.c | 5 +++ 5 files changed, 62 insertions(+), 19 deletions(-) create mode 100644 qcsrc/menu/xonotic/dialog_multiplayer_playersetup_hudconfirm.c diff --git a/qcsrc/menu/classes.c b/qcsrc/menu/classes.c index 0be24e5ea..44141dfcd 100644 --- a/qcsrc/menu/classes.c +++ b/qcsrc/menu/classes.c @@ -79,6 +79,7 @@ #include "xonotic/dialog_singleplayer_winner.c" #include "xonotic/dialog_credits.c" #include "xonotic/credits.c" +#include "xonotic/dialog_multiplayer_playersetup_hudconfirm.c" #include "xonotic/dialog_multiplayer_playersetup_view.c" #include "xonotic/dialog_multiplayer_playersetup_weapons.c" #include "xonotic/weaponslist.c" diff --git a/qcsrc/menu/skin-customizables.inc b/qcsrc/menu/skin-customizables.inc index c4a004e85..5449cd916 100644 --- a/qcsrc/menu/skin-customizables.inc +++ b/qcsrc/menu/skin-customizables.inc @@ -67,6 +67,7 @@ SKINBEGIN SKINVECTOR(COLOR_DIALOG_VIEW, '1 0.7 0.7'); SKINVECTOR(COLOR_DIALOG_SERVERINFO, '0.7 0.7 1'); SKINVECTOR(COLOR_DIALOG_CVARS, '1 0 0'); + SKINVECTOR(COLOR_DIALOG_HUDCONFIRM, '1 0 0'); // nexposee positions of windows (they are the scale transformation // centers, NOT the actual positions of the windows!) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c b/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c index fe5739b35..cf9d12874 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c @@ -10,12 +10,21 @@ CLASS(XonoticPlayerSettingsTab) EXTENDS(XonoticTab) ATTRIB(XonoticPlayerSettingsTab, playerNameLabelAlpha, float, 0) ENDCLASS(XonoticPlayerSettingsTab) entity makeXonoticPlayerSettingsTab(); - -void HUDSetup_Join_Click(entity me, entity btn); +void HUDSetup_Start(entity me, entity btn); #endif #ifdef IMPLEMENTATION - +void HUDSetup_Check_Gamestatus(entity me, entity btn) +{ + if not(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)) // we're not in a match, ask the player if they want to start one anyway + { + DialogOpenButton_Click(btn, main.hudconfirmDialog); + } + else // already in a match, lets just cut to the point and open up the hud editor directly + { + HUDSetup_Start(me, btn); + } +} entity makeXonoticPlayerSettingsTab() { entity me; @@ -140,7 +149,7 @@ void XonoticPlayerSettingsTab_fill(entity me) me.TR(me); me.TDempty(me, 0.5); me.TD(me, 1, 2, e = makeXonoticButton(_("Other crosshair settings"), '0 0 0')); - e.onClick = HUDSetup_Join_Click; + e.onClick = HUDSetup_Start; e.onClickEntity = me; setDependent(e, "crosshair_enabled", 1, 2); // TODO: show status of crosshair dot and hittest and pickups and such here with text @@ -148,7 +157,7 @@ void XonoticPlayerSettingsTab_fill(entity me) me.TR(me); me.TDempty(me, 0.5); me.TD(me, 1, 2, e = makeXonoticButton(_("Model settings"), '0 0 0')); - e.onClick = HUDSetup_Join_Click; + e.onClick = HUDSetup_Start; e.onClickEntity = me; // TODO: show csqc model settings like forcemyplayer and deglowing/ghosting bodies with text here me.TR(me); @@ -170,24 +179,11 @@ void XonoticPlayerSettingsTab_fill(entity me) me.TR(me); me.TDempty(me, 0.5); me.TD(me, 1, 2, e = makeXonoticButton(_("HUD settings"), '0 0 0')); - if not(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)) - { - e.onClick = DialogOpenButton_Click; - e.onClickEntity = main.weaponsDialog; - } - else - { - e.onClick = HUDSetup_Join_Click; + e.onClick = HUDSetup_Check_Gamestatus; e.onClickEntity = me; - } // TODO: show hud config name with text here me.gotoRC(me, me.rows - 1, 0); me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "color -1 -1;name \"$_cl_name\";cl_cmd sendcvar cl_weaponpriority;sendcvar cl_zoomfactor;sendcvar cl_zoomspeed;sendcvar cl_autoswitch;sendcvar cl_forceplayermodelsfromxonotic;sendcvar cl_forceplayermodels;playermodel $_cl_playermodel;playerskin $_cl_playerskin", COMMANDBUTTON_APPLY)); } -void HUDSetup_Join_Click(entity me, entity btn) -{ - localcmd("togglemenu 0\n"); - localcmd("_hud_configure 1", "\n"); -} #endif diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_playersetup_hudconfirm.c b/qcsrc/menu/xonotic/dialog_multiplayer_playersetup_hudconfirm.c new file mode 100644 index 000000000..433c99bad --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_multiplayer_playersetup_hudconfirm.c @@ -0,0 +1,40 @@ +#ifdef INTERFACE +CLASS(XonoticHUDConfirmDialog) EXTENDS(XonoticDialog) + METHOD(XonoticHUDConfirmDialog, fill, void(entity)) + ATTRIB(XonoticHUDConfirmDialog, title, string, _("Enter HUD editor")) + ATTRIB(XonoticHUDConfirmDialog, color, vector, SKINCOLOR_DIALOG_HUDCONFIRM) + ATTRIB(XonoticHUDConfirmDialog, intendedWidth, float, 0.5) + ATTRIB(XonoticHUDConfirmDialog, rows, float, 4) + ATTRIB(XonoticHUDConfirmDialog, columns, float, 2) +ENDCLASS(XonoticHUDConfirmDialog) +#endif + +#ifdef IMPLEMENTATION +void HUDSetup_Start(entity me, entity btn) +{ + if not(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)) + localcmd("map hudsetup/hudsetup", "\n"); + else + localcmd("togglemenu 0\n"); + + localcmd("_hud_configure 1", "\n"); +} + +void XonoticHUDConfirmDialog_fill(entity me) +{ + entity e; + + me.TR(me); + me.TD(me, 1, 2, e = makeXonoticTextLabel(0.5, _("In order for the HUD editor to show, you must first be in game."))); + me.TR(me); + me.TD(me, 1, 2, e = makeXonoticTextLabel(0.5, _("Do you wish to start a local game to set up the HUD?"))); + me.TR(me); + me.TR(me); + me.TD(me, 1, 1, e = makeXonoticButton(_("Yes"), '1 0 0')); + e.onClick = HUDSetup_Start; + e.onClickEntity = me; + me.TD(me, 1, 1, e = makeXonoticButton(_("No"), '0 1 0')); + e.onClick = Dialog_Close; + e.onClickEntity = me; +} +#endif diff --git a/qcsrc/menu/xonotic/mainwindow.c b/qcsrc/menu/xonotic/mainwindow.c index 4f762b618..9054bef6a 100644 --- a/qcsrc/menu/xonotic/mainwindow.c +++ b/qcsrc/menu/xonotic/mainwindow.c @@ -12,6 +12,7 @@ CLASS(MainWindow) EXTENDS(ModalController) ATTRIB(MainWindow, serverInfoDialog, entity, NULL) ATTRIB(MainWindow, cvarsDialog, entity, NULL) ATTRIB(MainWindow, viewDialog, entity, NULL) + ATTRIB(MainWindow, hudconfirmDialog, entity, NULL) ATTRIB(MainWindow, mainNexposee, entity, NULL) ATTRIB(MainWindow, fadedAlpha, float, SKINALPHA_BEHIND) ATTRIB(MainWindow, dialogToShow, entity, NULL) @@ -126,6 +127,10 @@ void MainWindow_configureMainWindow(entity me) i.configureDialog(i); me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + me.hudconfirmDialog = i = spawnXonoticHUDConfirmDialog(); + i.configureDialog(i); + me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + me.advancedDialog = i = spawnXonoticAdvancedDialog(); i.configureDialog(i); me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); -- 2.39.2