Skip to content

Commit

Permalink
Merge branch 'master' into worship_spam
Browse files Browse the repository at this point in the history
  • Loading branch information
Bumber64 authored Sep 28, 2024
2 parents 50f3f8b + edd662a commit f2aaeb8
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 86 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ Template for new versions:
## New Features

## Fixes
- `gui/quickfort`: only print a help blueprint's text once even if the repeat setting is enabled

## Misc Improvements
- `control-panel`: Add realistic-melting tweak to control-panel registry
- `idle-crafting`: also support making shell crafts for workshops with linked input stockpiles
- `fix/stuck-worship`: reduced console output by default. ``--verbose`` option to print all affected units.

## Removed
Expand Down
2 changes: 1 addition & 1 deletion docs/exterminate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Options
``-m``, ``--method <method>``
Specifies the "method" of killing units. See below for details.
``-o``, ``--only-visible``
Specifies the tool should only kill units visible to the player.
Specifies the tool should only kill units visible to the player
on the map.
``-f``, ``--include-friendly``
Specifies the tool should also kill units friendly to the player.
Expand Down
83 changes: 52 additions & 31 deletions docs/gui/journal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,68 @@ gui/journal
The `gui/journal` interface makes it easy to take notes and document
important details for the fortresses.

With this multi-line text editor,
you can keep track of your fortress's background story, goals, notable events,
and both short-term and long-term plans.
With this multi-line text editor, you can keep track of your fortress's
background story, goals, notable events, and both short- and long-term plans.

This is particularly useful when you need to take a longer break from the game.
Having detailed notes makes it much easier to resume your game after
a few weeks or months, without losing track of your progress and objectives.
Having detailed notes makes it much easier to resume your game after a few
weeks or months without losing track of your progress and objectives.

Supported Features
------------------

- Cursor Control: Navigate through text using arrow keys (left, right, up, down) for precise cursor placement.
- Fast Rewind: Use :kbd:`Ctrl` + :kbd:`Left` / :kbd:`Ctrl` + :kbd:`B` and :kbd:`Ctrl` + :kbd:`Right` / :kbd:`Ctrl` + :kbd:`F` to move the cursor one word back or forward.
- Longest X Position Memory: The cursor remembers the longest x position when moving up or down, making vertical navigation more intuitive.
- Mouse Control: Use the mouse to position the cursor within the text, providing an alternative to keyboard navigation.
- New Lines: Easily insert new lines using the :kbd:`Enter` key, supporting multiline text input.
- Text Wrapping: Text automatically wraps within the editor, ensuring lines fit within the display without manual adjustments.
- Backspace Support: Use the backspace key to delete characters to the left of the cursor.
- Delete Character: :kbd:`Ctrl` + :kbd:`D` deletes the character under the cursor.
- Line Navigation: :kbd:`Ctrl` + :kbd:`H` (like "Home") moves the cursor to the beginning of the current line, and :kbd:`Ctrl` + :kbd:`E` (like "End") moves it to the end.
- Delete Current Line: :kbd:`Ctrl` + :kbd:`U` deletes the entire current line where the cursor is located.
- Delete Rest of Line: :kbd:`Ctrl` + :kbd:`K` deletes text from the cursor to the end of the line.
- Delete Last Word: :kbd:`Ctrl` + :kbd:`W` removes the word immediately before the cursor.
- Text Selection: Select text with the mouse, with support for replacing or removing selected text.
- Jump to Beginning/End: Quickly move the cursor to the beginning or end of the text using :kbd:`Shift` + :kbd:`Up` and :kbd:`Shift` + :kbd:`Down`.
- Select Word/Line: Use double click to select current word, or triple click to select current line
- Cursor Control: Navigate through text using arrow keys (Left, Right, Up,
and Down) for precise cursor placement.
- Fast Rewind: Use :kbd:`Ctrl` + :kbd:`Left` and :kbd:`Ctrl` + :kbd:`Right` to
move the cursor one word back or forward.
- Longest X Position Memory: The cursor remembers the longest x position when
moving up or down, making vertical navigation more intuitive.
- Mouse Control: Use the mouse to position the cursor within the text,
providing an alternative to keyboard navigation.
- New Lines: Easily insert new lines using the :kbd:`Enter` key, supporting
multiline text input.
- Text Wrapping: Text automatically wraps within the editor, ensuring lines fit
within the display without manual adjustments.
- Backspace Support: Use the backspace key to delete characters to the left of
the cursor.
- Delete Character: :kbd:`Delete` deletes the character under the cursor.
- Line Navigation: :kbd:`Home` moves the cursor to the beginning of the current
line, and :kbd:`End` moves it to the end.
- Delete Current Line: :kbd:`Ctrl` + :kbd:`U` deletes the entire current line
where the cursor is located.
- Delete Rest of Line: :kbd:`Ctrl` + :kbd:`K` deletes text from the cursor to
the end of the line.
- Delete Last Word: :kbd:`Ctrl` + :kbd:`W` removes the word immediately before
the cursor.
- Text Selection: Select text with the mouse, with support for replacing or
removing selected text.
- Jump to Beginning/End: Quickly move the cursor to the beginning or end of the
text using :kbd:`Ctrl` + :kbd:`Home` and :kbd:`Ctrl` + :kbd:`End`.
- Select Word/Line: Use double click to select current word, or triple click to
select current line
- Select All: Select entire text by :kbd:`Ctrl` + :kbd:`A`
- Undo/Redo: Undo/Redo changes by :kbd:`Ctrl` + :kbd:`Z` / :kbd:`Ctrl` + :kbd:`Y`
- Clipboard Operations: Perform OS clipboard cut, copy, and paste operations on selected text, allowing you to paste the copied content into other applications.
- Undo/Redo: Undo/Redo changes by :kbd:`Ctrl` + :kbd:`Z` / :kbd:`Ctrl` +
:kbd:`Y`
- Clipboard Operations: Perform OS clipboard cut, copy, and paste operations on
selected text, allowing you to paste the copied content into other
applications.
- Copy Text: Use :kbd:`Ctrl` + :kbd:`C` to copy selected text.
- copy selected text, if available
- If no text is selected it copy the entire current line, including the terminating newline if present.
- copy selected text, if available
- If no text is selected it copy the entire current line, including the
terminating newline if present.
- Cut Text: Use :kbd:`Ctrl` + :kbd:`X` to cut selected text.
- cut selected text, if available
- If no text is selected it will cut the entire current line, including the terminating newline if present
- Paste Text: Use :kbd:`Ctrl` + :kbd:`V` to paste text from the clipboard into the editor.
- replace selected text, if available
- If no text is selected, paste text in the cursor position
- cut selected text, if available
- If no text is selected it will cut the entire current line, including the
terminating newline if present
- Paste Text: Use :kbd:`Ctrl` + :kbd:`V` to paste text from the clipboard into
the editor.
- replace selected text, if available
- If no text is selected, paste text in the cursor position
- Scrolling behaviour for long text build-in
- Table of contents (:kbd:`Ctrl` + :kbd:`O`), with headers line prefixed by '#', e.g. '# Fort history', '## Year 1'
- Table of contents navigation: jump to previous/next section by :kbd:`Ctrl` + :kbd:`Up` / :kbd:`Ctrl` + :kbd:`Down`
- Table of contents (:kbd:`Ctrl` + :kbd:`O`), with headers line prefixed by
``#``, e.g. ``# Fort history``, ``## Year 1``
- Table of contents navigation: jump to previous/next section by :kbd:`Ctrl` +
:kbd:`Up` / :kbd:`Ctrl` + :kbd:`Down`

Usage
-----
Expand Down
8 changes: 4 additions & 4 deletions docs/idle-crafting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ supported, with stonecrafting being the default option. Thus, to designate a
workshop for bone carving, disable the stonecrafting labor while keeping the
bone carving labor enabled.

For workshops with input stockpile links, the creation of totems and horn crafts
are supported as well. In this case, the choice of job is made randomly based on
the resources available in the input stockpiles (respecting the permitted
labors from the workshop profile).
For workshops with input stockpile links, the creation of totems, shell crafts,
and horn crafts are supported as well. In this case, the choice of job is made
randomly based on the resources available in the input stockpiles (respecting
the permitted labors from the workshop profile).
2 changes: 1 addition & 1 deletion docs/position.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ position

.. dfhack-tool::
:summary: Report cursor and mouse position, along with other info.
:tags: adventure fort inspection map
:tags: adventure dfhack fort inspection map

This tool reports the current date, clock time, month, season, and historical
era. It also reports the keyboard cursor position (or just the z-level if no
Expand Down
29 changes: 29 additions & 0 deletions idle-crafting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,31 @@ function makeBoneCraft(unit, workshop)
return dfhack.job.addWorker(job, unit)
end

---make shell crafts at specified workshop
---@param unit df.unit
---@param workshop df.building_workshopst
---@return boolean
function makeShellCraft(unit, workshop)
local job = make_job()
job.job_type = df.job_type.MakeCrafts
job.mat_type = -1
job.material_category.shell = true

local jitem = df.job_item:new()
jitem.item_type = df.item_type.NONE
jitem.mat_type = -1
jitem.mat_index = -1
jitem.quantity = 1
jitem.vector_id = df.job_item_vector_id.ANY_REFUSE
jitem.flags1.unrotten = true
jitem.flags2.shell = true
jitem.flags2.body_part = true
job.job_items.elements:insert('#', jitem)

assignToWorkshop(job, workshop)
return dfhack.job.addWorker(job, unit)
end

---make rock crafts at specified workshop
---@param unit df.unit
---@param workshop df.building_workshopst
Expand Down Expand Up @@ -177,6 +202,8 @@ local function categorize_craft(tab,item)
tab['skull'] = (tab['skull'] or 0) + 1
elseif item.corpse_flags.horn then
tab['horn'] = (tab['horn'] or 0) + item.material_amount.Horn
elseif item.corpse_flags.shell then
tab['shell'] = (tab['shell'] or 0) + 1
end
elseif df.item_boulderst:is_instance(item) then
tab['boulder'] = (tab['boulder'] or 0) + 1
Expand Down Expand Up @@ -310,11 +337,13 @@ function select_crafting_job(workshop)
tab['bone'] = nil
tab['skull'] = nil
tab['horn'] = nil
tab['shell'] = nil
end
local material = weightedChoice(tab)
if material == 'bone' then return makeBoneCraft
elseif material == 'skull' then return makeTotem
elseif material == 'horn' then return makeHornCrafts
elseif material == 'shell' then return makeShellCraft
elseif material == 'boulder' then return makeRockCraft
else
return nil
Expand Down
2 changes: 2 additions & 0 deletions internal/control-panel/registry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ COMMANDS_BY_IDX = {
{command='partial-items', help_command='tweak', group='gameplay', mode='tweak', default=true,
desc='Displays percentages on partially-consumed items like hospital cloth.'},
{command='pop-control', group='gameplay', mode='enable'},
{command='realistic-melting', help_command='tweak', group='gameplay', mode='tweak',
desc='Adjust selected item types melt return for all metals to ~95% of forging cost. Reduce melt return by 10% per wear level.'},
{command='starvingdead', group='gameplay', mode='enable'},
{command='timestream', group='gameplay', mode='enable'},
{command='work-now', group='gameplay', mode='enable'},
Expand Down
15 changes: 7 additions & 8 deletions internal/journal/text_editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -761,30 +761,30 @@ function TextEditorView:onCursorInput(keys)
self:setCursor(offset)
self.last_cursor_x = last_cursor_x
return true
elseif keys.KEYBOARD_CURSOR_UP_FAST then
elseif keys.CUSTOM_CTRL_HOME then
self:setCursor(1)
return true
elseif keys.KEYBOARD_CURSOR_DOWN_FAST then
elseif keys.CUSTOM_CTRL_END then
-- go to text end
self:setCursor(#self.text + 1)
return true
elseif keys.CUSTOM_CTRL_B or keys.A_MOVE_W_DOWN then
elseif keys.CUSTOM_CTRL_LEFT then
-- back one word
local word_start = self:wordStartOffset()
self:setCursor(word_start)
return true
elseif keys.CUSTOM_CTRL_F or keys.A_MOVE_E_DOWN then
elseif keys.CUSTOM_CTRL_RIGHT then
-- forward one word
local word_end = self:wordEndOffset()
self:setCursor(word_end)
return true
elseif keys.CUSTOM_CTRL_H then
elseif keys.CUSTOM_HOME then
-- line start
self:setCursor(
self:lineStartOffset()
)
return true
elseif keys.CUSTOM_CTRL_E then
elseif keys.CUSTOM_END then
-- line end
self:setCursor(
self:lineEndOffset()
Expand Down Expand Up @@ -878,8 +878,7 @@ function TextEditorView:onTextManipulationInput(keys)
self:eraseSelection()

return true
elseif keys.CUSTOM_CTRL_D then
-- delete char, there is no support for `Delete` key
elseif keys.CUSTOM_DELETE then
self.history:store(HISTORY_ENTRY.DELETE, self.text, self.cursor)

if (self:hasSelection()) then
Expand Down
6 changes: 5 additions & 1 deletion internal/quickfort/notes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ function do_run(_, grid, ctx)
if #line > 0 then
table.insert(lines, table.concat(line, ' '))
end
table.insert(ctx.messages, table.concat(lines, '\n'))
local message = table.concat(lines, '\n')
if not ctx.messages_set[message] then
table.insert(ctx.messages, message)
ctx.messages_set[message] = true
end
end

function do_orders()
Expand Down
2 changes: 1 addition & 1 deletion modtools/reaction-trigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ local validArgs = utils.invert({
'allowMultipleTargets',
'range',
'ignoreWorker',
'dontSkipInactive',
'dontSkipInactive', --TODO: positions for inactive units are meaningless!
'resetPolicy'
})

Expand Down
Loading

0 comments on commit f2aaeb8

Please sign in to comment.