Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add listvotes GUI #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/menus.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ reloadmenus
if (! (findfile "config.cfg")) [addzip "data/menus/guide.zip"; exec "guide.cfg"; showgui guide]

// workshop menu
if (integration) [exec "data/menus/workshop.cfg"]
if (integration) [exec "data/menus/workshop.cfg"]
85 changes: 85 additions & 0 deletions data/menus/mappoll.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
gettopvotes = [
local curbest topvotes
curbest = (at $listvotes 0)
loop i (listlen $listvotes) [
if (< (at $curbest 2) (at (at $listvotes $i) 2)) [
curbest = (at $listvotes $i)
]
]
loop i (listlen $listvotes) [
if (= (at (at $listvotes $i) 2) (at $curbest 2)) [
append topvotes (concatword "[" (at $listvotes $i) "]")
]
]
result $topvotes
]

getvotesnum = [local n; n = 0; looplist v $listvotes [n = (+ $n (at $v 2))]; result $n]

guimappoll = [
guitab (format "^f7%1 ^f8%2 in poll" (listlen $listvotes) (at ["map" "maps"] (> (listlen $listvotes) 1)))
local mpcurvote mpcurmap mpistopvoted mpimagesize
mpimagesize = (maxf 2.4 (- (at [8.5 7.5] (= (listlen $listvotes) 1)) (listlen $listvotes)))
if (listlen (getalias listvotes)) [
guialign 0 [
guilist [
loop row (div (+ (listlen $listvotes) 5) 6) [
guilist [
loop col 6 [
mpcurvote = (at $listvotes (+ (* $row 6) $col))
mpcurmap = (at $mpcurvote 0)
if (> (at $mpcurvote 2) 0) [
if (=s $mpcurmap "") [mpcurmap = "[new map]"]
if (>= (strlen $mpcurmap) 9) [mpcurmap = (strscroll $mpcurmap 9 150 0)]
mpistopvoted = (!= (indexof (gettopvotes) $mpcurvote) -1)
_mpisownvote = (!= (indexof (at $mpcurvote 3) (getclientnum)) -1)
if (strlen $mpcurvote) [
guilist [
guiimage (format "<mad:%1>packages/skyboxes/plain/white_ft.png" (
? $_mpisownvote "0/0.7/0" (? $mpistopvoted "0/1/1" "0.2/0.2/0.2")
)) [] (+f 0.1 $mpimagesize) 0 "data/background.png"

//map thumb
guiitemmove 0 0 (concatword "-" (maxf 4.9 (+f (*f $mpimagesize 2) 0.1))) [
guiimage (concatword "packages/base/" $mpcurmap ".jpg") [
mpcurvote = (at $listvotes (+ (* @row 6) @col))
mode (at $mpcurvote 1); map (at $mpcurvote 0)
] $mpimagesize 0 "packages/textures/default.png"

//stripe
guiitemmove 0 0 (concatword "-" (maxf -6 (*f $mpimagesize 2))) [
guiimage "data/stripe.png" [] $mpimagesize
guiitemmove -1 0.5 (concatword "-" (maxf -6 (*f $mpimagesize 2))) [
guititle (concatword "^f6" (at $modenames (at $mpcurvote 1)))
]
]

//counter
guiitemmove 0 0 (concatword "-" (+f $mpimagesize 0.8)) [
guititle (concatword (strstatecolor $mpistopvoted (at $mpcurvote 2) "3" "8") " " (at ["vote" "votes"] (> (at $mpcurvote 2) 1)))
//percentage
guialign 0 [guitext (strstatecolor $mpistopvoted (concatword (div (* 100 (at $mpcurvote 2)) (getvotesnum)) "^%") "3" "8") 0]
]

//map name
guiitemmove 0 0 (concatword "-" (maxf 1.2 (*f 0.6 (divf $mpimagesize 2)))) [
guitext (concatword "^f7" $mpcurmap) 0
]

//check box
guiitemmove -1 -0.2 (concatword "-" (maxf 1 (*f 0.6 (divf $mpimagesize 2)))) [
if $_mpisownvote [
guiimage "<mad:0/1/0>packages/icons/checkbox_on.jpg" [] 0.5 0 "packages/icons/arrow_fw.jpg"
] [guiimage "packages/icons/checkbox_off.jpg" [] 0.5 0]
]
]
]
]
]
]
]
]
]
]
] [guitext "^f3There is no map poll in progress"]
]
1 change: 1 addition & 0 deletions data/menus/maps.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ newgui gamemode [
guistrut 3 0
]
]
if (!=s (getalias listvotes) "") [guimappoll]
]
] "^f8mode & map"

Expand Down
Binary file added data/stripe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.