System Multiboard

Nestharus

o-o
Reaction score
84
I present a Multiboard wrapper that not only works, but is easy to use as well. Good game.

JASS:

library Multiboard /* v2.0.0.1
*************************************************************************************
*
*   Multiboard Struct API that actually works and is actually easy to use.
*
*************************************************************************************
*
*   */uses/*
*
*       */ Table /*         hiveworkshop.com/forums/jass-functions-413/snippet-new-table-188084/
*
************************************************************************************
*
*   struct Multiboard
*
*       string title
*       boolean display
*       boolean minimize
*       boolean suppress
*
*       real width=  (set only)
*       string icon= (set only)
*       string text= (set only)
*
*       readonly MultiboardRow row
*       readonly MultiboardColumn column
*
*       this[row][column] -> MultiboardItem
*
*       static method create takes integer rowCount, integer columnCount returns Multiboard
*       method destroy takes nothing returns nothing
*
*       method clear takes nothing returns nothing
*
*       method setTitleColor takes integer red, integer green, integer blue, integer alpha returns nothing
*       method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
*       method setStyle takes boolean showValues, boolean showIcons returns nothing
*
************************************************************************************
*
*   struct MultiboardRow extends array
*   struct MultiboardColumn extends array
*
*       integer count
*           -   row.count
*
*       string text
*       string icon=
*       real width=
*           -   row[0].width
*
*       method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
*       method setStyle takes boolean showValue, boolean showIcon returns nothing
*           -   row[0].setStyle
*
************************************************************************************
*
*   struct MultiboardItem extends array
*
*       string text= (set only)
*       string icon= (set only)
*       real width=  (set only)
*
*       method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
*       method setStyle takes boolean showValue, boolean showIcon returns nothing
*
************************************************************************************/
    globals
        private Table table
        private Table table2
        private integer array r
        private integer ic = 0
        private multiboard array boardp
        private integer array rc
        private integer array cc
        private boolean array suppressed
    endglobals
    
    private module Init
        private static method onInit takes nothing returns nothing
            set table = Table.create()
            set table2 = Table.create()
        endmethod
    endmodule
    
    struct MultiboardItem extends array
        method operator text= takes string value returns nothing
            call MultiboardSetItemValue(table.multiboarditem[this], value)
        endmethod
        method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
            call MultiboardSetItemValueColor(table.multiboarditem[this], red, green, blue, alpha)
        endmethod
        method setStyle takes boolean showValue, boolean showIcon returns nothing
            call MultiboardSetItemStyle(table.multiboarditem[this], showValue, showIcon)
        endmethod
        method operator icon= takes string str returns nothing
            call MultiboardSetItemIcon(table.multiboarditem[this], str)
        endmethod
        method operator width= takes real percent returns nothing
            call MultiboardSetItemWidth(table.multiboarditem[this], percent)
        endmethod
    
        implement Init
    endstruct
    
    //! textmacro MULTIBOARD_LOOPER takes ROW, TABLE, CODE
        local multiboarditem mb
        loop
            exitwhen 0 == $ROW$
            set mb = $TABLE$.multiboarditem[this]
            call $CODE$
            set this = this + 1
            set $ROW$ = $ROW$ - 1
        endloop
        
        set mb = null
    //! endtextmacro
    
    private keyword Multiboard2D
    private keyword getItems
    private keyword clearItems
    struct Multiboard extends array
        method getItems takes nothing returns nothing
            local integer row = rc[this]
            local integer column
            local multiboarditem mb
            loop
                set column = cc[this]
                loop
                    set mb = MultiboardGetItem(boardp[this], row, column)
                    set table.multiboarditem[(this*500+row)*500+column] = mb
                    set table2.multiboarditem[(this*500+column)*500+row] = mb
                    exitwhen 0 == column
                    set column = column - 1
                endloop
                exitwhen 0 == row
                set row = row - 1
            endloop
            set mb = null
        endmethod
        method clearItems takes nothing returns nothing
            local integer row = rc[this]
            local integer column
            loop
                set column = cc[this]
                loop
                    call MultiboardReleaseItem(table.multiboarditem[(this*500+row)*500+column])
                    call table.handle.remove((this*500+row)*500+column)
                    call table2.handle.remove((this*500+column)*500+row)
                    exitwhen 0 == column
                    set column = column - 1
                endloop
                exitwhen 0 == row
                set row = row - 1
            endloop
        endmethod
        
        static method create takes integer rowCount, integer columnCount returns thistype
            local thistype this = r[0]
            
            if (0 == this) then
                set this = ic + 1
                set ic = this
            else
                set suppressed[this] = false
                set r[0] = r[this]
            endif
            
            set boardp[this] = CreateMultiboard()
            call MultiboardSetColumnCount(boardp[this], columnCount)
            call MultiboardSetRowCount(boardp[this], rowCount)
            
            set rc[this] = rowCount
            set cc[this] = columnCount
            
            call getItems()
            
            return this
        endmethod
        
        method destroy takes nothing returns nothing
            set r[this] = r[0]
            set r[0] = this
            
            call clearItems()
            
            call DestroyMultiboard(boardp[this])
            set boardp[this] = null
        endmethod
        
        method clear takes nothing returns nothing
            call MultiboardClear(boardp[this])
        endmethod
        
        method operator display takes nothing returns boolean
            return IsMultiboardDisplayed(boardp[this])
        endmethod
        method operator display= takes boolean b returns nothing
            call MultiboardDisplay(boardp[this], b)
        endmethod
        method operator minimize takes nothing returns boolean
            return IsMultiboardMinimized(boardp[this])
        endmethod
        method operator minimize= takes boolean b returns nothing
            call MultiboardMinimize(boardp[this], b)
        endmethod
        method operator title takes nothing returns string
            return MultiboardGetTitleText(boardp[this])
        endmethod
        method operator title= takes string txt returns nothing
            call MultiboardSetTitleText(boardp[this], txt)
        endmethod
        method setTitleColor takes integer red, integer green, integer blue, integer alpha returns nothing
            call MultiboardSetTitleTextColor(boardp[this], red, green, blue, alpha)
        endmethod
        method operator suppress takes nothing returns boolean
            return suppressed[this]
        endmethod
        method operator suppress= takes boolean b returns nothing
            set suppressed[this] = b
            call MultiboardSuppressDisplay(b)
        endmethod
        method operator width= takes real percent returns nothing
            call MultiboardSetItemsWidth(boardp[this], percent)
        endmethod
        method operator row takes nothing returns MultiboardRow
            return this
        endmethod
        method operator column takes nothing returns MultiboardColumn
            return this
        endmethod
        method operator [] takes integer row returns Multiboard2D
            return this*500+row
        endmethod
        method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
            call MultiboardSetItemsValueColor(boardp[this], red, green, blue, alpha)
        endmethod
        method setStyle takes boolean showValues, boolean showIcons returns nothing
            call MultiboardSetItemsStyle(boardp[this], showValues, showIcons)
        endmethod
        method operator icon= takes string txt returns nothing
            call MultiboardSetItemsIcon(boardp[this], txt)
        endmethod
        method operator text= takes string txt returns nothing
            call MultiboardSetItemsValue(boardp[this], txt)
        endmethod
    endstruct
    
    private struct MultiboardSet extends array
        method text takes string v, integer c, Table t returns nothing
            //! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemValue(mb, v)")
        endmethod
        method color takes integer red, integer green, integer blue, integer alpha, integer c, Table t returns nothing
            //! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemValueColor(mb, red, green, blue, alpha)")
        endmethod
        method style takes boolean v, boolean i, integer c, Table t returns nothing
            //! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemStyle(mb, v, i)")
        endmethod
        method icon takes string s, integer c, Table t returns nothing
            //! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemIcon(mb, s)")
        endmethod
        method width takes real p, integer c, Table t returns nothing
            //! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemWidth(mb, p)")
        endmethod
    endstruct
    struct MultiboardColumn extends array
        method operator count takes nothing returns integer
            return MultiboardGetColumnCount(boardp[this])
        endmethod
        method operator count= takes integer columns returns nothing
            call Multiboard(this).clearItems()
            call MultiboardSetColumnCount(boardp[this], columns)
            set cc[this] = columns
            call Multiboard(this).getItems()
        endmethod
        method operator text= takes string value returns nothing
            call MultiboardSet(this).text(value, rc[this/250000], table2)
        endmethod
        method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
            call MultiboardSet(this).color(red, green, blue, alpha, rc[this/250000], table2)
        endmethod
        method setStyle takes boolean showValue, boolean showIcon returns nothing
            call MultiboardSet(this).style(showValue, showIcon, rc[this/250000], table2)
        endmethod
        method operator icon= takes string str returns nothing
            call MultiboardSet(this).icon(str, rc[this/250000], table2)
        endmethod
        method operator width= takes real percent returns nothing
            call MultiboardSet(this).width(percent, rc[this/250000], table2)
        endmethod
        method operator [] takes integer column returns thistype
            return (this*500+column)*500
        endmethod
    endstruct
    struct MultiboardRow extends array
        method operator count takes nothing returns integer
            return MultiboardGetRowCount(boardp[this])
        endmethod
        method operator count= takes integer rows returns nothing
            call Multiboard(this).clearItems()
            call MultiboardSetRowCount(boardp[this], rows)
            set rc[this] = rows
            call Multiboard(this).getItems()
        endmethod
        method operator text= takes string value returns nothing
            call MultiboardSet(this).text(value, cc[this/250000], table)
        endmethod
        method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
            call MultiboardSet(this).color(red, green, blue, alpha, cc[this/250000], table)
        endmethod
        method setStyle takes boolean showValue, boolean showIcon returns nothing
            call MultiboardSet(this).style(showValue, showIcon, cc[this/250000], table)
        endmethod
        method operator icon= takes string str returns nothing
            call MultiboardSet(this).icon(str, cc[this/250000], table)
        endmethod
        method operator width= takes real percent returns nothing
            call MultiboardSet(this).width(percent,cc[this/250000], table)
        endmethod
        method operator [] takes integer row returns thistype
            return (this*500+row)*500
        endmethod
    endstruct
    private struct Multiboard2D extends array
        method operator [] takes integer column returns MultiboardItem
            return this*500+column
        endmethod
    endstruct
endlibrary


Example
JASS:

struct Tester extends array
    private static method init takes nothing returns nothing
        local Multiboard board = Multiboard.create(2,2)
        
        call board.setStyle(true, false)
        
        set board[0][0].text = "00"
        set board[0][1].text = "01"
        set board[1][0].text = "10"
        set board[1][1].text = "11"
        
        set board.display = true
        
        set board.row.count = 3
        set board[2][0].text = "20"
        set board[2][1].text = "21"
        
        set board.row.count = 2
        set board.row.count = 3
        
        call DestroyTimer(GetExpiredTimer())
    endmethod
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(),0,false,function thistype.init)
    endmethod
endstruct


JASS:

struct Tester extends array
    private static method init takes nothing returns nothing
        local Multiboard board = Multiboard.create(19,4)
        
        call board.setStyle(true, false)
        
        set board.row[0].text = "row 1"
        set board.column[0].text = "column 1"
        set board[0][0].text = "X"
        
        set board.column[0].width = .15
        set board.column[1].width = .05
        set board.column[2].width = .05
        
        set board.display = true
        
        call DestroyTimer(GetExpiredTimer())
    endmethod
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(),0,false,function thistype.init)
    endmethod
endstruct
 
I've been "thinking" of a multiboard script that isn't just a wrapper./syntactic sugar for the native (this, Board, others.). One that allows for dynamic rows and columns adding and removing. One use of such a script would be to "reverse engineer" the Starcraft 2's Production tab. It displays each player's units, buildings and upgrades currently being produced. You can look it in this video for a reference what I am writing about. Of course it would be a replay only feature. One small and easy feature of a multiboard wrapper script could be to set the width of it in the create function/method, it's quite easy to do =). Width of 0.5 could mean that the left border of the multiboard should go exactly under the day/night planet thingy of the UI. And 1.0 width would mean, that the multiboard should take all the screen.

Well of course "thinking" != actually doing it so, yeah... It would probably be left as one of those ideas that "don't get anywhere".

OT: Also I really think wc3 melee gameplay could borrow some things from Starcraft 2, for example if a building is cancelled a text tag could be shown for indication of all players.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    Do you think the people that answer the phone for that company have any idea about that? Because they do not, nor can they tell me where they get that xanthum gum usually so I can't ask the people that make it, nor do they particularly care if I'm the one risking people's lives and not them.
  • Varine Varine:
    So that was my week building up to today, because that is when I got the menu and had to guess at the actual recipes for two of those days, because again I think he threw this into AI and ran with a lot of it
  • Varine Varine:
    I should have had all of this like a month ago but whatever, it's fine. He's trying a thing, idk it's his menu I don
  • Varine Varine:
    I don't care.
  • Varine Varine:
    Fuck I need more saturday nights off. Turns out I'm much cooler to drunk girls. If I hang out with enough people like that, eventually I'll meet one that likes me sober too
  • Varine Varine:
    idk if anyone has ever done IT. I am not IT but I just got off a 20 minute phone call with the general manager asking me how to make her new computer print. I do adore her, like I know her personally, but I asked three times if the printer was on. She apologized for bothering me, and Chef Ben walked in a few minutes later, turned the printer on apparently, and then called to ask if I was trying to print shit from my house again
  • Varine Varine:
    So I have a newfound appreciation
  • Varine Varine:
    And also I'm going to remove that one from my secondary career options
  • Varine Varine:
    As I get older I'm not thinking I can do this forever anymore, and I'm kind of dead end right now. I get a fine salary and fair raises, like I can easily live my lifestyle on this normally, but I don't know if I can do this in ten years, and I don't think I want to. I don't really have any desire to take over another restaurant, and I don't want to try and own one, and I doubt I'll luck out like I did with that taco place in Texas
  • Varine Varine:
    I have a math degree but that was a while ago and I'm not positive I actually deserved that. It was kind of just given to me I feel like cuz I was in school so long. Like for a bit as a teenager I got real into the mormon thing, and my dad grew up kind of similarly. Much like he fell out of it
  • Varine Varine:
    Anyway he started coming to church with me for a bit, and they gave home the I think Melchizedek? idk how to spell it, but it's the 'upper' priesthood, like he had a whole blessing thing after I got baptized, and it WAS a very neat experience. And the only reason I think they did they did that was cuz he was like late 30s, and that is kind of the age that they have the last chance at that
  • Varine Varine:
    And I mean its not, but like... I'm pretty well set in my lack of religious beliefs, I guess. And I'm a bit younger than my dad would have been then.
  • Varine Varine:
    And then I got real into, he got bored and was like you do you dude, and that's how I got a huge amount of freedom when I started doing drugs as a teenager
  • Varine Varine:
    In hindsight my parents were fantastic. but they were too fucking tired to raise kids like me. And their jobs were easier with better benefits.
  • Varine Varine:
    Anyway idk where I'm going here, but I asked ChatGPT some of the same things and holy shit was it way more strict and just gave me (importantly the wrong) phone number to a hotline
  • Varine Varine:
    TH, I gotta say, though, I'm amazed you keep this up. I feel like there are you and Ghan doing whatever you're doing, Tom posting news, and then me using the chatbox as a journal every once in a while.
  • Varine Varine:
    Thanks for letting me do that, also. I know I'm not using it correctly, but somewhere along the line I went from arguing with Cheshire to using this as a kind of void for my frustrations and hopes. I like to think of the whole thing as an enigma of sorts
  • Varine Varine:
    It's not, you guys could probably blackmail me if you went back far enough. I doubt anyone would, you've always been very kind, and I'm glad to have been a part of all this! I hope you enjoy me too, cuz I'm going to keep doing it.
  • Varine Varine:
    In my defense I was high for a lot of that though
  • V-SNES V-SNES:
    Thanks for sharing @Varine
  • The Helper The Helper:
    Brother how long we been here together? You guys are some of my best friends and I have never even met any of you. I dont know what I would if I did not have my Varine rant to look at when I get on. How could I possibly ever shut this site down? We have been here in this little chat box through a lot of shit for a long time. I love you guys!
  • tom_mai78101 tom_mai78101:
    I missed out on a lot of chat messages. But yeah, we're planning for my mom's funeral back in Taiwan. I'm really glad I work remotely, so I can try to leverage that and go to places outside of US while still working in US.
  • tom_mai78101 tom_mai78101:
    If it wasn't for my mom, I wouldn't be able to work in the US. Let alone being able to work until our office closed, and I became a full-time remote employee.
  • tom_mai78101 tom_mai78101:
    Really important though, get your wills and last testaments ready. We avoided like 2 to 3 months of waiting for probate court to get back to us.
    +1
  • The Helper The Helper:
    V-SNES I got good news I got your stuff packed for shipping and just need to get to the post office to get shipping cost!

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top