diff --git a/SMShared/Json/ThemeConfigJson.cs b/SMShared/Json/ThemeConfigJson.cs
index 269aacb..1ab647d 100644
--- a/SMShared/Json/ThemeConfigJson.cs
+++ b/SMShared/Json/ThemeConfigJson.cs
@@ -21,6 +21,7 @@ public class ThemeConfigItem
public string Name;
public bool HideFromStores;
public bool PreventRandomSpawning;
+ public float? CanPrice;
public string LabelTextureFile;
public string LabelBaseColor;
diff --git a/SkinConfigurator/ThemeConfigEditor.xaml b/SkinConfigurator/ThemeConfigEditor.xaml
index 80a9d5b..c18f98d 100644
--- a/SkinConfigurator/ThemeConfigEditor.xaml
+++ b/SkinConfigurator/ThemeConfigEditor.xaml
@@ -32,6 +32,7 @@
+
@@ -44,7 +45,31 @@
ItemsSource="{Binding AvailableSkinNames}"
SelectionChanged="ComboBox_SelectionChanged"/>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/SkinConfigurator/ThemeConfigEditor.xaml.cs b/SkinConfigurator/ThemeConfigEditor.xaml.cs
index 5e9b96b..1db0fe4 100644
--- a/SkinConfigurator/ThemeConfigEditor.xaml.cs
+++ b/SkinConfigurator/ThemeConfigEditor.xaml.cs
@@ -3,9 +3,11 @@
using SMShared;
using System;
using System.Diagnostics;
+using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
@@ -103,5 +105,56 @@ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs
{
Model.ThemeName = (string?)ThemeNameCombo.SelectedItem;
}
+
+ private void PriceInput_LostFocus(object sender, RoutedEventArgs e)
+ {
+ if (float.TryParse(PriceInput.Text, out float value))
+ {
+
+ }
+ }
+ }
+
+ public class FloatStringRule : ValidationRule
+ {
+ public override ValidationResult Validate(object value, CultureInfo cultureInfo)
+ {
+ string strVal = (string)value;
+
+ if (string.IsNullOrWhiteSpace(strVal)) return ValidationResult.ValidResult;
+
+ if (float.TryParse(strVal, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out _))
+ {
+ return ValidationResult.ValidResult;
+ }
+ return new ValidationResult(false, "Not a valid decimal number");
+ }
+ }
+
+ public class FloatStringConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is float f)
+ {
+ return f.ToString("F0", CultureInfo.CurrentCulture);
+ }
+ return string.Empty;
+ }
+
+ public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ string strVal = (string)value;
+ if (string.IsNullOrWhiteSpace(strVal))
+ {
+ return null;
+ }
+
+ if (float.TryParse(strVal, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out float result))
+ {
+ return (float)Math.Round(Math.Abs(result));
+ }
+ return null;
+ }
}
}
diff --git a/SkinConfigurator/ViewModels/ThemeConfigModel.cs b/SkinConfigurator/ViewModels/ThemeConfigModel.cs
index 36169b5..d621102 100644
--- a/SkinConfigurator/ViewModels/ThemeConfigModel.cs
+++ b/SkinConfigurator/ViewModels/ThemeConfigModel.cs
@@ -96,6 +96,16 @@ public bool PreventRandomSpawning
DependencyProperty.Register("PreventRandomSpawning", typeof(bool), typeof(ThemeConfigModel), new PropertyMetadata(false));
+ public float? CanPrice
+ {
+ get { return (float?)GetValue(CanPriceProperty); }
+ set { SetValue(CanPriceProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for CanPrice. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty CanPriceProperty =
+ DependencyProperty.Register("CanPrice", typeof(float?), typeof(ThemeConfigModel), new PropertyMetadata(defaultValue: null));
+
public event PropertyChangedEventHandler? PropertyChanged;
@@ -192,6 +202,7 @@ public ThemeConfigItem JsonModel()
Name = ThemeName,
HideFromStores = HideFromStores,
PreventRandomSpawning = PreventRandomSpawning,
+ CanPrice = CanPrice,
};
if (HasValidImage)
diff --git a/SkinManagerMod/Items/PaintFactory.cs b/SkinManagerMod/Items/PaintFactory.cs
index 2b73d71..96e3c40 100644
--- a/SkinManagerMod/Items/PaintFactory.cs
+++ b/SkinManagerMod/Items/PaintFactory.cs
@@ -470,13 +470,18 @@ public static void InjectShopData()
// global shop data
Main.LogVerbose($"Injecting shop data for theme {theme.name}");
+ if (!SkinProvider.TryGetThemeSettings(theme.name, out var settings))
+ {
+ settings = null;
+ }
+
var newShopData = new ShopItemData()
{
item = newItemSpec,
shelfItem = DefaultCanShopData.shelfItem,
- amount = 20,
- basePrice = DefaultCanShopData.basePrice,
+ amount = 50,
+ basePrice = settings?.CanPrice ?? DefaultCanShopData.basePrice,
isGlobal = true,
careerOnly = false,
diff --git a/SkinManagerMod/ThemeSettings.cs b/SkinManagerMod/ThemeSettings.cs
index 94402bf..9857885 100644
--- a/SkinManagerMod/ThemeSettings.cs
+++ b/SkinManagerMod/ThemeSettings.cs
@@ -11,6 +11,7 @@ public class ThemeSettings
public Version HighestVersion;
public bool HideFromStores;
public bool PreventRandomSpawning;
+ public float? CanPrice;
public SkinTexture CanLabel;
public Color? LabelBaseColor;
@@ -28,6 +29,8 @@ public void Merge(ThemeSettings other)
bool otherIsNewer = other.HighestVersion > HighestVersion;
ReplaceIfNewer(ref HideFromStores, other.HideFromStores, otherIsNewer);
+ ReplaceIfNewer(ref PreventRandomSpawning, other.PreventRandomSpawning, otherIsNewer);
+ ReplaceIfNewer(ref CanPrice, other.CanPrice, otherIsNewer);
ReplaceIfNewer(ref CanLabel, other.CanLabel, otherIsNewer);
ReplaceIfNewer(ref LabelBaseColor, other.LabelBaseColor, otherIsNewer);
@@ -51,6 +54,7 @@ public static ThemeSettings Create(string basePath, ThemeConfigItem data, Versio
{
HideFromStores = data.HideFromStores,
PreventRandomSpawning = data.PreventRandomSpawning,
+ CanPrice = data.CanPrice,
};
TryParseColor(data.LabelBaseColor, basePath, ref result.LabelBaseColor);