Petr Mrázek 2012-05-21 20:32:50 +02:00
commit 1e09d67fc3
2 changed files with 55 additions and 2 deletions

@ -41,6 +41,8 @@ using namespace std;
#include "MiscUtils.h" #include "MiscUtils.h"
using namespace DFHack; using namespace DFHack;
#include "modules/Job.h"
#include "DataDefs.h" #include "DataDefs.h"
#include "df/world.h" #include "df/world.h"
#include "df/global_objects.h" #include "df/global_objects.h"
@ -58,6 +60,7 @@ using namespace DFHack;
#include "df/viewscreen_layer_militaryst.h" #include "df/viewscreen_layer_militaryst.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/ui_unit_view_mode.h" #include "df/ui_unit_view_mode.h"
#include "df/ui_sidebar_menus.h" #include "df/ui_sidebar_menus.h"
#include "df/ui_look_list.h" #include "df/ui_look_list.h"
@ -353,6 +356,9 @@ DEFINE_GET_FOCUS_STRING_HANDLER(pet)
if (vector_get(screen->trainer_unit, screen->trainer_cursor)) if (vector_get(screen->trainer_unit, screen->trainer_cursor))
focus += "/Unit"; focus += "/Unit";
break; break;
default:
break;
} }
} }
@ -391,6 +397,17 @@ DEFINE_GET_FOCUS_STRING_HANDLER(layer_assigntrade)
focus += "/Items"; focus += "/Items";
} }
DEFINE_GET_FOCUS_STRING_HANDLER(stores)
{
if (!screen->in_right_list)
focus += "/Categories";
else if (screen->in_group_mode)
focus += "/Groups";
else
focus += "/Items";
}
std::string Gui::getFocusString(df::viewscreen *top) std::string Gui::getFocusString(df::viewscreen *top)
{ {
if (!top) if (!top)
@ -625,7 +642,13 @@ static df::unit *getAnyUnit(df::viewscreen *top)
using df::global::ui_selected_unit; using df::global::ui_selected_unit;
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_joblistst, top)) if (VIRTUAL_CAST_VAR(screen, df::viewscreen_joblistst, top))
return vector_get(screen->units, screen->cursor_pos); {
if (auto unit = vector_get(screen->units, screen->cursor_pos))
return unit;
if (auto job = vector_get(screen->jobs, screen->cursor_pos))
return Job::getWorker(job);
return NULL;
}
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_unitlistst, top)) if (VIRTUAL_CAST_VAR(screen, df::viewscreen_unitlistst, top))
return vector_get(screen->units[screen->page], screen->cursor_pos[screen->page]); return vector_get(screen->units[screen->page], screen->cursor_pos[screen->page]);
@ -781,6 +804,14 @@ static df::item *getAnyItem(df::viewscreen *top)
return vector_get(screen->trader_items, screen->trader_cursor); return vector_get(screen->trader_items, screen->trader_cursor);
} }
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_storesst, top))
{
if (screen->in_right_list && !screen->in_group_mode)
return vector_get(screen->items, screen->item_cursor);
return NULL;
}
if (!Gui::dwarfmode_hotkey(top)) if (!Gui::dwarfmode_hotkey(top))
return NULL; return NULL;

@ -6,6 +6,7 @@
#include "modules/Gui.h" #include "modules/Gui.h"
#include "modules/Translation.h" #include "modules/Translation.h"
#include "modules/Units.h" #include "modules/Units.h"
#include "modules/Job.h"
#include "LuaTools.h" #include "LuaTools.h"
@ -22,6 +23,7 @@
#include "df/viewscreen_tradegoodsst.h" #include "df/viewscreen_tradegoodsst.h"
#include "df/viewscreen_dwarfmodest.h" #include "df/viewscreen_dwarfmodest.h"
#include "df/viewscreen_petst.h" #include "df/viewscreen_petst.h"
#include "df/viewscreen_storesst.h"
#include "df/layer_object_listst.h" #include "df/layer_object_listst.h"
#include "df/assign_trade_status.h" #include "df/assign_trade_status.h"
@ -273,7 +275,16 @@ DEFINE_SORT_HANDLER(unit_sorters, joblist, "", jobs)
{ {
PARSE_SPEC("units", parameters); PARSE_SPEC("units", parameters);
if (compute_order(*pout, L, top, &order, jobs->units)) std::vector<df::unit*> units;
for (size_t i = 0; i < jobs->units.size(); i++)
{
auto unit = jobs->units[i];
if (!unit && jobs->jobs[i])
unit = Job::getWorker(jobs->jobs[i]);
units.push_back(unit);
}
if (compute_order(*pout, L, top, &order, units))
{ {
reorder_cursor(&jobs->cursor_pos, order); reorder_cursor(&jobs->cursor_pos, order);
reorder_vector(&jobs->units, order); reorder_vector(&jobs->units, order);
@ -526,6 +537,17 @@ DEFINE_SORT_HANDLER(item_sorters, layer_assigntrade, "/Items", bring)
} }
} }
DEFINE_SORT_HANDLER(item_sorters, stores, "/Items", stocks)
{
PARSE_SPEC("items", parameters);
if (compute_order(*pout, L, top, &order, stocks->items))
{
reorder_cursor(&stocks->item_cursor, order);
reorder_vector(&stocks->items, order);
}
}
static bool item_list_hotkey(df::viewscreen *screen) static bool item_list_hotkey(df::viewscreen *screen)
{ {
auto focus = Gui::getFocusString(screen); auto focus = Gui::getFocusString(screen);