+#include "cl_minigames_hud.qh"
#include "minigames.qh"
-#include "../../client/mapvoting.qh"
// whether the mouse is over the given panel
bool HUD_mouse_over(entity somepanel)
{
vector pos = stov(cvar_string(strcat("hud_panel_", somepanel.panel_name, "_pos")));
vector sz = stov(cvar_string(strcat("hud_panel_", somepanel.panel_name, "_size")));
- return mousepos_x >= pos_x*vid_conwidth && mousepos_x <= (pos_x+sz_x)*vid_conwidth &&
+ return mousepos_x >= pos_x*vid_conwidth && mousepos_x <= (pos_x+sz_x)*vid_conwidth &&
mousepos_y >= pos_y*vid_conheight && mousepos_y <= (pos_y+sz_y)*vid_conheight ;
}
void HUD_MinigameBoard ()
{
entity hud_minigame = world;
-
+
if(!autocvar__hud_configure)
hud_minigame = active_minigame.descriptor;
else
hud_minigame = minigame_get_descriptor("nmm");
-
+
if ( !hud_minigame )
return;
-
+
HUD_Panel_UpdateCvars();
-
-
+
+
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
-
+
hud_minigame.minigame_hud_board(pos,mySize);
}
void HUD_MinigameStatus ()
{
entity hud_minigame = world;
-
+
if(!autocvar__hud_configure)
hud_minigame = active_minigame.descriptor;
else
hud_minigame = minigame_get_descriptor("nmm");
-
+
if ( !hud_minigame )
return;
-
+
HUD_Panel_UpdateCvars();
-
-
+
+
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
-
+
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
mySize -= '2 2 0' * panel_bg_padding;
}
-
+
hud_minigame.minigame_hud_status(pos,mySize);
}
entity HUD_MinigameMenu_last_entry;
// Minigame menu options: insert entry after the given location
-void HUD_MinigameMenu_InsertEntry(entity new, entity prev)
+void HUD_MinigameMenu_InsertEntry(entity newentry, entity prev)
{
if ( !HUD_MinigameMenu_entries )
{
- HUD_MinigameMenu_entries = new;
- HUD_MinigameMenu_last_entry = new;
+ HUD_MinigameMenu_entries = newentry;
+ HUD_MinigameMenu_last_entry = newentry;
return;
}
-
- new.list_prev = prev;
- new.list_next = prev.list_next;
+
+ newentry.list_prev = prev;
+ newentry.list_next = prev.list_next;
if ( prev.list_next )
- prev.list_next.list_prev = new;
+ prev.list_next.list_prev = newentry;
else
- HUD_MinigameMenu_last_entry = new;
- prev.list_next = new;
-
+ HUD_MinigameMenu_last_entry = newentry;
+ prev.list_next = newentry;
+
}
// Click the given item
void HUD_MinigameMenu_Click(entity menuitem)
-{
+{SELFPARAM();
if ( menuitem )
{
- entity e = self;
- self = menuitem;
- menuitem.use();
- self = e;
+ WITH(entity, self, menuitem, menuitem.use());
}
}
{
HUD_MinigameMenu_Click(e);
}
-
+
if ( e.list_prev )
e.list_prev.list_next = e.list_next;
else
HUD_MinigameMenu_entries = e.list_next;
-
+
if ( e.list_next )
e.list_next.list_prev = e.list_prev;
else
HUD_MinigameMenu_last_entry = e.list_prev;
-
+
if ( HUD_MinigameMenu_activeitem == e )
HUD_MinigameMenu_activeitem = world;
-
+
remove(e);
}
// Click action for Create sub-entries
void HUD_MinigameMenu_ClickCreate_Entry()
-{
+{SELFPARAM();
minigame_cmd("create ",self.netname);
}
// Helper click action for collapsible entries
// returns true when you have to create the sub-entries
bool HUD_MinigameMenu_Click_ExpandCollapse()
-{
+{SELFPARAM();
entity e;
if ( self.flags & 2 )
{
- if ( HUD_MinigameMenu_activeitem &&
+ if ( HUD_MinigameMenu_activeitem &&
HUD_MinigameMenu_activeitem.owner == self )
HUD_MinigameMenu_activeitem = world;
self.flags &= ~2;
if ( e.flags & 2 && e.origin_x == self.origin_x)
HUD_MinigameMenu_Click(e);
}
-
+
self.flags |= 2;
-
+
return true;
}
return false;
// Click action for the Create menu
void HUD_MinigameMenu_ClickCreate()
-{
+{SELFPARAM();
if ( HUD_MinigameMenu_Click_ExpandCollapse() )
{
- entity e;
entity curr;
entity prev = self;
- for ( e = minigame_descriptors; e != world; e = e.list_next )
+ FOREACH(Minigames, true, LAMBDA(
{
curr = HUD_MinigameMenu_SpawnSubEntry(
- e.message, HUD_MinigameMenu_ClickCreate_Entry, self );
- curr.netname = e.netname;
- curr.model = strzone(minigame_texture(strcat(e.netname,"/icon")));
+ it.message, HUD_MinigameMenu_ClickCreate_Entry, self );
+ curr.netname = it.netname;
+ curr.model = strzone(minigame_texture(strcat(it.netname,"/icon")));
HUD_MinigameMenu_InsertEntry( curr, prev );
prev = curr;
- }
+ }));
}
}
// Click action for Join sub-entries
void HUD_MinigameMenu_ClickJoin_Entry()
-{
+{SELFPARAM();
minigame_cmd("join ",self.netname);
HUD_MinigameMenu_EraseEntry(self);
}
// Click action for the Join menu
void HUD_MinigameMenu_ClickJoin()
-{
+{SELFPARAM();
if ( HUD_MinigameMenu_Click_ExpandCollapse() )
{
entity e = world;
// Click action for Invite sub-entries
void HUD_MinigameMenu_ClickInvite_Entry()
-{
+{SELFPARAM();
minigame_cmd("invite #",self.netname);
}
// Click action for the Invite menu
void HUD_MinigameMenu_ClickInvite()
-{
+{SELFPARAM();
if ( HUD_MinigameMenu_Click_ExpandCollapse() )
{
entity e;
}
void HUD_MinigameMenu_ClickCustomEntry()
-{
+{SELFPARAM();
if ( active_minigame )
active_minigame.minigame_event(active_minigame,"menu_click",self.netname);
}
// Click action for the Current Game menu
void HUD_MinigameMenu_ClickCurrentGame()
-{
+{SELFPARAM();
if ( HUD_MinigameMenu_Click_ExpandCollapse() )
{
HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
_("Quit"), HUD_MinigameMenu_ClickQuit, self ), self);
-
+
active_minigame.minigame_event(active_minigame,"menu_show",self);
-
+
HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
_("Invite"), HUD_MinigameMenu_ClickInvite, self), self);
}
HUD_MinigameMenu_InsertEntry(currb,HUD_MinigameMenu_last_entry);
HUD_MinigameMenu_Click(currb);
}
- else
+ else
{
entity p;
for ( e = HUD_MinigameMenu_last_entry; e != world; e = p.list_prev )
panel_pos += '1 1 0' * panel_bg_padding;
panel_size -= '2 2 0' * panel_bg_padding;
}
-
+
entity e;
-
+
panel_pos_y += hud_fontsize_y*2;
-
+
HUD_MinigameMenu_activeitem = world;
vector sz;
for ( e = HUD_MinigameMenu_entries; e != world; e = e.list_next )
// Minigame menu panel UI
void HUD_MinigameMenu ()
-{
+{
if ( !HUD_MinigameMenu_IsOpened() )
return;
-
+
HUD_Panel_UpdateCvars();
-
+
HUD_Panel_DrawBg(1);
-
+
if(panel_bg_padding)
{
panel_pos += '1 1 0' * panel_bg_padding;
HUD_MinigameMenu_DrawEntry(panel_pos,_("Minigames"),hud_fontsize*2,'0.25 0.47 0.72');
panel_pos_y += hud_fontsize_y*2;
-
+
vector color;
vector offset;
float itemh;
for ( entity e = HUD_MinigameMenu_entries; e != world; e = e.list_next )
{
color = e.colormod;
-
+
offset = e.origin;
itemh = e.size_y;
-
+
if ( e.model )
itemh = imgsz_y;
-
+
if ( e.flags & 2 )
{
- drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod,
+ drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod,
panel_fg_alpha, DRAWFLAG_NORMAL);
color = '0 0 0';
}
offset_x += imgsz_x;
offset_y = (imgsz_y-e.size_y) / 2;
}
-
+
if ( e.flags & 1 )
HUD_MinigameMenu_DrawColoredEntry(panel_pos+offset,e.message,e.size);
else
HUD_MinigameMenu_DrawEntry(panel_pos+offset,e.message,e.size,color);
-
+
if ( e == HUD_MinigameMenu_activeitem )
drawfill(panel_pos, eX*panel_size_x + eY*itemh,'1 1 1', 0.25, DRAWFLAG_ADDITIVE);
-
+
panel_pos_y += itemh;
}
}
void HUD_MinigameHelp()
{
string help_message;
-
+
if(!autocvar__hud_configure)
help_message = active_minigame.message;
else
help_message = "Minigame message";
-
+
if ( !help_message )
return;
-
+
HUD_Panel_UpdateCvars();
-
-
+
+
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
-
+
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
mySize -= '2 2 0' * panel_bg_padding;
}
-
- minigame_drawcolorcodedstring_wrapped( mySize_x, pos, help_message,
+
+ minigame_drawcolorcodedstring_wrapped( mySize_x, pos, help_message,
hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5 );
}
// ====================================================================
float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary)
{
-
+
if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure )
return false;
if ( minigame_isactive() && HUD_mouse_over(HUD_PANEL(MINIGAME_BOARD)) )
active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos);
return true;
-
+
}
else
{
if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
}
-
+
// allow some binds
string con_keys;
con_keys = findkeysforcommand("toggleconsole", 0);
if(nPrimary == stof(argv(i)))
return false;
}
-
+
if ( minigame_isactive() && ( bInputType == 0 || bInputType == 1 ) )
{
string device = "";
}
else
device = "key";
-
+
if ( device && active_minigame.minigame_event(
active_minigame,strcat(device,"_",action),nPrimary) )
return true;
-
+
/// TODO: bInputType == 2?
}
-
+
if ( bInputType == 0 )
{
if ( nPrimary == K_MOUSE1 && HUD_MinigameMenu_activeitem &&
}
}
}
-
+
return false;
}
void HUD_Minigame_Mouse()
-{
+{
if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure || mv_active )
return;
-
+
if(!autocvar_hud_cursormode)
{
mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
mousepos_x = bound(0, mousepos_x, vid_conwidth);
mousepos_y = bound(0, mousepos_y, vid_conheight);
}
-
+
if ( HUD_MinigameMenu_IsOpened() && HUD_mouse_over(HUD_PANEL(MINIGAME_MENU)) )
HUD_MinigameMenu_MouseInput();
-
+
vector cursorsize = '32 32 0';
- drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"),
+ drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"),
cursorsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
}
bool HUD_Minigame_Showpanels()
{
- return HUD_MinigameMenu_IsOpened() && ( autocvar__hud_configure || minigame_isactive() );
+ return (HUD_MinigameMenu_IsOpened() && minigame_isactive());
}