///////////////////////////////////////////////////////////////////////////////
//  Edit HUD Elements                                                        //
///////////////////////////////////////////////////////////////////////////////
edittoggled = [
   if $editing [
      showui "editstats"
      showui "varicons"
   ] [
      hideallui
   ]
]

newui "editstats" [
   uiallowinput 0
   if $hidehud [] [
      uialign -1 1
      uiabovehud
      uicolor $c_menu_a 0 0 [
         uispace $UIwindow_padding $UIwindow_padding [
            uivlist 0 [
               uicontext (
                  format "%4^f7%5^f7gridsize :^f8 %1 ^f7| worldsize :^f8 %2 ^f7| floatspeed :^f8 %3" $gridpower $mapscale $floatspeed (
                     if $hmapedit [format "heightmap brush^f8 %1 ^f7:^f8 %2^n" $hbrushindex $hbrushname] [
                        if $blendpaintmode [
                           format "blendpaint mode : ^f8%1^f7^nblend brush : ^f8%2^n" (at $blendpaintmodes $blendpaintmode) (getblendbrushname (curblendbrush))
                        ] [if (! (enthavesel)) [
                           format "index^f8 %1 ^f7:^f8 %2^n" (max 0 (getseltex)) (gettexname (getseltex))
                        ]]
                     ]
                  ) (if (enthavesel) [concat (entget) ":^f8" (enthavesel) "^f7selected^n"])
               )
               uicontext (format "cube %1%2" $selchildcount (if $showmat [selchildmat ": "]))
               uihlist 0 [
                  uicontextfill 12 0 [uicontext (format "wtr:%1k(%2%%)" $editstatwtr $editstatvtr)    ; uialign- -1 0]
                  uicontextfill 12 0 [uicontext (format "wvt:%1k(%2%%)" $editstatwvt $editstatvvt)    ; uialign- -1 0]
                  uicontextfill 11 0 [uicontext (format "evt:%1k" $editstatevt)                       ; uialign- -1 0]
                  uicontextfill  7 0 [uicontext (format "eva:%1k" $editstateva)                       ; uialign- -1 0]
               ]
               uihlist 0 [
                  uicontextfill 12 0 [uicontext (concatword "ond:" $editstatocta)                     ; uialign- -1 0]
                  uicontextfill 12 0 [uicontext (concatword "va:" $editstatva)                        ; uialign- -1 0]
                  uicontextfill 11 0 [uicontext (format "gl:%1(%2)" $editstatglde $editstatgeombatch) ; uialign- -1 0]
                  uicontextfill  7 0 [uicontext (concatword "oq:" $editstatoq)                        ; uialign- -1 0]
                  uicontextfill  7 0 [uicontext (concatword "pvs:" $editstatpvs)                      ; uialign- -1 0]
               ]
               uialign* -1 0
            ]
         ]
         uioutline $c_line ; uiclamp- 1 1 1 1
      ]
   ]
]

newui "varicons" [
   uiallowinput 0
   if $hidehud [] [
      uialign 1 1
      uispace 0.01 0.1 [
         uivlist 0 [
            looplist i (concatword "allfaces entselsnap entediting fullbright showmat " (? $scoreboardmultiplayer "nompedit")) [
               uifont "default_outline" [
                  uialign 1
                  if $$i [
                     uitext (concatword "^f8" $i) 0.47
                  ] [uicolortext $i 0x80FFFFFF 0.47]
               ]
            ]
         ]
      ]
   ]
]
