From cc30a6b75fa8e49b6a521db740ca0c796508c7d2 Mon Sep 17 00:00:00 2001 From: Overkane Date: Fri, 26 Feb 2021 21:37:44 +0500 Subject: [PATCH 1/3] Made tab frames --- imports/itemshopframes.fdf | 123 ++++++++++++++++++++++++------------- wurst/ItemShopMenu.wurst | 10 +++ 2 files changed, 92 insertions(+), 41 deletions(-) diff --git a/imports/itemshopframes.fdf b/imports/itemshopframes.fdf index f15f941..8a2f860 100644 --- a/imports/itemshopframes.fdf +++ b/imports/itemshopframes.fdf @@ -4,54 +4,95 @@ 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 "GLUECHECKBOX" "TabButton" { + Width 0.08, + Height 0.025, + + Frame "TEXT" "TabText" { + SetAllPoints, + DecorateFileNames, + FrameFont "EscMenuTextFont", 0.013, "", + FontJustificationH JUSTIFYCENTER, + FontJustificationV JUSTIFYMIDDLE, + FontJustificationOffset 0.0 -0.002, + FontFlags "FIXEDSIZE", + FontColor 0.99 0.827 0.0705 1.0, + FontHighlightColor 1.0 1.0 1.0 1.0, + FontDisabledColor 0.5 0.5 0.5 1.0, + FontShadowColor 0.0 0.0 0.0 0.9, + FontShadowOffset 0.002 -0.002, + LayerStyle "IGNORETRACKEVENTS", + } + + ControlBackdrop "TabButtonBackdrop", + Frame "BACKDROP" "TabButtonBackdrop" INHERITS "EscMenuButtonBackdropTemplate" { + } + + ControlDisabledBackdrop "TabButtonDisabledBackdrop", + Frame "BACKDROP" "TabButtonDisabledBackdrop" INHERITS "EscMenuButtonDisabledBackdropTemplate" { + } + + ControlPushedBackdrop "TabButtonPushedBackdrop", + Frame "BACKDROP" "TabButtonPushedBackdrop" INHERITS "EscMenuButtonPushedBackdropTemplate" { + } + + CheckBoxCheckHighlight "TabButtonHighlightTemplate", + Frame "HIGHLIGHT" "TabButtonHighlightTemplate" { + DecorateFileNames, + HighlightType "FILETEXTURE", + HighlightAlphaFile "EscMenuButtonMouseOverHighlight", + HighlightAlphaMode "ADD", + } } 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..81270fc 100644 --- a/wurst/ItemShopMenu.wurst +++ b/wurst/ItemShopMenu.wurst @@ -26,12 +26,22 @@ 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) construct() itemShopFrame ..setSize(0.245, 0.365) ..setAbsPoint(FRAMEPOINT_TOP, vec2(0.8, 0.53)) + tabButton1..setPoint(FRAMEPOINT_BOTTOMLEFT, itemShopFrame, FRAMEPOINT_TOPLEFT) + getFrame("TabText", 0)..setText("Tab1") + tabButton2..setPoint(FRAMEPOINT_LEFT, tabButton1, FRAMEPOINT_RIGHT) + getFrame("TabText", 1)..setText("Tab2") + tabButton3..setPoint(FRAMEPOINT_LEFT, tabButton2, FRAMEPOINT_RIGHT) + getFrame("TabText", 2)..setText("Tab3") + itemShopBackdrop.setAllPoints(itemShopFrame) itemShopFrame.hide() From 48b10e4c0f88c119b45a05a749844bd9aac402d8 Mon Sep 17 00:00:00 2001 From: Overkane Date: Fri, 5 Mar 2021 23:48:58 +0500 Subject: [PATCH 2/3] Fixed tabs --- imports/itemshopframes.fdf | 38 +++----------------------------------- wurst/ItemShopMenu.wurst | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/imports/itemshopframes.fdf b/imports/itemshopframes.fdf index 8a2f860..8dab80f 100644 --- a/imports/itemshopframes.fdf +++ b/imports/itemshopframes.fdf @@ -22,44 +22,12 @@ Frame "GLUETEXTBUTTON" "GeneralButton" INHERITS WITHCHILDREN "EscMenuButtonTempl } } -Frame "GLUECHECKBOX" "TabButton" { +Frame "GLUETEXTBUTTON" "TabButton" INHERITS WITHCHILDREN "EscMenuButtonTemplate" { Width 0.08, Height 0.025, - Frame "TEXT" "TabText" { - SetAllPoints, - DecorateFileNames, - FrameFont "EscMenuTextFont", 0.013, "", - FontJustificationH JUSTIFYCENTER, - FontJustificationV JUSTIFYMIDDLE, - FontJustificationOffset 0.0 -0.002, - FontFlags "FIXEDSIZE", - FontColor 0.99 0.827 0.0705 1.0, - FontHighlightColor 1.0 1.0 1.0 1.0, - FontDisabledColor 0.5 0.5 0.5 1.0, - FontShadowColor 0.0 0.0 0.0 0.9, - FontShadowOffset 0.002 -0.002, - LayerStyle "IGNORETRACKEVENTS", - } - - ControlBackdrop "TabButtonBackdrop", - Frame "BACKDROP" "TabButtonBackdrop" INHERITS "EscMenuButtonBackdropTemplate" { - } - - ControlDisabledBackdrop "TabButtonDisabledBackdrop", - Frame "BACKDROP" "TabButtonDisabledBackdrop" INHERITS "EscMenuButtonDisabledBackdropTemplate" { - } - - ControlPushedBackdrop "TabButtonPushedBackdrop", - Frame "BACKDROP" "TabButtonPushedBackdrop" INHERITS "EscMenuButtonPushedBackdropTemplate" { - } - - CheckBoxCheckHighlight "TabButtonHighlightTemplate", - Frame "HIGHLIGHT" "TabButtonHighlightTemplate" { - DecorateFileNames, - HighlightType "FILETEXTURE", - HighlightAlphaFile "EscMenuButtonMouseOverHighlight", - HighlightAlphaMode "ADD", + ButtonText "TabText", + Frame "TEXT" "TabText" INHERITS "EscMenuButtonTextTemplate" { } } diff --git a/wurst/ItemShopMenu.wurst b/wurst/ItemShopMenu.wurst index 81270fc..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,9 +27,14 @@ 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 @@ -36,11 +42,18 @@ public class ItemShop ..setAbsPoint(FRAMEPOINT_TOP, vec2(0.8, 0.53)) tabButton1..setPoint(FRAMEPOINT_BOTTOMLEFT, itemShopFrame, FRAMEPOINT_TOPLEFT) - getFrame("TabText", 0)..setText("Tab1") + ..setText("Tab1") + ..disable() + ..onClick() -> + toggleTabs(tabButton1) tabButton2..setPoint(FRAMEPOINT_LEFT, tabButton1, FRAMEPOINT_RIGHT) - getFrame("TabText", 1)..setText("Tab2") + ..setText("Tab2") + ..onClick() -> + toggleTabs(tabButton2) tabButton3..setPoint(FRAMEPOINT_LEFT, tabButton2, FRAMEPOINT_RIGHT) - getFrame("TabText", 2)..setText("Tab3") + ..setText("Tab3") + ..onClick() -> + toggleTabs(tabButton3) itemShopBackdrop.setAllPoints(itemShopFrame) itemShopFrame.hide() @@ -49,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) From 086bb9afb43079f3c38098ebfc6ecc45d9c1e829 Mon Sep 17 00:00:00 2001 From: Frotty Date: Fri, 9 Apr 2021 00:43:51 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) +