Skip to content

Commit

Permalink
Merge pull request #415 from Aragas/dev
Browse files Browse the repository at this point in the history
v5.8.1
  • Loading branch information
Aragas authored Jul 11, 2023
2 parents c5b05cb + 8452d4e commit 4d1d0d4
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<GameVersion>1.0.0</GameVersion>
<Version>5.8.0</Version>
<Version>5.8.1</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<ButterLibVersion>2.8.8</ButterLibVersion>
<UIExtenderExVersion>2.8.0</UIExtenderExVersion>
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 5.8.1
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.2.0,v1.2.1
* Fixed missing Preset saving
* Fixed unintentional crashes
---------------------------------------------------------------------------------------------------
Version: 5.8.0
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.2.0
* Added the ability to save custom Presets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,25 @@ IEnumerable<GlobalSettings> GetGlobalSettings()
.Where(t => typeof(GlobalSettings).IsAssignableFrom(t))
.Where(t => !typeof(EmptyGlobalSettings).IsAssignableFrom(t))
.Where(t => !typeof(IWrapper).IsAssignableFrom(t))
.Select(t => Activator.CreateInstance(t) as GlobalSettings)
.Select(t =>
{
try
{
return Activator.CreateInstance(t) as GlobalSettings;
}
catch (Exception e)
{
try
{
logger.LogError(e, $"Failed to initialize type {t}");
}
catch (Exception)
{
logger.LogError(e, "Failed to initialize and log type!");
}
return null;
}
})
.OfType<GlobalSettings>()
.ToList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,25 @@ IEnumerable<PerCampaignSettings> GetPerCampaignSettings()
.Where(t => typeof(PerCampaignSettings).IsAssignableFrom(t))
.Where(t => !typeof(EmptyPerCampaignSettings).IsAssignableFrom(t))
.Where(t => !typeof(IWrapper).IsAssignableFrom(t))
.Select(t => Activator.CreateInstance(t) as PerCampaignSettings)
.Select(t =>
{
try
{
return Activator.CreateInstance(t) as PerCampaignSettings;
}
catch (Exception e)
{
try
{
_logger.LogError(e, $"Failed to initialize type {t}");
}
catch (Exception)
{
_logger.LogError(e, "Failed to initialize and log type!");
}
return null;
}
})
.OfType<PerCampaignSettings>()
.ToList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,25 @@ IEnumerable<PerSaveSettings> GetPerSaveSettings()
.Where(t => typeof(PerSaveSettings).IsAssignableFrom(t))
.Where(t => !typeof(EmptyPerSaveSettings).IsAssignableFrom(t))
.Where(t => !typeof(IWrapper).IsAssignableFrom(t))
.Select(t => Activator.CreateInstance(t) as PerSaveSettings)
.Select(t =>
{
try
{
return Activator.CreateInstance(t) as PerSaveSettings;
}
catch (Exception e)
{
try
{
_logger.LogError(e, $"Failed to initialize type {t}");
}
catch (Exception)
{
_logger.LogError(e, "Failed to initialize and log type!");
}
return null;
}
})
.OfType<PerSaveSettings>()
.ToList();
}
Expand Down
21 changes: 20 additions & 1 deletion src/MCM.UI/GUI/Prefabs/ModOptionsPageView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<Children>
<!-- Dropdown Presets -->
<Widget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="300" SuggestedHeight="42" HorizontalAlignment="Left"
VerticalAlignment="Center" MarginLeft="20" MarginRight="40" IsVisible="@IsPresetsSelectorVisible">
VerticalAlignment="Center" MarginLeft="20" IsVisible="@IsPresetsSelectorVisible">
<Children>
<Standard.DropdownWithHorizontalControl HorizontalAlignment="Center" Parameter.SelectorDataSource="{PresetsSelectorCopy}"
Parameter.ShowNextAndPrevious="false" />
Expand All @@ -97,6 +97,25 @@

</Children>
</ListPanel>

<!-- Preset Section -->
<ListPanel WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="80" LayoutImp.LayoutMethod="HorizontalLeftToRight"
HorizontalAlignment="Center" VerticalAlignment="Top" MarginBottom="-20" MarginTop="-30" >
<Children>

<!-- Save As Preset -->
<ButtonWidget SuggestedWidth="200" SuggestedHeight="64" HorizontalAlignment="Left" VerticalAlignment="Center"
MarginLeft="10" DoNotPassEventsToChildren="true" Brush="MCM.Cancel.Button" Command.Click="ExecuteSaveAsPreset"
IsVisible="@CanSaveAsPreset" >
<Children>
<TextWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" VerticalAlignment="Center" HorizontalAlignment="Center"
Text="@SaveAsPreset" Brush="MCM.Button.Text" />
</Children>
</ButtonWidget>

</Children>
</ListPanel>

<!-- Separator -->
<BrushWidget WidthSizePolicy="StretchToParent" HeightSizePolicy="Fixed" SuggestedHeight="2" VerticalAlignment="Top" Brush="MCM.Divider.Yellow" MarginLeft="15" MarginRight="15"/>

Expand Down
2 changes: 1 addition & 1 deletion src/MCM.UI/GUI/Prefabs/ModOptionsView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<Children>
<!-- Dropdown Presets -->
<Widget WidthSizePolicy="Fixed" HeightSizePolicy="Fixed" SuggestedWidth="300" SuggestedHeight="42" HorizontalAlignment="Left"
VerticalAlignment="Center" MarginLeft="20" MarginRight="40" IsVisible="@IsPresetsSelectorVisible">
VerticalAlignment="Center" MarginLeft="20" IsVisible="@IsPresetsSelectorVisible">
<Children>
<Standard.DropdownWithHorizontalControl HorizontalAlignment="Center" Parameter.SelectorDataSource="{PresetsSelectorCopy}"
Parameter.ShowNextAndPrevious="false" />
Expand Down
19 changes: 16 additions & 3 deletions src/MCM.UI/GUI/ViewModels/SettingsPropertyVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,24 @@ public bool IsSettingVisible

public SettingsPropertyVM(ISettingsPropertyDefinition definition, SettingsVM settingsVM)
{
static IFormatProvider? TryCreateCustomFormatter(Type? customFormatter)
{
if (customFormatter is null) return null;

try
{
return Activator.CreateInstance(customFormatter) as IFormatProvider;
}
catch (Exception)
{
return null;
}
}


SettingsVM = settingsVM;
SettingPropertyDefinition = definition;
ValueFormatProvider = SettingPropertyDefinition.CustomFormatter is not null
? Activator.CreateInstance(SettingPropertyDefinition.CustomFormatter) as IFormatProvider
: null;
ValueFormatProvider = TryCreateCustomFormatter(SettingPropertyDefinition.CustomFormatter);

NumericValueToggle = IsInt || IsFloat;

Expand Down

0 comments on commit 4d1d0d4

Please sign in to comment.