• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Multiboard Inventory System: Comments!

Status
Not open for further replies.
Level 16
Joined
Feb 22, 2006
Messages
960
I was a bit bored and so i thought why not posting some random system by me for anyone who maybe wants to use it in its current state (too lazy to finish)

In general it's a multiboard system including an inventory with ~100 slots and a quest board.
Also I added a "item-system" for the inventory multiboard ... so one can create items via script, one just has to use the items I added in the object-editor

Maybe I have some time in the future to finish the sys and release a 100% version, but actually I don't think so.
Somebody might find use in this but please give credits etc.

The system uses the icons imported in the attached map.
Also it uses Table by Vexorian

But now the script :O (btw. nearly no comments => just for those who have a good knowledge of vJass)


JASS:
library MultiboardManagement initializer init requires Table
globals
                StringTable                     table 
endglobals

//Public Functions
//! textmacro boardPublicOne takes TYPE
    function set$TYPE$Multiboard takes player p, Multiboard board returns nothing
        set table[GetPlayerName(p)+"$TYPE$"] = board
    endfunction

    function get$TYPE$Multiboard takes player p returns Multiboard
        return table[GetPlayerName(p)+"$TYPE$"]
    endfunction
//! endtextmacro

//! runtextmacro boardPublicOne("Main")
//! runtextmacro boardPublicOne("Current")

//! textmacro boardPublicTwo takes TYPE
    function set$TYPE$Multiboard takes player p, $TYPE$Multiboard board returns nothing
        set table[GetPlayerName(p)+"$TYPE$"] = board
    endfunction

    function get$TYPE$Multiboard takes player p returns $TYPE$Multiboard
        return table[GetPlayerName(p)+"$TYPE$"]
    endfunction
//! endtextmacro

//! runtextmacro boardPublicTwo("Inventory")
//! runtextmacro boardPublicTwo("QuestMain")

private function init takes nothing returns nothing
    set table = StringTable.create()
endfunction
endlibrary



JASS:
library MultiboardCore initializer init requires InventoryMultiboardCore, QuestMultiboardCore
globals
                string              array       icons
                string              array       itemIcons
                string              array       equipIcons
    constant    string                          arrow                       =   "ReplaceableTextures\\CommandButtons\\BTNReplay-Play.blp"
    constant    string                          arrowDown                   =   "ReplaceableTextures\\CommandButtons\\ArrowDown.blp"
    constant    string                          inventar                    =   "ReplaceableTextures\\CommandButtons\\inventar.blp"
    
                unit                array       units   
                
    constant    integer                         MULTIBOARD_TYPE_MAIN        =   0
    constant    integer                         MULTIBOARD_TYPE_INVENTORY   =   1
    constant    integer                         MULTIBOARD_TYPE_QUEST       =   2
    constant    integer                         MULTIBOARD_TYPE_ITEM        =   3
    constant    integer                         MULTIBOARD_TYPE_RING        =   4
endglobals

struct Multiboard
    private multiboard          board
    private player              p
    private unit                hero            = null
    private integer             minIndex        = 0
    private integer             maxIndex        = 0
    private integer             minSideIndex    = 0
    private integer             maxSideIndex    = 0
    private boolean             sidebar         = false
    private boolean             itemMulti       = false
    private boolean             ringMulti       = false
    
    private integer             curIndex        = 0
    private integer             curSideIndex    = 0 
    
    stub method getBoardType takes nothing returns integer
        return MULTIBOARD_TYPE_MAIN
    endmethod
    
    method getPlayer takes nothing returns player
        return this.p
    endmethod
    
    method getBoard takes nothing returns multiboard
        return this.board
    endmethod
    
    method setSidebarActive takes boolean b returns nothing
        set this.sidebar = b
    endmethod
    
    method getMinIndex takes nothing returns integer
        return this.minIndex
    endmethod
    
    method setMinIndex takes integer index returns nothing
        set this.minIndex = index
    endmethod
    
    method getMaxIndex takes nothing returns integer
        return this.maxIndex
    endmethod
    
    method setMaxIndex takes integer index returns nothing
        set this.maxIndex = index
    endmethod
    
    method setMinSideIndex takes integer index returns nothing
        set this.minSideIndex = index
    endmethod
    
    method getMinSideIndex takes nothing returns integer
        return this.minSideIndex
    endmethod 
    
    method setMaxSideIndex takes integer index returns nothing
        set this.maxSideIndex = index
    endmethod
    
    method getMaxSideIndex takes nothing returns integer
        return this.maxSideIndex
    endmethod     
    
    method display takes boolean b returns nothing
        if GetLocalPlayer() == this.p then            
            call MultiboardDisplay(this.board, b)   
            call this.minimize(false)
        endif 
    endmethod
    
    method showItems takes boolean text, boolean icon returns nothing
        local integer curRow = 0
        local integer curCol = 0
        local integer numRows = MultiboardGetRowCount(this.board)
        local integer numCols = MultiboardGetColumnCount(this.board)
        local multiboarditem boardItem = null 
        loop
            exitwhen curRow > numRows
            set curCol = 0
            loop                
                exitwhen curCol > numCols
                set boardItem = MultiboardGetItem(this.board, curRow, curCol)
                call MultiboardSetItemStyle(boardItem, text, icon)
                call MultiboardReleaseItem(boardItem)
                set curCol = curCol + 1
            endloop
            set curRow = curRow + 1
        endloop    
        set boardItem = null
    endmethod
    
    method showItem takes boolean text, boolean icon, integer row, integer col returns nothing
        local multiboarditem boardItem = MultiboardGetItem(this.board, row, col)
        call MultiboardSetItemStyle(boardItem, text, icon)
        call MultiboardReleaseItem(boardItem)
        set boardItem = null
    endmethod
    
    method setAllIcons takes string iconPath returns nothing
        local integer curRow = 0
        local integer curCol = 0
        local integer numRows = MultiboardGetRowCount(this.board)
        local integer numCols = MultiboardGetColumnCount(this.board)
        local multiboarditem boardItem = null
        loop
            exitwhen curRow > numRows
            set curCol = 0
            loop                
                exitwhen curCol > numCols
                set boardItem = MultiboardGetItem(this.board, curRow, curCol)
                call MultiboardSetItemIcon(boardItem, iconPath)
                call MultiboardReleaseItem(boardItem)
                set curCol = curCol + 1
            endloop
            set curRow = curRow + 1
        endloop    
        set boardItem = null        
    endmethod
    
    method setIcon takes string iconPath, integer row, integer col returns nothing
        local multiboarditem boardItem = MultiboardGetItem(this.board, row, col)
        call MultiboardSetItemIcon(boardItem, iconPath)
        call MultiboardReleaseItem(boardItem)
        set boardItem = null
    endmethod
    
    method setText takes string text, integer row, integer col returns nothing
        local multiboarditem boardItem = MultiboardGetItem(this.board, row, col)
        call MultiboardSetItemValue(boardItem, text)
        call MultiboardReleaseItem(boardItem)
        set boardItem = null
    endmethod
    
    method setTextColor takes integer alpha, integer red, integer green, integer blue, integer row, integer col returns nothing
        local multiboarditem boardItem = MultiboardGetItem(this.board, row, col)
        call MultiboardSetItemValueColor(boardItem, red, green, blue, alpha)
        call MultiboardReleaseItem(boardItem)
        set boardItem = null
    endmethod
    
    method setAllItemWidth takes real width returns nothing
        local integer curRow = 0
        local integer curCol = 0
        local integer numRows = MultiboardGetRowCount(this.board)
        local integer numCols = MultiboardGetColumnCount(this.board)
        local multiboarditem boardItem = null
        loop
            exitwhen curRow > numRows
            set curCol = 0
            loop                
                exitwhen curCol > numCols
                set boardItem = MultiboardGetItem(this.board, curRow, curCol)
                call MultiboardSetItemWidth(boardItem, width)
                call MultiboardReleaseItem(boardItem)
                set curCol = curCol + 1
            endloop
            set curRow = curRow + 1
        endloop    
        set boardItem = null        
    endmethod
    
    method setItemWidth takes real width, integer row, integer col returns nothing
        local multiboarditem boardItem = MultiboardGetItem(this.board, row, col)
        call MultiboardSetItemWidth(boardItem, width)
        call MultiboardReleaseItem(boardItem)
        set boardItem = null
    endmethod
    
    method saveMultiboard takes thistype board, integer index returns nothing
        local Multiboard mboard
        if this.savedMultiboardExists(index) then
            set mboard = table[GetPlayerName(this.getPlayer())+I2S(index)+"MultiboardSave"+I2S(this)]
            call mboard.destroy()
            call table.flush(GetPlayerName(this.getPlayer())+I2S(index)+"MultiboardSave"+I2S(this))
        endif
        set table[GetPlayerName(this.getPlayer())+I2S(index)+"MultiboardSave"+I2S(this)] = board
    endmethod
    
    method deleteMultiboard takes integer index returns nothing
        call table.flush(GetPlayerName(this.getPlayer())+I2S(index)+"MultiboardSave"+I2S(this))
    endmethod
    
    method savedMultiboardExists takes integer index returns boolean
        return table.exists(GetPlayerName(this.getPlayer())+I2S(index)+"MultiboardSave"+I2S(this))
    endmethod
    
    method getSavedMultiboard takes integer index returns thistype
        return table[GetPlayerName(this.getPlayer())+I2S(index)+"MultiboardSave"+I2S(this)]
    endmethod
    
    method setCurIndex takes integer index returns nothing
        if index > this.getMaxIndex() or index < this.getMinIndex() then
            return
        endif
        set this.curIndex = index
    endmethod
    
    method setCurSideIndex takes integer index returns nothing
        if index > this.getMaxSideIndex() or index < this.getMinSideIndex() then
            return
        endif
        set this.curSideIndex = index
    endmethod
    
    method getCurIndex takes nothing returns integer
        return this.curIndex
    endmethod
    
    method getCurSideIndex takes nothing returns integer
        return this.curSideIndex
    endmethod
    
    stub method incIndex takes nothing returns nothing
        set this.curIndex = this.curIndex + 1
    endmethod
    
    method incSideIndex takes nothing returns nothing
        set this.curSideIndex = this.curSideIndex + 1
    endmethod

    stub method decIndex takes nothing returns nothing
        set this.curIndex = this.curIndex - 1
    endmethod
    
    method decSideIndex takes nothing returns nothing
        set this.curSideIndex = this.curSideIndex - 1
    endmethod    
    
    method minimize takes boolean b returns nothing
        call MultiboardMinimize(this.board,b)
    endmethod
    
    method isMinimized takes nothing returns boolean
        return IsMultiboardMinimized(this.board)
    endmethod
    
    method setHero takes unit hero returns nothing
        set this.hero = hero
    endmethod
    
    method getHero takes nothing returns unit
        return this.hero
    endmethod
    
    method sidebarActive takes nothing returns boolean
        return this.sidebar
    endmethod
    
    method setTitle takes string title returns nothing
        call MultiboardSetTitleText(this.board, title) 
    endmethod
    
    method getTitle takes nothing returns string
        return MultiboardGetTitleText(this.board)
    endmethod
    
    method getRowCount takes nothing returns integer
        return MultiboardGetRowCount(this.board)
    endmethod
    
    method addRow takes nothing returns nothing
        call MultiboardSetRowCount(this.board,this.getRowCount()+1)
    endmethod
    
    method deleteRow takes nothing returns nothing
        call MultiboardSetRowCount(this.board,this.getRowCount()-1)
    endmethod
    
    static method create takes player p, integer rows, integer cols, string title returns thistype
        local thistype this = thistype.allocate()
        local integer i = 0
        set this.p = p
        set this.board = CreateMultiboard()
        call MultiboardSetRowCount(this.board, rows)
        call MultiboardSetColumnCount(this.board, cols)
        call MultiboardSetTitleText(this.board, title)        
        loop
            exitwhen i >= 30
            call table.flush(GetPlayerName(this.getPlayer())+I2S(i)+"MultiboardSave"+I2S(this))
            set i = i + 1
        endloop
        return this
    endmethod  
    
    method onDestroy takes nothing returns nothing
        call DestroyMultiboard(this.board)
        set this.board = null
        set this.hero = null
    endmethod
endstruct

private function init takes nothing returns nothing
    set icons[0] = "ReplaceableTextures\\CommandButtons\\BTNINV_Misc_Bag_07.blp"
    set icons[1] = "ReplaceableTextures\\CommandButtons\\BTNSkillz.blp"
    set icons[2] = "ReplaceableTextures\\CommandButtons\\BTNINV_Letter_09.blp"
    set icons[3] = "ReplaceableTextures\\CommandButtons\\BTNSelectHeroOn.blp"
    set itemIcons[0] = "ReplaceableTextures\\CommandButtons\\BTNFootman.blp"
    set itemIcons[1] = "ReplaceableTextures\\CommandButtons\\BTNAttackGround.blp"
    set itemIcons[2] = "ReplaceableTextures\\CommandButtons\\BTNMGExchange.blp"
    set itemIcons[3] = "ReplaceableTextures\\CommandButtons\\BTNCancel.blp"
    set equipIcons[3] = "ReplaceableTextures\\CommandButtons\\Amulet.blp"
    set equipIcons[5] = "ReplaceableTextures\\CommandButtons\\Armor.blp"
    set equipIcons[8] = "ReplaceableTextures\\CommandButtons\\Boots.blp"
    set equipIcons[7] = "ReplaceableTextures\\CommandButtons\\Gloves.blp"
    set equipIcons[2] = "ReplaceableTextures\\CommandButtons\\Helm.blp"
    set equipIcons[6] = "ReplaceableTextures\\CommandButtons\\Pants.blp"
    set equipIcons[9] = "ReplaceableTextures\\CommandButtons\\Ring.blp"
    set equipIcons[10] = "ReplaceableTextures\\CommandButtons\\Ring.blp"
    set equipIcons[11] = "ReplaceableTextures\\CommandButtons\\Ring.blp"
    set equipIcons[12] = "ReplaceableTextures\\CommandButtons\\Ring.blp"
    set equipIcons[1] = "ReplaceableTextures\\CommandButtons\\Shield.blp"
    set equipIcons[4] = "ReplaceableTextures\\CommandButtons\\Shoulder.blp"
    set equipIcons[0] = "ReplaceableTextures\\CommandButtons\\Weapon.blp"            
endfunction
endlibrary



JASS:
library InventoryMultiboardCore initializer init requires ItemMultiboardCore, MultiboardManagement
struct InventoryMultiboard extends Multiboard
    //1 - Weapon
    //2 - Shield
    //3 - Helm 
    //4 - Amulet
    //5 - Shoulder
    //6 - Chest
    //7 - Pants
    //8 - Gloves
    //9 - Boots
    //10 - Ring1
    //11 - Ring2
    //12 - Ring3
    //13 - Ring4
    
    method getBoardType takes nothing returns integer
        return MULTIBOARD_TYPE_INVENTORY
    endmethod
    
    method getText takes nothing returns string
        local string text = ""
        local Item it
        if this.isItemInSlot() != true then
            set text = "|cff505050Empty - Slot|r"
            if this.getCurIndex() == 2 and this.getCurSideIndex() == 1 then
                set text = "|cff505050Empty - Weapon|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 2 then
                set text = "|cff505050Empty - Off-Hand|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 3 then
                set text = "|cff505050Empty - Head|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 4 then
                set text = "|cff505050Empty - Amulet|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 5 then
                set text = "|cff505050Empty - Shoulder|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 6 then
                set text = "|cff505050Empty - Chest|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 7 then
                set text = "|cff505050Empty - Pants|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 8 then
                set text = "|cff505050Empty - Gloves|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 9 then
                set text = "|cff505050Empty - Boots|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 10 then
                set text = "|cff505050Empty - Ring|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 11 then
                set text = "|cff505050Empty - Ring|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 12 then
                set text = "|cff505050Empty - Ring|r"
            elseif this.getCurIndex() == 2 and this.getCurSideIndex() == 13 then
                set text = "|cff505050Empty - Ring|r"                
            endif            
        else
            set it = table[GetPlayerName(this.getPlayer())+I2S(this.getCurIndex())+I2S(this.getCurSideIndex())+"Item"]
            set text = it.getName()
        endif
        return text
    endmethod
    
    method setStatText takes nothing returns nothing
        local Item it
        if this.isItemInSlot() then
            set it = table[GetPlayerName(this.getPlayer())+I2S(this.getCurIndex())+I2S(this.getCurSideIndex())+"Item"]
            call this.setText("+ "+I2S(R2I(it.getStats().getStrength()))+" Strength",21,1)
            call this.setText("+ "+I2S(R2I(it.getStats().getAgility()))+" Agility",22,1)
            call this.setText("+ "+I2S(R2I(it.getStats().getIntelligence()))+" Intelligence",23,1)
            call this.setItemWidth(0.15,21,1)
            call this.setItemWidth(0.15,22,1)
            call this.setItemWidth(0.15,23,1)
        else
            call this.setText("",21,1)
            call this.setText("",22,1)
            call this.setText("",23,1)            
        endif
    endmethod
    
    method isItemInSlot takes nothing returns boolean
        return table.exists(GetPlayerName(this.getPlayer())+I2S(this.getCurIndex())+I2S(this.getCurSideIndex())+"Item")
    endmethod
    
    method isItemInSlotEx takes integer row, integer collum returns boolean
        return table.exists(GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item")
    endmethod
    
    method registerItem takes Item it, integer row, integer collum returns nothing
        local ItemMultiboard itm = ItemMultiboard.create(this.getPlayer(), 4, 1, it.getName())
        set table[GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item"] = it                
        call itm.setHero(this.getHero())
        call itm.setMaxIndex(3)
        call itm.setMinIndex(0)        
        call itm.setIcon(arrow,0,0)
        call itm.setIcon(itemIcons[1],1,0)
        call itm.setIcon(itemIcons[2],2,0)
        call itm.setIcon(itemIcons[3],3,0)
        call itm.setTextColor(255,0,255,0,0,0)
        call itm.setText("Equip",0,0)
        call itm.setText("Drop",1,0)
        call itm.setText("Sell",2,0)
        call itm.setText("Back",3,0)
        call itm.setItemWidth(0.10,0,0)
        call itm.setItemWidth(0.10,1,0)
        call itm.setItemWidth(0.10,2,0)
        call itm.setItemWidth(0.10,3,0)
        call itm.saveMultiboard(this,3)
        call it.setItemMultiboard(itm)
        call this.setIcon(it.getIcon(),row,collum)
        call this.setText(it.getName(),row,collum)
        call getInventoryMultiboard(this.getPlayer()).setText(getInventoryMultiboard(this.getPlayer()).getText(),19,1)
        call getInventoryMultiboard(this.getPlayer()).setStatText()
    endmethod
    
    method getItemMultiboard takes nothing returns ItemMultiboard
        local Item it = table[GetPlayerName(this.getPlayer())+I2S(this.getCurIndex())+I2S(this.getCurSideIndex())+"Item"] 
        return it.getItemMultiboard()
    endmethod
    
    method incIndex takes nothing returns nothing
        local integer i = this.getCurIndex()
        if i == 16 and this.sidebarActive() then
            return
        endif
        if i == 2 then
            call this.setCurIndex(this.getCurIndex()+4)
        elseif i == 16 then
            call this.setCurIndex(this.getCurIndex()+1)
        endif
        if i != 2 and i != 16 then
            call this.setCurIndex(this.getCurIndex()+2)
        endif    
    endmethod
    
    method decIndex takes nothing returns nothing
        local integer i = this.getCurIndex()
        if i == 6 then
            call this.setCurIndex(this.getCurIndex()-4)
        elseif i == 17 then
            call this.setCurIndex(this.getCurIndex()-1)
        endif
        if i != 6 and i != 17 then
            call this.setCurIndex(this.getCurIndex()-2)
        endif
    endmethod
endstruct

private function pickup takes nothing returns nothing
    local Item it = GetItemData(GetManipulatedItem())
    local integer i = 6
    local integer k = 1
    local boolean b = false
    local player p = GetOwningPlayer(GetManipulatingUnit())
    loop
        exitwhen i >= getInventoryMultiboard(p).getMaxIndex() or b == true
        loop
            exitwhen k > getInventoryMultiboard(p).getMaxSideIndex() or b == true
            if getInventoryMultiboard(p).isItemInSlotEx(i,k) != true then
                call getInventoryMultiboard(p).registerItem(it,i,k)
                set b = true
            endif
            set k = k + 1
        endloop
        set k = 1
        set i = i + 2
    endloop
    if b == false then
        call UnitRemoveItem(GetManipulatingUnit(),GetManipulatedItem()) 
        call DisplayTextToPlayer(GetOwningPlayer(GetManipulatingUnit()),0,0,"Inventory is full")
    else
        call UnitRemoveItem(GetManipulatingUnit(),GetManipulatedItem())
        call SetItemVisible(GetManipulatedItem(),false)    
    endif
endfunction

private function init takes nothing returns nothing
    local trigger int = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(int, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction(int,function pickup)
    set int = null
endfunction
endlibrary



JASS:
library QuestMultiboardCore requires MultiboardManagement
globals
        constant    integer     questNumberMax  =   20
endglobals


struct QuestMainMultiboard extends Multiboard
    private integer currentQuestCount   =   0     
    method createQuest takes string title, string line1, string line2, string line3, string line4, string line5, string line6, string line7, string line8, integer level returns nothing
        local QuestMultiboard board = QuestMultiboard.create(this.getPlayer(),15,3,title)
        local integer i = 0
        local boolean b = false
        call board.setMinIndex(19)
        call board.setMaxIndex(19)
        call board.setCurIndex(19)
        call board.saveMultiboard(this,19)
        call board.showItems(true,false)
        loop
            exitwhen i >= 15
            call board.setItemWidth(0.05,i,0)
            call board.setItemWidth(0.05,i,2)
            call board.setItemWidth(0.20,i,1)
            set i = i + 1
        endloop
        set i = 0
        call board.setText(line1,0,1)
        call board.setText(line2,1,1)
        call board.setText(line3,2,1)
        call board.setText(line4,3,1)
        call board.setText(line5,4,1)
        call board.setText(line6,5,1)
        call board.setText(line7,6,1)
        call board.setText(line8,7,1)
        call board.setText("Recommended Level: "+I2S(level)+"+",9,1)
        call board.showItem(true,true,14,0)
        call board.setIcon(arrow,14,0)
        call board.setTextColor(255,0,255,0,14,0)
        call board.setText("Back",14,0)
        loop
            exitwhen i >= questNumberMax or b
            if this.savedMultiboardExists(i) != true or this.getSavedMultiboard(i) == getMainMultiboard(this.getPlayer()) then
                call this.setText(title,i,1)
                set this.currentQuestCount = this.currentQuestCount + 1
                call this.setTitle("Quests "+I2S(this.currentQuestCount)+"/"+I2S(questNumberMax))
                call getMainMultiboard(this.getPlayer()).setText("Quests "+I2S(this.currentQuestCount)+"/"+I2S(questNumberMax),2,0)
                call this.addRow()
                call this.saveMultiboard(this.getSavedMultiboard(this.getMaxIndex()),this.getMaxIndex()+1)
                call this.deleteMultiboard(this.getMaxIndex())
                call this.saveMultiboard(board,i)
                call this.showItem(false,false,this.getMaxIndex(),0)
                call this.setMaxIndex(this.getMaxIndex()+1)
                call this.setText("Back",this.getMaxIndex(),1)
                call this.showItem(true,false,this.getMaxIndex(),1)
                call this.showItem(false,true,this.getMaxIndex(),0)
                call this.showItem(false,false,this.getCurIndex(),0)
                call this.setTextColor(255,255,255,255,this.getCurIndex(),1)                
                call this.setCurIndex(this.getMaxIndex())
                call this.setIcon(arrow,this.getMaxIndex(),0)
                call this.setItemWidth(0.01,this.getMaxIndex(),0)
                call this.setItemWidth(0.10,i,1)
                call this.showItem(false,false,i,0)
                call this.setTextColor(255,255,255,255,i,1)
                call this.setTextColor(255,0,255,0,this.getMaxIndex(),1)
                set b = true 
            endif            
            set i = i + 1
        endloop
        if b == false then
            call board.destroy()
            call DisplayTimedTextToPlayer(this.getPlayer(),0,0,15,"You can't have more quests")
        endif
    endmethod
    
    method isQuestlogFull takes nothing returns boolean        
        return this.currentQuestCount >= questNumberMax
    endmethod
    
    method finishQuest takes string title returns nothing
        local integer i = 0 
        local integer k = 0
        local boolean b = false
        loop
            exitwhen i >= 20 or b
            if this.savedMultiboardExists(i) then
                if getCurrentMultiboard(this.getPlayer()) == this.getSavedMultiboard(i) and this.currentQuestCount > 0 then
                    call this.getSavedMultiboard(i).display(false)
                    call this.getSavedMultiboard(i).destroy()
                    call this.deleteMultiboard(i)                    
                    set k = i
                    loop
                        exitwhen k >= this.getMaxIndex()-1
                        call this.saveMultiboard(this.getSavedMultiboard(k+1),k)
                        call this.deleteMultiboard(k+1)
                        call this.setText(this.getSavedMultiboard(k).getTitle(),k,1)
                        set k = k + 1
                    endloop
                    call this.saveMultiboard(this.getSavedMultiboard(this.getMaxIndex()),this.getMaxIndex()-1)
                    call this.deleteMultiboard(this.getMaxIndex())
                    call this.setMaxIndex(this.getMaxIndex()-1)
                    call this.showItem(false,false,this.getCurIndex(),0)
                    call this.setTextColor(255,255,255,255,this.getCurIndex(),1)                    
                    call this.setCurIndex(this.getMaxIndex())
                    call this.setText("Back",this.getMaxIndex(),1)
                    call this.showItem(true,false,this.getMaxIndex(),1)
                    call this.showItem(false,true,this.getMaxIndex(),0)
                    call this.setCurIndex(this.getMaxIndex())
                    call this.setIcon(arrow,this.getMaxIndex(),0)                    
                    call this.setTextColor(255,0,255,0,this.getMaxIndex(),1)              
                    call setCurrentMultiboard(this.getPlayer(),getQuestMainMultiboard(this.getPlayer()))
                    call getCurrentMultiboard(this.getPlayer()).display(true)
                    call this.deleteRow()
                    set b = true
                elseif title == MultiboardGetTitleText(this.getSavedMultiboard(i).getBoard()) then
                    call this.getSavedMultiboard(i).destroy()
                    call this.deleteMultiboard(i)  
                    set k = i
                    loop
                        exitwhen k >= this.getMaxIndex()-1
                        call this.saveMultiboard(this.getSavedMultiboard(k+1),k)
                        call this.deleteMultiboard(k+1)
                        call this.setText(this.getSavedMultiboard(k).getTitle(),k,1)
                        set k = k + 1
                    endloop     
                    call this.saveMultiboard(this.getSavedMultiboard(this.getMaxIndex()),this.getMaxIndex()-1)
                    call this.deleteMultiboard(this.getMaxIndex())                    
                    call this.setMaxIndex(this.getMaxIndex()-1)
                    call this.showItem(false,false,this.getCurIndex(),0)
                    call this.setTextColor(255,255,255,255,this.getCurIndex(),1)
                    call this.setCurIndex(this.getMaxIndex())
                    call this.setText("Back",this.getMaxIndex(),1)
                    call this.showItem(true,false,this.getMaxIndex(),1)
                    call this.showItem(false,true,this.getMaxIndex(),0)
                    call this.setCurIndex(this.getMaxIndex())
                    call this.setIcon(arrow,this.getMaxIndex(),0)                    
                    call this.setTextColor(255,0,255,0,this.getMaxIndex(),1)
                    call this.deleteRow()
                    set b = true
                endif
            endif
            set i = i + 1
        endloop
        if b then
            set this.currentQuestCount = this.currentQuestCount - 1
            call this.setTitle("Quests "+I2S(this.currentQuestCount)+"/"+I2S(questNumberMax))
            call getMainMultiboard(this.getPlayer()).setText("Quests "+I2S(this.currentQuestCount)+"/"+I2S(questNumberMax),2,0)
            call DisplayTextToPlayer(this.getPlayer(),0,0,"You've finished the quest '"+title+"'")
        endif
    endmethod    
endstruct

struct QuestMultiboard extends Multiboard 
endstruct
endlibrary



JASS:
library ItemMultiboardCore initializer init requires Table, MultiboardManagement
globals
        //Item-Types
            constant    integer                 ITEM_TYPE_WEAPON      =   0
            constant    integer                 ITEM_TYPE_SHIELD      =   1
            constant    integer                 ITEM_TYPE_HELM        =   2
            constant    integer                 ITEM_TYPE_AMULET      =   3
            constant    integer                 ITEM_TYPE_SHOULDER    =   4
            constant    integer                 ITEM_TYPE_CHEST       =   5
            constant    integer                 ITEM_TYPE_PANTS       =   6
            constant    integer                 ITEM_TYPE_GLOVES      =   7
            constant    integer                 ITEM_TYPE_BOOTS       =   8
            constant    integer                 ITEM_TYPE_RING        =   9
                        integer         array   itemRawCodes
                        integer                 itemRawCodeTotal    =   0
    private             HandleTable             hTable              
endglobals

function RegisterItem takes Item object returns nothing
    set hTable[object.getItem()] = object
endfunction

function GetItemData takes item it returns Item
    return hTable[it]
endfunction

struct Stats
    private real    str     = 0.0
    private real    agi     = 0.0
    private real    int     = 0.0
    
    //! textmacro stats takes NAME, TYPE
    method get$NAME$ takes nothing returns real
        return this.$TYPE$
    endmethod
    
    method set$NAME$ takes real $TYPE$ returns nothing
        set this.$TYPE$ = $TYPE$
    endmethod
    //! endtextmacro
    //! runtextmacro stats("Strength","str")
    //! runtextmacro stats("Agility","agi")
    //! runtextmacro stats("Intelligence","int")
endstruct
    
struct Item
        
    private string          name        = ""
    private string          legText     = ""
    private string          icon        = ""
    private integer         itemType    = 0
    private item            it          = null
    private ItemMultiboard  itm    
        
    private Stats   stats
    
    method destroyItemMultiboard takes nothing returns nothing
        call this.itm.destroy()
        set this.itm = 0
    endmethod
    
    method setItemMultiboard takes integer itm returns nothing
        set this.itm = itm
    endmethod
    
    method getItemMultiboard takes nothing returns ItemMultiboard
        return this.itm
    endmethod
    
    method getItemType takes nothing returns integer
        return this.itemType
    endmethod
    
    method getItem takes nothing returns item
        return this.it
    endmethod
    
    method getName takes nothing returns string
        return this.name
    endmethod
    
    method getIcon takes nothing returns string
        return this.icon
    endmethod
    
    method getStats takes nothing returns Stats
        return this.stats
    endmethod
    
    static method create takes integer itemType, string name, string icon, Stats stats, string legText, real x, real y returns thistype
        local thistype this = thistype.allocate()
        local integer i = 0
        if itemType < 0 or itemType > 10 then
            call this.destroy()
            return 0
        endif
        set this.name = name
        set this.icon = icon
        set this.stats = stats
        set this.legText = legText
        set this.itemType = itemType
        loop
            exitwhen i >= itemRawCodeTotal
            if itemType == i then
                set this.it = CreateItem(itemRawCodes[i],x,y)
            endif
            set i = i + 1
        endloop
        call RegisterItem(this)
        return this
    endmethod
endstruct


struct ItemMultiboard extends Multiboard
    stub method getBoardType takes nothing returns integer
        return MULTIBOARD_TYPE_ITEM
    endmethod
    
    method applyStats takes Item it, boolean b returns nothing
        local Stats stats = it.getStats()
        if b then
            call SetHeroStr(this.getHero(),R2I((GetHeroStr(this.getHero(),false)+stats.getStrength())+0.5),true)
            call SetHeroAgi(this.getHero(),R2I((GetHeroAgi(this.getHero(),false)+stats.getStrength())+0.5),true)
            call SetHeroInt(this.getHero(),R2I((GetHeroInt(this.getHero(),false)+stats.getStrength())+0.5),true)
        else
            call SetHeroStr(this.getHero(),R2I((GetHeroStr(this.getHero(),false)-stats.getStrength())+0.5),true)
            call SetHeroAgi(this.getHero(),R2I((GetHeroAgi(this.getHero(),false)-stats.getStrength())+0.5),true)
            call SetHeroInt(this.getHero(),R2I((GetHeroInt(this.getHero(),false)-stats.getStrength())+0.5),true)            
        endif
    endmethod
    
    method equipItem takes nothing returns nothing
        local integer row = getInventoryMultiboard(this.getPlayer()).getCurIndex()
        local integer collum = getInventoryMultiboard(this.getPlayer()).getCurSideIndex()
        local Item it = table[GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item"]
        local Item tmpItem
        local Multiboard board
        local integer itemType = it.getItemType()
        local integer i = 0 
        local integer k = 1
        local boolean b = false
        if row != 2 then
            loop
                exitwhen i >= 9
                if itemType == i then
                    if getInventoryMultiboard(this.getPlayer()).isItemInSlotEx(2,i+1) != true then
                        call getInventoryMultiboard(this.getPlayer()).setIcon(inventar,row,collum)
                        call table.flush(GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item")
                        call getInventoryMultiboard(this.getPlayer()).registerItem(it,2,i+1)
                        call getInventoryMultiboard(this.getPlayer()).setText(getInventoryMultiboard(this.getPlayer()).getText(),19,1)
                        call getInventoryMultiboard(this.getPlayer()).setStatText()
                        call getCurrentMultiboard(this.getPlayer()).display(false) 
                        call getCurrentMultiboard(this.getPlayer()).destroy()
                        call setCurrentMultiboard(this.getPlayer(),getInventoryMultiboard(this.getPlayer()))
                        call getInventoryMultiboard(this.getPlayer()).display(true)
                        call it.getItemMultiboard().setText("Unequip",0,0)
                    else                        
                        set tmpItem = table[GetPlayerName(this.getPlayer())+I2S(2)+I2S(i+1)+"Item"]                       
                        call table.flush(GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item")
                        call table.flush(GetPlayerName(this.getPlayer())+I2S(2)+I2S(i+1)+"Item")
                        call getCurrentMultiboard(this.getPlayer()).display(false)                        
                        call it.destroyItemMultiboard()
                        call tmpItem.destroyItemMultiboard()                                                                         
                        call getInventoryMultiboard(this.getPlayer()).registerItem(it,2,i+1)
                        call getInventoryMultiboard(this.getPlayer()).registerItem(tmpItem,row,collum)
                        call setCurrentMultiboard(this.getPlayer(),getInventoryMultiboard(this.getPlayer()))
                        call getInventoryMultiboard(this.getPlayer()).display(true)
                        call it.getItemMultiboard().setText("Unequip",0,0)
                    endif
                endif
                set i = i + 1
            endloop
            if itemType == 9 then
                call getCurrentMultiboard(this.getPlayer()).destroy()
                set board = RingMultiboard.create(this.getPlayer(),5,2,"Equip Ring")                
                call board.saveMultiboard(it.getItemMultiboard(),4)
                call board.setMaxIndex(4)
                call board.showItems(false,false)
                call board.showItem(true,false,0,1)
                call board.showItem(true,false,1,1)
                call board.showItem(true,false,2,1)
                call board.showItem(true,false,3,1)
                call board.showItem(true,false,4,1)
                call board.showItem(false,true,0,0)               
                call board.setText("Ring-Slot 1",0,1)
                call board.setText("Ring-Slot 2",1,1)
                call board.setText("Ring-Slot 3",2,1)
                call board.setText("Ring-Slot 4",3,1)
                call board.setText("Cancel",4,1)
                call board.setItemWidth(0.01,0,0)
                call board.setItemWidth(0.01,1,0)
                call board.setItemWidth(0.01,2,0)
                call board.setItemWidth(0.01,3,0)
                call board.setItemWidth(0.01,4,0)
                call board.setItemWidth(0.08,0,1)
                call board.setItemWidth(0.08,1,1)
                call board.setItemWidth(0.08,2,1)
                call board.setItemWidth(0.08,3,1)
                call board.setItemWidth(0.08,4,1)
                call board.setIcon(arrow,0,0)
                call board.setTextColor(255,0,255,0,0,1)
                call setCurrentMultiboard(this.getPlayer(),board)
                call board.display(true)
            endif
        else
            set i = 6
            set b = false
            loop
                exitwhen i >= getInventoryMultiboard(this.getPlayer()).getMaxIndex() or b == true
                loop
                    exitwhen k > getInventoryMultiboard(this.getPlayer()).getMaxSideIndex() or b == true
                    if getInventoryMultiboard(this.getPlayer()).isItemInSlotEx(i,k) != true then
                        call getInventoryMultiboard(this.getPlayer()).setIcon(equipIcons[collum-1],row,collum)
                        call table.flush(GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item")
                        call getInventoryMultiboard(this.getPlayer()).setText(getInventoryMultiboard(this.getPlayer()).getText(),19,1)
                        call getInventoryMultiboard(this.getPlayer()).registerItem(it,i,k)
                        call getCurrentMultiboard(this.getPlayer()).display(false)
                        call getCurrentMultiboard(this.getPlayer()).destroy()
                        call setCurrentMultiboard(this.getPlayer(),getInventoryMultiboard(this.getPlayer()))
                        call getCurrentMultiboard(this.getPlayer()).display(true)
                        set b = true
                    endif
                    set k = k + 1
                endloop
                set k = 1
                set i = i + 2
            endloop            
        endif
    endmethod
    
    //! textmacro ring takes NUMBER , COLLUM
    method equipRingSlot$NUMBER$ takes nothing returns nothing
        local integer row = getInventoryMultiboard(this.getPlayer()).getCurIndex()
        local integer collum = getInventoryMultiboard(this.getPlayer()).getCurSideIndex()
        local Item it = table[GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item"]   
        local Item tmpItem
        if getInventoryMultiboard(this.getPlayer()).isItemInSlotEx(2,$COLLUM$) != true then
            call getInventoryMultiboard(this.getPlayer()).setIcon(inventar,row,collum)
            call table.flush(GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item")
            call getInventoryMultiboard(this.getPlayer()).setText(getInventoryMultiboard(this.getPlayer()).getText(),19,1)
            call getInventoryMultiboard(this.getPlayer()).setStatText()
            call getInventoryMultiboard(this.getPlayer()).registerItem(it,2,$COLLUM$)
            call getCurrentMultiboard(this.getPlayer()).display(false)
            call getCurrentMultiboard(this.getPlayer()).destroy()
            call setCurrentMultiboard(this.getPlayer(),getInventoryMultiboard(this.getPlayer()))
            call getCurrentMultiboard(this.getPlayer()).display(true)
            call it.getItemMultiboard().setText("Unequip",0,0)
        else
            set tmpItem = table[GetPlayerName(this.getPlayer())+I2S(2)+I2S($COLLUM$)+"Item"]
            call table.flush(GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item")
            call table.flush(GetPlayerName(this.getPlayer())+I2S(2)+I2S($COLLUM$)+"Item")
            call getCurrentMultiboard(this.getPlayer()).display(false)
            call it.destroyItemMultiboard()
            call tmpItem.destroyItemMultiboard()
            call getInventoryMultiboard(this.getPlayer()).registerItem(it,2,$COLLUM$)
            call getInventoryMultiboard(this.getPlayer()).registerItem(tmpItem,row,collum)
            call setCurrentMultiboard(this.getPlayer(),getInventoryMultiboard(this.getPlayer()))
            call getInventoryMultiboard(this.getPlayer()).setText(getInventoryMultiboard(this.getPlayer()).getText(),19,1)
            call getInventoryMultiboard(this.getPlayer()).setStatText()
            call getCurrentMultiboard(this.getPlayer()).display(true)
            call it.getItemMultiboard().setText("Unequip",0,0)
        endif        
    endmethod
    //! endtextmacro
    //! runtextmacro ring("1","10")
    //! runtextmacro ring("2","11")
    //! runtextmacro ring("3","12")
    //! runtextmacro ring("4","13")    
    
    method dropItem takes nothing returns nothing
        local integer row = getInventoryMultiboard(this.getPlayer()).getCurIndex()
        local integer collum = getInventoryMultiboard(this.getPlayer()).getCurSideIndex()
        local Item it = table[GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item"]
        call SetItemVisible(it.getItem(),true)
        call SetItemPosition(it.getItem(),GetUnitX(getMainMultiboard(this.getPlayer()).getHero()),GetUnitY(getMainMultiboard(this.getPlayer()).getHero()))
        call getInventoryMultiboard(this.getPlayer()).setIcon(inventar,row,collum)
        call table.flush(GetPlayerName(this.getPlayer())+I2S(row)+I2S(collum)+"Item")
        call getInventoryMultiboard(this.getPlayer()).setText(getInventoryMultiboard(this.getPlayer()).getText(),19,1) 
        call getInventoryMultiboard(this.getPlayer()).setStatText()
        call getCurrentMultiboard(this.getPlayer()).display(false)
        call getCurrentMultiboard(this.getPlayer()).destroy()
        call setCurrentMultiboard(this.getPlayer(),getInventoryMultiboard(this.getPlayer()))
        call getCurrentMultiboard(this.getPlayer()).display(true)        
    endmethod

endstruct

struct RingMultiboard extends ItemMultiboard
    method getBoardType takes nothing returns integer
        return MULTIBOARD_TYPE_RING
    endmethod
endstruct

private function init takes nothing returns nothing
    set itemRawCodes[0] = 'I001'
    set itemRawCodes[1] = 'I003'
    set itemRawCodes[2] = 'I000'
    set itemRawCodes[3] = 'I002'
    set itemRawCodes[4] = 'I004'
    set itemRawCodes[5] = 'I005'
    set itemRawCodes[6] = 'I006'
    set itemRawCodes[7] = 'I007'
    set itemRawCodes[8] = 'I008'
    set itemRawCodes[9] = 'I009'
    set itemRawCodeTotal = 10
    set hTable = HandleTable.create()
endfunction
endlibrary



JASS:
library NavigationCore initializer init requires MultiboardCore, MultiboardManagement


private function pressActionDown takes nothing returns nothing
    local Multiboard board = getCurrentMultiboard(GetTriggerPlayer())
    local integer i = board.getCurIndex()
    local integer k = board.getCurSideIndex()
    if i == board.getMaxIndex() or board.isMinimized() then        
        return
    endif      
    if board.sidebarActive() != true then        
        call board.setTextColor(255,255,255,255,i,0) 
        if board.getBoardType() == MULTIBOARD_TYPE_RING then
            call board.setTextColor(255,255,255,255,i,1)
        endif        
        if getCurrentMultiboard(GetTriggerPlayer()) == getQuestMainMultiboard(GetTriggerPlayer()) then
            if getQuestMainMultiboard(GetTriggerPlayer()).savedMultiboardExists(i) then
                call board.setTextColor(255,255,255,255,i,1)
            endif
        endif
        if getCurrentMultiboard(GetTriggerPlayer()) == getMainMultiboard(GetTriggerPlayer()) then
            call board.setIcon(icons[i],i,0)
            call board.incIndex()
        elseif getCurrentMultiboard(GetTriggerPlayer()) == getInventoryMultiboard(GetTriggerPlayer()) then
            call board.showItem(false,false,i,0)
            call board.incIndex()
        endif  
        if getCurrentMultiboard(GetTriggerPlayer()) != getMainMultiboard(GetTriggerPlayer()) and getCurrentMultiboard(GetTriggerPlayer()) != getInventoryMultiboard(GetTriggerPlayer()) and getCurrentMultiboard(GetTriggerPlayer()).getBoardType() != MULTIBOARD_TYPE_ITEM then
            call board.showItem(true,false,i,0)
            call board.incIndex()
        endif
        if getCurrentMultiboard(GetTriggerPlayer()).getBoardType() == MULTIBOARD_TYPE_ITEM then
            call board.setIcon(itemIcons[i],i,0)
            call board.incIndex()
        endif
        set i = board.getCurIndex()        
        call board.setTextColor(255,0,255,0,i,0)
        if getCurrentMultiboard(GetTriggerPlayer()) != getMainMultiboard(GetTriggerPlayer()) or (getCurrentMultiboard(GetTriggerPlayer()) == getInventoryMultiboard(GetTriggerPlayer()) and i != 19)then
            call board.showItem(false,true,i,0)
        endif
        if (getCurrentMultiboard(GetTriggerPlayer()) == getInventoryMultiboard(GetTriggerPlayer()) and i == 17) or getCurrentMultiboard(GetTriggerPlayer()).getBoardType() == MULTIBOARD_TYPE_ITEM then
            call board.showItem(true,true,i,0)
            call board.setTextColor(255,0,255,0,i,1)
        endif
        if board.getBoardType() == MULTIBOARD_TYPE_RING or getCurrentMultiboard(GetTriggerPlayer()) == getQuestMainMultiboard(GetTriggerPlayer()) then 
            call board.setTextColor(255,0,255,0,i,1)
        endif
        call board.setIcon(arrow,i,0)
    else
        call board.showItem(true,false,i,0)
        call board.showItem(true,false,i-1,k)            
        call board.setTextColor(255,255,255,255,i,1)
        call board.showItem(true,false,i-1,k)
        call board.incIndex()
        set i = board.getCurIndex()
        call board.showItem(true,true,i,0)
        call board.showItem(true,true,i-1,k)        
        call board.setIcon(arrowDown,i-1,k)
        call board.setIcon(arrow,i,0)
        //ToolTip
        call board.showItem(true,false,19,1)
        call board.setItemWidth(0.10,19,1)
        call board.setText(getInventoryMultiboard(GetTriggerPlayer()).getText(),19,1)
        call getInventoryMultiboard(GetTriggerPlayer()).setStatText()
    endif
endfunction

private function pressActionUp takes nothing returns nothing
    local Multiboard board = getCurrentMultiboard(GetTriggerPlayer())
    local integer i = board.getCurIndex()
    local integer k = board.getCurSideIndex()
    if i == board.getMinIndex() or board.isMinimized() then
        return
    endif
    if board.sidebarActive() != true then        
        call board.setTextColor(255,255,255,255,i,0)
        if board.getBoardType() == MULTIBOARD_TYPE_RING then
            call board.setTextColor(255,255,255,255,i,1)
        endif
        if getCurrentMultiboard(GetTriggerPlayer()) == getQuestMainMultiboard(GetTriggerPlayer()) then
            if getQuestMainMultiboard(GetTriggerPlayer()).savedMultiboardExists(i) then
                call board.setTextColor(255,255,255,255,i,1)
            endif
        endif
        if getCurrentMultiboard(GetTriggerPlayer()) == getMainMultiboard(GetTriggerPlayer()) then
            call board.setIcon(icons[i],i,0)
            call board.decIndex()
        elseif getCurrentMultiboard(GetTriggerPlayer()) != getMainMultiboard(GetTriggerPlayer()) and getCurrentMultiboard(GetTriggerPlayer()) != getInventoryMultiboard(GetTriggerPlayer()) and getCurrentMultiboard(GetTriggerPlayer()).getBoardType() != MULTIBOARD_TYPE_ITEM then
            call board.showItem(false,false,i,0)
            call board.decIndex()
        endif
        if getCurrentMultiboard(GetTriggerPlayer()) == getInventoryMultiboard(GetTriggerPlayer()) then
            call board.showItem(true,false,i,0)
            call board.setTextColor(255,255,255,255,i,1)
            call board.decIndex()
        endif    
        if getCurrentMultiboard(GetTriggerPlayer()).getBoardType() == MULTIBOARD_TYPE_ITEM then
            call board.setIcon(itemIcons[i],i,0)
            call board.decIndex()
        endif        
        set i = board.getCurIndex()
        if getCurrentMultiboard(GetTriggerPlayer()) != getMainMultiboard(GetTriggerPlayer()) then
            call board.showItem(false,true,i,0)
        endif  
        if getCurrentMultiboard(GetTriggerPlayer()).getBoardType() == MULTIBOARD_TYPE_ITEM then
            call board.showItem(true,true,i,0)
        endif
        call board.setTextColor(255,0,255,0,i,0)
        if board.getBoardType() == MULTIBOARD_TYPE_RING or getCurrentMultiboard(GetTriggerPlayer()) == getQuestMainMultiboard(GetTriggerPlayer()) then
            call board.setTextColor(255,0,255,0,i,1)
        endif
        call board.setIcon(arrow,i,0)
    else
        call board.showItem(true,false,i,0)
        call board.showItem(true,false,i-1,k)            
        call board.setTextColor(255,255,255,255,i,1)
        call board.showItem(true,false,i-1,k)
        call board.decIndex()
        set i = board.getCurIndex()
        call board.showItem(true,true,i,0)
        call board.showItem(true,true,i-1,k)        
        call board.setIcon(arrowDown,i-1,k)
        call board.setIcon(arrow,i,0)
        //ToolTip
        call board.showItem(true,false,19,1)
        call board.setItemWidth(0.10,19,1)
        call board.setText(getInventoryMultiboard(GetTriggerPlayer()).getText(),19,1)
        call getInventoryMultiboard(GetTriggerPlayer()).setStatText()
    endif
endfunction

private function pressActionLeft takes nothing returns nothing
    local Multiboard board = getCurrentMultiboard(GetTriggerPlayer())
    local integer i = board.getCurIndex() 
    local integer k = board.getCurSideIndex()
    if k > 0 then
        call board.setSidebarActive(true)
    else
        call board.setSidebarActive(false)        
    endif     
    if board.isMinimized() or board != getInventoryMultiboard(GetTriggerPlayer()) or board.getCurSideIndex() <= board.getMinSideIndex() then        
        return
    endif    
    if k == 1 then
        call board.showItem(false,false,i-1,k)
        call board.decSideIndex()
        call board.setSidebarActive(false)
        call board.showItem(false,false,19,1)
        call getInventoryMultiboard(GetTriggerPlayer()).setStatText()
    elseif k > 0 then
        call board.showItem(false,false,i-1,k)
        call board.decSideIndex()
        set k = board.getCurSideIndex()   
        call board.setIcon(arrowDown,i-1,k)
        call board.showItem(false,true,i-1,k)
        //ToolTip
        call board.showItem(true,false,19,1)
        call board.setItemWidth(0.10,19,1)
        call board.setText(getInventoryMultiboard(GetTriggerPlayer()).getText(),19,1) 
        call getInventoryMultiboard(GetTriggerPlayer()).setStatText()
    endif    
endfunction

private function pressActionRight takes nothing returns nothing
    local Multiboard board = getCurrentMultiboard(GetTriggerPlayer())
    local integer i = board.getCurIndex() 
    local integer k = board.getCurSideIndex()   
    if board.isMinimized() or board != getInventoryMultiboard(GetTriggerPlayer()) or board.getCurSideIndex() >= board.getMaxSideIndex() then        
        return
    endif    
    if k == 0 and i != board.getMaxIndex() then
        call board.incSideIndex()
        set k = board.getCurSideIndex()
        call board.setSidebarActive(true)
        call board.setIcon(arrowDown,i-1,k)
        call board.showItem(false,true,i-1,k)
        //Tooltip
        call board.showItem(true,false,19,1)
        call board.setItemWidth(0.10,19,1)
        call board.setText(getInventoryMultiboard(GetTriggerPlayer()).getText(),19,1)
        call getInventoryMultiboard(GetTriggerPlayer()).setStatText()
    elseif k > 0 and i != board.getMaxIndex() then
        call board.showItem(false,false,i-1,k)
        call board.incSideIndex()
        set k = board.getCurSideIndex()   
        call board.setIcon(arrowDown,i-1,k)
        call board.showItem(false,true,i-1,k)
        //ToolTip
        call board.showItem(true,false,19,1)
        call board.setItemWidth(0.10,19,1)
        call board.setText(getInventoryMultiboard(GetTriggerPlayer()).getText(),19,1)
        call getInventoryMultiboard(GetTriggerPlayer()).setStatText()
    endif
endfunction

private function pressActionEsc takes nothing returns nothing
    local Multiboard board = getCurrentMultiboard(GetTriggerPlayer())
    local ItemMultiboard itm
    local integer i = board.getCurIndex() 
    if board.isMinimized() then
        return
    endif         
    if board.savedMultiboardExists(i) then
        call board.display(false)
        call setCurrentMultiboard(GetTriggerPlayer(),board.getSavedMultiboard(i))
        call getCurrentMultiboard(GetTriggerPlayer()).display(true)
    else
        if board.getBoardType() == MULTIBOARD_TYPE_ITEM then
            if board.getCurIndex() == 0 then
                set itm = board   
                call itm.equipItem()
            elseif board.getCurIndex() == 1 then
                set itm = board
                call itm.dropItem()
            endif
        elseif board.getBoardType() == MULTIBOARD_TYPE_RING then
            if board.getCurIndex() == 0 then
                set itm = board
                call itm.equipRingSlot1()
            elseif board.getCurIndex() == 1 then
                set itm = board
                call itm.equipRingSlot2()
            elseif board.getCurIndex() == 2 then
                set itm = board
                call itm.equipRingSlot3()
            elseif board.getCurIndex() == 3 then
                set itm = board
                call itm.equipRingSlot4()
            endif
        else
            if getInventoryMultiboard(GetTriggerPlayer()).isItemInSlot() and getCurrentMultiboard(GetTriggerPlayer()) == getInventoryMultiboard(GetTriggerPlayer()) then
                set itm = getInventoryMultiboard(GetTriggerPlayer()).getItemMultiboard()
                call board.display(false)
                call itm.display(true)
                call setCurrentMultiboard(GetTriggerPlayer(),itm)
            else
                if getCurrentMultiboard(GetTriggerPlayer()) == getInventoryMultiboard(GetTriggerPlayer()) and board.getCurIndex () == 17 then
                    call board.display(false)
                    call setCurrentMultiboard(GetTriggerPlayer(),getMainMultiboard(GetTriggerPlayer()))
                    call getCurrentMultiboard(GetTriggerPlayer()).display(true) 
                elseif getCurrentMultiboard(GetTriggerPlayer()) == getInventoryMultiboard(GetTriggerPlayer()) and board.getCurIndex () != 17 then
                    call board.showItem(true,false,19,1)
                    call board.setItemWidth(0.10,19,1)
                    call board.setText("|cff505050No Item|r",19,1)                
                endif
            endif
        endif
    endif
endfunction

private function init takes nothing returns nothing
    local trigger press = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerKeyEventBJ(press, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
        set i = i + 1
        exitwhen i >= 6
    endloop
    call TriggerAddAction(press,function pressActionDown)
    set i = 0
    set press = CreateTrigger()
    loop
        call TriggerRegisterPlayerKeyEventBJ(press, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
        set i = i + 1
        exitwhen i >= 6
    endloop
    call TriggerAddAction(press,function pressActionUp)
    set i = 0
    set press = CreateTrigger()
    loop
        call TriggerRegisterPlayerEventEndCinematic(press, Player(i))
        set i = i + 1
        exitwhen i >= 6
    endloop
    call TriggerAddAction(press,function pressActionEsc)
    set i = 0
    set press = CreateTrigger()
    loop
        call TriggerRegisterPlayerKeyEventBJ(press, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
        set i = i + 1
        exitwhen i >= 6
    endloop    
    call TriggerAddAction(press,function pressActionRight)
    set i = 0
    set press = CreateTrigger()
    loop
        call TriggerRegisterPlayerKeyEventBJ(press, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
        set i = i + 1
        exitwhen i >= 6
    endloop    
    call TriggerAddAction(press,function pressActionLeft)    
    set press = null
endfunction
endlibrary
 

Attachments

  • Multiboard System.w3x
    120.3 KB · Views: 67
Level 18
Joined
Jan 21, 2006
Messages
2,552
To be honest if I were going to work on a multiboard inventory system, I would sooner make one from scratch than have to figure out how you are going about it. Your code is unorganized too, absolutely no use of spaces or anything. Its just a big clump of code.
 
Level 16
Joined
Feb 22, 2006
Messages
960
1. it's organized in different libraries / names etc.
2. spaces are used lol... allways! integer bla = 1 + 1 //<<---vars are in this standard pattern
3. if you would look through it you also would figure out which method is used for what
4. there is a testmap with an example oO
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
After reading through it, I would almost find it more useful if it were split into two components. The first component would be a multiboard "system", basically what you've done with your struct Multiboard. The second would be an extension of this Multiboard that uses the dynamic features of the multiboard in order to setup some sort of an inventory.
 
Status
Not open for further replies.
Top