Skip to content

Commit 0561f09

Browse files
committed
don't intercept string input when player is editing name
1 parent c82195b commit 0561f09

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

plugins/lua/preserve-rooms.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ DEBUG = DEBUG or false
1515
--
1616

1717
-- updated on world load
18-
local code_lookup = {}
18+
code_lookup = code_lookup or {}
1919

2020
function assignToRole(code, bld)
2121
local group_codes = code_lookup[code:lower()]
@@ -111,7 +111,7 @@ ReservedWidget.ATTRS{
111111
version=2,
112112
}
113113

114-
local new_world_loaded = true
114+
new_world_loaded = true
115115

116116
local CONFLICTING_TOOLTIPS = utils.invert{
117117
df.main_hover_instruction.ZoneRepaint,
@@ -222,15 +222,19 @@ end
222222
local mi = df.global.game.main_interface
223223

224224
function ReservedWidget:onInput(keys)
225-
if not CONFLICTING_TOOLTIPS[mi.current_hover] and ReservedWidget.super.onInput(self, keys) then
226-
return true
227-
end
228225
if keys._MOUSE_L and
229226
(preserve_rooms_isReserved() or preserve_rooms_getRoleAssignment() ~= '')
230227
then
231228
if self.subviews.pause_mask:getMousePos() then return true end
232229
if self.subviews.add_mask:getMousePos() then return true end
233230
end
231+
if CONFLICTING_TOOLTIPS[mi.current_hover] then
232+
return false
233+
end
234+
if mi.entering_building_name and keys._STRING then
235+
return false
236+
end
237+
return ReservedWidget.super.onInput(self, keys)
234238
end
235239

236240
function ReservedWidget:render(dc)
@@ -276,7 +280,7 @@ local function add_options(options, choices, codes)
276280
end
277281

278282
-- updated on world load
279-
local codes = {}
283+
codes = codes or {}
280284

281285
function ReservedWidget:refresh_role_list()
282286
local options, choices = {{label='None', value={''}, pen=COLOR_YELLOW}}, {'None'}

0 commit comments

Comments
 (0)