diff --git a/README.md b/README.md index d2dd837..60b7d5f 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,5 @@ You need to add the .toc and .fdef files from the imports folder into your own p Demo: https://github.com/Frotty/wurst-item-shop/blob/main/wurst/ItemShopTest.wurst -![](https://github.com/Frotty/wurst-item-shop/blob/main/screenshot.png) +![image](https://user-images.githubusercontent.com/1486037/114105191-a2fa6000-98cc-11eb-8565-5e1e78245d5f.png) + diff --git a/imports/itemshopframes.fdf b/imports/itemshopframes.fdf index f15f941..8dab80f 100644 --- a/imports/itemshopframes.fdf +++ b/imports/itemshopframes.fdf @@ -4,54 +4,63 @@ IncludeFile "UI\FrameDef\UI\EscMenuTemplates.fdf", // -- LOCAL TEMPLATES ------------------------------------------------------- Frame "BACKDROP" "BoxedTextBackgroundTemplate" { - DecorateFileNames, //Look-Up Names in some String table (for example gameinterface) - BackdropTileBackground, //Tile mode enabled - BackdropBackground "ToolTipBackground", //BackgroundFile - BackdropCornerFlags "UL|UR|BL|BR|T|L|B|R", - BackdropCornerSize 0.008, //higher numbers make the corners bigger. - BackdropBackgroundInsets 0.0022 0.0022 0.0022 0.0022, //makes the background smaller, from the outside. - BackdropEdgeFile "ToolTipBorder", //the border File - BackdropBlendAll, + DecorateFileNames, //Look-Up Names in some String table (for example gameinterface) + BackdropTileBackground, //Tile mode enabled + BackdropBackground "ToolTipBackground", //BackgroundFile + BackdropCornerFlags "UL|UR|BL|BR|T|L|B|R", + BackdropCornerSize 0.008, //higher numbers make the corners bigger. + BackdropBackgroundInsets 0.0022 0.0022 0.0022 0.0022, //makes the background smaller, from the outside. + BackdropEdgeFile "ToolTipBorder", //the border File + BackdropBlendAll, } // -- Frames ------------------------------------------------------- Frame "GLUETEXTBUTTON" "GeneralButton" INHERITS WITHCHILDREN "EscMenuButtonTemplate" { - UseActiveContext, - ButtonText "GeneralButtonText", - Frame "TEXT" "GeneralButtonText" INHERITS "EscMenuButtonTextTemplate" { - Text "", - } + UseActiveContext, + ButtonText "GeneralButtonText", + Frame "TEXT" "GeneralButtonText" INHERITS "EscMenuButtonTextTemplate" { + Text "", + } +} + +Frame "GLUETEXTBUTTON" "TabButton" INHERITS WITHCHILDREN "EscMenuButtonTemplate" { + Width 0.08, + Height 0.025, + + ButtonText "TabText", + Frame "TEXT" "TabText" INHERITS "EscMenuButtonTextTemplate" { + } } Frame "BACKDROP" "ItemShopBackdrop" { - DecorateFileNames, //Look-Up Names in some String table (for example gameinterface) - BackdropTileBackground, //Tile mode enabled - BackdropBackground "EscMenuBackground", //BackgroundFile - BackdropCornerFlags "UL|UR|BL|BR|T|L|B|R", - BackdropBackgroundInsets 0.0022 0.0022 0.0022 0.0022, //makes the background smaller, from the outside. - BackdropEdgeFile "EscMenuBorder", //the border File - BackdropBlendAll, + DecorateFileNames, //Look-Up Names in some String table (for example gameinterface) + BackdropTileBackground, //Tile mode enabled + BackdropBackground "EscMenuBackground", //BackgroundFile + BackdropCornerFlags "UL|UR|BL|BR|T|L|B|R", + BackdropBackgroundInsets 0.0022 0.0022 0.0022 0.0022, //makes the background smaller, from the outside. + BackdropEdgeFile "EscMenuBorder", //the border File + BackdropBlendAll, } Frame "BACKDROP" "BoxedText" INHERITS "BoxedTextBackgroundTemplate" { - UseActiveContext, - - Frame "TEXT" "BoxedTextTitle" { - UseActiveContext, - DecorateFileNames, - FontFlags "FIXEDSIZE", - FrameFont "MasterFont", 0.012, "", - FontColor 1.0 1.0 1.0 1.0, //Red Green Blue Alpha 0.0 to 1.0 - FontShadowColor 0.0 0.0 0.0 0.9, - FontShadowOffset 0.001 -0.001, - } - - Frame "TEXT" "BoxedTextValue" { - UseActiveContext, - DecorateFileNames, - FontFlags "FIXEDSIZE", - FrameFont "MasterFont", 0.010, "", - FontColor 1.0 1.0 1.0 1.0, - FontShadowColor 0.0 0.0 0.0 0.9, - FontShadowOffset 0.001 -0.001, - } + UseActiveContext, + + Frame "TEXT" "BoxedTextTitle" { + UseActiveContext, + DecorateFileNames, + FontFlags "FIXEDSIZE", + FrameFont "MasterFont", 0.012, "", + FontColor 1.0 1.0 1.0 1.0, //Red Green Blue Alpha 0.0 to 1.0 + FontShadowColor 0.0 0.0 0.0 0.9, + FontShadowOffset 0.001 -0.001, + } + + Frame "TEXT" "BoxedTextValue" { + UseActiveContext, + DecorateFileNames, + FontFlags "FIXEDSIZE", + FrameFont "MasterFont", 0.010, "", + FontColor 1.0 1.0 1.0 1.0, + FontShadowColor 0.0 0.0 0.0 0.9, + FontShadowOffset 0.001 -0.001, + } } diff --git a/wurst/ItemShopMenu.wurst b/wurst/ItemShopMenu.wurst index 0c83609..f07104a 100644 --- a/wurst/ItemShopMenu.wurst +++ b/wurst/ItemShopMenu.wurst @@ -6,6 +6,7 @@ import ClosureTimers import LinkedList import public ItemShopIcon import RecipeItem +import ClosureFrames constant itemShopOpenSound = new SoundDefinition(Sounds.bigButtonClick) @@ -26,12 +27,34 @@ public class ItemShop constant itemShopFrame = createFrame("FRAME", "itemShopFrame", getFrame("ConsoleUIBackdrop", 0), "", 0) private constant itemShopBackdrop = createFrame("ItemShopBackdrop", itemShopFrame, 0, 1) // Context is 1 cuz same name uses hero pick menu. + + private constant tabButton1 = createFrame("TabButton", itemShopFrame, 0, 0) + private constant tabButton2 = createFrame("TabButton", itemShopFrame, 0, 1) + private constant tabButton3 = createFrame("TabButton", itemShopFrame, 0, 2) + private constant radioGroup = new LinkedList + ..add(tabButton1) + ..add(tabButton2) + ..add(tabButton3) construct() itemShopFrame ..setSize(0.245, 0.365) ..setAbsPoint(FRAMEPOINT_TOP, vec2(0.8, 0.53)) + tabButton1..setPoint(FRAMEPOINT_BOTTOMLEFT, itemShopFrame, FRAMEPOINT_TOPLEFT) + ..setText("Tab1") + ..disable() + ..onClick() -> + toggleTabs(tabButton1) + tabButton2..setPoint(FRAMEPOINT_LEFT, tabButton1, FRAMEPOINT_RIGHT) + ..setText("Tab2") + ..onClick() -> + toggleTabs(tabButton2) + tabButton3..setPoint(FRAMEPOINT_LEFT, tabButton2, FRAMEPOINT_RIGHT) + ..setText("Tab3") + ..onClick() -> + toggleTabs(tabButton3) + itemShopBackdrop.setAllPoints(itemShopFrame) itemShopFrame.hide() @@ -39,6 +62,13 @@ public class ItemShop buyers.forEach() (_player, value) -> checkBuyability(_player) + function toggleTabs(framehandle clickedTab) + clickedTab.disable() + + radioGroup.forEach() (framehandle tab) -> + if tab != clickedTab + tab.enable() + function toggleView(player p, unit u) if buyers.has(p) hideForPlayer(p)