2011-06-16 15:53:39 -06:00
|
|
|
/*
|
|
|
|
https://github.com/peterix/dfhack
|
2012-09-29 20:03:37 -06:00
|
|
|
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
2011-06-16 15:53:39 -06:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any
|
|
|
|
damages arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
purpose, including commercial applications, and to alter it and
|
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must
|
|
|
|
not claim that you wrote the original software. If you use this
|
|
|
|
software in a product, an acknowledgment in the product documentation
|
|
|
|
would be appreciated but is not required.
|
|
|
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
|
|
must not be misrepresented as being the original software.
|
|
|
|
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
distribution.
|
|
|
|
*/
|
|
|
|
|
2011-04-10 05:12:28 -06:00
|
|
|
#pragma once
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Export.h"
|
|
|
|
#include "Module.h"
|
|
|
|
#include "BitArray.h"
|
2012-03-10 04:55:42 -07:00
|
|
|
#include "ColorText.h"
|
2011-07-09 03:33:58 -06:00
|
|
|
#include <string>
|
2010-04-04 16:48:19 -06:00
|
|
|
|
2012-11-19 07:11:26 -07:00
|
|
|
#include "Types.h"
|
|
|
|
|
2012-01-24 21:18:21 -07:00
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "df/init.h"
|
2023-01-05 18:11:01 -07:00
|
|
|
#include "df/plotinfost.h"
|
2012-09-02 04:10:58 -06:00
|
|
|
#include "df/announcement_type.h"
|
2014-04-14 09:41:01 -06:00
|
|
|
#include "df/announcement_flags.h"
|
2023-01-27 11:22:52 -07:00
|
|
|
#include "df/building_stockpilest.h"
|
Update Gui.h
Added parseReportString, which parses a string using '&' as a control character (&r as newline, && as &) and cuts to a certain length w/o splitting words.
Added autoDFAnnouncement, which takes a report_init and a string, and handles them like DF does.
Added variants to log unprinted announcements and to build the report_init from arguments.
Added pauseRecenter, which recenters on an xyz coord (item style, not unit) and optionally pauses, while respecting pause_zoom_no_interface_ms.
Added variant that takes a pos.
Added recenterViewscreen, which recenters on an xyz coord using a report zoom style (item, unit, generic. revealInDwarfmodeMap calls "unit" style "center". Generic style ignores coords and just enforces valid view bounds.)
Added variants that take pos or use current cursor coords.
2022-04-24 23:32:41 -06:00
|
|
|
#include "df/report_init.h"
|
|
|
|
#include "df/report_zoom_type.h"
|
2014-04-14 09:41:01 -06:00
|
|
|
#include "df/unit_report_type.h"
|
2012-01-24 21:18:21 -07:00
|
|
|
|
2015-11-14 12:14:32 -07:00
|
|
|
#include "modules/GuiHooks.h"
|
|
|
|
|
2012-01-07 08:21:07 -07:00
|
|
|
namespace df {
|
|
|
|
struct viewscreen;
|
|
|
|
struct job;
|
2012-01-14 08:31:43 -07:00
|
|
|
struct unit;
|
|
|
|
struct item;
|
2017-05-05 12:45:46 -06:00
|
|
|
struct plant;
|
2012-01-07 08:21:07 -07:00
|
|
|
};
|
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
2012-03-03 06:38:24 -07:00
|
|
|
* \defgroup grp_gui utility code that helps dealing with DF's user interface
|
2011-03-18 04:09:26 -06:00
|
|
|
* @ingroup grp_modules
|
|
|
|
*/
|
|
|
|
|
2010-04-04 16:48:19 -06:00
|
|
|
namespace DFHack
|
|
|
|
{
|
2012-01-07 08:21:07 -07:00
|
|
|
class Core;
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* The Gui module
|
|
|
|
* \ingroup grp_modules
|
|
|
|
* \ingroup grp_gui
|
|
|
|
*/
|
2012-03-03 06:38:24 -07:00
|
|
|
namespace Gui
|
2010-04-04 16:48:19 -06:00
|
|
|
{
|
2023-01-27 11:22:52 -07:00
|
|
|
DFHACK_EXPORT std::vector<std::string> getFocusStrings(df::viewscreen *top);
|
2023-02-06 01:58:57 -07:00
|
|
|
DFHACK_EXPORT bool matchFocusString(std::string focus_string, df::viewscreen *top = NULL);
|
2023-01-27 11:22:52 -07:00
|
|
|
|
2012-05-19 09:50:36 -06:00
|
|
|
|
2012-03-03 06:38:24 -07:00
|
|
|
// Full-screen item details view
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool item_details_hotkey(df::viewscreen *top);
|
2012-03-03 06:38:24 -07:00
|
|
|
// 'u'nits or 'j'obs full-screen view
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool unitjobs_hotkey(df::viewscreen *top);
|
2012-03-03 06:38:24 -07:00
|
|
|
|
|
|
|
// A job is selected in a workshop
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool workshop_job_hotkey(df::viewscreen *top);
|
2012-03-03 06:38:24 -07:00
|
|
|
// Building material selection mode
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool build_selector_hotkey(df::viewscreen *top);
|
2012-03-03 06:38:24 -07:00
|
|
|
// A unit is selected in the 'v' mode
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool view_unit_hotkey(df::viewscreen *top);
|
2012-03-03 06:38:24 -07:00
|
|
|
// Above + the inventory page is selected.
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool unit_inventory_hotkey(df::viewscreen *top);
|
2012-03-03 06:38:24 -07:00
|
|
|
|
|
|
|
// In workshop_job_hotkey, returns the job
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT df::job *getSelectedWorkshopJob(color_ostream &out, bool quiet = false);
|
2012-03-03 06:38:24 -07:00
|
|
|
|
|
|
|
// A job is selected in a workshop, or unitjobs
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool any_job_hotkey(df::viewscreen *top);
|
|
|
|
DFHACK_EXPORT df::job *getSelectedJob(color_ostream &out, bool quiet = false);
|
2012-03-03 06:38:24 -07:00
|
|
|
|
|
|
|
// A unit is selected via 'v', 'k', unitjobs, or
|
|
|
|
// a full-screen item view of a cage or suchlike
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool any_unit_hotkey(df::viewscreen *top);
|
2014-11-25 18:22:26 -07:00
|
|
|
DFHACK_EXPORT df::unit *getAnyUnit(df::viewscreen *top);
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT df::unit *getSelectedUnit(color_ostream &out, bool quiet = false);
|
2012-03-03 06:38:24 -07:00
|
|
|
|
|
|
|
// An item is selected via 'v'->inventory, 'k', 't', or
|
|
|
|
// a full-screen item view of a container. Note that in the
|
|
|
|
// last case, the highlighted contained item is returned, not
|
|
|
|
// the container itself.
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT bool any_item_hotkey(df::viewscreen *top);
|
2014-11-25 18:22:26 -07:00
|
|
|
DFHACK_EXPORT df::item *getAnyItem(df::viewscreen *top);
|
2012-03-10 04:55:42 -07:00
|
|
|
DFHACK_EXPORT df::item *getSelectedItem(color_ostream &out, bool quiet = false);
|
2012-03-03 06:38:24 -07:00
|
|
|
|
2012-09-20 00:41:03 -06:00
|
|
|
// A building is selected via 'q', 't' or 'i' (civzone)
|
|
|
|
DFHACK_EXPORT bool any_building_hotkey(df::viewscreen *top);
|
2014-11-25 18:22:26 -07:00
|
|
|
DFHACK_EXPORT df::building *getAnyBuilding(df::viewscreen *top);
|
2012-09-20 00:41:03 -06:00
|
|
|
DFHACK_EXPORT df::building *getSelectedBuilding(color_ostream &out, bool quiet = false);
|
|
|
|
|
2023-01-27 11:22:52 -07:00
|
|
|
DFHACK_EXPORT bool any_stockpile_hotkey(df::viewscreen* top);
|
|
|
|
DFHACK_EXPORT df::building_stockpilest *getAnyStockpile(df::viewscreen* top);
|
|
|
|
DFHACK_EXPORT df::building_stockpilest *getSelectedStockpile(color_ostream& out, bool quiet = false);
|
|
|
|
|
2017-05-05 12:45:46 -06:00
|
|
|
// A plant is selected, e.g. via 'k'
|
|
|
|
DFHACK_EXPORT bool any_plant_hotkey(df::viewscreen *top);
|
|
|
|
DFHACK_EXPORT df::plant *getAnyPlant(df::viewscreen *top);
|
|
|
|
DFHACK_EXPORT df::plant *getSelectedPlant(color_ostream &out, bool quiet = false);
|
|
|
|
|
2014-04-14 09:41:01 -06:00
|
|
|
// Low-level API that gives full control over announcements and reports
|
|
|
|
DFHACK_EXPORT void writeToGamelog(std::string message);
|
|
|
|
|
|
|
|
DFHACK_EXPORT int makeAnnouncement(df::announcement_type type, df::announcement_flags mode, df::coord pos, std::string message, int color = 7, bool bright = true);
|
|
|
|
DFHACK_EXPORT bool addCombatReport(df::unit *unit, df::unit_report_type slot, int report_index);
|
|
|
|
DFHACK_EXPORT bool addCombatReportAuto(df::unit *unit, df::announcement_flags mode, int report_index);
|
|
|
|
|
2012-03-03 06:38:24 -07:00
|
|
|
// Show a plain announcement, or a titan-style popup message
|
|
|
|
DFHACK_EXPORT void showAnnouncement(std::string message, int color = 7, bool bright = true);
|
2012-09-02 04:10:58 -06:00
|
|
|
DFHACK_EXPORT void showZoomAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true);
|
2012-03-03 06:38:24 -07:00
|
|
|
DFHACK_EXPORT void showPopupAnnouncement(std::string message, int color = 7, bool bright = true);
|
|
|
|
|
2012-09-02 04:10:58 -06:00
|
|
|
// Show an announcement with effects determined by announcements.txt
|
2014-04-14 09:41:01 -06:00
|
|
|
DFHACK_EXPORT void showAutoAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true, df::unit *unit1 = NULL, df::unit *unit2 = NULL);
|
2022-05-28 16:56:49 -06:00
|
|
|
|
Update Gui.h
Added parseReportString, which parses a string using '&' as a control character (&r as newline, && as &) and cuts to a certain length w/o splitting words.
Added autoDFAnnouncement, which takes a report_init and a string, and handles them like DF does.
Added variants to log unprinted announcements and to build the report_init from arguments.
Added pauseRecenter, which recenters on an xyz coord (item style, not unit) and optionally pauses, while respecting pause_zoom_no_interface_ms.
Added variant that takes a pos.
Added recenterViewscreen, which recenters on an xyz coord using a report zoom style (item, unit, generic. revealInDwarfmodeMap calls "unit" style "center". Generic style ignores coords and just enforces valid view bounds.)
Added variants that take pos or use current cursor coords.
2022-04-24 23:32:41 -06:00
|
|
|
// Process an announcement exactly like DF would, which might result in no announcement
|
2022-05-16 19:41:47 -06:00
|
|
|
DFHACK_EXPORT bool autoDFAnnouncement(df::report_init r, std::string message);
|
|
|
|
DFHACK_EXPORT bool autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true,
|
2022-05-24 04:52:33 -06:00
|
|
|
df::unit *unit1 = NULL, df::unit *unit2 = NULL, bool is_sparring = false);
|
2022-05-28 16:56:49 -06:00
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
/*
|
2022-09-18 09:19:02 -06:00
|
|
|
* Cursor and window map coords
|
2011-03-18 04:09:26 -06:00
|
|
|
*/
|
2012-08-25 00:37:03 -06:00
|
|
|
DFHACK_EXPORT df::coord getViewportPos();
|
|
|
|
DFHACK_EXPORT df::coord getCursorPos();
|
2022-09-18 09:19:02 -06:00
|
|
|
DFHACK_EXPORT df::coord getMousePos();
|
2012-08-25 00:37:03 -06:00
|
|
|
|
2012-09-02 04:10:58 -06:00
|
|
|
static const int AREA_MAP_WIDTH = 23;
|
|
|
|
static const int MENU_WIDTH = 30;
|
|
|
|
|
|
|
|
struct DwarfmodeDims {
|
2022-12-31 23:49:30 -07:00
|
|
|
int map_x1, map_x2;
|
2015-12-22 09:42:51 -07:00
|
|
|
int map_y1, map_y2;
|
2012-11-19 07:11:26 -07:00
|
|
|
|
2016-10-07 21:51:58 -06:00
|
|
|
rect2d map() { return mkrect_xy(map_x1, map_y1, map_x2, map_y2); }
|
2012-09-02 04:10:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
DFHACK_EXPORT DwarfmodeDims getDwarfmodeViewDims();
|
|
|
|
|
|
|
|
DFHACK_EXPORT void resetDwarfmodeView(bool pause = false);
|
2022-06-04 12:59:04 -06:00
|
|
|
DFHACK_EXPORT bool revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center = false);
|
|
|
|
DFHACK_EXPORT inline bool revealInDwarfmodeMap(df::coord pos, bool center = false) { return revealInDwarfmodeMap(pos.x, pos.y, pos.z, center); };
|
|
|
|
DFHACK_EXPORT bool pauseRecenter(int32_t x, int32_t y, int32_t z, bool pause = true);
|
|
|
|
DFHACK_EXPORT inline bool pauseRecenter(df::coord pos, bool pause = true) { return pauseRecenter(pos.x, pos.y, pos.z, pause); };
|
2017-06-22 21:56:35 -06:00
|
|
|
DFHACK_EXPORT bool refreshSidebar();
|
2012-09-02 04:10:58 -06:00
|
|
|
|
2018-05-09 08:23:05 -06:00
|
|
|
DFHACK_EXPORT bool inRenameBuilding();
|
|
|
|
|
2012-03-03 06:38:24 -07:00
|
|
|
DFHACK_EXPORT bool getViewCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
DFHACK_EXPORT bool setViewCoords (const int32_t x, const int32_t y, const int32_t z);
|
|
|
|
|
|
|
|
DFHACK_EXPORT bool getCursorCoords (int32_t &x, int32_t &y, int32_t &z);
|
2021-05-15 13:05:00 -06:00
|
|
|
DFHACK_EXPORT bool getCursorCoords (df::coord &pos);
|
2012-03-03 06:38:24 -07:00
|
|
|
DFHACK_EXPORT bool setCursorCoords (const int32_t x, const int32_t y, const int32_t z);
|
2011-09-25 19:39:27 -06:00
|
|
|
|
2012-03-03 06:38:24 -07:00
|
|
|
DFHACK_EXPORT bool getDesignationCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
DFHACK_EXPORT bool setDesignationCoords (const int32_t x, const int32_t y, const int32_t z);
|
2011-09-25 19:39:27 -06:00
|
|
|
|
2015-11-14 12:14:32 -07:00
|
|
|
// The distance from the z-level of the tile at map coordinates (x, y) to the closest ground z-level below
|
|
|
|
// Defaults to 0, unless overriden by plugins
|
|
|
|
DFHACK_EXPORT int getDepthAt (int32_t x, int32_t y);
|
2011-07-09 03:33:58 -06:00
|
|
|
/*
|
|
|
|
* Gui screens
|
|
|
|
*/
|
|
|
|
/// Get the current top-level view-screen
|
2012-08-24 03:20:08 -06:00
|
|
|
DFHACK_EXPORT df::viewscreen *getCurViewscreen(bool skip_dismissed = false);
|
|
|
|
|
2015-10-03 07:27:24 -06:00
|
|
|
DFHACK_EXPORT df::viewscreen *getViewscreenByIdentity(virtual_identity &id, int n = 1);
|
2015-10-02 19:50:55 -06:00
|
|
|
|
2023-01-06 13:17:36 -07:00
|
|
|
/// Get the top-most underlying DF viewscreen (not owned by DFHack)
|
2023-02-05 19:01:46 -07:00
|
|
|
DFHACK_EXPORT df::viewscreen *getDFViewscreen(bool skip_dismissed = false, df::viewscreen *top = NULL);
|
2023-01-06 13:17:36 -07:00
|
|
|
|
2015-10-02 19:50:55 -06:00
|
|
|
/// Get the top-most viewscreen of the given type from the top `n` viewscreens (or all viewscreens if n < 1)
|
|
|
|
/// returns NULL if none match
|
|
|
|
template <typename T>
|
|
|
|
inline T *getViewscreenByType (int n = 1) {
|
|
|
|
return strict_virtual_cast<T>(getViewscreenByIdentity(T::_identity, n));
|
|
|
|
}
|
|
|
|
|
2023-01-27 11:22:52 -07:00
|
|
|
inline std::vector<std::string> getCurFocus(bool skip_dismissed = false) {
|
|
|
|
return getFocusStrings(getCurViewscreen(skip_dismissed));
|
2012-08-24 03:20:08 -06:00
|
|
|
}
|
2011-07-09 03:33:58 -06:00
|
|
|
|
2012-03-03 15:18:12 -07:00
|
|
|
/// get the size of the window buffer
|
2012-03-03 06:38:24 -07:00
|
|
|
DFHACK_EXPORT bool getWindowSize(int32_t & width, int32_t & height);
|
2012-02-22 00:30:44 -07:00
|
|
|
|
2015-11-14 12:14:32 -07:00
|
|
|
namespace Hooks {
|
|
|
|
GUI_HOOK_DECLARE(depth_at, int, (int32_t x, int32_t y));
|
|
|
|
GUI_HOOK_DECLARE(dwarfmode_view_dims, DwarfmodeDims, ());
|
|
|
|
}
|
2012-03-03 06:38:24 -07:00
|
|
|
}
|
2010-04-04 16:48:19 -06:00
|
|
|
}
|