Update handling of viewscreen_workshop_profilest in Gui module, search/sort plugins

develop
lethosor 2016-05-14 11:43:37 -04:00
parent 35de4e34b0
commit 55e58e5f06
4 changed files with 52 additions and 38 deletions

@ -429,16 +429,22 @@ DEFINE_GET_FOCUS_STRING_HANDLER(layer_military)
} }
} }
// DEFINE_GET_FOCUS_STRING_HANDLER(layer_workshop_profile) DEFINE_GET_FOCUS_STRING_HANDLER(workshop_profile)
// { {
// auto list1 = getLayerList(screen, 0); typedef df::viewscreen_workshop_profilest::T_tab T_tab;
// if (!list1) return; switch(screen->tab)
{
// if (vector_get(screen->workers, list1->cursor)) case T_tab::Workers:
// focus += "/Unit"; focus += "/Unit";
// else break;
// focus += "/None"; case T_tab::Orders:
// } focus += "/Orders";
break;
case T_tab::Restrictions:
focus += "/Restrictions";
break;
}
}
DEFINE_GET_FOCUS_STRING_HANDLER(layer_noblelist) DEFINE_GET_FOCUS_STRING_HANDLER(layer_noblelist)
{ {
@ -810,12 +816,12 @@ df::unit *Gui::getAnyUnit(df::viewscreen *top)
return ref ? ref->getUnit() : NULL; return ref ? ref->getUnit() : NULL;
} }
// if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_workshop_profilest, top)) if (VIRTUAL_CAST_VAR(screen, df::viewscreen_workshop_profilest, top))
// { {
// if (auto list1 = getLayerList(screen, 0)) if (screen->tab == df::viewscreen_workshop_profilest::Workers)
// return vector_get(screen->workers, list1->cursor); return vector_get(screen->workers, screen->worker_idx);
// return NULL; return NULL;
// } }
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_noblelistst, top)) if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_noblelistst, top))
{ {

@ -1 +1 @@
Subproject commit 83aa92b3717e876afbd26d300175c17a075c0678 Subproject commit eae49d13af541710f6f6f5a42368e915f74bd749

@ -15,7 +15,7 @@
#include "df/viewscreen_layer_stockpilest.h" #include "df/viewscreen_layer_stockpilest.h"
#include "df/viewscreen_layer_militaryst.h" #include "df/viewscreen_layer_militaryst.h"
#include "df/viewscreen_layer_noblelistst.h" #include "df/viewscreen_layer_noblelistst.h"
#include "df/viewscreen_layer_workshop_profilest.h" #include "df/viewscreen_workshop_profilest.h"
#include "df/viewscreen_topicmeeting_fill_land_holder_positionsst.h" #include "df/viewscreen_topicmeeting_fill_land_holder_positionsst.h"
#include "df/viewscreen_tradegoodsst.h" #include "df/viewscreen_tradegoodsst.h"
#include "df/viewscreen_unitlistst.h" #include "df/viewscreen_unitlistst.h"
@ -1654,11 +1654,16 @@ IMPLEMENT_HOOKS(df::viewscreen_layer_noblelistst, nobles_search);
// //
// START: Workshop profiles search list // START: Workshop profiles search list
// //
typedef layered_search<df::viewscreen_layer_workshop_profilest, df::unit*, 0> profiles_search_base; typedef search_generic<df::viewscreen_workshop_profilest, df::unit*> profiles_search_base;
class profiles_search : public profiles_search_base class profiles_search : public profiles_search_base
{ {
public: public:
bool can_init (df::viewscreen_workshop_profilest *screen)
{
return screen->tab == df::viewscreen_workshop_profilest::T_tab::Workers;
}
string get_element_description(df::unit *element) const string get_element_description(df::unit *element) const
{ {
return get_unit_description(element); return get_unit_description(element);
@ -1673,9 +1678,14 @@ public:
{ {
return &viewscreen->workers; return &viewscreen->workers;
} }
int32_t *get_viewscreen_cursor()
{
return &viewscreen->worker_idx;
}
}; };
IMPLEMENT_HOOKS(df::viewscreen_layer_workshop_profilest, profiles_search); IMPLEMENT_HOOKS(df::viewscreen_workshop_profilest, profiles_search);
// //
// END: Workshop profiles search list // END: Workshop profiles search list

@ -16,7 +16,6 @@
#include "df/viewscreen_joblistst.h" #include "df/viewscreen_joblistst.h"
#include "df/viewscreen_unitlistst.h" #include "df/viewscreen_unitlistst.h"
#include "df/viewscreen_layer_militaryst.h" #include "df/viewscreen_layer_militaryst.h"
#include "df/viewscreen_layer_workshop_profilest.h"
#include "df/viewscreen_layer_noblelistst.h" #include "df/viewscreen_layer_noblelistst.h"
#include "df/viewscreen_layer_overall_healthst.h" #include "df/viewscreen_layer_overall_healthst.h"
#include "df/viewscreen_layer_assigntradest.h" #include "df/viewscreen_layer_assigntradest.h"
@ -24,6 +23,7 @@
#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/viewscreen_storesst.h"
#include "df/viewscreen_workshop_profilest.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"
@ -310,23 +310,6 @@ DEFINE_SORT_HANDLER(unit_sorters, layer_military, "/Positions/Candidates", milit
} }
/*
* Sort units in the workshop 'q'uery 'P'rofile modification screen.
*/
DEFINE_SORT_HANDLER(unit_sorters, layer_workshop_profile, "/Unit", profile)
{
auto list1 = getLayerList(profile, 0);
PARSE_SPEC("units", parameters);
if (compute_order(*pout, L, top, &order, profile->workers))
{
reorder_cursor(&list1->cursor, order);
reorder_vector(&profile->workers, order);
}
}
DEFINE_SORT_HANDLER(unit_sorters, layer_noblelist, "/Appoint", nobles) DEFINE_SORT_HANDLER(unit_sorters, layer_noblelist, "/Appoint", nobles)
{ {
auto list2 = getLayerList(nobles, 1); auto list2 = getLayerList(nobles, 1);
@ -443,6 +426,21 @@ DEFINE_SORT_HANDLER(unit_sorters, dwarfmode, "/QueryBuilding/Some/Assign", scree
} }
} }
/*
* Sort units in the workshop 'q'uery 'P'rofile modification screen.
*/
DEFINE_SORT_HANDLER(unit_sorters, workshop_profile, "/Unit", profile)
{
PARSE_SPEC("units", parameters);
if (compute_order(*pout, L, top, &order, profile->workers))
{
reorder_cursor(&profile->worker_idx, order);
reorder_vector(&profile->workers, order);
}
}
/* /*
* Sort pen assignment candidate units in 'z'->'N'. * Sort pen assignment candidate units in 'z'->'N'.
*/ */