Skip to content

Add a hotkey to open the contracts menu directly (Shift+R by default) - #122

Open
helgehelge123 wants to merge 1 commit into
GMNGjoy:mainfrom
helgehelge123:feature/open-contracts-hotkey
Open

Add a hotkey to open the contracts menu directly (Shift+R by default)#122
helgehelge123 wants to merge 1 commit into
GMNGjoy:mainfrom
helgehelge123:feature/open-contracts-hotkey

Conversation

@helgehelge123

Copy link
Copy Markdown

What this adds

A new global input action CONTRACT_BOOST_OPEN_CONTRACTS that opens the in-game menu directly on the contracts page — no more clicking through ESC → menu tabs to check contracts.

  • Default binding: Shift+R, fully rebindable via the game's input settings
  • The keybind hint is hidden from the F1 help menu to avoid cluttering it
  • Localized action labels for all 10 supported languages (en, de, cz, da, es, fr, it, pl, pt, ru)

Implementation notes

  • The action is registered in registerGlobalPlayerActionEvents via Utils.overwrittenFunction, so it works on foot and in vehicles
  • openContractsMenu() resolves the contracts page through g_inGameMenu (with a fallback to g_gui.screenControllers) and logs a warning instead of erroring if the page can't be found

Tested in singleplayer on FS25 with the current main (1.1.2.7) code.

🤖 Generated with Claude Code

Registers a new global input action CONTRACT_BOOST_OPEN_CONTRACTS that
opens the in-game menu directly on the contracts page. Bound to Shift+R
by default, rebindable via the game's input settings. The keybind hint
is hidden from the F1 help menu to avoid clutter.

Includes localized action labels for all 10 supported languages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@KeilerHirsch KeilerHirsch left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, small feature — the input binding registration follows the standard Utils.overwrittenFunction chaining pattern correctly (calls superFunc first), and it's purely local UI state (no network events involved), so no multiplayer/authority concerns.

One thing worth a second look in openContractsMenu() (scripts/ContractBoost.lua):

local index = inGameMenu.pagingElement:getPageMappingIndexByElement(inGameMenu.pageContracts)
inGameMenu.pageSelector:setState(index, true)

The guard above only checks inGameMenu.pageContracts == nil, not whether that page is actually registered in pagingElement's mapping. If contracts are disabled for the current mission/save (game setting), the page object can still exist while never having been added to the pager — in which case getPageMappingIndexByElement returns nil and pageSelector:setState(nil, true) gets called. I haven't been able to test this in-game, so I can't confirm whether setState actually errors on a nil index or just no-ops — flagging as a suspicion, not a confirmed bug. Might be worth an if index ~= nil then ... end guard just to be safe, but not blocking on it since I can't verify it reproduces.

Everything else checks out — nil-safety on inGameMenu/pageContracts, eventId checked before setActionEventTextVisibility. Minor cosmetic nit: modDesc.xml and the Lua file are still missing a trailing newline (pre-existing, not introduced by this PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants