Implement model menu.

Can be opened using whatever is bound as the smoke grenade key.
master
Icedream 2016-04-09 21:11:48 +02:00
parent 382f047f07
commit e7b0e1089d
2 changed files with 319 additions and 0 deletions

View File

@ -172,11 +172,15 @@ onPrecacheGametype()
game["fx_confetti"] = LoadFX("props/cash_player_drop"); game["fx_confetti"] = LoadFX("props/cash_player_drop");
game["fx_boom"] = LoadFX("props/electricbox4_explode"); game["fx_boom"] = LoadFX("props/electricbox4_explode");
game["menu_models"] = "hns_models";
PreCacheString(&"HIDEANDSEEK_TIMER_SEEKER_RELEASE"); PreCacheString(&"HIDEANDSEEK_TIMER_SEEKER_RELEASE");
PreCacheString(&"HIDEANDSEEK_SEEKERS_RELEASED"); PreCacheString(&"HIDEANDSEEK_SEEKERS_RELEASED");
PreCacheString(&"OBJECTIVES_HIDEANDSEEK_DEFENDER"); PreCacheString(&"OBJECTIVES_HIDEANDSEEK_DEFENDER");
PreCacheShader(game["hiders_model_icon"]); PreCacheShader(game["hiders_model_icon"]);
PreCacheMenu(game["menu_models"]);
} }
registerPrereleaseDvar(dvarString, defaultValue, minValue, maxValue) registerPrereleaseDvar(dvarString, defaultValue, minValue, maxValue)
@ -244,6 +248,18 @@ onStartGameType()
setDvar("g_TeamName_" + game["hiders"], "Hiders"); setDvar("g_TeamName_" + game["hiders"], "Hiders");
setDvar("g_TeamName_" + game["seekers"], "Seekers"); setDvar("g_TeamName_" + game["seekers"], "Seekers");
// define models that can be changed into for hns_models menu
for (i = 0; i < 64; i++)
{
dvarName = "ui_hns_model_" + i;
value = "";
if (i < level.ModelList.size)
{
value = level.ModelList[i].RName;
}
setDvar(dvarName, value);
}
// prevent spectators ghosting through nickchanging // prevent spectators ghosting through nickchanging
setClientNameMode("auto_change"); setClientNameMode("auto_change");
@ -362,6 +378,9 @@ onPlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHit
// If victim was disguised, reset him // If victim was disguised, reset him
player deleteDisguiseModel(); player deleteDisguiseModel();
// Close menu, intended for hns_models menu
player closePopupMenu();
// Update spectator permissions // Update spectator permissions
thread checkAllowSpectating(); thread checkAllowSpectating();
} }
@ -633,6 +652,7 @@ handleHider() {
player thread enableThirdPersonSwitch("+actionslot 3", 1); player thread enableThirdPersonSwitch("+actionslot 3", 1);
player thread enableModelChange("+attack"); player thread enableModelChange("+attack");
player thread enableModelMenu("+smoke");
player thread giveHelpfulHintsForHider(); player thread giveHelpfulHintsForHider();
player thread revealWhenGameEnds(); player thread revealWhenGameEnds();
@ -828,6 +848,63 @@ enableModelChange(playerCommand) {
} }
} }
enableModelMenu(playerCommand)
{
LogPrint("enableModelMenu called");
player = self;
player endon("disconnect");
player endon("death");
// Wait for player to try and open up the menu
player notifyOnPlayerCommand("modelmenu_requested", playerCommand);
player thread handleModelMenuSelection();
for (;;)
{
player waittill("modelmenu_requested");
player IPrintLn("Opening model menu...");
player openPopupMenu(game["menu_models"]);
}
}
handleModelMenuSelection()
{
LogPrint("handleModelMenuSelection called");
player = self;
player endon("disconnect");
player endon("death");
for (;;)
{
player waittill("menuresponse", menu, response);
// Make sure this is our menu that we got a response for
if (!IsDefined(menu) || menu != "hns_models" || !IsDefined(response))
continue;
// Possible values: chmodel,<id>; back
player IPrintLn(response);
selection = StrTok(response, ",");
switch (selection[0])
{
case "chmodel":
if (selection.size != 2)
break;
modelid = int(selection[1]);
if (modelid < 0)
break;
modelid = modelid % level.ModelList.size;
player setDisguiseModel(level.ModelList[modelid].name);
break;
}
player closePopupMenu();
}
}
/* /*
* Makes sure that the disguiseEntity attached to the "self" object * Makes sure that the disguiseEntity attached to the "self" object
* (a player) is always at the same position as the object itself. * (a player) is always at the same position as the object itself.

View File

@ -0,0 +1,242 @@
/*
maxEntriesPerColumn = 16;
columnWidth = 160;
rowHeight = 18;
columns = int(level.ModelList.size / maxEntriesPerColumn);
startX = -35 - (columns * columnWidth/2);
startY = 86;
for (i = 0; i < level.ModelList.size; i++)
{
column = int(i / maxEntriesPerColumn);
row = i % maxEntriesPerColumn;
x = startX + (column * columnWidth);
y = startY + row * rowHeight;
btn = self createButton();
btn setPoint("TOPCENTER", "TOPCENTER", x, y);
//btn setParent(self.modelMenu);
btn setText(level.ModelList[i].RName);
btns[btns.size] = btn;
}
*/
#define MAX_ENTRIES_PER_ROW 3
#define COLUMN_WIDTH 192
#define BUTTON_WIDTH ( COLUMN_WIDTH - 4 )
#define ROW_HEIGHT 24
#define BUTTON_HEIGHT ( ROW_HEIGHT - 2 )
#define COLUMNS 3
#define START_X ( 0 - ( COLUMNS * COLUMN_WIDTH / 2 ) )
#define START_Y 32
#define ROW(i) ( int( i / COLUMNS ) )
#define COLUMN(i) ( i - ( ROW(i) * COLUMNS ) )
#define BUTTON_X(i) ( START_X + ( COLUMN(i) * COLUMN_WIDTH ))
#define BUTTON_Y(i) ( START_Y + ( ROW(i) * ROW_HEIGHT ))
#define MENU_MODEL_BUTTON(i) \
itemDef \
{ \
name "model" #i \
rect 0 0 BUTTON_WIDTH BUTTON_HEIGHT 2 1 \
exp rect X( BUTTON_X(i) ) \
exp rect Y( BUTTON_Y(i) ) \
foreColor 1 1 1 1 \
backColor 0 0 0 0 \
background "menu_setting_selection_bar" \
style 1 \
origin 0 0 \
group mw2_button \
type 1 \
textAlign 4 \
textAlignX 3 \
textScale 0.375 \
textFont 3 \
exp text( dvarstring( "ui_hns_model_" #i ) ) \
onFocus \
{ \
play mouse_over; \
setItemColor self backcolor 0 0 0 1; \
setLocalVarBool ui_menuAButton 1; \
} \
leaveFocus \
{ \
setItemColor self backcolor 0 0 0 0; \
setLocalVarBool ui_menuAButton 0; \
} \
action \
{ \
play mouse_click; \
scriptMenuResponse "chmodel," #i ; \
escape self; \
} \
visible when !(dvarstring( "ui_hns_model_" #i ) == "") \
} \
{
menuDef
{
name "hns_models"
rect 0 0 640 480 0 0
forecolor 1 1 1 1
focuscolor 1 1 1 1
blurWorld 7
onOpen
{
focusfirst;
}
onEsc
{
scriptmenuresponse "back";
}
itemDef
{
rect 0 0 640 480 4 4
decoration
visible 1
style 3
forecolor 0 0 0 0.4
background "white"
textscale 0.55
}
itemDef
{
rect 0 0 640 480 4 4
decoration
visible 1
style 3
forecolor 1 1 1 0
background "mockup_bg_glow"
textscale 0.55
exp forecolor a ( ( ( sin( milliseconds( ) / 1500 ) + 1 ) * 0.25 ) + 0.25 )
}
itemDef
{
rect 0 0 640 480 4 4
decoration
visible 1
style 3
forecolor 1 1 1 0
background "mockup_bg_glow"
textscale 0.55
exp forecolor a ( ( ( sin( milliseconds( ) / 480 ) + 1 ) * 0.25 ) + 0.25 )
}
/*itemDef
{
rect 0 0 320 28 1 1
decoration
visible 1
forecolor 1 1 1 1
textfont 9
textalign 6
textalignx -60
textscale 0.5
text "MODELS"
}*/
MENU_MODEL_BUTTON(0)
MENU_MODEL_BUTTON(1)
MENU_MODEL_BUTTON(2)
MENU_MODEL_BUTTON(3)
MENU_MODEL_BUTTON(4)
MENU_MODEL_BUTTON(5)
MENU_MODEL_BUTTON(6)
MENU_MODEL_BUTTON(7)
MENU_MODEL_BUTTON(8)
MENU_MODEL_BUTTON(9)
MENU_MODEL_BUTTON(10)
MENU_MODEL_BUTTON(11)
MENU_MODEL_BUTTON(12)
MENU_MODEL_BUTTON(13)
MENU_MODEL_BUTTON(14)
MENU_MODEL_BUTTON(15)
MENU_MODEL_BUTTON(16)
MENU_MODEL_BUTTON(17)
MENU_MODEL_BUTTON(18)
MENU_MODEL_BUTTON(19)
MENU_MODEL_BUTTON(20)
MENU_MODEL_BUTTON(21)
MENU_MODEL_BUTTON(22)
MENU_MODEL_BUTTON(23)
MENU_MODEL_BUTTON(24)
MENU_MODEL_BUTTON(25)
MENU_MODEL_BUTTON(26)
MENU_MODEL_BUTTON(27)
MENU_MODEL_BUTTON(28)
MENU_MODEL_BUTTON(29)
MENU_MODEL_BUTTON(30)
MENU_MODEL_BUTTON(31)
MENU_MODEL_BUTTON(32)
MENU_MODEL_BUTTON(33)
MENU_MODEL_BUTTON(34)
MENU_MODEL_BUTTON(35)
MENU_MODEL_BUTTON(36)
MENU_MODEL_BUTTON(37)
MENU_MODEL_BUTTON(38)
MENU_MODEL_BUTTON(39)
MENU_MODEL_BUTTON(40)
MENU_MODEL_BUTTON(41)
MENU_MODEL_BUTTON(42)
MENU_MODEL_BUTTON(43)
MENU_MODEL_BUTTON(44)
MENU_MODEL_BUTTON(45)
MENU_MODEL_BUTTON(46)
MENU_MODEL_BUTTON(47)
MENU_MODEL_BUTTON(48)
MENU_MODEL_BUTTON(49)
MENU_MODEL_BUTTON(50)
MENU_MODEL_BUTTON(51)
MENU_MODEL_BUTTON(52)
MENU_MODEL_BUTTON(53)
MENU_MODEL_BUTTON(54)
MENU_MODEL_BUTTON(55)
MENU_MODEL_BUTTON(56)
MENU_MODEL_BUTTON(57)
MENU_MODEL_BUTTON(58)
MENU_MODEL_BUTTON(59)
MENU_MODEL_BUTTON(60)
MENU_MODEL_BUTTON(61)
MENU_MODEL_BUTTON(62)
MENU_MODEL_BUTTON(63)
itemDef
{
rect -64 -20 336 20 1 3
visible 1
group "mw2_button"
style 1
forecolor 1 1 1 1
disablecolor 0.6 0.55 0.55 1
background "menu_button_selection_bar"
type 1
textfont 3
textalign 6
textalignx -60
textscale 0.375
text "@PLATFORM_BACK_CAPS"
action
{
play "mouse_click";
play "mouse_click";
"escape" self;
}
onFocus
{
play "mouse_over";
if ( dvarstring( "gameMode" ) != "mp" )
{
setItemColor "mw2_button" backcolor 0 0 0 0;
}
setItemColor self backcolor 0 0 0 1;
setLocalVarBool "ui_menuAButton" ( 1 );
}
leaveFocus
{
setItemColor self backcolor 0 0 0 "0.0";
setLocalVarString "ui_hint_text" ( "@NULL_EMPTY" );
setLocalVarBool "ui_menuAButton" ( 0 );
}
}
}
}