diff options
-rw-r--r-- | src/cgame/cg_servercmds.c | 265 | ||||
-rw-r--r-- | src/game/bg_public.h | 16 | ||||
-rw-r--r-- | src/game/g_active.c | 2 | ||||
-rw-r--r-- | src/game/g_buildable.c | 18 | ||||
-rw-r--r-- | src/game/g_cmds.c | 17 | ||||
-rw-r--r-- | ui/tremulous_dialogs.menu | 97 |
6 files changed, 276 insertions, 139 deletions
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 636f7341..6d6c9e7e 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -456,9 +456,22 @@ CG_Menu */ void CG_Menu( int menu ) { - const char *cmd = NULL; // command to send - const char *longMsg = NULL; // command parameter - const char *shortMsg = NULL; // non-modal version of message + const char *cmd = NULL; // command to send + const char *longMsg = NULL; // command parameter + const char *shortMsg = NULL; // non-modal version of message + + const char *dialog; + switch( cg.snap->ps.stats[ STAT_PTEAM ] ) + { + case PTE_ALIENS: + dialog = "menu tremulous_alien_dialog\n"; + break; + case PTE_HUMANS: + dialog = "menu tremulous_human_dialog\n"; + break; + default: + dialog = "menu tremulous_default_dialog\n"; + } switch( menu ) { @@ -489,266 +502,299 @@ void CG_Menu( int menu ) case MN_A_TEAMFULL: longMsg = "The alien team has too many players. Please wait until slots " "become available or join the human team."; - shortMsg = "The alien team has too many players\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "The alien team has too many players"; + cmd = dialog; break; case MN_H_TEAMFULL: longMsg = "The human team has too many players. Please wait until slots " "become available or join the alien team."; - shortMsg = "The human team has too many players\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "The human team has too many players"; + cmd = dialog; break; case MN_A_TEAMCHANGEBUILDTIMER: longMsg = "You cannot leave the Alien team until your build timer " "has expired."; - shortMsg = "You cannot change teams until your build timer expires.\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "You cannot change teams until your build timer expires."; + cmd = dialog; break; case MN_H_TEAMCHANGEBUILDTIMER: longMsg = "You cannot leave the Human team until your build timer " "has expired."; - shortMsg = "You cannot change teams until your build timer expires.\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "You cannot change teams until your build timer expires."; + cmd = dialog; break; //=============================== - case MN_H_NOROOM: - longMsg = "There is no room to build here. Move until the buildable turns " + // Since cheating commands have no default binds, they will often be done + // via console. In light of this, perhaps opening a menu is + // counterintuitive + case MN_CMD_CHEAT: + longMsg = "This action is considered cheating. It can only be used " + "in cheat mode, which is not enabled on this server."; + shortMsg = "Cheats are not enabled on this server"; + cmd = dialog; + break; + + case MN_CMD_TEAM: + longMsg = "You must be on a team to perform this action. Join the alien" + "or human team and try again."; + shortMsg = "Join a team first"; + cmd = dialog; + break; + + case MN_CMD_SPEC: + longMsg = "You may not perform this action while on a team. Become a " + "spectator before trying again."; + shortMsg = "You can only use this command when spectating"; + cmd = dialog; + break; + + case MN_CMD_ALIEN: + longMsg = "You must be on the alien team to perform this action."; + shortMsg = "Must be alien to use this command"; + cmd = dialog; + break; + + case MN_CMD_HUMAN: + longMsg = "You must be on the human team to perform this action."; + shortMsg = "Must be human to use this command"; + cmd = dialog; + break; + + case MN_CMD_LIVING: + longMsg = "You must be living to perform this action."; + shortMsg = "Must be living to use this command"; + cmd = dialog; + break; + + + //=============================== + + case MN_B_NOROOM: + longMsg = "There is no room to build here. Move until the structure turns " "translucent green indicating a valid build location."; - shortMsg = "There is no room to build here\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "There is no room to build here"; + cmd = dialog; break; + case MN_B_NORMAL: + longMsg = "Cannot build on this surface. The surface is too steep or " + "unsuitable to build on. Please choose another site for this " + "structure."; + shortMsg = "Cannot build on this surface"; + cmd = dialog; + break; + + + //=============================== + case MN_H_NOBP: longMsg = "There is no power remaining. Free up power by destroying " "existing buildable objects."; - shortMsg = "There is no power remaining\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "There is no power remaining"; + cmd = dialog; break; case MN_H_NOTPOWERED: longMsg = "This buildable is not powered. Build a Reactor and/or Repeater " "in order to power it."; - shortMsg = "This buildable is not powered\n"; - cmd = "menu tremulous_human_dialog\n"; - break; - - case MN_H_NORMAL: - longMsg = "Cannot build on this surface. The surface is too steep or " - "unsuitable to build on. Please choose another site for this " - "structure."; - shortMsg = "Cannot build on this surface\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "This buildable is not powered"; + cmd = dialog; break; case MN_H_ONEREACTOR: longMsg = "There can only be one Reactor. Destroy the existing one if you " "wish to move it."; - shortMsg = "There can only be one Reactor\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "There can only be one Reactor"; + cmd = dialog; break; case MN_H_NOPOWERHERE: longMsg = "There is no power here. If available, a Repeater may be used to " "transmit power to this location."; - shortMsg = "There is no power here\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "There is no power here"; + cmd = dialog; break; case MN_H_NODCC: longMsg = "There is no Defense Computer. A Defense Computer is needed to " "build this."; - shortMsg = "There is no Defense Computer\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "There is no Defense Computer"; + cmd = dialog; break; case MN_H_TNODEWARN: longMsg = "WARNING: This Telenode will not be powered. Build near a power " "structure to prevent seeing this message again."; - shortMsg = "This Telenode will not be powered\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "This Telenode will not be powered"; + cmd = dialog; break; case MN_H_RPTNOREAC: longMsg = "WARNING: This Repeater will not be powered as there is no parent " "Reactor providing power. Build a Reactor."; - shortMsg = "This Repeater will not be powered\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "This Repeater will not be powered"; + cmd = dialog; break; case MN_H_RPTPOWERHERE: longMsg = "This area already has power. A Repeater is not required here."; - shortMsg = "This area already has power\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "This area already has power"; + cmd = dialog; break; case MN_H_NOSLOTS: longMsg = "You have no room to carry this. Please sell any conflicting " "upgrades before purchasing this item."; - shortMsg = "You have no room to carry this\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "You have no room to carry this"; + cmd = dialog; break; case MN_H_NOFUNDS: longMsg = "Insufficient funds. You do not have enough credits to perform " "this action."; - shortMsg = "Insufficient funds\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "Insufficient funds"; + cmd = dialog; break; case MN_H_ITEMHELD: longMsg = "You already hold this item. It is not possible to carry multiple " "items of the same type."; - shortMsg = "You already hold this item\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "You already hold this item"; + cmd = dialog; break; case MN_H_NOARMOURYHERE: longMsg = "You must be near a powered Armoury in order to purchase " "weapons, upgrades or non-energy ammunition."; - shortMsg = "You must be near a powered Armoury\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "You must be near a powered Armoury"; + cmd = dialog; break; case MN_H_NOENERGYAMMOHERE: longMsg = "You must be near an Armoury, Reactor or Repeater in order " "to purchase energy ammunition."; - shortMsg = "You must be near an Armoury, Reactor or Repeater\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "You must be near an Armoury, Reactor or Repeater"; + cmd = dialog; break; case MN_H_NOROOMBSUITON: longMsg = "There is not enough room here to put on a Battle Suit. " "Make sure you have enough head room to climb in."; - shortMsg = "Not enough room here to put on a Battle Suit\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "Not enough room here to put on a Battle Suit"; + cmd = dialog; break; case MN_H_NOROOMBSUITOFF: longMsg = "There is not enough room here to take off your Battle Suit. " "Make sure you have enough head room to climb out."; - shortMsg = "Not enough room here to take off your Battle Suit\n"; - cmd = "menu tremulous_human_dialog\n"; + shortMsg = "Not enough room here to take off your Battle Suit"; + cmd = dialog; break; case MN_H_ARMOURYBUILDTIMER: longMsg = "You are not allowed to buy or sell weapons until your " "build timer has expired."; shortMsg = "You can not buy or sell weapos until your build timer " - "expires\n"; - cmd = "menu tremulous_human_dialog\n"; + "expires"; + cmd = dialog; break; //=============================== - case MN_A_NOROOM: - longMsg = "There is no room to build here. Move until the structure turns " - "translucent green indicating a valid build location."; - shortMsg = "There is no room to build here\n"; - cmd = "menu tremulous_alien_dialog\n"; - break; - case MN_A_NOCREEP: longMsg = "There is no creep here. You must build near existing Eggs or " "the Overmind. Alien structures will not support themselves."; - shortMsg = "There is no creep here\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "There is no creep here"; + cmd = dialog; break; case MN_A_NOOVMND: longMsg = "There is no Overmind. An Overmind must be built to control " "the structure you tried to place"; - shortMsg = "There is no Overmind\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "There is no Overmind"; + cmd = dialog; break; case MN_A_ONEOVERMIND: longMsg = "There can only be one Overmind. Destroy the existing one if you " "wish to move it."; - shortMsg = "There can only be one Overmind\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "There can only be one Overmind"; + cmd = dialog; break; case MN_A_ONEHOVEL: longMsg = "There can only be one Hovel. Destroy the existing one if you " "wish to move it."; - shortMsg = "There can only be one Hovel\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "There can only be one Hovel"; + cmd = dialog; break; case MN_A_NOBP: longMsg = "The Overmind cannot control any more structures. Destroy existing " "structures to build more."; - shortMsg = "The Overmind cannot control any more structures\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "The Overmind cannot control any more structures"; + cmd = dialog; break; case MN_A_SPWNWARN: longMsg = "WARNING: This spawn will not be controlled by an Overmind. " "Build an Overmind to prevent seeing this message again."; - shortMsg = "This spawn will not be controlled by an Overmind\n"; - cmd = "menu tremulous_alien_dialog\n"; - break; - - case MN_A_NORMAL: - longMsg = "Cannot build on this surface. This surface is too steep or " - "unsuitable to build on. Please choose another site for this " - "structure."; - shortMsg = "Cannot build on this surface\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "This spawn will not be controlled by an Overmind"; + cmd = dialog; break; case MN_A_NOEROOM: longMsg = "There is no room to evolve here. Move away from walls or other " "nearby objects and try again."; - cmd = "menu tremulous_alien_dialog\n"; - shortMsg = "There is no room to evolve here\n"; + cmd = dialog; + shortMsg = "There is no room to evolve here"; break; case MN_A_TOOCLOSE: longMsg = "This location is too close to the enemy to evolve. Move away " "until you are no longer aware of the enemy's presence and try " - "again."; - shortMsg = "This location is too close to the enemy to evolve\n"; - cmd = "menu tremulous_alien_dialog\n"; + "again."; + shortMsg = "This location is too close to the enemy to evolve"; + cmd = dialog; break; case MN_A_NOOVMND_EVOLVE: longMsg = "There is no Overmind. An Overmind must be built to allow " "you to upgrade."; - shortMsg = "There is no Overmind\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "There is no Overmind"; + cmd = dialog; break; case MN_A_EVOLVEBUILDTIMER: longMsg = "You cannot Evolve until your build timer has expired."; - shortMsg = "You cannot Evolve until your build timer expires\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "You cannot Evolve until your build timer expires"; + cmd = dialog; break; case MN_A_HOVEL_OCCUPIED: longMsg = "This Hovel is already occupied by another builder."; - shortMsg = "This Hovel is already occupied by another builder\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "This Hovel is already occupied by another builder"; + cmd = dialog; break; case MN_A_HOVEL_BLOCKED: longMsg = "The exit to this Hovel is currently blocked. Please wait until it " "becomes clear then try again."; - shortMsg = "The exit to this Hovel is currently blocked\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "The exit to this Hovel is currently blocked"; + cmd = dialog; break; case MN_A_HOVEL_EXIT: longMsg = "The exit to this Hovel would always be blocked. Please choose " "a more suitable location."; - shortMsg = "The exit to this Hovel would always be blocked\n"; - cmd = "menu tremulous_alien_dialog\n"; + shortMsg = "The exit to this Hovel would always be blocked"; + cmd = dialog; break; case MN_A_INFEST: @@ -761,22 +807,23 @@ void CG_Menu( int menu ) Com_Printf( "cgame: debug: no such menu %d\n", menu ); } - if( !cg_disableWarningDialogs.integer || !shortMsg ) + if( cg_disableWarningDialogs.integer == 0 && + !shortMsg ) { - // Player either wants dialog window or there's no short message - if( cmd ) + // Player either wants dialog window or there's no short message + if( cmd ) { - if( longMsg ) - trap_Cvar_Set( "ui_dialog", longMsg ); + if( longMsg ) + trap_Cvar_Set( "ui_dialog", longMsg ); - trap_SendConsoleCommand( cmd ); - } - } - else + trap_SendConsoleCommand( cmd ); + } + } + else if( cg_disableWarningDialogs.integer == 1 ) { - // There is short message and player wants it - CG_Printf( shortMsg ); - } + // There is short message and player wants it + CG_Printf( "%s\n", shortMsg ); + } } /* diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 6a6869c9..a5d6680c 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -574,6 +574,14 @@ typedef enum MN_A_TEAMFULL, MN_H_TEAMFULL, + // cmd stuff + MN_CMD_CHEAT, + MN_CMD_TEAM, + MN_CMD_SPEC, + MN_CMD_ALIEN, + MN_CMD_HUMAN, + MN_CMD_LIVING, + //alien stuff MN_A_CLASS, MN_A_BUILD, @@ -584,14 +592,16 @@ typedef enum MN_A_TOOCLOSE, MN_A_NOOVMND_EVOLVE, + //shared build + MN_B_NOROOM, + MN_B_NORMAL, + //alien build MN_A_SPWNWARN, // not currently used MN_A_ONEOVERMIND, MN_A_NOBP, MN_A_NOCREEP, MN_A_NOOVMND, - MN_A_NOROOM, - MN_A_NORMAL, // too steep MN_A_ONEHOVEL, MN_A_HOVEL_EXIT, MN_A_TEAMCHANGEBUILDTIMER, @@ -615,8 +625,6 @@ typedef enum MN_H_NOTPOWERED, MN_H_NODCC, MN_H_ONEREACTOR, - MN_H_NOROOM, - MN_H_NORMAL, // too steep MN_H_TNODEWARN, // not currently used MN_H_RPTNOREAC, MN_H_RPTPOWERHERE, diff --git a/src/game/g_active.c b/src/game/g_active.c index 090b83d6..f641d7ca 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -259,7 +259,7 @@ ClientImpacts */ void ClientImpacts( gentity_t *ent, pmove_t *pm ) { - int i, j; + int i; trace_t trace; gentity_t *other; diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 40d2ab7e..ee5a55ce 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -2042,8 +2042,7 @@ Used by HMGTurret_Think to track enemy location */ qboolean HMGTurret_TrackEnemy( gentity_t *self ) { - trace_t tr; - vec3_t dirToTarget, dttAdjusted, angleToTarget, angularDiff, xNormal, end; + vec3_t dirToTarget, dttAdjusted, angleToTarget, angularDiff, xNormal; vec3_t refNormal = { 0.0f, 0.0f, 1.0f }; float temp, rotAngle, angularSpeed; @@ -3455,17 +3454,11 @@ qboolean G_BuildIfValid( gentity_t *ent, buildable_t buildable ) return qfalse; case IBE_NORMAL: - if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) - G_TriggerMenu( ent->client->ps.clientNum, MN_H_NORMAL ); - else - G_TriggerMenu( ent->client->ps.clientNum, MN_A_NORMAL ); + G_TriggerMenu( ent->client->ps.clientNum, MN_B_NORMAL ); return qfalse; case IBE_PERMISSION: - if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) - G_TriggerMenu( ent->client->ps.clientNum, MN_H_NORMAL ); - else - G_TriggerMenu( ent->client->ps.clientNum, MN_A_NORMAL ); + G_TriggerMenu( ent->client->ps.clientNum, MN_B_NORMAL ); return qfalse; case IBE_ONEREACTOR: @@ -3477,10 +3470,7 @@ qboolean G_BuildIfValid( gentity_t *ent, buildable_t buildable ) return qfalse; case IBE_NOROOM: - if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) - G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOROOM ); - else - G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOROOM ); + G_TriggerMenu( ent->client->ps.clientNum, MN_B_NOROOM ); return qfalse; case IBE_NOHUMANBP: diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 2824018a..b530af51 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -2964,8 +2964,7 @@ void ClientCommand( int clientNum ) if( cmds[ i ].cmdFlags & CMD_CHEAT && !g_cheats.integer ) { - trap_SendServerCommand( clientNum, - "print \"Cheats are not enabled on this server\n\"" ); + G_TriggerMenu( clientNum, MN_CMD_CHEAT ); return; } @@ -2975,31 +2974,28 @@ void ClientCommand( int clientNum ) if( cmds[ i ].cmdFlags & CMD_TEAM && ent->client->pers.teamSelection == PTE_NONE ) { - trap_SendServerCommand( clientNum, "print \"Join a team first\n\"" ); + G_TriggerMenu( clientNum, MN_CMD_TEAM ); return; } if( cmds[ i ].cmdFlags & CMD_SPEC && ent->client->sess.sessionTeam != TEAM_SPECTATOR ) { - trap_SendServerCommand( clientNum, - "print \"You can only use this command when spectating\n\"" ); + G_TriggerMenu( clientNum, MN_CMD_SPEC ); return; } if( cmds[ i ].cmdFlags & CMD_ALIEN && ent->client->pers.teamSelection != PTE_ALIENS ) { - trap_SendServerCommand( clientNum, - "print \"Must be alien to use this command\n\"" ); + G_TriggerMenu( clientNum, MN_CMD_ALIEN ); return; } if( cmds[ i ].cmdFlags & CMD_HUMAN && ent->client->pers.teamSelection != PTE_HUMANS ) { - trap_SendServerCommand( clientNum, - "print \"Must be human to use this command\n\"" ); + G_TriggerMenu( clientNum, MN_CMD_HUMAN ); return; } @@ -3007,8 +3003,7 @@ void ClientCommand( int clientNum ) ( ent->client->ps.stats[ STAT_HEALTH ] <= 0 || ent->client->sess.sessionTeam == TEAM_SPECTATOR ) ) { - trap_SendServerCommand( clientNum, - "print \"Must be living to use this command\n\"" ); + G_TriggerMenu( clientNum, MN_CMD_LIVING ); return; } diff --git a/ui/tremulous_dialogs.menu b/ui/tremulous_dialogs.menu new file mode 100644 index 00000000..ca712d57 --- /dev/null +++ b/ui/tremulous_dialogs.menu @@ -0,0 +1,97 @@ +#include "ui/menudef.h" + +{ + +#define W 280 +#define H 190 +#define BORDER 10 + +#define BUTT_H 25 +#define BUTT_W 45 + +#define INFO_W (W-(2*BORDER)) +#define INFO_H (H-((4*BORDER)+(2*BUTT_H))) +#define INFO_X BORDER +#define INFO_Y ((2*BORDER)+BUTT_H) +#define INFO_TOFF 6 + + menuDef + { + name "tremulous_default_dialog" + visible MENU_FALSE + fullscreen MENU_FALSE + outOfBoundsClick + rect (320-(W/2)) (240-(H/2)) W H + focusColor 1 .75 0 1 + style WINDOW_STYLE_EMPTY + popup + + itemDef + { + name window + rect 0 0 W H + style WINDOW_STYLE_FILLED + backcolor 0 0 0 1 + visible MENU_TRUE + decoration + + border WINDOW_BORDER_FULL + borderSize 1.0 + borderColor 0.5 0.5 0.5 1 + } + + itemDef + { + name default_dialog + text "Error" + type ITEM_TYPE_TEXT + textstyle ITEM_TEXTSTYLE_NORMAL + style WINDOW_STYLE_EMPTY + rect BORDER BORDER INFO_W BUTT_H + textalign ALIGN_CENTER + textvalign VALIGN_CENTER + textscale .4 + forecolor 1 1 1 1 + backcolor .5 0 0 .25 + visible MENU_TRUE + decoration + } + + itemDef + { + name default_dialog + textstyle ITEM_TEXTSTYLE_NORMAL + style WINDOW_STYLE_EMPTY + rect INFO_X INFO_Y INFO_W INFO_H + cvar "ui_dialog" + wrapped + textalign ALIGN_CENTER + textvalign VALIGN_CENTER + textscale .33 + forecolor 1 1 1 1 + backcolor .5 0 0 .25 + visible MENU_TRUE + decoration + } + + itemDef + { + name default_dialog + text "OK" + type ITEM_TYPE_BUTTON + style WINDOW_STYLE_EMPTY + rect (W-(BORDER+BUTT_W)) (H-(BORDER+BUTT_H)) BUTT_W BUTT_H + textalign ALIGN_CENTER + textvalign VALIGN_CENTER + textscale .4 + forecolor 1 1 1 1 + backcolor .5 0 0 .25 + visible MENU_TRUE + action + { + play "sound/misc/menu1.wav"; + close tremulous_default_dialog + } + } + } +} |