From 7fe8762852c11caeaeb486e9b76f024f5cbaf0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 3 Mar 2012 14:38:24 +0100 Subject: [PATCH] Get rid of Simple namespace, Gui module is now a namespace. --- library/Core.cpp | 19 +-- library/PluginManager.cpp | 2 +- library/include/Core.h | 4 - library/include/PluginManager.h | 11 +- library/include/modules/Buildings.h | 3 - library/include/modules/Constructions.h | 3 - library/include/modules/Engravings.h | 3 - library/include/modules/Gui.h | 150 ++++++++----------- library/include/modules/Items.h | 3 - library/include/modules/MapCache.h | 1 - library/include/modules/Maps.h | 3 - library/include/modules/Translation.h | 3 - library/include/modules/Units.h | 3 - library/include/modules/Vegetation.h | 3 - library/include/modules/Vermin.h | 7 +- library/include/modules/kitchen.h | 3 - library/modules/Buildings.cpp | 1 - library/modules/Constructions.cpp | 1 - library/modules/Engravings.cpp | 1 - library/modules/Gui.cpp | 186 +++++------------------- library/modules/Items.cpp | 1 - library/modules/Maps.cpp | 1 - library/modules/Translation.cpp | 1 - library/modules/Units.cpp | 1 - library/modules/Vegetation.cpp | 1 - library/modules/Vermin.cpp | 1 - library/modules/kitchen.cpp | 1 - plugins/advtools.cpp | 2 +- plugins/autodump.cpp | 9 +- plugins/changevein.cpp | 1 - plugins/cleaners.cpp | 3 +- plugins/cleanowned.cpp | 1 - plugins/colonies.cpp | 1 - plugins/deramp.cpp | 1 - plugins/devel/buildprobe.cpp | 8 +- plugins/devel/catsplosion.cpp | 1 - plugins/devel/frozen.cpp | 1 - plugins/devel/kittens.cpp | 26 ++-- plugins/devel/tilesieve.cpp | 1 - plugins/dwarfexport/dwarfexport.cpp | 3 - plugins/filltraffic.cpp | 6 +- plugins/fixveins.cpp | 1 - plugins/follow.cpp | 31 ++-- plugins/initflags.cpp | 4 +- plugins/jobutils.cpp | 18 +-- plugins/liquids.cpp | 4 +- plugins/plants.cpp | 6 +- plugins/probe.cpp | 7 +- plugins/rename.cpp | 4 +- plugins/reveal.cpp | 3 +- plugins/seedwatch.cpp | 1 - plugins/showmood.cpp | 1 - plugins/stockpiles.cpp | 2 +- plugins/stonesense | 2 +- plugins/tiletypes.cpp | 6 +- plugins/tubefill.cpp | 1 - plugins/vdig.cpp | 13 +- plugins/workflow.cpp | 10 +- 58 files changed, 192 insertions(+), 403 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index aa3a8702d..af44a79ff 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -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(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); diff --git a/library/PluginManager.cpp b/library/PluginManager.cpp index 5d5ef3577..82e53b3f7 100644 --- a/library/PluginManager.cpp +++ b/library/PluginManager.cpp @@ -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; } } diff --git a/library/include/Core.h b/library/include/Core.h index 107dd2fce..a2fa27a5f 100644 --- a/library/include/Core.h +++ b/library/include/Core.h @@ -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; diff --git a/library/include/PluginManager.h b/library/include/PluginManager.h index e59a7f7b3..4fcd80ff0 100644 --- a/library/include/PluginManager.h +++ b/library/include/PluginManager.h @@ -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. diff --git a/library/include/modules/Buildings.h b/library/include/modules/Buildings.h index 10de78bc3..73542450b 100644 --- a/library/include/modules/Buildings.h +++ b/library/include/modules/Buildings.h @@ -35,8 +35,6 @@ distribution. namespace DFHack { -namespace Simple -{ namespace Buildings { /** @@ -86,4 +84,3 @@ DFHACK_EXPORT bool ReadCustomWorkshopTypes(std::map & bt } } -} diff --git a/library/include/modules/Constructions.h b/library/include/modules/Constructions.h index cc9fef2b1..e76cc7ba1 100644 --- a/library/include/modules/Constructions.h +++ b/library/include/modules/Constructions.h @@ -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 diff --git a/library/include/modules/Engravings.h b/library/include/modules/Engravings.h index d52303f32..ea5eae62c 100644 --- a/library/include/modules/Engravings.h +++ b/library/include/modules/Engravings.h @@ -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 diff --git a/library/include/modules/Gui.h b/library/include/modules/Gui.h index 3f2d41dd4..70231ba00 100644 --- a/library/include/modules/Gui.h +++ b/library/include/modules/Gui.h @@ -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 diff --git a/library/include/modules/Items.h b/library/include/modules/Items.h index e2f3a8893..6f10cb49d 100644 --- a/library/include/modules/Items.h +++ b/library/include/modules/Items.h @@ -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 &values); } -} } \ No newline at end of file diff --git a/library/include/modules/MapCache.h b/library/include/modules/MapCache.h index 9b9f92c56..8468f5a0d 100644 --- a/library/include/modules/MapCache.h +++ b/library/include/modules/MapCache.h @@ -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) diff --git a/library/include/modules/Maps.h b/library/include/modules/Maps.h index f86f7888c..d67000048 100644 --- a/library/include/modules/Maps.h +++ b/library/include/modules/Maps.h @@ -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*& plants); -} } } #endif diff --git a/library/include/modules/Translation.h b/library/include/modules/Translation.h index bb6ba6baf..c88f35b89 100644 --- a/library/include/modules/Translation.h +++ b/library/include/modules/Translation.h @@ -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 diff --git a/library/include/modules/Units.h b/library/include/modules/Units.h index d0420eb57..3d491b86e 100644 --- a/library/include/modules/Units.h +++ b/library/include/modules/Units.h @@ -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 diff --git a/library/include/modules/Vegetation.h b/library/include/modules/Vegetation.h index 492c19782..83a192b98 100644 --- a/library/include/modules/Vegetation.h +++ b/library/include/modules/Vegetation.h @@ -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 diff --git a/library/include/modules/Vermin.h b/library/include/modules/Vermin.h index bc04111a5..9f440606b 100644 --- a/library/include/modules/Vermin.h +++ b/library/include/modules/Vermin.h @@ -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 +} diff --git a/library/include/modules/kitchen.h b/library/include/modules/kitchen.h index fab387288..ea9dec14d 100644 --- a/library/include/modules/kitchen.h +++ b/library/include/modules/kitchen.h @@ -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(); } } -} diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 1ef913f27..ec43dc766 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -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" diff --git a/library/modules/Constructions.cpp b/library/modules/Constructions.cpp index ac9057075..8dc81911c 100644 --- a/library/modules/Constructions.cpp +++ b/library/modules/Constructions.cpp @@ -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() diff --git a/library/modules/Engravings.cpp b/library/modules/Engravings.cpp index 9fc2c3adf..3621bc736 100644 --- a/library/modules/Engravings.cpp +++ b/library/modules/Engravings.cpp @@ -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() diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 115508995..ef3e84901 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -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(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(top) || !!strict_virtual_cast(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(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 &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 & 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 & 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 & parameters) if (!parameters.empty()) return CR_WRONG_USAGE; - df::item *item = getSelectedItem(c); + df::item *item = Gui::getSelectedItem(c); if (!item) return CR_FAILURE; diff --git a/plugins/changevein.cpp b/plugins/changevein.cpp index 6b2767d5a..efb045f76 100644 --- a/plugins/changevein.cpp +++ b/plugins/changevein.cpp @@ -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; diff --git a/plugins/cleaners.cpp b/plugins/cleaners.cpp index 42bb9e757..3e5d03767 100644 --- a/plugins/cleaners.cpp +++ b/plugins/cleaners.cpp @@ -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 )); commands.push_back(PluginCommand( "spotclean","Cleans map tile under cursor.", - spotclean,cursor_hotkey + spotclean,Gui::cursor_hotkey )); return CR_OK; } diff --git a/plugins/cleanowned.cpp b/plugins/cleanowned.cpp index 5b6907e59..945fb9754 100644 --- a/plugins/cleanowned.cpp +++ b/plugins/cleanowned.cpp @@ -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; diff --git a/plugins/colonies.cpp b/plugins/colonies.cpp index 6b12f8100..2ba0e7384 100644 --- a/plugins/colonies.cpp +++ b/plugins/colonies.cpp @@ -10,7 +10,6 @@ using std::vector; using std::string; using namespace DFHack; -using namespace DFHack::Simple; command_result colonies (Core * c, vector & parameters); diff --git a/plugins/deramp.cpp b/plugins/deramp.cpp index 14e8d6842..75b99cff6 100644 --- a/plugins/deramp.cpp +++ b/plugins/deramp.cpp @@ -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; diff --git a/plugins/devel/buildprobe.cpp b/plugins/devel/buildprobe.cpp index 223157641..d5e570987 100644 --- a/plugins/devel/buildprobe.cpp +++ b/plugins/devel/buildprobe.cpp @@ -39,7 +39,6 @@ command_result readFlag (Core * c, vector & parameters) { c->Suspend(); - Gui * Gui = c->getGui(); // init the map if(!Maps::IsValid()) { @@ -49,8 +48,7 @@ command_result readFlag (Core * c, vector & 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 & parameters) c->Suspend(); - Gui * Gui = c->getGui(); // init the map if(!Maps::IsValid()) { @@ -116,8 +113,7 @@ command_result writeFlag (Core * c, vector & 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(); diff --git a/plugins/devel/catsplosion.cpp b/plugins/devel/catsplosion.cpp index f6952405d..7c220641e 100644 --- a/plugins/devel/catsplosion.cpp +++ b/plugins/devel/catsplosion.cpp @@ -24,7 +24,6 @@ using namespace std; #include using namespace DFHack; -using namespace DFHack::Simple; command_result catsplosion (Core * c, std::vector & parameters); diff --git a/plugins/devel/frozen.cpp b/plugins/devel/frozen.cpp index 1bcb6f83e..8311cde3d 100644 --- a/plugins/devel/frozen.cpp +++ b/plugins/devel/frozen.cpp @@ -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; diff --git a/plugins/devel/kittens.cpp b/plugins/devel/kittens.cpp index 0135baf74..f2e983e83 100644 --- a/plugins/devel/kittens.cpp +++ b/plugins/devel/kittens.cpp @@ -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 & 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 & parameters) return CR_OK; } +// FIXME: move cursor properly relative to view position command_result zoom (Core * c, vector & parameters) { if(parameters.size() < 3) @@ -159,12 +156,11 @@ command_result zoom (Core * c, vector & 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 & parameters) diff --git a/plugins/devel/tilesieve.cpp b/plugins/devel/tilesieve.cpp index 21bcd0c90..8d663db1c 100644 --- a/plugins/devel/tilesieve.cpp +++ b/plugins/devel/tilesieve.cpp @@ -13,7 +13,6 @@ #include "TileTypes.h" using namespace DFHack; -using namespace DFHack::Simple; using namespace df::enums; using df::global::world; diff --git a/plugins/dwarfexport/dwarfexport.cpp b/plugins/dwarfexport/dwarfexport.cpp index 996f8c98c..6c997ca27 100644 --- a/plugins/dwarfexport/dwarfexport.cpp +++ b/plugins/dwarfexport/dwarfexport.cpp @@ -20,9 +20,6 @@ using namespace std; #include using namespace DFHack; -using namespace DFHack::Simple; -using namespace DFHack::Simple; - using df::global::ui; using df::global::world; diff --git a/plugins/filltraffic.cpp b/plugins/filltraffic.cpp index dc05ecbc4..37d036868 100644 --- a/plugins/filltraffic.cpp +++ b/plugins/filltraffic.cpp @@ -40,7 +40,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector { 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 & 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 & 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"); diff --git a/plugins/fixveins.cpp b/plugins/fixveins.cpp index 3d8d5caea..de6ddf810 100644 --- a/plugins/fixveins.cpp +++ b/plugins/fixveins.cpp @@ -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; diff --git a/plugins/follow.cpp b/plugins/follow.cpp index d13643db5..aa165899e 100644 --- a/plugins/follow.cpp +++ b/plugins/follow.cpp @@ -29,7 +29,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector { 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 & 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; diff --git a/plugins/initflags.cpp b/plugins/initflags.cpp index c9bbe4584..1125b625b 100644 --- a/plugins/initflags.cpp +++ b/plugins/initflags.cpp @@ -23,9 +23,9 @@ DFhackCExport command_result plugin_init (Core *c, std::vector & { 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; diff --git a/plugins/jobutils.cpp b/plugins/jobutils.cpp index 805fc545e..e81414238 100644 --- a/plugins/jobutils.cpp +++ b/plugins/jobutils.cpp @@ -89,7 +89,7 @@ DFhackCExport command_result plugin_init (Core *c, std::vector & 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 & 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 & 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 & 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 & 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; diff --git a/plugins/liquids.cpp b/plugins/liquids.cpp index 139faafcf..9e26a9e9b 100644 --- a/plugins/liquids.cpp +++ b/plugins/liquids.cpp @@ -224,7 +224,6 @@ command_result df_liquids (Core * c, vector & 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 & 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 & 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; diff --git a/plugins/plants.cpp b/plugins/plants.cpp index 8e5d51a75..951ac0a8b 100644 --- a/plugins/plants.cpp +++ b/plugins/plants.cpp @@ -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 * alltrees; if(Maps::ReadVegetation(x/16,y/16,z,alltrees)) @@ -205,9 +204,8 @@ command_result df_grow (Core * c, vector & 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 * alltrees; if(Maps::ReadVegetation(x/16,y/16,z,alltrees)) diff --git a/plugins/probe.cpp b/plugins/probe.cpp index 970a07350..271545bba 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -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 & 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 & parameters) CoreSuspender suspend(c); - DFHack::Gui *Gui = c->getGui(); DFHack::Materials *Materials = c->getMaterials(); DFHack::VersionInfo* mem = c->vinfo; std::vector inorganic; @@ -111,7 +108,7 @@ command_result df_probe (Core * c, vector & 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"); diff --git a/plugins/rename.cpp b/plugins/rename.cpp index 09d737be6..0ff9469de 100644 --- a/plugins/rename.cpp +++ b/plugins/rename.cpp @@ -120,7 +120,7 @@ static command_result rename(Core * c, vector ¶meters) 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 ¶meters) 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; diff --git a/plugins/reveal.cpp b/plugins/reveal.cpp index fd9b65c93..01dcaf89d 100644 --- a/plugins/reveal.cpp +++ b/plugins/reveal.cpp @@ -303,7 +303,6 @@ command_result revflood(DFHack::Core * c, std::vector & 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 & 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"); diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index d5573b400..53a94c665 100755 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -18,7 +18,6 @@ using namespace std; using namespace DFHack; -using namespace DFHack::Simple; using namespace df::enums; using df::global::world; diff --git a/plugins/showmood.cpp b/plugins/showmood.cpp index 6f5b6527c..23a5383ad 100644 --- a/plugins/showmood.cpp +++ b/plugins/showmood.cpp @@ -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; diff --git a/plugins/stockpiles.cpp b/plugins/stockpiles.cpp index 185973364..06b72c0c5 100644 --- a/plugins/stockpiles.cpp +++ b/plugins/stockpiles.cpp @@ -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) { diff --git a/plugins/stonesense b/plugins/stonesense index 58147c313..34183f96b 160000 --- a/plugins/stonesense +++ b/plugins/stonesense @@ -1 +1 @@ -Subproject commit 58147c3138cddc2e732dd537ca8a78782f196f88 +Subproject commit 34183f96b86394895975fb59ae3c4673cd78f502 diff --git a/plugins/tiletypes.cpp b/plugins/tiletypes.cpp index cad4f0666..5b322e95e 100644 --- a/plugins/tiletypes.cpp +++ b/plugins/tiletypes.cpp @@ -656,7 +656,6 @@ command_result df_tiletypes (Core * c, vector & 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 & 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 & 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 & 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; diff --git a/plugins/tubefill.cpp b/plugins/tubefill.cpp index 419c845b7..71216c871 100644 --- a/plugins/tubefill.cpp +++ b/plugins/tubefill.cpp @@ -14,7 +14,6 @@ #include "TileTypes.h" using namespace DFHack; -using namespace DFHack::Simple; using namespace df::enums; using df::global::world; diff --git a/plugins/vdig.cpp b/plugins/vdig.cpp index d283f0357..b350e4574 100644 --- a/plugins/vdig.cpp +++ b/plugins/vdig.cpp @@ -29,13 +29,13 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector { 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 & 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 & 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 & 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 & 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 & 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 & 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"); diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index b93d6f437..a8ace1b02 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -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 & 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];