Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made tab frames #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

91 changes: 50 additions & 41 deletions imports/itemshopframes.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
30 changes: 30 additions & 0 deletions wurst/ItemShopMenu.wurst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ClosureTimers
import LinkedList
import public ItemShopIcon
import RecipeItem
import ClosureFrames

constant itemShopOpenSound = new SoundDefinition(Sounds.bigButtonClick)

Expand All @@ -26,19 +27,48 @@ 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<framehandle>
..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()

doPeriodically(0.5) cb ->
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)
Expand Down