fix: stop viewing humans when they're sent away
This commit is contained in:
parent
a3e2210195
commit
ed41828ecb
2 changed files with 9 additions and 9 deletions
|
|
@ -36,6 +36,7 @@ class Adventures{
|
|||
adventure.setup()
|
||||
adventure.adventurers.each{|human|
|
||||
Human.set_active(human, false)
|
||||
if(_game.focus.value == human) _game.focus.value = null
|
||||
}
|
||||
adventure.resources.list().each{|resource|
|
||||
_game.resources.remove(resource["base_name"], resource["amount"])
|
||||
|
|
|
|||
|
|
@ -33,11 +33,10 @@ class UiInfo{
|
|||
_ui = ui
|
||||
|
||||
_page = Observable.new(UiInfo.human)
|
||||
_game = Globals["Game"]
|
||||
|
||||
_focus = Observable.new()
|
||||
Globals["Game"].focus.on_change(true) {|val|
|
||||
_game.focus.on_change(true) {|val|
|
||||
if(ui.ui_mode == Ui.Info){
|
||||
_focus.value = val
|
||||
if(_page.value == UiInfo.resources){
|
||||
_page.value = UiInfo.human
|
||||
}
|
||||
|
|
@ -79,7 +78,7 @@ class UiInfo{
|
|||
|
||||
//toolbar buttons
|
||||
_ui.list_button(list, [6, 0], "Adventure!") {
|
||||
Globals["Game"].adventures.new_or_current()
|
||||
_game.adventures.new_or_current()
|
||||
_ui.ui_mode = Ui.Planning
|
||||
}
|
||||
_ui.list_button(list, [2, 0], "Stats") {_page.value = UiInfo.human}
|
||||
|
|
@ -111,7 +110,7 @@ class UiInfo{
|
|||
Control.set_id(frame, "person info frame")
|
||||
Control.child_add(portrait, frame)
|
||||
|
||||
_focus.on_change(true) {|val|
|
||||
_game.focus.on_change(true) {|val|
|
||||
//todo: more sophisticated portrait generation
|
||||
UIImage.set_image(portrait, Assets.image("assets/wip/Portrait"))
|
||||
UIImage.set_color(portrait, Human.get_color(val) || [0, 0, 0, 1])
|
||||
|
|
@ -126,7 +125,7 @@ class UiInfo{
|
|||
var name = UISimpleText.create(_ent)
|
||||
Control.child_add(statBlock, name)
|
||||
Control.set_id(name, "human name info")
|
||||
_focus.on_change(true) {|val|
|
||||
_game.focus.on_change(true) {|val|
|
||||
var name_string = Human.get_name(val) || "-"
|
||||
UISimpleText.set_text(name, name_string)
|
||||
}
|
||||
|
|
@ -134,7 +133,7 @@ class UiInfo{
|
|||
var adventures = UISimpleText.create(_ent)
|
||||
Control.child_add(statBlock, adventures)
|
||||
Control.set_id(name, "human adventure count")
|
||||
_focus.on_change(true) {|val|
|
||||
_game.focus.on_change(true) {|val|
|
||||
var count = Human.get_adventure_count(val)
|
||||
var text = count ? "Adventures: %(count)" : ""
|
||||
UISimpleText.set_text(adventures, text)
|
||||
|
|
@ -156,7 +155,7 @@ class UiInfo{
|
|||
Control.set_id(title, "human name info")
|
||||
UILayout.set_behave(_ent, title, UILayoutBehave.left | UILayoutBehave.top) //|
|
||||
UILayout.set_margin(_ent, title, 1, 1, 0, 0)
|
||||
_focus.on_change(true) {|val|
|
||||
_game.focus.on_change(true) {|val|
|
||||
var name = Human.get_name(val)
|
||||
var diary_title = name ? "%(StringUtil.possesive(name)) Diary" : "Diary"
|
||||
UISimpleText.set_text(title, diary_title)
|
||||
|
|
@ -177,7 +176,7 @@ class UiInfo{
|
|||
Control.child_add(page, resList)
|
||||
UILayout.set_behave(_ent, resList, UILayoutBehave.left | UILayoutBehave.top) //|
|
||||
UILayout.set_margin(_ent, resList, 7, 3, 0, 0)
|
||||
Globals["Game"].resources.on_change{|val|
|
||||
_game.resources.on_change{|val|
|
||||
var resources = val.list()
|
||||
var text = resources.map{|res| "%(res["name"]): %(res["amount"])"}.join("\n")
|
||||
UISimpleText.set_text(resList, text)
|
||||
|
|
|
|||
Loading…
Reference in a new issue