• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Custom UI combo box/popupmenu does not work

Status
Not open for further replies.
Level 26
Joined
Feb 2, 2006
Messages
1,690
Hi,
from this tutorial I have tried to create a combo box/popupmenu in a custom UI: The Big UI-Frame Tutorial

As far as I understand the tutorial, I have to create a custom FDF file with the popupmenu templates containing all entries.

This is my .toc file imported with the path "war3mapImported\aiplayersTOC.toc":
JASS:
UI\FrameDef\UI\aiplayerspopups.fdf

This is my FDF file imported with the path "UI\FrameDef\UI\aiplayerspopups.fdf":
JASS:
IncludeFile "UI/FrameDef/UI/EscMenuTemplates.fdf",

Frame "POPUPMENU" "MyPopupTemplate" {
    Width 0.19625,
    Height 0.03,
    PopupButtonInset 0.01, // -x offset for PopupArrowFrame from RIGHT of the POPUPMENU

    // Background Enabled
    ControlBackdrop "MyPopupTemplateBackdropTemplate",
    Frame "BACKDROP" "MyPopupTemplateBackdropTemplate" INHERITS "EscMenuButtonBackdropTemplate" {
    }

    // Background Disabled
    ControlDisabledBackdrop "MyPopupTemplateDisabledBackdropTemplate",
    Frame "BACKDROP" "MyPopupTemplateDisabledBackdropTemplate" INHERITS "EscMenuButtonDisabledBackdropTemplate" {
    }

    // Text markup for the current selected Text, also can be used with a FrameEvent to know when someone starts selecting.
    PopupTitleFrame "PopupMenuTitleTemplate",
    Frame "GLUETEXTBUTTON" "PopupMenuTitleTemplate" INHERITS WITHCHILDREN "EscMenuPopupMenuTitleTemplate" {
    }

    // the Arrow at the right
    PopupArrowFrame "PopupMenuArrowTemplate",
    Frame "BUTTON" "PopupMenuArrowTemplate" INHERITS WITHCHILDREN "EscMenuPopupMenuArrowTemplate" {
    }

    // The Container for the selectable options
    // actulay it is smarter to not define this in the Template.
    //PopupMenuFrame "TestPopupMenu",
    //Frame "MENU" "TestPopupMenu" INHERITS WITHCHILDREN "EscMenuPopupMenuMenuTemplate" {
//
//    }
}

Frame "POPUPMENU" "TestPopup" INHERITS WITHCHILDREN "MyPopupTemplate" {
    // The Container for the selectable options
    PopupMenuFrame "TestPopupMenu",
    Frame "MENU" "TestPopupMenu" INHERITS WITHCHILDREN "EscMenuPopupMenuMenuTemplate" {
        // the selectable options
        // they will try to load a Localized String
        MenuItem "Random",     -2,
        MenuItem "Random Human",     -2,
        MenuItem "Mountain King",     -2,
        MenuItem "TestD",     -2,
    }
}

Frame "POPUPMENU" "HeroesPopup" INHERITS WITHCHILDREN "MyPopupTemplate" {
    PopupMenuFrame "HeroesPopupMenu",
    Frame "MENU" "HeroesPopupMenu" INHERITS WITHCHILDREN "EscMenuPopupMenuMenuTemplate" {
        MenuItem "Random",     -2,
        MenuItem "Random Human",     -2,
        MenuItem "Mountain King",     -2,
    }
}

Frame "EDITBOX" "HeroesEditBox" INHERITS WITHCHILDREN "EscMenuEditBoxTemplate" {
    Width 0.15,
    Height 0.037,
    DecorateFileNames,
    FrameFont "MasterFont", 0.015, "",
    SetPoint TOPLEFT, "HeroesPopup", TOPRIGHT, 0.0, 0.0,

    EditTextFrame "CustomCommandsEditBoxText",
    Frame "TEXT" "CustomCommandsEditBoxText" INHERITS "EscMenuEditBoxTextTemplate" {
    }
}

Frame "POPUPMENU" "StartLocationsPopup" INHERITS WITHCHILDREN "MyPopupTemplate" {
    PopupMenuFrame "StartLocationsPopupMenu",
    Frame "MENU" "StartLocationsPopupMenu" INHERITS WITHCHILDREN "EscMenuPopupMenuMenuTemplate" {
        MenuItem "Random",     -2,
        MenuItem "New Stormwind",     -2,
        MenuItem "Orgrimmar",     -2,
    }
}

Frame "POPUPMENU" "RacesPopup" INHERITS WITHCHILDREN "MyPopupTemplate" {
    PopupMenuFrame "RacesPopupMenu",
    Frame "MENU" "RacesPopupMenu" INHERITS WITHCHILDREN "EscMenuPopupMenuMenuTemplate" {
        MenuItem "Freelancer",     -2,
        MenuItem "Random",     -2,
        MenuItem "Human",     -2,
    }
}

Frame "POPUPMENU" "ProfessionsPopup" INHERITS WITHCHILDREN "MyPopupTemplate" {
    PopupMenuFrame "ProfessionsPopupMenu",
    Frame "MENU" "ProfessionsPopupMenu" INHERITS WITHCHILDREN "EscMenuPopupMenuMenuTemplate" {
        MenuItem "Random",     -2,
        MenuItem "Herbalist",     -2,
        MenuItem "Alchemist",     -2,
    }
}

I have imported the attached .toc file and use the following code:
JASS:
globals
       framehandle array AiPlayersUILabelFrameColumnRaceEdit
endglobals

...

// show the frame to the player
call BlzFrameSetVisible(AiPlayersUILabelFrameColumnRaceEdit[index], visible)

...

call BlzLoadTOCFile("war3mapImported\\aiplayersTOC.toc")
...
set AiPlayersUILabelFrameColumnRaceEdit[index] = BlzCreateFrame("RacesPopup", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
call BlzFrameSetAbsPoint(AiPlayersUILabelFrameColumnRaceEdit[index], FRAMEPOINT_TOPLEFT, AI_PLAYERS_UI_COLUMN_RACE_X, y)
call BlzFrameSetAbsPoint(AiPlayersUILabelFrameColumnRaceEdit[index], FRAMEPOINT_BOTTOMRIGHT, AI_PLAYERS_UI_COLUMN_RACE_X + AI_PLAYERS_UI_COLUMN_RACE_WIDTH, y - AI_PLAYERS_UI_LINE_HEADERS_HEIGHT)
call BlzFrameSetEnable(AiPlayersUILabelFrameColumnRaceEdit[index], true)
call BlzFrameSetVisible(AiPlayersUILabelFrameColumnRaceEdit[index], false)

I am no custom UI expert, so maybe I did something very basic wrong.
 
This is my .toc file imported with the path "war3mapImported\aiplayersTOC.toc":
JASS:
UI\FrameDef\UI\aiplayerspopups.fdf
Make Sure you have an empty ending line (inside the toc file) like in that image:
toc-empty-line-jpg.367753
 
Level 26
Joined
Feb 2, 2006
Messages
1,690
Hive does not show it properly but there is an empty ending line after the line:

JASS:
UI\FrameDef\UI\aiplayerspopups.fdf
You can download and try the map: https://github.com/tdauth/wowr/raw/master/wowr2.1.w3x
If you start it with additional Computer players there is a dialog for AI settings in the beginning which should show the popupmenus but does show nothing. However, text edits and labels do work.
 
Status
Not open for further replies.
Top