Update test.html
This commit is contained in:
parent
5d27d7e8ca
commit
81aac00a16
418
test.html
418
test.html
|
|
@ -2095,7 +2095,7 @@ function updateDynamicCursor(hexColor) {
|
|||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const factionInput = document.getElementById('chosen-country');
|
||||
const factionInput = document.getElementById('chosen-country-input');
|
||||
const tooltip = document.getElementById('vats-tooltip'); // WE ARE USING YOUR EXISTING TOOLTIP ELEMENT
|
||||
|
||||
if (!factionInput || !tooltip) {
|
||||
|
|
@ -2537,122 +2537,20 @@ const helpBtn = document.querySelector('#help-btn');
|
|||
const helpModal = document.querySelector('#help-modal');
|
||||
const closeHelpBtn = document.querySelector('#close-help-btn');
|
||||
|
||||
// --- NEW: GAME MODE PRESET LOGIC (FINAL FORMATTING) ---
|
||||
const presetSelector = document.getElementById('game-mode-preset');
|
||||
const descriptionBox = document.getElementById('preset-description');
|
||||
const customRulesBox = document.getElementById('custom-rules-container');
|
||||
const checkboxes = {
|
||||
perks: document.getElementById('opt-perks'),
|
||||
commander: document.getElementById('opt-commander'),
|
||||
fog: document.getElementById('opt-fog-of-war'),
|
||||
radstorms: document.getElementById('opt-radstorms'),
|
||||
horrors: document.getElementById('opt-horrors'),
|
||||
encounters: document.getElementById('opt-encounters'),
|
||||
nukes: document.getElementById('opt-nukes'),
|
||||
flatTrade: document.getElementById('opt-flat-trade')
|
||||
};
|
||||
|
||||
const presetData = {
|
||||
'classic': {
|
||||
narrative: `"The old world is dead. The new world is a battleground. This is a pure contest of strategy and will. Amass your forces, conquer the continents, and eliminate all rivals. In this simulation, only tactical superiority matters. No heroes, no cataclysms—just war. War never changes."`,
|
||||
mechanics: { economy: false, perks: false, commander: false, fog: false, radstorms: false, horrors: false, encounters: false, nukes: false }
|
||||
},
|
||||
'survival': {
|
||||
narrative: `"Forget conquering the world; your only goal is to survive it. The air itself is poison, radioactive storms blot out the sun, and packs of ghouls infest the ruins. The map is a dark, unknown space. Every cap counts. Every step could be your last. Welcome to the real wasteland."`,
|
||||
mechanics: { economy: true, perks: false, commander: false, fog: true, radstorms: true, horrors: true, encounters: true, nukes: false }
|
||||
},
|
||||
'heroes': {
|
||||
narrative: `"History is not made by armies, but by individuals. In this simulation, the fate of the wasteland rests on the shoulders of its Commanders. Leverage your faction's unique doctrines and your leader's abilities to outmaneuver your foes. This is a war of personalities, where a single heroic action can turn the tide."`,
|
||||
mechanics: { economy: true, perks: true, commander: true, fog: false, radstorms: false, horrors: false, encounters: true, nukes: false }
|
||||
},
|
||||
'apocalypse': {
|
||||
narrative: `"The end of the world wasn't the end. The real apocalypse is now. The sky rains radiation, the dead walk the earth, and the forgotten keys to nuclear fire are back in play. There are no safe havens. There is no hope. There is only the roar of the storm, the shriek of the ghouls, and the terrifying whistle of the falling bomb."`,
|
||||
mechanics: { economy: true, perks: false, commander: false, fog: false, radstorms: true, horrors: true, encounters: true, nukes: true }
|
||||
},
|
||||
'alliance': {
|
||||
narrative: `"No faction can stand alone against the darkness. In this scenario, you are bound by oath to a brother-in-arms. You will be automatically allied with a lore-friendly faction, and you will share their fate. If they fall, you fall. Coordinate your attacks, defend your ally's borders, and crush the other coalitions to achieve a shared victory."`,
|
||||
mechanics: { economy: true, perks: true, commander: true, fog: true, radstorms: false, horrors: false, encounters: false, nukes: false }
|
||||
},
|
||||
'covert': {
|
||||
narrative: `"The deadliest weapon is the one your enemy never sees coming. This is a war fought in the shadows. Use your Commander to infiltrate enemy lines, leverage your faction's perks for an asymmetric advantage, and navigate the fog of war to set the perfect trap. Information is your ammunition. Secrecy is your armor."`,
|
||||
mechanics: { economy: true, perks: true, commander: true, fog: true, radstorms: false, horrors: false, encounters: true, nukes: false }
|
||||
},
|
||||
'nuclear': {
|
||||
narrative: `"The ghosts of the Great War have returned. This simulation is a tense cold war, a frantic arms race to secure the world's remaining nuclear arsenal. Protect your Commander, hunt for launch codes, and make the impossible choice. Will you be the savior of the wasteland, or will you become its destroyer?"`,
|
||||
mechanics: { economy: true, perks: false, commander: true, fog: true, radstorms: false, horrors: false, encounters: false, nukes: true }
|
||||
}
|
||||
};
|
||||
|
||||
function updatePresetView() {
|
||||
const selectedMode = presetSelector.value;
|
||||
|
||||
if (selectedMode === 'custom') {
|
||||
descriptionBox.style.display = 'none';
|
||||
customRulesBox.style.display = 'block';
|
||||
} else {
|
||||
descriptionBox.style.display = 'block';
|
||||
customRulesBox.style.display = 'none';
|
||||
|
||||
const data = presetData[selectedMode];
|
||||
if (!data) return;
|
||||
|
||||
// Update checkboxes behind the scenes
|
||||
checkboxes.perks.checked = data.mechanics.perks;
|
||||
checkboxes.commander.checked = data.mechanics.commander;
|
||||
checkboxes.fog.checked = data.mechanics.fog;
|
||||
checkboxes.radstorms.checked = data.mechanics.radstorms;
|
||||
checkboxes.horrors.checked = data.mechanics.horrors;
|
||||
checkboxes.encounters.checked = data.mechanics.encounters;
|
||||
checkboxes.nukes.checked = data.mechanics.nukes;
|
||||
|
||||
const economyEnabled = data.mechanics.economy;
|
||||
|
||||
// Build the comma-separated mechanics string
|
||||
let enabledMechanics = [];
|
||||
if (economyEnabled) enabledMechanics.push("Wasteland Economy");
|
||||
if (data.mechanics.perks) enabledMechanics.push("Faction Perks");
|
||||
if (data.mechanics.commander) enabledMechanics.push("Commanders");
|
||||
if (data.mechanics.fog) enabledMechanics.push("Fog of War");
|
||||
if (data.mechanics.radstorms) enabledMechanics.push("Radstorms");
|
||||
if (data.mechanics.horrors) enabledMechanics.push("Wild Ghouls");
|
||||
if (data.mechanics.encounters) enabledMechanics.push("Dynamic Encounters");
|
||||
if (data.mechanics.nukes) enabledMechanics.push("Scorched Earth");
|
||||
|
||||
let mechanicsString;
|
||||
if (enabledMechanics.length > 0) {
|
||||
mechanicsString = enabledMechanics.join(', ');
|
||||
} else {
|
||||
mechanicsString = "None (Card trade-in reinforcements only)";
|
||||
}
|
||||
|
||||
// Build the final description HTML
|
||||
descriptionBox.innerHTML = `<p style="margin-top: 0; margin-bottom: 10px;">${data.narrative}</p><strong>MECHANICS ENABLED:</strong><br>${mechanicsString}`;
|
||||
}
|
||||
const perksAreOn = checkboxes.perks.checked;
|
||||
factionInput.disabled = !perksAreOn;
|
||||
factionInput.style.opacity = perksAreOn ? '1' : '0.5';
|
||||
factionInput.style.pointerEvents = perksAreOn ? 'auto' : 'none';
|
||||
|
||||
}
|
||||
|
||||
// Add event listener and run once on load
|
||||
presetSelector.addEventListener('change', updatePresetView);
|
||||
document.addEventListener('DOMContentLoaded', updatePresetView);
|
||||
|
||||
|
||||
let Gamestate = {};
|
||||
// --- ERA-SPECIFIC DYNAMIC THEME LOADER ---
|
||||
const themeSelector = document.getElementById('chosen-theme');
|
||||
const leaderInput = document.getElementById('chosen-leader');
|
||||
const factionInput = document.getElementById('chosen-country');
|
||||
|
||||
// --- FINAL, WORKING PRESET LOGIC ---
|
||||
// =================================================================
|
||||
// --- UNIFIED BOOT SEQUENCE SCRIPT ---
|
||||
// =================================================================
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// --- 1. Define All Elements Safely ---
|
||||
const themeSelector = document.getElementById('chosen-theme');
|
||||
const leaderInput = document.getElementById('chosen-leader');
|
||||
const factionInput = document.getElementById('chosen-country-input');
|
||||
const optionsContainer = document.getElementById('custom-faction-options');
|
||||
const tooltip = document.getElementById('vats-tooltip');
|
||||
const presetSelector = document.getElementById('game-mode-preset');
|
||||
const descriptionBox = document.getElementById('preset-description');
|
||||
const customRulesBox = document.getElementById('custom-rules-container');
|
||||
const factionInput = document.getElementById('chosen-country-input');
|
||||
|
||||
const checkboxes = {
|
||||
perks: document.getElementById('opt-perks'),
|
||||
commander: document.getElementById('opt-commander'),
|
||||
|
|
@ -2665,36 +2563,26 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
};
|
||||
|
||||
const presetData = {
|
||||
'classic': {
|
||||
narrative: `"The old world is dead. The new world is a battleground. This is a pure contest of strategy and will. Amass your forces, conquer the continents, and eliminate all rivals. In this simulation, only tactical superiority matters. No heroes, no cataclysms—just war. War never changes."`,
|
||||
mechanics: { economy: false, perks: false, commander: false, fog: false, radstorms: false, horrors: false, encounters: false, nukes: false }
|
||||
},
|
||||
'survival': {
|
||||
narrative: `"Forget conquering the world; your only goal is to survive it. The air itself is poison, radioactive storms blot out the sun, and packs of ghouls infest the ruins. The map is a dark, unknown space. Every cap counts. Every step could be your last. Welcome to the real wasteland."`,
|
||||
mechanics: { economy: true, perks: false, commander: false, fog: true, radstorms: true, horrors: true, encounters: true, nukes: false }
|
||||
},
|
||||
'heroes': {
|
||||
narrative: `"History is not made by armies, but by individuals. In this simulation, the fate of the wasteland rests on the shoulders of its Commanders. Leverage your faction's unique doctrines and your leader's abilities to outmaneuver your foes. This is a war of personalities, where a single heroic action can turn the tide."`,
|
||||
mechanics: { economy: true, perks: true, commander: true, fog: false, radstorms: false, horrors: false, encounters: true, nukes: false }
|
||||
},
|
||||
'apocalypse': {
|
||||
narrative: `"The end of the world wasn't the end. The real apocalypse is now. The sky rains radiation, the dead walk the earth, and the forgotten keys to nuclear fire are back in play. There are no safe havens. There is no hope. There is only the roar of the storm, the shriek of the ghouls, and the terrifying whistle of the falling bomb."`,
|
||||
mechanics: { economy: true, perks: false, commander: false, fog: false, radstorms: true, horrors: true, encounters: true, nukes: true }
|
||||
},
|
||||
'alliance': {
|
||||
narrative: `"No faction can stand alone against the darkness. In this scenario, you are bound by oath to a brother-in-arms. You will be automatically allied with a lore-friendly faction, and you will share their fate. If they fall, you fall. Coordinate your attacks, defend your ally's borders, and crush the other coalitions to achieve a shared victory."`,
|
||||
mechanics: { economy: true, perks: true, commander: true, fog: true, radstorms: false, horrors: false, encounters: false, nukes: false }
|
||||
},
|
||||
'covert': {
|
||||
narrative: `"The deadliest weapon is the one your enemy never sees coming. This is a war fought in the shadows. Use your Commander to infiltrate enemy lines, leverage your faction's perks for an asymmetric advantage, and navigate the fog of war to set the perfect trap. Information is your ammunition. Secrecy is your armor."`,
|
||||
mechanics: { economy: true, perks: true, commander: true, fog: true, radstorms: false, horrors: false, encounters: true, nukes: false }
|
||||
},
|
||||
'nuclear': {
|
||||
narrative: `"The ghosts of the Great War have returned. This simulation is a tense cold war, a frantic arms race to secure the world's remaining nuclear arsenal. Protect your Commander, hunt for launch codes, and make the impossible choice. Will you be the savior of the wasteland, or will you become its destroyer?"`,
|
||||
mechanics: { economy: true, perks: false, commander: true, fog: true, radstorms: false, horrors: false, encounters: false, nukes: true }
|
||||
}
|
||||
'classic': { narrative: `"The old world is dead. The new world is a battleground. This is a pure contest of strategy and will. Amass your forces, conquer the continents, and eliminate all rivals. In this simulation, only tactical superiority matters. No heroes, no cataclysms—just war. War never changes."`, mechanics: { perks: false, commander: false, fog: false, radstorms: false, horrors: false, encounters: false, nukes: false } },
|
||||
'survival': { narrative: `"Forget conquering the world; your only goal is to survive it. The air itself is poison, radioactive storms blot out the sun, and packs of ghouls infest the ruins. The map is a dark, unknown space. Every cap counts. Every step could be your last. Welcome to the real wasteland."`, mechanics: { perks: false, commander: false, fog: true, radstorms: true, horrors: true, encounters: true, nukes: false } },
|
||||
'heroes': { narrative: `"History is not made by armies, but by individuals. In this simulation, the fate of the wasteland rests on the shoulders of its Commanders. Leverage your faction's unique doctrines and your leader's abilities to outmaneuver your foes. This is a war of personalities, where a single heroic action can turn the tide."`, mechanics: { perks: true, commander: true, fog: false, radstorms: false, horrors: false, encounters: true, nukes: false } },
|
||||
'apocalypse': { narrative: `"The end of the world wasn't the end. The real apocalypse is now. The sky rains radiation, the dead walk the earth, and the forgotten keys to nuclear fire are back in play. There are no safe havens. There is no hope. There is only the roar of the storm, the shriek of the ghouls, and the terrifying whistle of the falling bomb."`, mechanics: { perks: false, commander: false, fog: false, radstorms: true, horrors: true, encounters: true, nukes: true } },
|
||||
'alliance': { narrative: `"No faction can stand alone against the darkness. In this scenario, you are bound by oath to a brother-in-arms. You will be automatically allied with a lore-friendly faction, and you will share their fate. If they fall, you fall. Coordinate your attacks, defend your ally's borders, and crush the other coalitions to achieve a shared victory."`, mechanics: { perks: true, commander: true, fog: true, radstorms: false, horrors: false, encounters: false, nukes: false } },
|
||||
'covert': { narrative: `"The deadliest weapon is the one your enemy never sees coming. This is a war fought in the shadows. Use your Commander to infiltrate enemy lines, leverage your faction's perks for an asymmetric advantage, and navigate the fog of war to set the perfect trap. Information is your ammunition. Secrecy is your armor."`, mechanics: { perks: true, commander: true, fog: true, radstorms: false, horrors: false, encounters: true, nukes: false } },
|
||||
'nuclear': { narrative: `"The ghosts of the Great War have returned. This simulation is a tense cold war, a frantic arms race to secure the world's remaining nuclear arsenal. Protect your Commander, hunt for launch codes, and make the impossible choice. Will you be the savior of the wasteland, or will you become its destroyer?"`, mechanics: { perks: false, commander: true, fog: true, radstorms: false, horrors: false, encounters: false, nukes: true } }
|
||||
};
|
||||
|
||||
function applyVisualTheme() {
|
||||
const theme = themeSelector.value;
|
||||
if (typeof updateDynamicCursor === 'function') {
|
||||
if (theme === 'fnv') { updateDynamicCursor('#ffb642'); }
|
||||
else if (theme === 'fo4') { updateDynamicCursor('#22ccff'); }
|
||||
else { updateDynamicCursor('#18ff62'); }
|
||||
}
|
||||
document.body.classList.remove('theme-fo3', 'theme-fnv', 'theme-fo4');
|
||||
if (theme !== 'fo3') { document.body.classList.add('theme-' + theme); }
|
||||
}
|
||||
|
||||
function updatePresetView() {
|
||||
const selectedMode = presetSelector.value;
|
||||
let perksAreOn = false;
|
||||
|
|
@ -2706,52 +2594,230 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
} else {
|
||||
descriptionBox.style.display = 'block';
|
||||
customRulesBox.style.display = 'none';
|
||||
|
||||
const data = presetData[selectedMode];
|
||||
if (!data) return;
|
||||
if (data) {
|
||||
Object.keys(checkboxes).forEach(key => {
|
||||
if(data.mechanics[key] !== undefined) { checkboxes[key].checked = data.mechanics[key]; }
|
||||
});
|
||||
perksAreOn = data.mechanics.perks;
|
||||
|
||||
let mechanicsList = Object.keys(data.mechanics).filter(k => data.mechanics[k]).map(k => {
|
||||
const names = {perks: "Faction Perks", commander: "Commanders", fog: "Fog of War", radstorms: "Radstorms", horrors: "Wild Ghouls", encounters: "Dynamic Encounters", nukes: "Scorched Earth"};
|
||||
return names[k];
|
||||
}).filter(Boolean);
|
||||
if (selectedMode !== 'classic') mechanicsList.unshift("Wasteland Economy");
|
||||
|
||||
checkboxes.perks.checked = data.mechanics.perks;
|
||||
checkboxes.commander.checked = data.mechanics.commander;
|
||||
checkboxes.fog.checked = data.mechanics.fog;
|
||||
checkboxes.radstorms.checked = data.mechanics.radstorms;
|
||||
checkboxes.horrors.checked = data.mechanics.horrors;
|
||||
checkboxes.encounters.checked = data.mechanics.encounters;
|
||||
checkboxes.nukes.checked = data.mechanics.nukes;
|
||||
|
||||
perksAreOn = data.mechanics.perks;
|
||||
const economyEnabled = data.mechanics.economy;
|
||||
|
||||
let enabledMechanics = [];
|
||||
if (economyEnabled) enabledMechanics.push("Wasteland Economy");
|
||||
if (perksAreOn) enabledMechanics.push("Faction Perks");
|
||||
if (data.mechanics.commander) enabledMechanics.push("Commanders");
|
||||
if (data.mechanics.fog) enabledMechanics.push("Fog of War");
|
||||
if (data.mechanics.radstorms) enabledMechanics.push("Radstorms");
|
||||
if (data.mechanics.horrors) enabledMechanics.push("Wild Ghouls");
|
||||
if (data.mechanics.encounters) enabledMechanics.push("Dynamic Encounters");
|
||||
if (data.mechanics.nukes) enabledMechanics.push("Scorched Earth");
|
||||
|
||||
let mechanicsString = (enabledMechanics.length > 0) ? enabledMechanics.join(', ') : "None (Card trade-in reinforcements only)";
|
||||
descriptionBox.innerHTML = `<p style="margin-top: 0; margin-bottom: 10px;">${data.narrative}</p><strong>MECHANICS ENABLED:</strong><br>${mechanicsString}`;
|
||||
let mechanicsString = (mechanicsList.length > 0) ? mechanicsList.join(', ') : "None (Card trade-in reinforcements only)";
|
||||
descriptionBox.innerHTML = `<p style="margin-top: 0; margin-bottom: 10px;">${data.narrative}</p><strong>MECHANICS ENABLED:</strong><br>${mechanicsString}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
factionInput.readOnly = (selectedMode === 'alliance');
|
||||
factionInput.disabled = !perksAreOn;
|
||||
factionInput.style.opacity = perksAreOn ? '1' : '0.5';
|
||||
factionInput.style.pointerEvents = perksAreOn ? 'auto' : 'none';
|
||||
}
|
||||
|
||||
// Add event listeners
|
||||
presetSelector.addEventListener('change', updatePresetView);
|
||||
Object.values(checkboxes).forEach(checkbox => {
|
||||
checkbox.addEventListener('change', () => {
|
||||
if (presetSelector.value === 'custom') {
|
||||
updatePresetView();
|
||||
}
|
||||
function populateFactionDropdown() {
|
||||
const theme = themeSelector.value;
|
||||
if (theme === 'fo3') {
|
||||
leaderInput.value = "Lone Wanderer";
|
||||
factionInput.value = "Brotherhood of Steel";
|
||||
} else if (theme === 'fnv') {
|
||||
leaderInput.value = "Courier Six";
|
||||
factionInput.value = "New California Republic";
|
||||
} else if (theme === 'fo4') {
|
||||
leaderInput.value = "Sole Survivor";
|
||||
factionInput.value = "The Minutemen";
|
||||
}
|
||||
|
||||
optionsContainer.innerHTML = '';
|
||||
const factionThemes = {
|
||||
"fo3": ["Brotherhood of Steel", "The Enclave", "Vault 87 Mutants", "Wasteland Raiders", "BOS Outcasts", "Reilly's Rangers"],
|
||||
"fnv": ["New California Republic", "Caesar's Legion", "New Vegas Securitrons", "Mojave Brotherhood", "Great Khans", "The Fiends"],
|
||||
"fo4": ["The Minutemen", "The Institute", "The Railroad", "The Gunners", "Nuka-World Raiders", "Brotherhood of Steel"]
|
||||
};
|
||||
const factions = factionThemes[theme] || [];
|
||||
factions.forEach(factionName => {
|
||||
const optionDiv = document.createElement('div');
|
||||
optionDiv.textContent = factionName;
|
||||
optionDiv.style.cssText = 'padding: 8px 12px; cursor: pointer;';
|
||||
optionDiv.addEventListener('mousedown', () => { factionInput.value = factionName; optionsContainer.style.display = 'none'; });
|
||||
optionDiv.addEventListener('mouseenter', () => { /* Simplified */ });
|
||||
optionDiv.addEventListener('mouseleave', () => { /* Simplified */ });
|
||||
optionsContainer.appendChild(optionDiv);
|
||||
});
|
||||
}
|
||||
|
||||
// --- Set Up All Event Listeners ---
|
||||
themeSelector.addEventListener('change', () => {
|
||||
applyVisualTheme();
|
||||
populateFactionDropdown();
|
||||
});
|
||||
presetSelector.addEventListener('change', updatePresetView);
|
||||
Object.values(checkboxes).forEach(cb => cb.addEventListener('change', () => { if (presetSelector.value === 'custom') { updatePresetView(); } }));
|
||||
factionInput.addEventListener('focus', () => { if (checkboxes.perks.checked) { optionsContainer.style.display = 'block'; } });
|
||||
document.addEventListener('click', (e) => { if (!factionInput.contains(e.target)) { optionsContainer.style.display = 'none'; } });
|
||||
|
||||
// --- Initial Run on Page Load ---
|
||||
applyVisualTheme();
|
||||
populateFactionDropdown();
|
||||
updatePresetView();
|
||||
});
|
||||
|
||||
// Add event listener and run once on load
|
||||
|
||||
|
||||
let Gamestate = {};
|
||||
// --- ERA-SPECIFIC DYNAMIC THEME LOADER ---
|
||||
const themeSelector = document.getElementById('chosen-theme');
|
||||
const leaderInput = document.getElementById('chosen-leader');
|
||||
const factionInput = document.getElementById('chosen-country-input');
|
||||
|
||||
// =================================================================
|
||||
// NEW CUSTOM DROPDOWN & TOOLTIP LOGIC
|
||||
// =================================================================
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const factionInput = document.getElementById('chosen-country-input');
|
||||
const optionsContainer = document.getElementById('custom-faction-options');
|
||||
const tooltip = document.getElementById('vats-tooltip');
|
||||
|
||||
const perksEnabledCheckbox = document.getElementById('opt-perks');
|
||||
|
||||
if (!factionInput || !optionsContainer || !tooltip) return;
|
||||
|
||||
// --- Function to populate the options ---
|
||||
const populateCustomDropdown = () => {
|
||||
const themeDropdown = document.getElementById('chosen-theme');
|
||||
const selectedTheme = themeDropdown ? themeDropdown.value : "fo3";
|
||||
optionsContainer.innerHTML = ''; // Clear old options
|
||||
|
||||
const factionThemes = {
|
||||
"fo3": ["Brotherhood of Steel", "The Enclave", "Vault 87 Mutants", "Wasteland Raiders", "BOS Outcasts", "Reilly's Rangers"],
|
||||
"fnv": ["New California Republic", "Caesar's Legion", "New Vegas Securitrons", "Mojave Brotherhood", "Great Khans", "The Fiends"],
|
||||
"fo4": ["The Minutemen", "The Institute", "The Railroad", "The Gunners", "Nuka-World Raiders", "Brotherhood of Steel"]
|
||||
};
|
||||
const factions = factionThemes[selectedTheme] || [];
|
||||
|
||||
factions.forEach(factionName => {
|
||||
const optionDiv = document.createElement('div');
|
||||
optionDiv.textContent = factionName;
|
||||
optionDiv.style.padding = '8px 12px';
|
||||
optionDiv.style.cursor = 'pointer';
|
||||
|
||||
// THIS IS THE KEY: We attach mouse events to each custom option DIV
|
||||
optionDiv.addEventListener('mouseenter', (e) => {
|
||||
optionDiv.style.background = 'var(--pip-color)';
|
||||
optionDiv.style.color = 'var(--pip-dark)';
|
||||
const factionData = FACTIONS[factionName];
|
||||
if (factionData && factionData.perk) {
|
||||
tooltip.innerHTML = `<strong>${factionData.perk.name}:</strong> ${factionData.perk.description}`;
|
||||
tooltip.style.display = 'block';
|
||||
}
|
||||
});
|
||||
optionDiv.addEventListener('mouseleave', () => {
|
||||
optionDiv.style.background = '';
|
||||
optionDiv.style.color = '';
|
||||
tooltip.style.display = 'none';
|
||||
});
|
||||
optionDiv.addEventListener('mousemove', (e) => {
|
||||
tooltip.style.left = (e.pageX + 15) + 'px';
|
||||
tooltip.style.top = (e.pageY + 15) + 'px';
|
||||
});
|
||||
optionDiv.addEventListener('mousedown', () => {
|
||||
factionInput.value = factionName;
|
||||
optionsContainer.style.display = 'none';
|
||||
});
|
||||
|
||||
optionsContainer.appendChild(optionDiv);
|
||||
});
|
||||
};
|
||||
|
||||
// --- Event Listeners to control the dropdown ---
|
||||
factionInput.addEventListener('focus', () => {
|
||||
const selectedMode = presetSelector.value;
|
||||
|
||||
// For Alliance Warfare, force the dropdown open and make the input read-only.
|
||||
if (selectedMode === 'alliance') {
|
||||
factionInput.readOnly = true;
|
||||
populateCustomDropdown();
|
||||
optionsContainer.style.display = 'block';
|
||||
}
|
||||
// For other modes with perks, allow the dropdown but also allow typing.
|
||||
else if (checkboxes.perks.checked) {
|
||||
factionInput.readOnly = false;
|
||||
populateCustomDropdown();
|
||||
optionsContainer.style.display = 'block';
|
||||
}
|
||||
// For modes without perks, do nothing, leaving it as a simple textbox.
|
||||
else {
|
||||
factionInput.readOnly = false;
|
||||
}
|
||||
});
|
||||
|
||||
// Initial run on page load
|
||||
updatePresetView();
|
||||
// Add a listener to remove the read-only state if the user switches away from Alliance mode.
|
||||
presetSelector.addEventListener('change', () => {
|
||||
if (presetSelector.value !== 'alliance') {
|
||||
factionInput.readOnly = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Hide dropdown if you click anywhere else
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!factionInput.contains(e.target) && !optionsContainer.contains(e.target)) {
|
||||
optionsContainer.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Also attach populate AND theme-switching logic to theme selector
|
||||
const themeSelector = document.getElementById('chosen-theme');
|
||||
if (themeSelector) {
|
||||
themeSelector.addEventListener('change', (e) => {
|
||||
// The populateCustomDropdown function is now called by the faction input's 'focus' event.
|
||||
// Now, perform all the theme-switching actions
|
||||
const theme = e.target.value;
|
||||
const leaderInput = document.getElementById('chosen-leader');
|
||||
const factionInput = document.getElementById('chosen-country-input');
|
||||
|
||||
// 1. Update cursor color
|
||||
if (typeof updateDynamicCursor === 'function') {
|
||||
if (theme === 'fnv') {
|
||||
updateDynamicCursor('#ffb642');
|
||||
} else if (theme === 'fo4') {
|
||||
updateDynamicCursor('#22ccff');
|
||||
} else {
|
||||
updateDynamicCursor('#18ff62');
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Swap CSS body class
|
||||
document.body.classList.remove('theme-fo3', 'theme-fnv', 'theme-fo4');
|
||||
if (theme !== 'fo3') {
|
||||
document.body.classList.add('theme-' + theme);
|
||||
}
|
||||
|
||||
// 3. Auto-fill default names
|
||||
if (theme === 'fo3') {
|
||||
if (leaderInput) { leaderInput.value = "Lone Wanderer"; }
|
||||
if (factionInput) { factionInput.value = "Brotherhood of Steel"; }
|
||||
} else if (theme === 'fnv') {
|
||||
if (leaderInput) { leaderInput.value = "Courier Six"; }
|
||||
if (factionInput) { factionInput.value = "New California Republic"; }
|
||||
} else if (theme === 'fo4') {
|
||||
if (leaderInput) { leaderInput.value = "Sole Survivor"; }
|
||||
if (factionInput) { factionInput.value = "The Minutemen"; }
|
||||
}
|
||||
});
|
||||
|
||||
themeSelector.dispatchEvent(new Event('change'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Initial population
|
||||
populateCustomDropdown();
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue