BoardEx v1.5

This bundle is marked as approved. It works and satisfies the submission rules.
BoardEx: v1.5
Actually this is a Multiboard System and the Ex means extra system which is the ColoredText, these systems are very
simple and GUI'ers can use this with ease.

Please read carefully the instructions on how to use this.

JASS:
/*
=====BoardEx v1.5
=====Made by: Mckill2009

This is just a Multiboard System, simple to use even for GUIer's

INSTALLATION:
- Copy and Paste the "BoardEx" trigger to your map.
- Read the instructions. DONE!

API:
    static method create takes integer rowQty, integer columnQty, boolean showtexts, boolean showicons returns thistype
    method setTitle takes string s returns nothing
    method setAllWidth takes real width returns nothing 
    method setIndividualWidths takes integer row, integer column, real width returns nothing 
    method showValues takes integer row, integer column, boolean showtext, boolean showicon returns nothing 
    method display takes boolean minimize, boolean show returns nothing
    method setIcon takes integer row, integer column, string iconpath returns nothing
    method setText takes integer row, integer column, string text returns nothing
    method destroy takes nothing returns nothing
*/

library BoardEx

struct BoardEx extends array
    private multiboard MB
    private static constant integer boardLimit = 8191
    private static multiboarditem boardItem = null
    private static thistype countBoard = 0  
    
    //===This is the first thing you need to do, setting up the multiboard
    //===Take note that this allocates a new index
    static method create takes integer rowQty, integer columnQty, boolean showtexts, boolean showicons returns thistype
        local thistype this
        if countBoard==boardLimit then
            debug call BJDebugMsg("boardSetUp ERROR: Maximum exceeded: "+I2S(boardLimit))
        else
            set countBoard = countBoard + 1
            set this = countBoard
            set .MB = CreateMultiboard()
            call .display(false,true)
            call MultiboardSetColumnCount(.MB, columnQty)
            call MultiboardSetRowCount(.MB, rowQty)
            call MultiboardSetItemsStyle(.MB, showtexts, showicons)
        endif
        return this
    endmethod

    method setTitle takes string s returns nothing
        call MultiboardSetTitleText(.MB, s)
    endmethod

    //===Sets all width of the multiboard in uniform order, real value should be 0.1 or less
    method setAllWidth takes real width returns nothing 
        call MultiboardSetItemsWidth(.MB, width)
    endmethod

    //===Sets individual widths, real value should be 0.1 or less
    method setIndividualWidths takes integer row, integer column, real width returns nothing 
        set boardItem = MultiboardGetItem(.MB, row, column)
        call MultiboardSetItemWidth(boardItem, width)
        call MultiboardReleaseItem(boardItem)
    endmethod

    //===Show/Hide values such as text or icons
    method showValues takes integer row, integer column, boolean showtext, boolean showicon returns nothing 
        set boardItem = MultiboardGetItem(.MB, row, column)
        call MultiboardSetItemStyle(boardItem, showtext, showicon)
        call MultiboardReleaseItem(boardItem)
    endmethod

    //===Maximize/Minimize, Show/Hide multiboard
    method display takes boolean minimize, boolean show returns nothing
        call MultiboardDisplay(.MB, show)
        call MultiboardMinimize(.MB, minimize)
    endmethod

    //===Change the icon, showicon from the showValues must be true
    method setIcon takes integer row, integer column, string iconpath returns nothing
        set boardItem = MultiboardGetItem(.MB, row, column)
        call MultiboardSetItemIcon(boardItem, iconpath)
        call MultiboardReleaseItem(boardItem)
    endmethod

    //===This is the MAIN multiboard value and text change
    method setText takes integer row, integer column, string text returns nothing
        set boardItem = MultiboardGetItem(.MB, row, column)
        call MultiboardSetItemValue(boardItem, text)
        call MultiboardReleaseItem(boardItem)
    endmethod
    
    //===destroys the 'this' (indexed) multiboard
    method destroy takes nothing returns nothing
        call MultiboardClear(.MB)
        call DestroyMultiboard(.MB)
        set .MB = countBoard.MB
        set countBoard = countBoard - 1
    endmethod
endstruct

endlibrary


JASS:
globals
    //First, create your global board(s)
    BoardEx rem //for now I'm gonna use this instance, but you must use this by:
    //set rem = rem.create(rowQty, columnQty, showtexts, showicons)
    //see the GUI trigger "SetupBoard RemainingUnits GUI" for more info and setup
    //============================
    //You can create more boards up to 8191
    //Im not gonna focus on the created BoardEx below coz
    //this just gives you an example on how to create them
    BoardEx kills
    BoardEx xxx
    BoardEx saved
    BoardEx etc
endglobals

  • SetupBoard RemainingUnits GUI
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Read the map header script instructions before you proceed --------
      • -------- Map header scripts can be found far above this trigger when you can see the BoardEx.w3x --------
      • -------- Let's make an instance of the rem variable --------
      • Custom script: set rem = rem.create(6,2,true,true)
      • -------- The 'rem' is your global reference in accessing the BoardEx multiboards --------
      • -------- So let's set this up --------
      • Custom script: call rem.setTitle("RemainingUnits")
      • Custom script: call rem.setText(0,0,"Player Name")
      • Custom script: call rem.setText(0,1,"Remaining Units")
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set Index = (Index + 1)
          • Custom script: call rem.setText(udg_Index, 0,"Player "+I2S(udg_Index))
          • Custom script: call rem.setText(udg_Index, 1,I2S(udg_Remaining[udg_Index]))
      • -------- resetting the index to zero --------
      • Set Index = 0
      • -------- the rows is 6 so we need to set the loop at 6 --------
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • -------- setting the width for each column, it should ne be greater than 0.1 --------
          • Custom script: call rem.setIndividualWidths(udg_Index,0,0.05)
          • Custom script: call rem.setIndividualWidths(udg_Index,1,0.05)
          • Set Index = (Index + 1)
      • Set Index = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Custom script: call rem.setIcon(udg_Index,0,"ReplaceableTextures\\CommandButtons\\BTNPriestAdept.blp")
          • Custom script: call rem.setIcon(udg_Index,1,"ReplaceableTextures\\CommandButtons\\BTNHumanMissileUpOne.blp")
          • Set Index = (Index + 1)
      • -------- maximizes the multiboard and shows texts --------
      • Custom script: call rem.display(false,true)
UPDATING USING COLORED TEXT:
  • RemainingUnits DEMO GUI
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Index = (Player number of (Triggering player))
      • Set Remaining[Index] = (Remaining[Index] - 1)
      • -------- updating the units remaining, the row and column in multiboard starts with 0 --------
      • Custom script: call rem.setText(udg_Index, 1, ColoredText.ctRandomColor(I2S(udg_Remaining[udg_Index])))




JASS:
/*
===ColoredText v1.0
===Made by Mckill2009

This system colors your text using a hex code or web code, a sample of a web code format
can be seen in your object edidor like the War Stomp ability.
    - Learn War S|cffffcc00t|romp - [|cffffcc00Level %d|r].

The "ffcc00" is a hex code, colored as yellow or yellow orange. There are tons of hex codes
that you can browse on the web like.
    - [url]http://en.wikipedia.org/wiki/Web_colors[/url]

You may color your systems like quests, leaderboard, multiboard, texttag etc...

API:
    static method ctFixedColor takes string fixedHexColor, string text returns string
    static method ctRandomColor takes string text returns string

HOW TO USE:
    local string coloredText = ColoredText.ctFixedColor("00f5ff","I AM TEAL!")
    call BJDebugMsg(coloredText) //this displays the colored text which is teal    
*/

library ColoredText

globals
    private string array sID
endglobals

struct ColoredText extends array

    static method ctFixedColor takes string fixedHexColor, string text returns string
        return "|cff"+ fixedHexColor + text + "|r"
    endmethod
    
    static method ctRandomColor takes string text returns string
        local integer a = GetRandomInt(0,15)
        local integer b = GetRandomInt(0,15)
        local integer c = GetRandomInt(0,15)
        local integer d = GetRandomInt(0,15)
        local integer e = GetRandomInt(0,15)
        local integer f = GetRandomInt(0,15)  
        return "|cff"+sID[a]+sID[b]+sID[c]+sID[d]+sID[e]+sID[f]+text + "|r"
    endmethod
    
    private static method onInit takes nothing returns nothing
        set sID[0] = "0"
        set sID[1] = "1"
        set sID[2] = "2"
        set sID[3] = "3"
        set sID[4] = "4"
        set sID[5] = "5"
        set sID[6] = "6"
        set sID[7] = "7"
        set sID[8] = "8"
        set sID[9] = "9"
        set sID[10] = "a"
        set sID[11] = "b"
        set sID[12] = "c"
        set sID[13] = "d"
        set sID[14] = "e"
        set sID[15] = "f"
    endmethod

endstruct

endlibrary


  • ColoredText DEMO GUI
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Fixed color texts --------
      • Custom script: call BJDebugMsg(ColoredText.ctFixedColor("0000ff","I AM BLUE!"))
      • Custom script: call BJDebugMsg(ColoredText.ctFixedColor("ff0000","I AM RED!"))
      • Custom script: call BJDebugMsg(ColoredText.ctFixedColor("ffff00","I AM YELLOW!"))
      • Custom script: call BJDebugMsg(ColoredText.ctFixedColor("EE9A00","I AM ORANGE!"))
      • Custom script: call BJDebugMsg(ColoredText.ctFixedColor("00f5ff","I AM TEAL!"))
      • -------- Random colored texts --------
      • For each (Integer A) from 1 to 7, do (Actions)
        • Loop - Actions
          • Custom script: call BJDebugMsg(ColoredText.ctRandomColor("RANDOM COLORS"))




Credits:
-
Changelogs:
v1.5
- Added extends array which behaves less accurate (suggested by Magtheridon96)
Magtheridon96 said:
When you deallocate, destroy the multiboard, and set this.multiboard = count.multiboard, then decrease count by 1.

v1.4
- Static methods replaced by methods

v1.3
- API changed names

v1.2
- boardDestroy changed

v1.1
- Multiboard is now arrayed which means you can have up to boardLimit(8190 MAX) at the same time but displays at a time only.
- boardEdit removed and replaced by boardDestroy.


Keywords:
mckill2009, board, leaderboard, system, multiboard, text, color, dota, rank
Contents

BoardEx (Map)

Reviews
01:07, 23rd Aug 2012 Magtheridon96: Approved. This could be useful.

Moderator

M

Moderator

01:07, 23rd Aug 2012
Magtheridon96:

Approved.

This could be useful.
 
Of course they can be used easily with GUI, I mean, the only thing that makes yours more GUI Friendly is the fact that you provided GUI triggers to show examples ._.

It's not easy to make a GUI Friendly system in vJASS because you need a super simple API.

Okay, yes, I will admit yours is a bit more friendly to GUIers than their systems, but it's not something a GUIer would easily understand to use because of the OO syntax :/
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
You really shouldn't be using a struct for this because you aren't taking advantage of OOP here; everything in the struct is static. You might as well as use functions and globals instead.

I don't find it user-friendly for people to have to use integer indices to refer to a multiboard. The fact that you aren't recycling indices properly for multiboards when they are destroyed makes this system buggy to use.

Although the function names may be intuitive, the documentation is really lacking.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
Magtheridon96 said:
Struct methods are actually function that takes an integer this.
watermelon_1234 said:
You really shouldn't be using a struct for this because you aren't taking advantage of OOP here; everything in the struct is static. You might as well as use functions and globals instead.
You think IDK that?, :(...
I can even do like this:

JASS:
struct testMB
    static BoardEx mb1
    static BoardEx mb2
    static boolean check = true
    
    static method displayMB takes nothing returns nothing
        if check then
            set check = false
            call mb1.display(false,true)
        else
            set check = true
            call mb2.display(false,true)
        endif    
    endmethod  
    
    static method tim takes nothing returns nothing
        set mb1 = mb1.create(1,1,true,true)
        set mb2 = mb2.create(1,1,true,true)
        call mb1.setTitle("BoardEx ONE")
        call mb2.setTitle("BoardEx TWO")
        call TimerStart(CreateTimer(),2.0,true,function thistype.displayMB)        
    endmethod

    static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(),0,false,function thistype.tim)
    endmethod
endstruct

But it's much harder for GUIers to deal with OOP, that's why I did the indexes manually...you cant really declare struct values in a GUI environment...

EDIT:
Except:
  • BoardEx in GUI
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: local BoardEx gee
      • Custom script: set gee = gee.create(1,1,true,true)
 
Last edited:
Level 29
Joined
Mar 10, 2009
Messages
5,016
I fail to understand the purpose of this "system" of yours.
Could you bother and explain it in a better way?
--->
Actually this is a Multiboard System...

and where do you not understand?

EDIT:
Im beggining to dislike you Mags, there's nothing wrong with the code using built in allocators! :(...
 
Last edited:
Top