Skip to content

Commit

Permalink
Added the ability to retain the last used randomization settings per …
Browse files Browse the repository at this point in the history
…game.
  • Loading branch information
lushen124 committed Jan 24, 2019
1 parent 5096cec commit abbe0e0
Show file tree
Hide file tree
Showing 19 changed files with 585 additions and 22 deletions.
1 change: 1 addition & 0 deletions Universal FE Randomizer/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.swt"/>
<classpathentry kind="lib" path="C:/Users/Lu/Documents/Universal-FE-Randomizer/gson-2.8.5.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions Universal FE Randomizer/src/ui/BasesView.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,33 @@ public BaseOptions getBaseOptions() {

return new BaseOptions(currentMode, redistributionOption, deltaOption, adjustSTRMAGBases);
}

public void setBasesOptions(BaseOptions options) {
if (options == null) {
enableButton.setSelection(false);
setEnableBases(false);
} else {
enableButton.setSelection(true);
setEnableBases(true);
setMode(options.mode);

switch (options.mode) {
case REDISTRIBUTE:
redistributeOption.setSelection(true);
byDeltaOption.setSelection(false);
varianceSpinner.setSelection(options.redistributionOption.variance);
break;
case DELTA:
redistributeOption.setSelection(false);
byDeltaOption.setSelection(true);
deltaSpinner.setSelection(options.deltaOption.variance);
break;
}

if (adjustSTRMAG != null) {
adjustSTRMAG.setSelection(options.adjustSTRMAGByClass);
}
}
}

}
21 changes: 21 additions & 0 deletions Universal FE Randomizer/src/ui/ClassesView.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,25 @@ public ClassOptions getClassOptions() {
return new ClassOptions(pcsEnabled, lordsEnabled, thievesEnabled, randomizeEnemiesButton.getSelection(), randomizeBossesButton.getSelection());
}
}

public void setClassOptions(ClassOptions options) {
if (options == null) {
// Shouldn't happen.
} else {
if (options.randomizePCs) {
randomizePCButton.setSelection(true);
randomizePCLordsButton.setEnabled(true);
randomizePCThievesButton.setEnabled(true);
randomizePCLordsButton.setSelection(options.includeLords);
randomizePCThievesButton.setSelection(options.includeThieves);
if (hasMonsterOption) {
mixMonsterClasses.setEnabled(true);
mixMonsterClasses.setSelection(options.separateMonsters);
}
}

randomizeEnemiesButton.setSelection(options.randomizeEnemies);
randomizeBossesButton.setSelection(options.randomizeBosses);
}
}
}
33 changes: 33 additions & 0 deletions Universal FE Randomizer/src/ui/EnemyBuffsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,37 @@ public EnemyOptions getEnemyOptions() {
}
}
}

public void setEnemyOptions(EnemyOptions options) {
if (options == null) {
// Shouldn't happen.
} else {
switch (options.mode) {
case NONE:
buffEnemyGrowthsButton.setSelection(false);
flatBonusButton.setEnabled(false);
scalingBonusButton.setEnabled(false);
buffSpinner.setEnabled(false);
break;
case FLAT:
buffEnemyGrowthsButton.setSelection(true);
flatBonusButton.setEnabled(true);
scalingBonusButton.setEnabled(true);
flatBonusButton.setSelection(true);
scalingBonusButton.setSelection(false);
buffSpinner.setEnabled(true);
buffSpinner.setSelection(options.buffAmount);
break;
case SCALING:
buffEnemyGrowthsButton.setSelection(true);
flatBonusButton.setEnabled(true);
scalingBonusButton.setEnabled(true);
flatBonusButton.setSelection(false);
scalingBonusButton.setSelection(true);
buffSpinner.setEnabled(true);
buffSpinner.setSelection(options.buffAmount);
break;
}
}
}
}
38 changes: 38 additions & 0 deletions Universal FE Randomizer/src/ui/GrowthsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,42 @@ public GrowthOptions getGrowthOptions() {

return new GrowthOptions(currentMode, redistributionOption, deltaOption, fullOption, adjustHPGrowths.getSelection(), adjustSTRMAG);
}

public void setGrowthOptions(GrowthOptions options) {
if (options == null) {
enableButton.setSelection(false);
setEnableGrowths(false);
} else {
enableButton.setSelection(true);
setEnableGrowths(true);
setMode(options.mode);

switch (options.mode) {
case REDISTRIBUTE:
redistributeOption.setSelection(true);
byDeltaOption.setSelection(false);
fullRandomOption.setSelection(false);
varianceSpinner.setSelection(options.redistributionOption.variance);
break;
case DELTA:
redistributeOption.setSelection(false);
byDeltaOption.setSelection(true);
fullRandomOption.setSelection(false);
deltaSpinner.setSelection(options.deltaOption.variance);
break;
case FULL:
redistributeOption.setSelection(false);
byDeltaOption.setSelection(false);
fullRandomOption.setSelection(true);
growthRangeControl.setMin(options.fullOption.minValue);
growthRangeControl.setMax(options.fullOption.maxValue);
break;
}

adjustHPGrowths.setSelection(options.adjustHP);
if (adjustSTRMAGSplit != null) {
adjustSTRMAGSplit.setSelection(options.adjustSTRMAGSplit);
}
}
}
}
23 changes: 23 additions & 0 deletions Universal FE Randomizer/src/ui/MOVCONAffinityView.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,27 @@ public OtherCharacterOptions getOtherCharacterOptions() {

return new OtherCharacterOptions(movementOptions, constitutionOptions, randomizeAffinityButton.getSelection());
}

public void setOtherCharacterOptions(OtherCharacterOptions options) {
if (options == null) {
// Shouldn't happen.
} else {
if (options.movementOptions != null) {
randomizeMOVButton.setSelection(true);
movLimitControl.setEnabled(true);
movLimitControl.setMin(options.movementOptions.minValue);
movLimitControl.setMax(options.movementOptions.maxValue);
}

if (options.constitutionOptions != null) {
randomizeCONButton.setSelection(true);
minCONSpinner.setEnabled(true);
varianceSpinner.setEnabled(true);
minCONSpinner.setSelection(options.constitutionOptions.minValue);
varianceSpinner.setSelection(options.constitutionOptions.variance);
}

randomizeAffinityButton.setSelection(options.randomizeAffinity);
}
}
}
52 changes: 51 additions & 1 deletion Universal FE Randomizer/src/ui/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
import ui.general.OpenFileFlow;
import ui.general.ProgressModal;
import util.DiffCompiler;
import util.OptionRecorder;
import util.SeedGenerator;
import util.OptionRecorder.FE4OptionBundle;
import util.OptionRecorder.GBAOptionBundle;
import util.recordkeeper.RecordKeeper;

public class MainView implements FileFlowDelegate {
Expand Down Expand Up @@ -89,7 +92,7 @@ public MainView(Display mainDisplay) {
super();

Shell shell = new Shell(mainDisplay, SWT.SHELL_TRIM & ~SWT.RESIZE & ~SWT.MAX);
shell.setText("Yune: A Universal Fire Emblem Randomizer (v0.7.2)");
shell.setText("Yune: A Universal Fire Emblem Randomizer (v0.7.3)");
shell.setImage(new Image(mainDisplay, Main.class.getClassLoader().getResourceAsStream("YuneIcon.png")));

mainShell = shell;
Expand Down Expand Up @@ -211,6 +214,32 @@ private void disposeRandomizationOptionsViews() {
mainShell.setSize(newSize);
}

private void preloadOptions(GameType type) {
if (type == GameType.FE4 && OptionRecorder.options.fe4 != null) {
FE4OptionBundle bundle = OptionRecorder.options.fe4;
growthView.setGrowthOptions(bundle.growths);
baseView.setBasesOptions(bundle.bases);
holyBloodView.setHolyBloodOptions(bundle.holyBlood);
miscView.setMiscellaneousOptions(bundle.misc);
skillsView.setSkillOptions(bundle.skills);
fe4ClassView.setClassOptions(bundle.classes);
} else if (type.isGBA()) {
GBAOptionBundle bundle = null;
if (type == GameType.FE6) { bundle = OptionRecorder.options.fe6; }
else if (type == GameType.FE7) { bundle = OptionRecorder.options.fe7; }
else if (type == GameType.FE8) { bundle = OptionRecorder.options.fe8; }
if (bundle != null) {
growthView.setGrowthOptions(bundle.growths);
baseView.setBasesOptions(bundle.bases);
otherCharOptionView.setOtherCharacterOptions(bundle.other);
weaponView.setWeaponOptions(bundle.weapons);
classView.setClassOptions(bundle.classes);
enemyView.setEnemyOptions(bundle.enemies);
miscView.setMiscellaneousOptions(bundle.otherOptions);
}
}
}

private void updateLayoutForGameType(GameType type) {

disposeRandomizationOptionsViews();
Expand Down Expand Up @@ -456,6 +485,9 @@ else if (handler.getCRC32() == FE4Data.CleanHeaderedCRC32 || handler.getCRC32()

loadedGameType = type;

// Preload options if there are any.
preloadOptions(type);

final GameType gameType = type;

if (type != GameType.UNKNOWN) {
Expand Down Expand Up @@ -536,6 +568,16 @@ public void handleEvent(Event event) {
enemyView.getEnemyOptions(),
miscView.getMiscellaneousOptions(),
seedField.getText());

OptionRecorder.recordGBAFEOptions(gameType,
growthView.getGrowthOptions(),
baseView.getBaseOptions(),
classView.getClassOptions(),
weaponView.getWeaponOptions(),
otherCharOptionView.getOtherCharacterOptions(),
enemyView.getEnemyOptions(),
miscView.getMiscellaneousOptions(),
seedField.getText());
} else if (gameType.isSFC()) {
if (gameType == GameType.FE4) {
boolean headeredROM = handler.getCRC32() == FE4Data.CleanHeaderedCRC32;;
Expand All @@ -547,6 +589,14 @@ public void handleEvent(Event event) {
fe4ClassView.getClassOptions(),
miscView.getMiscellaneousOptions(),
seedField.getText());

OptionRecorder.recordFE4Options(growthView.getGrowthOptions(),
baseView.getBaseOptions(),
holyBloodView.getHolyBloodOptions(),
skillsView.getSkillOptions(),
fe4ClassView.getClassOptions(),
miscView.getMiscellaneousOptions(),
seedField.getText());
}
}

Expand Down
16 changes: 16 additions & 0 deletions Universal FE Randomizer/src/ui/MiscellaneousView.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,20 @@ public MiscellaneousOptions getMiscellaneousOptions() {

return new MiscellaneousOptions(false, false, false);
}

public void setMiscellaneousOptions(MiscellaneousOptions options) {
if (options == null) {
// Shouldn't happen.
} else {
if (applyEnglishPatch != null) {
applyEnglishPatch.setSelection(options.applyEnglishPatch);
}
if (randomizeChestVillageRewards != null) {
randomizeChestVillageRewards.setSelection(options.randomizeRewards);
}
if (randomizeRecruitmentOrder != null) {
randomizeRecruitmentOrder.setSelection(options.randomizeRecruitment);
}
}
}
}
17 changes: 17 additions & 0 deletions Universal FE Randomizer/src/ui/WeaponEffectSelectionView.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,23 @@ public WeaponEffectOptions getOptions() {
return new WeaponEffectOptions(noneEnabled, statBoostsEnabled, effectivenessEnabled, unbreakableEnabled, braveEnabled, reverseEnabled, rangeEnabled, criticalEnabled, magicEnabled, poisonEnabled, eclipseEnabled, devilEnabled);
}

public void setOptions(WeaponEffectOptions options) {
if (options != null) {
noneCheckBox.setSelection(options.none);
statBoostsCheckBox.setSelection(options.statBoosts);
effectivenessCheckBox.setSelection(options.effectiveness);
unbreakableCheckBox.setSelection(options.unbreakable);
braveCheckBox.setSelection(options.brave);
reverseTriangleCheckBox.setSelection(options.reverseTriangle);
extendedRangeCheckBox.setSelection(options.extendedRange);
highCriticalCheckBox.setSelection(options.highCritical);
magicDamageCheckBox.setSelection(options.magicDamage);
poisonCheckBox.setSelection(options.poison);
if (eclipseCheckBox != null) { eclipseCheckBox.setSelection(options.eclipse); }
devilCheckBox.setSelection(options.devil);
}
}

public void notifySelectionChange() {
noneEnabled = noneCheckBox.getSelection();
statBoostsEnabled = statBoostsCheckBox.getSelection();
Expand Down
50 changes: 50 additions & 0 deletions Universal FE Randomizer/src/ui/WeaponsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,54 @@ public WeaponOptions getWeaponOptions() {

return new WeaponOptions(mightOptions, hitOptions, weightOptions, durabilityOptions, enableRandomEffectsButton.getSelection(), effectsSelectionView.getOptions(), noEffectsForIronButton.getSelection());
}

public void setWeaponOptions(WeaponOptions options) {
if (options == null) {
// Shouldn't happen.
} else {
if (options.mightOptions != null) {
enableMightButton.setSelection(true);
mightRangeControl.setEnabled(true);
mightRangeControl.setMin(options.mightOptions.minValue);
mightRangeControl.setMax(options.mightOptions.maxValue);
mightVarianceSpinner.setEnabled(true);
mightVarianceSpinner.setSelection(options.mightOptions.variance);
}

if (options.hitOptions != null) {
enableHitButton.setSelection(true);
hitRangeControl.setEnabled(true);
hitRangeControl.setMin(options.hitOptions.minValue);
hitRangeControl.setMax(options.hitOptions.maxValue);
hitVarianceSpinner.setEnabled(true);
hitVarianceSpinner.setSelection(options.hitOptions.variance);
}

if (options.weightOptions != null) {
enableWeightButton.setSelection(true);
weightRangeControl.setEnabled(true);
weightRangeControl.setMin(options.weightOptions.minValue);
weightRangeControl.setMax(options.weightOptions.maxValue);
weightVarianceSpinner.setEnabled(true);
weightVarianceSpinner.setSelection(options.weightOptions.variance);
}

if (options.durabilityOptions != null) {
enableDurabilityButton.setSelection(true);
durabilityRangeControl.setEnabled(true);
durabilityRangeControl.setMin(options.durabilityOptions.minValue);
durabilityRangeControl.setMax(options.durabilityOptions.maxValue);
durabilityVarianceSpinner.setEnabled(true);
durabilityVarianceSpinner.setSelection(options.durabilityOptions.variance);
}

if (options.shouldAddEffects) {
enableRandomEffectsButton.setSelection(true);
effectsSelectionView.setEnabled(true);
noEffectsForIronButton.setEnabled(true);
effectsSelectionView.setOptions(options.effectsList);
noEffectsForIronButton.setSelection(options.noEffectIronWeapons);
}
}
}
}
Loading

0 comments on commit abbe0e0

Please sign in to comment.