HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Multiboard problems.

01-21-2010, 08:26 AM#1
Anachron
Sup dudes. I am having some issues with the library Board.

I didn't test whether this is a multiboard problem in general or not, well here it is, my code:

Collapse JASS:
library CIItemBoard initializer init requires Board, CIItemInfo, CIBonus, CustomItem
    globals
        constant string CIItemBoard_DefAmrIcon  = "ReplaceableTextures\\CommandButtons\\BTNLeatherUpgradeThree.blp"
        constant string CIItemBoard_DefDmgIcon  = "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp"
        constant string CIItemBoard_DefSrIcon   = "ReplaceableTextures\\CommandButtons\\BTNGem.blp"
        constant string CIItemBoard_DefLrIcon   = "ReplaceableTextures\\CommandButtons\\BTNReplenishHealth.blp"
        constant string CIItemBoard_DefMrIcon   = "ReplaceableTextures\\CommandButtons\\BTNReplenishMana.blp"
        constant string CIItemBoard_DefStrIcon  = "ReplaceableTextures\\CommandButtons\\BTNBelt.blp"
        constant string CIItemBoard_DefAgyIcon  = "ReplaceableTextures\\CommandButtons\\BTNBoots.blp"
        constant string CIItemBoard_DefIntIcon  = "ReplaceableTextures\\CommandButtons\\BTNRobeOfTheMagi.blp"
        constant string CIItemBoard_DefAsIcon   = "ReplaceableTextures\\CommandButtons\\BTNGauntletsOfOgrePower.blp"
        constant string CIItemBoard_DefMsIcon   = "ReplaceableTextures\\CommandButtons\\BTNBootsOfSpeed.blp"
        constant string CIItemBoard_DefHpIcon   = "ReplaceableTextures\\CommandButtons\\BTNPeriapt.blp"
        constant string CIItemBoard_DefMpIcon   = "ReplaceableTextures\\CommandButtons\\BTNPeriapt1.blp"
        CustomItem CIItemBoard_Dummy = 0
    endglobals
    
    private function init takes nothing returns nothing
        set CIItemBoard_Dummy = CustomItem.new(null)
        set CIItemBoard_Dummy.icon = "ReplaceableTextures\\CommandButtons\\BTNSelectHeroOn.blp"
        set CIItemBoard_Dummy.name = "No item"
        set CIItemBoard_Dummy.desc = "There is no item in this slot."
        call CIItemBoard_Dummy.clear()
    endfunction
    
    module CIItemBoard
        private Board itemBoard = 0
        
        private method renewTitle takes nothing returns nothing
            local BoardItem bi = 0
            
            set .itemBoard.title = "CustomInventory [View Item]"
            set .itemBoard.titleColor = 0xFFFFFF
            set .itemBoard.visible = false
            
            set bi = .itemBoard[0][0]
            set bi.icon = ""
            set bi.width = 0.02
            call bi.setDisplay(false, true)
            
            set bi = .itemBoard[1][0]
            set bi.text = ""
            set bi.width = 0.13
            call bi.setDisplay(true, false)
            
            set bi = .itemBoard[0][1]
            set bi.width = 0.15
            call bi.setDisplay(false, false)
            
            set bi = .itemBoard[0][3]
            set bi.width = 0.15
            call bi.setDisplay(true, false)
            
            set bi = .itemBoard[0][5]
            set bi.text = "Attributes"
            set bi.width = 0.13
            call bi.setDisplay(true, false)
        endmethod
        
        public method initBoard takes nothing returns nothing
            local boolean showText = false
            local boolean showIcon = false
            
            set .itemBoard = Board.create()
            call .renewTitle()
        endmethod
        
        public method updateBoard takes CustomItem ciObj returns nothing
            local BoardItem bi = 0
            local integer i = 0
            local boolean display = false
            local integer value = 0
            local integer x = 0
            local integer y = 0
            local string text = ""
            local string icon = ""
            local string valStr = ""
            local integer field = 0
            local integer rows = 4
            local boolean array hasValue
            
            call .itemBoard.clear()
            call .renewTitle()
            
            if ciObj == 0 then
                set ciObj = CIItemBoard_Dummy
            endif
            
            call .minimizeBoard(true)
            set .itemBoard.row.count = rows
            
            set bi = .itemBoard[0][0]
            set bi.icon = ciObj.icon
            set bi = .itemBoard[1][0]
            set bi.text = ciObj.name
            set bi = .itemBoard[0][3]
            set bi.text = ciObj.desc
            
            static if LIBRARY_CIBonus then
                // Create the status items
                set i = 0
                set x = 0
                set y = 5
                loop
                    exitwhen i >= 12
                    
                    if i == 0 then
                        set value = ciObj.amr
                        set text = "Armor"
                        set icon = CIItemBoard_DefAmrIcon
                    elseif i == 1 then
                        set value = ciObj.dmg
                        set text = "Dmg"
                        set icon = CIItemBoard_DefDmgIcon
                    elseif i == 2 then
                        set value = ciObj.lr
                        set text = "Lifereg"
                        set icon = CIItemBoard_DefLrIcon
                    elseif i == 3 then
                        set value = ciObj.mr
                        set text = "Manareg"
                        set icon = CIItemBoard_DefMrIcon
                    elseif i == 4 then
                        set value = ciObj.str
                        set text = "Str"
                        set icon = CIItemBoard_DefStrIcon
                    elseif i == 5 then
                        set value = ciObj.agy
                        set text = "Agy"
                        set icon = CIItemBoard_DefAgyIcon
                    elseif i == 6 then
                        set value = ciObj.int
                        set text = "Int"
                        set icon = CIItemBoard_DefIntIcon
                    elseif i == 7 then
                        set value = ciObj.as
                        set text = "Att.spd"
                        set icon = CIItemBoard_DefAsIcon
                    elseif i == 8 then
                        set value = ciObj.ms
                        set text = "Movespd"
                        set icon = CIItemBoard_DefMsIcon
                    elseif i == 9 then
                        set value = ciObj.hp
                        set text = "Hitpts"
                        set icon = CIItemBoard_DefHpIcon
                    elseif i == 10 then
                        set value = ciObj.mp
                        set text = "Manapts"
                        set icon = CIItemBoard_DefMpIcon
                    elseif i == 11 then
                        set value = ciObj.sr
                        set text = "Sight"
                        set icon = CIItemBoard_DefSrIcon
                    endif
                    set valStr = I2S(value)
                    
                    if i == 3 or i == 7 or i == 8 then
                        set valStr = valStr + "%"
                    endif
                    
                    set display = value != 0
                    set hasValue[i] = display
                    
                    if display then
                        if field == 6 then
                            set y = 5
                            set x = 4
                        endif
                        set y = y +1
                        
                        set bi = .itemBoard[x][y]
                        set bi.width = .05
                        set bi.icon = icon
                        set bi.text = text +":"
                        call bi.setDisplay(true, true)
                        
                        // Create the textitem
                        set bi = .itemBoard[x +1][y]
                        set bi.width = 0.02
                        set bi.text = valStr
                        if value > 0 then
                            set bi.color = 0xFFFFFF
                        else
                            set bi.color = 0xFF0000
                        endif
                        call bi.setDisplay(true, false)
                        
                        // Create a space
                        if field < 6 then
                            if field == 0 then
                                set rows = rows +1
                            endif
                            set bi = .itemBoard[x +2][y]
                            set bi.width = 0.01
                            call bi.setDisplay(false, false)
                            
                            set rows = rows +1
                        endif
                        
                        set field = field +1
                    endif
                    
                    set i = i +1
                endloop
                
                set i = field
                loop
                    exitwhen i >= 12
                    
                    if i < 6 then
                        set x = 0
                        set y = 6 + i
                    else
                        set x = 4
                        set y = 6 + (i -5)
                    endif
                    
                    //call BJDebugMsg("Cleaning [" + I2S(x) + "/" + I2S(y) + "]")
                    set bi = .itemBoard[x][y]
                    set bi.width = .0
                    call bi.setDisplay(false, false)
                    
                    //call BJDebugMsg("Cleaning [" + I2S(x +1) + "/" + I2S(y) + "]")
                    set bi = .itemBoard[x +1][y]
                    set bi.width = .0
                    call bi.setDisplay(false, false)
                    
                    if i < 6 then
                        //call BJDebugMsg("Cleaning [" + I2S(x +2) + "/" + I2S(y) + "]")
                        set bi = .itemBoard[x +2][y]
                        set bi.width = .0
                        call bi.setDisplay(false, false)
                    endif
                    
                    set i = i +1
                endloop
            endif
            
            set bi = .itemBoard[0][5]
            if field > 0 then
                set bi.text = "Attributes"
            else
                set bi.text = ""
            endif
            
            set .itemBoard.row.count = rows
            call .minimizeBoard(false)
            
            set icon = null
            set text = null
            set valStr = null
        endmethod
        
        public method showBoard takes boolean bol returns nothing
            set .itemBoard.visible[GetOwningPlayer(.getOwner())] = bol
        endmethod
        
        public method minimizeBoard takes boolean bol returns nothing
            set .itemBoard.minimized[GetOwningPlayer(.getOwner())] = bol
        endmethod
    endmodule

endlibrary

When I use the updateBoard() stuff, it somehow manages to not show attributes at some time, sometimes it will show. Also, sometimes there are empty spaces and such.

Can anyone explain whats wrong?

This is what I want to have:
[X] = Column
[Y] = Row

[0][0] = Icon of item (Works)
[1][0] = Name of item (Works)
[0][1] = Space ford escription (Works)
[0][2] = 2nd space for description (Works)
[0][3] = Description (Works)
[0][4] = 3rd space for description (Works)

[OPTIONAL]
[0][5] (If item has attribute) = Attributes (Is sometimes displayed)
[0][X (6 -11)] = Attribute Icon
[1][X (6 -11)] = Attribute Name
[2][X (6 -11)] = Attribute Value
[3][X (6 -11)] = Space

(continues on another row after the space)
[4][X (6 -11)] = Attribute Icon
[5][X (6 -11)] = Attribute Name
[6][X (6 -11)] = Attribute Value

This is a picture of what it can look like:
(This version was without description. Just ignore that missing 3 lines)
(Also ignore the not space col I had there...)
Click image for larger version

Name:	CW_CI6.png
Views:	24
Size:	7.5 KB
ID:	47579

And this is how it sometimes looks, (as it should),
Click image for larger version

Name:	CW_CI8.png
Views:	51
Size:	1.22 MB
ID:	47580
but most of the times it just got screwed up.
Attached Images
File type: pngCW_CI6.png (7.5 KB)
File type: pngCW_CI8.png (1.2 MB)
01-21-2010, 09:02 AM#2
Ammorth
If you are changing the number of rows/colums, you can run into problems (unless blizzard has fixed this since I checked last).

Re-sizing a multiboard can lead to errors in the the board. I posted about it somewhere, but I can't remember...

here we go: http://www.wc3c.net/showpost.php?p=980304&postcount=30
01-21-2010, 09:07 AM#3
Anachron
Damn blizzard.

Collapse JASS:
call .itemBoard.clear()
This doesn't work either, I am already using it.

Any suggestions?
Should I just instead create a new multiboard?

Collapse JASS:
call .itemBoard.destroy()
set .itemBoard = Board.create()
01-23-2010, 10:01 PM#4
Ammorth
Quote:
Originally Posted by Anachron
Any suggestions?
Should I just instead create a new multiboard?

Collapse JASS:
call .itemBoard.destroy()
set .itemBoard = Board.create()

If lots of the fields on the multiboards are similar (formatting is always the same, but the data is slightly different), you could look at setting up an array to store boards of varrying sizes into. That way, you don't have to re-create the entire board from scratch, if you already have one.

Otherwise, destroying is your best bet.
01-24-2010, 11:15 AM#5
Veev
Have you tried hiding and THEN showing the multiboard immediately? Every time (basically) this will apply the correct sizing/elements to the multiboard... Kinda a dumb issue, but this has fixed it before (for me). I've had this same problem before, where the multiboard should be correct but isn't (and hiding/showing) fixes the problem.

Alternatively, you can create the board, hide it, do all your creations (with size/icons/text/etc) and then show it once all those actions are done. This'll probably be "better"...
01-25-2010, 08:07 AM#6
Anachron
I am destroying it now every time, and it works.
It doesn't work with hiding/mimizing/cleaning at all. Its just a bugged handletype.
04-30-2010, 10:12 AM#7
TheKid
I know this is a really old thread, but I was having some troubles recently with a multiboard and when I did a search this is one of the first entries found.

Quote:
Originally Posted by Ammorth
If you are changing the number of rows/colums, you can run into problems (unless blizzard has fixed this since I checked last).

Its not only the number of rows/columns that seem to screw multiboards up; if you try to manipulate individual row item-widths everything about them seems to fail miserably, including item styles (pretty similar diagnosis to what Ammorth was talking about).

I don't know how often people try to do this, but at least now there's something about it in the Search section :smiley: