Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 40 additions & 37 deletions src/context/trackerContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 14 additions & 1 deletion src/scenes/TrackerLauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`; }

Expand All @@ -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.
Expand Down Expand Up @@ -298,6 +306,11 @@ const TrackerLauncher = () => {
}
/>
</InputGroup>
{launchAttempted && missingSettingsString && (
<div className="text-danger small mt-1">
Enter a settings string or pick a preset to launch with check tracking.
</div>
)}
</div>
</div>

Expand Down
14 changes: 1 addition & 13 deletions src/scenes/TrackerLayout.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className="w-100 d-flex flex-column align-items-center my-5">
<img src={frog} alt="Frog" />
<span>Loading...</span>
</div>
);
}
useSessionRestore(true);

return (
<div className="">
Expand Down
Loading