• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Snippet] Multiboard bar 'system'

Status
Not open for further replies.

Ardenian

A

Ardenian

Could someone please be so kind and write a small snippet to display a bar on a multiboard, based on rows ?
It should be similar to the one you can see here: http://www.hiveworkshop.com/forums/spells-569/advanced-aos-multiboard-v1-02-gui-185807/ -> llllllllllllllllllll

However, I would like every part, every 'I' to be configurable.
I don't quite get where that is done in the system I linked.

To summarize, I would be glad to receive a small code snippet that allows me to display
a bar in row X column Y of a multiboard with Z independently bars ( so one could change the color of each independently, for example).
 

Ardenian

A

Ardenian

Yeah, but where is the code to set the color of these 'I' and where are they indexed ?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
the code is very annoying to go through in this system as it is quite complex and written in GUI. In the Trigger "AMUpdate", you can find

  • Player Group - Pick every player in AM_PG[1] and do (Actions)
    • Loop - Actions
      • Multiboard - Set the text for AM_MB[1] item in column 6, row ((Position of (Picked player) in AM_LB[1]) + 2) to ((String((Integer((Life of AM_CHOSEN_HERO[(Player number of (Picked player))]))))) + (/ + (String((Integer((Max. Life of AM_CHOSEN_HERO[(Player number of (Picked player))])))))))
      • Set AM_MULTIPLIER[(Player number of (Picked player))] = ((Percentage life of AM_CHOSEN_HERO[(Player number of (Picked player))]) / 100.00)
      • Set AM_BARS_COLOURED[(Player number of (Picked player))] = (Integer((AM_MULTIPLIER[(Player number of (Picked player))] x (Real(AM_BAR_COUNT)))))
      • Multiboard - Set the text for AM_MB[1] item in column 7, row ((Position of (Picked player) in AM_LB[1]) + 2) to (AM_BAR_COLOUR[1] + ((Substring(AM_BAR_STRING, 1, AM_BARS_COLOURED[(Player number of (Picked player))])) + (|r + (AM_BAR_COLOUR[2] + ((Substring(AM_BAR_STRING, (AM_BARS_COLOURED[(Player number of (Picked player))] + 1), (AM_BAR_COUNT + 2))) + (|r [ + ((Strin
Then you find in the trigger "AM settings"

  • Set AM_BAR_COLOUR[1] = |cffff0303
  • Set AM_BAR_COLOUR[2] = |cff999999
But to be honest, it is not that hard to do. You can either make a one slot approach, where you update a string like "IIIIII", then change its color and display or a multiple slot approach, where you show icons in a mb row.

E.g. in a map of mine, I display the current hunger/fatigue lvls of a unit in a mb like this:

JASS:
if IsMultiboardDisplayed( udg_MULTIBOARDS[index]) == TRUE then
                // Adjust General Info for each Player 
                set boardItem = MultiboardGetItem( udg_MULTIBOARDS[index], 0, 1)
                call MultiboardSetItemValue( boardItem, "|c00ffcc00Honor|r" + "  " + I2S( udg_PLAYER_DATA[index+180]))
                loop
                    exitwhen boardSlot > 9 
                    // FATIGUE
                    set boardItem = MultiboardGetItem( udg_MULTIBOARDS[index], 3, boardSlot)
                    if udg_PLAYER_DATA[index+184] >= ( udg_PRESET_FATIGUE * boardSlot) then
                        call MultiboardSetItemIcon( boardItem, "UI\\Widgets\\EscMenu\\Human\\slider-knob.blp")
                    else
                        call MultiboardSetItemIcon( boardItem, "UI\\Widgets\\EscMenu\\Human\\slider-knobdisabled.blp")
                    endif
                    // HUNGER
                    set boardItem = MultiboardGetItem( udg_MULTIBOARDS[index], 5, boardSlot)
                    if udg_PLAYER_DATA[index+188] >= ( udg_PRESET_HUNGER * boardSlot) then
                        call MultiboardSetItemIcon( boardItem, "UI\\Widgets\\EscMenu\\Human\\slider-knob.blp")
                    else
                        call MultiboardSetItemIcon( boardItem, "UI\\Widgets\\EscMenu\\Human\\slider-knobdisabled.blp")
                    endif
                    // go through all 9 columns of MB[index] and check, if fatigue or hunger has to be displayed
                    set boardSlot = boardSlot + 1
                endloop
            endif

This basicly just loops through a row of mb slots and decides whether to show the "is stat full" or "is stat empty" icon.

Do you want the string color to change from a certain color to another in general for all the sub-strings, or do you want to be able to manipulate each sub-string?
 

Ardenian

A

Ardenian

Thanks, this definitely helps. Substring is a great idea.

It should be able to do this: IIIIIIII

1 = "|c00ffcc00 l |r"
2 = "|c00ffcc01 l |r"
3 = "|c00ffcc02 l |r"

JASS:
call MultiboardSetItemValueBJ( mb,0,0, 1+1+1+1+1+1+1 )

This should work, I think. However, what if I would like to set it dynamically ?
Change it for example to 1+1+1+1+1+1+2 ?

Would I do it like this:

JASS:
set string = MultiboardGetItem(mb,0,0)
set string = Substring(string,1,6) + 2 
call MultiboardSetItemValueBJ(mb,0,0, string)

Or is there a better way ?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Do you want it to have always a few grey bars in front of the green bars, if the value is not max? Or do you want the color of the remaining value in comparison to the max value change completely depending on the actual value (like a health bar)?

EDIT:

I created something that looks like the bar, you posted. The second colour is not really dynamic though, because I was not sure, what you wanted. You can adjust everything in this snippet. I also included (in comments) a simple example on how you could add dynamics into it).

JASS:
library M initializer SetUpStrings

    globals
        private string      COLOURED_STRING_1       = "|c0000ff00"
        private string      COLOURED_STRING_2       = "|cffffcc00"
        private integer     MAX_COUNT_COLOUR_2      = 2
        private string      COLOURED_STRING_3       = "|cFF2AB8FF"
        private string      COLOUR_CAP              = "|r"
        private integer     STRING_LENGTH           = 10
        private string      STRING_INDICATOR        = "I"
    endglobals

    public function DISPLAY_MB_ITEM takes multiboard mb, integer WHICH_ROW, integer WHICH_COLUMN, integer VALUE, integer MAX_VALUE returns nothing
        local multiboarditem boardItem      = MultiboardGetItem( mb, WHICH_ROW, WHICH_COLUMN)
        local integer VALUE_PER_INST        = MAX_VALUE / STRING_LENGTH
        local integer index                 = 1 
        local integer CURRENT_VALUE_INDEX   = VALUE / VALUE_PER_INST
        local integer CURRENT_VALUE_FULL    = CURRENT_VALUE_INDEX - MAX_COUNT_COLOUR_2
        local string  RETURN_STRING         = ""
        
        /* ADJUST THE AMOUNT OF SEMI FULL VALUES TO MAKE IT MORE DYNAMIC
        // debug adjusted values, if very low value, but not 0
        if CURRENT_VALUE_FULL <= 0 and VALUE > 0 then
            // set at least one instance to display full
            set CURRENT_VALUE_FULL = 1
        endif
        */
        // find out, how much the value actually is, and adjust the output string to that
        loop
            exitwhen index > STRING_LENGTH // loop through every position in our string indicator
            // if value is 0, then only display empty indicator
            call BJDebugMsg("loop " + I2S(index))
            if VALUE <= 0 then
                set RETURN_STRING = RETURN_STRING + COLOURED_STRING_3
            else
                // if value is not max, assemble the string indicator
                if VALUE < MAX_VALUE then
                    if index <= CURRENT_VALUE_FULL then
                        // display full value 
                        set RETURN_STRING = RETURN_STRING + COLOURED_STRING_1
                        call BJDebugMsg("value full")
                    elseif index > CURRENT_VALUE_FULL and index <= CURRENT_VALUE_INDEX then
                        // display semi value
                        set RETURN_STRING = RETURN_STRING + COLOURED_STRING_2
                        call BJDebugMsg("value semi")
                    elseif index > CURRENT_VALUE_INDEX then
                        // display empty value
                        set RETURN_STRING = RETURN_STRING + COLOURED_STRING_3
                        call BJDebugMsg("value empty")
                    endif
                else
                    // if value is max, display full string only
                    set RETURN_STRING = RETURN_STRING + COLOURED_STRING_1
                    call BJDebugMsg("value max")
                endif
            endif
            call BJDebugMsg("String returned for: " + I2S(index) + " " + RETURN_STRING)
            set index = index + 1
        endloop
        
        // display value at target item in mb
        call MultiboardSetItemValue( boardItem, RETURN_STRING)
        
        set RETURN_STRING   = null
        set boardItem       = null
    endfunction
    
    function SetUpStrings takes nothing returns nothing
        // assemble the indicator
        set COLOURED_STRING_1 = COLOURED_STRING_1 + STRING_INDICATOR + COLOUR_CAP // full
        set COLOURED_STRING_2 = COLOURED_STRING_2 + STRING_INDICATOR + COLOUR_CAP // semi
        set COLOURED_STRING_3 = COLOURED_STRING_3 + STRING_INDICATOR + COLOUR_CAP // empty
    endfunction
    
endlibrary

Try the
TestMap
 
Last edited:
I thought you were looking for something like this:
attachment.php

http://www.wc3c.net/showthread.php?t=98138

but what you want was simple text bar
 

Ardenian

A

Ardenian

Every 'I' shouold be seperately configurable ( = colored).

Thanks a lot for the material, guys, I can work with these!
 
Status
Not open for further replies.
Top