|
|
@ -130,479 +130,261 @@ static std::string getNameChunk(virtual_identity *id, int start, int end)
|
|
|
|
* Classifying focus context by means of a string path.
|
|
|
|
* Classifying focus context by means of a string path.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*getFocusStringHandler)(std::string &str, df::viewscreen *screen);
|
|
|
|
typedef void (*getFocusStringsHandler)(std::string &str, std::vector<std::string> &strList, df::viewscreen *screen);
|
|
|
|
static std::map<virtual_identity*, getFocusStringHandler> getFocusStringHandlers;
|
|
|
|
static std::map<virtual_identity*, getFocusStringsHandler> getFocusStringsHandlers;
|
|
|
|
|
|
|
|
|
|
|
|
#define VIEWSCREEN(name) df::viewscreen_##name##st
|
|
|
|
#define VIEWSCREEN(name) df::viewscreen_##name##st
|
|
|
|
#define DEFINE_GET_FOCUS_STRING_HANDLER(screen_type) \
|
|
|
|
#define DEFINE_GET_FOCUS_STRING_HANDLER(screen_type) \
|
|
|
|
static void getFocusString_##screen_type(std::string &focus, VIEWSCREEN(screen_type) *screen);\
|
|
|
|
static void getFocusStrings_##screen_type(std::string &baseFocus, std::vector<std::string> &focusStrings, VIEWSCREEN(screen_type) *screen);\
|
|
|
|
DFHACK_STATIC_ADD_TO_MAP(\
|
|
|
|
DFHACK_STATIC_ADD_TO_MAP(\
|
|
|
|
&getFocusStringHandlers, &VIEWSCREEN(screen_type)::_identity, \
|
|
|
|
&getFocusStringsHandlers, &VIEWSCREEN(screen_type)::_identity, \
|
|
|
|
(getFocusStringHandler)getFocusString_##screen_type \
|
|
|
|
(getFocusStringsHandler)getFocusStrings_##screen_type \
|
|
|
|
); \
|
|
|
|
); \
|
|
|
|
static void getFocusString_##screen_type(std::string &focus, VIEWSCREEN(screen_type) *screen)
|
|
|
|
static void getFocusStrings_##screen_type(std::string &baseFocus, std::vector<std::string> &focusStrings, VIEWSCREEN(screen_type) *screen)
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
std::string newFocusString;
|
|
|
|
using namespace df::enums::ui_sidebar_mode;
|
|
|
|
|
|
|
|
|
|
|
|
if (game->main_interface.info.open) {
|
|
|
|
using df::global::ui_workshop_in_add;
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
using df::global::ui_build_selector;
|
|
|
|
newFocusString += "/Info";
|
|
|
|
using df::global::ui_selected_unit;
|
|
|
|
newFocusString += "/" + enum_item_key(game->main_interface.info.current_mode);
|
|
|
|
using df::global::ui_look_list;
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
using df::global::ui_look_cursor;
|
|
|
|
}
|
|
|
|
using df::global::ui_building_item_cursor;
|
|
|
|
if (game->main_interface.view_sheets.open) {
|
|
|
|
using df::global::ui_building_assign_type;
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
using df::global::ui_building_assign_is_marked;
|
|
|
|
newFocusString += "/ViewSheets";
|
|
|
|
using df::global::ui_building_assign_units;
|
|
|
|
newFocusString += "/" + enum_item_key(game->main_interface.view_sheets.active_sheet);
|
|
|
|
using df::global::ui_building_assign_items;
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
using df::global::ui_building_in_assign;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::STOCKPILE) {
|
|
|
|
focus += "/" + enum_item_key(plotinfo->main.mode);
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
|
|
|
|
// TODO: learn more about where /Some was used previously to ensure proper/consistent usage
|
|
|
|
switch (plotinfo->main.mode)
|
|
|
|
if (game->main_interface.stockpile.cur_bld) {
|
|
|
|
{
|
|
|
|
newFocusString += "/Some";
|
|
|
|
case QueryBuilding:
|
|
|
|
|
|
|
|
if (df::building *selected = world->selected_building)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!selected->jobs.empty() &&
|
|
|
|
|
|
|
|
selected->jobs[0]->job_type == job_type::DestroyBuilding)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
focus += "/Destroying";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/Some";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual_identity *id = virtual_identity::get(selected);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool jobs = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (id == &df::building_workshopst::_identity ||
|
|
|
|
|
|
|
|
id == &df::building_furnacest::_identity)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
focus += "/Workshop";
|
|
|
|
|
|
|
|
jobs = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (id == &df::building_trapst::_identity)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto trap = (df::building_trapst*)selected;
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(trap->trap_type);
|
|
|
|
|
|
|
|
if (trap->trap_type == trap_type::Lever)
|
|
|
|
|
|
|
|
jobs = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ui_building_in_assign && *ui_building_in_assign &&
|
|
|
|
|
|
|
|
ui_building_assign_type && ui_building_assign_units &&
|
|
|
|
|
|
|
|
ui_building_assign_type->size() == ui_building_assign_units->size())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
focus += "/Assign";
|
|
|
|
|
|
|
|
if (ui_building_item_cursor)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto unit = vector_get(*ui_building_assign_units, *ui_building_item_cursor);
|
|
|
|
|
|
|
|
focus += unit ? "/Unit" : "/None";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(selected->getType());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (jobs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ui_workshop_in_add && *ui_workshop_in_add)
|
|
|
|
|
|
|
|
focus += "/AddJob";
|
|
|
|
|
|
|
|
else if (!selected->jobs.empty())
|
|
|
|
|
|
|
|
focus += "/Job";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
focus += "/Empty";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
newFocusString += "/Stockpile";
|
|
|
|
focus += "/None";
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::HAULING) {
|
|
|
|
case Build:
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
if (ui_build_selector)
|
|
|
|
newFocusString += "/Hauling";
|
|
|
|
{
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
// Not selecting, or no choices?
|
|
|
|
}
|
|
|
|
if (ui_build_selector->building_type < 0)
|
|
|
|
if (game->main_interface.trade.open) {
|
|
|
|
focus += "/Type";
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
else if (ui_build_selector->stage != 2)
|
|
|
|
newFocusString += "/Trade";
|
|
|
|
{
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
if (ui_build_selector->stage != 1)
|
|
|
|
}
|
|
|
|
focus += "/NoMaterials";
|
|
|
|
if (game->main_interface.job_details.open) {
|
|
|
|
else
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/Position";
|
|
|
|
newFocusString += "/JobDetails";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
focus += "/" + enum_item_key(ui_build_selector->building_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (game->main_interface.assign_trade.open) {
|
|
|
|
else
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
{
|
|
|
|
newFocusString += "/AssignTrade";
|
|
|
|
focus += "/Material";
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
if (ui_build_selector->is_grouped)
|
|
|
|
}
|
|
|
|
focus += "/Groups";
|
|
|
|
if (game->main_interface.diplomacy.open) {
|
|
|
|
else
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/Items";
|
|
|
|
newFocusString += "/Diplomacy";
|
|
|
|
}
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
if (game->main_interface.petitions.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
case ViewUnits:
|
|
|
|
newFocusString += "/Petitions";
|
|
|
|
if (ui_selected_unit)
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
if (vector_get(world->units.active, *ui_selected_unit))
|
|
|
|
if (game->main_interface.stocks.open) {
|
|
|
|
{
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/Some";
|
|
|
|
newFocusString += "/Stocks";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
using df::global::ui_unit_view_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.assign_display_item.open) {
|
|
|
|
if (ui_unit_view_mode)
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/" + enum_item_key(ui_unit_view_mode->value);
|
|
|
|
newFocusString += "/AssignDisplayItem";
|
|
|
|
}
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
else
|
|
|
|
}
|
|
|
|
focus += "/None";
|
|
|
|
if (game->main_interface.name_creator.open) {
|
|
|
|
}
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
break;
|
|
|
|
newFocusString += "/NameCreator";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
case LookAround:
|
|
|
|
}
|
|
|
|
if (ui_look_list && ui_look_cursor)
|
|
|
|
if (game->main_interface.image_creator.open) {
|
|
|
|
{
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
auto item = vector_get(ui_look_list->items, *ui_look_cursor);
|
|
|
|
newFocusString += "/ImageCreator";
|
|
|
|
if (item)
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
focus += "/" + enum_item_key(item->type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (game->main_interface.unit_selector.open) {
|
|
|
|
focus += "/None";
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
}
|
|
|
|
newFocusString += "/UnitSelector";
|
|
|
|
break;
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
|
|
|
|
}
|
|
|
|
case BuildingItems:
|
|
|
|
if (game->main_interface.announcement_alert.open) {
|
|
|
|
if (VIRTUAL_CAST_VAR(selected, df::building_actual, world->selected_building))
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
{
|
|
|
|
newFocusString += "/AnnouncementAlert";
|
|
|
|
if (selected->contained_items.empty())
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
focus += "/Some/Empty";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (game->main_interface.custom_symbol.open) {
|
|
|
|
focus += "/Some/Item";
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
}
|
|
|
|
newFocusString += "/CustomSymbol";
|
|
|
|
else
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
focus += "/None";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
if (game->main_interface.patrol_routes.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
case ZonesPenInfo:
|
|
|
|
newFocusString += "/PatrolRoutes";
|
|
|
|
if (ui_building_assign_type && ui_building_assign_units &&
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
ui_building_assign_is_marked && ui_building_assign_items &&
|
|
|
|
}
|
|
|
|
ui_building_assign_type->size() == ui_building_assign_units->size())
|
|
|
|
if (game->main_interface.squad_equipment.open) {
|
|
|
|
{
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/Assign";
|
|
|
|
newFocusString += "/SquadEquipment";
|
|
|
|
if (ui_building_item_cursor)
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
if (vector_get(*ui_building_assign_units, *ui_building_item_cursor))
|
|
|
|
if (game->main_interface.squad_schedule.open) {
|
|
|
|
focus += "/Unit";
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
else if (vector_get(*ui_building_assign_items, *ui_building_item_cursor))
|
|
|
|
newFocusString += "/SquadSchedule";
|
|
|
|
focus += "/Vermin";
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
else
|
|
|
|
}
|
|
|
|
focus += "/None";
|
|
|
|
if (game->main_interface.squad_selector.open) {
|
|
|
|
}
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
}
|
|
|
|
newFocusString += "/SquadSelector";
|
|
|
|
break;
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
|
|
|
|
}
|
|
|
|
case Burrows:
|
|
|
|
if (game->main_interface.burrow_selector.open) {
|
|
|
|
if (plotinfo->burrows.in_confirm_delete)
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/ConfirmDelete";
|
|
|
|
newFocusString += "/BurrowSelector";
|
|
|
|
else if (plotinfo->burrows.in_add_units_mode)
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
focus += "/AddUnits";
|
|
|
|
}
|
|
|
|
else if (plotinfo->burrows.in_edit_name_mode)
|
|
|
|
if (game->main_interface.location_selector.open) {
|
|
|
|
focus += "/EditName";
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
else if (plotinfo->burrows.in_define_mode)
|
|
|
|
newFocusString += "/LocationSelector";
|
|
|
|
focus += "/Define";
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
else
|
|
|
|
}
|
|
|
|
focus += "/List";
|
|
|
|
if (game->main_interface.location_details.open) {
|
|
|
|
break;
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
|
|
|
|
newFocusString += "/LocationDetails";
|
|
|
|
case Hauling:
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
if (plotinfo->hauling.in_assign_vehicle)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
if (game->main_interface.hauling_stop_conditions.open) {
|
|
|
|
auto vehicle = vector_get(plotinfo->hauling.vehicles, plotinfo->hauling.cursor_vehicle);
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/AssignVehicle/" + std::string(vehicle ? "Some" : "None");
|
|
|
|
newFocusString += "/HaulingStopConditions";
|
|
|
|
}
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
else
|
|
|
|
}
|
|
|
|
{
|
|
|
|
if (game->main_interface.assign_vehicle.open) {
|
|
|
|
int idx = plotinfo->hauling.cursor_top;
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
auto route = vector_get(plotinfo->hauling.view_routes, idx);
|
|
|
|
newFocusString += "/AssignVehicle";
|
|
|
|
auto stop = vector_get(plotinfo->hauling.view_stops, idx);
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
std::string tag = stop ? "Stop" : (route ? "Route" : "None");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.stockpile_link.open) {
|
|
|
|
if (plotinfo->hauling.in_name)
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/Rename/" + tag;
|
|
|
|
newFocusString += "/StockpileLink";
|
|
|
|
else if (plotinfo->hauling.in_stop)
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
int sidx = plotinfo->hauling.cursor_stop;
|
|
|
|
if (game->main_interface.stockpile_tools.open) {
|
|
|
|
auto cond = vector_get(plotinfo->hauling.stop_conditions, sidx);
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
auto link = vector_get(plotinfo->hauling.stop_links, sidx);
|
|
|
|
newFocusString += "/StockpileTools";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
focus += "/DefineStop";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.custom_stockpile.open) {
|
|
|
|
if (cond)
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
focus += "/Cond/" + enum_item_key(cond->mode);
|
|
|
|
newFocusString += "/CustomStockpile";
|
|
|
|
else if (link)
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
focus += "/Link/";
|
|
|
|
if (game->main_interface.create_squad.open) {
|
|
|
|
if (link->mode.bits.give) focus += "Give";
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
if (link->mode.bits.take) focus += "Take";
|
|
|
|
newFocusString += "/CreateSquad";
|
|
|
|
}
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
else
|
|
|
|
}
|
|
|
|
focus += "/None";
|
|
|
|
if (game->main_interface.squad_supplies.open) {
|
|
|
|
}
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
else
|
|
|
|
newFocusString += "/SquadSupplies";
|
|
|
|
focus += "/Select/" + tag;
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
if (game->main_interface.assign_uniform.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
default:
|
|
|
|
newFocusString += "/AssignUniform";
|
|
|
|
break;
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.create_work_order.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
|
|
|
|
newFocusString += "/CreateWorkOrder";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.hotkey.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
|
|
|
|
newFocusString += "/Hotkey";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.options.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
|
|
|
|
newFocusString += "/Options";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.help.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
|
|
|
|
newFocusString += "/Help";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game->main_interface.settings.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
|
|
|
|
newFocusString += "/Settings";
|
|
|
|
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
if (game->main_interface.squad_equipment.open) {
|
|
|
|
}
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
|
|
|
|
newFocusString += "/SquadEquipment";
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(dungeonmode)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// squads should be last because it's the only one not exclusive with the others? or something?
|
|
|
|
using df::global::adventure;
|
|
|
|
if (game->main_interface.squads.open) {
|
|
|
|
|
|
|
|
newFocusString = baseFocus;
|
|
|
|
if (!adventure)
|
|
|
|
newFocusString += "/Squads";
|
|
|
|
return;
|
|
|
|
focusStrings.push_back(newFocusString);
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(adventure->menu);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(unitlist)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(screen->page);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(layer_military)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto list1 = getLayerList(screen, 0);
|
|
|
|
|
|
|
|
auto list2 = getLayerList(screen, 1);
|
|
|
|
|
|
|
|
auto list3 = getLayerList(screen, 2);
|
|
|
|
|
|
|
|
if (!list1 || !list2 || !list3) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(screen->page);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int cur_list;
|
|
|
|
|
|
|
|
if (list1->active) cur_list = 0;
|
|
|
|
|
|
|
|
else if (list2->active) cur_list = 1;
|
|
|
|
|
|
|
|
else if (list3->active) cur_list = 2;
|
|
|
|
|
|
|
|
else return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (screen->page)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case df::viewscreen_layer_militaryst::Positions:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
static const char *lists[] = { "/Squads", "/Positions", "/Candidates" };
|
|
|
|
|
|
|
|
focus += lists[cur_list];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case df::viewscreen_layer_militaryst::Equip:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(screen->equip.mode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (screen->equip.mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case df::viewscreen_layer_militaryst::T_equip::Customize:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (screen->equip.edit_mode < 0)
|
|
|
|
|
|
|
|
focus += "/View";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(screen->equip.edit_mode);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case df::viewscreen_layer_militaryst::T_equip::Uniform:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case df::viewscreen_layer_militaryst::T_equip::Priority:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (screen->equip.prio_in_move >= 0)
|
|
|
|
|
|
|
|
focus += "/Move";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
focus += "/View";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char *lists[] = { "/Squads", "/Positions", "/Choices" };
|
|
|
|
|
|
|
|
focus += lists[cur_list];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(workshop_profile)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef df::viewscreen_workshop_profilest::T_tab T_tab;
|
|
|
|
|
|
|
|
switch(screen->tab)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case T_tab::Workers:
|
|
|
|
|
|
|
|
focus += "/Unit";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_tab::Orders:
|
|
|
|
|
|
|
|
focus += "/Orders";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_tab::Restrictions:
|
|
|
|
|
|
|
|
focus += "/Restrictions";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(layer_noblelist)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto list1 = getLayerList(screen, 0);
|
|
|
|
|
|
|
|
auto list2 = getLayerList(screen, 1);
|
|
|
|
|
|
|
|
if (!list1 || !list2) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(screen->mode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(pet)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(screen->mode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (screen->mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case df::viewscreen_petst::List:
|
|
|
|
|
|
|
|
focus += vector_get(screen->is_vermin, screen->cursor) ? "/Vermin" : "/Unit";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case df::viewscreen_petst::SelectTrainer:
|
|
|
|
|
|
|
|
if (vector_get(screen->trainer_unit, screen->trainer_cursor))
|
|
|
|
|
|
|
|
focus += "/Unit";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(layer_overall_health)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto list1 = getLayerList(screen, 0);
|
|
|
|
|
|
|
|
if (!list1) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/Units";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(tradegoods)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!screen->has_traders || screen->is_unloading)
|
|
|
|
|
|
|
|
focus += "/NoTraders";
|
|
|
|
|
|
|
|
else if (screen->in_edit_count)
|
|
|
|
|
|
|
|
focus += "/EditCount";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
focus += (screen->in_right_pane ? "/Items/Broker" : "/Items/Trader");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(layer_assigntrade)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto list1 = getLayerList(screen, 0);
|
|
|
|
|
|
|
|
auto list2 = getLayerList(screen, 1);
|
|
|
|
|
|
|
|
if (!list1 || !list2) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int list_idx = vector_get(screen->visible_lists, list1->cursor, (int16_t)-1);
|
|
|
|
|
|
|
|
unsigned num_lists = sizeof(screen->lists)/sizeof(screen->lists[0]);
|
|
|
|
|
|
|
|
if (unsigned(list_idx) >= num_lists)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list1->active)
|
|
|
|
|
|
|
|
focus += "/Groups";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(layer_stockpile)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto list1 = getLayerList(screen, 0);
|
|
|
|
|
|
|
|
auto list2 = getLayerList(screen, 1);
|
|
|
|
|
|
|
|
auto list3 = getLayerList(screen, 2);
|
|
|
|
|
|
|
|
if (!list1 || !list2 || !list3 || !screen->settings) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto group = screen->cur_group;
|
|
|
|
|
|
|
|
if (group != vector_get(screen->group_ids, list1->cursor))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(group);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto bits = vector_get(screen->group_bits, list1->cursor);
|
|
|
|
|
|
|
|
if (bits.whole && !(bits.whole & screen->settings->flags.whole))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
focus += "/Off";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/On";
|
|
|
|
if (!newFocusString.size()) {
|
|
|
|
|
|
|
|
focusStrings.push_back(baseFocus);
|
|
|
|
if (list2->active || list3->active || screen->list_ids.empty()) {
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(screen->cur_list);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list3->active)
|
|
|
|
|
|
|
|
focus += (screen->item_names.empty() ? "/None" : "/Item");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(locations)
|
|
|
|
bool Gui::matchFocusString(std::string focusString) {
|
|
|
|
{
|
|
|
|
focusString = toLower(focusString);
|
|
|
|
focus += "/" + enum_item_key(screen->menu);
|
|
|
|
std::vector<std::string> currentFocus = getFocusStrings(Core::getTopViewscreen());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(jobmanagement)
|
|
|
|
return std::find_if(currentFocus.begin(), currentFocus.end(), [&focusString](std::string item) {
|
|
|
|
{
|
|
|
|
return focusString == toLower(item);
|
|
|
|
focus += (screen->in_max_workshops ? "/MaxWorkshops" : "/Main");
|
|
|
|
}) != currentFocus.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(workquota_condition)
|
|
|
|
std::vector<std::string> Gui::getFocusStrings(df::viewscreen* top)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
focus += "/" + enum_item_key(screen->mode);
|
|
|
|
std::vector<std::string> focusStrings;
|
|
|
|
if (screen->item_count_edit)
|
|
|
|
|
|
|
|
focus += "/EditCount";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string Gui::getFocusString(df::viewscreen *top)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!top)
|
|
|
|
if (!top)
|
|
|
|
return "";
|
|
|
|
return focusStrings;
|
|
|
|
|
|
|
|
|
|
|
|
if (dfhack_viewscreen::is_instance(top))
|
|
|
|
if (dfhack_viewscreen::is_instance(top))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto name = static_cast<dfhack_viewscreen*>(top)->getFocusString();
|
|
|
|
auto name = static_cast<dfhack_viewscreen*>(top)->getFocusStrings();
|
|
|
|
return name.empty() ? "dfhack" : "dfhack/"+name;
|
|
|
|
focusStrings.push_back(name.empty() ? "dfhack" : "dfhack/" + name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (virtual_identity *id = virtual_identity::get(top))
|
|
|
|
else if (virtual_identity *id = virtual_identity::get(top))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string name = getNameChunk(id, 11, 2);
|
|
|
|
std::string name = getNameChunk(id, 11, 2);
|
|
|
|
|
|
|
|
|
|
|
|
auto handler = map_find(getFocusStringHandlers, id);
|
|
|
|
auto handler = map_find(getFocusStringsHandlers, id);
|
|
|
|
if (handler)
|
|
|
|
if (handler)
|
|
|
|
handler(name, top);
|
|
|
|
handler(name, focusStrings, top);
|
|
|
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Core &core = Core::getInstance();
|
|
|
|
Core &core = Core::getInstance();
|
|
|
|
std::string name = core.p->readClassName(*(void**)top);
|
|
|
|
std::string name = core.p->readClassName(*(void**)top);
|
|
|
|
return name.substr(11, name.size()-11-2);
|
|
|
|
focusStrings.push_back(name.substr(11, name.size()-11-2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return focusStrings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Predefined common guard functions
|
|
|
|
// Predefined common guard functions
|
|
|
@ -1269,6 +1051,28 @@ df::item *Gui::getSelectedItem(color_ostream &out, bool quiet)
|
|
|
|
return item;
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Gui::any_stockpile_hotkey(df::viewscreen* top)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return getAnyStockpile(top) != NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
df::building_stockpilest* Gui::getAnyStockpile(df::viewscreen* top) {
|
|
|
|
|
|
|
|
if (matchFocusString("dwarfmode/Some/Stockpile")) {
|
|
|
|
|
|
|
|
return game->main_interface.stockpile.cur_bld;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
df::building_stockpilest* Gui::getSelectedStockpile(color_ostream& out, bool quiet) {
|
|
|
|
|
|
|
|
df::building_stockpilest* stockpile = getAnyStockpile(Core::getTopViewscreen());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!stockpile && !quiet)
|
|
|
|
|
|
|
|
out.printerr("No stockpile is selected in the UI.\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return stockpile;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
df::building *Gui::getAnyBuilding(df::viewscreen *top)
|
|
|
|
df::building *Gui::getAnyBuilding(df::viewscreen *top)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using df::global::game;
|
|
|
|
using df::global::game;
|
|
|
|