diff --git a/.travis.yml b/.travis.yml index 3e5677ff7..ad17693a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,12 @@ sudo: false language: cpp +cache: + pip: true + directories: + - $HOME/lua53 addons: apt: packages: &default_packages - - lua5.2 - libxml-libxml-perl - libxml-libxslt-perl - zlib1g-dev:i386 @@ -19,8 +22,10 @@ matrix: - gcc-4.8-multilib - g++-4.8-multilib before_install: - pip install --user "sphinx==1.4" "requests[security]" +- pip install --user "sphinx==1.4" "requests[security]" +- sh travis/build-lua.sh script: +- export PATH="$PATH:$HOME/lua53/bin" - git tag tmp-travis-build - sh travis/git-info.sh - sphinx-build -qW -j3 . docs/html @@ -28,7 +33,7 @@ script: - python travis/lint.py - python travis/authors-rst.py - python travis/script-docs.py -- python travis/script-syntax.py --ext=lua --cmd="luac5.2 -p" || true +- python travis/script-syntax.py --ext=lua --cmd="luac5.3 -p" - python travis/script-syntax.py --ext=rb --cmd="ruby -c" - mkdir build-travis - cd build-travis diff --git a/README.md b/README.md index c3d51c4d1..9ea1ccb04 100644 --- a/README.md +++ b/README.md @@ -15,5 +15,5 @@ If you're an end-user, modder, or interested in contributing to DFHack - go read those docs. If that's unclear or you need more help, try -[the Bay12 forums thread](http://www.bay12forums.com/smf/index.php?topic=139553) +[the Bay12 forums thread](http://www.bay12forums.com/smf/index.php?topic=164123) or the #dfhack IRC channel on freenode. diff --git a/docs/Binpatches.rst b/docs/Binpatches.rst index 53e1455b4..a0fcc6630 100644 --- a/docs/Binpatches.rst +++ b/docs/Binpatches.rst @@ -13,15 +13,14 @@ the `binpatch` command. We recommend using a script or plugin instead of a raw patch if at all possible - that way your work will work for many versions - across multiple operating systems. There's a reason nobody has - written patches since ``0.34.11``! + across multiple operating systems. .. contents:: Getting a patch =============== -There are no binary patches available for Dwarf Fortress versions after 0.34.11 +There are no binary patches available for Dwarf Fortress versions after 0.34.11. This system is kept for the chance that someone will find it useful, so some hints on how to write your own follow. This will require disassembly and @@ -29,7 +28,7 @@ decent skill in `memory research `. * The patches are expected to be encoded in text format used by IDA. -* See :commit:`8a9e3d1a728` for examples. +* See `the patches folder in commit b0e1b51 `_ for examples. * :issue:`546` is about the future of the binpatches, and may be useful reading. diff --git a/docs/Core.rst b/docs/Core.rst index 2c5d1168f..15adcc533 100644 --- a/docs/Core.rst +++ b/docs/Core.rst @@ -104,7 +104,8 @@ of DFhack, rather than plugins or scripts. .. contents:: :local: -.. _cls: + +.. _alias: alias ----- @@ -129,6 +130,9 @@ be passed to the underlying command in order. An example with `devel/print-args` example text + +.. _cls: + cls --- Clear the terminal. Does not delete command history. diff --git a/docs/Plugins.rst b/docs/Plugins.rst index 75e3a8f8e..95d827f71 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -10,7 +10,7 @@ Most commands offered by plugins are listed here, hopefully organised in a way you will find useful. .. contents:: - :depth: 2 + :depth: 3 =============================== Data inspection and visualizers diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 38319dcfc..ca958cfdc 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1486,7 +1486,9 @@ static const LuaWrapper::FunctionReg dfhack_gui_module[] = { WRAPM(Gui, showZoomAnnouncement), WRAPM(Gui, showPopupAnnouncement), WRAPM(Gui, showAutoAnnouncement), + WRAPM(Gui, resetDwarfmodeView), WRAPM(Gui, revealInDwarfmodeMap), + WRAPM(Gui, refreshSidebar), WRAPM(Gui, getDepthAt), { NULL, NULL } }; diff --git a/library/include/modules/Gui.h b/library/include/modules/Gui.h index d3e8497ce..ec5d1ea94 100644 --- a/library/include/modules/Gui.h +++ b/library/include/modules/Gui.h @@ -148,6 +148,7 @@ namespace DFHack DFHACK_EXPORT void resetDwarfmodeView(bool pause = false); DFHACK_EXPORT bool revealInDwarfmodeMap(df::coord pos, bool center = false); + DFHACK_EXPORT bool refreshSidebar(); 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); diff --git a/library/lua/gui/dwarfmode.lua b/library/lua/gui/dwarfmode.lua index 27649bc6e..3764c4df7 100644 --- a/library/lua/gui/dwarfmode.lua +++ b/library/lua/gui/dwarfmode.lua @@ -14,6 +14,8 @@ local world_map = df.global.world.map AREA_MAP_WIDTH = 23 MENU_WIDTH = 30 +refreshSidebar = dfhack.gui.refreshSidebar + function getPanelLayout() local dims = dfhack.gui.getDwarfmodeViewDims() local area_pos = df.global.ui_area_map_width diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index c51d9ea73..a1124323d 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -109,6 +109,10 @@ function Pages:getSelected() return self.selected, self.subviews[self.selected] end +function Pages:getSelectedPage() + return self.subviews[self.selected] +end + ---------------- -- Edit field -- ---------------- diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 611e00205..5b56ee1ed 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -1594,6 +1594,26 @@ bool Gui::revealInDwarfmodeMap(df::coord pos, bool center) return true; } +bool Gui::refreshSidebar() +{ + auto scr = getViewscreenByType(0); + if (scr) + { + if (df::global::window_z && *df::global::window_z == 0) + { + scr->feed_key(interface_key::CURSOR_UP_Z); + scr->feed_key(interface_key::CURSOR_DOWN_Z); + } + else + { + scr->feed_key(interface_key::CURSOR_DOWN_Z); + scr->feed_key(interface_key::CURSOR_UP_Z); + } + return true; + } + return false; +} + bool Gui::getViewCoords (int32_t &x, int32_t &y, int32_t &z) { x = *df::global::window_x; diff --git a/library/xml b/library/xml index 29ba19bf7..3322beb2e 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 29ba19bf7a4bab69854c99135f3a66fcdb2227ed +Subproject commit 3322beb2e7f4b28ff8e573e9bec738c77026b8e9 diff --git a/plugins/automaterial.cpp b/plugins/automaterial.cpp index 2465c6325..cfbc95ae7 100644 --- a/plugins/automaterial.cpp +++ b/plugins/automaterial.cpp @@ -868,8 +868,7 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest void move_cursor(df::coord &pos) { Gui::setCursorCoords(pos.x, pos.y, pos.z); - send_key(interface_key::CURSOR_DOWN_Z); - send_key(interface_key::CURSOR_UP_Z); + Gui::refreshSidebar(); } void move_cursor(coord32_t &pos) diff --git a/plugins/buildingplan.cpp b/plugins/buildingplan.cpp index f72888d00..747e5cfb7 100644 --- a/plugins/buildingplan.cpp +++ b/plugins/buildingplan.cpp @@ -107,8 +107,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest planmode_enabled[type] = !planmode_enabled[type]; if (!planmode_enabled[type]) { - send_key(interface_key::CURSOR_DOWN_Z); - send_key(interface_key::CURSOR_UP_Z); + Gui::refreshSidebar(); planner.in_dummmy_screen = false; } return true; @@ -140,8 +139,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest { if (ui_build_selector->errors.size() == 0 && planner.allocatePlannedBuilding(type)) { - send_key(interface_key::CURSOR_DOWN_Z); - send_key(interface_key::CURSOR_UP_Z); + Gui::refreshSidebar(); if (planner.inQuickFortMode()) { planner.in_dummmy_screen = true; diff --git a/plugins/dwarfmonitor.cpp b/plugins/dwarfmonitor.cpp index 2c78c0854..2ea811f38 100644 --- a/plugins/dwarfmonitor.cpp +++ b/plugins/dwarfmonitor.cpp @@ -147,8 +147,7 @@ static void send_key(const df::interface_key &key) static void move_cursor(df::coord &pos) { Gui::setCursorCoords(pos.x, pos.y, pos.z); - send_key(interface_key::CURSOR_DOWN_Z); - send_key(interface_key::CURSOR_UP_Z); + Gui::refreshSidebar(); } static void open_stats_srceen(); diff --git a/plugins/mousequery.cpp b/plugins/mousequery.cpp index 7f0095c58..7a70f29c4 100644 --- a/plugins/mousequery.cpp +++ b/plugins/mousequery.cpp @@ -507,16 +507,7 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest return; Gui::setCursorCoords(mpos.x, mpos.y, mpos.z); - if (mpos.z == 0) - { - sendKey(interface_key::CURSOR_UP_Z); - sendKey(interface_key::CURSOR_DOWN_Z); - } - else - { - sendKey(interface_key::CURSOR_DOWN_Z); - sendKey(interface_key::CURSOR_UP_Z); - } + Gui::refreshSidebar(); } bool inBuildPlacement() diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index 1d3d04d6f..a5b84672d 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -981,8 +981,7 @@ public: void move_cursor(const df::coord &pos) { Gui::setCursorCoords(pos.x, pos.y, pos.z); - send_key(interface_key::CURSOR_DOWN_Z); - send_key(interface_key::CURSOR_UP_Z); + Gui::refreshSidebar(); } void send_key(const df::interface_key &key) diff --git a/plugins/tweak/tweaks/stable-cursor.h b/plugins/tweak/tweaks/stable-cursor.h index 105510c8b..7b6482d7b 100644 --- a/plugins/tweak/tweaks/stable-cursor.h +++ b/plugins/tweak/tweaks/stable-cursor.h @@ -52,20 +52,7 @@ struct stable_cursor_hook : df::viewscreen_dwarfmodest last_cursor.isValid() && cur_cursor.isValid()) { Gui::setCursorCoords(last_cursor.x, last_cursor.y, last_cursor.z); - - // Force update of ui state - set tmp; - if (last_cursor.z < 2) - tmp.insert(interface_key::CURSOR_UP_Z); - else - tmp.insert(interface_key::CURSOR_DOWN_Z); - INTERPOSE_NEXT(feed)(&tmp); - tmp.clear(); - if (last_cursor.z < 2) - tmp.insert(interface_key::CURSOR_DOWN_Z); - else - tmp.insert(interface_key::CURSOR_UP_Z); - INTERPOSE_NEXT(feed)(&tmp); + Gui::refreshSidebar(); } else if (!is_default && cur_cursor.isValid()) { diff --git a/scripts b/scripts index d461a8417..1ba8f81ca 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit d461a8417260cba96db7028ef0602a787e48274b +Subproject commit 1ba8f81cacefba76bc97a56b2683e2002ee31ff4 diff --git a/travis/build-lua.sh b/travis/build-lua.sh new file mode 100644 index 000000000..e29d7ce87 --- /dev/null +++ b/travis/build-lua.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +set -e + +LUA_ROOT="$HOME/lua53" +LUA_URL="http://www.lua.org/ftp/lua-5.3.3.tar.gz" +LUA_TAR=$(basename "$LUA_URL") +LUA_DIR="$LUA_ROOT/${LUA_TAR%.tar.*}" +LUA_SHA1="a0341bc3d1415b814cc738b2ec01ae56045d64ef" + +echo LUA_ROOT $LUA_ROOT +echo LUA_TAR $LUA_TAR +echo LUA_DIR $LUA_DIR + +sha1() { + python -c 'import hashlib, sys; print(hashlib.sha1(open(sys.argv[1],"rb").read()).hexdigest())' "$1" +} + +download() { + echo "Downloading $LUA_URL" + wget -O "$LUA_ROOT/$LUA_TAR" "$LUA_URL" + tar xvf "$LUA_ROOT/$LUA_TAR" +} + +build() { + cd "$LUA_DIR/src" + make generic +} + +main() { + mkdir -p "$LUA_ROOT" + cd "$LUA_ROOT" + mkdir -p bin + + if [ "$(sha1 "$LUA_ROOT/$LUA_TAR" 2>/dev/null)" != "$LUA_SHA1" ]; then + download + build + else + echo "Already downloaded" + + if [ -x "$LUA_DIR/src/luac" ]; then + echo "Already built" + else + build + fi + fi + + echo "Linking" + ln -sf "$LUA_DIR/src/lua" "$LUA_ROOT/bin/lua5.3" + ln -sf "$LUA_DIR/src/luac" "$LUA_ROOT/bin/luac5.3" + echo "Done" +} + +main