Add support for viewscreen_locationsst to various gui functions

develop
lethosor 2015-12-25 11:09:05 -05:00
parent d4b631d9fd
commit 64d861bf6b
2 changed files with 25 additions and 1 deletions

@ -62,6 +62,7 @@ using namespace DFHack;
#include "df/viewscreen_layer_assigntradest.h" #include "df/viewscreen_layer_assigntradest.h"
#include "df/viewscreen_layer_militaryst.h" #include "df/viewscreen_layer_militaryst.h"
#include "df/viewscreen_layer_stockpilest.h" #include "df/viewscreen_layer_stockpilest.h"
#include "df/viewscreen_locationsst.h"
#include "df/viewscreen_petst.h" #include "df/viewscreen_petst.h"
#include "df/viewscreen_tradegoodsst.h" #include "df/viewscreen_tradegoodsst.h"
#include "df/viewscreen_storesst.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) std::string Gui::getFocusString(df::viewscreen *top)
{ {
if (!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)) if (VIRTUAL_CAST_VAR(screen, df::viewscreen_petst, top))
{ {
switch (screen->mode) switch (screen->mode)

@ -1 +1 @@
Subproject commit 636f7787552cc663f01561c7dc84f758cea027f1 Subproject commit 73a4758307b01396ed28c8df011a6f95867450cf