From 46fd094a7914924dc360b3adfd162c793d0e5e74 Mon Sep 17 00:00:00 2001 From: Ronja Date: Sun, 20 Sep 2020 11:56:25 +0200 Subject: [PATCH] use new ui function --- Luxe/blocks/tooltip.wren | 2 ++ Luxe/blocks/ui/adventure.wren | 49 +++++----------------------------- Luxe/blocks/ui/info.wren | 50 +++++------------------------------ Luxe/blocks/ui/ui.wren | 6 +++-- 4 files changed, 20 insertions(+), 87 deletions(-) diff --git a/Luxe/blocks/tooltip.wren b/Luxe/blocks/tooltip.wren index e7c157d..1c85ddf 100644 --- a/Luxe/blocks/tooltip.wren +++ b/Luxe/blocks/tooltip.wren @@ -57,10 +57,12 @@ class Tooltip{ fix_y(value){ _y = value + tick() } fix_x(value){ _x = value + tick() } set(text, source){ diff --git a/Luxe/blocks/ui/adventure.wren b/Luxe/blocks/ui/adventure.wren index 4bdfeb7..25db1a1 100644 --- a/Luxe/blocks/ui/adventure.wren +++ b/Luxe/blocks/ui/adventure.wren @@ -41,47 +41,12 @@ class UiAdventure{ UILayout.set_margin(_ent, list, 0, 0, 0, 0) UILayout.set_contain(_ent, list, UILayoutContain.row | UILayoutContain.start) //| - var tiles = [10, 1] - var button - - //back to info - button = _ui.list_button(list) - ImageButton.set_tooltip(button, "Info") - ImageButton.set_tile_uv(button, tiles, [1, 0]) - ImageButton.set_state_change(button) { |data| - if(data["press"]){ - _ui.ui_mode = Ui.Info - } - } - - //abort - button = _ui.list_button(list) - ImageButton.set_tooltip(button, "Abort") - ImageButton.set_tile_uv(button, tiles, [0, 0]) - ImageButton.set_state_change(button) { |data| - if(data["press"]){ - _ui.ui_mode = Ui.Info - } - } - - //people - button = _ui.list_button(list) - ImageButton.set_tooltip(button, "People") - ImageButton.set_tile_uv(button, tiles, [2, 0]) - - //stuff - button = _ui.list_button(list) - ImageButton.set_tooltip(button, "Stuff") - ImageButton.set_tile_uv(button, tiles, [4, 0]) - - //direction - button = _ui.list_button(list) - ImageButton.set_tooltip(button, "Direction") - ImageButton.set_tile_uv(button, tiles, [3, 0]) - - //go - button = _ui.list_button(list) - ImageButton.set_tooltip(button, "Depart") - ImageButton.set_tile_uv(button, tiles, [5, 0]) + //toolbar icons + _ui.list_button(list, [1, 0], "Info") {_ui.ui_mode = Ui.Info} + _ui.list_button(list, [0, 0], "Abort") {_ui.ui_mode = Ui.Info} + _ui.list_button(list, [2, 0], "People") {} + _ui.list_button(list, [4, 0], "Stuff") {} + _ui.list_button(list, [3, 0], "Direction") {} + _ui.list_button(list, [5, 0], "Depart") {} } } \ No newline at end of file diff --git a/Luxe/blocks/ui/info.wren b/Luxe/blocks/ui/info.wren index 19bd2e7..a9a29a1 100644 --- a/Luxe/blocks/ui/info.wren +++ b/Luxe/blocks/ui/info.wren @@ -74,50 +74,14 @@ class UiInfo{ var tiles = [10, 1] var button - //plan adventure - button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) - ImageButton.set_tooltip(button, "Adventure!") - ImageButton.set_tile_uv(button, tiles, [1, 0]) - ImageButton.set_state_change(button) { |data| - if(data["press"]){ - Globals["Game"].adventures.new_or_current() - _ui.ui_mode = Ui.Planning - } - } - - //info - button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) - ImageButton.set_tooltip(button, "Stats") - ImageButton.set_tile_uv(button, tiles, [2, 0]) - ImageButton.set_state_change(button) { |data| - if(data["press"]){ - _page.value = UiInfo.human - } - } - - //read diary - button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) - ImageButton.set_tooltip(button, "Diary") - ImageButton.set_tile_uv(button, tiles, [1, 0]) - ImageButton.set_state_change(button) { |data| - if(data["press"]){ - _page.value = UiInfo.diary - } - } - - //resources - button = _ui.list_button(list) - UIImage.set_image(button, adventureButtons) - ImageButton.set_tooltip(button, "Resources") - ImageButton.set_tile_uv(button, tiles, [4, 0]) - ImageButton.set_state_change(button) { |data| - if(data["press"]){ - _page.value = UiInfo.resources - } + //toolbar buttons + _ui.list_button(list, [1, 0], "Adventure!") { + Globals["Game"].adventures.new_or_current() + _ui.ui_mode = Ui.Planning } + _ui.list_button(list, [2, 0], "Stats") {_page.value = UiInfo.human} + _ui.list_button(list, [1, 0], "Diary") {_page.value = UiInfo.diary} + _ui.list_button(list, [4, 0], "Resources") {_page.value = UiInfo.resources} } human(){ diff --git a/Luxe/blocks/ui/ui.wren b/Luxe/blocks/ui/ui.wren index 8b78448..a91f9ff 100644 --- a/Luxe/blocks/ui/ui.wren +++ b/Luxe/blocks/ui/ui.wren @@ -78,18 +78,20 @@ class Ui{ list_button(parent, tile, tooltip){ var button = list_button(parent, tile) ImageButton.set_tooltip(button, tooltip) + return button } list_button(parent, tile, tooltip, pressFn){ - var button = list_button(parent, tile) + var button = list_button(parent, tile, tooltip) ImageButton.set_state_change(button) { |data| if(data["press"]){ pressFn.call() } } + return button } } -//this is behind the class def to make cyclic dependency happy lol +//this is behind the class def to make cyclic dependency happy ^^ import "blocks/ui/info" for UiInfo import "blocks/ui/adventure" for UiAdventure \ No newline at end of file