Skip to content

Commit

Permalink
Merge pull request #1368 from myk002/myk_embark_fix
Browse files Browse the repository at this point in the history
[gui/rename] allow units to be given nicknames on the embark screen
  • Loading branch information
myk002 authored Jan 10, 2025
2 parents f071f7a + def1165 commit f146fa3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Template for new versions:
- `gui/settings-manager`: new overlay on the Labor -> Standing Orders tab for configuring the number of barrels to reserve for job use (so you can brew alcohol and not have all your barrels claimed by stockpiles for container storage)
- `gui/settings-manager`: standing orders save/load now includes the reserved barrels setting
- `gui/rename`: add overlay to worldgen screen allowing you to rename the world before the new world is saved
- `gui/rename`: add overlay to the "Prepare carefully" embark screen that transparently fixes a DF bug where you can't give units nicknames or custom professions

## Fixes
- `fix/dry-buckets`: don't empty buckets for wells that are actively in use
Expand Down
3 changes: 3 additions & 0 deletions docs/gui/rename.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ This tool supports the following overlays:

``gui/rename.world``
Adds a widget to the world generation screen for renaming the world.
``gui/rename.unit_embark``
Transparently fixes DF :bug:`12060` on the "Prepare carefully" embark screen
where the player is unable to give units nicknames or custom professions.
60 changes: 60 additions & 0 deletions gui/rename.lua
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,67 @@ function WorldRenameOverlay:init()
}
end

--
-- UnitEmbarkRenameOverlay
--

local mi = df.global.game.main_interface

UnitEmbarkRenameOverlay = defclass(UnitEmbarkRenameOverlay, overlay.OverlayWidget)
UnitEmbarkRenameOverlay.ATTRS {
desc='Allows editing of unit nicknames on the embark preparation screen.',
default_enabled=true,
viewscreens='setupdwarfgame/Dwarves',
fullscreen=true,
active=function() return mi.view_sheets.open end,
}

local function get_selected_embark_unit()
local scr = dfhack.gui.getDFViewscreen(true)
return scr.s_unit[scr.selected_u]
end

function UnitEmbarkRenameOverlay:onInput(keys)
if (keys.SELECT or keys._STRING) and mi.view_sheets.unit_overview_customizing then
if mi.view_sheets.unit_overview_entering_nickname then
if keys.SELECT then
mi.view_sheets.unit_overview_entering_nickname = false
return true
end
local unit = get_selected_embark_unit()
if unit then
if keys._STRING == 0 then
unit.name.nickname = string.sub(unit.name.nickname, 1, -2)
else
unit.name.nickname = unit.name.nickname .. string.char(keys._STRING)
end
local hf = df.historical_figure.find(unit.hist_figure_id)
if hf then
hf.name.nickname = unit.name.nickname
end
return true
end
elseif mi.view_sheets.unit_overview_entering_profession_nickname then
if keys.SELECT then
mi.view_sheets.unit_overview_entering_profession_nickname = false
return true
end
local unit = get_selected_embark_unit()
if unit then
if keys._STRING == 0 then
unit.custom_profession = string.sub(unit.custom_profession, 1, -2)
else
unit.custom_profession = unit.custom_profession .. string.char(keys._STRING)
end
return true
end
end
end
return false
end

OVERLAY_WIDGETS = {
unit_embark=UnitEmbarkRenameOverlay,
world=WorldRenameOverlay,
}

Expand Down

0 comments on commit f146fa3

Please sign in to comment.