From 64d861bf6b99e8411395bc0f6b0f0ac99fc197e0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 25 Dec 2015 11:09:05 -0500 Subject: [PATCH] Add support for viewscreen_locationsst to various gui functions --- library/modules/Gui.cpp | 24 ++++++++++++++++++++++++ library/xml | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 8de672ec6..518fe9bda 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -62,6 +62,7 @@ using namespace DFHack; #include "df/viewscreen_layer_assigntradest.h" #include "df/viewscreen_layer_militaryst.h" #include "df/viewscreen_layer_stockpilest.h" +#include "df/viewscreen_locationsst.h" #include "df/viewscreen_petst.h" #include "df/viewscreen_tradegoodsst.h" #include "df/viewscreen_storesst.h" @@ -542,6 +543,11 @@ DEFINE_GET_FOCUS_STRING_HANDLER(layer_stockpile) } } +DEFINE_GET_FOCUS_STRING_HANDLER(locations) +{ + focus += "/" + enum_item_key(screen->menu); +} + std::string Gui::getFocusString(df::viewscreen *top) { if (!top) @@ -835,6 +841,24 @@ df::unit *Gui::getAnyUnit(df::viewscreen *top) } } + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_locationsst, top)) + { + switch (screen->menu) + { + case df::viewscreen_locationsst::AssignOccupation: + return vector_get(screen->units, screen->unit_idx); + case df::viewscreen_locationsst::Occupations: + { + auto occ = vector_get(screen->occupations, screen->occupation_idx); + if (occ) + return df::unit::find(occ->unit_id); + return NULL; + } + default: + return NULL; + } + } + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_petst, top)) { switch (screen->mode) diff --git a/library/xml b/library/xml index 636f77875..73a475830 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 636f7787552cc663f01561c7dc84f758cea027f1 +Subproject commit 73a4758307b01396ed28c8df011a6f95867450cf