diff --git a/src/context/trackerContext.js b/src/context/trackerContext.js index 49e280d..fbb9c0f 100644 --- a/src/context/trackerContext.js +++ b/src/context/trackerContext.js @@ -603,55 +603,58 @@ function reducer(state, action) { const draggedIcons = snapshot.draggedIcons || {}; const starting_item_claims = snapshot.starting_item_claims || {}; const unchanged_starting_inventory = snapshot.unchanged_starting_inventory || []; - - if (snapshot.mq_dungeons_specific) { - _.set(LogicHelper.settings, "mq_dungeons_specific", snapshot.mq_dungeons_specific); - SettingsHelper.settings["mq_dungeons_specific"] = snapshot.mq_dungeons_specific; - } - if (snapshot.dungeon_shortcuts) { - _.set(LogicHelper.settings, "dungeon_shortcuts", snapshot.dungeon_shortcuts); - SettingsHelper.settings["dungeon_shortcuts"] = snapshot.dungeon_shortcuts; - } - SettingsHelper.invalidateCachedSets(); - const starting_age_selection = snapshot.starting_age_selection || null; - SettingsHelper.setStartingAgeSelection(starting_age_selection); + const parsedItems = parseItems(items_list, counters, unchanged_starting_inventory); - // Rebuild the tooltip caches the restored settings invalidated - scheduleTooltipWarm(); + let restoredLocations = state.locations; - const locations = _.cloneDeep(state.locations); + // The following is only restored with check tracking on. + if (!_.isEmpty(state.locations)) { + if (snapshot.mq_dungeons_specific) { + _.set(LogicHelper.settings, "mq_dungeons_specific", snapshot.mq_dungeons_specific); + SettingsHelper.settings["mq_dungeons_specific"] = snapshot.mq_dungeons_specific; + } + if (snapshot.dungeon_shortcuts) { + _.set(LogicHelper.settings, "dungeon_shortcuts", snapshot.dungeon_shortcuts); + SettingsHelper.settings["dungeon_shortcuts"] = snapshot.dungeon_shortcuts; + } + SettingsHelper.invalidateCachedSets(); + SettingsHelper.setStartingAgeSelection(starting_age_selection); - // Rebuild each dungeon's location list to match the restored MQ setting. - _.forEach(_.keys(locations), regionName => { - if (!_.includes(DUNGEONS, regionName)) { return; } - const locationKey = SettingsHelper.isMQDungeon(regionName) ? "dungeon_mq" : "dungeon"; - _.set(locations, regionName, {}); - _.forEach(Locations.locations[locationKey][regionName], (locationData, locationName) => { - if (Locations.isProgressLocation(locationData)) { - _.set(locations, [regionName, locationName], { isAvailable: false, isChecked: false }); - } + const locations = _.cloneDeep(state.locations); + + // Rebuild each dungeon's location list to match the restored MQ setting. + _.forEach(_.keys(locations), regionName => { + if (!_.includes(DUNGEONS, regionName)) { return; } + const locationKey = SettingsHelper.isMQDungeon(regionName) ? "dungeon_mq" : "dungeon"; + _.set(locations, regionName, {}); + _.forEach(Locations.locations[locationKey][regionName], (locationData, locationName) => { + if (Locations.isProgressLocation(locationData)) { + _.set(locations, [regionName, locationName], { isAvailable: false, isChecked: false }); + } + }); }); - }); - _.forEach(snapshot.checkedLocations || {}, (locationNames, regionName) => { - if (!locations[regionName]) { return; } - locationNames.forEach(locationName => { - if (locations[regionName][locationName]) { - _.set(locations, [regionName, locationName, "isChecked"], true); - } + _.forEach(snapshot.checkedLocations || {}, (locationNames, regionName) => { + if (!locations[regionName]) { return; } + locationNames.forEach(locationName => { + if (locations[regionName][locationName]) { + _.set(locations, [regionName, locationName, "isChecked"], true); + } + }); }); - }); - const settingsString = snapshot.settings_string || state.settings_string; - const skipRegions = isEFK(settingsString) ? getEFKSkipRegions(settingsString, labelSelections) : new Set(); + const settingsString = snapshot.settings_string || state.settings_string; + const skipRegions = isEFK(settingsString) ? getEFKSkipRegions(settingsString, labelSelections) : new Set(); + restoredLocations = validateLocations(locations, parsedItems, skipRegions); - const parsedItems = parseItems(items_list, counters, unchanged_starting_inventory); - const validatedLocations = validateLocations(locations, parsedItems, skipRegions); + // Rebuild the tooltip caches the restored settings invalidated + scheduleTooltipWarm(); + } return { ...state, - locations: validatedLocations, + locations: restoredLocations, items: parsedItems, items_list, counters, diff --git a/src/scenes/TrackerLauncher.js b/src/scenes/TrackerLauncher.js index 3b54ec8..41c1f19 100644 --- a/src/scenes/TrackerLauncher.js +++ b/src/scenes/TrackerLauncher.js @@ -81,7 +81,15 @@ const TrackerLauncher = () => { setGeneratorVersionCache(debouncedVersion); }, [debouncedVersion, setGeneratorVersionCache]); + const missingSettingsString = checks && !settingsString.trim(); + const [launchAttempted, setLaunchAttempted] = useState(false); + const launchTracker = useCallback(() => { + if (missingSettingsString) { + setLaunchAttempted(true); + return; + } + let url = `${baseURL}/tracker`; if (checks) { url = `${baseURL}/tracker/checks`; } @@ -98,7 +106,7 @@ const TrackerLauncher = () => { "HashFrog Tracker", `toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=${width},height=${height}` ); - }, [checks, layout, settingsString, generatorVersion, layoutSize]); + }, [missingSettingsString, checks, layout, settingsString, generatorVersion, layoutSize]); // Track whether a saved session exists so the Resume button reacts when one // is created in a popup window; refresh on focus when returning to the launcher. @@ -298,6 +306,11 @@ const TrackerLauncher = () => { } /> + {launchAttempted && missingSettingsString && ( +
+ Enter a settings string or pick a preset to launch with check tracking. +
+ )} diff --git a/src/scenes/TrackerLayout.js b/src/scenes/TrackerLayout.js index 9576500..0ea14ac 100644 --- a/src/scenes/TrackerLayout.js +++ b/src/scenes/TrackerLayout.js @@ -1,20 +1,8 @@ -import frog from "../assets/icons/hashfrogsping.gif"; import { useSessionRestore } from "../context/trackerContext"; -import useLogicInitialization from "../hooks/useLogicInitialization"; import Layout from "./Layout"; const TrackerLayout = () => { - const { isLoading, isInitialized } = useLogicInitialization(); - useSessionRestore(isInitialized); - - if (isLoading) { - return ( -
- Frog - Loading... -
- ); - } + useSessionRestore(true); return (