diff --git a/CMakeLists.txt b/CMakeLists.txt index 984bb09e7..a01129418 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,5 +188,10 @@ ELSEIF(WIN32) SET(CPACK_GENERATOR "ZIP") ENDIF() set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) -set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${CMAKE_SYSTEM_NAME}") +IF(APPLE) + set(DFHACK_PACKAGE_PLATFORM_NAME OSX) +ELSE() + set(DFHACK_PACKAGE_PLATFORM_NAME ${CMAKE_SYSTEM_NAME}) +ENDIF() +set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_PACKAGE_PLATFORM_NAME}") INCLUDE(CPack) diff --git a/Readme.html b/Readme.html index 558c2a662..ca81c56f8 100644 --- a/Readme.html +++ b/Readme.html @@ -533,69 +533,68 @@ access DF memory and allow for easier development of new tools.
Show a quick overview of critical stock quantities, including food, dirnks, wood, and various bars.
-Allows to embark anywhere. Currently windows only.
-Kills any unit of a given race.
With no argument, lists the available races and count eligible targets.
With the special argument him, targets only the selected creature.
@@ -3121,7 +3116,7 @@ exterminate elve magmaInstantly grow seeds inside farming plots.
With no argument, this command list the various seed types currently in use in your farming plots. @@ -3133,7 +3128,7 @@ growcrops plump 40
Allow manipulation of in-game levers from the dfhack console.
Can list levers, including state and links, with:
@@ -3147,7 +3142,7 @@ lever pull 42 --now
Scan the map for metal ores.
Finds and designate for digging one tile of a specific metal ore. Only works for native metal ores, does not handle reaction stuff (eg STEEL).
@@ -3160,7 +3155,7 @@ locate-ore ironThere are the following ways to invoke this command:
lua (without any parameters)
@@ -3179,14 +3174,14 @@ directory. If the filename is not supplied, it loads "dfhack.lua".Designate all creatures in cages on top of a pit/pond activity zone for pitting. Works best with an animal stockpile on top of the zone.
Works with a zone number as argument (eg Activity Zone #6 -> masspit 6) or with the game cursor on top of the area.
Run multiple dfhack commands. The argument is split around the character ; and all parts are run sequencially as independent dfhack commands. Useful for hotkeys.
@@ -3196,21 +3191,21 @@ multicmd locate-ore iron ; digvIf called in dwarf mode, makes DF immediately auto-save the game by setting a flag normally used in seasonal auto-save.
Sets stress to -1,000,000; the normal range is 0 to 500,000 with very stable or very stressed dwarves taking on negative or greater values respectively. Applies to the selected unit, or use "remove-stress -all" to apply to all units.
Run setfps <number> to set the FPS cap at runtime, in case you want to watch combat in slow motion or something :)
Wakes up sleeping units, cancels breaks and stops parties either everywhere, or in the burrows given as arguments. In return, adds bad thoughts about noise, tiredness and lack of protection. Also, the units with interrupted @@ -3218,7 +3213,7 @@ breaks will go on break again a lot sooner. The script is intended for emergencies, e.g. when a siege appears, and all your military is partying.
It is a well known issue that Soundsense cannot detect the correct current season when a savegame is loaded and has to play random season music until a season switch occurs.
@@ -3227,7 +3222,7 @@ to gamelog.txt on every map load to fix this. For best results call the script from dfhack.init.Create an infinite magma or water source or drain on a tile.
This script registers a map tile as a liquid source, and every 12 game ticks that tile receives or remove 1 new unit of flow based on the configuration.
@@ -3249,7 +3244,7 @@ source add water 0 - water drainSimilar to fastdwarf, per-creature.
To make any creature superfast, target it ingame using 'v' and:
@@ -3259,7 +3254,7 @@ superdwarf addThis plugin also shortens the 'sleeping' and 'on break' periods of targets.
For dumping items inside cages. Will mark selected items for dumping, then a dwarf may come and actually dump it. See also autodump.
With the items argument, only dumps items laying in the cage, excluding @@ -3277,7 +3272,7 @@ stripcaged weapons 25321 34228
Teleports a unit to given coordinates.
Examples:
@@ -3287,12 +3282,12 @@ teleport -unit 1234 -x 56 -y 115 -z 26 - teleports unit 1234 to 56,115,26
These scripts are mostly useful for raw modders and scripters. They all have standard arguments: arguments are of the form tool -argName1 argVal1 -argName2 argVal2. This is equivalent to tool -argName2 argVal2 -argName1 argVal1. It is not necessary to provide a value to an argument name: tool -argName3 is fine. Supplying the same argument name multiple times will result in an error. Argument names are preceded with a dash. The -help argument will print a descriptive usage string describing the nature of the arguments. For multiple word argument values, brackets must be used: tool -argName4 [ sadf1 sadf2 sadf3 ]. In order to allow passing literal braces as part of the argument, backslashes are used: tool -argName4 [ \] asdf \foo ] sets argName4 to \] asdf foo. The *-trigger scripts have a similar policy with backslashes.
add-syndrome
@@ -3349,7 +3344,7 @@ teleport -unit 1234 -x 56 -y 115 -z 26 - teleports unit 1234 to 56,115,26These tools work by displaying dialogs or overlays in the game window, and are mostly implemented by lua scripts.
Implemented by the 'manipulator' plugin.
To activate, open the unit screen and press 'l'.
 @@ -3405,7 +3400,7 @@ cursor onto that cell instead of toggling it.
 directly to the main dwarf mode screen.
@@ -3405,7 +3400,7 @@ cursor onto that cell instead of toggling it.
 directly to the main dwarf mode screen.
 Implemented by the 'search' plugin.
The search plugin adds search to the Stocks, Animals, Trading, Stockpile, Noble (assignment candidates), Military (position candidates), Burrows @@ -3436,7 +3431,7 @@ only fat or tallow by forbidding fats, then searching for fat/tallow, and using Permit Fats again while the list is filtered.
Implemented by the 'automaterial' plugin.
This makes building constructions (walls, floors, fortifications, etc) a little bit easier by saving you from having to trawl through long lists of materials each time @@ -3464,7 +3459,7 @@ materials, it returns you back to this screen. If you use this along with severa enabled materials, you should be able to place complex constructions more conveniently.
Enable the automelt or autotrade plugins in your dfhack.init with:
enable automelt @@ -3475,7 +3470,7 @@ When automelt is enabled for a stockpile, any meltable items placed in it will b When autotrade is enabled for a stockpile, any items placed in it will be designated to be taken to the Trade Depot whenever merchants are on the map.
This script allows to perform jobs in adventure mode. For more complete help press '?' while script is running. It's most confortable to use this as a keybinding. (e.g. keybinding set Ctrl-T gui/advfort). Possible arguments:
@@ -3508,7 +3503,7 @@ implies -aBind to a key (the example config uses P), and activate when viewing a weapon rack in the 'q' mode.
 @@ -3532,7 +3527,7 @@ the intended user. In order to aid in the choice, it shows the number
 of currently assigned racks for every valid squad.
@@ -3532,7 +3527,7 @@ the intended user. In order to aid in the choice, it shows the number
 of currently assigned racks for every valid squad.
 Bind to a key (the example config uses Ctrl-W), and activate in the Equip->View/Customize page of the military screen.
Depending on the cursor location, it rewrites all 'individual choice weapon' entries @@ -3543,14 +3538,14 @@ only that entry, and does it even if it is not 'individual choice'.
and may lead to inappropriate weapons being selected.Bind to a key (the example config uses Ctrl-C), and activate in the Uniforms page of the military screen with the cursor in the leftmost list.
When invoked, the script duplicates the currently selected uniform template, and selects the newly created copy.
A script to issue orders for companions. Select companions with lower case chars, issue orders with upper case. Must be in look or talk mode to issue command on tile.
 @@ -3566,7 +3561,7 @@ case. Must be in look or talk mode to issue command on tile.
@@ -3566,7 +3561,7 @@ case. Must be in look or talk mode to issue command on tile.
 
 There are three ways to open this editor:
Opens an in-game screen showing DFHack keybindings that are valid in the current mode.
 
 Type hotkeys into the DFHack console to open the screen, or bind the command to a @@ -3591,7 +3586,7 @@ keybinding add Ctrl-F1 hotkeys
Opens an in-game screen showing DFHack keybindings that are valid in the current mode.
 
 Type hotkeys into the DFHack console to open the screen, or bind the command to a @@ -3600,7 +3595,7 @@ globally active hotkey in dfhack.init, e.g.:
keybinding add Ctrl-F1 hotkeysTo use, bind to a key (the example config uses Alt-L) and activate in the 'k' mode.
 
 This script is a gui front-end to the liquids plugin and works similar to it, @@ -3638,7 +3633,7 @@ rivers power water wheels even when full and technically not flowing.
After setting up the desired operations using the described keys, use Enter to apply them.
To use, bind to a key (the example config uses Ctrl-M) and activate in the 'q' mode.
 
 Lists mechanisms connected to the building, and their links. Navigating the list centers @@ -3648,13 +3643,13 @@ focus on the current one. Shift-Enter has an effect equivalent to pressing Enter re-entering the mechanisms ui.
A way to simply install and remove small mods. It looks for specially formatted mods in df subfolder 'mods'. Mods are not included, for example mods see: github mini mod repository
 
 Backed by the rename plugin, this script allows entering the desired name via a simple dialog in the game ui.
To use, bind to a key (the example config uses Alt-R) and activate in the 'q' mode, either immediately or after opening the assign owner page.
 @@ -3685,7 +3680,7 @@ either immediately or after opening the assign owner page.
 list, and allows unassigning them.
@@ -3685,7 +3680,7 @@ either immediately or after opening the assign owner page.
 list, and allows unassigning them.
 Bind to a key (the example config uses Alt-P), and activate in the Hauling menu with the cursor over a Guide order.
 @@ -3693,7 +3688,7 @@ the cursor over a Guide order.
 computes it when the order is executed for the first time.
@@ -3693,7 +3688,7 @@ the cursor over a Guide order.
 computes it when the order is executed for the first time.
 Bind to a key (the example config uses Alt-W), and activate with a job selected in a workshop in the 'q' mode.
 @@ -3740,7 +3735,7 @@ the current stock value. The bright green dashed line is the target
 limit (maximum) and the dark green line is that minus the gap (minimum).
@@ -3740,7 +3735,7 @@ the current stock value. The bright green dashed line is the target
 limit (maximum) and the dark green line is that minus the gap (minimum).
 Bind to a key (the example config uses Alt-A), and activate with a job selected in a workshop in the 'q' mode.
 @@ -3777,7 +3772,7 @@ you have to unset the material first.
@@ -3777,7 +3772,7 @@ you have to unset the material first.
 These plugins, when activated via configuration UI or by detecting certain structures in RAWs, modify the game engine behavior concerning the target objects to add features not otherwise present.
@@ -3788,20 +3783,20 @@ technical challenge, and do not represent any long-term plans to produce more similar modifications of the game.The siege-engine plugin enables siege engines to be linked to stockpiles, and aimed at an arbitrary rectangular area across Z levels, instead of the original four directions. Also, catapults can be ordered to load arbitrary objects, not just stones.
Siege engines are a very interesting feature, but sadly almost useless in the current state because they haven't been updated since 2D and can only aim in four directions. This is an attempt to bring them more up to date until Toady has time to work on it. Actual improvements, e.g. like making siegers bring their own, are something only Toady can do.
The configuration front-end to the plugin is implemented by the gui/siege-engine script. Bind it to a key (the example config uses Alt-A) and activate after selecting a siege engine in 'q' mode.
@@ -3824,7 +3819,7 @@ menu.The power-meter plugin implements a modified pressure plate that detects power being supplied to gear boxes built in the four adjacent N/S/W/E tiles.
The configuration front-end is implemented by the gui/power-meter script. Bind it to a @@ -3835,11 +3830,11 @@ in the build menu.
configuration page, but configures parameters relevant to the modded power meter building.The steam-engine plugin detects custom workshops with STEAM_ENGINE in their token, and turns them into real steam engines.
The vanilla game contains only water wheels and windmills as sources of power, but windmills give relatively little power, and water wheels require flowing water, which must either be a real river and thus immovable and @@ -3850,7 +3845,7 @@ it can be done just by combining existing features of the game engine in a new way with some glue code and a bit of custom logic.
The workshop needs water as its input, which it takes via a passable floor tile below it, like usual magma workshops do. The magma version also needs magma.
@@ -3874,7 +3869,7 @@ short axles that can be built later than both of the engines.In order to operate the engine, queue the Stoke Boiler job (optionally on repeat). A furnace operator will come, possibly bringing a bar of fuel, and perform it. As a result, a "boiling water" item will appear @@ -3905,7 +3900,7 @@ decrease it by further 4%, and also decrease the whole steam use rate by 10%.
The engine must be constructed using barrel, pipe and piston from fire-safe, or in the magma version magma-safe metals.
During operation weak parts get gradually worn out, and @@ -3914,7 +3909,7 @@ toppled during operation by a building destroyer, or a tantruming dwarf.
It should be safe to load and view engine-using fortresses from a DF version without DFHack installed, except that in such case the engines won't work. However actually making modifications @@ -3925,7 +3920,7 @@ being generated.
This plugin makes reactions with names starting with SPATTER_ADD_
 produce contaminants on the items instead of improvements. The produced
 contaminants are immune to being washed away by water or destroyed by
diff --git a/Readme.rst b/Readme.rst
index 609a98dcd..bea371065 100644
--- a/Readme.rst
+++ b/Readme.rst
@@ -2291,10 +2291,6 @@ dfstatus
 ========
 Show a quick overview of critical stock quantities, including food, dirnks, wood, and various bars.
 
-embark
-======
-Allows to embark anywhere. Currently windows only.
-
 exterminate
 ===========
 Kills any unit of a given race.
diff --git a/library/Core.cpp b/library/Core.cpp
index 19e2c4345..452c294e3 100644
--- a/library/Core.cpp
+++ b/library/Core.cpp
@@ -714,7 +714,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve
                 std::string keystr = parts[1];
                 if (parts[0] == "set")
                     ClearKeyBindings(keystr);
-                for (int i = parts.size()-1; i >= 2; i--) 
+                for (int i = parts.size()-1; i >= 2; i--)
                 {
                     if (!AddKeyBinding(keystr, parts[i])) {
                         con.printerr("Invalid key spec: %s\n", keystr.c_str());
@@ -910,7 +910,7 @@ void fIOthread(void * iodata)
             main_history.add(command);
             main_history.save("dfhack.history");
         }
-        
+
         auto rv = core->runCommand(con, command);
 
         if (rv == CR_NOT_IMPLEMENTED)
@@ -1091,6 +1091,7 @@ bool Core::Init()
     screen_window = new Windows::top_level_window();
     screen_window->addChild(new Windows::dfhack_dummy(5,10));
     started = true;
+    modstate = 0;
 
     cerr << "Starting the TCP listener.\n";
     server = new ServerMain();
@@ -1579,7 +1580,7 @@ int UnicodeAwareSym(const SDL::KeyboardEvent& ke)
 //MEMO: return false if event is consumed
 int Core::DFH_SDL_Event(SDL::Event* ev)
 {
-    static bool alt = 0;
+    //static bool alt = 0;
 
     // do NOT process events before we are ready.
     if(!started) return true;
@@ -1589,31 +1590,27 @@ int Core::DFH_SDL_Event(SDL::Event* ev)
     {
         auto ke = (SDL::KeyboardEvent *)ev;
 
-        if (ke->ksym.sym == SDL::K_LALT || ke->ksym.sym == SDL::K_RALT)
-        {
-            alt = (ev->type == SDL::ET_KEYDOWN);
-        }
-        else
-        if(ke->state == SDL::BTN_PRESSED && !hotkey_states[ke->ksym.sym])
+        if (ke->ksym.sym == SDL::K_LSHIFT || ke->ksym.sym == SDL::K_RSHIFT)
+            modstate = (ev->type == SDL::ET_KEYDOWN) ? modstate | MOD_SHIFT : modstate & ~MOD_SHIFT;
+        else if (ke->ksym.sym == SDL::K_LCTRL || ke->ksym.sym == SDL::K_RCTRL)
+            modstate = (ev->type == SDL::ET_KEYDOWN) ? modstate | MOD_CTRL : modstate & ~MOD_CTRL;
+        else if (ke->ksym.sym == SDL::K_LALT || ke->ksym.sym == SDL::K_RALT)
+            modstate = (ev->type == SDL::ET_KEYDOWN) ? modstate | MOD_ALT : modstate & ~MOD_ALT;
+        else if(ke->state == SDL::BTN_PRESSED && !hotkey_states[ke->ksym.sym])
         {
             hotkey_states[ke->ksym.sym] = true;
 
-            int mod = 0;
-            if (ke->ksym.mod & SDL::KMOD_SHIFT) mod |= 1;
-            if (ke->ksym.mod & SDL::KMOD_CTRL) mod |= 2;
-            if (alt) mod |= 4;
-
             // Use unicode so Windows gives the correct value for the
             // user's Input Language
             if((ke->ksym.unicode & 0xff80) == 0)
             {
                 int key = UnicodeAwareSym(*ke);
-                SelectHotkey(key, mod);
+                SelectHotkey(key, modstate);
             }
             else
             {
                 // Pretend non-ascii characters don't happen:
-                SelectHotkey(ke->ksym.sym, mod);
+                SelectHotkey(ke->ksym.sym, modstate);
             }
         }
         else if(ke->state == SDL::BTN_RELEASED)
@@ -1710,7 +1707,7 @@ static bool parseKeySpec(std::string keyspec, int *psym, int *pmod, std::string
         } else if (keyspec.size() > 4 && keyspec.substr(0, 4) == "Alt-") {
             *pmod |= 4;
             keyspec = keyspec.substr(4);
-        } else 
+        } else
             break;
     }
 
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp
index f2693363a..f9b19b102 100644
--- a/library/LuaApi.cpp
+++ b/library/LuaApi.cpp
@@ -2008,10 +2008,12 @@ static void *checkaddr(lua_State *L, int idx, bool allow_null = false)
 
 static uint32_t getImageBase() { return Core::getInstance().p->getBase(); }
 static int getRebaseDelta() { return Core::getInstance().vinfo->getRebaseDelta(); }
+static int8_t getModstate() { return Core::getInstance().getModstate(); }
 
 static const LuaWrapper::FunctionReg dfhack_internal_module[] = {
     WRAP(getImageBase),
     WRAP(getRebaseDelta),
+    WRAP(getModstate),
     { NULL, NULL }
 };
 
@@ -2351,6 +2353,22 @@ static int internal_runCommand(lua_State *L)
     return 1;
 }
 
+static int internal_getModifiers(lua_State *L)
+{
+    int8_t modstate = Core::getInstance().getModstate();
+    lua_newtable(L);
+    lua_pushstring(L, "shift");
+    lua_pushboolean(L, modstate & MOD_SHIFT);
+    lua_settable(L, -3);
+    lua_pushstring(L, "ctrl");
+    lua_pushboolean(L, modstate & MOD_CTRL);
+    lua_settable(L, -3);
+    lua_pushstring(L, "alt");
+    lua_pushboolean(L, modstate & MOD_ALT);
+    lua_settable(L, -3);
+    return 1;
+}
+
 static const luaL_Reg dfhack_internal_funcs[] = {
     { "getAddress", internal_getAddress },
     { "setAddress", internal_setAddress },
@@ -2365,6 +2383,7 @@ static const luaL_Reg dfhack_internal_funcs[] = {
     { "diffscan", internal_diffscan },
     { "getDir", internal_getDir },
     { "runCommand", internal_runCommand },
+    { "getModifiers", internal_getModifiers },
     { NULL, NULL }
 };
 
diff --git a/library/include/Core.h b/library/include/Core.h
index b3db50c74..f3166496a 100644
--- a/library/include/Core.h
+++ b/library/include/Core.h
@@ -36,6 +36,10 @@ distribution.
 
 #include "RemoteClient.h"
 
+#define MOD_SHIFT 1
+#define MOD_CTRL 2
+#define MOD_ALT 4
+
 struct WINDOW;
 
 namespace tthread
@@ -142,6 +146,7 @@ namespace DFHack
         bool ClearKeyBindings(std::string keyspec);
         bool AddKeyBinding(std::string keyspec, std::string cmdline);
         std::vector