Skip to content

Commit

Permalink
Add support for viewscreen_locationsst to various gui functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lethosor committed Dec 25, 2015
1 parent d4b631d commit 64d861b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions library/modules/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion library/xml
Submodule xml updated 2 files
+24 −0 df.pathfinding.xml
+18 −4 df.viewscreen.xml

0 comments on commit 64d861b

Please sign in to comment.