|
|
|
@ -43,6 +43,7 @@ using namespace DFHack;
|
|
|
|
|
|
|
|
|
|
#include "modules/Job.h"
|
|
|
|
|
#include "modules/Screen.h"
|
|
|
|
|
#include "modules/Maps.h"
|
|
|
|
|
|
|
|
|
|
#include "DataDefs.h"
|
|
|
|
|
#include "df/world.h"
|
|
|
|
@ -81,6 +82,8 @@ using namespace DFHack;
|
|
|
|
|
#include "df/graphic.h"
|
|
|
|
|
#include "df/layer_object_listst.h"
|
|
|
|
|
#include "df/assign_trade_status.h"
|
|
|
|
|
#include "df/announcement_flags.h"
|
|
|
|
|
#include "df/announcements.h"
|
|
|
|
|
|
|
|
|
|
using namespace df::enums;
|
|
|
|
|
using df::global::gview;
|
|
|
|
@ -88,6 +91,9 @@ using df::global::init;
|
|
|
|
|
using df::global::gps;
|
|
|
|
|
using df::global::ui;
|
|
|
|
|
using df::global::world;
|
|
|
|
|
using df::global::selection_rect;
|
|
|
|
|
using df::global::ui_menu_width;
|
|
|
|
|
using df::global::ui_area_map_width;
|
|
|
|
|
|
|
|
|
|
static df::layer_object_listst *getLayerList(df::viewscreen_layerst *layer, int idx)
|
|
|
|
|
{
|
|
|
|
@ -921,8 +927,9 @@ df::item *Gui::getSelectedItem(color_ostream &out, bool quiet)
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void Gui::showAnnouncement(std::string message, int color, bool bright)
|
|
|
|
|
{
|
|
|
|
|
static void doShowAnnouncement(
|
|
|
|
|
df::announcement_type type, df::coord pos, std::string message, int color, bool bright
|
|
|
|
|
) {
|
|
|
|
|
using df::global::world;
|
|
|
|
|
using df::global::cur_year;
|
|
|
|
|
using df::global::cur_year_tick;
|
|
|
|
@ -948,6 +955,9 @@ void Gui::showAnnouncement(std::string message, int color, bool bright)
|
|
|
|
|
{
|
|
|
|
|
df::report *new_rep = new df::report();
|
|
|
|
|
|
|
|
|
|
new_rep->type = type;
|
|
|
|
|
new_rep->pos = pos;
|
|
|
|
|
|
|
|
|
|
new_rep->color = color;
|
|
|
|
|
new_rep->bright = bright;
|
|
|
|
|
new_rep->year = year;
|
|
|
|
@ -969,7 +979,17 @@ void Gui::showAnnouncement(std::string message, int color, bool bright)
|
|
|
|
|
world->status.announcements.push_back(new_rep);
|
|
|
|
|
world->status.display_timer = 2000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Gui::showAnnouncement(std::string message, int color, bool bright)
|
|
|
|
|
{
|
|
|
|
|
doShowAnnouncement(df::announcement_type(0), df::coord(), message, color, bright);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Gui::showZoomAnnouncement(
|
|
|
|
|
df::announcement_type type, df::coord pos, std::string message, int color, bool bright
|
|
|
|
|
) {
|
|
|
|
|
doShowAnnouncement(type, pos, message, color, bright);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Gui::showPopupAnnouncement(std::string message, int color, bool bright)
|
|
|
|
@ -983,6 +1003,29 @@ void Gui::showPopupAnnouncement(std::string message, int color, bool bright)
|
|
|
|
|
world->status.popups.push_back(popup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Gui::showAutoAnnouncement(
|
|
|
|
|
df::announcement_type type, df::coord pos, std::string message, int color, bool bright
|
|
|
|
|
) {
|
|
|
|
|
using df::global::announcements;
|
|
|
|
|
|
|
|
|
|
df::announcement_flags flags;
|
|
|
|
|
if (is_valid_enum_item(type) && announcements)
|
|
|
|
|
flags = announcements->flags[type];
|
|
|
|
|
|
|
|
|
|
doShowAnnouncement(type, pos, message, color, bright);
|
|
|
|
|
|
|
|
|
|
if (flags.bits.DO_MEGA || flags.bits.PAUSE || flags.bits.RECENTER)
|
|
|
|
|
{
|
|
|
|
|
resetDwarfmodeView(flags.bits.DO_MEGA || flags.bits.PAUSE);
|
|
|
|
|
|
|
|
|
|
if (flags.bits.RECENTER && pos.isValid())
|
|
|
|
|
revealInDwarfmodeMap(pos, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags.bits.DO_MEGA)
|
|
|
|
|
showPopupAnnouncement(message, color, bright);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed)
|
|
|
|
|
{
|
|
|
|
|
df::viewscreen * ws = &gview->view;
|
|
|
|
@ -1015,6 +1058,110 @@ df::coord Gui::getCursorPos()
|
|
|
|
|
return df::coord(cursor->x, cursor->y, cursor->z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gui::DwarfmodeDims Gui::getDwarfmodeViewDims()
|
|
|
|
|
{
|
|
|
|
|
DwarfmodeDims dims;
|
|
|
|
|
|
|
|
|
|
auto ws = Screen::getWindowSize();
|
|
|
|
|
dims.y1 = 1;
|
|
|
|
|
dims.y2 = ws.y-2;
|
|
|
|
|
dims.map_x1 = 1;
|
|
|
|
|
dims.map_x2 = ws.x-2;
|
|
|
|
|
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 : 2);
|
|
|
|
|
int area_pos = (ui_area_map_width ? *ui_area_map_width : 3);
|
|
|
|
|
|
|
|
|
|
if (ui && ui->main.mode && menu_pos >= area_pos)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Gui::resetDwarfmodeView(bool pause)
|
|
|
|
|
{
|
|
|
|
|
using df::global::cursor;
|
|
|
|
|
|
|
|
|
|
if (ui)
|
|
|
|
|
{
|
|
|
|
|
ui->follow_unit = -1;
|
|
|
|
|
ui->follow_item = -1;
|
|
|
|
|
ui->main.mode = ui_sidebar_mode::Default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selection_rect)
|
|
|
|
|
{
|
|
|
|
|
selection_rect->start_x = -30000;
|
|
|
|
|
selection_rect->end_x = -30000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cursor)
|
|
|
|
|
cursor->x = cursor->y = cursor->z = -30000;
|
|
|
|
|
|
|
|
|
|
if (pause && df::global::pause_state)
|
|
|
|
|
*df::global::pause_state = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Gui::revealInDwarfmodeMap(df::coord pos, bool center)
|
|
|
|
|
{
|
|
|
|
|
using df::global::window_x;
|
|
|
|
|
using df::global::window_y;
|
|
|
|
|
using df::global::window_z;
|
|
|
|
|
|
|
|
|
|
if (!window_x || !window_y || !window_z || !world)
|
|
|
|
|
return false;
|
|
|
|
|
if (!Maps::isValidTilePos(pos))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
auto dims = getDwarfmodeViewDims();
|
|
|
|
|
int w = dims.map_x2 - dims.map_x1 + 1;
|
|
|
|
|
int h = dims.y2 - dims.y1 + 1;
|
|
|
|
|
|
|
|
|
|
*window_z = pos.z;
|
|
|
|
|
|
|
|
|
|
if (center)
|
|
|
|
|
{
|
|
|
|
|
*window_x = pos.x - w/2;
|
|
|
|
|
*window_y = pos.y - h/2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (*window_x + w < pos.x+5) *window_x += 10;
|
|
|
|
|
while (*window_y + h < pos.y+5) *window_y += 10;
|
|
|
|
|
while (*window_x + 5 > pos.x) *window_x -= 10;
|
|
|
|
|
while (*window_y + 5 > pos.y) *window_y -= 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*window_x = std::max(0, std::min(*window_x, world->map.x_count-w));
|
|
|
|
|
*window_y = std::max(0, std::min(*window_y, world->map.y_count-h));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Gui::getViewCoords (int32_t &x, int32_t &y, int32_t &z)
|
|
|
|
|
{
|
|
|
|
|
x = *df::global::window_x;
|
|
|
|
|