use new ui function

This commit is contained in:
Ronja 2020-09-20 11:56:25 +02:00
parent fa40c19c50
commit 46fd094a79
4 changed files with 20 additions and 87 deletions

View file

@ -57,10 +57,12 @@ class Tooltip{
fix_y(value){ fix_y(value){
_y = value _y = value
tick()
} }
fix_x(value){ fix_x(value){
_x = value _x = value
tick()
} }
set(text, source){ set(text, source){

View file

@ -41,47 +41,12 @@ class UiAdventure{
UILayout.set_margin(_ent, list, 0, 0, 0, 0) UILayout.set_margin(_ent, list, 0, 0, 0, 0)
UILayout.set_contain(_ent, list, UILayoutContain.row | UILayoutContain.start) //| UILayout.set_contain(_ent, list, UILayoutContain.row | UILayoutContain.start) //|
var tiles = [10, 1] //toolbar icons
var button _ui.list_button(list, [1, 0], "Info") {_ui.ui_mode = Ui.Info}
_ui.list_button(list, [0, 0], "Abort") {_ui.ui_mode = Ui.Info}
//back to info _ui.list_button(list, [2, 0], "People") {}
button = _ui.list_button(list) _ui.list_button(list, [4, 0], "Stuff") {}
ImageButton.set_tooltip(button, "Info") _ui.list_button(list, [3, 0], "Direction") {}
ImageButton.set_tile_uv(button, tiles, [1, 0]) _ui.list_button(list, [5, 0], "Depart") {}
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])
} }
} }

View file

@ -74,50 +74,14 @@ class UiInfo{
var tiles = [10, 1] var tiles = [10, 1]
var button var button
//plan adventure //toolbar buttons
button = _ui.list_button(list) _ui.list_button(list, [1, 0], "Adventure!") {
UIImage.set_image(button, adventureButtons) Globals["Game"].adventures.new_or_current()
ImageButton.set_tooltip(button, "Adventure!") _ui.ui_mode = Ui.Planning
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
}
} }
_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(){ human(){

View file

@ -78,18 +78,20 @@ class Ui{
list_button(parent, tile, tooltip){ list_button(parent, tile, tooltip){
var button = list_button(parent, tile) var button = list_button(parent, tile)
ImageButton.set_tooltip(button, tooltip) ImageButton.set_tooltip(button, tooltip)
return button
} }
list_button(parent, tile, tooltip, pressFn){ 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| ImageButton.set_state_change(button) { |data|
if(data["press"]){ if(data["press"]){
pressFn.call() 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/info" for UiInfo
import "blocks/ui/adventure" for UiAdventure import "blocks/ui/adventure" for UiAdventure