|
|
@ -61,12 +61,12 @@ using namespace DFHack;
|
|
|
|
#include "df/general_ref.h"
|
|
|
|
#include "df/general_ref.h"
|
|
|
|
#include "df/global_objects.h"
|
|
|
|
#include "df/global_objects.h"
|
|
|
|
#include "df/graphic.h"
|
|
|
|
#include "df/graphic.h"
|
|
|
|
|
|
|
|
#include "df/graphic_viewportst.h"
|
|
|
|
#include "df/historical_figure.h"
|
|
|
|
#include "df/historical_figure.h"
|
|
|
|
#include "df/interfacest.h"
|
|
|
|
#include "df/interfacest.h"
|
|
|
|
#include "df/item_corpsepiecest.h"
|
|
|
|
#include "df/item_corpsepiecest.h"
|
|
|
|
#include "df/item_corpsest.h"
|
|
|
|
#include "df/item_corpsest.h"
|
|
|
|
#include "df/job.h"
|
|
|
|
#include "df/job.h"
|
|
|
|
#include "df/layer_object_listst.h"
|
|
|
|
|
|
|
|
#include "df/occupation.h"
|
|
|
|
#include "df/occupation.h"
|
|
|
|
#include "df/plant.h"
|
|
|
|
#include "df/plant.h"
|
|
|
|
#include "df/popup_message.h"
|
|
|
|
#include "df/popup_message.h"
|
|
|
@ -74,10 +74,10 @@ using namespace DFHack;
|
|
|
|
#include "df/report_zoom_type.h"
|
|
|
|
#include "df/report_zoom_type.h"
|
|
|
|
#include "df/route_stockpile_link.h"
|
|
|
|
#include "df/route_stockpile_link.h"
|
|
|
|
#include "df/stop_depart_condition.h"
|
|
|
|
#include "df/stop_depart_condition.h"
|
|
|
|
#include "df/ui_advmode.h"
|
|
|
|
#include "df/adventurest.h"
|
|
|
|
#include "df/ui_build_selector.h"
|
|
|
|
#include "df/buildreq.h"
|
|
|
|
#include "df/ui_look_list.h"
|
|
|
|
#include "df/ui_look_list.h"
|
|
|
|
#include "df/ui_sidebar_menus.h"
|
|
|
|
#include "df/gamest.h"
|
|
|
|
#include "df/ui_unit_view_mode.h"
|
|
|
|
#include "df/ui_unit_view_mode.h"
|
|
|
|
#include "df/unit.h"
|
|
|
|
#include "df/unit.h"
|
|
|
|
#include "df/unit_inventory_item.h"
|
|
|
|
#include "df/unit_inventory_item.h"
|
|
|
@ -101,9 +101,9 @@ using df::global::gps;
|
|
|
|
using df::global::gview;
|
|
|
|
using df::global::gview;
|
|
|
|
using df::global::init;
|
|
|
|
using df::global::init;
|
|
|
|
using df::global::selection_rect;
|
|
|
|
using df::global::selection_rect;
|
|
|
|
using df::global::ui;
|
|
|
|
using df::global::plotinfo;
|
|
|
|
using df::global::ui_menu_width;
|
|
|
|
using df::global::ui_menu_width;
|
|
|
|
using df::global::ui_sidebar_menus;
|
|
|
|
using df::global::game;
|
|
|
|
using df::global::world;
|
|
|
|
using df::global::world;
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
@ -143,6 +143,7 @@ static std::map<virtual_identity*, getFocusStringHandler> getFocusStringHandlers
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
using namespace df::enums::ui_sidebar_mode;
|
|
|
|
using namespace df::enums::ui_sidebar_mode;
|
|
|
|
|
|
|
|
|
|
|
|
using df::global::ui_workshop_in_add;
|
|
|
|
using df::global::ui_workshop_in_add;
|
|
|
@ -157,9 +158,9 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
|
|
|
|
using df::global::ui_building_assign_items;
|
|
|
|
using df::global::ui_building_assign_items;
|
|
|
|
using df::global::ui_building_in_assign;
|
|
|
|
using df::global::ui_building_in_assign;
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(ui->main.mode);
|
|
|
|
focus += "/" + enum_item_key(plotinfo->main.mode);
|
|
|
|
|
|
|
|
|
|
|
|
switch (ui->main.mode)
|
|
|
|
switch (plotinfo->main.mode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case QueryBuilding:
|
|
|
|
case QueryBuilding:
|
|
|
|
if (df::building *selected = world->selected_building)
|
|
|
|
if (df::building *selected = world->selected_building)
|
|
|
@ -303,39 +304,38 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Burrows:
|
|
|
|
case Burrows:
|
|
|
|
if (ui->burrows.in_confirm_delete)
|
|
|
|
if (plotinfo->burrows.in_confirm_delete)
|
|
|
|
focus += "/ConfirmDelete";
|
|
|
|
focus += "/ConfirmDelete";
|
|
|
|
else if (ui->burrows.in_add_units_mode)
|
|
|
|
else if (plotinfo->burrows.in_add_units_mode)
|
|
|
|
focus += "/AddUnits";
|
|
|
|
focus += "/AddUnits";
|
|
|
|
else if (ui->burrows.in_edit_name_mode)
|
|
|
|
else if (plotinfo->burrows.in_edit_name_mode)
|
|
|
|
focus += "/EditName";
|
|
|
|
focus += "/EditName";
|
|
|
|
else if (ui->burrows.in_define_mode)
|
|
|
|
else if (plotinfo->burrows.in_define_mode)
|
|
|
|
focus += "/Define";
|
|
|
|
focus += "/Define";
|
|
|
|
else
|
|
|
|
else
|
|
|
|
focus += "/List";
|
|
|
|
focus += "/List";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
|
|
|
|
case Hauling:
|
|
|
|
case Hauling:
|
|
|
|
if (ui->hauling.in_assign_vehicle)
|
|
|
|
if (plotinfo->hauling.in_assign_vehicle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto vehicle = vector_get(ui->hauling.vehicles, ui->hauling.cursor_vehicle);
|
|
|
|
auto vehicle = vector_get(plotinfo->hauling.vehicles, plotinfo->hauling.cursor_vehicle);
|
|
|
|
focus += "/AssignVehicle/" + std::string(vehicle ? "Some" : "None");
|
|
|
|
focus += "/AssignVehicle/" + std::string(vehicle ? "Some" : "None");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int idx = ui->hauling.cursor_top;
|
|
|
|
int idx = plotinfo->hauling.cursor_top;
|
|
|
|
auto route = vector_get(ui->hauling.view_routes, idx);
|
|
|
|
auto route = vector_get(plotinfo->hauling.view_routes, idx);
|
|
|
|
auto stop = vector_get(ui->hauling.view_stops, idx);
|
|
|
|
auto stop = vector_get(plotinfo->hauling.view_stops, idx);
|
|
|
|
std::string tag = stop ? "Stop" : (route ? "Route" : "None");
|
|
|
|
std::string tag = stop ? "Stop" : (route ? "Route" : "None");
|
|
|
|
|
|
|
|
|
|
|
|
if (ui->hauling.in_name)
|
|
|
|
if (plotinfo->hauling.in_name)
|
|
|
|
focus += "/Rename/" + tag;
|
|
|
|
focus += "/Rename/" + tag;
|
|
|
|
else if (ui->hauling.in_stop)
|
|
|
|
else if (plotinfo->hauling.in_stop)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int sidx = ui->hauling.cursor_stop;
|
|
|
|
int sidx = plotinfo->hauling.cursor_stop;
|
|
|
|
auto cond = vector_get(ui->hauling.stop_conditions, sidx);
|
|
|
|
auto cond = vector_get(plotinfo->hauling.stop_conditions, sidx);
|
|
|
|
auto link = vector_get(ui->hauling.stop_links, sidx);
|
|
|
|
auto link = vector_get(plotinfo->hauling.stop_links, sidx);
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/DefineStop";
|
|
|
|
focus += "/DefineStop";
|
|
|
|
|
|
|
|
|
|
|
@ -354,22 +354,22 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
|
|
|
|
focus += "/Select/" + tag;
|
|
|
|
focus += "/Select/" + tag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(dungeonmode)
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(dungeonmode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using df::global::ui_advmode;
|
|
|
|
using df::global::adventure;
|
|
|
|
|
|
|
|
|
|
|
|
if (!ui_advmode)
|
|
|
|
if (!adventure)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
focus += "/" + enum_item_key(ui_advmode->menu);
|
|
|
|
focus += "/" + enum_item_key(adventure->menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(unitlist)
|
|
|
|
DEFINE_GET_FOCUS_STRING_HANDLER(unitlist)
|
|
|
@ -667,14 +667,15 @@ bool Gui::cursor_hotkey(df::viewscreen *top)
|
|
|
|
|
|
|
|
|
|
|
|
bool Gui::workshop_job_hotkey(df::viewscreen *top)
|
|
|
|
bool Gui::workshop_job_hotkey(df::viewscreen *top)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!dwarfmode_hotkey(top))
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
using df::global::ui_workshop_in_add;
|
|
|
|
using df::global::ui_workshop_in_add;
|
|
|
|
using df::global::ui_workshop_job_cursor;
|
|
|
|
using df::global::ui_workshop_job_cursor;
|
|
|
|
|
|
|
|
|
|
|
|
if (!dwarfmode_hotkey(top))
|
|
|
|
switch (plotinfo->main.mode) {
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (ui->main.mode) {
|
|
|
|
|
|
|
|
case QueryBuilding:
|
|
|
|
case QueryBuilding:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!ui_workshop_job_cursor) // allow missing
|
|
|
|
if (!ui_workshop_job_cursor) // allow missing
|
|
|
@ -699,17 +700,19 @@ bool Gui::workshop_job_hotkey(df::viewscreen *top)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/ return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Gui::build_selector_hotkey(df::viewscreen *top)
|
|
|
|
bool Gui::build_selector_hotkey(df::viewscreen *top)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
|
|
|
|
using df::global::ui_build_selector;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!dwarfmode_hotkey(top))
|
|
|
|
if (!dwarfmode_hotkey(top))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
switch (ui->main.mode) {
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
|
|
|
|
using df::global::ui_build_selector;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (plotinfo->main.mode) {
|
|
|
|
case Build:
|
|
|
|
case Build:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!ui_build_selector) // allow missing
|
|
|
|
if (!ui_build_selector) // allow missing
|
|
|
@ -726,20 +729,23 @@ bool Gui::build_selector_hotkey(df::viewscreen *top)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/ return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Gui::view_unit_hotkey(df::viewscreen *top)
|
|
|
|
bool Gui::view_unit_hotkey(df::viewscreen *top)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using df::global::ui_selected_unit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!dwarfmode_hotkey(top))
|
|
|
|
if (!dwarfmode_hotkey(top))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if (ui->main.mode != ui_sidebar_mode::ViewUnits)
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
|
|
|
|
using df::global::ui_selected_unit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (plotinfo->main.mode != ui_sidebar_mode::ViewUnits)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if (!ui_selected_unit) // allow missing
|
|
|
|
if (!ui_selected_unit) // allow missing
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return vector_get(world->units.active, *ui_selected_unit) != NULL;
|
|
|
|
return vector_get(world->units.active, *ui_selected_unit) != NULL;
|
|
|
|
|
|
|
|
*/ return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Gui::unit_inventory_hotkey(df::viewscreen *top)
|
|
|
|
bool Gui::unit_inventory_hotkey(df::viewscreen *top)
|
|
|
@ -826,6 +832,7 @@ df::job *Gui::getSelectedJob(color_ostream &out, bool quiet)
|
|
|
|
|
|
|
|
|
|
|
|
df::unit *Gui::getAnyUnit(df::viewscreen *top)
|
|
|
|
df::unit *Gui::getAnyUnit(df::viewscreen *top)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
using df::global::ui_look_cursor;
|
|
|
|
using df::global::ui_look_cursor;
|
|
|
|
using df::global::ui_look_list;
|
|
|
|
using df::global::ui_look_list;
|
|
|
@ -834,7 +841,6 @@ df::unit *Gui::getAnyUnit(df::viewscreen *top)
|
|
|
|
using df::global::ui_building_assign_units;
|
|
|
|
using df::global::ui_building_assign_units;
|
|
|
|
using df::global::ui_building_item_cursor;
|
|
|
|
using df::global::ui_building_item_cursor;
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
|
|
|
|
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_unitst, top))
|
|
|
|
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_unitst, top))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return screen->unit;
|
|
|
|
return screen->unit;
|
|
|
@ -1011,19 +1017,19 @@ df::unit *Gui::getAnyUnit(df::viewscreen *top)
|
|
|
|
if (!Gui::dwarfmode_hotkey(top))
|
|
|
|
if (!Gui::dwarfmode_hotkey(top))
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (!ui)
|
|
|
|
if (!plotinfo)
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
// general assigning units in building, i.e. (q)uery cage -> (a)ssign
|
|
|
|
// general assigning units in building, i.e. (q)uery cage -> (a)ssign
|
|
|
|
if (ui_building_in_assign && *ui_building_in_assign
|
|
|
|
if (ui_building_in_assign && *ui_building_in_assign
|
|
|
|
&& ui_building_assign_units && ui_building_item_cursor
|
|
|
|
&& ui_building_assign_units && ui_building_item_cursor
|
|
|
|
&& ui->main.mode != Zones) // dont show for (i) zone
|
|
|
|
&& plotinfo->main.mode != Zones) // dont show for (i) zone
|
|
|
|
return vector_get(*ui_building_assign_units, *ui_building_item_cursor);
|
|
|
|
return vector_get(*ui_building_assign_units, *ui_building_item_cursor);
|
|
|
|
|
|
|
|
|
|
|
|
if (ui->follow_unit != -1)
|
|
|
|
if (plotinfo->follow_unit != -1)
|
|
|
|
return df::unit::find(ui->follow_unit);
|
|
|
|
return df::unit::find(plotinfo->follow_unit);
|
|
|
|
|
|
|
|
|
|
|
|
switch (ui->main.mode) {
|
|
|
|
switch (plotinfo->main.mode) {
|
|
|
|
case ViewUnits:
|
|
|
|
case ViewUnits:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!ui_selected_unit || !world)
|
|
|
|
if (!ui_selected_unit || !world)
|
|
|
@ -1041,8 +1047,8 @@ df::unit *Gui::getAnyUnit(df::viewscreen *top)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case Burrows:
|
|
|
|
case Burrows:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ui->burrows.in_add_units_mode)
|
|
|
|
if (plotinfo->burrows.in_add_units_mode)
|
|
|
|
return vector_get(ui->burrows.list_units, ui->burrows.unit_cursor_pos);
|
|
|
|
return vector_get(plotinfo->burrows.list_units, plotinfo->burrows.unit_cursor_pos);
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1108,13 +1114,13 @@ df::unit *Gui::getSelectedUnit(color_ostream &out, bool quiet)
|
|
|
|
|
|
|
|
|
|
|
|
df::item *Gui::getAnyItem(df::viewscreen *top)
|
|
|
|
df::item *Gui::getAnyItem(df::viewscreen *top)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
using df::global::ui_look_cursor;
|
|
|
|
using df::global::ui_look_cursor;
|
|
|
|
using df::global::ui_look_list;
|
|
|
|
using df::global::ui_look_list;
|
|
|
|
using df::global::ui_unit_view_mode;
|
|
|
|
using df::global::ui_unit_view_mode;
|
|
|
|
using df::global::ui_building_item_cursor;
|
|
|
|
using df::global::ui_building_item_cursor;
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
|
|
|
|
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_textviewerst, top))
|
|
|
|
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_textviewerst, top))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// return the main item if the parent screen is a viewscreen_itemst
|
|
|
|
// return the main item if the parent screen is a viewscreen_itemst
|
|
|
@ -1190,16 +1196,16 @@ df::item *Gui::getAnyItem(df::viewscreen *top)
|
|
|
|
if (!Gui::dwarfmode_hotkey(top))
|
|
|
|
if (!Gui::dwarfmode_hotkey(top))
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
switch (ui->main.mode) {
|
|
|
|
switch (plotinfo->main.mode) {
|
|
|
|
case ViewUnits:
|
|
|
|
case ViewUnits:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!ui_unit_view_mode || !ui_look_cursor || !ui_sidebar_menus)
|
|
|
|
if (!ui_unit_view_mode || !ui_look_cursor || !game)
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (ui_unit_view_mode->value != df::ui_unit_view_mode::Inventory)
|
|
|
|
if (ui_unit_view_mode->value != df::ui_unit_view_mode::Inventory)
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
auto inv_item = vector_get(ui_sidebar_menus->unit.inv_items, *ui_look_cursor);
|
|
|
|
auto inv_item = vector_get(game->unit.inv_items, *ui_look_cursor);
|
|
|
|
return inv_item ? inv_item->item : NULL;
|
|
|
|
return inv_item ? inv_item->item : NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case LookAround:
|
|
|
|
case LookAround:
|
|
|
@ -1248,11 +1254,11 @@ df::item *Gui::getSelectedItem(color_ostream &out, bool quiet)
|
|
|
|
|
|
|
|
|
|
|
|
df::building *Gui::getAnyBuilding(df::viewscreen *top)
|
|
|
|
df::building *Gui::getAnyBuilding(df::viewscreen *top)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
using namespace ui_sidebar_mode;
|
|
|
|
using df::global::ui_look_list;
|
|
|
|
using df::global::ui_look_list;
|
|
|
|
using df::global::ui_look_cursor;
|
|
|
|
using df::global::ui_look_cursor;
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
|
|
|
|
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_buildinglistst, top))
|
|
|
|
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_buildinglistst, top))
|
|
|
|
return vector_get(screen->buildings, screen->cursor);
|
|
|
|
return vector_get(screen->buildings, screen->cursor);
|
|
|
|
|
|
|
|
|
|
|
@ -1265,7 +1271,7 @@ df::building *Gui::getAnyBuilding(df::viewscreen *top)
|
|
|
|
if (!Gui::dwarfmode_hotkey(top))
|
|
|
|
if (!Gui::dwarfmode_hotkey(top))
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
switch (ui->main.mode) {
|
|
|
|
switch (plotinfo->main.mode) {
|
|
|
|
case LookAround:
|
|
|
|
case LookAround:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!ui_look_list || !ui_look_cursor)
|
|
|
|
if (!ui_look_list || !ui_look_cursor)
|
|
|
@ -1287,8 +1293,8 @@ df::building *Gui::getAnyBuilding(df::viewscreen *top)
|
|
|
|
case ZonesPitInfo:
|
|
|
|
case ZonesPitInfo:
|
|
|
|
case ZonesHospitalInfo:
|
|
|
|
case ZonesHospitalInfo:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ui_sidebar_menus)
|
|
|
|
if (game)
|
|
|
|
return ui_sidebar_menus->zone.selected;
|
|
|
|
return game->zone.selected;
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -1321,13 +1327,15 @@ df::plant *Gui::getAnyPlant(df::viewscreen *top)
|
|
|
|
|
|
|
|
|
|
|
|
if (Gui::dwarfmode_hotkey(top))
|
|
|
|
if (Gui::dwarfmode_hotkey(top))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!cursor || !ui || !world)
|
|
|
|
if (!cursor || !plotinfo || !world)
|
|
|
|
return nullptr;
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
if (ui->main.mode == ui_sidebar_mode::LookAround)
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
|
|
|
|
if (plotinfo->main.mode == ui_sidebar_mode::LookAround)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Maps::getPlantAtTile(cursor->x, cursor->y, cursor->z);
|
|
|
|
return Maps::getPlantAtTile(cursor->x, cursor->y, cursor->z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
return nullptr;
|
|
|
@ -1865,6 +1873,12 @@ bool Gui::autoDFAnnouncement(df::announcement_type type, df::coord pos, std::str
|
|
|
|
return autoDFAnnouncement(r, message);
|
|
|
|
return autoDFAnnouncement(r, message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static df::viewscreen * do_skip_dismissed(df::viewscreen * ws) {
|
|
|
|
|
|
|
|
while (ws && Screen::isDismissed(ws) && ws->parent)
|
|
|
|
|
|
|
|
ws = ws->parent;
|
|
|
|
|
|
|
|
return ws;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed)
|
|
|
|
df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!gview)
|
|
|
|
if (!gview)
|
|
|
@ -1875,10 +1889,7 @@ df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed)
|
|
|
|
ws = ws->child;
|
|
|
|
ws = ws->child;
|
|
|
|
|
|
|
|
|
|
|
|
if (skip_dismissed)
|
|
|
|
if (skip_dismissed)
|
|
|
|
{
|
|
|
|
ws = do_skip_dismissed(ws);
|
|
|
|
while (ws && Screen::isDismissed(ws) && ws->parent)
|
|
|
|
|
|
|
|
ws = ws->parent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ws;
|
|
|
|
return ws;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1898,6 +1909,16 @@ df::viewscreen *Gui::getViewscreenByIdentity (virtual_identity &id, int n)
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
df::viewscreen *Gui::getDFViewscreen(bool skip_dismissed) {
|
|
|
|
|
|
|
|
df::viewscreen *screen = Gui::getCurViewscreen(skip_dismissed);
|
|
|
|
|
|
|
|
while (screen && dfhack_viewscreen::is_instance(screen)) {
|
|
|
|
|
|
|
|
screen = screen->parent;
|
|
|
|
|
|
|
|
if (skip_dismissed)
|
|
|
|
|
|
|
|
screen = do_skip_dismissed(screen);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return screen;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
df::coord Gui::getViewportPos()
|
|
|
|
df::coord Gui::getViewportPos()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!df::global::window_x || !df::global::window_y || !df::global::window_z)
|
|
|
|
if (!df::global::window_x || !df::global::window_y || !df::global::window_z)
|
|
|
@ -1919,47 +1940,14 @@ Gui::DwarfmodeDims getDwarfmodeViewDims_default()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Gui::DwarfmodeDims dims;
|
|
|
|
Gui::DwarfmodeDims dims;
|
|
|
|
|
|
|
|
|
|
|
|
auto ws = Screen::getWindowSize();
|
|
|
|
bool use_graphics = Screen::inGraphicsMode();
|
|
|
|
dims.y1 = 1;
|
|
|
|
auto dimx = use_graphics ? gps->main_viewport->dim_x : gps->dimx;
|
|
|
|
dims.y2 = ws.y-2;
|
|
|
|
auto dimy = use_graphics ? gps->main_viewport->dim_y : gps->dimy;
|
|
|
|
|
|
|
|
|
|
|
|
dims.map_x1 = 1;
|
|
|
|
|
|
|
|
dims.map_x2 = ws.x-2;
|
|
|
|
|
|
|
|
dims.map_y1 = dims.y1;
|
|
|
|
|
|
|
|
dims.map_y2 = dims.y2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dims.area_x1 = dims.area_x2 = dims.menu_x1 = dims.menu_x2 = -1;
|
|
|
|
|
|
|
|
dims.menu_forced = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int menu_pos = (ui_menu_width ? (*ui_menu_width)[0] : 2);
|
|
|
|
dims.map_x1 = 0;
|
|
|
|
int area_pos = (ui_menu_width ? (*ui_menu_width)[1] : 3);
|
|
|
|
dims.map_x2 = dimx - 1;
|
|
|
|
|
|
|
|
dims.map_y1 = 0;
|
|
|
|
if (ui && ui->main.mode != ui_sidebar_mode::Default && ui->main.mode != ui_sidebar_mode::ArenaWeather && menu_pos >= area_pos)
|
|
|
|
dims.map_y2 = dimy - 1;
|
|
|
|
{
|
|
|
|
|
|
|
|
dims.menu_forced = true;
|
|
|
|
|
|
|
|
menu_pos = area_pos-1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dims.area_on = (area_pos < 3);
|
|
|
|
|
|
|
|
dims.menu_on = (menu_pos < area_pos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dims.menu_on)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dims.menu_x2 = ws.x - 2;
|
|
|
|
|
|
|
|
dims.menu_x1 = dims.menu_x2 - Gui::MENU_WIDTH + 1;
|
|
|
|
|
|
|
|
if (menu_pos == 1)
|
|
|
|
|
|
|
|
dims.menu_x1 -= Gui::AREA_MAP_WIDTH + 1;
|
|
|
|
|
|
|
|
dims.map_x2 = dims.menu_x1 - 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dims.area_on)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dims.area_x2 = ws.x-2;
|
|
|
|
|
|
|
|
dims.area_x1 = dims.area_x2 - Gui::AREA_MAP_WIDTH + 1;
|
|
|
|
|
|
|
|
if (dims.menu_on)
|
|
|
|
|
|
|
|
dims.menu_x2 = dims.area_x1 - 2;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
dims.map_x2 = dims.area_x1 - 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dims;
|
|
|
|
return dims;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1974,11 +1962,13 @@ void Gui::resetDwarfmodeView(bool pause)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using df::global::cursor;
|
|
|
|
using df::global::cursor;
|
|
|
|
|
|
|
|
|
|
|
|
if (ui)
|
|
|
|
if (plotinfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->follow_unit = -1;
|
|
|
|
plotinfo->follow_unit = -1;
|
|
|
|
ui->follow_item = -1;
|
|
|
|
plotinfo->follow_item = -1;
|
|
|
|
ui->main.mode = ui_sidebar_mode::Default;
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
|
|
|
|
plotinfo->main.mode = ui_sidebar_mode::Default;
|
|
|
|
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selection_rect)
|
|
|
|
if (selection_rect)
|
|
|
@ -2034,8 +2024,8 @@ bool Gui::revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center)
|
|
|
|
*window_x = clip_range(new_win_x, 0, (world->map.x_count - w));
|
|
|
|
*window_x = clip_range(new_win_x, 0, (world->map.x_count - w));
|
|
|
|
*window_y = clip_range(new_win_y, 0, (world->map.y_count - h));
|
|
|
|
*window_y = clip_range(new_win_y, 0, (world->map.y_count - h));
|
|
|
|
*window_z = clip_range(new_win_z, 0, (world->map.z_count - 1));
|
|
|
|
*window_z = clip_range(new_win_z, 0, (world->map.z_count - 1));
|
|
|
|
ui_sidebar_menus->minimap.need_render = true;
|
|
|
|
game->minimap.need_render = true;
|
|
|
|
ui_sidebar_menus->minimap.need_scan = true;
|
|
|
|
game->minimap.need_scan = true;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2081,10 +2071,10 @@ bool Gui::refreshSidebar()
|
|
|
|
|
|
|
|
|
|
|
|
bool Gui::inRenameBuilding()
|
|
|
|
bool Gui::inRenameBuilding()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!ui_sidebar_menus)
|
|
|
|
if (!game)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
return ui_sidebar_menus->barracks.in_rename;
|
|
|
|
return game->barracks.in_rename;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2150,24 +2140,33 @@ bool Gui::setDesignationCoords (const int32_t x, const int32_t y, const int32_t
|
|
|
|
df::coord Gui::getMousePos()
|
|
|
|
df::coord Gui::getMousePos()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
df::coord pos;
|
|
|
|
df::coord pos;
|
|
|
|
/* TODO: understand how this changes for v50
|
|
|
|
if (gps && gps->precise_mouse_x > -1) {
|
|
|
|
if (gps && gps->mouse_x > -1) {
|
|
|
|
|
|
|
|
// return invalid coords if the cursor is not over the map
|
|
|
|
|
|
|
|
DwarfmodeDims dims = getDwarfmodeViewDims();
|
|
|
|
|
|
|
|
if (gps->mouse_x < dims.map_x1 || gps->mouse_x > dims.map_x2 ||
|
|
|
|
|
|
|
|
gps->mouse_y < dims.map_y1 || gps->mouse_y > dims.map_y2) {
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = getViewportPos();
|
|
|
|
pos = getViewportPos();
|
|
|
|
pos.x += gps->mouse_x - 1;
|
|
|
|
if (Screen::inGraphicsMode()) {
|
|
|
|
pos.y += gps->mouse_y - 1;
|
|
|
|
int32_t map_tile_pixels = gps->viewport_zoom_factor / 4;
|
|
|
|
|
|
|
|
pos.x += gps->precise_mouse_x / map_tile_pixels;
|
|
|
|
|
|
|
|
pos.y += gps->precise_mouse_y / map_tile_pixels;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
pos.x += gps->mouse_x;
|
|
|
|
|
|
|
|
pos.y += gps->mouse_y;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
if (!Maps::isValidTilePos(pos.x, pos.y, pos.z))
|
|
|
|
|
|
|
|
return df::coord();
|
|
|
|
return pos;
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int getDepthAt_default (int32_t x, int32_t y)
|
|
|
|
int getDepthAt_default (int32_t x, int32_t y)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
auto &main_vp = gps->main_viewport;
|
|
|
|
|
|
|
|
if (x < 0 || x >= main_vp->dim_x || y < 0 || y >= main_vp->dim_y)
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
const size_t num_viewports = gps->viewport.size();
|
|
|
|
|
|
|
|
const size_t index = (x * main_vp->dim_y) + y;
|
|
|
|
|
|
|
|
for (size_t depth = 0; depth < num_viewports; ++depth) {
|
|
|
|
|
|
|
|
if (gps->viewport[depth]->screentexpos_background[index])
|
|
|
|
|
|
|
|
return depth;
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2190,17 +2189,3 @@ bool Gui::getWindowSize (int32_t &width, int32_t &height)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Gui::getMenuWidth(uint8_t &menu_width, uint8_t &area_map_width)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
menu_width = (*ui_menu_width)[0];
|
|
|
|
|
|
|
|
area_map_width = (*ui_menu_width)[1];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Gui::setMenuWidth(const uint8_t menu_width, const uint8_t area_map_width)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
(*ui_menu_width)[0] = menu_width;
|
|
|
|
|
|
|
|
(*ui_menu_width)[1] = area_map_width;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|