• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

UIBoard

Level 19
Joined
Mar 18, 2012
Messages
1,716

UIBoard


For your multiboard needs in custom UIs.


JASS:
library UIBoard/*v1.0
*************************************************************************************
*
*   For your multiboard needs in custom UIs.
*   
*   UIBoard uses player id based instances and offers
*   wrappers around the "multiboarditem" handle to prevent them from leaking.
*   UIBoards are associated to UIScreens and automatically destroyed when you close them.
*
*************************************************************************************
*
*   */ uses /*
*  
*       */ UIBasic /*
*
**************************************************************************************
*/
    
    struct UIBoard extends array
        
        //*  Readonly member:
        //*  ================
        readonly multiboard board
        
        //*  UIBoard API:
        //*  ============
        method release takes nothing returns nothing
            if (board != null) then
                call DestroyMultiboard(board)
                set board = null
            endif
        endmethod
        
        //*  Visible for only one player.
        method new takes integer rows, integer columns returns thistype
            call release()
            set board = CreateMultiboard()
            call MultiboardSetColumnCount(board, columns)
            call MultiboardSetRowCount(board, rows)
            call MultiboardDisplay(board, GetLocalClient() == Player(this))
            call MultiboardMinimize(board, false)
            call MultiboardSetItemsStyle(board, true, false)
            return this
        endmethod
        
        //*  Wrapper around multiboarditems:
        //*  ===============================
        method setRowWidth takes integer row, real width returns nothing
            local integer        index   = 0
            local integer        columns = MultiboardGetColumnCount(board)
            local multiboarditem i       = null
            loop
                exitwhen (index > columns) or (columns == 0)
                set i = MultiboardGetItem(board, row, columns)
                call MultiboardSetItemWidth(i, width)
                call MultiboardReleaseItem(i)
                set index = index + 1
            endloop
            set i = null
        endmethod
        
        method setColumnWidth takes integer column, real width returns nothing
            local integer        index = 0
            local integer        rows  = MultiboardGetRowCount(board)
            local multiboarditem i     = null
            loop
                exitwhen (index > rows) or (rows == 0)
                set i = MultiboardGetItem(board, index, column)
                call MultiboardSetItemWidth(i, width)
                call MultiboardReleaseItem(i)
                set index = index + 1
            endloop
            set i = null
        endmethod
        
        method setText takes integer row, integer column, string str returns nothing
            local multiboarditem i = MultiboardGetItem(board, row, column) 
            call MultiboardSetItemValue(i, str)
            call MultiboardReleaseItem(i)
            set i = null
        endmethod

        method setIcon takes integer row, integer column, string str returns nothing
            local multiboarditem i = MultiboardGetItem(board, row, column)
            call MultiboardSetItemIcon(i, str)
            call MultiboardReleaseItem(i)
            set i = null
        endmethod
        
        method setColor takes integer row, integer column, integer red, integer green, integer blue, integer alpha returns nothing
            local multiboarditem i = MultiboardGetItem(board, row, column)
            call MultiboardSetItemValueColor(i, red, green, blue, alpha)
            call MultiboardReleaseItem(i)
            set i = null
        endmethod
        
        method setStyle takes integer row, integer column, boolean showValue, boolean showIcon returns nothing
            local multiboarditem i = MultiboardGetItem(board, row, column)
            call MultiboardSetItemStyle(i, showValue, showIcon)
            call MultiboardReleaseItem(i)
            set i = null
        endmethod

        method setWidth takes integer row, integer column, real width returns nothing
            local multiboarditem i = MultiboardGetItem(board, row, column)
            call MultiboardSetItemWidth(i, width)
            call MultiboardReleaseItem(i)
            set i = null
        endmethod

    endstruct

endlibrary
Last edited:
Top