Skip to content

Commit 22bcb98

Browse files
committed
revamp menu preset init process
1 parent 7f27adc commit 22bcb98

File tree

8 files changed

+62
-213
lines changed

8 files changed

+62
-213
lines changed

mod-menu.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<PresetsArray>
66
<Preset id="0" displayName="rer_defaults" >
77
<Entry varId="RERmodEnabled" value="1" />
8+
<Entry varId="RERmenuPreset" value="1" />
89
<Entry varId="Difficulty" value="4" />
910
<Entry varId="RERlevelScaling" value="0" />
1011
<Entry varId="RERexternalFactorsImpact" value="2" />
@@ -18,6 +19,20 @@
1819
<Var id="RERmodEnabled" displayName="rer_mod_enabled" displayType="TOGGLE"></Var>
1920
<Var id="RERperformanceMode" displayName="rer_performance_mode" displayType="TOGGLE"></Var>
2021

22+
<Var id="RERmenuPreset" displayName="rer_menu_preset" displayType="OPTIONS">
23+
<OptionsArray>
24+
<Option id="0" displayName="rer_default">
25+
<Entry varId="RERmenuPreset" value="0"/>
26+
</Option>
27+
<Option id="1" displayName="rer_menu_preset_none">
28+
<Entry varId="RERmenuPreset" value="1"/>
29+
</Option>
30+
<Option id="2" displayName="rer_menu_preset_enhanced_edition">
31+
<Entry varId="RERmenuPreset" value="2"/>
32+
</Option>
33+
</OptionsArray>
34+
</Var>
35+
2136
<Var id="Separator" displayName="" displayType="SUBTLE_SEPARATOR"/>
2237

2338
<Var id="RERgeneralIntensity" displayName="rer_general_intensity" displayType="SLIDER;0;500;500"/>

src/helpers/menu_descriptors/main.wss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ class RER_MainMenuDescriptor extends SU_MenuDescriptor {
88

99
this.onHover(
1010
'RERperformanceMode',
11-
"Enabling <font color='#CD7D03'>Performance Mode</font> will alter how the mod operates to focus even more on performances, sometimes by ignoring the values from the menu to use pre-defined ones, or by disabling features like the Ecosystem for a smoother experience at the cost of immersion.<br/><br/>Changes to the option requires a reload of the save to take effect."
11+
"Enabling <font color='#CD7D03'>Performance Mode</font> will alter how the mod operates to focus even more on performances, sometimes by ignoring the values from the menu to use pre-defined ones, or by disabling features like the Ecosystem for a smoother experience at the cost of immersion. Note that this option is only useful if you notice a framerate drop caused by your CPU being pushed to its maximum capacity.<br/><br/>Changes to the option requires a reload of the save to take effect."
12+
);
13+
14+
this.onHover(
15+
'RERmenuPreset',
16+
"Setting this option to anything else than <font color='#CD7D03'>No preset</font> will tell the mod to update all of the settings according to the selected preset the next time you load a save. The mod does NOT have to be enabled for this option to take effect, in fact it will also cause the mod to enable itself once the preset is applied."
1217
);
1318

1419
this.onHoverDynamic(
@@ -35,7 +40,7 @@ class RER_MainMenuDescriptor extends SU_MenuDescriptor {
3540
);
3641

3742
if (value > 200.0) {
38-
return description + "<br/><br/>A value above 200% can cause performance issues from the amount of spawns it will cause, adjust encounter settings and more specifically the death threshold accordingly (a lower value).";
43+
return description + "<br/><br/>A value above 200% can cause performance issues from the amount of spawns it will create, adjust encounter settings and more specifically the death threshold accordingly (a lower value).";
3944
}
4045
}
4146

src/settings.wss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ class RE_Settings {
232232
);
233233
}
234234

235-
public function shouldResetRERSettings(inGameConfigWrapper: CInGameConfigWrapper): bool {
236-
return StringToFloat(inGameConfigWrapper.GetVarValue('RERmain', 'RERmodVersion')) <= 0;
237-
}
238-
239235
private function loadModEnabledSettings(inGameConfigWrapper: CInGameConfigWrapper) {
240236
this.is_enabled = inGameConfigWrapper.GetVarValue('RERmain', 'RERmodEnabled');
241237
}

src/states/initialising/initialising.wss

Lines changed: 5 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ state Initialising in CRandomEncounters {
3333
return;
3434
}
3535

36-
if (parent.settings.shouldResetRERSettings(theGame.GetInGameConfigWrapper())) {
37-
this.displayPresetChoiceDialogeMenu();
38-
}
39-
36+
this.tryApplyMenuPreset();
4037
this.removeAllRerMapPins();
4138
this.updateSettings();
4239

@@ -88,188 +85,30 @@ state Initialising in CRandomEncounters {
8885
constants = RER_Constants();
8986
current_version = StringToFloat(config.GetVarValue('RERmain', 'RERmodVersion'));
9087

91-
if (current_version < 2.07) {
92-
config.ApplyGroupPreset('RERcontracts', 0);
93-
94-
current_version = 2.07;
95-
}
96-
97-
if (current_version < 2.08) {
98-
NDEBUG("[RER] The mod was updated to v2.8: the Contract System settings were reset to support the new reputation system");
99-
100-
// reset the contract tutorial value so it displays again
101-
// config.SetVarValue('RERtutorials', 'RERtutorialMonsterContract', 1);
102-
config.ApplyGroupPreset('RERcontracts', 0);
103-
104-
current_version = 2.08;
105-
}
106-
107-
if (current_version < 2.09) {
108-
NDEBUG("[RER] The mod was updated to v2.9: the Contract System settings were reset to support updated distance settings");
109-
110-
// reset the contract tutorial value so it displays again
111-
// config.SetVarValue('RERtutorials', 'RERtutorialMonsterContract', 1);
112-
config.ApplyGroupPreset('RERcontracts', 0);
113-
114-
// disable any active bounty from before v2.9 since it won't be compatible
115-
// anymore.
116-
parent.storages.bounty.current_bounty.is_active = false;
117-
118-
current_version = 2.09;
119-
}
120-
121-
if (current_version < 2.11) {
122-
NDEBUG("[RER] The mod was updated to v2.11");
123-
124-
current_version = 2.11;
125-
}
126-
127-
if (current_version < 2.12) {
128-
var message: string;
129-
130-
message += "You just updated the Random Encounters Reworked mod to the v2.12, the loot update.<br/><br/>";
131-
message += "All of your reward settings were reset following the update. ";
132-
message += "To simplify and streamline the loot coming from the mod, all of the old rewards were removed and replaced ";
133-
message += "with a central and generic system. This system called the Loot Manager offers four loot categories:";
134-
message += "<br/> - Gear";
135-
message += "<br/> - Materials";
136-
message += "<br/> - Consumables";
137-
message += "<br/> - Valuables";
138-
message += "<br/>And for each category it offers four loot rarities: ";
139-
message += "<br/> - Common";
140-
message += "<br/> - Uncommon";
141-
message += "<br/> - Rare";
142-
message += "<br/> - Exotic";
143-
message += "<br/><br/>Now every time RER wants to add loot to something, it sends a call to the loot manager which will ";
144-
message += "give it a list of items based on the settings you set in the menu, and this for every feature in the mod.";
145-
146-
NTUTO("RER v2.12 - The loot update", message);
147-
148-
config.ApplyGroupPreset('RERrewardsGeneral', 0);
149-
config.ApplyGroupPreset('RERcontainerRefill', 0);
150-
config.ApplyGroupPreset('RERkillingSpreeCustomLoot', 0);
151-
config.ApplyGroupPreset('RERmonsterTrophies', 0);
152-
config.ApplyGroupPreset('RERcontracts', 0);
153-
154-
current_version = 2.12;
155-
}
156-
157-
if (current_version < 2.13) {
158-
config.ApplyGroupPreset('RERmonsterTrophies', 0);
159-
160-
if (RER_playerUsesEnhancedEditionRedux()) {
161-
config.SetVarValue('RERmonsterTrophies', 'RERtrophyMasterBuyingPrice', 30);
162-
}
163-
164-
current_version = 2.13;
165-
}
166-
167-
if (current_version < 3.0) {
168-
current_version = 3.0;
169-
170-
config.ApplyGroupPreset('RERtutorials', 0);
171-
}
172-
173-
if (current_version < 3.01) {
174-
current_version = 3.01;
175-
176-
var message: string;
177-
message += "Random Encounters Reworked was updated to the v3.1 - The Next-Gen update";
178-
message += "<br/>A new settings was enabled automatically: disable encounter spawns when near quest markers.";
179-
message += "If you wish to turn it off, you can find the toggle at the bottom of the Encounters System, General menu";
180-
NTUTO("RER v3.1 - Next-Gen update", message);
181-
182-
config.SetVarValue('RERmonsterTrophies', 'RERtrophyMasterBuyingPrice', 1);
183-
config.ApplyGroupPreset('RERtutorials', 0);
184-
}
185-
186-
if (current_version < 3.02) {
187-
current_version = 3.02;
188-
189-
var message: string;
190-
message += "Random Encounters Reworked was updated to the v3.2";
191-
message += "<br/>This version brings two major changes:";
192-
message += "<br/><br/>" + RER_yellowFont("Standalone 3D markers") + " for the various things spawned by the mod "
193-
+ "were added. You can toggle them ON or OFF in the " + RER_yellowFont("Optional Features") + " menu.";
194-
195-
message += "<br/><br/>" + RER_yellowFont("Contract rewards streamlining") + ", the random nature of Tokens of Gratitude "
196-
+ "plus the need to find the bounty master to sell them was frustrating. "
197-
+ "A new option (that is enabled by default) was added to the Contracts menu to give crowns directly instead "
198-
+ "of tokens. If you prefer the Tokens way of getting reward, this solution was streamlined to no longer "
199-
+ "scale with your current reputation but instead scale linearly with the contract's difficulty: 1 plus "
200-
+ "an additional token every 7 Contract levels";
201-
202-
NTUTO("RER v3.2 - 3D Markers & Contract rewards", message);
203-
204-
config.SetVarValue('RERoptionalFeatures', 'RERonelinersBountyMainTarget', 1);
205-
config.SetVarValue('RERoptionalFeatures', 'RERonelinersContract', 1);
206-
config.SetVarValue('RERoptionalFeatures', 'RERonelinersBountyMaster', 1);
207-
config.SetVarValue('RERmonsterCrowns', 'RERcrownsContract', 40);
208-
config.SetVarValue('RERcontracts', 'RERcontractsRewardOption', 0);
209-
}
210-
211-
if (current_version < 3.03) {
212-
current_version = 3.03;
213-
214-
config.SetVarValue('RERcontracts', 'RERcontractsDeathReputationLossAmount', 1);
215-
216-
NTUTO("RER v3.3", "The mod was successfully updated to v3.3");
217-
}
218-
219-
if (current_version < 3.04) {
220-
current_version = 3.04;
221-
222-
config.SetVarValue('RERmain', 'RERlevelScaling', 0);
223-
config.ApplyGroupPreset('RERcontracts', 0);
224-
225-
NTUTO("RER v3.4", "The mod was successfully updated to v3.4");
226-
}
227-
22888
if (current_version < 3.05) {
22989
current_version = 3.05;
23090

23191
config.SetVarValue('RERmain', 'RERgeneralIntensity', 100);
23292

233-
NTUTO("RER v3.5", "The mod was successfully updated to v3.5");
93+
NDEBUG("Random Encounters Reworked was successfully updated to v3.5");
23494
}
23595

23696
config.SetVarValue('RERmain', 'RERmodVersion', constants.version);
23797
theGame.SaveUserSettings();
23898
}
23999

240-
latent function displayPresetChoiceDialogeMenu() {
241-
var choices: array<SSceneChoice>;
242-
var manager: RER_PresetManager;
243-
var response: SSceneChoice;
244-
245-
manager = new RER_PresetManager in this;
246-
manager.master = parent;
247-
248-
choices = manager.getChoiceList();
249-
100+
latent function tryApplyMenuPreset() {
250101
while (isPlayerBusy()) {
251102
Sleep(5);
252103
}
253104

254105
Sleep(5);
255106

256-
(new RER_RandomDialogBuilder in thePlayer).start()
257-
.dialog(new REROL_whoa_in_for_one_helluva_ride in thePlayer, true)
258-
.play();
259-
260-
response = SU_setDialogChoicesAndWaitForResponse(choices);
261-
SU_closeDialogChoiceInterface();
262-
manager.GotoState(response.playGoChunk);
263-
107+
var manager: RER_PresetManager = new RER_PresetManager in this;
108+
manager.tryApplyMenuPreset(RER_getModMenuPreset(), parent);
264109
while (!manager.done) {
265110
SleepOneFrame();
266111
}
267-
268-
(new RER_RandomDialogBuilder in thePlayer).start()
269-
.dialog(new REROL_ready_to_go_now in thePlayer, true)
270-
.play();
271-
272-
theGame.SaveUserSettings();
273112
}
274113

275114
private function removeAllRerMapPins() {

src/states/initialising/presets/enhanced_edition.wss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ state EnhancedEdition in RER_PresetManager {
7272
this.wrapperMultiplyFloatValue(wrapper, 'RERmonsterTrophies', 'RERtrophyMasterBuyingPrice', 0.65);
7373

7474
theGame.SaveUserSettings();
75-
7675
parent.done = true;
76+
parent.displayPresetAppliedPopup("Enhanced Edition (W3EE)");
7777
}
7878

7979
function wrapperMultiplyFloatValue(wrapper: CInGameConfigWrapper, menu: name, value: name, multiplier: float) {

src/states/initialising/presets/preset_manager.wss

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,41 @@ statemachine class RER_PresetManager {
33
public var done: bool;
44
public var master: CRandomEncounters;
55

6-
public function getPresetList(): array<RER_Preset> {
7-
var output: array<RER_Preset>;
8-
9-
output.PushBack(RER_Preset(
10-
"rer_dialog_preset_vanilla",
11-
'Vanilla'
12-
));
13-
14-
output.PushBack(RER_Preset(
15-
"rer_dialog_preset_enhanced_edition",
16-
'EnhancedEdition'
6+
public function displayPresetAppliedPopup(preset_name: string) {
7+
NDEBUG(StrReplace(
8+
GetLocStringByKey()
9+
"{{preset_name}}",
10+
preset_name
1711
));
12+
}
1813

19-
output.PushBack(RER_Preset(
20-
"rer_dialog_preset_exit_do_nothing",
21-
'Exit'
22-
));
14+
public function tryApplyMenuPreset(
15+
preset: RER_MenuPreset,
16+
master: CRandomEncounters
17+
) {
18+
this.done = false;
19+
this.master = master;
2320

24-
return output;
25-
}
21+
if (preset == RER_MenuPreset_Default) {
22+
this.GotoState('Vanilla');
23+
return;
24+
}
2625

27-
public function getChoiceList(): array<SSceneChoice> {
28-
var presets: array<RER_Preset>;
29-
var choices: array<SSceneChoice>;
30-
var i: int;
31-
32-
presets = this.getPresetList();
33-
34-
for (i = 0; i < presets.Size(); i += 1) {
35-
choices.PushBack(SSceneChoice(
36-
GetLocStringByKey(presets[i].dialog_string_key),
37-
false,
38-
false,
39-
false,
40-
DialogAction_GAME_DAGGER,
41-
presets[i].state_name
42-
));
26+
if (preset == RER_MenuPreset_EnhancedEdition) {
27+
this.GotoState('EnhancedEdition');
28+
return;
4329
}
4430

45-
return choices;
31+
this.done = true;
4632
}
4733
}
4834

49-
struct RER_Preset {
50-
var dialog_string_key: string;
51-
var state_name: name;
35+
enum RER_MenuPreset {
36+
RER_MenuPreset_Default = 0,
37+
RER_MenuPreset_None = 1,
38+
RER_MenuPreset_EnhancedEdition = 2,
39+
}
40+
41+
function RER_getModMenuPreset(): RER_MenuPreset {
42+
return StringToInt(RER_menu('RERmain', 'RERmenuPreset'));
5243
}

src/states/initialising/presets/vanilla.wss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ state Vanilla in RER_PresetManager {
99

1010
entry function Vanilla_applySettings() {
1111
parent.master.settings.resetRERSettings(theGame.GetInGameConfigWrapper());
12-
1312
parent.done = true;
13+
parent.displayPresetAppliedPopup("Defaults / Vanilla");
1414
}
15-
1615
}

strings/en.w3strings.csv

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,4 +556,8 @@
556556
2115018488| |rer_surround_ecosystem_popup_body|This area and its vicinity are now teeming with {{teeming_creature_names}}. The possibility of encountering {{less_likely_creature_names}} is now less likely.<br /><br />{{ecosystem_advice}}<br /><br />{{ecosystem_delay_multiplier}}
557557
2115018489| |rer_ecosystem_advice|A large community of {{creature_name}} lives here due to the abundance of {{advice_creature_names}} As a result, other creatures such as {{other_creature_names}} may roam the area.
558558
2115018490| |rer_ecosystem_addition_advice|<br />In addition, {{creature_name}} prevent {{advice_creature_names}} from residing here.
559-
2115018491| |rer_ecosystem_delay_multiplier|Creatures in the area are multiplying at {{rate_parent}} of their usual rate.
559+
2115018491| |rer_ecosystem_delay_multiplier|Creatures in the area are multiplying at {{rate_parent}} of their usual rate.
560+
2115018492| |option_rer_menu_preset|Menu preset
561+
2115018493| |option_rer_menu_preset_enhanced_edition|Enhanced Edition (W3EE)
562+
2115018494| |option_rer_menu_preset_none|No preset
563+
2115018495| |rer_menu_preset_applied_message|<u>Random Encounters Reworked</u><br/><br/>The mod is enabled and its settings were set to the <font color="#ffd33d">{{preset_name}</font> preset. If you are using an overhaul like Enhanced Edition (W3EE), make sure to visit the mod's general menu to apply the dedicated preset for a smoother experience.

0 commit comments

Comments
 (0)