Support sorting items in stocks, and correct unit sorting in joblist.

develop
Alexander Gavrilov 2012-05-21 22:29:03 +04:00
parent 34f08c0223
commit 81022451c2
3 changed files with 45 additions and 3 deletions

@ -41,6 +41,8 @@ using namespace std;
#include "MiscUtils.h"
using namespace DFHack;
#include "modules/Job.h"
#include "DataDefs.h"
#include "df/world.h"
#include "df/global_objects.h"
@ -58,6 +60,7 @@ using namespace DFHack;
#include "df/viewscreen_layer_militaryst.h"
#include "df/viewscreen_petst.h"
#include "df/viewscreen_tradegoodsst.h"
#include "df/viewscreen_storesst.h"
#include "df/ui_unit_view_mode.h"
#include "df/ui_sidebar_menus.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))
focus += "/Unit";
break;
default:
break;
}
}
@ -636,7 +642,13 @@ static df::unit *getAnyUnit(df::viewscreen *top)
using df::global::ui_selected_unit;
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))
return vector_get(screen->units[screen->page], screen->cursor_pos[screen->page]);
@ -792,6 +804,14 @@ static df::item *getAnyItem(df::viewscreen *top)
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))
return NULL;

@ -1 +1 @@
Subproject commit 230511eef7a6987e34f3e63cfc3eb738ee92b41f
Subproject commit c3c76adcf6dab5d733b256e00ecbe40709fba8ff

@ -6,6 +6,7 @@
#include "modules/Gui.h"
#include "modules/Translation.h"
#include "modules/Units.h"
#include "modules/Job.h"
#include "LuaTools.h"
@ -22,6 +23,7 @@
#include "df/viewscreen_tradegoodsst.h"
#include "df/viewscreen_dwarfmodest.h"
#include "df/viewscreen_petst.h"
#include "df/viewscreen_storesst.h"
#include "df/layer_object_listst.h"
#include "df/assign_trade_status.h"
@ -273,7 +275,16 @@ DEFINE_SORT_HANDLER(unit_sorters, joblist, "", jobs)
{
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_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)
{
auto focus = Gui::getFocusString(screen);