Skip to content

Commit

Permalink
merged changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
flashy-man committed Jan 14, 2024
2 parents 4e950dd + 65d86a6 commit a39ec2e
Show file tree
Hide file tree
Showing 36 changed files with 1,409 additions and 616 deletions.
13 changes: 7 additions & 6 deletions autofish.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
--@ enable=true
--@ module=true

local json = require("json")
local persist = require("persist-table")
local argparse = require("argparse")
local repeatutil = require("repeat-util")

Expand All @@ -26,16 +24,19 @@ end

--- Save the current state of the script
local function persist_state()
persist.GlobalTable[GLOBAL_KEY] = json.encode({enabled=enabled,
s_maxFish=s_maxFish, s_minFish=s_minFish, s_useRaw=s_useRaw,
isFishing=isFishing
dfhack.persistent.saveSiteData(GLOBAL_KEY, {
enabled=enabled,
s_maxFish=s_maxFish,
s_minFish=s_minFish,
s_useRaw=s_useRaw,
isFishing=isFishing,
})
end

--- Load the saved state of the script
local function load_state()
-- load persistent data
local persisted_data = json.decode(persist.GlobalTable[GLOBAL_KEY] or "") or {}
local persisted_data = dfhack.persistent.getSiteData(GLOBAL_KEY, {})
enabled = persisted_data.enabled or false
s_maxFish = persisted_data.s_maxFish or 100
s_minFish = persisted_data.s_minFish or 75
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Template for new versions:
- `control-panel`: new commandline interface for control panel functions
- `uniform-unstick`: (reinstated) force squad members to drop items that they picked up in the wrong order so they can get everything equipped properly
- `gui/reveal`: temporarily unhide terrain and then automatically hide it again when you're ready to unpause
- `gui/teleport`: mouse-driven interface for selecting and teleporting units
- `gui/biomes`: visualize and inspect biome regions on the map

## New Features
- `uniform-unstick`: add overlay to the squad equipment screen to show a equipment conflict report and give you a one-click button to fix
Expand All @@ -41,6 +43,7 @@ Template for new versions:
- `ban-cooking`: fix banning creature alcohols resulting in error
- `confirm`: properly detect clicks on the remove zone button even when the unit selection screen is also open (e.g. the vanilla assign animal to pasture panel)
- `fix/workorder-detail-fix`: fix item types not being passed properly on some modified work order jobs
- `quickfort`: if a blueprint specifies an up/down stair, but the tile the blueprint is applied to cannot make an up stair (e.g. it has already been dug out), still designate a down stair if possible

## Misc Improvements
- `gui/control-panel`: reduce frequency for `warn-stranded` check to once every 2 days
Expand All @@ -56,8 +59,10 @@ Template for new versions:
- `gui/autobutcher`: interface redesigned to better support mouse control
- `gui/launcher`: now persists the most recent 32KB of command output even if you close it and bring it back up
- `gui/quickcmd`: clickable buttons for command add/remove/edit operations
- `uniform-unstick`: warn if a unit belongs to a squad from a different site (can happen with migrants from previous forts)
- `gui/mass-remove`: can now differentiate planned constructions, stockpiles, and regular buildings
- `gui/mass-remove`: can now remove zones
- `gui/mass-remove`: can now cancel removal for buildings and constructions

## Removed

Expand Down
13 changes: 6 additions & 7 deletions control-panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

local argparse = require('argparse')
local common = reqscript('internal/control-panel/common')
local json = require('json')
local persist = require('persist-table')
local registry = reqscript('internal/control-panel/registry')
local utils = require('utils')

Expand All @@ -12,7 +10,7 @@ local GLOBAL_KEY = 'control-panel'
-- state change hooks

local function apply_system_config()
local enabled_map =common.get_enabled_map()
local enabled_map = common.get_enabled_map()
for _, data in ipairs(registry.COMMANDS_BY_IDX) do
if data.mode == 'system_enable' then
common.apply_command(data, enabled_map)
Expand All @@ -29,18 +27,19 @@ end
local function apply_autostart_config()
local enabled_map =common.get_enabled_map()
for _, data in ipairs(registry.COMMANDS_BY_IDX) do
if data.mode == 'enable' or data.mode == 'run' then
if data.mode == 'enable' or data.mode == 'run' or data.mode == 'repeat' then
common.apply_command(data, enabled_map)
end
end
end

local function apply_fort_loaded_config()
if not safe_index(json.decode(persist.GlobalTable[GLOBAL_KEY] or ''), 'autostart_done') then
local state = dfhack.persistent.getSiteData(GLOBAL_KEY, {})
if not state.autostart_done then
apply_autostart_config()
persist.GlobalTable[GLOBAL_KEY] = json.encode({autostart_done=true})
dfhack.persistent.saveSiteData(GLOBAL_KEY, {autostart_done=true})
end
local enabled_repeats = json.decode(persist.GlobalTable[common.REPEATS_GLOBAL_KEY] or '') or {}
local enabled_repeats = dfhack.persistent.getSiteData(common.REPEATS_GLOBAL_KEY, {})
for _, data in ipairs(registry.COMMANDS_BY_IDX) do
if data.mode == 'repeat' and enabled_repeats[data.command] then
common.apply_command(data)
Expand Down
21 changes: 1 addition & 20 deletions devel/prepare-save.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
-- Prepare the current save for devel/find-offsets
--[====[
devel/prepare-save
==================
.. warning::
THIS SCRIPT IS STRICTLY FOR DFHACK DEVELOPERS.
This script prepares the current savegame to be used
with `devel/find-offsets`. It CHANGES THE GAME STATE
to predefined values, and initiates an immediate
`quicksave`, thus PERMANENTLY MODIFYING the save.
]====]

local utils = require 'utils'

Expand Down Expand Up @@ -89,11 +74,7 @@ local yearstr = df.global.cur_year..','..df.global.cur_year_tick

print('Cur year and tick: '..yearstr)

dfhack.persistent.save{
key='prepare-save/cur_year',
value=yearstr,
ints={df.global.cur_year, df.global.cur_year_tick}
}
dfhack.persistent.saveSiteDataString('prepare-save/cur_year', yearstr)

-- Save

Expand Down
2 changes: 1 addition & 1 deletion docs/embark-skills.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ embark-skills

.. dfhack-tool::
:summary: Adjust dwarves' skills when embarking.
:tags: unavailable
:tags: embark armok units

When selecting starting skills for your dwarves on the embark screen, this tool
can manipulate the skill values or adjust the number of points you have
Expand Down
17 changes: 17 additions & 0 deletions docs/gui/biomes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
gui/biomes
==========

.. dfhack-tool::
:summary: Visualize and inspect biome regions on the map.
:tags: fort inspection map

This script shows the boundaries of the biome regions on the map.
Hover over a biome entry in the list to get detailed info about it.


Usage
-----

::

gui/biomes
80 changes: 46 additions & 34 deletions docs/gui/control-panel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,61 +18,73 @@ The tabs can also be navigated with the keyboard, with the :kbd:`Ctrl`:kbd:`T`
and :kbd:`Ctrl`:kbd:`Y` hotkeys. These are the default hotkeys for navigating
DFHack tab bars.

The "Enabled" tab
-----------------
The "Automation", "Bug Fixes", and "Gameplay" tabs
--------------------------------------------------

The "Enabled" tab shows tools that you can enable right now. You can select the
tool name to see a short description at the bottom of the list. Hit
These three tabs provide access to the three main subcategories of DFHack tools.
In general, you'll probably want to start with only the "Bugfix" tools enabled.
As you become more comfortable with vanilla systems, and some of them start to
become less fun and more toilsome, you can enable more of the "Automation"
tools to manage them for you. Finally, you can examine the tools on the
"Gameplay" tab and enable whatever you think sounds like fun :).

Under each of these tabs, there are two subtabs: "Enabled" and "Autostart". The
subtabs can be navigated with the keyboard, using the :kbd:`Ctrl`:kbd:`N` and
:kbd:`Ctrl`:kbd:`M` hotkeys.

The "Enabled" subtab
~~~~~~~~~~~~~~~~~~~~

The "Enabled" tab allows you to toggle which tools are enabled right now. You
can select the tool in the list to see a short description at the bottom. Hit
:kbd:`Enter`, double click on the tool name, or click on the toggle on the far
left to enable or disable that tool.

Note that before a fort is loaded, there will be very few tools listed here.
Come back when a fort is loaded to see much more.

Tools are split into three subcategories: ``automation``, ``bugfix``, and
``gameplay``. In general, you'll probably want to start with only the
``bugfix`` tools enabled. As you become more comfortable with vanilla systems,
and some of them start to become less fun and more toilsome, you can enable
more of the ``automation`` tools to manage them for you. Finally, you can
examine the tools on the ``gameplay`` tab and enable whatever you think sounds
like fun :).
Once tools are enabled, they will save their state with your fort and
automatically re-enable themselves when you load that same fort again.

The category subtabs can also be navigated with the keyboard, with the
:kbd:`Ctrl`:kbd:`N` and :kbd:`Ctrl`:kbd:`M` hotkeys.

Once tools are enabled (possible after you've loaded a fort), they will save
their state with your fort and automatically re-enable themselves when you load
that same fort again.

You can hit :kbd:`Ctrl`:kbd:`H` or click on the help icon to show the help page for the selected tool in `gui/launcher`. You can also use this as shortcut to
You can hit :kbd:`Ctrl`:kbd:`H` or click on the help icon to show the help page
for the selected tool in `gui/launcher`. You can also use this as shortcut to
run custom commandline commands to configure that tool manually. If the tool has
an associated GUI config screen, a gear icon will also appear next to the help
icon. Hit :kbd:`Ctrl`:kbd:`G`, click on the gear icon, or Shift-double click the tool name to launch the relevant configuration interface.
icon. Hit :kbd:`Ctrl`:kbd:`G`, click on the gear icon, or Shift-double click
the tool name to launch the relevant configuration interface.

.. _dfhack-examples-guide:

The "Autostart" tab
-------------------
The "Autostart" subtab
~~~~~~~~~~~~~~~~~~~~~~

This tab is organized similarly to the "Enabled" tab, but instead of tools you
can enable now, it shows the tools that you can configure DFHack to auto-enable
or auto-run when you start the game or a new fort. You'll recognize many tools
from the "Enabled" tab here, but there are also useful one-time commands that
you might want to run at the start of a fort, like
`ban-cooking all <ban-cooking>`.
This subtab is organized similarly to the "Enabled" subtab, but instead of
tools you can enable now, it shows the tools that you can configure DFHack to
auto-enable or auto-run when you start the game or a new fort. You'll recognize
many tools from the "Enabled" subtab here, but there are also useful one-time
commands that you might want to run at the start of a fort, like
`ban-cooking all <ban-cooking>` or (if you have "mortal mode" disabled in the
"Preferences" tab) god-mode tools like `light-aquifers-only`.

The "UI Overlays" tab
---------------------

The overlays tab allows you to easily see which overlays are enabled, lets you
toggle them on and off, and gives you links for the related help text (which is
normally added at the bottom of the help page for the tool that provides the
overlay). If you want to reposition any of the overlay widgets, hit
:kbd:`Ctrl`:kbd:`G` or click on the the hotkey hint to launch `gui/overlay`.
DFHack overlays add information and additional functionality to the vanilla DF
screens. For example, the popular DFHack `Building Planner <buildingplan>` is
an overlay named ``buildingplan.planner`` that appears when you are building
something.

The "Overlays" tab allows you to easily see which overlays are enabled, gives
you a short description of what each one does, lets you toggle them on and off,
and gives you links for the related help text (which is normally added at the
bottom of the help page for the tool that provides the overlay). If you want to
reposition any of the overlay widgets, hit :kbd:`Ctrl`:kbd:`G` or click on the
the hotkey hint to launch `gui/overlay`.

The "Preferences" tab
---------------------

The preferences tab allows you to change DFHack's internal settings and
The "Preferences" tab allows you to change DFHack's internal settings and
defaults, like whether DFHack's "mortal mode" is enabled -- hiding the god-mode
tools from the UI, whether DFHack tools pause the game when they come up, or how
long you can take between clicks and still have it count as a double-click.
Expand Down
7 changes: 4 additions & 3 deletions docs/gui/reveal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Examples
``gui/reveal``
Reveal all "normal" terrain, but keep areas with late-game surprises hidden.
``gui/reveal hell``
Fully reveal adamantine spires, gemstone pillars, and the underworld. Note
that keeping these areas unrevealed when you exit `gui/reveal` will trigger
all the surprise events immediately.
Fully reveal adamantine spires, gemstone pillars, and the underworld. The
game cannot be unpaused with these features revealed, so the choice to keep
the map unrevealed when you close `gui/reveal` is disabled when this option
is specified.
16 changes: 12 additions & 4 deletions docs/gui/teleport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ gui/teleport
============

.. dfhack-tool::
:summary: Teleport a unit anywhere.
:tags: unavailable
:summary: Teleport units anywhere.
:tags: fort armok units

This tool is a front-end for the `teleport` tool. It allows you to interactively
choose a unit to teleport and a destination tile using the in-game cursor.
This tool allows you to interactively select units to teleport by drawing boxes
around them on the map. Double clicking on a destination tile will teleport the selected units there.

If a unit is already selected in the UI when you run `gui/teleport`, it will be
pre-selected for teleport.

Note that you *can* select enemies that are lying in ambush and are not visible
on the map yet, so you if you select an area and see a marker that indicates
that a unit is selected, but you don't see the unit itself, this is likely what
it is. You can stil teleport these units while they are hidden.

Usage
-----
Expand Down
16 changes: 8 additions & 8 deletions embark-skills.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function adjust(dwarves, callback)
end

local scr = dfhack.gui.getCurViewscreen() --as:df.viewscreen_setupdwarfgamest
if dfhack.gui.getCurFocus() ~= 'setupdwarfgame' or scr.show_play_now == 1 then
qerror('Must be called on the "Prepare carefully" screen')
if not dfhack.gui.matchFocusString('setupdwarfgame/Dwarves', scr) then
qerror('Must be called on the "Prepare carefully" screen, "Dwarves" tab')
end

local dwarf_info = scr.dwarf_info
local dwarves = dwarf_info
local selected_dwarf = {[0] = scr.dwarf_info[scr.dwarf_cursor]} --as:df.setup_character_info[]
local selected_dwarf = {[0] = scr.dwarf_info[scr.selected_u]} --as:df.setup_character_info[]

local args = {...}
if args[1] == 'points' then
Expand All @@ -58,20 +58,20 @@ if args[1] == 'points' then
end
if args[3] ~= 'all' then dwarves = selected_dwarf end
adjust(dwarves, function(dwf)
dwf.skill_points_remaining = points
dwf.skill_picks_left = points
end)
elseif args[1] == 'max' then
if args[2] ~= 'all' then dwarves = selected_dwarf end
adjust(dwarves, function(dwf)
for skill, level in pairs(dwf.skills) do
dwf.skills[skill] = df.skill_rating.Proficient
for skill, level in pairs(dwf.skilllevel) do
dwf.skilllevel[skill] = df.skill_rating.Proficient
end
end)
elseif args[1] == 'legendary' then
if args[2] ~= 'all' then dwarves = selected_dwarf end
adjust(dwarves, function(dwf)
for skill, level in pairs(dwf.skills) do
dwf.skills[skill] = df.skill_rating.Legendary5
for skill, level in pairs(dwf.skilllevel) do
dwf.skilllevel[skill] = df.skill_rating.Legendary5
end
end)
else
Expand Down
9 changes: 3 additions & 6 deletions emigration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
--@module = true
--@enable = true

local json = require('json')
local persist = require('persist-table')

local GLOBAL_KEY = 'emigration' -- used for state change hooks and persistence

enabled = enabled or false
Expand All @@ -16,7 +13,7 @@ function isEnabled()
end

local function persist_state()
persist.GlobalTable[GLOBAL_KEY] = json.encode({enabled=enabled})
dfhack.persistent.saveSiteData(GLOBAL_KEY, {enabled=enabled})
end

function desireToStay(unit,method,civ_id)
Expand Down Expand Up @@ -215,8 +212,8 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
return
end

local persisted_data = json.decode(persist.GlobalTable[GLOBAL_KEY] or '')
enabled = (persisted_data or {enabled=false})['enabled']
local persisted_data = dfhack.persistent.getSiteData(GLOBAL_KEY, {enabled=false})
enabled = persisted_data.enabled
event_loop()
end

Expand Down
Loading

0 comments on commit a39ec2e

Please sign in to comment.