Skip to content

Commit bbbf76d

Browse files
v2.0.0.2 — Replace custom settings screen with in-game settings integration
Settings are now injected into the native ESC > Settings page via RWESettingsIntegration, following the InGameMenuSettingsFrame hook pattern. Removes the broken TabbedMenuWithDetails/MessageDialog mismatch that caused a crash when opening the settings screen via F3 or rweSettings. - Add gui/RWESettingsIntegration.lua (hooks InGameMenuSettingsFrame) - Remove broken custom screen/frame GUI files from extraSourceFiles - Neutralize loadGUI(); fix consoleCommandSettings(); fix F3 handler - Bump version to 2.0.0.2
1 parent 7273748 commit bbbf76d

9 files changed

Lines changed: 780 additions & 311 deletions

FS25_RandomWorldEvents.zip

4.25 KB
Binary file not shown.

RandomWorldEvents.lua

Lines changed: 21 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- =========================================================
2-
-- Random World Events (version 2.0.0.1) - FS25 Conversion
2+
-- Random World Events (version 2.0.0.2) - FS25 Conversion
33
-- =========================================================
44
-- Random events that can occur. Settings can be changed!
55
-- =========================================================
@@ -538,13 +538,9 @@ function RandomWorldEvents:consoleCommandList(category)
538538
return string.format("Listed %d events", total)
539539
end
540540

541-
-- Open the settings screen programmatically.
541+
-- Settings are now in ESC > Settings > Random World Events.
542542
function RandomWorldEvents:consoleCommandSettings()
543-
if g_gui then
544-
g_gui:showGui("RandomWorldEventsScreen")
545-
return "Opening settings screen"
546-
end
547-
return "GUI not available"
543+
return "Settings: open ESC > Settings and scroll to 'Random World Events'"
548544
end
549545

550546
-- =====================
@@ -578,54 +574,9 @@ end
578574
-- =====================
579575

580576
function RandomWorldEvents:loadGUI()
581-
Logging.info("[RWE] Starting GUI loading...")
582-
583-
-- First, load the GUI Lua files
584-
local guiFiles = {
585-
"gui/RandomWorldEventsScreen.lua",
586-
"gui/RandomWorldEventsFrame.lua",
587-
"gui/RandomWorldDebugFrame.lua"
588-
}
589-
590-
for _, guiFile in ipairs(guiFiles) do
591-
local filePath = Utils.getFilename(guiFile, self.modDirectory)
592-
if fileExists(filePath) then
593-
source(filePath)
594-
Logging.info("[RandomWorldEvents] Loaded GUI file: " .. guiFile)
595-
else
596-
Logging.error("[RandomWorldEvents] GUI file not found: " .. filePath)
597-
end
598-
end
599-
600-
-- Load GUI profiles
601-
local profilesPath = Utils.getFilename("guiProfiles.xml", self.modDirectory)
602-
if fileExists(profilesPath) then
603-
g_gui:loadProfiles(profilesPath)
604-
Logging.info("[RWE] GUI profiles loaded")
605-
else
606-
Logging.error("[RWE] GUI profiles not found: " .. profilesPath)
607-
end
608-
609-
-- Register screen classes if they exist
610-
if RandomWorldEventsScreen then
611-
g_gui:loadGui(Utils.getFilename("xml/RandomWorldEventsScreen.xml", self.modDirectory),
612-
"RandomWorldEventsScreen", RandomWorldEventsScreen)
613-
Logging.info("[RWE] RandomWorldEventsScreen registered")
614-
end
615-
616-
if RandomWorldEventsFrame then
617-
g_gui:loadGui(Utils.getFilename("xml/RandomWorldEventsFrame.xml", self.modDirectory),
618-
"RandomWorldEventsFrame", RandomWorldEventsFrame)
619-
Logging.info("[RWE] RandomWorldEventsFrame registered")
620-
end
621-
622-
if RandomWorldEventsDebugFrame then
623-
g_gui:loadGui(Utils.getFilename("xml/RandomWorldDebugFrame.xml", self.modDirectory),
624-
"RandomWorldDebugFrame", RandomWorldEventsDebugFrame)
625-
Logging.info("[RWE] RandomWorldDebugFrame registered")
626-
end
627-
628-
Logging.info("[RWE] GUI loading complete")
577+
-- Settings are injected into ESC > Settings via RWESettingsIntegration (hooks pattern).
578+
-- No custom screen registration needed.
579+
Logging.info("[RWE] GUI ready (settings via InGameMenuSettingsFrame hook)")
629580
end
630581

631582
-- =====================
@@ -651,10 +602,7 @@ local function load(mission)
651602

652603
-- Now load event modules (they need g_RandomWorldEvents to exist)
653604
rweManager:loadEventModules()
654-
655-
-- Load GUI
656-
rweManager:loadGUI()
657-
605+
658606
-- Mark as initialized
659607
rweManager.isInitialized = true
660608

@@ -688,17 +636,28 @@ end
688636
local function keyEvent(unicode, sym, modifier, isDown)
689637
if not isDown or not rweManager then return end
690638

691-
if sym == 284 then -- F3 — open settings screen
692-
if g_gui then
693-
g_gui:showGui("RandomWorldEventsScreen")
639+
if sym == 284 then -- F3 — hint: settings are in ESC > Settings
640+
if g_currentMission then
641+
g_currentMission:addIngameNotification(
642+
FSBaseMission.INGAME_NOTIFICATION_INFO,
643+
"RWE: Open ESC > Settings to configure Random World Events"
644+
)
694645
end
695646
elseif sym == 290 then -- F9 — force-trigger a random event
696647
rweManager:triggerRandomEvent()
697648
end
698649
end
699650

651+
local function loadFinished(mission, ...)
652+
if rweManager and not rweManager.guiLoaded then
653+
rweManager:loadGUI()
654+
rweManager.guiLoaded = true
655+
end
656+
end
657+
700658
-- Hook into FS25
701659
Mission00.load = Utils.prependedFunction(Mission00.load, load)
660+
Mission00.loadMission00Finished = Utils.appendedFunction(Mission00.loadMission00Finished, loadFinished)
702661
FSBaseMission.update = Utils.appendedFunction(FSBaseMission.update, update)
703662
FSBaseMission.delete = Utils.appendedFunction(FSBaseMission.delete, delete)
704663
FSBaseMission.keyEvent = Utils.appendedFunction(FSBaseMission.keyEvent, keyEvent)

0 commit comments

Comments
 (0)