• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Multiboard - Text disappearing

Status
Not open for further replies.
Level 3
Joined
Sep 13, 2008
Messages
63
I created a multiboard which has menus and stuff (uses arrow keys to navigate). My problem is when I change menus text starts to not display for certain rows. During the menu changes the multiboard changes size (rows/columns) and text. Any idea what may be wrong? I can't really post the code because its overly complex and connected to other codes.

Edit: Also, if the board it too small I get text overlapping. And when changing to a smaller multiboard I can still see some text from another menu.
 
Last edited:
Level 18
Joined
Aug 23, 2008
Messages
2,319
If a multiboard is overly complex, you probably did something more complex then necessary. Also I assume 'connected to other codes' means other triggers or variables. Just post your triggers here. If those triggers are also part of the multiboard, please post those too.
 
Level 3
Joined
Sep 13, 2008
Messages
63
I personally think you'll regret this :) If you decide you just don't want to get into it don't feel bad. I think its pretty complex.

JASS:
//ADD: invisible destructables (range, interval, image type)
scope Multiboard initializer Init

globals
    private constant real   KEY_INTERVAL  = .2 //Almost 3 times a sec
    private constant real   KEY_LOOP_WAIT = .5
    private constant string POINTER       = ">>>"
    private multiboard array Multiboard
    private integer array Menu
    private integer array Position
    private boolean array KeyPress[12][4] //false=off; true=on
    private boolean array KeyLoopOn[12]
endglobals

struct Data
    static integer       menusize //Title doesn't count
    static integer array row   [10] //Title doesn't count
    static integer array col   [10] //Title doesn't count
    static string  array title [10] //Title of menu
    static string  array name  [10][10] //What to display in the menu
    static real    array inc   [10][10] //How much to increase/decrease by
    //static real    array min   [10][10]
    //static real    array max   [10][10]
    static method onInit takes nothing returns nothing
        set .menusize = 3
        
        //Main menu
        set .row   [1]    = 1
        set .col   [1]    = 2
        set .title [1]    = "Main Menu"
        set .name  [1][1] = "Use the arrow keys to navagate"

        //Camera Menu
        set .row   [2]    = 6
        set .col   [2]    = 3
        set .title [2]    = "Camera Settings"
        set .name  [2][1] = "Rotation Speed"
        set .inc   [2][1] = .1
        set .name  [2][2] = "Angle of Attack"
        set .inc   [2][2] = 2
        set .name  [2][3] = "Field of View"
        set .inc   [2][3] = 2
        set .name  [2][4] = "Target Distance"
        set .inc   [2][4] = 20
        set .name  [2][5] = "Z Offset"
        set .inc   [2][5] = 2
        set .name  [2][6] = "Far Z"
        set .inc   [2][6] = 50
        
        //Invisible Destructables
        set .row   [3]    = 2
        set .col   [3]    = 3
        set .title [3]    = "Invisible Trees"
        set .name  [3][1] = "Radius"
        set .inc   [3][1] = 10
        set .name  [3][2] = "Image"
        set .inc   [3][2] = 1
    endmethod
    
    //Can this be moved into the original function itself?
    static method Set takes integer id, integer k returns nothing
        local integer p = Position[id] //+1
        if Menu[id] == 2 then
            if p == 0 then
                set Camera_Data.D[id].rotationspeed = Camera_Data.D[id].rotationspeed + .inc[2][1]*k
            elseif p == 1 then
                set Camera_Data.D[id].aoa = Camera_Data.D[id].aoa + .inc[2][2]*k
            elseif p == 2 then
                set Camera_Data.D[id].fov = Camera_Data.D[id].fov + .inc[2][3]*k
            elseif p == 3 then
                set Camera_Data.D[id].targetdistance = Camera_Data.D[id].targetdistance + .inc[2][4]*k
            elseif p == 4 then
                set Camera_Data.D[id].zoffset = Camera_Data.D[id].zoffset + .inc[2][5]*k
            elseif p == 5 then
                set Camera_Data.D[id].farz = Camera_Data.D[id].farz + .inc[2][6]*k
            endif
        elseif Menu[id] == 3 then
            if p == 0 then
                set InvisibleDestructables_Radius[id] = InvisibleDestructables_Radius[id] + .inc[3][1]*k
            elseif p == 1 then
                set InvisibleDestructables_WhichImage[id] = InvisibleDestructables_WhichImage[id] + k
            endif
        endif
    endmethod
    
    //A seperate function because the values (reals) can change and need to be updated
    static method Get takes integer id, integer m, integer p returns string
        local real r
        if m == 2 then
            if p == 1 then
                set r = Camera_Data.D[id].rotationspeed
            elseif p == 2 then
                set r = Camera_Data.D[id].aoa
            elseif p == 3 then
                set r = Camera_Data.D[id].fov
            elseif p == 4 then
                set r = Camera_Data.D[id].targetdistance
            elseif p == 5 then
                set r = Camera_Data.D[id].zoffset
            elseif p == 6 then
                set r = Camera_Data.D[id].farz
            endif
        elseif m == 3 then
            if p == 1 then
                set r = InvisibleDestructables_Radius[id]
            elseif p == 2 then
                set r = InvisibleDestructables_WhichImage[id]
            endif
        endif    
        if r != null then
            return R2S(r)
        else
            return "null"
        endif
    endmethod
    
    //Updates everything on the board
    static method FullUpdate takes integer id returns nothing
        local integer row = 0 //Top/Bottom
        local multiboard mb = Multiboard[id]
        local multiboarditem mi1
        local multiboarditem mi2
        local multiboarditem mi3
        //Resize multiboard
        call MultiboardSetRowCount(mb, .row[Menu[id]])
        call MultiboardSetColumnCount(mb, .col[Menu[id]])
        //The board
        if .col[Menu[id]] == 2 then
            loop
                set mi1 = MultiboardGetItem(mb, row, 0)
                call MultiboardSetItemStyle(mi1, true, false)
                call MultiboardSetItemValue(mi1, "")
                call MultiboardSetItemWidth(mi1, 0.01)
                set mi2 = MultiboardGetItem(mb, row, 1)
                call MultiboardSetItemStyle(mi2, true, false)
                call MultiboardSetItemValue(mi2, .name[Menu[id]][row+1])
                call MultiboardSetItemWidth(mi2, 0.17)
                set mi3 = MultiboardGetItem(mb, row, 2)
                call MultiboardSetItemStyle(mi3, false, false)
                call MultiboardSetItemValue(mi3, "")
                call MultiboardSetItemWidth(mi3, 0)
                set row = row + 1
                exitwhen row == .row[Menu[id]]
            endloop
        elseif .col[Menu[id]] == 3 then
            loop
                set mi1 = MultiboardGetItem(mb, row, 0)
                set mi2 = MultiboardGetItem(mb, row, 1)
                set mi3 = MultiboardGetItem(mb, row, 2)
                call MultiboardSetItemWidth(mi1, 0.03)
                call MultiboardSetItemWidth(mi2, 0.10)
                call MultiboardSetItemWidth(mi3, 0.05)
                call MultiboardSetItemStyle(mi1, true, false)
                call MultiboardSetItemStyle(mi2, true, false)
                call MultiboardSetItemStyle(mi3, true, false)
                call MultiboardSetItemValue(mi1, "")
                call MultiboardSetItemValue(mi2, .name[Menu[id]][row+1])
                call MultiboardSetItemValue(mi3, .Get(id, Menu[id], row+1))
                set row = row + 1
                exitwhen row == .row[Menu[id]]
            endloop
        endif
        //The title and Pointer
        if Position[id] == -1 then
            if Menu[id] == 1 then
                call MultiboardSetTitleText(mb, "    " + .title[Menu[id]] + " >>>")
            elseif Menu[id] == .menusize then
                call MultiboardSetTitleText(mb, "<<< " + .title[Menu[id]] + "    ")
            else
                call MultiboardSetTitleText(mb, "<<< " + .title[Menu[id]] + " >>>")
            endif
        else
            call MultiboardSetTitleText(mb, "     " + .title[Menu[id]] + "     ")
            call MultiboardSetItemValue(MultiboardGetItem(mb, Position[id], 0), POINTER)
        endif
    endmethod
    
endstruct

//========================================================================================
//Arrow keys
//========================================================================================

//For holding down the key (There has to be a better way to do this)
private function KeyLoop takes nothing returns nothing
    local integer id = 0
    local integer i
    loop
        set i = 0
        if KeyPress[id][1] then
            set i = i + 1
        endif
        if KeyPress[id][2] then
            set i = i + 1
        endif
        if KeyPress[id][3] then
            set i = i + 1
        endif
        if KeyPress[id][4] then
            set i = i + 1
        endif
        if i >= 2 then
            //Do Nothing
        else
            if KeyPress[id][1] then
                if Menu[id] == 1 and Position[id] == -1 then
                    //Do nothing
                elseif Menu[id] > 1 and Position[id] == -1 then
                    set Menu[id] = Menu[id] - 1
                    call Data.FullUpdate(id)
                else
                    call Data.Set(id, -1)
                    call Data.FullUpdate(id)
                endif
            endif
            if KeyPress[id][2] then
                if Menu[id] == Data.menusize and Position[id] == -1 then
                    //Do nothing
                elseif Menu[id] < Data.menusize and Position[id] == -1 then
                    set Menu[id] = Menu[id] + 1
                    call Data.FullUpdate(id)
                else
                    call Data.Set(id, 1)
                    call Data.FullUpdate(id)
                endif
            endif
            if KeyPress[id][3] then
                if Position[id] == Data.row[Menu[id]]-1 then
                    //Do nothing
                else
                    set Position[id] = Position[id] + 1
                    call Data.FullUpdate(id)
                endif
            endif
            if KeyPress[id][4] then
                if Position[id] == -1 then
                    //Do nothing
                else
                    set Position[id] = Position[id] - 1
                    call Data.FullUpdate(id)
                endif
            endif
        endif
        set id = id + 1
        exitwhen id == 12
    endloop
endfunction

//For pressing the key fast
private function QuickKey takes integer id, integer key returns nothing
    local integer i = 0
    if KeyPress[id][1] then
        set i = i + 1
    endif
    if KeyPress[id][2] then
        set i = i + 1
    endif
    if KeyPress[id][3] then
        set i = i + 1
    endif
    if KeyPress[id][4] then
        set i = i + 1
    endif
    if not (i >= 2) then
        if key == 1 then
            if Menu[id] == 1 and Position[id] == -1 then
                //Do nothing
            elseif Menu[id] > 1 and Position[id] == -1 then
                set Menu[id] = Menu[id] - 1
                call Data.FullUpdate(id)
            else
                call Data.Set(id, -1)
                call Data.FullUpdate(id)
            endif
        endif
        if key == 2 then
            if Menu[id] == Data.menusize and Position[id] == -1 then
                //Do nothing
            elseif Menu[id] < Data.menusize and Position[id] == -1 then
                set Menu[id] = Menu[id] + 1
                call Data.FullUpdate(id)
            else
                call Data.Set(id, 1)
                call Data.FullUpdate(id)
            endif
        endif
        if key == 3 then
            if Position[id] == Data.row[Menu[id]]-1 then
                //Do nothing
            else
                set Position[id] = Position[id] + 1
                call Data.FullUpdate(id)
            endif
        endif
        if key == 4 then
            if Position[id] == -1 then
                //Do nothing
            else
                set Position[id] = Position[id] - 1
                call Data.FullUpdate(id)
            endif
        endif
    endif
endfunction

private function Down_Left takes nothing returns nothing
    call QuickKey(GetPlayerId(GetTriggerPlayer()), 1)
    set KeyPress[GetPlayerId(GetTriggerPlayer())][1] = true
endfunction

private function Down_Right takes nothing returns nothing
    call QuickKey(GetPlayerId(GetTriggerPlayer()), 2)
    set KeyPress[GetPlayerId(GetTriggerPlayer())][2] = true
endfunction

private function Down_Down takes nothing returns nothing
    call QuickKey(GetPlayerId(GetTriggerPlayer()), 3)
    set KeyPress[GetPlayerId(GetTriggerPlayer())][3] = true
endfunction

private function Down_Up takes nothing returns nothing
    call QuickKey(GetPlayerId(GetTriggerPlayer()), 4)
    set KeyPress[GetPlayerId(GetTriggerPlayer())][4] = true
endfunction

private function Up_Left takes nothing returns nothing
    set KeyPress[GetPlayerId(GetTriggerPlayer())][1] = false
endfunction

private function Up_Right takes nothing returns nothing
    set KeyPress[GetPlayerId(GetTriggerPlayer())][2] = false
endfunction

private function Up_Down takes nothing returns nothing
    set KeyPress[GetPlayerId(GetTriggerPlayer())][3] = false
endfunction

private function Up_Up takes nothing returns nothing
    set KeyPress[GetPlayerId(GetTriggerPlayer())][4] = false
endfunction
//========================================================================================
//Setup
//========================================================================================
private function BoardOn takes nothing returns nothing
    local integer id = 0
    loop
        set Multiboard[id] = CreateMultiboard()
        set Menu[id] = 1
        set Position[id] = -1
        set KeyLoopOn[id] = false
        call Data.FullUpdate(id)
        //Different people, different boards
        if GetLocalPlayer() == Player(id) then
            call MultiboardMinimize(Multiboard[id], false)
            call MultiboardDisplay(Multiboard[id], true)
        endif
        set id = id + 1
        exitwhen id == 12
    endloop
endfunction

private function Init takes nothing returns nothing
    local trigger t1 = CreateTrigger()
    local trigger t2 = CreateTrigger()
    local trigger t3 = CreateTrigger()
    local trigger t4 = CreateTrigger()
    local trigger t5 = CreateTrigger()
    local trigger t6 = CreateTrigger()
    local trigger t7 = CreateTrigger()
    local trigger t8 = CreateTrigger()
    local trigger t9 = CreateTrigger()
    local integer id = 0
    loop
        if GetPlayerController(Player(id)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then            
            //Pressing the key down
            call TriggerRegisterPlayerEvent(t1, Player(id), EVENT_PLAYER_ARROW_LEFT_DOWN)
            call TriggerRegisterPlayerEvent(t2, Player(id), EVENT_PLAYER_ARROW_RIGHT_DOWN)
            call TriggerRegisterPlayerEvent(t3, Player(id), EVENT_PLAYER_ARROW_DOWN_DOWN)
            call TriggerRegisterPlayerEvent(t4, Player(id), EVENT_PLAYER_ARROW_UP_DOWN)
            //Letting go of the key
            call TriggerRegisterPlayerEvent(t5, Player(id), EVENT_PLAYER_ARROW_LEFT_UP)
            call TriggerRegisterPlayerEvent(t6, Player(id), EVENT_PLAYER_ARROW_RIGHT_UP)
            call TriggerRegisterPlayerEvent(t7, Player(id), EVENT_PLAYER_ARROW_DOWN_UP)
            call TriggerRegisterPlayerEvent(t8, Player(id), EVENT_PLAYER_ARROW_UP_UP)
        endif
        set KeyPress[id][1] = false
        set KeyPress[id][2] = false
        set KeyPress[id][3] = false
        set KeyPress[id][4] = false
        set id = id + 1
        exitwhen id == 12
    endloop
    call TriggerAddAction(t1, function Down_Left)
    call TriggerAddAction(t2, function Down_Right)
    call TriggerAddAction(t3, function Down_Down)
    call TriggerAddAction(t4, function Down_Up)
    call TriggerAddAction(t5, function Up_Left)
    call TriggerAddAction(t6, function Up_Right)
    call TriggerAddAction(t7, function Up_Down)
    call TriggerAddAction(t8, function Up_Up)
    
    call TriggerRegisterTimerEvent(t9, .01, false)
    call TriggerAddAction(t9, function BoardOn)
    
    call TimerStart(CreateTimer(), KEY_INTERVAL, true, function KeyLoop)
endfunction

endscope

JASS:
scope Camera

globals
    private constant real    CAMERA_UPDATE_INTERVAL = .1
    private constant integer UID = 'hfoo'
endglobals

public struct Data
    static Data array D[12]
    
    //Camera
    static timer tim1 = CreateTimer()
    integer id
    unit follow
    boolean rotation    = true
    real rotationspeed  = 2
    real aoa            = 340
    real fov            = 40
    real targetdistance = 1000
    real zoffset        = 175
    real farz           = 5000
    
    //Rotation
    timer tim = CreateTimer()
    real interval = 2
    
    //========================================================================================
    //Updates the players camera
    //========================================================================================
    static method UpdateCamera takes nothing returns nothing
        local integer id = 0
        loop
            if GetPlayerController(Player(id)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING and GetLocalPlayer() == Player(id) then
                call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, .D[id].targetdistance, .5)
                call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, .D[id].aoa, .5)
                call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, .D[id].fov, .5)
                call SetCameraField(CAMERA_FIELD_ZOFFSET, .D[id].zoffset, .5)
                call SetCameraField(CAMERA_FIELD_FARZ, .D[id].farz, .5)
                call SetCameraTargetController(.D[id].follow, 0, 0, false)
            endif
            set id = id + 1
            exitwhen id == 12
        endloop
    endmethod
    
    static method UpdateRotation takes nothing returns nothing
        local integer id = 0
        call BJDebugMsg("1")
        loop
            set id = id + 1
            exitwhen GetExpiredTimer() == .D[id].tim
        endloop
        call BJDebugMsg("2")
        if GetPlayerController(Player(id)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING and GetLocalPlayer() == Player(id) then
            if .D[id].rotation then //Rotates w/ unit or no rotation (top-down view)
                call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(.D[id].follow), .D[id].rotationspeed)
            else
                call SetCameraField(CAMERA_FIELD_ROTATION, 90, 0)
            endif
        endif
        call BJDebugMsg("3")
        call TimerStart(.D[id].tim, .D[id].interval, false, function Data.UpdateRotation)
    endmethod
    
    //========================================================================================
    //SETUP - units, structs, timers.
    //========================================================================================
    static method Setup takes nothing returns nothing
        local integer id = 0
        loop
            if GetPlayerController(Player(id)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
                set .D[id] = Data.create()
                set .D[id].follow = CreateUnit(Player(id), UID, 0, 0, 0)
                set .D[id].id = id
                call TimerStart(.D[id].tim, .D[id].interval, false, function Data.UpdateRotation)
            endif
            set id = id + 1
            exitwhen id == 12
        endloop
        call TimerStart(.tim1, CAMERA_UPDATE_INTERVAL, true, function Data.UpdateCamera)
    endmethod
    
    static method onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer id = 0
        loop
            if GetPlayerController(Player(id)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then

            else
                set .D[id] = 0
            endif
            set id = id + 1
            exitwhen id == 12
        endloop
        call TriggerRegisterTimerEvent(t, 1, false)
        call TriggerAddAction(t, function Data.Setup)
    endmethod
endstruct

endscope

JASS:
scope InvisibleDestructables initializer Init

globals
    private constant real      INTERVAL = .5
    public  real         array Radius[12] //*
    public  integer      array WhichImage[12] //*
    private string       array Image[10]
    private timer              Tim = CreateTimer()
    private integer            Index  = 0
    private destructable array Dest  [12][810]
    private effect       array Effect[12][810]
    private destructable array Filtergroup
endglobals

private function Conditions takes nothing returns boolean
    local integer i = 0
    local integer did = GetDestructableTypeId(GetFilterDestructable()) //Should I use GetFilterDestructable() instead?
    loop
        set i = i + 1
        exitwhen did == ESDestructable_Code[i] or i == ESDestructable_End
    endloop
    return ESDestructable_Transparent[i] == true
endfunction

private function Actions takes nothing returns nothing
    set Index = Index + 1
    set Filtergroup[Index] = GetEnumDestructable()
endfunction

private function UpdateDestructable takes nothing returns nothing
    local integer id = 0
    local integer i = 0
    local real x
    local real y
    local rect r
    loop
        if GetPlayerController(Player(id)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
            set i = 0
            loop
                set i = i + 1
                exitwhen Dest[id][i] == null or i == 810
                call DestroyEffect(Effect[id][i])
                set Effect[id][i] = null
                call ShowDestructable(Dest[id][i], true)
                set Dest[id][i] = null
            endloop
            //Finds certain destructables and makes them invisible
            set Index = 0
            set x = GetUnitX(Camera_Data.D[id].follow)-128*Cos(GetUnitFacing(Camera_Data.D[id].follow)*(3.14159/180.0))
            set y = GetUnitY(Camera_Data.D[id].follow)-128*Sin(GetUnitFacing(Camera_Data.D[id].follow)*(3.14159/180.0))
            set r = Rect(x-Radius[id], y-Radius[id], x+Radius[id], y+Radius[id])
            call EnumDestructablesInRect(r, Condition(function Conditions), function Actions)
            call RemoveRect(r)
            set r = null
            set i = 0
            loop
                exitwhen i == Index
                set i = i + 1
                set Dest[id][i] = Filtergroup[i]
                set Filtergroup[i] = null
                call ShowDestructable(Dest[id][i], false)
                //if GetLocalPlayer() == Player(id) then
                    set Effect[id][i] = AddSpecialEffect(Image[WhichImage[id]], GetDestructableX(Dest[id][i]), GetDestructableY(Dest[id][i]))
                //endif
            endloop
        endif
        set id = id + 1
        exitwhen id == 12
    endloop
    call TimerStart(Tim, INTERVAL, false, function UpdateDestructable)
endfunction

private function Timers takes nothing returns nothing
    call TimerStart(Tim, INTERVAL, false, function UpdateDestructable)
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer id = 0
    loop
        set Radius[id] = 500
        set WhichImage[id] = 6
        set id = id + 1
        exitwhen id == 12
    endloop
    call TriggerRegisterTimerEvent(t, 1, false)
    call TriggerAddAction(t, function Timers)
    set Image[1] = "UI\\Feedback\\SelectionCircleEnemy\\SelectionCircleEnemy.mdx"
    set Image[2] = "UI\\Feedback\\SelectionCircleHero\\SelectionCircleHero.mdx"
    set Image[3] = "UI\\Feedback\\SelectionCircleUnit\\SelectionCircleUnit.mdx"
    set Image[4] = "UI\\Feedback\\TargetPreSelected\\TargetPreSelected.mdl"
    set Image[5] = "UI\\Feedback\\Target\\Target.mdl"
    set Image[6] = "UI\\Feedback\\SelectionCircle\\SelectionCircle.mdl"
endfunction

endscope
 

Attachments

  • Demo v0.30 (basic).w3x
    36 KB · Views: 45
Status
Not open for further replies.
Top