FAForever / fa

Lua code for FAF
226 stars 232 forks source link

Build menu hotkey is not working when loading the campaign game #6165

Open forGGe opened 4 months ago

forGGe commented 4 months ago

Describe the bug

Loading the saved campaign game in the offline mode results in the build menu hotkey not being functional.

bad.log

To Reproduce

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:

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.