From 055c2a222e632d61d282736fc13b60b4adb91352 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Mon, 19 Jun 2023 07:14:18 +0000 Subject: [PATCH 01/44] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index 04e3165b0..f4c1b85d2 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 04e3165b025353219e12a8b2531907c43fb5cdb9 +Subproject commit f4c1b85d22104b69677f9a44cdf044154bcf72c4 From b571e5b52b3af7ba6b0125d7a51b26dd5de01181 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 19 Jun 2023 16:48:07 -0700 Subject: [PATCH 02/44] don't diplay orders overlay on subscreens --- docs/changelog.txt | 1 + library/modules/Gui.cpp | 6 ++++++ plugins/lua/orders.lua | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 839a593a7..14b47663a 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -44,6 +44,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Misc Improvements - `autonick`: additional nicknames based on burrowing animals, colours, gems, and minerals - `stockpiles`: added ``barrels``, ``organic``, ``artifacts``, and ``masterworks`` stockpile presets +- `orders`: only display import/export/sort/clear panel on main orders screen - Blueprint library: dreamfort: full rewrite and update for DF v50 - Blueprint library: pump_stack: updated walkthrough and separated dig and channel steps so boulders can be cleared - Blueprint library: aquifer_tap: updated walkthrough diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index d03bcce09..09c3887cb 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -200,6 +200,12 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) case df::enums::info_interface_mode_type::JUSTICE: newFocusString += "/" + enum_item_key(game->main_interface.info.justice.current_mode); break; + case df::enums::info_interface_mode_type::WORK_ORDERS: + if (game->main_interface.info.work_orders.conditions.open) + newFocusString += "/Conditions"; + else + newFocusString += "/Default"; + break; default: break; } diff --git a/plugins/lua/orders.lua b/plugins/lua/orders.lua index 50197fce4..7a87e529f 100644 --- a/plugins/lua/orders.lua +++ b/plugins/lua/orders.lua @@ -66,7 +66,7 @@ OrdersOverlay = defclass(OrdersOverlay, overlay.OverlayWidget) OrdersOverlay.ATTRS{ default_pos={x=53,y=-6}, default_enabled=true, - viewscreens='dwarfmode/Info/WORK_ORDERS', + viewscreens='dwarfmode/Info/WORK_ORDERS/Default', frame={w=30, h=4}, } @@ -142,6 +142,7 @@ function OrdersOverlay:init() end function OrdersOverlay:onInput(keys) + if df.global.game.main_interface.job_details.open then return end if keys.CUSTOM_ALT_M then self.minimized = not self.minimized return true @@ -151,6 +152,11 @@ function OrdersOverlay:onInput(keys) end end +function OrdersOverlay:render(dc) + if df.global.game.main_interface.job_details.open then return end + OrdersOverlay.super.render(self, dc) +end + OVERLAY_WIDGETS = { overlay=OrdersOverlay, } From afa113645e6a4d2a4b50d9c7878ab313ec1f82c5 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:10:54 +0000 Subject: [PATCH 03/44] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index f4c1b85d2..e9abfb95b 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit f4c1b85d22104b69677f9a44cdf044154bcf72c4 +Subproject commit e9abfb95ba16702ef08c4bc16e86d5f54c055b02 From 5a90a04a8eb3f95ee560a335395b8c03cc22f9c1 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Wed, 21 Jun 2023 02:00:06 -0700 Subject: [PATCH 04/44] handle obsidian --- docs/changelog.txt | 1 + plugins/dig-now.cpp | 42 ++++++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 14b47663a..3300bd0c1 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -49,6 +49,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - Blueprint library: pump_stack: updated walkthrough and separated dig and channel steps so boulders can be cleared - Blueprint library: aquifer_tap: updated walkthrough - `orders`: better order conditions for the ``smelting`` library orders to reduce cancellation spam +- `dig-now`: can now handle digging obsidian that has been formed from magma and water ## Documentation - `blueprint-library-guide`: update Dreamfort screenshots, add ``aquifer_tap`` screenshot diff --git a/plugins/dig-now.cpp b/plugins/dig-now.cpp index 94d8c761f..1cd56255b 100644 --- a/plugins/dig-now.cpp +++ b/plugins/dig-now.cpp @@ -388,21 +388,37 @@ struct dug_tile_info { df::tiletype tt = map.tiletypeAt(pos); tmat = tileMaterial(tt); + itype = df::item_type::BOULDER; + imat = -1; + + df::tiletype_shape shape = tileShape(tt); + if (shape == df::tiletype_shape::WALL || shape == df::tiletype_shape::FORTIFICATION) { + switch (tmat) { + case df::tiletype_material::STONE: + case df::tiletype_material::MINERAL: + case df::tiletype_material::FEATURE: + imat = map.baseMaterialAt(pos).mat_index; + break; + case df::tiletype_material::LAVA_STONE: + { + MaterialInfo mi; + if (mi.findInorganic("OBSIDIAN")) + imat = mi.index; + return; // itype should always be BOULDER, regardless of vein + } + default: + break; + } + } + switch (map.BlockAtTile(pos)->veinTypeAt(pos)) { case df::inclusion_type::CLUSTER_ONE: case df::inclusion_type::CLUSTER_SMALL: itype = df::item_type::ROUGH; break; default: - itype = df::item_type::BOULDER; + break; } - - imat = -1; - if (tileShape(tt) == df::tiletype_shape::WALL - && (tmat == df::tiletype_material::STONE - || tmat == df::tiletype_material::MINERAL - || tmat == df::tiletype_material::FEATURE)) - imat = map.baseMaterialAt(pos).mat_index; } }; @@ -415,7 +431,6 @@ static bool is_diggable(MapExtras::MapCache &map, const DFCoord &pos, case df::tiletype_material::RIVER: case df::tiletype_material::TREE: case df::tiletype_material::ROOT: - case df::tiletype_material::LAVA_STONE: case df::tiletype_material::MAGMA: case df::tiletype_material::HFS: case df::tiletype_material::UNDERWORLD_GATE: @@ -444,15 +459,6 @@ static bool dig_tile(color_ostream &out, MapExtras::MapCache &map, return false; } - /** The algorithm process seems to be: - * for each tile - * check for a designation - * if a designation exists send it to dig_tile - * - * dig_tile (below) then digs the layer below the channel designated tile - * thereby changing it and causing its designation to be lost - * */ - df::tiletype target_type = df::tiletype::Void; switch(designation) { case df::tile_dig_designation::Default: From d77ea845dd2ed38880da54b20c15057e7916a171 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Wed, 21 Jun 2023 11:55:21 -0700 Subject: [PATCH 05/44] pasture male birds near nestboxes so they can fetilize the eggs --- data/blueprints/dreamfort.csv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/blueprints/dreamfort.csv b/data/blueprints/dreamfort.csv index 4df30dc26..93cb4e3f7 100644 --- a/data/blueprints/dreamfort.csv +++ b/data/blueprints/dreamfort.csv @@ -250,7 +250,7 @@ Features: - A grid of small farm plots for lucrative surface farming "" Manual steps you have to take: -- Assign grazing livestock to the large pasture and dogs to the pasture over the central stairs (DFHack's autonestbox can manage the nestbox zones) +"- Assign grazing livestock to the large pasture, dogs to the pasture over the central stairs, and male birds to the zone between the rows of nestboxes (DFHack's autonestbox will auto-assign the female egg-laying birds to the nestbox zones)" - Connect levers to the drawbridges that match the names of the levers - Assign minecarts to the trade goods and prisoner processing quantum stockpile hauling routes with assign-minecarts all "" @@ -412,7 +412,7 @@ corridor_traps/surface_corridor_traps -#zone label(surface_zones) start(19; 19) hidden() message(Remember to assign your dogs to the pasture surrounding the central stairs and your grazing animals to the large pasture.) pastures and training areas +"#zone label(surface_zones) start(19; 19) hidden() message(Remember to assign your dogs to the pasture surrounding the central stairs, your grazing animals to the large pasture, and your male birds to the zone between the rows of nestboxes.) pastures and training areas" @@ -430,7 +430,7 @@ corridor_traps/surface_corridor_traps ,,,`,,`,,,,,,,,,,,,,,,,,,,,,,,,,,`,,` ,,,`,,`,`,`,`,`,`,`,`,`,`,`,`,,`,,`,`,`,`,`,`,`,`,`,`,`,`,,` ,,,`,,`,,`,"n{name=""Nestbox 1""}(1x1)","n{name=""Nestbox 2""}(1x1)","n{name=""Nestbox 3""}(1x1)","n{name=""Nestbox 4""}(1x1)","n{name=""Nestbox 5""}(1x1)","n{name=""Nestbox 6""}(1x1)","n{name=""Nestbox 7""}(1x1)",`,,,,,,`,,,,,,,,,,`,,` -,,,`,,`,,`,,,,,,,,,"n/guarddogs{name=""Guard dogs""}(5x1)",~,~,~,~,,,,,,,,,,,`,,` +,,,`,,`,,`,"n{name=""Male birds""}(7x3)",,,,,,,,"n/guarddogs{name=""Guard dogs""}(5x1)",~,~,~,~,,,,,,,,,,,`,,` ,,,`,,`,,,,,,,,,,`,,`,~,`,,`,,,,,,,,,,`,,` ,,,`,,`,,`,,,,,,,,,n/guarddogs(5x1),~,~,~,~,,,,,,,,,,,`,,` ,,,`,,`,,`,"n{name=""Nestbox 8""}(1x1)","n{name=""Nestbox 9""}(1x1)","n{name=""Nestbox 10""}(1x1)","n{name=""Nestbox 11""}(1x1)","n{name=""Nestbox 12""}(1x1)","n{name=""Nestbox 13""}(1x1)","n{name=""Nestbox 14""}(1x1)",`,,,,,,`,,,,,,,,,,`,,` @@ -1686,7 +1686,7 @@ build2/industry_build2 ,,w,`,`,`,`,`,`,`,`,`,`,`,,,`,,`,,,`,`,`,`,`,`,`,`,`,`,`,c ,,w,`,`,`,`,`,`,"w{name=""Wood feeder""}(2x5)",,"g{name=""Goods feeder"" containers=0}:+cat_food/tallow+wax-crafts-goblets(3x3)",,`,,`,`,`,`,`,,"hlS{name=""Cloth/bones feeder"" containers=0}:+cat_refuse/skulls/,bones/,hair/,shells/,teeth/,horns/-adamantinethread(5x5)",,,~,~,`,`,`,`,`,`,c ,,w,`,`,`,`,`,`,~,~,~,~,~,`,`,,,,`,`,~,~,~,~,~,`,`,`,`,`,`,c -,,`,`,`,`,`,"c{name=""Goods/wood quantum"" quantum=true give_to=Pots,Barrels,Jugs,Bags}:+all",`,~,~,~,~,~,,`,,`,,`,,~,~,~,~,~,`,"r{name=""Cloth/bones quantum"" quantum=true}:+all",`,`,`,`,c +,,`,`,`,`,`,"c{name=""Goods/wood quantum"" quantum=true give_to=""Pots,Barrels,Jugs,Bags,Seeds feeder""}:+all",`,~,~,~,~,~,,`,,`,,`,,~,~,~,~,~,`,"r{name=""Cloth/bones quantum"" quantum=true}:+all",`,`,`,`,c ,,"c{name=""Lye"" barrels=2}:+miscliquid",`,`,`,`,`,`,~,~,"u{name=""Furniture feeder""}:-sand(3x2)",~,~,`,`,,,,`,`,~,~,~,~,~,`,`,`,`,`,`,c ,,c,`,`,`,`,`,`,~,~,~,~,~,,`,`,`,`,`,,~,~,~,~,~,`,`,`,`,`,`,c ,,c,`,`,`,`,`,`,`,`,`,`,`,,,`,,`,,,`,`,`,`,`,`,`,`,`,`,`,c From fab840d90ee70cc67be5fdb3f962b3900dfd0ef5 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Wed, 21 Jun 2023 23:22:38 +0000 Subject: [PATCH 06/44] Auto-update submodules library/xml: master scripts: master --- library/xml | 2 +- scripts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index 6c722a0f7..f42397811 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 6c722a0f745f8953fa24fe3177ca72146b3a5f42 +Subproject commit f423978117f5eba1d53d5d88937d85069a58382c diff --git a/scripts b/scripts index e9abfb95b..8f921d62c 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit e9abfb95ba16702ef08c4bc16e86d5f54c055b02 +Subproject commit 8f921d62cee58d4f5c5a9b4b38bd21650f3acaae From 462ec8b8770af1afa3e86e526faa1d0abefbca76 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Fri, 23 Jun 2023 07:15:28 +0000 Subject: [PATCH 07/44] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index 8f921d62c..f18d22c01 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 8f921d62cee58d4f5c5a9b4b38bd21650f3acaae +Subproject commit f18d22c018d0baffb0b3fbe21e9c863c2f29b6cc From 6fa361a326ddc4df88925e5a69b1d84880264dd4 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Fri, 23 Jun 2023 17:23:26 +0000 Subject: [PATCH 08/44] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index f18d22c01..04a01e6d3 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit f18d22c018d0baffb0b3fbe21e9c863c2f29b6cc +Subproject commit 04a01e6d35a467ee40d6b706ce92f1c43a1acfa2 From 30e6c44769eaec22d1be6cf4f6d28e1bba2d3783 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 22 Jun 2023 10:13:01 -0700 Subject: [PATCH 09/44] addendum for #3480 --- data/orders/military.json | 6 +++--- data/orders/smelting.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/orders/military.json b/data/orders/military.json index abf2675f9..e461f0d3d 100644 --- a/data/orders/military.json +++ b/data/orders/military.json @@ -418,7 +418,7 @@ "condition" : "AtLeast", "item_type" : "BOULDER", "material" : "INORGANIC:CASSITERITE", - "value" : 5 + "value" : 25 }, { "condition" : "AtLeast", @@ -697,7 +697,7 @@ "bearing" : "TIN", "condition" : "AtLeast", "item_type" : "BOULDER", - "value" : 5 + "value" : 25 }, { "bearing" : "COPPER", @@ -758,7 +758,7 @@ "bearing" : "TIN", "condition" : "AtMost", "item_type" : "BOULDER", - "value" : 5 + "value" : 25 }, { "bearing" : "COPPER", diff --git a/data/orders/smelting.json b/data/orders/smelting.json index 7d88997f0..781a52100 100644 --- a/data/orders/smelting.json +++ b/data/orders/smelting.json @@ -43,7 +43,7 @@ "condition" : "AtLeast", "item_type" : "BOULDER", "material" : "INORGANIC:CASSITERITE", - "value" : 5 + "value" : 25 }, { "condition" : "AtLeast", @@ -668,7 +668,7 @@ "bearing" : "TIN", "condition" : "AtLeast", "item_type" : "BOULDER", - "value" : 5 + "value" : 25 }, { "bearing" : "COPPER", @@ -729,7 +729,7 @@ "bearing" : "TIN", "condition" : "AtMost", "item_type" : "BOULDER", - "value" : 5 + "value" : 25 }, { "bearing" : "COPPER", From eff175567563c2bf6c942ce00684bab4676048f3 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 23 Jun 2023 10:59:21 -0700 Subject: [PATCH 10/44] bump to 50.08-r4 --- CMakeLists.txt | 4 ++-- docs/changelog.txt | 30 ++++++++++++++++++++---------- library/xml | 2 +- scripts | 2 +- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed92b1eca..1309daa4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ project(dfhack) # set up versioning. set(DF_VERSION "50.08") -set(DFHACK_RELEASE "r4rc1") -set(DFHACK_PRERELEASE TRUE) +set(DFHACK_RELEASE "r4") +set(DFHACK_PRERELEASE FALSE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") set(DFHACK_ABI_VERSION 1) diff --git a/docs/changelog.txt b/docs/changelog.txt index 3300bd0c1..7761ad8f7 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -33,6 +33,24 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future +## New Plugins + +## Fixes + +## Misc Improvements + +## Documentation + +## API + +## Internals + +## Lua + +## Removed + +# 50.08-r4 + ## New Plugins - `logistics`: automatically mark and route items or animals that come to monitored stockpiles. options are toggleable on an overlay that comes up when you have a stockpile selected. @@ -45,22 +63,14 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `autonick`: additional nicknames based on burrowing animals, colours, gems, and minerals - `stockpiles`: added ``barrels``, ``organic``, ``artifacts``, and ``masterworks`` stockpile presets - `orders`: only display import/export/sort/clear panel on main orders screen +- `orders`: refine order conditions for library orders to reduce cancellation spam - Blueprint library: dreamfort: full rewrite and update for DF v50 - Blueprint library: pump_stack: updated walkthrough and separated dig and channel steps so boulders can be cleared - Blueprint library: aquifer_tap: updated walkthrough -- `orders`: better order conditions for the ``smelting`` library orders to reduce cancellation spam - `dig-now`: can now handle digging obsidian that has been formed from magma and water ## Documentation -- `blueprint-library-guide`: update Dreamfort screenshots, add ``aquifer_tap`` screenshot - -## API - -## Internals - -## Lua - -## Removed +- `blueprint-library-guide`: update Dreamfort screenshots and links, add ``aquifer_tap`` screenshot # 50.08-r3 diff --git a/library/xml b/library/xml index f42397811..916a49700 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit f423978117f5eba1d53d5d88937d85069a58382c +Subproject commit 916a497000651b64272dacda3a5005650d3c0c68 diff --git a/scripts b/scripts index 04a01e6d3..fcccedb91 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 04a01e6d35a467ee40d6b706ce92f1c43a1acfa2 +Subproject commit fcccedb91e48ebdbe151950c86689d52f0617ea9 From 4e48ce64f111778929900caeb777be7ed5cac633 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 22 May 2023 15:07:19 -0700 Subject: [PATCH 11/44] get things mostly ported to SDL2 --- CMakeLists.txt | 41 +-- library/CMakeLists.txt | 4 - library/Core.cpp | 122 ++----- library/Hooks.cpp | 2 +- library/LuaApi.cpp | 4 +- library/include/Core.h | 4 +- library/include/Hooks.h | 54 +-- library/include/SDL_events.h | 210 ----------- library/include/SDL_keyboard.h | 61 ---- library/include/SDL_keysym.h | 329 ------------------ library/include/df/custom/enabler.methods.inc | 2 + library/include/modules/DFSDL.h | 79 +---- library/include/modules/Screen.h | 2 +- library/modules/DFSDL.cpp | 64 ++-- library/modules/Screen.cpp | 2 + library/modules/Textures.cpp | 36 +- library/xml | 2 +- .../remotefortressreader.cpp | 14 +- 18 files changed, 149 insertions(+), 883 deletions(-) delete mode 100644 library/include/SDL_events.h delete mode 100644 library/include/SDL_keyboard.h delete mode 100644 library/include/SDL_keysym.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1309daa4e..545a0e6f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -285,30 +285,27 @@ else() unset(CMAKE_HAVE_PTHREAD_H CACHE) endif() - if(NOT APPLE AND DFHACK_BUILD_32) - set(ZLIB_ROOT /usr/lib/i386-linux-gnu) - endif() + # Move zlib to the build folder so possible 32 and 64-bit builds + # in the same source tree don't conflict + file(COPY ${dfhack_SOURCE_DIR}/depends/zlib + DESTINATION ${CMAKE_BINARY_DIR}/depends/) + file(COPY ${ZLIB_DOWNLOAD_DIR}/zlib.lib + DESTINATION ${CMAKE_BINARY_DIR}/depends/zlib/lib/) endif() -find_package(ZLIB REQUIRED) -include_directories(${ZLIB_INCLUDE_DIRS}) -if(WIN32) - # Do the same for SDL.dll - # (DFHack doesn't require this at build time, so no need to move it to the build folder) - # TODO: remove SDL.dll from our distribution once DF moves to SDL2. we only - # continue to include it so we don't break Steam players on update by removing - # the SDL.dll that DF needs. - set(SDL_DOWNLOAD_DIR ${dfhack_SOURCE_DIR}/package/windows/win${DFHACK_BUILD_ARCH}) - if(${DFHACK_BUILD_ARCH} STREQUAL "64") - download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-SDL.dll" - ${SDL_DOWNLOAD_DIR}/SDL.dll - "1ae242c4b94cb03756a1288122a66faf") - else() - download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win32-SDL.dll" - ${SDL_DOWNLOAD_DIR}/SDL.dll - "5a09604daca6b2b5ce049d79af935d6a") - endif() -endif() +# Download SDL release and extract into depends (in the build dir so as not to clutter up the source dir) +# all we need are the header files, so the same release package will work for all platforms +# (the above statement is untested for OSX) +set(SDL_VERSION 2.26.2) +set(SDL_ZIP_FILE SDL2-devel-${SDL_VERSION}-VC.zip) +set(SDL_ZIP_PATH ${CMAKE_BINARY_DIR}/depends/SDL2/) +file(DOWNLOAD "https://github.com/libsdl-org/SDL/releases/download/release-${SDL_VERSION}/${SDL_ZIP_FILE}" + ${SDL_ZIP_PATH}${SDL_ZIP_FILE} + EXPECTED_MD5 574daf26d48de753d0b1e19823c9d8bb + SHOW_PROGRESS) +file(ARCHIVE_EXTRACT INPUT ${SDL_ZIP_PATH}${SDL_ZIP_FILE} + DESTINATION ${SDL_ZIP_PATH}) +include_directories(${SDL_ZIP_PATH}/SDL2-${SDL_VERSION}/include) if(APPLE) # libstdc++ (GCC 4.8.5 for OS X 10.6) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 8681c9c90..5d2698bb0 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -431,10 +431,6 @@ if(UNIX) install(TARGETS dfhooks LIBRARY DESTINATION . RUNTIME DESTINATION .) -else() - # On windows, copy SDL.dll so DF can still run. - install(PROGRAMS ${dfhack_SOURCE_DIR}/package/windows/win${DFHACK_BUILD_ARCH}/SDL.dll - DESTINATION ${DFHACK_LIBRARY_DESTINATION}) endif() # install the main lib diff --git a/library/Core.cpp b/library/Core.cpp index 431cd2c9f..6fc453060 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -84,7 +84,7 @@ using namespace DFHack; #include #include "md5wrapper.h" -#include "SDL_events.h" +#include #ifdef LINUX_BUILD #include @@ -2347,99 +2347,47 @@ bool Core::DFH_ncurses_key(int key) return ncurses_wgetch(key, dummy); } -int UnicodeAwareSym(const SDL::KeyboardEvent& ke) -{ - // Assume keyboard layouts don't change the order of numbers: - if( '0' <= ke.ksym.sym && ke.ksym.sym <= '9') return ke.ksym.sym; - if(SDL::K_F1 <= ke.ksym.sym && ke.ksym.sym <= SDL::K_F12) return ke.ksym.sym; - - // These keys are mapped to the same control codes as Ctrl-? - switch (ke.ksym.sym) - { - case SDL::K_RETURN: - case SDL::K_KP_ENTER: - case SDL::K_TAB: - case SDL::K_ESCAPE: - case SDL::K_DELETE: - return ke.ksym.sym; - default: - break; - } - - int unicode = ke.ksym.unicode; - - // convert Ctrl characters to their 0x40-0x5F counterparts: - if (unicode < ' ') - { - unicode += 'A' - 1; - } - - // convert A-Z to their a-z counterparts: - if('A' <= unicode && unicode <= 'Z') - { - unicode += 'a' - 'A'; - } - - // convert various other punctuation marks: - if('\"' == unicode) unicode = '\''; - if('+' == unicode) unicode = '='; - if(':' == unicode) unicode = ';'; - if('<' == unicode) unicode = ','; - if('>' == unicode) unicode = '.'; - if('?' == unicode) unicode = '/'; - if('{' == unicode) unicode = '['; - if('|' == unicode) unicode = '\\'; - if('}' == unicode) unicode = ']'; - if('~' == unicode) unicode = '`'; - - return unicode; -} - // returns true if the event is handled -bool Core::DFH_SDL_Event(SDL::Event* ev) +bool Core::DFH_SDL_Event(SDL_Event* ev) { // do NOT process events before we are ready. if(!started || !ev) return false; - if(ev->type == SDL::ET_ACTIVEEVENT && ev->active.gain) - { + if (ev->type == SDL_WINDOWEVENT && ev->window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { // clear modstate when gaining focus in case alt-tab was used when // losing focus and modstate is now incorrectly set modstate = 0; return false; } - if(ev->type == SDL::ET_KEYDOWN || ev->type == SDL::ET_KEYUP) - { - auto ke = (SDL::KeyboardEvent *)ev; + if (ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP) { + auto &ke = ev->key; - if (ke->ksym.sym == SDL::K_LSHIFT || ke->ksym.sym == SDL::K_RSHIFT) - modstate = (ev->type == SDL::ET_KEYDOWN) ? modstate | DFH_MOD_SHIFT : modstate & ~DFH_MOD_SHIFT; - else if (ke->ksym.sym == SDL::K_LCTRL || ke->ksym.sym == SDL::K_RCTRL) - modstate = (ev->type == SDL::ET_KEYDOWN) ? modstate | DFH_MOD_CTRL : modstate & ~DFH_MOD_CTRL; - else if (ke->ksym.sym == SDL::K_LALT || ke->ksym.sym == SDL::K_RALT) - modstate = (ev->type == SDL::ET_KEYDOWN) ? modstate | DFH_MOD_ALT : modstate & ~DFH_MOD_ALT; - else if(ke->state == SDL::BTN_PRESSED && !hotkey_states[ke->ksym.sym]) + if (ke.keysym.sym == SDLK_LSHIFT || ke.keysym.sym == SDLK_RSHIFT) + modstate = (ev->type == SDL_KEYDOWN) ? modstate | DFH_MOD_SHIFT : modstate & ~DFH_MOD_SHIFT; + else if (ke.keysym.sym == SDLK_LCTRL || ke.keysym.sym == SDLK_RCTRL) + modstate = (ev->type == SDL_KEYDOWN) ? modstate | DFH_MOD_CTRL : modstate & ~DFH_MOD_CTRL; + else if (ke.keysym.sym == SDLK_LALT || ke.keysym.sym == SDLK_RALT) + modstate = (ev->type == SDL_KEYDOWN) ? modstate | DFH_MOD_ALT : modstate & ~DFH_MOD_ALT; + else if (ke.state == SDL_PRESSED && !hotkey_states[ke.keysym.sym]) { - hotkey_states[ke->ksym.sym] = true; - - // Use unicode so Windows gives the correct value for the - // user's Input Language - if(ke->ksym.unicode && ((ke->ksym.unicode & 0xff80) == 0)) - { - int key = UnicodeAwareSym(*ke); - SelectHotkey(key, modstate); - } - else - { - // Pretend non-ascii characters don't happen: - SelectHotkey(ke->ksym.sym, modstate); - } + hotkey_states[ke.keysym.sym] = true; } - else if(ke->state == SDL::BTN_RELEASED) + else if(ke.state == SDL_RELEASED) { - hotkey_states[ke->ksym.sym] = false; + hotkey_states[ke.keysym.sym] = false; + } + } + else if (ev->type == SDL_TEXTINPUT) { + auto &te = ev->text; + + uint8_t sym = (uint8_t)te.text[0]; + if (sym <= 0x7f && hotkey_states[sym]) { + // register that we have responded to this hotkey, and don't respond + // again even if the key is held down + hotkey_states[sym] = false; + SelectHotkey(sym, modstate); } } return false; @@ -2455,8 +2403,8 @@ bool Core::SelectHotkey(int sym, int modifiers) while (screen->child) screen = screen->child; - if (sym == SDL::K_KP_ENTER) - sym = SDL::K_RETURN; + if (sym == SDLK_KP_ENTER) + sym = SDLK_RETURN; std::string cmd; @@ -2497,7 +2445,7 @@ bool Core::SelectHotkey(int sym, int modifiers) if (cmd.empty()) { // Check the hotkey keybindings - int idx = sym - SDL::K_F1; + int idx = sym - SDLK_F1; if(idx >= 0 && idx < 8) { /* TODO: understand how this changes for v50 @@ -2555,22 +2503,22 @@ static bool parseKeySpec(std::string keyspec, int *psym, int *pmod, std::string } if (keyspec.size() == 1 && keyspec[0] >= 'A' && keyspec[0] <= 'Z') { - *psym = SDL::K_a + (keyspec[0]-'A'); + *psym = SDLK_a + (keyspec[0]-'A'); return true; } else if (keyspec.size() == 1 && keyspec[0] == '`') { - *psym = SDL::K_BACKQUOTE; + *psym = SDLK_BACKQUOTE; return true; } else if (keyspec.size() == 1 && keyspec[0] >= '0' && keyspec[0] <= '9') { - *psym = SDL::K_0 + (keyspec[0]-'0'); + *psym = SDLK_0 + (keyspec[0]-'0'); return true; } else if (keyspec.size() == 2 && keyspec[0] == 'F' && keyspec[1] >= '1' && keyspec[1] <= '9') { - *psym = SDL::K_F1 + (keyspec[1]-'1'); + *psym = SDLK_F1 + (keyspec[1]-'1'); return true; } else if (keyspec.size() == 3 && keyspec.substr(0, 2) == "F1" && keyspec[2] >= '0' && keyspec[2] <= '2') { - *psym = SDL::K_F10 + (keyspec[2]-'0'); + *psym = SDLK_F10 + (keyspec[2]-'0'); return true; } else if (keyspec == "Enter") { - *psym = SDL::K_RETURN; + *psym = SDLK_RETURN; return true; } else return false; diff --git a/library/Hooks.cpp b/library/Hooks.cpp index 4e339e768..31a8ec749 100644 --- a/library/Hooks.cpp +++ b/library/Hooks.cpp @@ -48,7 +48,7 @@ DFhackCExport void dfhooks_prerender() { // called from the main thread for each SDL event. if true is returned, then // the event has been consumed and further processing shouldn't happen -DFhackCExport bool dfhooks_sdl_event(SDL::Event* event) { +DFhackCExport bool dfhooks_sdl_event(SDL_Event* event) { if (disabled) return false; return DFHack::Core::getInstance().DFH_SDL_Event(event); diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 0a737875a..7de74470f 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -2635,6 +2635,7 @@ static int screen_charToKey(lua_State *L) return 1; } +/* static int screen_zoom(lua_State *L) { using df::global::enabler; @@ -2651,6 +2652,7 @@ static int screen_zoom(lua_State *L) enabler->zoom_display(cmd); return 0; } +*/ } @@ -2671,7 +2673,7 @@ static const luaL_Reg dfhack_screen_funcs[] = { { "_doSimulateInput", screen_doSimulateInput }, { "keyToChar", screen_keyToChar }, { "charToKey", screen_charToKey }, - { "zoom", screen_zoom }, + //{ "zoom", screen_zoom }, { NULL, NULL } }; diff --git a/library/include/Core.h b/library/include/Core.h index 696be4ead..916a63cf3 100644 --- a/library/include/Core.h +++ b/library/include/Core.h @@ -112,7 +112,7 @@ namespace DFHack friend void ::dfhooks_shutdown(); friend void ::dfhooks_update(); friend void ::dfhooks_prerender(); - friend bool ::dfhooks_sdl_event(SDL::Event* event); + friend bool ::dfhooks_sdl_event(SDL_Event* event); friend bool ::dfhooks_ncurses_key(int key); public: /// Get the single Core instance or make one. @@ -195,7 +195,7 @@ namespace DFHack bool InitSimulationThread(); int Update (void); int Shutdown (void); - bool DFH_SDL_Event(SDL::Event* event); + bool DFH_SDL_Event(SDL_Event* event); bool ncurses_wgetch(int in, int & out); bool DFH_ncurses_key(int key); diff --git a/library/include/Hooks.h b/library/include/Hooks.h index 5856fb44f..fb72fdbe3 100644 --- a/library/include/Hooks.h +++ b/library/include/Hooks.h @@ -24,61 +24,11 @@ distribution. #pragma once -/* - * Some much needed SDL fakery. - */ - -#include "Pragma.h" -#include "Export.h" -#include -#include - -#include "modules/Graphic.h" - -// function and variable pointer... we don't try to understand what SDL does here -typedef void * fPtr; -typedef void * vPtr; -struct WINDOW; -namespace SDL -{ - union Event; -} - -// these functions are here because they call into DFHack::Core and therefore need to -// be declared as friend functions/known -#ifdef _DARWIN -DFhackCExport int DFH_SDL_NumJoysticks(void); -DFhackCExport void DFH_SDL_Quit(void); -DFhackCExport int DFH_SDL_PollEvent(SDL::Event* event); -DFhackCExport int DFH_SDL_Init(uint32_t flags); -DFhackCExport int DFH_wgetch(WINDOW * win); -#endif -DFhackCExport int SDL_NumJoysticks(void); -DFhackCExport void SDL_Quit(void); -DFhackCExport int SDL_PollEvent(SDL::Event* event); -DFhackCExport int SDL_PushEvent(SDL::Event* event); -DFhackCExport int SDL_Init(uint32_t flags); -DFhackCExport int wgetch(WINDOW * win); - -DFhackCExport int SDL_UpperBlit(DFHack::DFSDL_Surface* src, DFHack::DFSDL_Rect* srcrect, DFHack::DFSDL_Surface* dst, DFHack::DFSDL_Rect* dstrect); -DFhackCExport vPtr SDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth, - uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask); -DFhackCExport vPtr SDL_CreateRGBSurfaceFrom(vPtr pixels, int width, int height, int depth, int pitch, - uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask); -DFhackCExport void SDL_FreeSurface(vPtr surface); -DFhackCExport vPtr SDL_ConvertSurface(vPtr surface, vPtr format, uint32_t flags); -DFhackCExport int SDL_LockSurface(vPtr surface); -DFhackCExport void SDL_UnlockSurface(vPtr surface); -DFhackCExport uint8_t SDL_GetMouseState(int *x, int *y); -DFhackCExport void * SDL_GetVideoSurface(void); - -DFhackCExport int SDL_SemWait(vPtr sem); -DFhackCExport int SDL_SemPost(vPtr sem); +union SDL_Event; -// new Hooks API DFhackCExport void dfhooks_init(); DFhackCExport void dfhooks_shutdown(); DFhackCExport void dfhooks_update(); DFhackCExport void dfhooks_prerender(); -DFhackCExport bool dfhooks_sdl_event(SDL::Event* event); +DFhackCExport bool dfhooks_sdl_event(SDL_Event* event); DFhackCExport bool dfhooks_ncurses_key(int key); diff --git a/library/include/SDL_events.h b/library/include/SDL_events.h deleted file mode 100644 index 80067f07d..000000000 --- a/library/include/SDL_events.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -// Fake - only structs. Shamelessly pilfered from the SDL library. -// Needed for processing its event types without polluting our namespaces with C garbage - -#pragma once -#include "SDL_keyboard.h" - -namespace SDL -{ - enum ButtonState - { - BTN_RELEASED = 0, - BTN_PRESSED = 1 - }; - - /** Event enumerations */ - enum EventType - { - ET_NOEVENT = 0, /**< Unused (do not remove) */ - ET_ACTIVEEVENT, /**< Application loses/gains visibility */ - ET_KEYDOWN, /**< Keys pressed */ - ET_KEYUP, /**< Keys released */ - ET_MOUSEMOTION, /**< Mouse moved */ - ET_MOUSEBUTTONDOWN, /**< Mouse button pressed */ - ET_MOUSEBUTTONUP, /**< Mouse button released */ - ET_JOYAXISMOTION, /**< Joystick axis motion */ - ET_JOYBALLMOTION, /**< Joystick trackball motion */ - ET_JOYHATMOTION, /**< Joystick hat position change */ - ET_JOYBUTTONDOWN, /**< Joystick button pressed */ - ET_JOYBUTTONUP, /**< Joystick button released */ - ET_QUIT, /**< User-requested quit */ - ET_SYSWMEVENT, /**< System specific event */ - ET_EVENT_RESERVEDA, /**< Reserved for future use.. */ - ET_EVENT_RESERVEDB, /**< Reserved for future use.. */ - ET_VIDEORESIZE, /**< User resized video mode */ - ET_VIDEOEXPOSE, /**< Screen needs to be redrawn */ - ET_EVENT_RESERVED2, /**< Reserved for future use.. */ - ET_EVENT_RESERVED3, /**< Reserved for future use.. */ - ET_EVENT_RESERVED4, /**< Reserved for future use.. */ - ET_EVENT_RESERVED5, /**< Reserved for future use.. */ - ET_EVENT_RESERVED6, /**< Reserved for future use.. */ - ET_EVENT_RESERVED7, /**< Reserved for future use.. */ - /** Events ET_USEREVENT through ET_MAXEVENTS-1 are for your use */ - ET_USEREVENT = 24, - /** This last event is only for bounding internal arrays - * It is the number of bits in the event mask datatype -- Uint32 - */ - ET_NUMEVENTS = 32 - }; - - /** Application visibility event structure */ - struct ActiveEvent - { - uint8_t type; /**< ET_ACTIVEEVENT */ - uint8_t gain; /**< Whether given states were gained or lost (1/0) */ - uint8_t state; /**< A mask of the focus states */ - }; - - /** Keyboard event structure */ - struct KeyboardEvent - { - uint8_t type; /**< ET_KEYDOWN or ET_KEYUP */ - uint8_t which; /**< The keyboard device index */ - uint8_t state; /**< BTN_PRESSED or BTN_RELEASED */ - keysym ksym; - }; - - /** Mouse motion event structure */ - struct MouseMotionEvent - { - uint8_t type; /**< ET_MOUSEMOTION */ - uint8_t which; /**< The mouse device index */ - uint8_t state; /**< The current button state */ - uint16_t x, y; /**< The X/Y coordinates of the mouse */ - int16_t xrel; /**< The relative motion in the X direction */ - int16_t yrel; /**< The relative motion in the Y direction */ - }; - - /** Mouse button event structure */ - struct MouseButtonEvent - { - uint8_t type; /**< ET_MOUSEBUTTONDOWN or ET_MOUSEBUTTONUP */ - uint8_t which; /**< The mouse device index */ - uint8_t button; /**< The mouse button index */ - uint8_t state; /**< BTN_PRESSED or BTN_RELEASED */ - uint16_t x, y; /**< The X/Y coordinates of the mouse at press time */ - }; - - /** Joystick axis motion event structure */ - struct JoyAxisEvent - { - uint8_t type; /**< ET_JOYAXISMOTION */ - uint8_t which; /**< The joystick device index */ - uint8_t axis; /**< The joystick axis index */ - int16_t value; /**< The axis value (range: -32768 to 32767) */ - }; - - /** Joystick trackball motion event structure */ - struct JoyBallEvent - { - uint8_t type; /**< ET_JOYBALLMOTION */ - uint8_t which; /**< The joystick device index */ - uint8_t ball; /**< The joystick trackball index */ - int16_t xrel; /**< The relative motion in the X direction */ - int16_t yrel; /**< The relative motion in the Y direction */ - }; - - /** Joystick hat position change event structure */ - struct JoyHatEvent - { - uint8_t type; /**< ET_JOYHATMOTION */ - uint8_t which; /**< The joystick device index */ - uint8_t hat; /**< The joystick hat index */ - uint8_t value; /**< The hat position value: - * SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP - * SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT - * SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN - * Note that zero means the POV is centered. - */ - }; - - /** Joystick button event structure */ - struct JoyButtonEvent - { - uint8_t type; /**< ET_JOYBUTTONDOWN or ET_JOYBUTTONUP */ - uint8_t which; /**< The joystick device index */ - uint8_t button; /**< The joystick button index */ - uint8_t state; /**< BTN_PRESSED or BTN_RELEASED */ - }; - - /** The "window resized" event - * When you get this event, you are responsible for setting a new video - * mode with the new width and height. - */ - struct ResizeEvent - { - uint8_t type; /**< ET_VIDEORESIZE */ - int w; /**< New width */ - int h; /**< New height */ - }; - - /** The "screen redraw" event */ - struct ExposeEvent - { - uint8_t type; /**< ET_VIDEOEXPOSE */ - }; - - /** The "quit requested" event */ - struct QuitEvent - { - uint8_t type; /**< ET_QUIT */ - }; - - /** A user-defined event type */ - struct UserEvent - { - uint8_t type; /**< ETL_USEREVENT through ET_NUMEVENTS-1 */ - int code; /**< User defined event code */ - void *data1; /**< User defined data pointer */ - void *data2; /**< User defined data pointer */ - }; - - /** If you want to use this event, you should include SDL_syswm.h */ - struct SysWMmsg; - struct SysWMEvent - { - uint8_t type; - SysWMmsg *msg; - }; - - /** General event structure */ - union Event - { - uint8_t type; - ActiveEvent active; - KeyboardEvent key; - MouseMotionEvent motion; - MouseButtonEvent button; - JoyAxisEvent jaxis; - JoyBallEvent jball; - JoyHatEvent jhat; - JoyButtonEvent jbutton; - ResizeEvent resize; - ExposeEvent expose; - QuitEvent quit; - UserEvent user; - SysWMEvent syswm; - }; -} diff --git a/library/include/SDL_keyboard.h b/library/include/SDL_keyboard.h deleted file mode 100644 index 1d58bd63f..000000000 --- a/library/include/SDL_keyboard.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -// Fake - only structs. Shamelessly pilfered from the SDL library. -// Needed for processing its event types without polluting our namespaces with C garbage - -#pragma once -#include "SDL_keysym.h" -#include - -namespace SDL -{ - /** Keysym structure - * - * - The scancode is hardware dependent, and should not be used by general - * applications. If no hardware scancode is available, it will be 0. - * - * - The 'unicode' translated character is only available when character - * translation is enabled by the SDL_EnableUNICODE() API. If non-zero, - * this is a UNICODE character corresponding to the keypress. If the - * high 9 bits of the character are 0, then this maps to the equivalent - * ASCII character: - * @code - * char ch; - * if ( (keysym.unicode & 0xFF80) == 0 ) { - * ch = keysym.unicode & 0x7F; - * } else { - * An international character.. - * } - * @endcode - */ - typedef struct keysym - { - uint8_t scancode; /**< hardware specific scancode */ - Key sym; /**< SDL virtual keysym */ - Mod mod; /**< current key modifiers */ - uint16_t unicode; /**< translated character */ - } keysym; - - /** This is the mask which refers to all hotkey bindings */ - #define ALL_HOTKEYS 0xFFFFFFFF -} diff --git a/library/include/SDL_keysym.h b/library/include/SDL_keysym.h deleted file mode 100644 index e19f786af..000000000 --- a/library/include/SDL_keysym.h +++ /dev/null @@ -1,329 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -// Fake - only structs. Shamelessly pilfered from the SDL library. -// Needed for processing its event types without polluting our namespaces with C garbage - -#pragma once - -namespace SDL -{ - /** What we really want is a mapping of every raw key on the keyboard. - * To support international keyboards, we use the range 0xA1 - 0xFF - * as international virtual keycodes. We'll follow in the footsteps of X11... - * @brief The names of the keys - */ - enum Key - { - /** @name ASCII mapped keysyms - * The keyboard syms have been cleverly chosen to map to ASCII - */ - /*@{*/ - K_UNKNOWN = 0, - K_FIRST = 0, - K_BACKSPACE = 8, - K_TAB = 9, - K_CLEAR = 12, - K_RETURN = 13, - K_PAUSE = 19, - K_ESCAPE = 27, - K_SPACE = 32, - K_EXCLAIM = 33, - K_QUOTEDBL = 34, - K_HASH = 35, - K_DOLLAR = 36, - K_AMPERSAND = 38, - K_QUOTE = 39, - K_LEFTPAREN = 40, - K_RIGHTPAREN = 41, - K_ASTERISK = 42, - K_PLUS = 43, - K_COMMA = 44, - K_MINUS = 45, - K_PERIOD = 46, - K_SLASH = 47, - K_0 = 48, - K_1 = 49, - K_2 = 50, - K_3 = 51, - K_4 = 52, - K_5 = 53, - K_6 = 54, - K_7 = 55, - K_8 = 56, - K_9 = 57, - K_COLON = 58, - K_SEMICOLON = 59, - K_LESS = 60, - K_EQUALS = 61, - K_GREATER = 62, - K_QUESTION = 63, - K_AT = 64, - /* - Skip uppercase letters - */ - K_LEFTBRACKET = 91, - K_BACKSLASH = 92, - K_RIGHTBRACKET = 93, - K_CARET = 94, - K_UNDERSCORE = 95, - K_BACKQUOTE = 96, - K_a = 97, - K_b = 98, - K_c = 99, - K_d = 100, - K_e = 101, - K_f = 102, - K_g = 103, - K_h = 104, - K_i = 105, - K_j = 106, - K_k = 107, - K_l = 108, - K_m = 109, - K_n = 110, - K_o = 111, - K_p = 112, - K_q = 113, - K_r = 114, - K_s = 115, - K_t = 116, - K_u = 117, - K_v = 118, - K_w = 119, - K_x = 120, - K_y = 121, - K_z = 122, - K_DELETE = 127, - /* End of ASCII mapped keysyms */ - /*@}*/ - - /** @name International keyboard syms */ - /*@{*/ - K_WORLD_0 = 160, /* 0xA0 */ - K_WORLD_1 = 161, - K_WORLD_2 = 162, - K_WORLD_3 = 163, - K_WORLD_4 = 164, - K_WORLD_5 = 165, - K_WORLD_6 = 166, - K_WORLD_7 = 167, - K_WORLD_8 = 168, - K_WORLD_9 = 169, - K_WORLD_10 = 170, - K_WORLD_11 = 171, - K_WORLD_12 = 172, - K_WORLD_13 = 173, - K_WORLD_14 = 174, - K_WORLD_15 = 175, - K_WORLD_16 = 176, - K_WORLD_17 = 177, - K_WORLD_18 = 178, - K_WORLD_19 = 179, - K_WORLD_20 = 180, - K_WORLD_21 = 181, - K_WORLD_22 = 182, - K_WORLD_23 = 183, - K_WORLD_24 = 184, - K_WORLD_25 = 185, - K_WORLD_26 = 186, - K_WORLD_27 = 187, - K_WORLD_28 = 188, - K_WORLD_29 = 189, - K_WORLD_30 = 190, - K_WORLD_31 = 191, - K_WORLD_32 = 192, - K_WORLD_33 = 193, - K_WORLD_34 = 194, - K_WORLD_35 = 195, - K_WORLD_36 = 196, - K_WORLD_37 = 197, - K_WORLD_38 = 198, - K_WORLD_39 = 199, - K_WORLD_40 = 200, - K_WORLD_41 = 201, - K_WORLD_42 = 202, - K_WORLD_43 = 203, - K_WORLD_44 = 204, - K_WORLD_45 = 205, - K_WORLD_46 = 206, - K_WORLD_47 = 207, - K_WORLD_48 = 208, - K_WORLD_49 = 209, - K_WORLD_50 = 210, - K_WORLD_51 = 211, - K_WORLD_52 = 212, - K_WORLD_53 = 213, - K_WORLD_54 = 214, - K_WORLD_55 = 215, - K_WORLD_56 = 216, - K_WORLD_57 = 217, - K_WORLD_58 = 218, - K_WORLD_59 = 219, - K_WORLD_60 = 220, - K_WORLD_61 = 221, - K_WORLD_62 = 222, - K_WORLD_63 = 223, - K_WORLD_64 = 224, - K_WORLD_65 = 225, - K_WORLD_66 = 226, - K_WORLD_67 = 227, - K_WORLD_68 = 228, - K_WORLD_69 = 229, - K_WORLD_70 = 230, - K_WORLD_71 = 231, - K_WORLD_72 = 232, - K_WORLD_73 = 233, - K_WORLD_74 = 234, - K_WORLD_75 = 235, - K_WORLD_76 = 236, - K_WORLD_77 = 237, - K_WORLD_78 = 238, - K_WORLD_79 = 239, - K_WORLD_80 = 240, - K_WORLD_81 = 241, - K_WORLD_82 = 242, - K_WORLD_83 = 243, - K_WORLD_84 = 244, - K_WORLD_85 = 245, - K_WORLD_86 = 246, - K_WORLD_87 = 247, - K_WORLD_88 = 248, - K_WORLD_89 = 249, - K_WORLD_90 = 250, - K_WORLD_91 = 251, - K_WORLD_92 = 252, - K_WORLD_93 = 253, - K_WORLD_94 = 254, - K_WORLD_95 = 255, /* 0xFF */ - /*@}*/ - - /** @name Numeric keypad */ - /*@{*/ - K_KP0 = 256, - K_KP1 = 257, - K_KP2 = 258, - K_KP3 = 259, - K_KP4 = 260, - K_KP5 = 261, - K_KP6 = 262, - K_KP7 = 263, - K_KP8 = 264, - K_KP9 = 265, - K_KP_PERIOD = 266, - K_KP_DIVIDE = 267, - K_KP_MULTIPLY = 268, - K_KP_MINUS = 269, - K_KP_PLUS = 270, - K_KP_ENTER = 271, - K_KP_EQUALS = 272, - /*@}*/ - - /** @name Arrows + Home/End pad */ - /*@{*/ - K_UP = 273, - K_DOWN = 274, - K_RIGHT = 275, - K_LEFT = 276, - K_INSERT = 277, - K_HOME = 278, - K_END = 279, - K_PAGEUP = 280, - K_PAGEDOWN = 281, - /*@}*/ - - /** @name Function keys */ - /*@{*/ - K_F1 = 282, - K_F2 = 283, - K_F3 = 284, - K_F4 = 285, - K_F5 = 286, - K_F6 = 287, - K_F7 = 288, - K_F8 = 289, - K_F9 = 290, - K_F10 = 291, - K_F11 = 292, - K_F12 = 293, - K_F13 = 294, - K_F14 = 295, - K_F15 = 296, - /*@}*/ - - /** @name Key state modifier keys */ - /*@{*/ - K_NUMLOCK = 300, - K_CAPSLOCK = 301, - K_SCROLLOCK = 302, - K_RSHIFT = 303, - K_LSHIFT = 304, - K_RCTRL = 305, - K_LCTRL = 306, - K_RALT = 307, - K_LALT = 308, - K_RMETA = 309, - K_LMETA = 310, - K_LSUPER = 311, /**< Left "Windows" key */ - K_RSUPER = 312, /**< Right "Windows" key */ - K_MODE = 313, /**< "Alt Gr" key */ - K_COMPOSE = 314, /**< Multi-key compose key */ - /*@}*/ - - /** @name Miscellaneous function keys */ - /*@{*/ - K_HELP = 315, - K_PRINT = 316, - K_SYSREQ = 317, - K_BREAK = 318, - K_MENU = 319, - K_POWER = 320, /**< Power Macintosh power key */ - K_EURO = 321, /**< Some european keyboards */ - K_UNDO = 322, /**< Atari keyboard has Undo */ - /*@}*/ - - /* Add any other keys here */ - - K_LAST - }; - - /** Enumeration of valid key mods (possibly OR'd together) */ - enum Mod { - KMOD_NONE = 0x0000, - KMOD_LSHIFT= 0x0001, - KMOD_RSHIFT= 0x0002, - KMOD_LCTRL = 0x0040, - KMOD_RCTRL = 0x0080, - KMOD_LALT = 0x0100, - KMOD_RALT = 0x0200, - KMOD_LMETA = 0x0400, - KMOD_RMETA = 0x0800, - KMOD_NUM = 0x1000, - KMOD_CAPS = 0x2000, - KMOD_MODE = 0x4000, - KMOD_RESERVED = 0x8000, - KMOD_CTRL = (KMOD_LCTRL|KMOD_RCTRL), - KMOD_SHIFT = (KMOD_LSHIFT|KMOD_RSHIFT), - KMOD_ALT = (KMOD_LALT|KMOD_RALT), - KMOD_META = (KMOD_LMETA|KMOD_RMETA) - }; -} diff --git a/library/include/df/custom/enabler.methods.inc b/library/include/df/custom/enabler.methods.inc index b06af2345..5cc584bc2 100644 --- a/library/include/df/custom/enabler.methods.inc +++ b/library/include/df/custom/enabler.methods.inc @@ -1,6 +1,8 @@ void zoom_display(df::zoom_commands command) { + /* DFHack::DFSDL::DFSDL_SemWait(async_zoom.sem); async_zoom.queue.push_back(command); DFHack::DFSDL::DFSDL_SemPost(async_zoom.sem); DFHack::DFSDL::DFSDL_SemPost(async_zoom.sem_fill); + */ } diff --git a/library/include/modules/DFSDL.h b/library/include/modules/DFSDL.h index 9f07ea3db..fc65fab34 100644 --- a/library/include/modules/DFSDL.h +++ b/library/include/modules/DFSDL.h @@ -3,60 +3,19 @@ #include "Export.h" #include "ColorText.h" +struct SDL_Surface; +struct SDL_Rect; +struct SDL_PixelFormat; +union SDL_Event; + namespace DFHack { - // SDL stand-in type definitions - typedef signed short SINT16; - typedef void DFSDL_sem; - typedef void DFSDL_Event; - - typedef struct - { - int16_t x, y; - uint16_t w, h; - } DFSDL_Rect; - typedef struct - { - void *palette; // SDL_Palette* - uint8_t BitsPerPixel; - uint8_t BytesPerPixel; - uint8_t Rloss; - uint8_t Gloss; - uint8_t Bloss; - uint8_t Aloss; - uint8_t Rshift; - uint8_t Gshift; - uint8_t Bshift; - uint8_t Ashift; - uint32_t Rmask; - uint32_t Gmask; - uint32_t Bmask; - uint32_t Amask; - uint32_t colorkey; - uint8_t alpha; - } DFSDL_PixelFormat; - typedef struct - { - uint32_t flags; - DFSDL_PixelFormat* format; - int w, h; - int pitch; - void* pixels; - void* userdata; // as far as i could see DF doesnt use this - int locked; - void* lock_data; - DFSDL_Rect clip_rect; - void* map; - int refcount; - } DFSDL_Surface; - - // ========= struct DFTileSurface { bool paintOver; // draw over original tile? - DFSDL_Surface* surface; // from where it should be drawn - DFSDL_Rect* rect; // from which coords (NULL to draw whole surface) - DFSDL_Rect* dstResize; // if not NULL dst rect will be resized (x/y/w/h will be added to original dst) + SDL_Surface* surface; // from where it should be drawn + SDL_Rect* rect; // from which coords (NULL to draw whole surface) + SDL_Rect* dstResize; // if not NULL dst rect will be resized (x/y/w/h will be added to original dst) }; /** @@ -79,17 +38,17 @@ bool init(DFHack::color_ostream &out); */ void cleanup(); -DFHACK_EXPORT DFSDL_Surface * DFIMG_Load(const char *file); -DFHACK_EXPORT int DFSDL_SetAlpha(DFSDL_Surface *surface, uint32_t flag, uint8_t alpha); -DFHACK_EXPORT DFSDL_Surface * DFSDL_GetVideoSurface(void); -DFHACK_EXPORT DFSDL_Surface * DFSDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask); -DFHACK_EXPORT DFSDL_Surface * DFSDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask); -DFHACK_EXPORT int DFSDL_UpperBlit(DFSDL_Surface *src, const DFSDL_Rect *srcrect, DFSDL_Surface *dst, DFSDL_Rect *dstrect); -DFHACK_EXPORT DFSDL_Surface * DFSDL_ConvertSurface(DFSDL_Surface *src, const DFSDL_PixelFormat *fmt, uint32_t flags); -DFHACK_EXPORT void DFSDL_FreeSurface(DFSDL_Surface *surface); -DFHACK_EXPORT int DFSDL_SemWait(DFSDL_sem *sem); -DFHACK_EXPORT int DFSDL_SemPost(DFSDL_sem *sem); -DFHACK_EXPORT int DFSDL_PushEvent(DFSDL_Event *event); +DFHACK_EXPORT SDL_Surface * DFIMG_Load(const char *file); +DFHACK_EXPORT int DFSDL_SetAlpha(SDL_Surface *surface, uint32_t flag, uint8_t alpha); +DFHACK_EXPORT SDL_Surface * DFSDL_GetVideoSurface(void); +DFHACK_EXPORT SDL_Surface * DFSDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask); +DFHACK_EXPORT SDL_Surface * DFSDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask); +DFHACK_EXPORT int DFSDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect); +DFHACK_EXPORT SDL_Surface * DFSDL_ConvertSurface(SDL_Surface *src, const SDL_PixelFormat *fmt, uint32_t flags); +DFHACK_EXPORT void DFSDL_FreeSurface(SDL_Surface *surface); +// DFHACK_EXPORT int DFSDL_SemWait(SDL_sem *sem); +// DFHACK_EXPORT int DFSDL_SemPost(SDL_sem *sem); +DFHACK_EXPORT int DFSDL_PushEvent(SDL_Event *event); } diff --git a/library/include/modules/Screen.h b/library/include/modules/Screen.h index c21e3ad32..887fb5f75 100644 --- a/library/include/modules/Screen.h +++ b/library/include/modules/Screen.h @@ -191,7 +191,7 @@ namespace DFHack } /// Wrapper to call enabler->zoom_display from plugins - DFHACK_EXPORT void zoom(df::zoom_commands cmd); + //DFHACK_EXPORT void zoom(df::zoom_commands cmd); /// Returns the state of [GRAPHICS:YES/NO] DFHACK_EXPORT bool inGraphicsMode(); diff --git a/library/modules/DFSDL.cpp b/library/modules/DFSDL.cpp index b95b6302a..36e8e1a41 100644 --- a/library/modules/DFSDL.cpp +++ b/library/modules/DFSDL.cpp @@ -14,29 +14,29 @@ using namespace DFHack; static DFLibrary *g_sdl_handle = nullptr; static DFLibrary *g_sdl_image_handle = nullptr; static const std::vector SDL_LIBS { - "SDL.dll", + "SDL2.dll", "SDL.framework/Versions/A/SDL", "SDL.framework/SDL", - "libSDL-1.2.so.0" + "libSDL2-2.0.so.0" }; static const std::vector SDL_IMAGE_LIBS { - "SDL_image.dll", + "SDL2_image.dll", "SDL_image.framework/Versions/A/SDL_image", "SDL_image.framework/SDL_image", - "libSDL_image-1.2.so.0" + "libSDL2_image-2.0.so.0" }; -DFSDL_Surface * (*g_IMG_Load)(const char *) = nullptr; -int (*g_SDL_SetAlpha)(DFSDL_Surface *, uint32_t, uint8_t) = nullptr; -DFSDL_Surface * (*g_SDL_GetVideoSurface)(void) = nullptr; -DFSDL_Surface * (*g_SDL_CreateRGBSurface)(uint32_t, int, int, int, uint32_t, uint32_t, uint32_t, uint32_t) = nullptr; -DFSDL_Surface * (*g_SDL_CreateRGBSurfaceFrom)(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) = nullptr; -int (*g_SDL_UpperBlit)(DFSDL_Surface *, const DFSDL_Rect *, DFSDL_Surface *, DFSDL_Rect *) = nullptr; -DFSDL_Surface * (*g_SDL_ConvertSurface)(DFSDL_Surface *, const DFSDL_PixelFormat *, uint32_t) = nullptr; -void (*g_SDL_FreeSurface)(DFSDL_Surface *) = nullptr; -int (*g_SDL_SemWait)(DFSDL_sem *) = nullptr; -int (*g_SDL_SemPost)(DFSDL_sem *) = nullptr; -int (*g_SDL_PushEvent)(DFSDL_Event *) = nullptr; +SDL_Surface * (*g_IMG_Load)(const char *) = nullptr; +int (*g_SDL_SetAlpha)(SDL_Surface *, uint32_t, uint8_t) = nullptr; +SDL_Surface * (*g_SDL_GetVideoSurface)(void) = nullptr; +SDL_Surface * (*g_SDL_CreateRGBSurface)(uint32_t, int, int, int, uint32_t, uint32_t, uint32_t, uint32_t) = nullptr; +SDL_Surface * (*g_SDL_CreateRGBSurfaceFrom)(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) = nullptr; +int (*g_SDL_UpperBlit)(SDL_Surface *, const SDL_Rect *, SDL_Surface *, SDL_Rect *) = nullptr; +SDL_Surface * (*g_SDL_ConvertSurface)(SDL_Surface *, const SDL_PixelFormat *, uint32_t) = nullptr; +void (*g_SDL_FreeSurface)(SDL_Surface *) = nullptr; +// int (*g_SDL_SemWait)(DFSDL_sem *) = nullptr; +// int (*g_SDL_SemPost)(DFSDL_sem *) = nullptr; +int (*g_SDL_PushEvent)(SDL_Event *) = nullptr; bool DFSDL::init(color_ostream &out) { for (auto &lib_str : SDL_LIBS) { @@ -72,8 +72,8 @@ bool DFSDL::init(color_ostream &out) { bind(g_sdl_handle, SDL_UpperBlit); bind(g_sdl_handle, SDL_ConvertSurface); bind(g_sdl_handle, SDL_FreeSurface); - bind(g_sdl_handle, SDL_SemWait); - bind(g_sdl_handle, SDL_SemPost); + // bind(g_sdl_handle, SDL_SemWait); + // bind(g_sdl_handle, SDL_SemPost); bind(g_sdl_handle, SDL_PushEvent); #undef bind @@ -93,46 +93,46 @@ void DFSDL::cleanup() { } } -DFSDL_Surface * DFSDL::DFIMG_Load(const char *file) { +SDL_Surface * DFSDL::DFIMG_Load(const char *file) { return g_IMG_Load(file); } -int DFSDL::DFSDL_SetAlpha(DFSDL_Surface *surface, uint32_t flag, uint8_t alpha) { +int DFSDL::DFSDL_SetAlpha(SDL_Surface *surface, uint32_t flag, uint8_t alpha) { return g_SDL_SetAlpha(surface, flag, alpha); } -DFSDL_Surface * DFSDL::DFSDL_GetVideoSurface(void) { +SDL_Surface * DFSDL::DFSDL_GetVideoSurface(void) { return g_SDL_GetVideoSurface(); } -DFSDL_Surface * DFSDL::DFSDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) { +SDL_Surface * DFSDL::DFSDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) { return g_SDL_CreateRGBSurface(flags, width, height, depth, Rmask, Gmask, Bmask, Amask); } -DFSDL_Surface * DFSDL::DFSDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) { +SDL_Surface * DFSDL::DFSDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) { return g_SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask); } -int DFSDL::DFSDL_UpperBlit(DFSDL_Surface *src, const DFSDL_Rect *srcrect, DFSDL_Surface *dst, DFSDL_Rect *dstrect) { +int DFSDL::DFSDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { return g_SDL_UpperBlit(src, srcrect, dst, dstrect); } -DFSDL_Surface * DFSDL::DFSDL_ConvertSurface(DFSDL_Surface *src, const DFSDL_PixelFormat *fmt, uint32_t flags) { +SDL_Surface * DFSDL::DFSDL_ConvertSurface(SDL_Surface *src, const SDL_PixelFormat *fmt, uint32_t flags) { return g_SDL_ConvertSurface(src, fmt, flags); } -void DFSDL::DFSDL_FreeSurface(DFSDL_Surface *surface) { +void DFSDL::DFSDL_FreeSurface(SDL_Surface *surface) { g_SDL_FreeSurface(surface); } -int DFSDL::DFSDL_SemWait(DFSDL_sem *sem) { - return g_SDL_SemWait(sem); -} +// int DFSDL::DFSDL_SemWait(DFSDL_sem *sem) { +// return g_SDL_SemWait(sem); +// } -int DFSDL::DFSDL_SemPost(DFSDL_sem *sem) { - return g_SDL_SemPost(sem); -} +// int DFSDL::DFSDL_SemPost(DFSDL_sem *sem) { +// return g_SDL_SemPost(sem); +// } -int DFSDL::DFSDL_PushEvent(DFSDL_Event *event) { +int DFSDL::DFSDL_PushEvent(SDL_Event *event) { return g_SDL_PushEvent(event); } diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index 6ccf246aa..a36f387b6 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -106,9 +106,11 @@ df::coord2d Screen::getWindowSize() return df::coord2d(gps->dimx, gps->dimy); } +/* void Screen::zoom(df::zoom_commands cmd) { enabler->zoom_display(cmd); } +*/ bool Screen::inGraphicsMode() { diff --git a/library/modules/Textures.cpp b/library/modules/Textures.cpp index a30f879a0..21aadf2da 100644 --- a/library/modules/Textures.cpp +++ b/library/modules/Textures.cpp @@ -8,6 +8,8 @@ #include "df/enabler.h" +#include + using df::global::enabler; using namespace DFHack; using namespace DFHack::DFSDL; @@ -37,26 +39,34 @@ static long g_window_borders_texpos_start = -1; // // It uses the same pixel format (RGBA, R at lowest address) regardless of // hardware. -DFSDL_Surface * canonicalize_format(DFSDL_Surface *src) { - DFSDL_PixelFormat fmt; +SDL_Surface * canonicalize_format(SDL_Surface *src) { + SDL_PixelFormat fmt; fmt.palette = NULL; fmt.BitsPerPixel = 32; fmt.BytesPerPixel = 4; fmt.Rloss = fmt.Gloss = fmt.Bloss = fmt.Aloss = 0; -//#if SDL_BYTEORDER == SDL_BIG_ENDIAN -// fmt.Rshift = 24; fmt.Gshift = 16; fmt.Bshift = 8; fmt.Ashift = 0; -//#else +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + fmt.Rshift = 24; fmt.Gshift = 16; fmt.Bshift = 8; fmt.Ashift = 0; +#else fmt.Rshift = 0; fmt.Gshift = 8; fmt.Bshift = 16; fmt.Ashift = 24; -//#endif +#endif fmt.Rmask = 255 << fmt.Rshift; fmt.Gmask = 255 << fmt.Gshift; fmt.Bmask = 255 << fmt.Bshift; fmt.Amask = 255 << fmt.Ashift; - fmt.colorkey = 0; - fmt.alpha = 255; - DFSDL_Surface *tgt = DFSDL_ConvertSurface(src, &fmt, 0); // SDL_SWSURFACE + SDL_Surface *tgt = DFSDL_ConvertSurface(src, &fmt, SDL_SWSURFACE); DFSDL_FreeSurface(src); + for (int x = 0; x < tgt->w; ++x) { + for (int y = 0; y < tgt->h; ++y) { + Uint8* p = (Uint8*)tgt->pixels + y * tgt->pitch + x * 4; + if (p[3] == 0) { + for (int c = 0; c < 3; c++) { + p[c] = 0; + } + } + } + } return tgt; } @@ -65,7 +75,7 @@ const uint32_t TILE_HEIGHT_PX = 12; static size_t load_textures(color_ostream & out, const char * fname, long *texpos_start) { - DFSDL_Surface *s = DFIMG_Load(fname); + SDL_Surface *s = DFIMG_Load(fname); if (!s) { out.printerr("unable to load textures from '%s'\n", fname); return 0; @@ -78,12 +88,12 @@ static size_t load_textures(color_ostream & out, const char * fname, long count = 0; for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { - DFSDL_Surface *tile = DFSDL_CreateRGBSurface(0, // SDL_SWSURFACE + SDL_Surface *tile = DFSDL_CreateRGBSurface(0, // SDL_SWSURFACE TILE_WIDTH_PX, TILE_HEIGHT_PX, 32, s->format->Rmask, s->format->Gmask, s->format->Bmask, s->format->Amask); DFSDL_SetAlpha(tile, 0,255); - DFSDL_Rect vp; + SDL_Rect vp; vp.x = TILE_WIDTH_PX * x; vp.y = TILE_HEIGHT_PX * y; vp.w = TILE_WIDTH_PX; @@ -161,7 +171,7 @@ void Textures::cleanup() { auto &raws = textures.raws; size_t texpos_end = g_dfhack_logo_texpos_start + g_num_dfhack_textures; for (size_t idx = g_dfhack_logo_texpos_start; idx <= texpos_end; ++idx) { - DFSDL_FreeSurface((DFSDL_Surface *)raws[idx]); + DFSDL_FreeSurface((SDL_Surface *)raws[idx]); raws[idx] = NULL; } diff --git a/library/xml b/library/xml index 916a49700..bff3a12b3 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 916a497000651b64272dacda3a5005650d3c0c68 +Subproject commit bff3a12b3863f54c5c2f3031c1726f7e28a9e70e diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index 56d29371b..6ca69d1a7 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -14,8 +14,6 @@ #include "PluginManager.h" #include "RemoteFortressReader.pb.h" #include "RemoteServer.h" -#include "SDL_events.h" -#include "SDL_keyboard.h" #include "TileTypes.h" #include "VersionInfo.h" #if DF_VERSION_INT > 34011 @@ -126,6 +124,9 @@ #include "dwarf_control.h" #include "item_reader.h" +#include +#include + using namespace DFHack; using namespace df::enums; using namespace RemoteFortressReader; @@ -2894,13 +2895,12 @@ static command_result CopyScreen(color_ostream &stream, const EmptyMessage *in, static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEvent *in) { #if DF_VERSION_INT > 34011 - SDL::Event e; + SDL_Event e; e.key.type = in->type(); e.key.state = in->state(); - e.key.ksym.mod = (SDL::Mod)in->mod(); - e.key.ksym.scancode = in->scancode(); - e.key.ksym.sym = (SDL::Key)in->sym(); - e.key.ksym.unicode = in->unicode(); + e.key.keysym.mod = in->mod(); + e.key.keysym.scancode = (SDL_Scancode)in->scancode(); + e.key.keysym.sym = in->sym(); DFHack::DFSDL::DFSDL_PushEvent(&e); #endif return CR_OK; From 52151b0e9840b69410ebb67ddeeb26a5897cd43c Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 22 May 2023 17:34:00 -0700 Subject: [PATCH 12/44] remove SDL functions that don't exist anymore --- library/include/modules/DFSDL.h | 2 -- library/modules/DFSDL.cpp | 12 ------------ library/modules/Textures.cpp | 2 -- 3 files changed, 16 deletions(-) diff --git a/library/include/modules/DFSDL.h b/library/include/modules/DFSDL.h index fc65fab34..626224d60 100644 --- a/library/include/modules/DFSDL.h +++ b/library/include/modules/DFSDL.h @@ -39,8 +39,6 @@ bool init(DFHack::color_ostream &out); void cleanup(); DFHACK_EXPORT SDL_Surface * DFIMG_Load(const char *file); -DFHACK_EXPORT int DFSDL_SetAlpha(SDL_Surface *surface, uint32_t flag, uint8_t alpha); -DFHACK_EXPORT SDL_Surface * DFSDL_GetVideoSurface(void); DFHACK_EXPORT SDL_Surface * DFSDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask); DFHACK_EXPORT SDL_Surface * DFSDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask); DFHACK_EXPORT int DFSDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect); diff --git a/library/modules/DFSDL.cpp b/library/modules/DFSDL.cpp index 36e8e1a41..7aa7f36d5 100644 --- a/library/modules/DFSDL.cpp +++ b/library/modules/DFSDL.cpp @@ -27,8 +27,6 @@ static const std::vector SDL_IMAGE_LIBS { }; SDL_Surface * (*g_IMG_Load)(const char *) = nullptr; -int (*g_SDL_SetAlpha)(SDL_Surface *, uint32_t, uint8_t) = nullptr; -SDL_Surface * (*g_SDL_GetVideoSurface)(void) = nullptr; SDL_Surface * (*g_SDL_CreateRGBSurface)(uint32_t, int, int, int, uint32_t, uint32_t, uint32_t, uint32_t) = nullptr; SDL_Surface * (*g_SDL_CreateRGBSurfaceFrom)(void *pixels, int width, int height, int depth, int pitch, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) = nullptr; int (*g_SDL_UpperBlit)(SDL_Surface *, const SDL_Rect *, SDL_Surface *, SDL_Rect *) = nullptr; @@ -65,8 +63,6 @@ bool DFSDL::init(color_ostream &out) { } bind(g_sdl_image_handle, IMG_Load); - bind(g_sdl_handle, SDL_SetAlpha); - bind(g_sdl_handle, SDL_GetVideoSurface); bind(g_sdl_handle, SDL_CreateRGBSurface); bind(g_sdl_handle, SDL_CreateRGBSurfaceFrom); bind(g_sdl_handle, SDL_UpperBlit); @@ -97,14 +93,6 @@ SDL_Surface * DFSDL::DFIMG_Load(const char *file) { return g_IMG_Load(file); } -int DFSDL::DFSDL_SetAlpha(SDL_Surface *surface, uint32_t flag, uint8_t alpha) { - return g_SDL_SetAlpha(surface, flag, alpha); -} - -SDL_Surface * DFSDL::DFSDL_GetVideoSurface(void) { - return g_SDL_GetVideoSurface(); -} - SDL_Surface * DFSDL::DFSDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) { return g_SDL_CreateRGBSurface(flags, width, height, depth, Rmask, Gmask, Bmask, Amask); } diff --git a/library/modules/Textures.cpp b/library/modules/Textures.cpp index 21aadf2da..e31e37426 100644 --- a/library/modules/Textures.cpp +++ b/library/modules/Textures.cpp @@ -82,7 +82,6 @@ static size_t load_textures(color_ostream & out, const char * fname, } s = canonicalize_format(s); - DFSDL_SetAlpha(s, 0, 255); int dimx = s->w / TILE_WIDTH_PX; int dimy = s->h / TILE_HEIGHT_PX; long count = 0; @@ -92,7 +91,6 @@ static size_t load_textures(color_ostream & out, const char * fname, TILE_WIDTH_PX, TILE_HEIGHT_PX, 32, s->format->Rmask, s->format->Gmask, s->format->Bmask, s->format->Amask); - DFSDL_SetAlpha(tile, 0,255); SDL_Rect vp; vp.x = TILE_WIDTH_PX * x; vp.y = TILE_HEIGHT_PX * y; From a48344fd241ddc98049d38310ca501114d188a26 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 22 May 2023 17:49:17 -0700 Subject: [PATCH 13/44] get keybindings working again --- library/Core.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index 6fc453060..4b036a83e 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -2373,23 +2373,13 @@ bool Core::DFH_SDL_Event(SDL_Event* ev) else if (ke.state == SDL_PRESSED && !hotkey_states[ke.keysym.sym]) { hotkey_states[ke.keysym.sym] = true; + SelectHotkey(ke.keysym.sym, modstate); } else if(ke.state == SDL_RELEASED) { hotkey_states[ke.keysym.sym] = false; } } - else if (ev->type == SDL_TEXTINPUT) { - auto &te = ev->text; - - uint8_t sym = (uint8_t)te.text[0]; - if (sym <= 0x7f && hotkey_states[sym]) { - // register that we have responded to this hotkey, and don't respond - // again even if the key is held down - hotkey_states[sym] = false; - SelectHotkey(sym, modstate); - } - } return false; } @@ -2408,7 +2398,7 @@ bool Core::SelectHotkey(int sym, int modifiers) std::string cmd; - DEBUG(keybinding).print("checking hotkeys for sym=%d, modifiers=%x\n", sym, modifiers); + DEBUG(keybinding).print("checking hotkeys for sym=%d (%c), modifiers=%x\n", sym, sym, modifiers); { std::lock_guard lock(HotkeyMutex); From 61eeea20e8eaef105f400eef13e1d05575b0f832 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 23 May 2023 16:56:42 -0700 Subject: [PATCH 14/44] ensure offline builds still work; clean up --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 545a0e6f5..ef3a7bd84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ project(dfhack) # set up versioning. set(DF_VERSION "50.08") -set(DFHACK_RELEASE "r4") -set(DFHACK_PRERELEASE FALSE) +set(DFHACK_RELEASE "r2rc1") +set(DFHACK_PRERELEASE TRUE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") set(DFHACK_ABI_VERSION 1) @@ -285,24 +285,23 @@ else() unset(CMAKE_HAVE_PTHREAD_H CACHE) endif() - # Move zlib to the build folder so possible 32 and 64-bit builds - # in the same source tree don't conflict - file(COPY ${dfhack_SOURCE_DIR}/depends/zlib - DESTINATION ${CMAKE_BINARY_DIR}/depends/) - file(COPY ${ZLIB_DOWNLOAD_DIR}/zlib.lib - DESTINATION ${CMAKE_BINARY_DIR}/depends/zlib/lib/) + if(NOT APPLE AND DFHACK_BUILD_32) + set(ZLIB_ROOT /usr/lib/i386-linux-gnu) + endif() endif() +find_package(ZLIB REQUIRED) +include_directories(${ZLIB_INCLUDE_DIRS}) -# Download SDL release and extract into depends (in the build dir so as not to clutter up the source dir) +# Download SDL release and extract into depends in the build dir # all we need are the header files, so the same release package will work for all platforms # (the above statement is untested for OSX) set(SDL_VERSION 2.26.2) +set(SDL_ZIP_MD5 574daf26d48de753d0b1e19823c9d8bb) set(SDL_ZIP_FILE SDL2-devel-${SDL_VERSION}-VC.zip) set(SDL_ZIP_PATH ${CMAKE_BINARY_DIR}/depends/SDL2/) -file(DOWNLOAD "https://github.com/libsdl-org/SDL/releases/download/release-${SDL_VERSION}/${SDL_ZIP_FILE}" +download_file("https://github.com/libsdl-org/SDL/releases/download/release-${SDL_VERSION}/${SDL_ZIP_FILE}" ${SDL_ZIP_PATH}${SDL_ZIP_FILE} - EXPECTED_MD5 574daf26d48de753d0b1e19823c9d8bb - SHOW_PROGRESS) + ${SDL_ZIP_MD5}) file(ARCHIVE_EXTRACT INPUT ${SDL_ZIP_PATH}${SDL_ZIP_FILE} DESTINATION ${SDL_ZIP_PATH}) include_directories(${SDL_ZIP_PATH}/SDL2-${SDL_VERSION}/include) From 90a280625192c9dd0d286c6a56e0ab8eda9a4110 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 23 May 2023 17:15:47 -0700 Subject: [PATCH 15/44] fix paths --- depends/zlib/lib/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 depends/zlib/lib/.gitignore diff --git a/depends/zlib/lib/.gitignore b/depends/zlib/lib/.gitignore deleted file mode 100644 index 683bf139f..000000000 --- a/depends/zlib/lib/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.lib From f6228240d2b4479da1153ba75506119cd071387c Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Wed, 24 May 2023 03:04:33 -0700 Subject: [PATCH 16/44] move zlib download back to src dir --- CMakeLists.txt | 2 +- depends/zlib/lib/win64/.gitignore | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 depends/zlib/lib/win64/.gitignore diff --git a/CMakeLists.txt b/CMakeLists.txt index ef3a7bd84..667e1d67e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,7 @@ if(WIN32) set(ZLIB_PATH ${dfhack_SOURCE_DIR}/depends/zlib/) set(ZLIB_MD5 a3b2fc6b68efafa89b0882e354fc8418) download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-${ZLIB_FILE}" - ${ZLIB_PATH}lib/${ZLIB_FILE} + ${ZLIB_PATH}lib/win64/${ZLIB_FILE} ${ZLIB_MD5}) set(ZLIB_ROOT ${ZLIB_PATH}) else() diff --git a/depends/zlib/lib/win64/.gitignore b/depends/zlib/lib/win64/.gitignore new file mode 100644 index 000000000..683bf139f --- /dev/null +++ b/depends/zlib/lib/win64/.gitignore @@ -0,0 +1 @@ +*.lib From 05ae92f08522e90415a10929c0170fdfee9a5860 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Wed, 24 May 2023 03:17:22 -0700 Subject: [PATCH 17/44] move SDL2 to depends in the src dir --- .gitignore | 7 ++++--- CMakeLists.txt | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index a386b260a..5b4c7f6fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # linux backup files *~ -#Kdevelop project files +# Kdevelop project files *.kdev4 .kdev4 @@ -70,7 +70,7 @@ tags # Mac OS X .DS_Store files .DS_Store -#VS is annoying about this one. +# VS is annoying about this one. /build/win64/DF_PATH.txt /build/win32/DF_PATH.txt /.vs @@ -81,5 +81,6 @@ tags # external plugins /plugins/CMakeLists.custom.txt -# steam api +# 3rd party downloads depends/steam +depends/SDL2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 667e1d67e..ea2d8f968 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,12 +293,13 @@ find_package(ZLIB REQUIRED) include_directories(${ZLIB_INCLUDE_DIRS}) # Download SDL release and extract into depends in the build dir -# all we need are the header files, so the same release package will work for all platforms +# all we need are the header files (including generated headers), so the same release package +# will work for all platforms # (the above statement is untested for OSX) set(SDL_VERSION 2.26.2) set(SDL_ZIP_MD5 574daf26d48de753d0b1e19823c9d8bb) set(SDL_ZIP_FILE SDL2-devel-${SDL_VERSION}-VC.zip) -set(SDL_ZIP_PATH ${CMAKE_BINARY_DIR}/depends/SDL2/) +set(SDL_ZIP_PATH ${dfhack_SOURCE_DIR}/depends/SDL2/) download_file("https://github.com/libsdl-org/SDL/releases/download/release-${SDL_VERSION}/${SDL_ZIP_FILE}" ${SDL_ZIP_PATH}${SDL_ZIP_FILE} ${SDL_ZIP_MD5}) From a51032b8eed05cf3f79ae701423d398fd28b94a2 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Wed, 24 May 2023 12:15:52 -0700 Subject: [PATCH 18/44] use standard ROOT path structure --- CMakeLists.txt | 2 +- depends/zlib/lib/{win64 => }/.gitignore | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename depends/zlib/lib/{win64 => }/.gitignore (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea2d8f968..ec0fbb3dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,7 @@ if(WIN32) set(ZLIB_PATH ${dfhack_SOURCE_DIR}/depends/zlib/) set(ZLIB_MD5 a3b2fc6b68efafa89b0882e354fc8418) download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-${ZLIB_FILE}" - ${ZLIB_PATH}lib/win64/${ZLIB_FILE} + ${ZLIB_PATH}lib/${ZLIB_FILE} ${ZLIB_MD5}) set(ZLIB_ROOT ${ZLIB_PATH}) else() diff --git a/depends/zlib/lib/win64/.gitignore b/depends/zlib/lib/.gitignore similarity index 100% rename from depends/zlib/lib/win64/.gitignore rename to depends/zlib/lib/.gitignore From 3e2940ef8f2ff8da12d556a5714f0d80b08c2ca7 Mon Sep 17 00:00:00 2001 From: Taxi Service Date: Thu, 1 Jun 2023 20:16:31 +0200 Subject: [PATCH 19/44] attempt to set optional tilesize arguments for load_texture() --- data/art/pathable.png | Bin 0 -> 615 bytes library/include/modules/Textures.h | 5 +++++ library/modules/Textures.cpp | 25 +++++++++++++++++-------- plugins/pathable.cpp | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 data/art/pathable.png diff --git a/data/art/pathable.png b/data/art/pathable.png new file mode 100644 index 0000000000000000000000000000000000000000..00f7f831d1dd51bc166ef390470a5382781eb631 GIT binary patch literal 615 zcmV-t0+{`YP)TK+Ot%kjw70!PgW+qU zu(P|l?&9G7ZagXS;ROL0*x~6rogBLS677#Q@_acybpoRiRb);T-{JjG$?uO4rUVzyQriJmpEc8an_0002ovPDHLkV1hMj B3>5$X literal 0 HcmV?d00001 diff --git a/library/include/modules/Textures.h b/library/include/modules/Textures.h index 95e628d5a..8aa43e5c1 100644 --- a/library/include/modules/Textures.h +++ b/library/include/modules/Textures.h @@ -46,6 +46,11 @@ DFHACK_EXPORT long getIconsTexposStart(); */ DFHACK_EXPORT long getOnOffTexposStart(); +/** + * Get the first texpos for the pathable 32x32 sprites. It's a 2x1 grid. + */ +DFHACK_EXPORT long getPathableTexposStart(); + /** * Get the first texpos for the control panel icons. 10x2 grid. */ diff --git a/library/modules/Textures.cpp b/library/modules/Textures.cpp index e31e37426..6cc262764 100644 --- a/library/modules/Textures.cpp +++ b/library/modules/Textures.cpp @@ -25,6 +25,7 @@ static long g_green_pin_texpos_start = -1; static long g_red_pin_texpos_start = -1; static long g_icons_texpos_start = -1; static long g_on_off_texpos_start = -1; +static long g_pathable_texpos_start = -1; static long g_control_panel_texpos_start = -1; static long g_thin_borders_texpos_start = -1; static long g_medium_borders_texpos_start = -1; @@ -74,7 +75,9 @@ const uint32_t TILE_WIDTH_PX = 8; const uint32_t TILE_HEIGHT_PX = 12; static size_t load_textures(color_ostream & out, const char * fname, - long *texpos_start) { + long *texpos_start, + int tile_w = TILE_WIDTH_PX, + int tile_h = TILE_HEIGHT_PX) { SDL_Surface *s = DFIMG_Load(fname); if (!s) { out.printerr("unable to load textures from '%s'\n", fname); @@ -82,20 +85,20 @@ static size_t load_textures(color_ostream & out, const char * fname, } s = canonicalize_format(s); - int dimx = s->w / TILE_WIDTH_PX; - int dimy = s->h / TILE_HEIGHT_PX; + int dimx = s->w / tile_w; + int dimy = s->h / tile_h; long count = 0; for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { SDL_Surface *tile = DFSDL_CreateRGBSurface(0, // SDL_SWSURFACE - TILE_WIDTH_PX, TILE_HEIGHT_PX, 32, + tile_w, tile_h, 32, s->format->Rmask, s->format->Gmask, s->format->Bmask, s->format->Amask); SDL_Rect vp; - vp.x = TILE_WIDTH_PX * x; - vp.y = TILE_HEIGHT_PX * y; - vp.w = TILE_WIDTH_PX; - vp.h = TILE_HEIGHT_PX; + vp.x = tile_w * x; + vp.y = tile_h * y; + vp.w = tile_w; + vp.h = tile_h; DFSDL_UpperBlit(s, &vp, tile, NULL); if (!count++) *texpos_start = enabler->textures.raws.size(); @@ -137,6 +140,8 @@ void Textures::init(color_ostream &out) { &g_icons_texpos_start); g_num_dfhack_textures += load_textures(out, "hack/data/art/on-off.png", &g_on_off_texpos_start); + g_num_dfhack_textures += load_textures(out, "hack/data/art/pathable.png", + &g_pathable_texpos_start, 32, 32); g_num_dfhack_textures += load_textures(out, "hack/data/art/control-panel.png", &g_control_panel_texpos_start); g_num_dfhack_textures += load_textures(out, "hack/data/art/border-thin.png", @@ -201,6 +206,10 @@ long Textures::getOnOffTexposStart() { return g_on_off_texpos_start; } +long Textures::getPathableTexposStart() { + return g_pathable_texpos_start; +} + long Textures::getControlPanelTexposStart() { return g_control_panel_texpos_start; } diff --git a/plugins/pathable.cpp b/plugins/pathable.cpp index 06394f838..916db4a72 100644 --- a/plugins/pathable.cpp +++ b/plugins/pathable.cpp @@ -41,7 +41,7 @@ static void paintScreen(df::coord target, bool skip_unrevealed = false) { long pathable_tile_texpos = df::global::init->load_bar_texpos[1]; long unpathable_tile_texpos = df::global::init->load_bar_texpos[4]; - long on_off_texpos = Textures::getOnOffTexposStart(); + long on_off_texpos = Textures::getPathableTexposStart(); if (on_off_texpos > 0) { pathable_tile_texpos = on_off_texpos + 0; unpathable_tile_texpos = on_off_texpos + 1; From 95b9cb0ab322e4e538cece4908fcdcae30baee63 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 5 Jun 2023 19:48:14 -0700 Subject: [PATCH 20/44] match DF's version string in ours --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec0fbb3dc..1a8d557b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,8 @@ cmake_policy(SET CMP0074 NEW) project(dfhack) # set up versioning. -set(DF_VERSION "50.08") -set(DFHACK_RELEASE "r2rc1") +set(DF_VERSION "50.08sdl2-5") +set(DFHACK_RELEASE "beta1") set(DFHACK_PRERELEASE TRUE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") From 258b647ef63f89305efa0b82fd0518f0a0f39320 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 5 Jun 2023 19:49:17 -0700 Subject: [PATCH 21/44] extend the title version widget to show longer version strings --- plugins/lua/overlay.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/lua/overlay.lua b/plugins/lua/overlay.lua index fda1edc95..68582e8eb 100644 --- a/plugins/lua/overlay.lua +++ b/plugins/lua/overlay.lua @@ -597,6 +597,10 @@ function TitleVersionOverlay:init() table.insert(text, {text='Pre-release build', pen=COLOR_LIGHTRED}) end + for _,t in ipairs(text) do + self.frame.w = math.max(self.frame.w, #t) + end + self:addviews{ widgets.Label{ frame={t=0, l=0}, From 0790ace9fde1bf6811244b08a0f29e4ec33bfdce Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 6 Jun 2023 11:26:10 -0700 Subject: [PATCH 22/44] temporarily disable faststart until DF no longer has a race condition --- plugins/faststart.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/faststart.cpp b/plugins/faststart.cpp index de014801c..65895e8bf 100644 --- a/plugins/faststart.cpp +++ b/plugins/faststart.cpp @@ -48,8 +48,10 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { if (enable != is_enabled) { +#if 0 if (!INTERPOSE_HOOK(prep_hook, logic).apply(enable)) return CR_FAILURE; +#endif is_enabled = enable; } From 840a2b3525aeb8cf62223ca8507ba21af5f1824a Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 15 Jun 2023 01:14:12 -0700 Subject: [PATCH 23/44] ensure DFHack screens get all string input --- library/include/modules/Screen.h | 3 +++ library/modules/Screen.cpp | 15 +++++++++++++-- plugins/overlay.cpp | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/library/include/modules/Screen.h b/library/include/modules/Screen.h index 887fb5f75..daa08ca59 100644 --- a/library/include/modules/Screen.h +++ b/library/include/modules/Screen.h @@ -229,6 +229,9 @@ namespace DFHack DFHACK_EXPORT bool hasActiveScreens(Plugin *p); DFHACK_EXPORT void raise(df::viewscreen *screen); + // returns a new set with text interface keys from the text buffer added in (if any) + DFHACK_EXPORT std::set add_text_keys(const std::set& keys); + /// Retrieve the string representation of the bound key. DFHACK_EXPORT std::string getKeyDisplay(df::interface_key key); diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index a36f387b6..d3419398c 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -78,7 +78,6 @@ namespace DFHack { DBG_DECLARE(core, screen, DebugCategory::LINFO); } - /* * Screen painting API. */ @@ -586,6 +585,17 @@ void Hide::merge() { } } } +std::set Screen::add_text_keys(const std::set& keys) { + std::set combined_keys(keys); + if (df::global::enabler->last_text_input[0]) { + char c = df::global::enabler->last_text_input[0]; + df::interface_key key = charToKey(c); + DEBUG(screen).print("adding character %c as interface key %ld\n", c, key); + combined_keys.emplace(key); + } + return combined_keys; +} + string Screen::getKeyDisplay(df::interface_key key) { if (enabler) @@ -940,7 +950,7 @@ int dfhack_lua_viewscreen::do_input(lua_State *L) } lua_pushvalue(L, -2); - Lua::PushInterfaceKeys(L, *keys); + Lua::PushInterfaceKeys(L, Screen::add_text_keys(*keys)); lua_call(L, 2, 0); self->update_focus(L, -1); @@ -1023,6 +1033,7 @@ void dfhack_lua_viewscreen::feed(std::set *keys) lua_pushlightuserdata(Lua::Core::State, keys); safe_call_lua(do_input, 1, 0); + df::global::enabler->last_text_input[0] = '\0'; } void dfhack_lua_viewscreen::onShow() diff --git a/plugins/overlay.cpp b/plugins/overlay.cpp index 784e17129..7185f73a1 100644 --- a/plugins/overlay.cpp +++ b/plugins/overlay.cpp @@ -76,7 +76,7 @@ struct viewscreen_overlay : T { [&](lua_State *L) { Lua::Push(L, T::_identity.getName()); Lua::Push(L, this); - Lua::PushInterfaceKeys(L, *input); + Lua::PushInterfaceKeys(L, Screen::add_text_keys(*input)); }, [&](lua_State *L) { input_is_handled = lua_toboolean(L, -1); }); From f7bef53b422d793c03fc442399df7b22e743a3ed Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 15 Jun 2023 01:35:48 -0700 Subject: [PATCH 24/44] prefer symbols to descriptions for hotkey names --- library/modules/Screen.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index d3419398c..76f782edb 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -598,10 +598,12 @@ std::set Screen::add_text_keys(const std::setGetKeyDisplay(key); - - return "?"; + int c = keyToChar(key); + if (c != -1) + return string(1, c); + if (key >= df::interface_key::CUSTOM_SHIFT_A && key <= df::interface_key::CUSTOM_SHIFT_Z) + return string(1, 'A' + (key - df::interface_key::CUSTOM_SHIFT_A)); + return enabler->GetKeyDisplay(key); } int Screen::keyToChar(df::interface_key key) From e101a6d9dcfd7aeab7b6fd95b2bd8e8e6cdec932 Mon Sep 17 00:00:00 2001 From: Myk Date: Sun, 18 Jun 2023 00:22:30 -0700 Subject: [PATCH 25/44] Update Textures.h --- library/include/modules/Textures.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/include/modules/Textures.h b/library/include/modules/Textures.h index 8aa43e5c1..bebd78dc9 100644 --- a/library/include/modules/Textures.h +++ b/library/include/modules/Textures.h @@ -49,7 +49,7 @@ DFHACK_EXPORT long getOnOffTexposStart(); /** * Get the first texpos for the pathable 32x32 sprites. It's a 2x1 grid. */ -DFHACK_EXPORT long getPathableTexposStart(); +DFHACK_EXPORT long getMapPathableTexposStart(); /** * Get the first texpos for the control panel icons. 10x2 grid. From b958727655ce089492db4d540cc59f1291c0e83c Mon Sep 17 00:00:00 2001 From: Myk Date: Sun, 18 Jun 2023 00:23:43 -0700 Subject: [PATCH 26/44] Update Textures.cpp --- library/modules/Textures.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/modules/Textures.cpp b/library/modules/Textures.cpp index 6cc262764..ba77f41f7 100644 --- a/library/modules/Textures.cpp +++ b/library/modules/Textures.cpp @@ -206,7 +206,7 @@ long Textures::getOnOffTexposStart() { return g_on_off_texpos_start; } -long Textures::getPathableTexposStart() { +long Textures::getMapPathableTexposStart() { return g_pathable_texpos_start; } From 2101918158302cbe96b99adb9e109232387bfd63 Mon Sep 17 00:00:00 2001 From: Myk Date: Sun, 18 Jun 2023 00:26:52 -0700 Subject: [PATCH 27/44] Update pathable.cpp --- plugins/pathable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pathable.cpp b/plugins/pathable.cpp index 916db4a72..6ed890325 100644 --- a/plugins/pathable.cpp +++ b/plugins/pathable.cpp @@ -41,7 +41,7 @@ static void paintScreen(df::coord target, bool skip_unrevealed = false) { long pathable_tile_texpos = df::global::init->load_bar_texpos[1]; long unpathable_tile_texpos = df::global::init->load_bar_texpos[4]; - long on_off_texpos = Textures::getPathableTexposStart(); + long on_off_texpos = Textures::getMapPathableTexposStart(); if (on_off_texpos > 0) { pathable_tile_texpos = on_off_texpos + 0; unpathable_tile_texpos = on_off_texpos + 1; From 2a361ae7960da49f005e698240165e8662aeda2f Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 18 Jun 2023 00:14:38 -0700 Subject: [PATCH 28/44] re-enable faststart now that the DF race condition has been fixed --- plugins/faststart.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/faststart.cpp b/plugins/faststart.cpp index 65895e8bf..de014801c 100644 --- a/plugins/faststart.cpp +++ b/plugins/faststart.cpp @@ -48,10 +48,8 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { if (enable != is_enabled) { -#if 0 if (!INTERPOSE_HOOK(prep_hook, logic).apply(enable)) return CR_FAILURE; -#endif is_enabled = enable; } From 20e425dc4f80417f3865ba7d3a3ea6a0e47b9397 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 23 Jun 2023 14:50:06 -0700 Subject: [PATCH 29/44] update to newest df sdl beta --- CMakeLists.txt | 4 ++-- library/xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a8d557b5..5e6b706f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,8 @@ cmake_policy(SET CMP0074 NEW) project(dfhack) # set up versioning. -set(DF_VERSION "50.08sdl2-5") -set(DFHACK_RELEASE "beta1") +set(DF_VERSION "50.09sdl2-2") +set(DFHACK_RELEASE "rc1") set(DFHACK_PRERELEASE TRUE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") diff --git a/library/xml b/library/xml index bff3a12b3..89c307f21 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit bff3a12b3863f54c5c2f3031c1726f7e28a9e70e +Subproject commit 89c307f211d24960d93ba7c46cae40600caed38a From f2dc910b289c9982d57f78a939a4a7a52b47cc16 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Sat, 24 Jun 2023 20:10:27 -0500 Subject: [PATCH 30/44] update for 50.09sdl2-3 --- CMakeLists.txt | 2 +- library/xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e6b706f1..fe556d5d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_policy(SET CMP0074 NEW) project(dfhack) # set up versioning. -set(DF_VERSION "50.09sdl2-2") +set(DF_VERSION "50.09sdl2-3") set(DFHACK_RELEASE "rc1") set(DFHACK_PRERELEASE TRUE) diff --git a/library/xml b/library/xml index 89c307f21..52214bbdd 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 89c307f211d24960d93ba7c46cae40600caed38a +Subproject commit 52214bbddf9c8da0f12407ea01b49e25fcfba8a1 From 5e13eb89d8ea7fa5c994d1e1d037576bda411162 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 25 Jun 2023 18:29:21 -0700 Subject: [PATCH 31/44] fix internal link to screenhot header --- docs/guides/quickfort-library-guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/quickfort-library-guide.rst b/docs/guides/quickfort-library-guide.rst index acf5f7b60..e1c3e6b91 100644 --- a/docs/guides/quickfort-library-guide.rst +++ b/docs/guides/quickfort-library-guide.rst @@ -217,7 +217,7 @@ create a drainage system so your dwarves don't drown when digging the tap, by running the ``library/aquifer_tap.csv`` ``/help`` blueprint. You can see how to nullify the water pressure (so you don't flood your fort) in -the `Dreamfort screenshot above `_. +the Dreamfort cistern screenshot above: `Services levels (4 deep)`_. The blueprint spreadsheet is also available `online `__. From 8235680ff0263c3a42ba6bd3e3a15a07c7577da2 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 18 Jun 2023 00:55:55 -0700 Subject: [PATCH 32/44] add unsuspend map textures --- data/art/unsuspend.png | Bin 0 -> 4697 bytes library/LuaApi.cpp | 1 + library/include/modules/Textures.h | 5 +++++ library/modules/Textures.cpp | 7 +++++++ 4 files changed, 13 insertions(+) create mode 100644 data/art/unsuspend.png diff --git a/data/art/unsuspend.png b/data/art/unsuspend.png new file mode 100644 index 0000000000000000000000000000000000000000..11cb910451f6f09086b07c0eac13c590bae8c2d5 GIT binary patch literal 4697 zcmeHKc~BEs8gB^5>B-EfqevS^1es1cCrJ+>V!{z5h#?@(>S8C|fktweG$f!1;<$r| zif4^Cj*g5M9(b+?2(i>rkzIFm$^#r26&!C@L1mnM2?$s_Ra;i={70%f{f^)Fd*Ao_ zzW1u%qJ;S9{@$N@LlD$o5hGWD_e}7>p8df8!|FUWc-eE+DYOc=!X~p(M`e;QonsEsvo^6DV3?BP4k1khJowWu)q;PjFQqiQf8Wo_fB zk|tfN{|lSX)=#2pWM!ynSvh~#wQ;-WY{IqQ#b;P=bP=X2I)!$1Fat4r&o z6{14dK+ebqo0}8dcdbHeC%nDXD$iv!R!#fl7fr)W2y*#~lF1SjGTFO$KolGDmP=x4 zCyYFk`j-f8+-=5$4r^QkQY; zhjneguzl|wTuoM785!ZaIHl0jg}XCoi?7d=F9oW&ZRyfSKL?mQn8yh7>gsd*3%u1a zO9MIv&a=+CTON38Tf)eex%(e3n*ty8;b$EFEid!N5 z>_OHttMy3R%g1YV`O@uE%*SJQCGtVt*(gw7DatrZYt*xF!l)rxHoXZH9t4F+Z6;hh zi=<%l+ge? zIB|_Ji<(wpWdWYcGDXyT`B-Q*f!k6=CDwd8T!I~z-P202od}%9#DI6b<`_1!r22c;n5aCrhD0cwa(>JUDO>JTw01o`9gKw`xrkiSlm zy4fv89c{(UWJDU!5oiU<)2S64ldDgz4^rTRziWOQ<=u0gA`Rdx$OqsGauJ#SKTkZVLM7#{P{0#V&s@ugH+eVa8zr6w|&ocUtLMBn=Mxh{*ns(Aa(->h%1con^cO;2Aw zb-Rfu+;lN;Jp=Mq)y@pW9Y^KkW;@7T?W34SFQd$x{a5PoMwpJEAK1)a4Gw z;gg>~JypeSoHA3jr{cB!e#qWxw>Qr=ZcN1=T-uAi9Az!ov=v_1KR($nv&m?h7*V{s zktkHoO`RuXTsMSP>>eM3ub;dm@Ed#M-76W-^xVq2s@l`(g^CXU0Sz6elS&_t-rX!Z zy#4j~IV>pzRd($Ea&55v$W!UhE)aV5ntOgpyW&E9b8*UL_w`;_h-wjFuPYw*bmj1B z90j5c|grt#*V3}^Ur4;(gY8FQztF@`1dut?8zC1=Q|Ez zP5jfz8IMf+lA|*_Zr;-S=AW!p-zim#Pqf5d`zGn~dhF`qjZpmLBt(G2-@+#?MxrcN;KoWqaVfm0tO;$Jdnqi=TBdcxH$|>0jBF^XV0@#`}YW zGamoFxS+m0{7Kt&C{ggVG5nl7&u>lCBxlOzPpBWz_=A6J6jC{Pl%swWk@511i8BlT E1DgodA^-pY literal 0 HcmV?d00001 diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 7de74470f..d2c32cf63 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1715,6 +1715,7 @@ static const LuaWrapper::FunctionReg dfhack_textures_module[] = { WRAPM(Textures, getRedPinTexposStart), WRAPM(Textures, getIconsTexposStart), WRAPM(Textures, getOnOffTexposStart), + WRAPM(Textures, getMapUnsuspendTexposStart), WRAPM(Textures, getControlPanelTexposStart), WRAPM(Textures, getThinBordersTexposStart), WRAPM(Textures, getMediumBordersTexposStart), diff --git a/library/include/modules/Textures.h b/library/include/modules/Textures.h index bebd78dc9..8032b04a5 100644 --- a/library/include/modules/Textures.h +++ b/library/include/modules/Textures.h @@ -51,6 +51,11 @@ DFHACK_EXPORT long getOnOffTexposStart(); */ DFHACK_EXPORT long getMapPathableTexposStart(); +/** + * Get the first texpos for the unsuspend 32x32 sprites. It's a 3x1 grid. + */ +DFHACK_EXPORT long getMapUnsuspendTexposStart(); + /** * Get the first texpos for the control panel icons. 10x2 grid. */ diff --git a/library/modules/Textures.cpp b/library/modules/Textures.cpp index ba77f41f7..46dd0a4c5 100644 --- a/library/modules/Textures.cpp +++ b/library/modules/Textures.cpp @@ -26,6 +26,7 @@ static long g_red_pin_texpos_start = -1; static long g_icons_texpos_start = -1; static long g_on_off_texpos_start = -1; static long g_pathable_texpos_start = -1; +static long g_unsuspend_texpos_start = -1; static long g_control_panel_texpos_start = -1; static long g_thin_borders_texpos_start = -1; static long g_medium_borders_texpos_start = -1; @@ -142,6 +143,8 @@ void Textures::init(color_ostream &out) { &g_on_off_texpos_start); g_num_dfhack_textures += load_textures(out, "hack/data/art/pathable.png", &g_pathable_texpos_start, 32, 32); + g_num_dfhack_textures += load_textures(out, "hack/data/art/unsuspend.png", + &g_unsuspend_texpos_start, 32, 32); g_num_dfhack_textures += load_textures(out, "hack/data/art/control-panel.png", &g_control_panel_texpos_start); g_num_dfhack_textures += load_textures(out, "hack/data/art/border-thin.png", @@ -210,6 +213,10 @@ long Textures::getMapPathableTexposStart() { return g_pathable_texpos_start; } +long Textures::getMapUnsuspendTexposStart() { + return g_unsuspend_texpos_start; +} + long Textures::getControlPanelTexposStart() { return g_control_panel_texpos_start; } From d54c13121b74e6492d15d4cb1b614f4742a89dbd Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 25 Jun 2023 18:56:37 -0700 Subject: [PATCH 33/44] use new icons from RafaelKB --- data/art/unsuspend.png | Bin 4697 -> 971 bytes library/include/modules/Textures.h | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/data/art/unsuspend.png b/data/art/unsuspend.png index 11cb910451f6f09086b07c0eac13c590bae8c2d5..c00d3a1ac1c865ce70acaa4c8983cdb33f874876 100644 GIT binary patch literal 971 zcmV;+12p`JP)Px&Ye_^wRCt{2nLlXMP#njcW7!Vz#gVNSmRBQ*M6{U+vV|t)cZczL=$P1U`PAud_sJ{<9 zc=;u{@5}xEyu25H`L9Xo_)#e(0f6UuslTzWHT~6$Ne4m*3fpS6T2tM&xW%QEbgz9g z0AK(h^}wy{I`k*cWdHzu6&cWPW={esCB1oT0RXmc>DQ*M9AB+gBj-w`5&^9PAr_>R zG}XO}KHs=TpNyzd$(`bp+7g4qwn8lh(4U8(+4|!{kgFm(d>Gn z+4a6XZv9qc@|LIR>g+o@cIi1CyYyU(wh)3W%OcCNNU^lEt0)$Wa9tO!>jD65+eV>K000yU1;1~aCaFr0j$;4{&+}3PD+_pQRIz_} z4*(!vO9!04D1PE{y{=_0^gJ)sSE=Lm^+SLh0sxE}KLXA_Gt!2MXQ@QqLsZ#sbpFfR z_qA!dt_$0?{o_)pcV(HR7O>F@7Hn{xmFFhAXa`RNY-nk0hY!0=hWpJe72i^agP z<2Y~}2g}RLem{)XDWFGoVPIte11k%GAV`Y&=??T&>gcP~13{1kDhS3$HYDPFMY!~@ zW;%!kwdSAd-W6EywzBKcpBu~3+*mH6-^{KB-EfqevS^1es1cCrJ+>V!{z5h#?@(>S8C|fktweG$f!1;<$r| zif4^Cj*g5M9(b+?2(i>rkzIFm$^#r26&!C@L1mnM2?$s_Ra;i={70%f{f^)Fd*Ao_ zzW1u%qJ;S9{@$N@LlD$o5hGWD_e}7>p8df8!|FUWc-eE+DYOc=!X~p(M`e;QonsEsvo^6DV3?BP4k1khJowWu)q;PjFQqiQf8Wo_fB zk|tfN{|lSX)=#2pWM!ynSvh~#wQ;-WY{IqQ#b;P=bP=X2I)!$1Fat4r&o z6{14dK+ebqo0}8dcdbHeC%nDXD$iv!R!#fl7fr)W2y*#~lF1SjGTFO$KolGDmP=x4 zCyYFk`j-f8+-=5$4r^QkQY; zhjneguzl|wTuoM785!ZaIHl0jg}XCoi?7d=F9oW&ZRyfSKL?mQn8yh7>gsd*3%u1a zO9MIv&a=+CTON38Tf)eex%(e3n*ty8;b$EFEid!N5 z>_OHttMy3R%g1YV`O@uE%*SJQCGtVt*(gw7DatrZYt*xF!l)rxHoXZH9t4F+Z6;hh zi=<%l+ge? zIB|_Ji<(wpWdWYcGDXyT`B-Q*f!k6=CDwd8T!I~z-P202od}%9#DI6b<`_1!r22c;n5aCrhD0cwa(>JUDO>JTw01o`9gKw`xrkiSlm zy4fv89c{(UWJDU!5oiU<)2S64ldDgz4^rTRziWOQ<=u0gA`Rdx$OqsGauJ#SKTkZVLM7#{P{0#V&s@ugH+eVa8zr6w|&ocUtLMBn=Mxh{*ns(Aa(->h%1con^cO;2Aw zb-Rfu+;lN;Jp=Mq)y@pW9Y^KkW;@7T?W34SFQd$x{a5PoMwpJEAK1)a4Gw z;gg>~JypeSoHA3jr{cB!e#qWxw>Qr=ZcN1=T-uAi9Az!ov=v_1KR($nv&m?h7*V{s zktkHoO`RuXTsMSP>>eM3ub;dm@Ed#M-76W-^xVq2s@l`(g^CXU0Sz6elS&_t-rX!Z zy#4j~IV>pzRd($Ea&55v$W!UhE)aV5ntOgpyW&E9b8*UL_w`;_h-wjFuPYw*bmj1B z90j5c|grt#*V3}^Ur4;(gY8FQztF@`1dut?8zC1=Q|Ez zP5jfz8IMf+lA|*_Zr;-S=AW!p-zim#Pqf5d`zGn~dhF`qjZpmLBt(G2-@+#?MxrcN;KoWqaVfm0tO;$Jdnqi=TBdcxH$|>0jBF^XV0@#`}YW zGamoFxS+m0{7Kt&C{ggVG5nl7&u>lCBxlOzPpBWz_=A6J6jC{Pl%swWk@511i8BlT E1DgodA^-pY diff --git a/library/include/modules/Textures.h b/library/include/modules/Textures.h index 8032b04a5..f16acec4b 100644 --- a/library/include/modules/Textures.h +++ b/library/include/modules/Textures.h @@ -52,7 +52,7 @@ DFHACK_EXPORT long getOnOffTexposStart(); DFHACK_EXPORT long getMapPathableTexposStart(); /** - * Get the first texpos for the unsuspend 32x32 sprites. It's a 3x1 grid. + * Get the first texpos for the unsuspend 32x32 sprites. It's a 4x1 grid. */ DFHACK_EXPORT long getMapUnsuspendTexposStart(); From 9b744929196c5433de2975cd6d21bb0e70ae9192 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Mon, 26 Jun 2023 07:15:49 +0000 Subject: [PATCH 34/44] Auto-update submodules library/xml: master scripts: master --- library/xml | 2 +- scripts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index 916a49700..1809e3d70 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 916a497000651b64272dacda3a5005650d3c0c68 +Subproject commit 1809e3d708869bb16e0ac1745a61ac473ce745f6 diff --git a/scripts b/scripts index fcccedb91..4c74bb905 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit fcccedb91e48ebdbe151950c86689d52f0617ea9 +Subproject commit 4c74bb9055c1c7a1bd49cbe535e2fc453cd79664 From b5f4cef1879a9cf9e66c09061fed531de5a1a293 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 26 Jun 2023 02:29:36 -0700 Subject: [PATCH 35/44] differentiate trade request screen from other diplomacy screens --- library/modules/Gui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 09c3887cb..ee5eaa31c 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -343,6 +343,10 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) if (game->main_interface.diplomacy.open) { newFocusString = baseFocus; newFocusString += "/Diplomacy"; + if (game->main_interface.diplomacy.taking_requests) + newFocusString += "/Requests"; + else + newFocusString += "/Default"; focusStrings.push_back(newFocusString); } if (game->main_interface.petitions.open) { From 164a8894799d51cbc4b70f86e262eaafbaa87a5b Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 26 Jun 2023 16:02:05 -0700 Subject: [PATCH 36/44] update xml ref --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index 52214bbdd..1bfb73d15 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 52214bbddf9c8da0f12407ea01b49e25fcfba8a1 +Subproject commit 1bfb73d154226f94ec01a89a2be34bc8e660974c From 09027543df9274890a1882db5ef8f8f85eec7d94 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 26 Jun 2023 16:31:18 -0700 Subject: [PATCH 37/44] update to 50.09-r1 --- CMakeLists.txt | 6 +++--- docs/changelog.txt | 2 ++ library/xml | 2 +- scripts | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe556d5d3..641c70bec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,9 +7,9 @@ cmake_policy(SET CMP0074 NEW) project(dfhack) # set up versioning. -set(DF_VERSION "50.09sdl2-3") -set(DFHACK_RELEASE "rc1") -set(DFHACK_PRERELEASE TRUE) +set(DF_VERSION "50.09") +set(DFHACK_RELEASE "r1") +set(DFHACK_PRERELEASE FALSE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") set(DFHACK_ABI_VERSION 1) diff --git a/docs/changelog.txt b/docs/changelog.txt index 7761ad8f7..d10407621 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -49,6 +49,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Removed +# 50.09-r1 + # 50.08-r4 ## New Plugins diff --git a/library/xml b/library/xml index 1bfb73d15..95f67053a 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 1bfb73d154226f94ec01a89a2be34bc8e660974c +Subproject commit 95f67053a22ca29c6f03ef005b0acaaa6d58209e diff --git a/scripts b/scripts index 4c74bb905..46bca726e 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 4c74bb9055c1c7a1bd49cbe535e2fc453cd79664 +Subproject commit 46bca726e8044dfc2c72eddfdfcc2021a0486a13 From 354f56cc33942014fdfe8b79e663b1e7a3b1f771 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Thu, 29 Jun 2023 20:14:44 -0500 Subject: [PATCH 38/44] include vs17.6 in acceptable version range --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 641c70bec..bedebfbaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,9 +60,9 @@ endif() if(WIN32) if(NOT MSVC) - message(SEND_ERROR "No MSVC found! MSVC 2022 version 1930 to 1935 is required.") - elseif((MSVC_VERSION LESS 1930) OR (MSVC_VERSION GREATER 1935)) - message(SEND_ERROR "MSVC 2022 version 1930 to 1935 is required, Version Found: ${MSVC_VERSION}") + message(SEND_ERROR "No MSVC found! MSVC 2022 version 1930 to 1936 is required.") + elseif((MSVC_VERSION LESS 1930) OR (MSVC_VERSION GREATER 1936)) + message(SEND_ERROR "MSVC 2022 version 1930 to 1936 is required, Version Found: ${MSVC_VERSION}") endif() endif() From b5fd877b840fd221dfa04219e4dbc64c6204f03b Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Sat, 1 Jul 2023 07:13:51 +0000 Subject: [PATCH 39/44] Auto-update submodules library/xml: master scripts: master --- library/xml | 2 +- scripts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index 95f67053a..5da8a785c 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 95f67053a22ca29c6f03ef005b0acaaa6d58209e +Subproject commit 5da8a785cf176f831a56f934ec8ec6069a965ecf diff --git a/scripts b/scripts index 46bca726e..ee8217978 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 46bca726e8044dfc2c72eddfdfcc2021a0486a13 +Subproject commit ee8217978d25bc8f9c3efa21156dd8ff99896f68 From 18a9a7d1fae4a2410e28383d37a3a409ae7ee0b4 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 29 Jun 2023 18:13:16 -0700 Subject: [PATCH 40/44] allow invalid options to default to the first option and make the range slider move the other slider if it would become invalid --- library/lua/gui/widgets.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index a58ac228c..7a3201f28 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -1552,8 +1552,7 @@ function CycleHotkeyLabel:setOption(value_or_index, call_on_change) end end if not option_idx then - error(('cannot find option with value or index: "%s"') - :format(value_or_index)) + option_idx = 1 end local old_option_idx = self.option_idx self.option_idx = option_idx @@ -2392,9 +2391,15 @@ local function rangeslider_do_drag(self, width_per_idx) end end if new_left_idx and new_left_idx ~= self.get_left_idx_fn() then + if not new_right_idx and new_left_idx > self.get_right_idx_fn() then + self.on_right_change(new_left_idx) + end self.on_left_change(new_left_idx) end if new_right_idx and new_right_idx ~= self.get_right_idx_fn() then + if new_right_idx < self.get_left_idx_fn() then + self.on_left_change(new_right_idx) + end self.on_right_change(new_right_idx) end end From acd03486a9f7dbd8b935068d180ff2ba296e00ff Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 29 Jun 2023 18:14:15 -0700 Subject: [PATCH 41/44] add some more detail to the focus strings for buildings --- library/modules/Gui.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index ee5eaa31c..e9ca4c411 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -216,6 +216,11 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) newFocusString = baseFocus; newFocusString += "/ViewSheets"; newFocusString += "/" + enum_item_key(game->main_interface.view_sheets.active_sheet); + if (game->main_interface.view_sheets.active_sheet == df::view_sheet_type::BUILDING) { + auto bld = df::building::find(game->main_interface.view_sheets.viewing_bldid); + if (bld) + newFocusString += '/' + enum_item_key(bld->getType()); + } focusStrings.push_back(newFocusString); } @@ -377,6 +382,7 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) if (game->main_interface.unit_selector.open) { newFocusString = baseFocus; newFocusString += "/UnitSelector"; + newFocusString += '/' + enum_item_key(game->main_interface.unit_selector.context); focusStrings.push_back(newFocusString); } if (game->main_interface.announcement_alert.open) { From d39440d33bede73579f88c0a576df133f74b4c74 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 29 Jun 2023 19:36:05 -0700 Subject: [PATCH 42/44] migrate markForTrade logic from logistics to core --- docs/dev/Lua API.rst | 4 ++++ library/LuaApi.cpp | 1 + library/include/modules/Items.h | 3 +++ library/modules/Items.cpp | 38 +++++++++++++++++++++++++++++++++ plugins/logistics.cpp | 26 +--------------------- 5 files changed, 47 insertions(+), 25 deletions(-) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index d07cb045e..33e27be2d 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -1775,6 +1775,10 @@ Items module Checks whether the item and all items it contains, if any, can be traded. +* ``dfhack.items.markForTrade(item, depot)`` + + Marks the given item for trade at the given depot. + * ``dfhack.items.isRouteVehicle(item)`` Checks whether the item is an assigned hauling vehicle. diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index d2c32cf63..5d9411434 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -2014,6 +2014,7 @@ static const LuaWrapper::FunctionReg dfhack_items_module[] = { WRAPM(Items, checkMandates), WRAPM(Items, canTrade), WRAPM(Items, canTradeWithContents), + WRAPM(Items, markForTrade), WRAPM(Items, isRouteVehicle), WRAPM(Items, isSquadEquipment), WRAPN(moveToGround, items_moveToGround), diff --git a/library/include/modules/Items.h b/library/include/modules/Items.h index 7f2c9ce69..08737fb2b 100644 --- a/library/include/modules/Items.h +++ b/library/include/modules/Items.h @@ -33,6 +33,7 @@ distribution. #include "MemAccess.h" #include "DataDefs.h" +#include "df/building_tradedepotst.h" #include "df/item.h" #include "df/item_type.h" #include "df/general_ref.h" @@ -199,6 +200,8 @@ DFHACK_EXPORT bool checkMandates(df::item *item); DFHACK_EXPORT bool canTrade(df::item *item); /// Checks whether the item and all items it contains, if any, can be traded DFHACK_EXPORT bool canTradeWithContents(df::item *item); +/// marks the given item for trade at the given depot +DFHACK_EXPORT bool markForTrade(df::item *item, df::building_tradedepotst *depot); /// Checks whether the item is an assigned hauling vehicle DFHACK_EXPORT bool isRouteVehicle(df::item *item); diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index 03d6cda4a..f98c7c46b 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -39,6 +39,7 @@ distribution. using namespace std; #include "ModuleFactory.h" +#include "modules/Job.h" #include "modules/MapCache.h" #include "modules/Materials.h" #include "modules/Items.h" @@ -48,6 +49,7 @@ using namespace std; #include "df/body_part_template_flags.h" #include "df/building.h" #include "df/building_actual.h" +#include "df/building_tradedepotst.h" #include "df/caste_raw.h" #include "df/creature_raw.h" #include "df/general_ref.h" @@ -1637,6 +1639,42 @@ bool Items::canTradeWithContents(df::item *item) return true; } +bool Items::markForTrade(df::item *item, df::building_tradedepotst *depot) { + CHECK_NULL_POINTER(item); + CHECK_NULL_POINTER(depot); + + // validate that the depot is in a good state + if (depot->getBuildStage() < depot->getMaxBuildStage()) + return false; + if (depot->jobs.size() && depot->jobs[0]->job_type == df::job_type::DestroyBuilding) + return false; + + auto href = df::allocate(); + if (!href) + return false; + + auto job = new df::job(); + job->job_type = df::job_type::BringItemToDepot; + job->pos = df::coord(depot->centerx, depot->centery, depot->z); + + // job <-> item link + if (!Job::attachJobItem(job, item, df::job_item_ref::Hauled)) { + delete job; + delete href; + return false; + } + + // job <-> building link + href->building_id = depot->id; + depot->jobs.push_back(job); + job->general_refs.push_back(href); + + // add to job list + Job::linkIntoWorld(job); + + return true; +} + bool Items::isRouteVehicle(df::item *item) { CHECK_NULL_POINTER(item); diff --git a/plugins/logistics.cpp b/plugins/logistics.cpp index d62ee8c36..20b2c343f 100644 --- a/plugins/logistics.cpp +++ b/plugins/logistics.cpp @@ -323,31 +323,7 @@ public: bool designate(color_ostream& out, df::item* item) override { if (!depot) return false; - - auto href = df::allocate(); - if (!href) - return false; - - auto job = new df::job(); - job->job_type = df::job_type::BringItemToDepot; - job->pos = df::coord(depot->centerx, depot->centery, depot->z); - - // job <-> item link - if (!Job::attachJobItem(job, item, df::job_item_ref::Hauled)) { - delete job; - delete href; - return false; - } - - // job <-> building link - href->building_id = depot->id; - depot->jobs.push_back(job); - job->general_refs.push_back(href); - - // add to job list - Job::linkIntoWorld(job); - - return true; + return Items::markForTrade(item, depot); } private: From c660a12502b3707da17d5767aa3a8bdf671c3bfa Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 2 Jul 2023 19:09:15 -0700 Subject: [PATCH 43/44] differentiate between choosing merchant screen and default trade screen --- library/modules/Gui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index e9ca4c411..dc6f47f59 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -333,6 +333,10 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) if (game->main_interface.trade.open) { newFocusString = baseFocus; newFocusString += "/Trade"; + if (game->main_interface.trade.choosing_merchant) + newFocusString += "/ChoosingMerchant"; + else + newFocusString += "/Default"; focusStrings.push_back(newFocusString); } if (game->main_interface.job_details.open) { From 7e92123952e8e146a43f1e8001dedb987c9bacbc Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 3 Jul 2023 11:27:13 -0700 Subject: [PATCH 44/44] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index d10407621..bf8182c73 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -46,6 +46,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Internals ## Lua +- ``dfhack.items.markForTrade``: new API for marking items for trade ## Removed