Behavior Mods
@@ -3076,12 +3075,8 @@ Also works when selecting units from the 'u'nitlist viewscreen.
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.
@@ -3113,7 +3108,7 @@ exterminate elve magma
-
+
Instantly grow seeds inside farming plots.
With no argument, this command list the various seed types currently in
use in your farming plots.
@@ -3125,7 +3120,7 @@ growcrops plump 40
-
+
Allow manipulation of in-game levers from the dfhack console.
Can list levers, including state and links, with:
@@ -3139,7 +3134,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).
@@ -3152,7 +3147,7 @@ locate-ore iron
-
+
There are the following ways to invoke this command:
lua (without any parameters)
@@ -3171,14 +3166,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.
@@ -3188,21 +3183,21 @@ multicmd locate-ore iron ; digv
-
+
If 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
@@ -3210,7 +3205,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.
@@ -3219,7 +3214,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.
@@ -3241,7 +3236,7 @@ source add water 0 - water drain
-
+
Similar to fastdwarf, per-creature.
To make any creature superfast, target it ingame using 'v' and:
@@ -3251,7 +3246,7 @@ superdwarf add
This 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
@@ -3269,7 +3264,7 @@ stripcaged weapons 25321 34228
-
+
Teleports a unit to given coordinates.
Examples:
@@ -3279,12 +3274,12 @@ teleport -unit 1234 -x 56 -y 115 -z 26 - teleports unit 1234 to 56,115,26
-
+
Undesignates building base materials for dumping.
-
+
Bind to a key (the example config uses P), and activate when viewing a weapon
rack in the 'q' mode.
![images/assign-rack.png](images/assign-rack.png)
@@ -3524,7 +3519,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
@@ -3535,14 +3530,14 @@ only that entry, and does it even if it is not 'individual choice'.
and may lead to inappropriate weapons being selected.
-
+
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.
![images/companion-order.png](images/companion-order.png)
@@ -3558,7 +3553,7 @@ case. Must be in look or talk mode to issue command on tile.
-
+
There are three ways to open this editor:
- using gui/gm-editor command/keybinding - opens editor on what is selected
@@ -3573,7 +3568,7 @@ the same as version above.
in-game help.
-
+
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
@@ -3583,7 +3578,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
@@ -3592,7 +3587,7 @@ globally active hotkey in dfhack.init, e.g.:
keybinding add Ctrl-F1 hotkeys
-
+
- Enable the autodump plugin in your dfhack.init with
- enable autodump
@@ -3601,7 +3596,7 @@ globally active hotkey in dfhack.init, e.g.:
Any items placed in this stockpile will be designated to be dumped.
-
+
- Enable the automelt plugin in your dfhack.init with
- enable automelt
@@ -3610,7 +3605,7 @@ Any items placed in this stockpile will be designated to be dumped.
Any items placed in this stockpile will be designated to be melted.
-
+
To 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,
@@ -3630,7 +3625,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
@@ -3640,13 +3635,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.
@@ -3669,7 +3664,7 @@ their species string.
unit profession change to Ctrl-Shift-T.
-
+
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.
![images/room-list.png](images/room-list.png)
@@ -3677,7 +3672,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.
![images/guide-path.png](images/guide-path.png)
@@ -3685,7 +3680,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.
![images/workflow.png](images/workflow.png)
@@ -3732,7 +3727,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.
![images/workshop-job.png](images/workshop-job.png)
@@ -3769,7 +3764,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.
@@ -3780,20 +3775,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.
@@ -3816,7 +3811,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
@@ -3827,11 +3822,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
@@ -3842,7 +3837,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.
@@ -3866,7 +3861,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
@@ -3897,7 +3892,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
@@ -3906,7 +3901,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
@@ -3917,7 +3912,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 15933e0f6..d5c1e026b 100644
--- a/Readme.rst
+++ b/Readme.rst
@@ -2273,10 +2273,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.
From c39cf1fb49aee87bd7d2e812a26062b7fe4ee334 Mon Sep 17 00:00:00 2001
From: lethosor
Date: Mon, 5 Jan 2015 19:36:06 -0500
Subject: [PATCH 2/7] Add room assignment search
---
plugins/search.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/plugins/search.cpp b/plugins/search.cpp
index e25343cf7..929cd653c 100644
--- a/plugins/search.cpp
+++ b/plugins/search.cpp
@@ -43,6 +43,9 @@ DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(gview);
REQUIRE_GLOBAL(ui);
+REQUIRE_GLOBAL(ui_building_assign_units);
+REQUIRE_GLOBAL(ui_building_in_assign);
+REQUIRE_GLOBAL(ui_building_item_cursor);
/*
Search Plugin
@@ -1671,6 +1674,68 @@ IMPLEMENT_HOOKS(df::viewscreen_dwarfmodest, burrow_search);
//
+//
+// START: Room assignment search
+//
+
+typedef search_generic room_assign_search_base;
+class room_assign_search : public room_assign_search_base
+{
+public:
+ bool can_init(df::viewscreen_dwarfmodest *screen)
+ {
+ if (ui->main.mode == df::ui_sidebar_mode::QueryBuilding && *ui_building_in_assign)
+ {
+ return room_assign_search_base::can_init(screen);
+ }
+
+ return false;
+ }
+
+ string get_element_description(df::unit *element) const
+ {
+ return element ? get_unit_description(element) : "Nobody";
+ }
+
+ void render() const
+ {
+ auto dims = Gui::getDwarfmodeViewDims();
+ int left_margin = dims.menu_x1 + 1;
+ int x = left_margin;
+ int y = 19;
+
+ print_search_option(x, y);
+ }
+
+ vector *get_primary_list()
+ {
+ return ui_building_assign_units;
+ }
+
+ virtual int32_t * get_viewscreen_cursor()
+ {
+ return ui_building_item_cursor;
+ }
+
+ bool should_check_input(set *input)
+ {
+ if (input->count(interface_key::SECONDSCROLL_UP) || input->count(interface_key::SECONDSCROLL_DOWN)
+ || input->count(interface_key::SECONDSCROLL_PAGEUP) || input->count(interface_key::SECONDSCROLL_PAGEDOWN))
+ {
+ end_entry_mode();
+ return false;
+ }
+
+ return true;
+ }
+};
+
+IMPLEMENT_HOOKS(df::viewscreen_dwarfmodest, room_assign_search);
+
+//
+// END: Room assignment search
+//
+
#define SEARCH_HOOKS \
HOOK_ACTION(unitlist_search_hook) \
HOOK_ACTION(roomlist_search_hook) \
@@ -1684,7 +1749,8 @@ IMPLEMENT_HOOKS(df::viewscreen_dwarfmodest, burrow_search);
HOOK_ACTION(annoucnement_search_hook) \
HOOK_ACTION(joblist_search_hook) \
HOOK_ACTION(burrow_search_hook) \
- HOOK_ACTION(stockpile_search_hook)
+ HOOK_ACTION(stockpile_search_hook) \
+ HOOK_ACTION(room_assign_search_hook)
DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable)
{
From 49990868462bdcdae0ca4080c7d772390a597af6 Mon Sep 17 00:00:00 2001
From: lethosor
Date: Wed, 7 Jan 2015 16:03:24 -0500
Subject: [PATCH 3/7] Use "OSX" in package names on OS X instead of "Darwin"
---
CMakeLists.txt | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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)
From 859fdd60d6c058ae77420c97118543109b5004ba Mon Sep 17 00:00:00 2001
From: lethosor
Date: Thu, 8 Jan 2015 16:59:25 -0500
Subject: [PATCH 4/7] annoucnement -> announcement
---
plugins/search.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/search.cpp b/plugins/search.cpp
index 929cd653c..a1ad442bd 100644
--- a/plugins/search.cpp
+++ b/plugins/search.cpp
@@ -1382,7 +1382,7 @@ IMPLEMENT_HOOKS(df::viewscreen_buildinglistst, roomlist_search);
//
// START: Announcement list search
//
-class annoucnement_search : public search_generic
+class announcement_search : public search_generic
{
public:
void render() const
@@ -1410,7 +1410,7 @@ private:
};
-IMPLEMENT_HOOKS(df::viewscreen_announcelistst, annoucnement_search);
+IMPLEMENT_HOOKS(df::viewscreen_announcelistst, announcement_search);
//
// END: Announcement list search
@@ -1746,7 +1746,7 @@ IMPLEMENT_HOOKS(df::viewscreen_dwarfmodest, room_assign_search);
HOOK_ACTION(military_search_hook) \
HOOK_ACTION(nobles_search_hook) \
HOOK_ACTION(profiles_search_hook) \
- HOOK_ACTION(annoucnement_search_hook) \
+ HOOK_ACTION(announcement_search_hook) \
HOOK_ACTION(joblist_search_hook) \
HOOK_ACTION(burrow_search_hook) \
HOOK_ACTION(stockpile_search_hook) \
From aa332e18e28a803098d74dffc078dfb32593461d Mon Sep 17 00:00:00 2001
From: lethosor
Date: Thu, 8 Jan 2015 16:59:37 -0500
Subject: [PATCH 5/7] Remove stray whitespace
---
plugins/search.cpp | 52 +++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/plugins/search.cpp b/plugins/search.cpp
index a1ad442bd..b4428f049 100644
--- a/plugins/search.cpp
+++ b/plugins/search.cpp
@@ -984,9 +984,9 @@ private:
return desc;
}
- bool should_check_input(set *input)
+ bool should_check_input(set *input)
{
- if (input->count(interface_key::CURSOR_LEFT) || input->count(interface_key::CURSOR_RIGHT) ||
+ if (input->count(interface_key::CURSOR_LEFT) || input->count(interface_key::CURSOR_RIGHT) ||
(!in_entry_mode() && input->count(interface_key::UNITVIEW_PRF_PROF)))
{
if (!in_entry_mode())
@@ -1009,17 +1009,17 @@ private:
return 'q';
}
- vector *get_secondary_list()
+ vector *get_secondary_list()
{
return &viewscreen->jobs[viewscreen->page];
}
- int32_t *get_viewscreen_cursor()
+ int32_t *get_viewscreen_cursor()
{
return &viewscreen->cursor_pos[viewscreen->page];
}
- vector *get_primary_list()
+ vector *get_primary_list()
{
return &viewscreen->units[viewscreen->page];
}
@@ -1092,7 +1092,7 @@ public:
// but the native hotkeys are where we normally write.
return;
}
-
+
print_search_option(2, -1);
if (!search_string.empty())
@@ -1121,7 +1121,7 @@ private:
return &viewscreen->trader_items;
}
- char get_search_select_key()
+ char get_search_select_key()
{
return 'q';
}
@@ -1142,7 +1142,7 @@ public:
// but the native hotkeys are where we normally write.
return;
}
-
+
int32_t x = gps->dimx / 2 + 2;
print_search_option(x, -1);
@@ -1171,7 +1171,7 @@ private:
return &viewscreen->broker_items;
}
- char get_search_select_key()
+ char get_search_select_key()
{
return 'w';
}
@@ -1206,12 +1206,12 @@ public:
print_search_option(51, 23);
}
- vector *get_primary_list()
+ vector *get_primary_list()
{
return &viewscreen->item_names;
}
- vector *get_secondary_list()
+ vector *get_secondary_list()
{
return &viewscreen->item_status;
}
@@ -1260,7 +1260,7 @@ public:
return true;
}
- vector *get_primary_list()
+ vector *get_primary_list()
{
return &viewscreen->positions.candidates;
}
@@ -1273,7 +1273,7 @@ public:
int32_t *cursor = get_viewscreen_cursor();
df::unit *selected_unit = get_primary_list()->at(*cursor);
clear_search();
-
+
for (*cursor = 0; *cursor < get_primary_list()->size(); (*cursor)++)
{
if (get_primary_list()->at(*cursor) == selected_unit)
@@ -1351,21 +1351,21 @@ private:
desc += name;
}
}
-
+
return desc;
}
- vector *get_secondary_list()
+ vector *get_secondary_list()
{
return &viewscreen->room_value;
}
- int32_t *get_viewscreen_cursor()
+ int32_t *get_viewscreen_cursor()
{
return &viewscreen->cursor;
}
- vector *get_primary_list()
+ vector *get_primary_list()
{
return &viewscreen->buildings;
}
@@ -1452,7 +1452,7 @@ public:
return nobles_search_base::can_init(screen);
}
- vector *get_primary_list()
+ vector *get_primary_list()
{
return &viewscreen->candidates;
}
@@ -1482,7 +1482,7 @@ public:
print_search_option(2, 23);
}
- vector *get_primary_list()
+ vector *get_primary_list()
{
return &viewscreen->workers;
}
@@ -1509,7 +1509,7 @@ void get_job_details(string &desc, df::job *job)
desc += c;
}
desc += ".";
-
+
df::item_type itype = ENUM_ATTR(job_type, item, job->job_type);
MaterialInfo mat(job);
@@ -1582,17 +1582,17 @@ private:
return 'q';
}
- vector *get_secondary_list()
+ vector *get_secondary_list()
{
return &viewscreen->units;
}
- int32_t *get_viewscreen_cursor()
+ int32_t *get_viewscreen_cursor()
{
return &viewscreen->cursor_pos;
}
- vector *get_primary_list()
+ vector *get_primary_list()
{
return &viewscreen->jobs;
}
@@ -1638,17 +1638,17 @@ public:
print_search_option(x, y);
}
- vector *get_primary_list()
+ vector *get_primary_list()
{
return &ui->burrows.list_units;
}
- vector *get_secondary_list()
+ vector *get_secondary_list()
{
return &ui->burrows.sel_units;
}
- virtual int32_t * get_viewscreen_cursor()
+ virtual int32_t * get_viewscreen_cursor()
{
return &ui->burrows.unit_cursor_pos;
}
From 077d149d645c249f0317fe2b2e42de7f3783e9ee Mon Sep 17 00:00:00 2001
From: lethosor
Date: Sun, 11 Jan 2015 12:48:52 -0500
Subject: [PATCH 6/7] Expose key modifier state to C++/Lua
---
library/Core.cpp | 31 ++++++++++++++-----------------
library/LuaApi.cpp | 19 +++++++++++++++++++
library/include/Core.h | 6 ++++++
3 files changed, 39 insertions(+), 17 deletions(-)
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 ListKeyBindings(std::string keyspec);
+ int8_t getModstate() { return modstate; }
std::string getHackPath();
@@ -216,6 +221,7 @@ namespace DFHack
std::string cmdline;
std::string focus;
};
+ int8_t modstate;
std::map > key_bindings;
std::map hotkey_states;
From e20808b6f6b4bc4bd2f6e80e2a84dc2039961643 Mon Sep 17 00:00:00 2001
From: Lethosor
Date: Sun, 11 Jan 2015 13:53:51 -0500
Subject: [PATCH 7/7] Allow `dfhack` script to be run from other directories on
OS X
---
package/darwin/dfhack | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/darwin/dfhack b/package/darwin/dfhack
index 55aa81a98..8040a837a 100755
--- a/package/darwin/dfhack
+++ b/package/darwin/dfhack
@@ -1,5 +1,6 @@
#!/bin/sh
PWD=`dirname "${0}"`
+cd "${PWD}"
#thanks to Iriel for figuring this out
OSREV=`uname -r | cut -d. -f1`
if [ "$OSREV" -ge 11 ] ; then
@@ -11,7 +12,6 @@ else
fi
old_tty_settings=$(stty -g)
-cd "${PWD}"
DYLD_INSERT_LIBRARIES=./hack/libdfhack.dylib ./dwarfort.exe "$@"
stty "$old_tty_settings"
echo ""