Get rid of Simple namespace, Gui module is now a namespace.

develop
Petr Mrázek 2012-03-03 14:38:24 +01:00
parent 022822277d
commit 7fe8762852
58 changed files with 192 additions and 403 deletions

@ -635,7 +635,6 @@ bool Core::Init()
cerr << "Initializing Console.\n";
// init the console.
Gui * g = getGui();
bool is_text_mode = false;
if(init && init->display.flag.is_set(init_display_flags::TEXT))
{
@ -877,20 +876,19 @@ bool Core::ncurses_wgetch(int in, int & out)
{
int idx = in - KEY_F(1);
// FIXME: copypasta, push into a method!
Gui * g = getGui();
if(df::global::ui && df::global::gview && g->df_menu_state)
if(df::global::ui && df::global::gview)
{
df::viewscreen * ws = g->GetCurrentScreen();
// FIXME: USE ENUMS
if(((t_virtual *)ws)->getClassName() == "viewscreen_dwarfmodest" && *g->df_menu_state == 0x23)
df::viewscreen * ws = Gui::GetCurrentScreen();
if (strict_virtual_cast<df::viewscreen_dwarfmodest>(ws) &&
df::global::ui->main.mode != ui_sidebar_mode::Hotkeys)
{
out = in;
return true;
setHotkeyCmd(df::global::ui->main.hotkeys[idx].name);
return false;
}
else
{
setHotkeyCmd(df::global::ui->main.hotkeys[idx].name);
return false;
out = in;
return true;
}
}
}
@ -1123,7 +1121,6 @@ TYPE * Core::get##TYPE() \
return s_mods.p##TYPE;\
}
MODULE_GETTER(Gui);
MODULE_GETTER(World);
MODULE_GETTER(Materials);
MODULE_GETTER(Notes);

@ -341,7 +341,7 @@ bool Plugin::can_invoke_hotkey( std::string & command, df::viewscreen *top )
else if (cmd.guard)
cr = cmd.guard(&c, top);
else
cr = default_hotkey(&c, top);
cr = Gui::default_hotkey(&c, top);
break;
}
}

@ -52,7 +52,6 @@ namespace DFHack
{
class Process;
class Module;
class Gui;
class World;
class Materials;
class Notes;
@ -98,8 +97,6 @@ namespace DFHack
/// Is everything OK?
bool isValid(void) { return !errorstate; }
/// get the gui module
Gui * getGui();
/// get the world module
World * getWorld();
/// get the materials module
@ -153,7 +150,6 @@ namespace DFHack
// Module storage
struct
{
Gui * pGui;
World * pWorld;
Materials * pMaterials;
Notes * pNotes;

@ -182,10 +182,13 @@ namespace DFHack
std::string plugin_path;
};
// Predefined hotkey guards
DFHACK_EXPORT bool default_hotkey(Core *, df::viewscreen *);
DFHACK_EXPORT bool dwarfmode_hotkey(Core *, df::viewscreen *);
DFHACK_EXPORT bool cursor_hotkey(Core *, df::viewscreen *);
namespace Gui
{
// Predefined hotkey guards
DFHACK_EXPORT bool default_hotkey(Core *, df::viewscreen *);
DFHACK_EXPORT bool dwarfmode_hotkey(Core *, df::viewscreen *);
DFHACK_EXPORT bool cursor_hotkey(Core *, df::viewscreen *);
}
};
/// You have to have this in every plugin you write - just once. Ideally on top of the main file.

@ -35,8 +35,6 @@ distribution.
namespace DFHack
{
namespace Simple
{
namespace Buildings
{
/**
@ -86,4 +84,3 @@ DFHACK_EXPORT bool ReadCustomWorkshopTypes(std::map <uint32_t, std::string> & bt
}
}
}

@ -38,8 +38,6 @@ distribution.
*/
namespace DFHack
{
namespace Simple
{
namespace Constructions
{
// "Simplified" copy of construction
@ -61,5 +59,4 @@ DFHACK_EXPORT bool copyConstruction (const int32_t index, t_construction &out);
DFHACK_EXPORT df::construction * getConstruction (const int32_t index);
}
}
}
#endif

@ -37,8 +37,6 @@ distribution.
*/
namespace DFHack
{
namespace Simple
{
namespace Engravings
{
// "Simplified" copy of engraving
@ -62,5 +60,4 @@ DFHACK_EXPORT bool copyEngraving (const int32_t index, t_engraving &out);
DFHACK_EXPORT df::engraving * getEngraving (const int32_t index);
}
}
}
#endif

@ -44,108 +44,95 @@ namespace df {
};
/**
* \defgroup grp_gui query DF's GUI state
* \defgroup grp_gui utility code that helps dealing with DF's user interface
* @ingroup grp_modules
*/
namespace DFHack
{
class Core;
// Full-screen item details view
DFHACK_EXPORT bool item_details_hotkey(Core *, df::viewscreen *top);
// 'u'nits or 'j'obs full-screen view
DFHACK_EXPORT bool unitjobs_hotkey(Core *, df::viewscreen *top);
// A job is selected in a workshop
DFHACK_EXPORT bool workshop_job_hotkey(Core *c, df::viewscreen *top);
// Building material selection mode
DFHACK_EXPORT bool build_selector_hotkey(Core *c, df::viewscreen *top);
// A unit is selected in the 'v' mode
DFHACK_EXPORT bool view_unit_hotkey(Core *c, df::viewscreen *top);
// Above + the inventory page is selected.
DFHACK_EXPORT bool unit_inventory_hotkey(Core *c, df::viewscreen *top);
// In workshop_job_hotkey, returns the job
DFHACK_EXPORT df::job *getSelectedWorkshopJob(Core *c, bool quiet = false);
// A job is selected in a workshop, or unitjobs
DFHACK_EXPORT bool any_job_hotkey(Core *c, df::viewscreen *top);
DFHACK_EXPORT df::job *getSelectedJob(Core *c, bool quiet = false);
// A unit is selected via 'v', 'k', unitjobs, or
// a full-screen item view of a cage or suchlike
DFHACK_EXPORT bool any_unit_hotkey(Core *c, df::viewscreen *top);
DFHACK_EXPORT df::unit *getSelectedUnit(Core *c, bool quiet = false);
// 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.
DFHACK_EXPORT bool any_item_hotkey(Core *c, df::viewscreen *top);
DFHACK_EXPORT df::item *getSelectedItem(Core *c, bool quiet = false);
// Show a plain announcement, or a titan-style popup message
DFHACK_EXPORT void showAnnouncement(std::string message, int color = 7, bool bright = true);
DFHACK_EXPORT void showPopupAnnouncement(std::string message, int color = 7, bool bright = true);
class DFContextShared;
/**
* One tile of the screen. Possibly outdated.
* \ingroup grp_gui
*/
struct t_screen
{
uint8_t symbol;
uint8_t foreground;
uint8_t background;
uint8_t bright;
uint8_t gtile;
uint8_t grayscale;
};
/**
* The Gui module
* \ingroup grp_modules
* \ingroup grp_gui
*/
class DFHACK_EXPORT Gui: public Module
namespace Gui
{
public:
// Full-screen item details view
DFHACK_EXPORT bool item_details_hotkey(Core *, df::viewscreen *top);
// 'u'nits or 'j'obs full-screen view
DFHACK_EXPORT bool unitjobs_hotkey(Core *, df::viewscreen *top);
// A job is selected in a workshop
DFHACK_EXPORT bool workshop_job_hotkey(Core *c, df::viewscreen *top);
// Building material selection mode
DFHACK_EXPORT bool build_selector_hotkey(Core *c, df::viewscreen *top);
// A unit is selected in the 'v' mode
DFHACK_EXPORT bool view_unit_hotkey(Core *c, df::viewscreen *top);
// Above + the inventory page is selected.
DFHACK_EXPORT bool unit_inventory_hotkey(Core *c, df::viewscreen *top);
// In workshop_job_hotkey, returns the job
DFHACK_EXPORT df::job *getSelectedWorkshopJob(Core *c, bool quiet = false);
// A job is selected in a workshop, or unitjobs
DFHACK_EXPORT bool any_job_hotkey(Core *c, df::viewscreen *top);
DFHACK_EXPORT df::job *getSelectedJob(Core *c, bool quiet = false);
// A unit is selected via 'v', 'k', unitjobs, or
// a full-screen item view of a cage or suchlike
DFHACK_EXPORT bool any_unit_hotkey(Core *c, df::viewscreen *top);
DFHACK_EXPORT df::unit *getSelectedUnit(Core *c, bool quiet = false);
// 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.
DFHACK_EXPORT bool any_item_hotkey(Core *c, df::viewscreen *top);
DFHACK_EXPORT df::item *getSelectedItem(Core *c, bool quiet = false);
// Show a plain announcement, or a titan-style popup message
DFHACK_EXPORT void showAnnouncement(std::string message, int color = 7, bool bright = true);
DFHACK_EXPORT void showPopupAnnouncement(std::string message, int color = 7, bool bright = true);
/**
* One tile of the screen.
* \ingroup grp_gui
*/
struct t_screen
{
uint8_t symbol;
uint8_t foreground;
uint8_t background;
uint8_t bright;
};
Gui();
~Gui();
bool Start();
bool Finish();
/*
* Cursor and window coords
*/
bool getViewCoords (int32_t &x, int32_t &y, int32_t &z);
bool setViewCoords (const int32_t x, const int32_t y, const int32_t z);
bool getCursorCoords (int32_t &x, int32_t &y, int32_t &z);
bool setCursorCoords (const int32_t x, const int32_t y, const int32_t z);
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);
DFHACK_EXPORT bool setCursorCoords (const int32_t x, const int32_t y, const int32_t z);
bool getDesignationCoords (int32_t &x, int32_t &y, int32_t &z);
bool setDesignationCoords (const int32_t x, const int32_t y, const int32_t z);
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);
bool getMousePos (int32_t & x, int32_t & y);
DFHACK_EXPORT bool getMousePos (int32_t & x, int32_t & y);
/*
* Gui screens
*/
/// Get the current top-level view-screen
df::viewscreen * GetCurrentScreen();
/// The DF menu state (designation menu ect)
uint32_t * df_menu_state;
DFHACK_EXPORT df::viewscreen * GetCurrentScreen();
/*
* Window size in tiles
*/
bool getWindowSize(int32_t & width, int32_t & height);
DFHACK_EXPORT bool getWindowSize(int32_t & width, int32_t & height);
/*
*Menu width:
*Menu width:
*3:3 - menu and area map closed
*2:3 - menu open single width
*1:3 - menu open double width
@ -153,18 +140,9 @@ namespace DFHack
*2:2 - area map open
*/
bool getMenuWidth(uint8_t & menu_width, uint8_t & area_map_width);
bool setMenuWidth(const uint8_t menu_width, const uint8_t area_map_width);
/*
* Screen tiles
*/
bool getScreenTiles(int32_t width, int32_t height, t_screen screen[]);
private:
struct Private;
Private *d;
};
DFHACK_EXPORT bool getMenuWidth(uint8_t & menu_width, uint8_t & area_map_width);
DFHACK_EXPORT bool setMenuWidth(const uint8_t menu_width, const uint8_t area_map_width);
}
}
#endif

@ -112,8 +112,6 @@ struct dfh_item
* \ingroup grp_modules
* \ingroup grp_items
*/
namespace Simple
{
namespace Items
{
@ -141,5 +139,4 @@ DFHACK_EXPORT bool removeItemOwner(df::item * item);
DFHACK_EXPORT bool readItemRefs(const df::item * item, const df::general_ref_type type,
/*output*/ std::vector<int32_t> &values);
}
}
}

@ -33,7 +33,6 @@ distribution.
#include "df/map_block.h"
#include "df/block_square_event_mineralst.h"
using namespace DFHack;
using namespace DFHack::Simple;
namespace MapExtras
{
void SquashVeins (DFCoord bcoord, mapblock40d & mb, t_blockmaterials & materials)

@ -192,8 +192,6 @@ typedef struct
* \ingroup grp_modules
* \ingroup grp_maps
*/
namespace Simple
{
namespace Maps
{
@ -324,7 +322,6 @@ extern DFHACK_EXPORT bool RemoveBlockEvent(uint32_t x, uint32_t y, uint32_t z, d
/// read all plants in this block
extern DFHACK_EXPORT bool ReadVegetation(uint32_t x, uint32_t y, uint32_t z, std::vector<df::plant *>*& plants);
}
}
}
#endif

@ -41,8 +41,6 @@ distribution.
namespace DFHack
{
namespace Simple
{
namespace Translation
{
// simple check to make sure if there's actual language data present
@ -56,5 +54,4 @@ DFHACK_EXPORT bool copyName(df::language_name * address, df::language_name * tar
DFHACK_EXPORT std::string TranslateName (const df::language_name * name, bool inEnglish = true);
}
}
}
#endif

@ -39,8 +39,6 @@ distribution.
*/
namespace DFHack
{
namespace Simple
{
namespace Units
{
/**
@ -196,5 +194,4 @@ DFHACK_EXPORT bool RemoveOwnedItemByIdx(const uint32_t index, int32_t id);
DFHACK_EXPORT bool RemoveOwnedItemByPtr(df::unit * unit, int32_t id);
}
}
}
#endif

@ -36,8 +36,6 @@ distribution.
namespace DFHack
{
namespace Simple
{
namespace Vegetation
{
const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3; // 3 years
@ -69,5 +67,4 @@ DFHACK_EXPORT df::plant * getPlant(const int32_t index);
DFHACK_EXPORT bool copyPlant (const int32_t index, t_plant &out);
}
}
}
#endif

@ -6,7 +6,9 @@
#include "DataDefs.h"
#include "df/vermin.h"
namespace DFHack { namespace Simple { namespace Vermin
namespace DFHack
{
namespace Vermin
{
/**
* Structure for holding a read DF vermin spawn point object
@ -38,4 +40,5 @@ namespace DFHack { namespace Simple { namespace Vermin
* Write into vermin object
*/
DFHACK_EXPORT bool Write (const uint32_t index, t_vermin & point);
} } } // end DFHack::Simple::Vermin
}// end DFHack::Vermin
}

@ -40,8 +40,6 @@ distribution.
namespace DFHack
{
namespace Simple
{
namespace Kitchen
{
typedef uint8_t t_exclusionType;
@ -83,4 +81,3 @@ DFHACK_EXPORT void clearLimits();
DFHACK_EXPORT std::size_t size();
}
}
}

@ -38,7 +38,6 @@ using namespace std;
#include "ModuleFactory.h"
#include "Core.h"
using namespace DFHack;
using namespace DFHack::Simple;
#include "DataDefs.h"
#include "df/world.h"

@ -38,7 +38,6 @@ using namespace std;
#include "modules/Constructions.h"
#include "df/world.h"
using namespace DFHack;
using namespace DFHack::Simple;
using df::global::world;
bool Constructions::isValid()

@ -39,7 +39,6 @@ using namespace std;
#include "df/world.h"
using namespace DFHack;
using namespace DFHack::Simple;
using df::global::world;
bool Engravings::isValid()

@ -69,7 +69,7 @@ using df::global::gps;
// Predefined common guard functions
bool DFHack::default_hotkey(Core *, df::viewscreen *top)
bool Gui::default_hotkey(Core *, df::viewscreen *top)
{
// Default hotkey guard function
for (;top ;top = top->parent)
@ -78,26 +78,26 @@ bool DFHack::default_hotkey(Core *, df::viewscreen *top)
return false;
}
bool DFHack::dwarfmode_hotkey(Core *, df::viewscreen *top)
bool Gui::dwarfmode_hotkey(Core *, df::viewscreen *top)
{
// Require the main dwarf mode screen
return !!strict_virtual_cast<df::viewscreen_dwarfmodest>(top);
}
bool DFHack::unitjobs_hotkey(Core *, df::viewscreen *top)
bool Gui::unitjobs_hotkey(Core *, df::viewscreen *top)
{
// Require the unit or jobs list
return !!strict_virtual_cast<df::viewscreen_joblistst>(top) ||
!!strict_virtual_cast<df::viewscreen_unitlistst>(top);
}
bool DFHack::item_details_hotkey(Core *, df::viewscreen *top)
bool Gui::item_details_hotkey(Core *, df::viewscreen *top)
{
// Require the main dwarf mode screen
return !!strict_virtual_cast<df::viewscreen_itemst>(top);
}
bool DFHack::cursor_hotkey(Core *c, df::viewscreen *top)
bool Gui::cursor_hotkey(Core *c, df::viewscreen *top)
{
if (!dwarfmode_hotkey(c, top))
return false;
@ -109,7 +109,7 @@ bool DFHack::cursor_hotkey(Core *c, df::viewscreen *top)
return true;
}
bool DFHack::workshop_job_hotkey(Core *c, df::viewscreen *top)
bool Gui::workshop_job_hotkey(Core *c, df::viewscreen *top)
{
using namespace ui_sidebar_mode;
using df::global::ui;
@ -147,7 +147,7 @@ bool DFHack::workshop_job_hotkey(Core *c, df::viewscreen *top)
}
}
bool DFHack::build_selector_hotkey(Core *c, df::viewscreen *top)
bool Gui::build_selector_hotkey(Core *c, df::viewscreen *top)
{
using namespace ui_sidebar_mode;
using df::global::ui;
@ -175,7 +175,7 @@ bool DFHack::build_selector_hotkey(Core *c, df::viewscreen *top)
}
}
bool DFHack::view_unit_hotkey(Core *c, df::viewscreen *top)
bool Gui::view_unit_hotkey(Core *c, df::viewscreen *top)
{
using df::global::ui;
using df::global::world;
@ -191,7 +191,7 @@ bool DFHack::view_unit_hotkey(Core *c, df::viewscreen *top)
return vector_get(world->units.other[0], *ui_selected_unit) != NULL;
}
bool DFHack::unit_inventory_hotkey(Core *c, df::viewscreen *top)
bool Gui::unit_inventory_hotkey(Core *c, df::viewscreen *top)
{
using df::global::ui_unit_view_mode;
@ -203,7 +203,7 @@ bool DFHack::unit_inventory_hotkey(Core *c, df::viewscreen *top)
return ui_unit_view_mode->value == df::ui_unit_view_mode::Inventory;
}
df::job *DFHack::getSelectedWorkshopJob(Core *c, bool quiet)
df::job *Gui::getSelectedWorkshopJob(Core *c, bool quiet)
{
using df::global::world;
using df::global::ui_workshop_job_cursor;
@ -226,7 +226,7 @@ df::job *DFHack::getSelectedWorkshopJob(Core *c, bool quiet)
return selected->jobs[idx];
}
bool DFHack::any_job_hotkey(Core *c, df::viewscreen *top)
bool Gui::any_job_hotkey(Core *c, df::viewscreen *top)
{
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_joblistst, top))
return vector_get(screen->jobs, screen->cursor_pos) != NULL;
@ -237,7 +237,7 @@ bool DFHack::any_job_hotkey(Core *c, df::viewscreen *top)
return workshop_job_hotkey(c,top);
}
df::job *DFHack::getSelectedJob(Core *c, bool quiet)
df::job *Gui::getSelectedJob(Core *c, bool quiet)
{
df::viewscreen *top = c->getTopViewscreen();
@ -285,7 +285,7 @@ static df::unit *getAnyUnit(Core *c, df::viewscreen *top)
return ref ? ref->getUnit() : NULL;
}
if (!dwarfmode_hotkey(c,top))
if (!Gui::dwarfmode_hotkey(c,top))
return NULL;
switch (ui->main.mode) {
@ -312,12 +312,12 @@ static df::unit *getAnyUnit(Core *c, df::viewscreen *top)
}
}
bool DFHack::any_unit_hotkey(Core *c, df::viewscreen *top)
bool Gui::any_unit_hotkey(Core *c, df::viewscreen *top)
{
return getAnyUnit(c, top) != NULL;
}
df::unit *DFHack::getSelectedUnit(Core *c, bool quiet)
df::unit *Gui::getSelectedUnit(Core *c, bool quiet)
{
df::unit *unit = getAnyUnit(c, c->getTopViewscreen());
@ -344,7 +344,7 @@ static df::item *getAnyItem(Core *c, df::viewscreen *top)
return ref ? ref->getItem() : NULL;
}
if (!dwarfmode_hotkey(c,top))
if (!Gui::dwarfmode_hotkey(c,top))
return NULL;
switch (ui->main.mode) {
@ -387,12 +387,12 @@ static df::item *getAnyItem(Core *c, df::viewscreen *top)
}
}
bool DFHack::any_item_hotkey(Core *c, df::viewscreen *top)
bool Gui::any_item_hotkey(Core *c, df::viewscreen *top)
{
return getAnyItem(c, top) != NULL;
}
df::item *DFHack::getSelectedItem(Core *c, bool quiet)
df::item *Gui::getSelectedItem(Core *c, bool quiet)
{
df::item *item = getAnyItem(c, c->getTopViewscreen());
@ -404,7 +404,7 @@ df::item *DFHack::getSelectedItem(Core *c, bool quiet)
//
void DFHack::showAnnouncement(std::string message, int color, bool bright)
void Gui::showAnnouncement(std::string message, int color, bool bright)
{
using df::global::world;
using df::global::cur_year;
@ -455,7 +455,7 @@ void DFHack::showAnnouncement(std::string message, int color, bool bright)
}
void DFHack::showPopupAnnouncement(std::string message, int color, bool bright)
void Gui::showPopupAnnouncement(std::string message, int color, bool bright)
{
using df::global::world;
@ -466,77 +466,6 @@ void DFHack::showPopupAnnouncement(std::string message, int color, bool bright)
world->status.popups.push_back(popup);
}
//
Module* DFHack::createGui()
{
return new Gui();
}
struct Gui::Private
{
Private()
{
Started = false;
StartedMenu = false;
StartedScreen = false;
}
bool Started;
int32_t * window_x_offset;
int32_t * window_y_offset;
int32_t * window_z_offset;
bool StartedMenu;
uint8_t * menu_width_offset;
uint8_t * area_map_width_offset;
bool StartedScreen;
void * screen_tiles_ptr_offset;
Process * owner;
};
Gui::Gui()
{
Core & c = Core::getInstance();
d = new Private;
d->owner = c.p;
VersionInfo * mem = c.vinfo;
// Setting up menu state
df_menu_state = (uint32_t *) & df::global::ui->main.mode;
d->window_x_offset = (int32_t *) mem->getAddress ("window_x");
d->window_y_offset = (int32_t *) mem->getAddress ("window_y");
d->window_z_offset = (int32_t *) mem->getAddress ("window_z");
if(d->window_z_offset && d->window_y_offset && d->window_x_offset)
d->Started = true;
d->menu_width_offset = (uint8_t *) mem->getAddress("ui_menu_width");
d->area_map_width_offset = (uint8_t *) mem->getAddress("ui_area_map_width");
if (d->menu_width_offset && d->area_map_width_offset)
d->StartedMenu = true;
d->screen_tiles_ptr_offset = (void *) mem->getAddress ("screen_tiles_pointer");
if(d->screen_tiles_ptr_offset)
d->StartedScreen = true;
}
Gui::~Gui()
{
delete d;
}
bool Gui::Start()
{
return true;
}
bool Gui::Finish()
{
return true;
}
df::viewscreen * Gui::GetCurrentScreen()
{
df::viewscreen * ws = &gview->view;
@ -552,27 +481,18 @@ df::viewscreen * Gui::GetCurrentScreen()
bool Gui::getViewCoords (int32_t &x, int32_t &y, int32_t &z)
{
if (!d->Started) return false;
Process * p = d->owner;
p->readDWord (d->window_x_offset, (uint32_t &) x);
p->readDWord (d->window_y_offset, (uint32_t &) y);
p->readDWord (d->window_z_offset, (uint32_t &) z);
x = *df::global::window_x;
y = *df::global::window_y;
z = *df::global::window_z;
return true;
}
//FIXME: confine writing of coords to map bounds?
bool Gui::setViewCoords (const int32_t x, const int32_t y, const int32_t z)
{
if (!d->Started)
{
return false;
}
Process * p = d->owner;
p->writeDWord (d->window_x_offset, (uint32_t) x);
p->writeDWord (d->window_y_offset, (uint32_t) y);
p->writeDWord (d->window_z_offset, (uint32_t) z);
auto cursor = df::global::cursor;
(*df::global::window_x) = x;
(*df::global::window_y) = y;
(*df::global::window_z) = z;
return true;
}
@ -581,8 +501,7 @@ bool Gui::getCursorCoords (int32_t &x, int32_t &y, int32_t &z)
x = df::global::cursor->x;
y = df::global::cursor->y;
z = df::global::cursor->z;
if (x == -30000) return false;
return true;
return (x == -30000) ? false : true;
}
//FIXME: confine writing of coords to map bounds?
@ -599,8 +518,7 @@ bool Gui::getDesignationCoords (int32_t &x, int32_t &y, int32_t &z)
x = df::global::selection_rect->start_x;
y = df::global::selection_rect->start_y;
z = df::global::selection_rect->start_z;
if (x == -30000) return false;
return true;
return (x == -30000) ? false : true;
}
bool Gui::setDesignationCoords (const int32_t x, const int32_t y, const int32_t z)
@ -615,8 +533,7 @@ bool Gui::getMousePos (int32_t & x, int32_t & y)
{
x = gps->mouse_x;
y = gps->mouse_y;
if(x == -1) return false;
return true;
return (x == -1) ? false : true;
}
bool Gui::getWindowSize (int32_t &width, int32_t &height)
@ -628,49 +545,14 @@ bool Gui::getWindowSize (int32_t &width, int32_t &height)
bool Gui::getMenuWidth(uint8_t &menu_width, uint8_t &area_map_width)
{
if (!d->StartedMenu) return false;
Process * p = d->owner;
p->readByte (d->menu_width_offset, menu_width);
p->readByte (d->area_map_width_offset, area_map_width);
menu_width = *df::global::ui_menu_width;
area_map_width = *df::global::ui_area_map_width;
return true;
}
bool Gui::setMenuWidth(const uint8_t menu_width, const uint8_t area_map_width)
{
if (!d->StartedMenu) return false;
Process * p = d->owner;
p->writeByte (d->menu_width_offset, menu_width);
p->writeByte (d->area_map_width_offset, area_map_width);
*df::global::ui_menu_width = menu_width;
*df::global::ui_area_map_width = area_map_width;
return true;
}
bool Gui::getScreenTiles (int32_t width, int32_t height, t_screen screen[])
{
if(!d->StartedScreen) return false;
void * screen_addr = (void *) d->owner->readDWord(d->screen_tiles_ptr_offset);
uint8_t* tiles = new uint8_t[width*height*4/* + 80 + width*height*4*/];
d->owner->read (screen_addr, (width*height*4/* + 80 + width*height*4*/), tiles);
for(int32_t iy=0; iy<height; iy++)
{
for(int32_t ix=0; ix<width; ix++)
{
screen[ix + iy*width].symbol = tiles[(iy + ix*height)*4 +0];
screen[ix + iy*width].foreground = tiles[(iy + ix*height)*4 +1];
screen[ix + iy*width].background = tiles[(iy + ix*height)*4 +2];
screen[ix + iy*width].bright = tiles[(iy + ix*height)*4 +3];
//screen[ix + iy*width].gtile = tiles[width*height*4 + 80 + iy + ix*height +0];
//screen[ix + iy*width].grayscale = tiles[width*height*4 + 80 + iy + ix*height +1];
}
}
delete [] tiles;
return true;
}

@ -66,7 +66,6 @@ using namespace std;
#include "df/general_ref.h"
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -47,7 +47,6 @@ using namespace std;
#include "df/feature_init.h"
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -37,7 +37,6 @@ using namespace std;
#include "Core.h"
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
#include "DataDefs.h"

@ -50,7 +50,6 @@ using namespace std;
#include "df/unit_inventory_item.h"
using namespace DFHack;
using namespace DFHack::Simple;
using df::global::world;
using df::global::ui;

@ -40,7 +40,6 @@ using namespace DFHack;
#include "df/world.h"
using namespace DFHack;
using namespace DFHack::Simple;
using df::global::world;
bool Vegetation::isValid()

@ -37,7 +37,6 @@ using namespace std;
#include "ModuleFactory.h"
#include "Core.h"
using namespace DFHack;
using namespace DFHack::Simple;
#include "DataDefs.h"
#include "df/world.h"

@ -17,7 +17,6 @@ using namespace std;
#include "ModuleFactory.h"
#include "Core.h"
using namespace DFHack;
using namespace DFHack::Simple;
#include "DataDefs.h"
#include "df/world.h"

@ -33,7 +33,7 @@ using df::global::ui_advmode;
using df::nemesis_record;
using df::historical_figure;
using namespace DFHack::Simple::Translation;
using namespace DFHack::Translation;
/*********************
* PLUGIN INTERFACE *

@ -56,12 +56,12 @@ DFhackCExport command_result plugin_init ( Core * c, vector <PluginCommand> &com
));
commands.push_back(PluginCommand(
"autodump-destroy-here", "Destroy items marked for dumping under cursor.",
df_autodump_destroy_here, cursor_hotkey,
df_autodump_destroy_here, Gui::cursor_hotkey,
" Identical to autodump destroy-here, but intended for use as keybinding.\n"
));
commands.push_back(PluginCommand(
"autodump-destroy-item", "Destroy the selected item.",
df_autodump_destroy_item, any_item_hotkey,
df_autodump_destroy_item, Gui::any_item_hotkey,
" Destroy the selected item. The item may be selected\n"
" in the 'k' list, or inside a container. If called\n"
" again before the game is resumed, cancels destroy.\n"
@ -108,7 +108,6 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
}
DFHack::VersionInfo *mem = c->vinfo;
DFHack::Gui * Gui = c->getGui();
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
@ -124,7 +123,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
DFCoord pos_cursor;
if(!destroy || here)
{
if (!Gui->getCursorCoords(cx,cy,cz))
if (!Gui::getCursorCoords(cx,cy,cz))
{
c->con.printerr("Cursor position not found. Please enabled the cursor.\n");
return CR_FAILURE;
@ -307,7 +306,7 @@ command_result df_autodump_destroy_item(Core * c, vector <string> & parameters)
if (!parameters.empty())
return CR_WRONG_USAGE;
df::item *item = getSelectedItem(c);
df::item *item = Gui::getSelectedItem(c);
if (!item)
return CR_FAILURE;

@ -13,7 +13,6 @@
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -16,7 +16,6 @@
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;
@ -208,7 +207,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
));
commands.push_back(PluginCommand(
"spotclean","Cleans map tile under cursor.",
spotclean,cursor_hotkey
spotclean,Gui::cursor_hotkey
));
return CR_OK;
}

@ -21,7 +21,6 @@ using namespace std;
#include "df/world.h"
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -10,7 +10,6 @@
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
command_result colonies (Core * c, vector <string> & parameters);

@ -12,7 +12,6 @@
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -39,7 +39,6 @@ command_result readFlag (Core * c, vector <string> & parameters)
{
c->Suspend();
Gui * Gui = c->getGui();
// init the map
if(!Maps::IsValid())
{
@ -49,8 +48,7 @@ command_result readFlag (Core * c, vector <string> & parameters)
}
int32_t cx, cy, cz;
Gui->getCursorCoords(cx,cy,cz);
while(cx == -30000)
if(!Gui::getCursorCoords(cx,cy,cz))
{
c->con.printerr("Cursor is not active.\n");
c->Resume();
@ -106,7 +104,6 @@ command_result writeFlag (Core * c, vector <string> & parameters)
c->Suspend();
Gui * Gui = c->getGui();
// init the map
if(!Maps::IsValid())
{
@ -116,8 +113,7 @@ command_result writeFlag (Core * c, vector <string> & parameters)
}
int32_t cx, cy, cz;
Gui->getCursorCoords(cx,cy,cz);
while(cx == -30000)
if(!Gui::getCursorCoords(cx,cy,cz))
{
c->con.printerr("Cursor is not active.\n");
c->Resume();

@ -24,7 +24,6 @@ using namespace std;
#include <df/creature_raw.h>
using namespace DFHack;
using namespace DFHack::Simple;
command_result catsplosion (Core * c, std::vector <std::string> & parameters);

@ -9,7 +9,6 @@
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -15,7 +15,7 @@
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
//FIXME: possible race conditions with calling kittens from the IO thread and shutdown from Core.
bool shutdown_flag = false;
bool final_flag = true;
@ -70,19 +70,16 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
}
if(trackmenu_flg)
{
DFHack::Gui * g =c->getGui();
if (last_menu != *g->df_menu_state)
if (last_menu != df::global::ui->main.mode)
{
last_menu = *g->df_menu_state;
last_menu = df::global::ui->main.mode;
c->con.print("Menu: %d\n",last_menu);
}
}
if(trackpos_flg)
{
DFHack::Gui * g =c->getGui();
g->Start();
int32_t desig_x, desig_y, desig_z;
g->getDesignationCoords(desig_x,desig_y,desig_z);
Gui::getDesignationCoords(desig_x,desig_y,desig_z);
if(desig_x != last_designation[0] || desig_y != last_designation[1] || desig_z != last_designation[2])
{
last_designation[0] = desig_x;
@ -91,7 +88,7 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
c->con.print("Designation: %d %d %d\n",desig_x, desig_y, desig_z);
}
int mouse_x, mouse_y;
g->getMousePos(mouse_x,mouse_y);
Gui::getMousePos(mouse_x,mouse_y);
if(mouse_x != last_mouse[0] || mouse_y != last_mouse[1])
{
last_mouse[0] = mouse_x;
@ -111,11 +108,10 @@ command_result trackmenu (Core * c, vector <string> & parameters)
}
else
{
DFHack::Gui * g =c->getGui();
if(g->df_menu_state)
if(df::global::ui)
{
trackmenu_flg = true;
last_menu = *g->df_menu_state;
last_menu = df::global::ui->main.mode;
c->con.print("Menu: %d\n",last_menu);
return CR_OK;
}
@ -150,6 +146,7 @@ command_result colormods (Core * c, vector <string> & parameters)
return CR_OK;
}
// FIXME: move cursor properly relative to view position
command_result zoom (Core * c, vector <string> & parameters)
{
if(parameters.size() < 3)
@ -159,12 +156,11 @@ command_result zoom (Core * c, vector <string> & parameters)
int z = atoi( parameters[2].c_str());
int xi, yi, zi;
CoreSuspender cs (c);
Gui * g = c->getGui();
if(g->getCursorCoords(xi, yi, zi))
if(Gui::getCursorCoords(xi, yi, zi))
{
g->setCursorCoords(x,y,z);
Gui::setCursorCoords(x,y,z);
}
g->setViewCoords(x,y,z);
Gui::setViewCoords(x,y,z);
}
command_result ktimer (Core * c, vector <string> & parameters)

@ -13,7 +13,6 @@
#include "TileTypes.h"
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -20,9 +20,6 @@ using namespace std;
#include <df/unit_soul.h>
using namespace DFHack;
using namespace DFHack::Simple;
using namespace DFHack::Simple;
using df::global::ui;
using df::global::world;

@ -40,7 +40,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
{
commands.push_back(PluginCommand(
"filltraffic","Flood-fill with selected traffic designation from cursor",
filltraffic, cursor_hotkey,
filltraffic, Gui::cursor_hotkey,
" Flood-fill selected traffic type from the cursor.\n"
"Traffic Type Codes:\n"
" H: High Traffic\n"
@ -115,7 +115,6 @@ command_result filltraffic(Core * c, std::vector<std::string> & params)
}
}
Gui * Gui = c->getGui();
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
@ -126,7 +125,7 @@ command_result filltraffic(Core * c, std::vector<std::string> & params)
Maps::getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui->getCursorCoords(cx,cy,cz);
Gui::getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
c->con.printerr("Cursor is not active.\n");
@ -276,7 +275,6 @@ command_result setAllMatching(Core * c, checkTile checkProc,
//Initialization.
CoreSuspender suspend(c);
Gui * Gui = c->getGui();
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");

@ -17,7 +17,6 @@
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -29,7 +29,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
{
commands.push_back(PluginCommand(
"follow", "Follow the selected unit until camera control is released",
follow, view_unit_hotkey,
follow, Gui::view_unit_hotkey,
" Select a unit and run this plugin to make the camera follow it. Moving the camera yourself deactivates the plugin.\n"
));
followedUnit = 0;
@ -69,14 +69,15 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
df::coord &unitPos = followedUnit->pos;
Gui *gui = c->getGui(); //Get all of the relevant data for determining the size of the map on the window
//Get all of the relevant data for determining the size of the map on the window
int32_t x,y,z,w,h,c_x,c_y,c_z;
uint8_t menu_width, area_map_width;
gui->getViewCoords(x,y,z);
gui->getWindowSize(w,h);
gui->getMenuWidth(menu_width, area_map_width);
gui->getCursorCoords(c_x,c_y,c_z);
Gui::getViewCoords(x,y,z);
Gui::getWindowSize(w,h);
Gui::getMenuWidth(menu_width, area_map_width);
Gui::getCursorCoords(c_x,c_y,c_z);
// FIXME: is this really needed? does it ever evaluate to 'true'?
if (c_x != -30000 && menu_width == 3) menu_width = 2; //Presence of the cursor means that there's actually a width-2 menu open
h -= 2; //account for vertical borders
@ -103,20 +104,26 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
return CR_OK;
}
//Get map size in tiles so we can prevent the camera from going off the edge
uint32_t x_max, y_max, z_max;
Simple::Maps::getSize(x_max, y_max, z_max); //Get map size in tiles so we can prevent the camera from going off the edge
Maps::getSize(x_max, y_max, z_max);
x_max *= 16;
y_max *= 16;
x = unitPos.x + w/2 >= x_max ? x_max-w : (unitPos.x >= w/2 ? unitPos.x - w/2 : 0); //Calculate a new screen position centered on the selected unit
//Calculate a new screen position centered on the selected unit
x = unitPos.x + w/2 >= x_max ? x_max-w : (unitPos.x >= w/2 ? unitPos.x - w/2 : 0);
y = unitPos.y + h/2 >= y_max ? y_max-h : (unitPos.y >= h/2 ? unitPos.y - h/2 : 0);
z = unitPos.z;
gui->setViewCoords(x, y, z); //Set the new screen position!
//Set the new screen position!
Gui::setViewCoords(x, y, z);
if (c_x != -30000 && !world->ReadPauseState()) gui->setCursorCoords(c_x - (prevX-x), c_y - (prevY-y), z); //If, for some reason, the cursor is active and the screen is still moving, move the cursor along with the screen
//If, for some reason, the cursor is active and the screen is still moving, move the cursor along with the screen
if (c_x != -30000 && !world->ReadPauseState())
Gui::setCursorCoords(c_x - (prevX-x), c_y - (prevY-y), z);
prevX = x; //Save this round's stuff for next time so we can monitor for changes made by the user
//Save this round's stuff for next time so we can monitor for changes made by the user
prevX = x;
prevY = y;
prevZ = z;
prevMenuWidth = menu_width;
@ -136,7 +143,7 @@ command_result follow (Core * c, std::vector <std::string> & parameters)
c->con.print("No longer following previously selected unit.\n");
followedUnit = 0;
}
followedUnit = getSelectedUnit(c);
followedUnit = Gui::getSelectedUnit(c);
if (followedUnit)
{
std::ostringstream ss;

@ -23,9 +23,9 @@ DFhackCExport command_result plugin_init (Core *c, std::vector <PluginCommand> &
{
if (d_init) {
commands.push_back(PluginCommand("twaterlvl", "Toggle display of water/magma depth.",
twaterlvl, dwarfmode_hotkey));
twaterlvl, Gui::dwarfmode_hotkey));
commands.push_back(PluginCommand("tidlers", "Toggle display of idlers.",
tidlers, dwarfmode_hotkey));
tidlers, Gui::dwarfmode_hotkey));
}
std::cerr << "d_init: " << sizeof(df::d_init) << endl;
return CR_OK;

@ -89,7 +89,7 @@ DFhackCExport command_result plugin_init (Core *c, std::vector <PluginCommand> &
commands.push_back(
PluginCommand(
"job-duplicate", "Duplicate the selected job in a workshop.",
job_duplicate, workshop_job_hotkey,
job_duplicate, Gui::workshop_job_hotkey,
" - In 'q' mode, when a job is highlighted within a workshop\n"
" or furnace building, instantly duplicates the job.\n"
)
@ -108,15 +108,15 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
static bool job_material_hotkey(Core *c, df::viewscreen *top)
{
return workshop_job_hotkey(c, top) ||
build_selector_hotkey(c, top);
return Gui::workshop_job_hotkey(c, top) ||
Gui::build_selector_hotkey(c, top);
}
/* job-material implementation */
static command_result job_material_in_job(Core *c, MaterialInfo &new_mat)
{
df::job *job = getSelectedWorkshopJob(c);
df::job *job = Gui::getSelectedWorkshopJob(c);
if (!job)
return CR_FAILURE;
@ -268,7 +268,7 @@ static command_result job_duplicate(Core * c, vector <string> & parameters)
if (!parameters.empty())
return CR_WRONG_USAGE;
df::job *job = getSelectedWorkshopJob(c);
df::job *job = Gui::getSelectedWorkshopJob(c);
if (!job)
return CR_FAILURE;
@ -320,14 +320,14 @@ static command_result job_cmd(Core * c, vector <string> & parameters)
std::string cmd = (parameters.empty() ? "query" : parameters[0]);
if (cmd == "query" || cmd == "list")
{
df::job *job = getSelectedJob(c);
df::job *job = Gui::getSelectedJob(c);
if (!job)
return CR_WRONG_USAGE;
if (cmd == "query") {
printJobDetails(c, job);
} else {
if (!workshop_job_hotkey(c, c->getTopViewscreen()))
if (!Gui::workshop_job_hotkey(c, c->getTopViewscreen()))
return CR_WRONG_USAGE;
df::building *selected = world->selected_building;
@ -340,7 +340,7 @@ static command_result job_cmd(Core * c, vector <string> & parameters)
if (parameters.size() != 3)
return CR_WRONG_USAGE;
df::job *job = getSelectedJob(c);
df::job *job = Gui::getSelectedJob(c);
df::job_item *item = getJobItem(c, job, parameters[1]);
if (!item)
return CR_WRONG_USAGE;
@ -384,7 +384,7 @@ static command_result job_cmd(Core * c, vector <string> & parameters)
if (parameters.size() != 3)
return CR_WRONG_USAGE;
df::job *job = getSelectedJob(c);
df::job *job = Gui::getSelectedJob(c);
df::job_item *item = getJobItem(c, job, parameters[1]);
if (!item)
return CR_WRONG_USAGE;

@ -224,7 +224,6 @@ command_result df_liquids (Core * c, vector <string> & parameters)
{
int32_t x,y,z;
DFHack::Gui * Position;
for(size_t i = 0; i < parameters.size();i++)
{
if(parameters[i] == "help" || parameters[i] == "?")
@ -429,7 +428,6 @@ command_result df_liquids (Core * c, vector <string> & parameters)
else if(command.empty())
{
CoreSuspender suspend(c);
Position = c->getGui();
do
{
if (!Maps::IsValid())
@ -437,7 +435,7 @@ command_result df_liquids (Core * c, vector <string> & parameters)
c->con << "Can't see any DF map loaded." << endl;
break;;
}
if(!Position->getCursorCoords(x,y,z))
if(!Gui::getCursorCoords(x,y,z))
{
c->con << "Can't get cursor coords! Make sure you have a cursor active in DF." << endl;
break;

@ -102,7 +102,6 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
Gui * Gui = c->getGui();
uint32_t x_max, y_max, z_max;
Maps::getSize(x_max, y_max, z_max);
MapExtras::MapCache map;
@ -125,7 +124,7 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
else
{
int32_t x,y,z;
if(Gui->getCursorCoords(x,y,z))
if(Gui::getCursorCoords(x,y,z))
{
vector<df::plant *> * alltrees;
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))
@ -205,9 +204,8 @@ command_result df_grow (Core * c, vector <string> & parameters)
return CR_FAILURE;
}
MapExtras::MapCache map;
Gui *Gui = c->getGui();
int32_t x,y,z;
if(Gui->getCursorCoords(x,y,z))
if(Gui::getCursorCoords(x,y,z))
{
vector<df::plant *> * alltrees;
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))

@ -27,7 +27,6 @@ using namespace std;
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;
@ -57,9 +56,8 @@ command_result df_cprobe (Core * c, vector <string> & parameters)
{
Console & con = c->con;
CoreSuspender suspend(c);
DFHack::Gui *Gui = c->getGui();
int32_t cursorX, cursorY, cursorZ;
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
Gui::getCursorCoords(cursorX,cursorY,cursorZ);
if(cursorX == -30000)
{
con.printerr("No cursor; place cursor over creature to probe.\n");
@ -94,7 +92,6 @@ command_result df_probe (Core * c, vector <string> & parameters)
CoreSuspender suspend(c);
DFHack::Gui *Gui = c->getGui();
DFHack::Materials *Materials = c->getMaterials();
DFHack::VersionInfo* mem = c->vinfo;
std::vector<t_matglossInorganic> inorganic;
@ -111,7 +108,7 @@ command_result df_probe (Core * c, vector <string> & parameters)
Maps::getPosition(regionX,regionY,regionZ);
int32_t cursorX, cursorY, cursorZ;
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
Gui::getCursorCoords(cursorX,cursorY,cursorZ);
if(cursorX == -30000)
{
con.printerr("No cursor; place cursor over tile to probe.\n");

@ -120,7 +120,7 @@ static command_result rename(Core * c, vector <string> &parameters)
if (parameters.size() != 2)
return CR_WRONG_USAGE;
df::unit *unit = getSelectedUnit(c);
df::unit *unit = Gui::getSelectedUnit(c);
if (!unit)
return CR_WRONG_USAGE;
@ -153,7 +153,7 @@ static command_result rename(Core * c, vector <string> &parameters)
if (parameters.size() != 2)
return CR_WRONG_USAGE;
df::unit *unit = getSelectedUnit(c);
df::unit *unit = Gui::getSelectedUnit(c);
if (!unit)
return CR_WRONG_USAGE;

@ -303,7 +303,6 @@ command_result revflood(DFHack::Core * c, std::vector<std::string> & params)
}
CoreSuspender suspend(c);
uint32_t x_max,y_max,z_max;
Gui * Gui = c->getGui();
World * World = c->getWorld();
if (!Maps::IsValid())
{
@ -327,7 +326,7 @@ command_result revflood(DFHack::Core * c, std::vector<std::string> & params)
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui->getCursorCoords(cx,cy,cz);
Gui::getCursorCoords(cx,cy,cz);
if(cx == -30000)
{
c->con.printerr("Cursor is not active. Point the cursor at some empty space you want to be unhidden.\n");

@ -18,7 +18,6 @@
using namespace std;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -22,7 +22,6 @@
using std::string;
using std::vector;
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -56,7 +56,7 @@ static bool copystock_guard(Core *c, df::viewscreen *top)
{
using namespace ui_sidebar_mode;
if (!dwarfmode_hotkey(c,top))
if (!Gui::dwarfmode_hotkey(c,top))
return false;
switch (ui->main.mode) {

@ -1 +1 @@
Subproject commit 58147c3138cddc2e732dd537ca8a78782f196f88
Subproject commit 34183f96b86394895975fb59ae3c4673cd78f502

@ -656,7 +656,6 @@ command_result df_tiletypes (Core * c, vector <string> & parameters)
uint32_t x_max = 0, y_max = 0, z_max = 0;
int32_t x = 0, y = 0, z = 0;
DFHack::Gui *gui;
for(size_t i = 0; i < parameters.size();i++)
{
if(parameters[i] == "help" || parameters[i] == "?")
@ -769,7 +768,6 @@ command_result df_tiletypes (Core * c, vector <string> & parameters)
}
CoreSuspender suspend(c);
gui = c->getGui();
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
@ -777,7 +775,7 @@ command_result df_tiletypes (Core * c, vector <string> & parameters)
}
Maps::getSize(x_max, y_max, z_max);
if (!(gui->Start() && gui->getCursorCoords(x,y,z)))
if (!Gui::getCursorCoords(x,y,z))
{
c->con.printerr("Can't get cursor coords! Make sure you have a cursor active in DF.\n");
return CR_FAILURE;
@ -798,7 +796,7 @@ command_result df_tiletypes (Core * c, vector <string> & parameters)
|| (filter.material > -1 && filter.material != tileMaterial(source))
|| (filter.special > -1 && filter.special != tileSpecial(source))
|| (filter.variant > -1 && filter.variant != tileVariant(source))
|| (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != tile_dig_designation::No))
|| (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != tile_dig_designation::No))
)
{
continue;

@ -14,7 +14,6 @@
#include "TileTypes.h"
using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;

@ -29,13 +29,13 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
{
commands.clear();
commands.push_back(PluginCommand(
"vdig","Dig a whole vein.",vdig,cursor_hotkey,
"vdig","Dig a whole vein.",vdig,Gui::cursor_hotkey,
" Designates a whole vein under the cursor for digging.\n"
"Options:\n"
" x - follow veins through z-levels with stairs.\n"
));
commands.push_back(PluginCommand(
"vdigx","Dig a whole vein, following through z-levels.",vdigx,cursor_hotkey,
"vdigx","Dig a whole vein, following through z-levels.",vdigx,Gui::cursor_hotkey,
" Designates a whole vein under the cursor for digging.\n"
" Also follows the vein between z-levels with stairs, like 'vdig x' would.\n"
));
@ -273,7 +273,6 @@ command_result digcircle (Core * c, vector <string> & parameters)
}
int32_t cx, cy, cz;
CoreSuspender suspend(c);
Gui * gui = c->getGui();
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
@ -284,7 +283,7 @@ command_result digcircle (Core * c, vector <string> & parameters)
Maps::getSize(x_max,y_max,z_max);
MapExtras::MapCache MCache;
if(!gui->getCursorCoords(cx,cy,cz) || cx == -30000)
if(!Gui::getCursorCoords(cx,cy,cz) || cx == -30000)
{
c->con.printerr("Can't get the cursor coords...\n");
return CR_FAILURE;
@ -848,7 +847,6 @@ command_result expdig (Core * c, vector <string> & parameters)
return CR_OK;
}
CoreSuspender suspend(c);
Gui * gui = c->getGui();
uint32_t x_max, y_max, z_max;
if (!Maps::IsValid())
{
@ -857,7 +855,7 @@ command_result expdig (Core * c, vector <string> & parameters)
}
Maps::getSize(x_max,y_max,z_max);
int32_t xzzz,yzzz,z_level;
if(!gui->getViewCoords(xzzz,yzzz,z_level))
if(!Gui::getViewCoords(xzzz,yzzz,z_level))
{
c->con.printerr("Can't get view coords...\n");
return CR_FAILURE;
@ -974,7 +972,6 @@ command_result vdig (Core * c, vector <string> & parameters)
Console & con = c->con;
DFHack::Gui * Gui = c->getGui();
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
@ -985,7 +982,7 @@ command_result vdig (Core * c, vector <string> & parameters)
Maps::getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui->getCursorCoords(cx,cy,cz);
Gui::getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
con.printerr("Cursor is not active. Point the cursor at a vein.\n");

@ -1232,15 +1232,15 @@ static void update_jobs_by_constraints(Core *c)
if (is_running != ct->is_active)
{
if (is_running && ct->request_resume)
showAnnouncement("Resuming production: " + info, 2, false);
Gui::showAnnouncement("Resuming production: " + info, 2, false);
else if (!is_running && !ct->request_resume)
showAnnouncement("Stopping production: " + info, 3, false);
Gui::showAnnouncement("Stopping production: " + info, 3, false);
}
if (ct->request_resume && !is_running)
{
if (!ct->cant_resume_reported)
showAnnouncement("Cannot produce: " + info, 6, true);
Gui::showAnnouncement("Cannot produce: " + info, 6, true);
ct->cant_resume_reported = true;
}
else
@ -1415,11 +1415,11 @@ static command_result workflow_cmd(Core *c, vector <string> & parameters)
df::building *workshop = NULL;
df::job *job = NULL;
if (dwarfmode_hotkey(c, c->getTopViewscreen()) &&
if (Gui::dwarfmode_hotkey(c, c->getTopViewscreen()) &&
ui->main.mode == ui_sidebar_mode::QueryBuilding)
{
workshop = world->selected_building;
job = getSelectedWorkshopJob(c, true);
job = Gui::getSelectedWorkshopJob(c, true);
}
std::string cmd = parameters.empty() ? "list" : parameters[0];