Build menu hotkey is not working when loading the campaign game
- Dominant language
- Lua
- Stars
- 264
- Forks
- 260
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 21
Description
**Describe the bug**
Loading the saved campaign game in the offline mode results in the build menu hotkey not being functional.
[bad.log](https://github.com/FAForever/fa/files/15271698/bad.log)
**To Reproduce**
- Run the client with `./run-offline`
- Start any campaign map
- Save the game
- Load saved game
- Hit "B" on your engies to activate build menu
**Expected behavior**
The build menu is supposed to be activated, and build hotkeys are supposed to be overlayed on top of build icons
**Additional context**
It looks like missing `HandleEvent` is the problem in the `gamemain.lua` module:
```
DEBUG: -> -> Loading module: /lua/ui/game/construction.lua
DEBUG: -> -> -> Loading module: /lua/ui/controls/specialgrid.lua
DEBUG: -> -> -> Loading module: /lua/maui/statusbar.lua
DEBUG: -> -> -> Loading module: /lua/maui/mauiutil.lua
DEBUG: -> -> -> Loading module: /lua/ui/game/build_templates.lua
DEBUG: -> -> -> Loading module: /lua/ui/game/buildmode.lua
DEBUG: -> -> -> -> Loading module: /lua/ui/game/tabs.lua
INFO: Hooked /lua/ui/game/tabs.lua with /mods/coop/hook/lua/ui/game/tabs.lua
DEBUG: -> -> -> Loading module: /lua/ui/game/unitviewdetail.lua
DEBUG: -> -> -> -> Loading module: /lua/ui/help/unitdescription.lua
DEBUG: -> -> -> -> Loading module: /lua/armordefinition.lua
INFO: Hooked /lua/armordefinition.lua with /mods/coop/hook/lua/armordefinition.lua
DEBUG: -> -> -> Loading module: /lua/ui/templates_factory.lua
DEBUG: -> -> -> Loading module: /lua/ui/game/straticons.lua
DEBUG: -> -> -> Loading module: /lua/ui/notify/enhancementqueue.lua
DEBUG: -> -> -> Loading module: /lua/keymap/hotkeylabelsui.lua
WARNING: ...orever\gamedata\lua.nx2\lua\ui\game\construction.lua(91): Attempt to set attribute 'HandleEvent' on nil
WARNING: stack traceback:
WARNING: [C]: in function `error'
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\config.lua(14): in function <...ne\.faforever\gamedata\lua.nx2\lua\system\config.lua:13>
WARNING: ...orever\gamedata\lua.nx2\lua\ui\game\construction.lua(91): in main chunk
WARNING: [C]: in function `doscript'
WARNING: [C]: ?
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(61): in function <...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua:41>
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(161): in function `import'
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(137): in function `import'
WARNING: ...forever\gamedata\lua.nx2\lua\ui\game\commandmode.lua(12): in main chunk
WARNING: [C]: in function `doscript'
WARNING: [C]: ?
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(61): in function <...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua:41>
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(161): in function `import'
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(137): in function `import'
WARNING: ...forever\gamedata\lua.nx2\lua\ui\game\objectives2.lua(26): in main chunk
WARNING: [C]: in function `doscript'
WARNING: [C]: ?
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(61): in function <...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua:41>
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(161): in function `import'
WARNING: ...axpayne\.faforever\gamedata\lua.nx2\lua\usersync.lua(286): in function <...axpayne\.faforever\gamedata\lua.nx2\lua\usersync.lua:53>
WARNING: ...axpayne\.faforever\gamedata\lua.nx2\lua\usersync.lua(527): in function `OnSync'
WARNING: [string "OnSync()"](1): in main chunk
WARNING: ...ne\.faforever\gamedata\lua.nx2\lua\system\import.lua(161): Error importing '/lua/ui/game/construction.lua'
```
`construction.lua` code in question:
```lua
if options.gui_draggable_queue ~= 0 then
-- Add gameparent handleevent for if the drag ends outside the queue window
local gameParent = import("/lua/ui/game/gamemain.lua").GetGameParent()
local oldGameParentHandleEvent = gameParent.HandleEvent
gameParent.HandleEvent = function(self, event)
if event.Type == 'ButtonRelease' then
import("/lua/ui/game/construction.lua").ButtonReleaseCallback()
end
oldGameParentHandleEvent(self, event)
end
end
```
I can confirm that by disabling the "draggable queue" UI option in the option menu, it is possible to bring back the build mode hotkey functionality. Good enough as a workaround.
Among other things, "transmission log" feature is also missing if "draggable queue" is set.
Contributor guide
Assessment
This issue has not been assessed yet.