System MBS - Multiboard System

Joker(Div)

Always Here..
Reaction score
86
JASS:
//==============================================================================
//  MBS -- Multiboard System by Joker(Div) -- v1.0
//==============================================================================
//
//  PURPOSE:
//       * Easy Multiboard Editing/Creating
//
//  HOW TO USE:
//       * Create a global Multiboard (the struct)
//       * Call the .create and start editing
//
//  FUNCTIONS:
//
//      .create takes integer MaxColumn, integer MaxRow returns Multiboard (the struct )
//
//      -----  Functions for Entire Board -----
//      .setTitle       takes string Title
//      .setColCount    takes integer NewMaxColumns returns nothing
//      .setRowCount    takes integer NewMaxRows returns nothing
//      .setStyle       takes boolean ShowText, boolean ShowIcon returns nothing
//      .show           takes nothing returns nothing
//      .hide           takes nothing returns nothing
//      .minimize       takes nothing returns nothing
//      .maximize       takes nothing returns nothing
//      .setColCount    takes integer NewMaxColumns returns nothing
//
//      -----  Functions for Specific Items -----
//      .setItemText    takes integer column, integer row, string text returns nothing
//      .setItemColor   takes integer column, integer row, integer red, integer blue, integer green, integer alpha returns nothing
//      .setItemStyle   takes integer column, integer row, boolean ShowText, boolean ShowIcon returns nothing
//
//      -----  Functions for Entire Row -----
//      .setRowText     takes integer row, string text returns nothing
//      .setRowColor    takes integer row, integer red, integer blue, integer green, integer alpha returns nothing
//      .setRowStyle    takes integer row, boolean ShowText, boolean ShowIcon returns nothing
//
//      -----  Functions for Entire Col -----
//      .setColText     takes integer column, string text returns nothing
//      .setColColor    takes integer column, integer red, integer blue, integer green, integer alpha returns nothing
//      .setColStyle    takes integer column, boolean ShowText, boolean ShowIcon returns nothing
//      .setColWidth    takes integer column, real widthPercent returns nothing
//
//      -----  Functions for Specific Players -----
//      .showForPlayer      takes player p returns nothing
//      .hideForPlayer      takes player p returns nothing
//      .minimizeForPlayer  takes player p returns nothing
//      .maximizeForPlayer  takes player p returns nothing
//
//  PROS: 
//       * Easy editing
//       * Simple
//
//  CONS:
//       * ???
//
//  DETAILS:
//       * Really its mostly wrappers for eye-candy. Some helpful functions too I suppose...
//
//  THANKS TO:
//      * Cohadar - Who I stole this info template from
//
//  HOW TO IMPORT:
//       * Just create a trigger named MBS
//       * convert it to text and replace the whole trigger text with this one
//
//==============================================================================
library MBS

    struct Multiboard
        //  I'm not really sure why I decided to use a 
        //  module. I thought I would need one when I 
        //  started, but I guess not...
        //  Looks prettier at least.
        implement MultiboardFunctions
        
        static method create takes integer colCount, integer rowCount returns thistype
            local thistype dat = thistype.allocate()
            
              set dat.board = CreateMultiboard()
                call dat.setColCount( colCount )
                call dat.setRowCount( rowCount )
                
            return dat
        endmethod
    endstruct
    
    //Wrappers and such...
    module MultiboardFunctions
        multiboard board
        private static multiboarditem mbi  //only need 1
        
        //===  --The "get" functions-- ===//
        //  If really needed, I could add some, but I 
        //  honestly don't see a need to.
        
        //===  --Functions for entire board-- ===//
        method setTitle takes string title returns nothing
            call MultiboardSetTitleText( this.board, title )
        endmethod
        
        method setColCount takes integer colCount returns nothing
            call MultiboardSetColumnCount( this.board, colCount )
        endmethod
        
        method setRowCount takes integer rowCount returns nothing
            call MultiboardSetRowCount( this.board, rowCount )
        endmethod
        
        method setStyle takes boolean showText, boolean showIcon returns nothing
            call MultiboardSetItemsStyle( this.board, showText, showIcon )
        endmethod
        
        method show takes nothing returns nothing
            call MultiboardDisplay( this.board, true )
        endmethod
        
        method hide takes nothing returns nothing
            call MultiboardDisplay( this.board, false )
        endmethod
        
        method minimize takes nothing returns nothing
            call MultiboardMinimize( this.board, true )
        endmethod
        
        method maximize takes nothing returns nothing
            call MultiboardMinimize( this.board, false )
        endmethod
        
        //===  --Functions for specific items-- ===//
        method setItemText takes integer whatCol, integer whatRow, string text returns nothing
            set .mbi = MultiboardGetItem( this.board, whatRow - 1, whatCol - 1 ) 
            call MultiboardSetItemValue( .mbi, text )
            call MultiboardReleaseItem( .mbi )
        endmethod
        
        method setItemColor takes integer whatCol, integer whatRow, integer red, integer blue, integer green, integer alpha returns nothing
            //I left this to the default 255, same as object editor coloring
            set .mbi = MultiboardGetItem( this.board, whatRow - 1, whatCol - 1 )
            call MultiboardSetItemValueColor( .mbi, red, green, blue, alpha )
            call MultiboardReleaseItem( .mbi )
        endmethod
        
        method setItemStyle takes integer whatCol, integer whatRow, boolean showText, boolean showIcon returns nothing
            set .mbi = MultiboardGetItem( this.board, whatRow - 1, whatCol - 1 ) 
            call MultiboardSetItemStyle( .mbi, showText, showIcon )
            call MultiboardReleaseItem( .mbi )
        endmethod
        
        //===  --Functions for entire row/column-- ===//
        method setRowText takes integer whatRow, string text returns nothing
            local integer loopCol = 0
            
            loop
                set .mbi = MultiboardGetItem( this.board, whatRow - 1, loopCol )
                call MultiboardSetItemValue( .mbi, text )
                call MultiboardReleaseItem( .mbi )
                set loopCol = loopCol + 1
                exitwhen loopCol == MultiboardGetColumnCount( this.board )
            endloop
        endmethod
        
        method setRowColor takes integer whatRow, integer red, integer blue, integer green, integer alpha returns nothing
            local integer loopCol = 0
            
            loop
                set .mbi = MultiboardGetItem( this.board, whatRow - 1, loopCol )
                call MultiboardSetItemValueColor( .mbi, red, green, blue, alpha )
                call MultiboardReleaseItem( .mbi )
                set loopCol = loopCol + 1
                exitwhen loopCol == MultiboardGetColumnCount( this.board )
            endloop
        endmethod
        
        method setRowStyle takes integer whatRow, boolean showText, boolean showIcon returns nothing
            local integer loopCol = 0
            
            loop
                set .mbi = MultiboardGetItem( this.board, whatRow - 1, loopCol )
                call MultiboardSetItemStyle( .mbi, showText, showIcon )
                call MultiboardReleaseItem( .mbi )
                set loopCol = loopCol + 1
                exitwhen loopCol == MultiboardGetColumnCount( this.board )
            endloop
        endmethod
        
        method setColText takes integer whatCol, string text returns nothing
            local integer loopRow = 0
            
            loop
                set .mbi = MultiboardGetItem( this.board, loopRow, whatCol - 1 )
                call MultiboardSetItemValue( .mbi, text )
                call MultiboardReleaseItem( .mbi )
                set loopRow = loopRow + 1
                exitwhen loopRow == MultiboardGetRowCount( this.board )
            endloop
        endmethod
        
        method setColColor takes integer whatCol, integer red, integer blue, integer green, integer alpha returns nothing
            local integer loopRow = 0
            
            loop
                set .mbi = MultiboardGetItem( this.board, loopRow, whatCol - 1 )
                call MultiboardSetItemValueColor( .mbi, red, green, blue, alpha )
                call MultiboardReleaseItem( .mbi )
                set loopRow = loopRow + 1
                exitwhen loopRow == MultiboardGetRowCount( this.board )
            endloop
        endmethod
        
        method setColStyle takes integer whatCol, boolean showText, boolean showIcon returns nothing
            local integer loopRow = 0
            
            loop
                set .mbi = MultiboardGetItem( this.board, loopRow, whatCol - 1 )
                call MultiboardSetItemStyle( .mbi, showText, showIcon )
                call MultiboardReleaseItem( .mbi )
                set loopRow = loopRow + 1
                exitwhen loopRow == MultiboardGetColumnCount( this.board )
            endloop
        endmethod
        
        method setColWidth takes integer whatCol, real widthPercent returns nothing
            local integer loopRow = 0
            
            loop
                set .mbi = MultiboardGetItem( this.board, loopRow, whatCol - 1 )
                call MultiboardSetItemWidth( .mbi, widthPercent * 0.01 )
                call MultiboardReleaseItem( .mbi )
                set loopRow = loopRow + 1
                exitwhen loopRow == MultiboardGetRowCount( this.board )
            endloop
        endmethod
        
        //===  --Functions for specific players-- ===//
        method showForPlayer takes player p returns nothing
            if GetLocalPlayer() == p then
                call MultiboardDisplay( this.board, true )
            endif
        endmethod
        
        method hideForPlayer takes player p returns nothing
            if GetLocalPlayer() == p then
                call MultiboardDisplay( this.board, false )
            endif
        endmethod
        
        method minimizeForPlayer takes player p returns nothing
            if GetLocalPlayer() == p then
                call MultiboardMinimize( this.board, true )
            endif
        endmethod
        
        method maximizeForPlayer takes player p returns nothing
            if GetLocalPlayer() == p then
                call MultiboardDisplay( this.board, false )
            endif
        endmethod
    endmodule

endlibrary


Example:
JASS:
//I know this has some other things, but really its irrelevant to 
//showing MBS
scope BoardSetup initializer onInit

    globals
        constant string GONE        = "|cFF808080 *Empty"
        constant string GONE_NUM    = "|cFF808080---"
    endglobals
    //======================================================
    
    globals
        Multiboard Board
    endglobals

    private function Create takes nothing returns nothing
        local integer i = 0
        
        set Board = Multiboard.create( 3, 10 )
            call Board.setTitle( "Time: 0:00" )
            
            call Board.setColWidth( 1, 9.0 )
            call Board.setColWidth( 2, 3.5)
            call Board.setColWidth( 3, 3.5 )
            
            call Board.setColColor( 2, 100, 80, 142, 255 )
            call Board.setColColor( 3, 210, 160, 120, 255 )
            
            call Board.setItemColor( 1, 2, 100, 250, 200, 255 )
            call Board.setItemColor( 1, 5, 100, 225, 200, 255 )
            call Board.setItemColor( 1, 8, 100, 200, 200, 255 )
            
            call Board.setRowText( 3, " 0" )
            call Board.setRowText( 4, " 0" )
            
            call Board.setItemText( 2, 1, BLIZZ_COLOR + "Count" )
            call Board.setItemText( 3, 1, BLIZZ_COLOR + "Total" )
        
            call Board.setItemText( 1, 2, "Team 1" )
            call Board.setItemText( 1, 5, "Team 2" )
            call Board.setItemText( 1, 8, "Team 3" )
        
            loop
                if Players<i>.isPlaying then
                    call Board.setItemText( 1, Players<i>.rowPosition, &quot; &quot; + GetPlayerNameColored(Player(i)) )
                else
                    call Board.setItemText( 1, Players<i>.rowPosition, GONE )
                    call Board.setItemText( 2, Players<i>.rowPosition, GONE_NUM )
                    call Board.setItemText( 3, Players<i>.rowPosition, GONE_NUM )
                endif
                set i = i + 1
                exitwhen i &gt;= MAX_PLAYERS
            endloop
            
            call Board.setStyle(true, false )
            call Board.minimize()
            call Board.show()
            
            call ReleaseTimer( GetExpiredTimer() )
    endfunction

    private function onInit takes nothing returns nothing
        call TimerStart( NewTimer(), GAME_DELAY, false, function Create )
    endfunction

endscope</i></i></i></i></i>

exampleu.jpg



Edit: Well, I now find that Darfett has beat me by 2 weeks. I had no idea...o well. I'll take it down with popular request.
 

D.V.D

Make a wish
Reaction score
73
In your first list of functions you wrote
JASS:
//      .setColCount    takes integer NewMaxColumns returns nothing
twice.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top