X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fminigames%2Fcl_minigames_hud.qc;h=dfe918feca56d97da3c6479b54227ac96eafb5c7;hp=51155f236fffaf0357b4615a3e0123c91cc1cd97;hb=f72821fdcebe3ca01181a99727a06198de65ea08;hpb=a240e0309a8ec5837f3ac3d37c168f5262e53d5b diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index 51155f236..dfe918fec 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -1,12 +1,20 @@ +#include "cl_minigames_hud.qh" + +#include + #include "minigames.qh" -#include "../../client/mapvoting.qh" + +.vector colormod; + +#include +#include // 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 ; } @@ -18,22 +26,22 @@ bool HUD_mouse_over(entity somepanel) 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); } @@ -44,28 +52,28 @@ void HUD_MinigameBoard () 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); } @@ -87,7 +95,7 @@ void HUD_MinigameMenu_InsertEntry(entity newentry, entity prev) HUD_MinigameMenu_last_entry = newentry; return; } - + newentry.list_prev = prev; newentry.list_next = prev.list_next; if ( prev.list_next ) @@ -95,7 +103,7 @@ void HUD_MinigameMenu_InsertEntry(entity newentry, entity prev) else HUD_MinigameMenu_last_entry = newentry; prev.list_next = newentry; - + } @@ -120,20 +128,20 @@ void HUD_MinigameMenu_EraseEntry ( entity e ) { 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); } @@ -175,7 +183,7 @@ bool HUD_MinigameMenu_Click_ExpandCollapse() 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; @@ -198,9 +206,9 @@ bool HUD_MinigameMenu_Click_ExpandCollapse() if ( e.flags & 2 && e.origin_x == self.origin_x) HUD_MinigameMenu_Click(e); } - + self.flags |= 2; - + return true; } return false; @@ -211,18 +219,15 @@ 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 ) - { - curr = HUD_MinigameMenu_SpawnSubEntry( - e.message, HUD_MinigameMenu_ClickCreate_Entry, self ); - curr.netname = e.netname; - curr.model = strzone(minigame_texture(strcat(e.netname,"/icon"))); + FOREACH(Minigames, true, { + curr = HUD_MinigameMenu_SpawnSubEntry(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; - } + }); } } @@ -284,11 +289,11 @@ void HUD_MinigameMenu_ClickInvite() entity prev = self; for(int i = 0; i < maxclients; ++i) { - if ( player_localnum != i && playerslots[i] && GetPlayerName(i) != "" && + if ( player_localnum != i && playerslots[i] && entcs_GetName(i) != "" && !findfloat(world,minigame_playerslot,i+1) && playerslots[i].ping ) { e = HUD_MinigameMenu_SpawnSubEntry( - strzone(GetPlayerName(i)), HUD_MinigameMenu_ClickInvite_Entry, + strzone(entcs_GetName(i)), HUD_MinigameMenu_ClickInvite_Entry, self ); e.flags |= 1; e.netname = strzone(ftos(i+1)); @@ -323,9 +328,9 @@ void HUD_MinigameMenu_ClickCurrentGame() { 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); } @@ -333,7 +338,7 @@ void HUD_MinigameMenu_ClickCurrentGame() // Whether the minigame menu panel is open bool HUD_MinigameMenu_IsOpened() { - return !!HUD_MinigameMenu_entries; + return HUD_MinigameMenu_entries != NULL; } // Close the minigame menu panel @@ -375,7 +380,7 @@ void HUD_MinigameMenu_CurrentButton() 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 ) @@ -430,11 +435,11 @@ void HUD_MinigameMenu_MouseInput() 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 ) @@ -465,14 +470,14 @@ void HUD_MinigameMenu_DrawColoredEntry(vector pos, string s, vector fontsize) // 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; @@ -489,16 +494,16 @@ void HUD_MinigameMenu () 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'; } @@ -509,15 +514,15 @@ void HUD_MinigameMenu () 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; } } @@ -529,29 +534,29 @@ void HUD_MinigameMenu () 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 ); } @@ -560,7 +565,7 @@ void HUD_MinigameHelp() // ==================================================================== float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary) { - + if( !HUD_MinigameMenu_IsOpened() || autocvar__hud_configure ) return false; @@ -571,7 +576,7 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary if ( minigame_isactive() && HUD_mouse_over(HUD_PANEL(MINIGAME_BOARD)) ) active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos); return true; - + } else { @@ -589,7 +594,7 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary 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); @@ -599,7 +604,7 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary if(nPrimary == stof(argv(i))) return false; } - + if ( minigame_isactive() && ( bInputType == 0 || bInputType == 1 ) ) { string device = ""; @@ -611,14 +616,14 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary } 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 && @@ -665,16 +670,16 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary } } } - + 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; @@ -682,16 +687,14 @@ void HUD_Minigame_Mouse() 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"), - cursorsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + + draw_cursor_normal(mousepos, '1 1 1', panel_fg_alpha); } bool HUD_Minigame_Showpanels() { - return HUD_MinigameMenu_IsOpened() && ( autocvar__hud_configure || minigame_isactive() ); + return (HUD_MinigameMenu_IsOpened() && minigame_isactive()); }