1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[vJASS] Stuck on this UI system. It just acts goofy and I don't see how

Discussion in 'Triggers & Scripts' started by Sephalo, Aug 21, 2015.

  1. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    Hey there.

    I'm working on an interface system for my map. In the map players have a deck with 40 cards, and in this interface they will be able to see this deck. I added 40 random cards to it, and with the buttons you'll be able to move around in the menu. There's just one problem: if I press the DOWN button (at around 0:10 of the example movie) the selection moves to the top of the interface, while it should actually go to the bottom.
    It would be really great if someone would know what causes this. I have a feeling there's something buggy about the rects I placed. I think something moves/swaps them around as soon as the game begins.

    I'll post the entire (unfinished) code here for people to see what I wrote down. I checked this 5 times now and didn't find any mistakes in the code.
    I also checked all the rects I'm using to see if they're placed at the right spots, but I'm 100% sure they are. Here's a screenshot of the rects to show how it looks like. Just believe me on this one that they're placed correctly.
    (I named them X#Y# to have an easy understanding of where they are)

    Screenshot of Rects
    [​IMG]


    Code
    Code (vJASS):
    library InterfaceMenu initializer init requires ButtonIndexing, SpaceHandlerLocal, StartingDeck, Indexing

        globals
           
            private timer Periodic = CreateTimer()
           
            rect array UI[13][8]
           
            ///PlayerVariables
            integer array       MSX[1] ///Menu Selection X
            integer array       MSY[1]
            integer array       MPX[1] ///Menu 'P'ressed X ///P stands for Pressed, as in the pressed button's coördinate
            integer array       MPY[1]
            boolean array       Hold[1] ///If a button is on hold
            destructable array  Selecter[1]
            destructable array  Holder[1]
            destructable array  Button[9]
                                /// Button 0 = Remove Button (middle)
                                /// Button 1 = Cancel Button (middle)
                                /// Button 2 = UI BTN Button Remove Button (top left)
                                /// Button 3 = UI DISBTN Button Remove Button (top left)
                               
            boolean array       InterfaceMode[1]
            string array        InterfaceType[1] ///Every interface 'looks' has its own name
                                /// SHOP
                                /// SHOP_CONFIRM
                                /// DECK
                                /// DECK_CONFIRM
           
           
            destructable array PopupButton[12]
            destructable array DeckButton_BTN[40]
            destructable array DeckButton_DISBTN[40]
           
           
            ///constant integers
            private integer SelecterId = 'B01L'
            private integer BORDER_U =  'BOR1'
            private integer BORDER_UR = 'BOR2'
            private integer BORDER_R =  'BOR3'
            private integer BORDER_DR = 'BOR4'
            private integer BORDER_D =  'BOR5'
            private integer BORDER_DL = 'BOR6'
            private integer BORDER_L =  'BOR7'
            private integer BORDER_UL = 'BOR8'
           
            private integer BTNRemove = 'B012'
            private integer DISBTNRemove = 'B013'
            private integer BTNCancel = 'B00X'
            private integer DISBTNCancel = 'B00Y'
           

        endglobals

    function GetIconDISBTN takes integer Icon returns integer
      local integer i = MaxIcons

        loop
        exitwhen BTNIcon[i] == Icon or i == 0
            set i = i - 1
        endloop
       
    return DISBTNIcon[i]
    endfunction

    private function Camera takes nothing returns nothing /// Locks the camera during interface mode
        local integer i = 0
       
        loop
        exitwhen i > 1
            if InterfaceMode[i] then
                call CameraSetupApplyForPlayer(true, gg_cam_Camera_002, Player(i), 0)
            endif
            set i = i + 1
        endloop
    endfunction

    private function CreateSelecter takes integer i, integer x, integer y returns nothing
        call RemoveDestructable(Selecter[i])
        set Selecter[i] = CreateDestructable('B01L', GetRectCenterX(UI[x][y]), GetRectCenterY(UI[x][y]), 180., 0.75, 1)
    endfunction

    private function CreateHolder takes integer i, integer x, integer y returns nothing
        call RemoveDestructable(Holder[i])
        set Holder[i] = CreateDestructable('B01L', GetRectCenterX(UI[x][y]), GetRectCenterY(UI[x][y]), 180., 0.75, 1)
    endfunction

    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////// ALL BUTTONS ///////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////

    private function SpacePressed takes nothing returns nothing
        local player p = GetTriggerPlayer()
        local integer i = GetPlayerId(p)
        local destructable BTN
        local destructable DISBTN
        local integer c = 1
       
        if InterfaceMode[i] then
            if InterfaceType[i] == "DECK" then
                if MSX[i] > 1 and MSX[i] < 10 and MSY[i] > 1 and MSY[i] < 7 then ///Somewere in the deck
                    if Hold[i] then
                        set Hold[i] = false
                        call RemoveDestructable(Holder[i])
                        ///Swap deck items ///
                    else
                        set MPX[i] = MSX[i]
                        set MPY[i] = MPY[i]
                        call CreateHolder(i, MPX[i], MPY[i])
                        set Hold[i] = true
                    endif
                elseif MSX[i] == 11 and MSY[i] == 8 and Hold[i] then ///Remove Button
                    set InterfaceType[i] = "DECK_REMOVE"
                   
                    if p == GetLocalPlayer() then
                        call ShowDestructable(Button[0], true)
                        call ShowDestructable(Button[1], true)
                        call ShowDestructable(Button[2], false)
                        call ShowDestructable(Button[3], true)
                    endif
                   
                    set MSX[i] = 8
                    set MSY[i] = 3
                    call CreateSelecter(i, MSX[i], MSY[i])
                    set Hold[i] = false
                    call RemoveDestructable(Holder[i])
           
                    loop ///This loop shows the DISBTN's of buttons and hides those that are under the menu
                    exitwhen c > 40
                        set BTN = DeckButton_BTN[i]
                        set DISBTN = DeckButton_DISBTN[i]
                       
                        call ShowDestructable(BTN, false)
                        if c != 22 and c != 23 and c != 24 and c != 27 and c != 28 and c != 29 and c != 32 and c != 33 and c != 34 then
                            call ShowDestructable(DISBTN, true)
                        endif
                        if c < 14 then
                            call ShowDestructable(PopupButton[c-1], true)
                        endif
                    set c = c + 1
                    endloop
                endif
            elseif InterfaceType[i] == "DECK_REMOVE" then
                set InterfaceType[i] = "DECK"
                if MSX[i] == 6 and MSY[i] == 3 then ///confirm remove
                    ///Remove the item
                    set MSX[i] = MPX[i]
                    set MSY[i] = MPY[i]
                    call CreateSelecter(i, MSX[i], MSY[i])
                elseif MSX[i] == 8 and MSY[i] == 3 then ///cancel remove
                    set Hold[i] = true
                    call CreateHolder(i, MPX[i], MPY[i])
                    set MSX[i] = 11
                    set MSY[i] = 8
                    call CreateSelecter(i, MSX[i], MSY[i])
                endif
                set c = 1
                loop /// Loop shows all the buttons again and hides the popup
                exitwhen c > 40
                    set BTN = DeckButton_BTN[c]
                    set DISBTN = DeckButton_DISBTN[c]
                   
                    call ShowDestructable(BTN, true)
                    call ShowDestructable(DISBTN, false)
                    if c < 14 then
                        call ShowDestructable(PopupButton[c-1], false)
                    endif
                set c = c + 1
                endloop
               
                if p == GetLocalPlayer() then
                    call ShowDestructable(Button[0], false)
                    call ShowDestructable(Button[1], false)
                    call ShowDestructable(Button[2], true)
                    call ShowDestructable(Button[3], false)
                endif
           
            endif
        endif

    endfunction

    private function PressUp takes nothing returns nothing
        local player p = GetTriggerPlayer()
        local integer i = GetPlayerId(p)
        if InterfaceMode[i] then
            if InterfaceType[i] == "DECK" then
                if MSY[i] < 6 and MSY[i] > 1 and MSX[i] < 10 and MSX[i] > 1 then ///ONE DOWN
                    set MSY[i] = MSY[i] + 1
                elseif MSY[i] == 6 then ///TO UPPER RIGHT
                    set MSY[i] = 8
                    set MSX[i] = 11
                elseif MSY[i] == 0 and MSX[i] > 1 and MSX[i] < 10 then ///TWO UP
                    set MSY[i] = MSY[i] + 2
                elseif MSY[i] == 0 and MSX[i] < 2 then /// TO BOTTOM LEFT OF DECK
                    set MSY[i] = 2
                    set MSX[i] = 2
                elseif MSY[i] == 0 and MSX[i] > 9 then
                    set MSY[i] = 8
                    set MSX[i] = 13
                endif
                call CreateSelecter(i, MSX[i], MSY[i])
            endif
        endif
        set p = null
    endfunction

    private function PressDown takes nothing returns nothing
        local player p = GetTriggerPlayer()
        local integer i = GetPlayerId(p)
        if InterfaceMode[i] then
            if InterfaceType[i] == "DECK" then
                if MSY[i] > 2 and MSY[i] < 7 and MSX[i] > 1 and MSX[i] < 10 then ///ONE DOWN
                    set MSY[i] = MSY[i] - 1
                elseif MSY[i] == 2 and MSX[i] < 4 then
                    set MSY[i] = 0
                    set MSX[i] = 2
                elseif MSY[i] == 2 and (MSX[i] == 5 or MSX[i] == 4) then
                    set MSY[i] = 0
                    set MSX[i] = 4
                elseif MSY[i] == 2 and MSX[i] < 10 and MSX[i] > 5 then
                    set MSY[i] = 0
                    set MSX[i] = 6
                elseif MSY[i] > 6 then
                    set MSY[i] = 6
                    set MSX[i] = 9
                endif
                call CreateSelecter(i, MSX[i], MSY[i])
            endif
        endif
        set p = null
    endfunction

    private function PressRight takes nothing returns nothing
        local player p = GetTriggerPlayer()
        local integer i = GetPlayerId(p)
        if InterfaceMode[i] then
            if InterfaceType[i] == "DECK" then
                if MSY[i] > 1 and MSY[i] < 7 and MSX[i] < 9 then ///ONE RIGHT
                    set MSX[i] = MSX[i] + 1
                elseif (MSY[i] == 0 and MSX[i] < 5) or (MSX[i] == 11 and MSY[i] == 8) then
                    set MSX[i] = MSX[i] + 2
                elseif MSY[i] == 0 and MSX[i] == 6 then
                    set MSX[i] = 13
                elseif MSY[i] > 3 and MSY[i] < 7 and MSX[i] == 9 then
                    set MSX[i] = 11
                    set MSY[i] = 8
                elseif MSY[i] < 4 and MSY[i] > 1 and MSX[i] == 9 then
                    set MSX[i] = 13
                    set MSY[i] = 0
                endif
                call CreateSelecter(i, MSX[i], MSY[i])
            endif
        endif
        set p = null
    endfunction

    private function PressLeft takes nothing returns nothing
        local player p = GetTriggerPlayer()
        local integer i = GetPlayerId(p)
        if InterfaceMode[i] then
            if InterfaceType[i] == "DECK" then
                if MSY[i] > 1 and MSY[i] < 7 and MSX[i] > 2 and MSX[i] < 10 then ///ONE LEFT
                    set MSX[i] = MSX[i] - 1
                elseif (MSY[i] == 0 and MSX[i] > 1 and MSX[i] < 7) or (MSX[i] == 13 and MSY[i] == 8) then
                    set MSX[i] = MSX[i] - 2
                elseif MSY[i] == 0 and MSX[i] == 13 then
                    set MSX[i] = 6
                elseif MSY[i] == 8 and MSX[i] == 11 then
                    set MSX[i] = 9
                    set MSY[i] = 6
                endif
                call CreateSelecter(i, MSX[i], MSY[i])
            endif
        endif
        set p = null
    endfunction

    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////// INITIALIZATION ////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////

    private function init takes nothing returns nothing
        local integer i = 1
        local integer c = 0
        local trigger t
        local player p
        local integer x = 2
        local integer y = 6

        call TimerStart(Periodic, 0.01, true, function Camera)

        set UI[0][0] = gg_rct_X0Y0
        set UI[1][0] = gg_rct_X1Y0
        set UI[2][0] = gg_rct_X2Y0
        set UI[3][0] = gg_rct_X3Y0
        set UI[4][0] = gg_rct_X4Y0
        set UI[5][0] = gg_rct_X5Y0
        set UI[6][0] = gg_rct_X6Y0
        set UI[7][0] = gg_rct_X7Y0
        set UI[8][0] = gg_rct_X8Y0
        set UI[9][0] = gg_rct_X9Y0
        set UI[10][0] = gg_rct_X10Y0
        set UI[11][0] = gg_rct_X11Y0
        set UI[12][0] = gg_rct_X12Y0
        set UI[13][0] = gg_rct_X13Y0
        set UI[0][1] = gg_rct_X0Y1
        set UI[1][1] = gg_rct_X1Y1
        set UI[2][1] = gg_rct_X2Y1
        set UI[3][1] = gg_rct_X3Y1
        set UI[4][1] = gg_rct_X4Y1
        set UI[5][1] = gg_rct_X5Y1
        set UI[6][1] = gg_rct_X6Y1
        set UI[7][1] = gg_rct_X7Y1
        set UI[8][1] = gg_rct_X8Y1
        set UI[9][1] = gg_rct_X9Y1
        set UI[10][1] = gg_rct_X10Y1
        set UI[11][1] = gg_rct_X11Y1
        set UI[12][1] = gg_rct_X12Y1
        set UI[13][1] = gg_rct_X13Y1
        set UI[0][2] = gg_rct_X0Y2
        set UI[1][2] = gg_rct_X1Y2
        set UI[2][2] = gg_rct_X2Y2
        set UI[3][2] = gg_rct_X3Y2
        set UI[4][2] = gg_rct_X4Y2
        set UI[5][2] = gg_rct_X5Y2
        set UI[6][2] = gg_rct_X6Y2
        set UI[7][2] = gg_rct_X7Y2
        set UI[8][2] = gg_rct_X8Y2
        set UI[9][2] = gg_rct_X9Y2
        set UI[10][2] = gg_rct_X10Y2
        set UI[11][2] = gg_rct_X11Y2
        set UI[12][2] = gg_rct_X12Y2
        set UI[13][2] = gg_rct_X13Y2
        set UI[0][3] = gg_rct_X0Y3
        set UI[1][3] = gg_rct_X1Y3
        set UI[2][3] = gg_rct_X2Y3
        set UI[3][3] = gg_rct_X3Y3
        set UI[4][3] = gg_rct_X4Y3
        set UI[5][3] = gg_rct_X5Y3
        set UI[6][3] = gg_rct_X6Y3
        set UI[7][3] = gg_rct_X7Y3
        set UI[8][3] = gg_rct_X8Y3
        set UI[9][3] = gg_rct_X9Y3
        set UI[10][3] = gg_rct_X10Y3
        set UI[11][3] = gg_rct_X11Y3
        set UI[12][3] = gg_rct_X12Y3
        set UI[13][3] = gg_rct_X13Y3
        set UI[0][4] = gg_rct_X0Y4
        set UI[1][4] = gg_rct_X1Y4
        set UI[2][4] = gg_rct_X2Y4
        set UI[3][4] = gg_rct_X3Y4
        set UI[4][4] = gg_rct_X4Y4
        set UI[5][4] = gg_rct_X5Y4
        set UI[6][4] = gg_rct_X6Y4
        set UI[7][4] = gg_rct_X7Y4
        set UI[8][4] = gg_rct_X8Y4
        set UI[9][4] = gg_rct_X9Y4
        set UI[10][4] = gg_rct_X10Y4
        set UI[11][4] = gg_rct_X11Y4
        set UI[12][4] = gg_rct_X12Y4
        set UI[13][4] = gg_rct_X13Y4
        set UI[0][5] = gg_rct_X0Y5
        set UI[1][5] = gg_rct_X1Y5
        set UI[2][5] = gg_rct_X2Y5
        set UI[3][5] = gg_rct_X3Y5
        set UI[4][5] = gg_rct_X4Y5
        set UI[5][5] = gg_rct_X5Y5
        set UI[6][5] = gg_rct_X6Y5
        set UI[7][5] = gg_rct_X7Y5
        set UI[8][5] = gg_rct_X8Y5
        set UI[9][5] = gg_rct_X9Y5
        set UI[10][5] = gg_rct_X10Y5
        set UI[11][5] = gg_rct_X11Y5
        set UI[12][5] = gg_rct_X12Y5
        set UI[13][5] = gg_rct_X13Y5
        set UI[0][6] = gg_rct_X0Y6
        set UI[1][6] = gg_rct_X1Y6
        set UI[2][6] = gg_rct_X2Y6
        set UI[3][6] = gg_rct_X3Y6
        set UI[4][6] = gg_rct_X4Y6
        set UI[5][6] = gg_rct_X5Y6
        set UI[6][6] = gg_rct_X6Y6
        set UI[7][6] = gg_rct_X7Y6
        set UI[8][6] = gg_rct_X8Y6
        set UI[9][6] = gg_rct_X9Y6
        set UI[10][6] = gg_rct_X10Y6
        set UI[11][6] = gg_rct_X11Y6
        set UI[12][6] = gg_rct_X12Y6
        set UI[13][6] = gg_rct_X13Y6
        set UI[0][7] = gg_rct_X0Y7
        set UI[1][7] = gg_rct_X1Y7
        set UI[2][7] = gg_rct_X2Y7
        set UI[3][7] = gg_rct_X3Y7
        set UI[4][7] = gg_rct_X4Y7
        set UI[5][7] = gg_rct_X5Y7
        set UI[6][7] = gg_rct_X6Y7
        set UI[7][7] = gg_rct_X7Y7
        set UI[8][7] = gg_rct_X8Y7
        set UI[9][7] = gg_rct_X9Y7
        set UI[10][7] = gg_rct_X10Y7
        set UI[11][7] = gg_rct_X11Y7
        set UI[12][7] = gg_rct_X12Y7
        set UI[13][7] = gg_rct_X13Y7
        set UI[0][8] = gg_rct_X0Y8
        set UI[1][8] = gg_rct_X1Y8
        set UI[2][8] = gg_rct_X2Y8
        set UI[3][8] = gg_rct_X3Y8
        set UI[4][8] = gg_rct_X4Y8
        set UI[5][8] = gg_rct_X5Y8
        set UI[6][8] = gg_rct_X6Y8
        set UI[7][8] = gg_rct_X7Y8
        set UI[8][8] = gg_rct_X8Y8
        set UI[9][8] = gg_rct_X9Y8
        set UI[10][8] = gg_rct_X10Y8
        set UI[11][8] = gg_rct_X11Y8
        set UI[12][8] = gg_rct_X12Y8
        set UI[13][8] = gg_rct_X13Y8
       
        set MSX[0] = 2
        set MSY[0] = 6
        call CreateSelecter(0, 2, 6)
        ///Button Creation
       
        set Button[0] = CreateDestructable(BTNRemove, GetRectCenterX(UI[6][3]), GetRectCenterY(UI[6][3]), 180., 0.75, 1) ///Middle Remove
        set Button[1] = CreateDestructable(BTNCancel, GetRectCenterX(UI[8][3]), GetRectCenterY(UI[8][3]), 180., 0.75, 1) ///Middle Cancel
        set Button[2] = CreateDestructable(BTNRemove, GetRectCenterX(UI[11][8]), GetRectCenterY(UI[11][8]), 180., 0.75, 1) ///Top Remove BTN
        set Button[3] = CreateDestructable(DISBTNRemove, GetRectCenterX(UI[11][8]), GetRectCenterY(UI[11][8]), 180., 0.75, 1) ///Top Remove DISBTN
        call ShowDestructable(Button[0], false)
        call ShowDestructable(Button[1], false)
        call ShowDestructable(Button[2], false)
        call ShowDestructable(Button[3], false)
       
        set p = Player(0)
        if p == GetLocalPlayer() then
            call ShowDestructable(Button[2], true)
        endif
       
        set PopupButton[0] = CreateDestructable(BORDER_UL, x+64.*4., y-64.*1., 0., 0.65, 1)
        set PopupButton[1] = CreateDestructable(BORDER_U, x+64.*5., y-64.*1., 0., 0.65, 1)
        set PopupButton[2] = CreateDestructable(BORDER_UR, x+64.*6., y-64.*1., 0., 0.65, 1)
        set PopupButton[3] = CreateDestructable(BORDER_L, x+64.*4., y-64.*2., 0., 0.65, 1)
        set PopupButton[4] = CreateDestructable(BORDER_R, x+64.*6., y-64.*2., 0., 0.65, 1)
        set PopupButton[5] = CreateDestructable(BORDER_UR, x+64.*4., y-64.*3., 0., 0.65, 1)
        set PopupButton[6] = CreateDestructable(BORDER_UL, x+64.*4., y-64.*3., 0., 0.65, 1)
        set PopupButton[7] = CreateDestructable(BORDER_DL, x+64.*4., y-64.*3., 0., 0.65, 1)
        set PopupButton[8] = CreateDestructable(BORDER_DR, x+64.*4., y-64.*3., 0., 0.65, 1)
        set PopupButton[9] = CreateDestructable(BORDER_UR, x+64.*6., y-64.*3., 0., 0.65, 1)
        set PopupButton[10] = CreateDestructable(BORDER_UL, x+64.*6., y-64.*3., 0., 0.65, 1)
        set PopupButton[11] = CreateDestructable(BORDER_DL, x+64.*6., y-64.*3., 0., 0.65, 1)
        set PopupButton[12] = CreateDestructable(BORDER_DR, x+64.*6., y-64.*3., 0., 0.65, 1)
       
        loop
        exitwhen c > 12
            call ShowDestructable(PopupButton[c], false)
            set c = c + 1
        endloop
       
        set i = 1
        loop
        exitwhen x > 9
           
            loop
            exitwhen y < 2

                if DeckItem[i][0] != 0 then
                    set DeckButton_BTN[i] = CreateDestructable(Item_IconId[GetItemId(DeckItem[i][0])], GetRectCenterX(UI[x][y]), GetRectCenterY(UI[x][y]), 180., 0.75, 1)
                    set DeckButton_DISBTN[i] = CreateDestructable(GetIconDISBTN(Item_IconId[GetItemId(DeckItem[i][0])]), GetRectCenterX(UI[x][y]), GetRectCenterY(UI[x][y]), 180., 0.75, 1)
                    call ShowDestructable(DeckButton_DISBTN[i], false)
                else
                    set DeckButton_BTN[i] = CreateDestructable('B01J', GetRectCenterX(UI[x][y]), GetRectCenterY(UI[x][y]), 180., 0.75, 1)
                    set DeckButton_DISBTN[i] = CreateDestructable('B01K', GetRectCenterX(UI[x][y]), GetRectCenterY(UI[x][y]), 180., 0.75, 1)
                    call ShowDestructable(DeckButton_DISBTN[i], false)
                endif
                set y = y - 1
                set i = i + 1
            endloop
           
            set x = x + 1
            set y = 6
        endloop
       
        call AddSpacebarAction(function SpacePressed)
        set t = CreateTrigger()
        call TriggerRegisterPlayerKeyEventBJ(t, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT)
        call TriggerAddAction(t, function PressLeft)
        set t = CreateTrigger()
        call TriggerRegisterPlayerKeyEventBJ(t, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT)
        call TriggerAddAction(t, function PressRight)
        set t = CreateTrigger()
        call TriggerRegisterPlayerKeyEventBJ(t, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP)
        call TriggerAddAction(t, function PressUp)
        set t = CreateTrigger()
        call TriggerRegisterPlayerKeyEventBJ(t, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN)
        call TriggerAddAction(t, function PressDown)
    endfunction
    endlibrary


    Oh and here's the sample video to see what happens when I'm trying it out ingame. It looks like the Y=0 rects have moved (or swapped place) with the Y=8 line. But in the world editor this didn't happen at all.

    https://www.youtube.com/watch?v=hfCX1v7yWNU&feature=youtu.be
     
  2. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Use a debug message to test whether it is setting the coordinates appropriately. i.e. in PressDown:
    Code (vJASS):
                elseif MSY[i] == 2 and MSX[i] < 4 then
                    call BJDebugMsg("Y = 2, X < 4")
                    set MSY[i] = 0
                    set MSX[i] = 2
                elseif MSY[i] == 2 and (MSX[i] == 5 or MSX[i] == 4) then
                    call BJDebugMsg("Y = 2, X = 4 or 5")
                    set MSY[i] = 0
                    set MSX[i] = 4
                elseif MSY[i] == 2 and MSX[i] < 10 and MSX[i] > 5 then
                    call BJDebugMsg("Y = 2, 5 < X < 10")
                    set MSY[i] = 0
                    set MSX[i] = 6


    Go to the same coordinates as you did in the video and test it out. If none of these messages display, then it is an issue with the MSX or MSY values.

    If the message displays but it still creates a destructable at the wrong coordinate, then it is likely an issue with the CreateSelecter function or the coordinate mapping.
     
  3. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    I did what you suggested and came with the following results.
    It really looks like the rects just move at the start of the game. The line of rects with Y = 0 seems to move 8 blocks up and one block to the left. I have no idea why this is happening, and the rects are really really really placed in the correct way in the World Editor.

    Any idea how I could work around this bug?

    Here's a video where I show what happens. This time with cöordinates displayed every time I press an arrow button.
    https://www.youtube.com/watch?v=vH544od9oOg&feature=youtu.be
     
  4. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,181
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    The video is private.
     
  5. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    It wasn't done uploading yet I guess. It should be displayed correctly now.
     
  6. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    I fixed it.
    I just put all those rects on their spots manually as soon as the game starts. For some reason there was still one rect that just didn't get in place correctly, but that's where the last line is for. It now works properly, altough it might look a bit funky in the code... It works. So I'm happy... Altough I really don't trust rects anymore, they seem to have a will on their own.

    Code (vJASS):
    local integer i = 1
        local integer c = 0
        local trigger t
        local player p
        local integer x = 0
        local integer y = 0

        set UI[0][0] = gg_rct_X0Y0
        set UI[1][0] = gg_rct_X1Y0
        set UI[2][0] = gg_rct_X2Y0
        set UI[3][0] = gg_rct_X3Y0
        set UI[4][0] = gg_rct_X4Y0
        set UI[5][0] = gg_rct_X5Y0
        set UI[6][0] = gg_rct_X6Y0
        set UI[7][0] = gg_rct_X7Y0
        set UI[8][0] = gg_rct_X8Y0
        set UI[9][0] = gg_rct_X9Y0
        set UI[10][0] = gg_rct_X10Y0
        set UI[11][0] = gg_rct_X11Y0
        set UI[12][0] = gg_rct_X12Y0
        set UI[13][0] = gg_rct_X13Y0
        set UI[0][1] = gg_rct_X0Y1
        set UI[1][1] = gg_rct_X1Y1
        set UI[2][1] = gg_rct_X2Y1
        set UI[3][1] = gg_rct_X3Y1
        set UI[4][1] = gg_rct_X4Y1
        set UI[5][1] = gg_rct_X5Y1
        set UI[6][1] = gg_rct_X6Y1
        set UI[7][1] = gg_rct_X7Y1
        set UI[8][1] = gg_rct_X8Y1
        set UI[9][1] = gg_rct_X9Y1
        set UI[10][1] = gg_rct_X10Y1
        set UI[11][1] = gg_rct_X11Y1
        set UI[12][1] = gg_rct_X12Y1
        set UI[13][1] = gg_rct_X13Y1
        set UI[0][2] = gg_rct_X0Y2
        set UI[1][2] = gg_rct_X1Y2
        set UI[2][2] = gg_rct_X2Y2
        set UI[3][2] = gg_rct_X3Y2
        set UI[4][2] = gg_rct_X4Y2
        set UI[5][2] = gg_rct_X5Y2
        set UI[6][2] = gg_rct_X6Y2
        set UI[7][2] = gg_rct_X7Y2
        set UI[8][2] = gg_rct_X8Y2
        set UI[9][2] = gg_rct_X9Y2
        set UI[10][2] = gg_rct_X10Y2
        set UI[11][2] = gg_rct_X11Y2
        set UI[12][2] = gg_rct_X12Y2
        set UI[13][2] = gg_rct_X13Y2
        set UI[0][3] = gg_rct_X0Y3
        set UI[1][3] = gg_rct_X1Y3
        set UI[2][3] = gg_rct_X2Y3
        set UI[3][3] = gg_rct_X3Y3
        set UI[4][3] = gg_rct_X4Y3
        set UI[5][3] = gg_rct_X5Y3
        set UI[6][3] = gg_rct_X6Y3
        set UI[7][3] = gg_rct_X7Y3
        set UI[8][3] = gg_rct_X8Y3
        set UI[9][3] = gg_rct_X9Y3
        set UI[10][3] = gg_rct_X10Y3
        set UI[11][3] = gg_rct_X11Y3
        set UI[12][3] = gg_rct_X12Y3
        set UI[13][3] = gg_rct_X13Y3
        set UI[0][4] = gg_rct_X0Y4
        set UI[1][4] = gg_rct_X1Y4
        set UI[2][4] = gg_rct_X2Y4
        set UI[3][4] = gg_rct_X3Y4
        set UI[4][4] = gg_rct_X4Y4
        set UI[5][4] = gg_rct_X5Y4
        set UI[6][4] = gg_rct_X6Y4
        set UI[7][4] = gg_rct_X7Y4
        set UI[8][4] = gg_rct_X8Y4
        set UI[9][4] = gg_rct_X9Y4
        set UI[10][4] = gg_rct_X10Y4
        set UI[11][4] = gg_rct_X11Y4
        set UI[12][4] = gg_rct_X12Y4
        set UI[13][4] = gg_rct_X13Y4
        set UI[0][5] = gg_rct_X0Y5
        set UI[1][5] = gg_rct_X1Y5
        set UI[2][5] = gg_rct_X2Y5
        set UI[3][5] = gg_rct_X3Y5
        set UI[4][5] = gg_rct_X4Y5
        set UI[5][5] = gg_rct_X5Y5
        set UI[6][5] = gg_rct_X6Y5
        set UI[7][5] = gg_rct_X7Y5
        set UI[8][5] = gg_rct_X8Y5
        set UI[9][5] = gg_rct_X9Y5
        set UI[10][5] = gg_rct_X10Y5
        set UI[11][5] = gg_rct_X11Y5
        set UI[12][5] = gg_rct_X12Y5
        set UI[13][5] = gg_rct_X13Y5
        set UI[0][6] = gg_rct_X0Y6
        set UI[1][6] = gg_rct_X1Y6
        set UI[2][6] = gg_rct_X2Y6
        set UI[3][6] = gg_rct_X3Y6
        set UI[4][6] = gg_rct_X4Y6
        set UI[5][6] = gg_rct_X5Y6
        set UI[6][6] = gg_rct_X6Y6
        set UI[7][6] = gg_rct_X7Y6
        set UI[8][6] = gg_rct_X8Y6
        set UI[9][6] = gg_rct_X9Y6
        set UI[10][6] = gg_rct_X10Y6
        set UI[11][6] = gg_rct_X11Y6
        set UI[12][6] = gg_rct_X12Y6
        set UI[13][6] = gg_rct_X13Y6
        set UI[0][7] = gg_rct_X0Y7
        set UI[1][7] = gg_rct_X1Y7
        set UI[2][7] = gg_rct_X2Y7
        set UI[3][7] = gg_rct_X3Y7
        set UI[4][7] = gg_rct_X4Y7
        set UI[5][7] = gg_rct_X5Y7
        set UI[6][7] = gg_rct_X6Y7
        set UI[7][7] = gg_rct_X7Y7
        set UI[8][7] = gg_rct_X8Y7
        set UI[9][7] = gg_rct_X9Y7
        set UI[10][7] = gg_rct_X10Y7
        set UI[11][7] = gg_rct_X11Y7
        set UI[12][7] = gg_rct_X12Y7
        set UI[13][7] = gg_rct_X13Y7
        set UI[0][8] = gg_rct_X0Y8
        set UI[1][8] = gg_rct_X1Y8
        set UI[2][8] = gg_rct_X2Y8
        set UI[3][8] = gg_rct_X3Y8
        set UI[4][8] = gg_rct_X4Y8
        set UI[5][8] = gg_rct_X5Y8
        set UI[6][8] = gg_rct_X6Y8
        set UI[7][8] = gg_rct_X7Y8
        set UI[8][8] = gg_rct_X8Y8
        set UI[9][8] = gg_rct_X9Y8
        set UI[10][8] = gg_rct_X10Y8
        set UI[11][8] = gg_rct_X11Y8
        set UI[12][8] = gg_rct_X12Y8
        set UI[13][8] = gg_rct_X13Y8
       
        loop
        exitwhen x > 13
            loop
            exitwhen y > 8
                call MoveRectTo(UI[x][y], 6336.+(64.*x), -4992.+(64.*y))
                set y = y + 1
            endloop
            set x = x + 1
            set y = 0
        endloop
        call MoveRectTo(UI[11][8], 6336.+(64.*11), -4992.+(64.*8)) ///Leave this here. For some reason this tile is bugged...
       
     
  7. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,501
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Glad to hear you fixed it, Sephalo! Your UI also looks awesome :D may I ask why the Blood elf still has the portrait glow ?! I thought I removed it for you!
     
  8. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    Thanks!
    The latest version got your fixed blood elf portrait. The version of the sample movies doesnt have it yet. I'll post a new video in the project's post (see my signature below) tomorrow to show the progress from the last few days. It's really starting to look good.:)