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.
 
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.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top