Skip to content

Commit 4390b56

Browse files
committed
Add state to LevelOrder, add Item Capsule randomization option
1 parent 52f1385 commit 4390b56

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

ShadowRando/Core/Settings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ public class SettingsLayout
123123
public SettingsLayoutWeapon Weapon = new SettingsLayoutWeapon();
124124
[IniAlwaysInclude]
125125
public SettingsLayoutPartner Partner = new SettingsLayoutPartner();
126+
[IniAlwaysInclude]
127+
public SettingsLayoutMisc Misc = new SettingsLayoutMisc();
126128
}
127129

128130
public class SettingsLayoutEnemy
@@ -172,6 +174,12 @@ public class SettingsLayoutPartner
172174
public List<Object0190_Partner.EPartner> SelectedPartners = [];
173175
}
174176

177+
public class SettingsLayoutMisc
178+
{
179+
[IniAlwaysInclude]
180+
public bool RandomItemCapsules;
181+
}
182+
175183
public class SettingsSubtitles
176184
{
177185
[IniAlwaysInclude]

ShadowRando/Views/MainView.axaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</CheckBox>
4343
</Grid>
4444
<Label Margin="0,20,0,0">Mode</Label>
45-
<ComboBox x:Name="LevelOrder_ComboBox_Mode" SelectedIndex="1" MinWidth="225">
45+
<ComboBox x:Name="LevelOrder_ComboBox_Mode" SelectionChanged="Shared_ComboBox_OnSelectionChanged" SelectedIndex="1" MinWidth="225">
4646
<ComboBoxItem>Default Order</ComboBoxItem>
4747
<ComboBoxItem>Shuffle All Stages w/Warps</ComboBoxItem>
4848
<ComboBoxItem>Vanilla Structure</ComboBoxItem>
@@ -682,7 +682,12 @@
682682
</Grid>
683683
</StackPanel>
684684
</TabItem>
685-
</TabControl>
685+
<TabItem Header="Misc">
686+
<StackPanel>
687+
<CheckBox x:Name="Layout_Misc_CheckBox_RandomItemCapsules">Random Item Capsules</CheckBox>
688+
</StackPanel>
689+
</TabItem>
690+
</TabControl>
686691
</StackPanel>
687692
</TabItem>
688693
<TabItem Header="Subtitles">
@@ -796,7 +801,7 @@
796801
<TabItem Header="Models">
797802
<StackPanel>
798803
<CheckBox x:Name="Models_CheckBox_RandomizeModel">Randomize Player Model</CheckBox>
799-
<CheckBox x:Name="Models_CheckBox_ModelP2">Randomize Player 2's Model</CheckBox>
804+
<CheckBox x:Name="Models_CheckBox_ModelP2" IsEnabled ="False">Randomize Player 2's Model</CheckBox>
800805
</StackPanel>
801806
</TabItem>
802807
<TabItem Header="Spoilers">

ShadowRando/Views/MainView.axaml.cs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
using ShadowSET;
2424
using ShadowSET.SETIDBIN;
2525
using SkiaSharp;
26-
using static System.Net.Mime.MediaTypeNames;
2726
using TableEntry = ShadowFNT.Structures.TableEntry;
2827

2928
namespace ShadowRando.Views;
@@ -513,6 +512,9 @@ private void UserControl_Loaded(object? sender, RoutedEventArgs e)
513512
foreach (var par in settings.Layout.Partner.SelectedPartners)
514513
PartnerCheckBoxes[(int)par - 1].IsChecked = true;
515514

515+
// Layout Misc
516+
Layout_Misc_CheckBox_RandomItemCapsules.IsChecked = settings.Layout.Misc.RandomItemCapsules;
517+
516518
// Subtitles
517519
Subtitles_CheckBox_RandomizeSubtitlesVoicelines.IsChecked = settings.Subtitles.Randomize;
518520
Subtitles_CheckBox_NoDuplicates.IsChecked = settings.Subtitles.NoDuplicates;
@@ -609,6 +611,9 @@ private void UpdateSettings()
609611
if (PartnerCheckBoxes[i].IsChecked == true)
610612
settings.Layout.Partner.SelectedPartners.Add((Object0190_Partner.EPartner)(i + 1));
611613

614+
// Misc
615+
settings.Layout.Misc.RandomItemCapsules = Layout_Misc_CheckBox_RandomItemCapsules.IsChecked.Value;
616+
612617
// Subtitles
613618
settings.Subtitles.Randomize = Subtitles_CheckBox_RandomizeSubtitlesVoicelines.IsChecked.Value;
614619
settings.Subtitles.NoDuplicates = Subtitles_CheckBox_NoDuplicates.IsChecked.Value;
@@ -2152,6 +2157,15 @@ private int RandomizeLayouts(Random r)
21522157
RandomizeEnvironmentWeaponDrops(ref ds1LayoutData, weaponsPool, r);
21532158
}
21542159

2160+
if (settings.Layout.Misc.RandomItemCapsules)
2161+
{
2162+
RandomizeItemCapsules(ref cmnLayoutData, r);
2163+
if (nrmLayoutData != null)
2164+
RandomizeItemCapsules(ref nrmLayoutData, r);
2165+
if (hrdLayoutData != null)
2166+
RandomizeItemCapsules(ref hrdLayoutData, r);
2167+
}
2168+
21552169
if (settings.Layout.Partner.Mode == LayoutPartnerMode.Wild)
21562170
{
21572171
MakeAllPartnersRandom(ref cmnLayoutData, settings.Layout.Partner.KeepAffiliationsAtSameLocation, darkPartners, heroPartners, r);
@@ -2708,6 +2722,21 @@ private static void RandomizeEnvironmentWeaponDrops(ref List<SetObjectShadow> se
27082722
}
27092723
}
27102724

2725+
private static void RandomizeItemCapsules(ref List<SetObjectShadow> setData, Random r)
2726+
{
2727+
List<(Object0012_ItemCapsule item, int index)> itemCapsuleItems = setData
2728+
.Select((item, index) => new { Item = item, Index = index })
2729+
.Where(pair => pair.Item is Object0012_ItemCapsule)
2730+
.Select(pair => (Item: (Object0012_ItemCapsule)pair.Item, Index: pair.Index))
2731+
.ToList();
2732+
2733+
foreach (var capsule in itemCapsuleItems)
2734+
{
2735+
capsule.item.Item = (EItemShadow)r.Next(11);
2736+
setData[capsule.index] = capsule.item;
2737+
}
2738+
}
2739+
27112740
private static void DelinkVehicleObjects(ref List<SetObjectShadow> setData)
27122741
{
27132742
List<(Object004F_Vehicle item, int index)> vehicleItems = setData
@@ -3965,6 +3994,12 @@ private void UpdateUIEnabledState()
39653994
return;
39663995
// Level Order
39673996
LevelOrder_TextBox_Seed.IsEnabled = !LevelOrder_CheckBox_Random_Seed.IsChecked.Value;
3997+
LevelOrder_ComboBox_MainPath.IsEnabled = (LevelOrderMode)LevelOrder_ComboBox_Mode.SelectedIndex == LevelOrderMode.AllStagesWarps;
3998+
LevelOrder_NumericUpDown_MaxBackwardsJump.IsEnabled = (LevelOrderMode)LevelOrder_ComboBox_Mode.SelectedIndex == LevelOrderMode.AllStagesWarps;
3999+
LevelOrder_NumericUpDown_MaxForwardsJump.IsEnabled = (LevelOrderMode)LevelOrder_ComboBox_Mode.SelectedIndex == LevelOrderMode.AllStagesWarps;
4000+
LevelOrder_NumericUpDown_BackwardsJumpProbability.IsEnabled = (LevelOrderMode)LevelOrder_ComboBox_Mode.SelectedIndex == LevelOrderMode.AllStagesWarps;
4001+
LevelOrder_CheckBox_AllowJumpsToSameLevel.IsEnabled = (LevelOrderMode)LevelOrder_ComboBox_Mode.SelectedIndex == LevelOrderMode.AllStagesWarps;
4002+
LevelOrder_CheckBox_AllowBossToBoss.IsEnabled = !((LevelOrderMode)LevelOrder_ComboBox_Mode.SelectedIndex == LevelOrderMode.BossRush) && !((LevelOrderMode)LevelOrder_ComboBox_Mode.SelectedIndex == LevelOrderMode.Wild);
39684003
// --Layout--
39694004
// Enemy
39704005
Layout_CheckBox_MakeCCSplinesVehicleCompatible.IsEnabled = Layout_CheckBox_RandomizeLayouts.IsChecked.Value;
@@ -3990,6 +4025,8 @@ private void UpdateUIEnabledState()
39904025
Layout_Partner_CheckBox_OnlySelectedPartners.IsEnabled = Layout_CheckBox_RandomizeLayouts.IsChecked.Value && (LayoutPartnerMode)Layout_Partner_ComboBox_Mode.SelectedIndex == LayoutPartnerMode.Wild;
39914026
for (int i = 0; i < PartnerCheckBoxes.Length; i++)
39924027
PartnerCheckBoxes[i].IsEnabled = Layout_Partner_CheckBox_OnlySelectedPartners.IsChecked.Value && Layout_CheckBox_RandomizeLayouts.IsChecked.Value && (LayoutPartnerMode)Layout_Partner_ComboBox_Mode.SelectedIndex == LayoutPartnerMode.Wild;
4028+
// Misc
4029+
Layout_Misc_CheckBox_RandomItemCapsules.IsEnabled = Layout_CheckBox_RandomizeLayouts.IsChecked.Value;
39934030
// --End Layout--
39944031
// Subtitles
39954032
Subtitles_CheckBox_OnlyWithLinkedAudio.IsEnabled = Subtitles_CheckBox_RandomizeSubtitlesVoicelines.IsChecked.Value;

0 commit comments

Comments
 (0)