Skip to content

Commit c25da7d

Browse files
authored
Merge branch 'DFHack:master' into active_units
2 parents c1b23c7 + c142a76 commit c25da7d

File tree

7 files changed

+136
-82
lines changed

7 files changed

+136
-82
lines changed

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Template for new versions:
3333
## Fixes
3434

3535
## Misc Improvements
36+
- `control-panel`: Add realistic-melting tweak to control-panel registry
37+
38+
- `idle-crafting`: also support making shell crafts for workshops with linked input stockpiles
3639

3740
## Removed
3841

docs/gui/journal.rst

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,68 @@ gui/journal
88
The `gui/journal` interface makes it easy to take notes and document
99
important details for the fortresses.
1010

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

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

1918
Supported Features
2019
------------------
2120

22-
- Cursor Control: Navigate through text using arrow keys (left, right, up, down) for precise cursor placement.
23-
- 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.
24-
- Longest X Position Memory: The cursor remembers the longest x position when moving up or down, making vertical navigation more intuitive.
25-
- Mouse Control: Use the mouse to position the cursor within the text, providing an alternative to keyboard navigation.
26-
- New Lines: Easily insert new lines using the :kbd:`Enter` key, supporting multiline text input.
27-
- Text Wrapping: Text automatically wraps within the editor, ensuring lines fit within the display without manual adjustments.
28-
- Backspace Support: Use the backspace key to delete characters to the left of the cursor.
29-
- Delete Character: :kbd:`Ctrl` + :kbd:`D` deletes the character under the cursor.
30-
- 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.
31-
- Delete Current Line: :kbd:`Ctrl` + :kbd:`U` deletes the entire current line where the cursor is located.
32-
- Delete Rest of Line: :kbd:`Ctrl` + :kbd:`K` deletes text from the cursor to the end of the line.
33-
- Delete Last Word: :kbd:`Ctrl` + :kbd:`W` removes the word immediately before the cursor.
34-
- Text Selection: Select text with the mouse, with support for replacing or removing selected text.
35-
- 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`.
36-
- Select Word/Line: Use double click to select current word, or triple click to select current line
21+
- Cursor Control: Navigate through text using arrow keys (Left, Right, Up,
22+
and Down) for precise cursor placement.
23+
- Fast Rewind: Use :kbd:`Ctrl` + :kbd:`Left` and :kbd:`Ctrl` + :kbd:`Right` to
24+
move the cursor one word back or forward.
25+
- Longest X Position Memory: The cursor remembers the longest x position when
26+
moving up or down, making vertical navigation more intuitive.
27+
- Mouse Control: Use the mouse to position the cursor within the text,
28+
providing an alternative to keyboard navigation.
29+
- New Lines: Easily insert new lines using the :kbd:`Enter` key, supporting
30+
multiline text input.
31+
- Text Wrapping: Text automatically wraps within the editor, ensuring lines fit
32+
within the display without manual adjustments.
33+
- Backspace Support: Use the backspace key to delete characters to the left of
34+
the cursor.
35+
- Delete Character: :kbd:`Delete` deletes the character under the cursor.
36+
- Line Navigation: :kbd:`Home` moves the cursor to the beginning of the current
37+
line, and :kbd:`End` moves it to the end.
38+
- Delete Current Line: :kbd:`Ctrl` + :kbd:`U` deletes the entire current line
39+
where the cursor is located.
40+
- Delete Rest of Line: :kbd:`Ctrl` + :kbd:`K` deletes text from the cursor to
41+
the end of the line.
42+
- Delete Last Word: :kbd:`Ctrl` + :kbd:`W` removes the word immediately before
43+
the cursor.
44+
- Text Selection: Select text with the mouse, with support for replacing or
45+
removing selected text.
46+
- Jump to Beginning/End: Quickly move the cursor to the beginning or end of the
47+
text using :kbd:`Ctrl` + :kbd:`Home` and :kbd:`Ctrl` + :kbd:`End`.
48+
- Select Word/Line: Use double click to select current word, or triple click to
49+
select current line
3750
- Select All: Select entire text by :kbd:`Ctrl` + :kbd:`A`
38-
- Undo/Redo: Undo/Redo changes by :kbd:`Ctrl` + :kbd:`Z` / :kbd:`Ctrl` + :kbd:`Y`
39-
- Clipboard Operations: Perform OS clipboard cut, copy, and paste operations on selected text, allowing you to paste the copied content into other applications.
51+
- Undo/Redo: Undo/Redo changes by :kbd:`Ctrl` + :kbd:`Z` / :kbd:`Ctrl` +
52+
:kbd:`Y`
53+
- Clipboard Operations: Perform OS clipboard cut, copy, and paste operations on
54+
selected text, allowing you to paste the copied content into other
55+
applications.
4056
- Copy Text: Use :kbd:`Ctrl` + :kbd:`C` to copy selected text.
41-
- copy selected text, if available
42-
- If no text is selected it copy the entire current line, including the terminating newline if present.
57+
- copy selected text, if available
58+
- If no text is selected it copy the entire current line, including the
59+
terminating newline if present.
4360
- Cut Text: Use :kbd:`Ctrl` + :kbd:`X` to cut selected text.
44-
- cut selected text, if available
45-
- If no text is selected it will cut the entire current line, including the terminating newline if present
46-
- Paste Text: Use :kbd:`Ctrl` + :kbd:`V` to paste text from the clipboard into the editor.
47-
- replace selected text, if available
48-
- If no text is selected, paste text in the cursor position
61+
- cut selected text, if available
62+
- If no text is selected it will cut the entire current line, including the
63+
terminating newline if present
64+
- Paste Text: Use :kbd:`Ctrl` + :kbd:`V` to paste text from the clipboard into
65+
the editor.
66+
- replace selected text, if available
67+
- If no text is selected, paste text in the cursor position
4968
- Scrolling behaviour for long text build-in
50-
- Table of contents (:kbd:`Ctrl` + :kbd:`O`), with headers line prefixed by '#', e.g. '# Fort history', '## Year 1'
51-
- Table of contents navigation: jump to previous/next section by :kbd:`Ctrl` + :kbd:`Up` / :kbd:`Ctrl` + :kbd:`Down`
69+
- Table of contents (:kbd:`Ctrl` + :kbd:`O`), with headers line prefixed by
70+
``#``, e.g. ``# Fort history``, ``## Year 1``
71+
- Table of contents navigation: jump to previous/next section by :kbd:`Ctrl` +
72+
:kbd:`Up` / :kbd:`Ctrl` + :kbd:`Down`
5273

5374
Usage
5475
-----

docs/idle-crafting.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ supported, with stonecrafting being the default option. Thus, to designate a
5454
workshop for bone carving, disable the stonecrafting labor while keeping the
5555
bone carving labor enabled.
5656

57-
For workshops with input stockpile links, the creation of totems and horn crafts
58-
are supported as well. In this case, the choice of job is made randomly based on
59-
the resources available in the input stockpiles (respecting the permitted
60-
labors from the workshop profile).
57+
For workshops with input stockpile links, the creation of totems, shell crafts,
58+
and horn crafts are supported as well. In this case, the choice of job is made
59+
randomly based on the resources available in the input stockpiles (respecting
60+
the permitted labors from the workshop profile).

idle-crafting.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,31 @@ function makeBoneCraft(unit, workshop)
143143
return dfhack.job.addWorker(job, unit)
144144
end
145145

146+
---make shell crafts at specified workshop
147+
---@param unit df.unit
148+
---@param workshop df.building_workshopst
149+
---@return boolean
150+
function makeShellCraft(unit, workshop)
151+
local job = make_job()
152+
job.job_type = df.job_type.MakeCrafts
153+
job.mat_type = -1
154+
job.material_category.shell = true
155+
156+
local jitem = df.job_item:new()
157+
jitem.item_type = df.item_type.NONE
158+
jitem.mat_type = -1
159+
jitem.mat_index = -1
160+
jitem.quantity = 1
161+
jitem.vector_id = df.job_item_vector_id.ANY_REFUSE
162+
jitem.flags1.unrotten = true
163+
jitem.flags2.shell = true
164+
jitem.flags2.body_part = true
165+
job.job_items.elements:insert('#', jitem)
166+
167+
assignToWorkshop(job, workshop)
168+
return dfhack.job.addWorker(job, unit)
169+
end
170+
146171
---make rock crafts at specified workshop
147172
---@param unit df.unit
148173
---@param workshop df.building_workshopst
@@ -177,6 +202,8 @@ local function categorize_craft(tab,item)
177202
tab['skull'] = (tab['skull'] or 0) + 1
178203
elseif item.corpse_flags.horn then
179204
tab['horn'] = (tab['horn'] or 0) + item.material_amount.Horn
205+
elseif item.corpse_flags.shell then
206+
tab['shell'] = (tab['shell'] or 0) + 1
180207
end
181208
elseif df.item_boulderst:is_instance(item) then
182209
tab['boulder'] = (tab['boulder'] or 0) + 1
@@ -310,11 +337,13 @@ function select_crafting_job(workshop)
310337
tab['bone'] = nil
311338
tab['skull'] = nil
312339
tab['horn'] = nil
340+
tab['shell'] = nil
313341
end
314342
local material = weightedChoice(tab)
315343
if material == 'bone' then return makeBoneCraft
316344
elseif material == 'skull' then return makeTotem
317345
elseif material == 'horn' then return makeHornCrafts
346+
elseif material == 'shell' then return makeShellCraft
318347
elseif material == 'boulder' then return makeRockCraft
319348
else
320349
return nil

internal/control-panel/registry.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ COMMANDS_BY_IDX = {
125125
{command='partial-items', help_command='tweak', group='gameplay', mode='tweak', default=true,
126126
desc='Displays percentages on partially-consumed items like hospital cloth.'},
127127
{command='pop-control', group='gameplay', mode='enable'},
128+
{command='realistic-melting', help_command='tweak', group='gameplay', mode='tweak',
129+
desc='Adjust selected item types melt return for all metals to ~95% of forging cost. Reduce melt return by 10% per wear level.'},
128130
{command='starvingdead', group='gameplay', mode='enable'},
129131
{command='timestream', group='gameplay', mode='enable'},
130132
{command='work-now', group='gameplay', mode='enable'},

internal/journal/text_editor.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -761,30 +761,30 @@ function TextEditorView:onCursorInput(keys)
761761
self:setCursor(offset)
762762
self.last_cursor_x = last_cursor_x
763763
return true
764-
elseif keys.KEYBOARD_CURSOR_UP_FAST then
764+
elseif keys.CUSTOM_CTRL_HOME then
765765
self:setCursor(1)
766766
return true
767-
elseif keys.KEYBOARD_CURSOR_DOWN_FAST then
767+
elseif keys.CUSTOM_CTRL_END then
768768
-- go to text end
769769
self:setCursor(#self.text + 1)
770770
return true
771-
elseif keys.CUSTOM_CTRL_B or keys.A_MOVE_W_DOWN then
771+
elseif keys.CUSTOM_CTRL_LEFT then
772772
-- back one word
773773
local word_start = self:wordStartOffset()
774774
self:setCursor(word_start)
775775
return true
776-
elseif keys.CUSTOM_CTRL_F or keys.A_MOVE_E_DOWN then
776+
elseif keys.CUSTOM_CTRL_RIGHT then
777777
-- forward one word
778778
local word_end = self:wordEndOffset()
779779
self:setCursor(word_end)
780780
return true
781-
elseif keys.CUSTOM_CTRL_H then
781+
elseif keys.CUSTOM_HOME then
782782
-- line start
783783
self:setCursor(
784784
self:lineStartOffset()
785785
)
786786
return true
787-
elseif keys.CUSTOM_CTRL_E then
787+
elseif keys.CUSTOM_END then
788788
-- line end
789789
self:setCursor(
790790
self:lineEndOffset()
@@ -878,8 +878,7 @@ function TextEditorView:onTextManipulationInput(keys)
878878
self:eraseSelection()
879879

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

885884
if (self:hasSelection()) then

0 commit comments

Comments
 (0)