Skip to content

Commit

Permalink
Merge pull request #38 from derail-valley-modding/paint_everything
Browse files Browse the repository at this point in the history
Paint Everything
  • Loading branch information
katycat5e authored Feb 3, 2025
2 parents 98e05d4 + d772cb3 commit 25a4a84
Show file tree
Hide file tree
Showing 48 changed files with 1,965 additions and 1,207 deletions.
407 changes: 407 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions SMShared/Json/ModInfoJson.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
using System;

#if PACKAGER
#nullable disable
#endif

namespace SMShared.Json
{
[Serializable]
public class ModInfoJson
{
public string Id;
public string DisplayName;
public string? Id;
public string? DisplayName;
public string Version = "1.0.0";
public string Author;
public string? Author;
public readonly string ManagerVersion = "0.27.3";
public readonly string[] Requirements = { "SkinManagerMod" };
}
Expand Down
2 changes: 0 additions & 2 deletions SMShared/Json/ResourceConfigJson.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;

#if PACKAGER
#nullable disable
#endif

namespace SMShared.Json
{
Expand Down
6 changes: 1 addition & 5 deletions SMShared/Json/SkinConfigJson.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;

#if PACKAGER
#nullable disable
#endif

namespace SMShared.Json
{
[Serializable]
public class SkinConfigJson : ResourceConfigJson
{
public string[] ResourceNames;
public string[]? ResourceNames;
public BaseTheme BaseTheme = BaseTheme.DVRT;
}

Expand Down
18 changes: 7 additions & 11 deletions SMShared/Json/ThemeConfigJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,26 @@
using System.Collections.Generic;
using System.Text;

#if PACKAGER
#nullable disable
#endif

namespace SMShared.Json
{
[Serializable]
public class ThemeConfigJson
{
public string Version = "1.0.0";
public ThemeConfigItem[] Themes;
public string? Version = "1.0.0";
public ThemeConfigItem[]? Themes;
}

[Serializable]
public class ThemeConfigItem
{
public string Name;
public string? Name;
public bool HideFromStores;
public bool PreventRandomSpawning;
public float? CanPrice;

public string LabelTextureFile;
public string LabelBaseColor;
public string LabelAccentColorA;
public string LabelAccentColorB;
public string? LabelTextureFile;
public string? LabelBaseColor;
public string? LabelAccentColorA;
public string? LabelAccentColorB;
}
}
24 changes: 7 additions & 17 deletions SMShared/Remaps.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#if PACKAGER
#nullable disable
#else
using DV.ThingTypes;
#endif

using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -15,7 +9,7 @@ public static class Remaps
{
private static readonly Dictionary<string, string> _newToOldCarIdMap;

public static bool TryGetOldTrainCarId(string newId, out string oldId)
public static bool TryGetOldTrainCarId(string newId, out string? oldId)
{
return _newToOldCarIdMap.TryGetValue(newId, out oldId);
}
Expand Down Expand Up @@ -67,7 +61,7 @@ public static bool TryGetOldTrainCarId(string newId, out string oldId)
{ "CarNuclearFlask", "NuclearFlask" },
};

public static bool TryGetUpdatedCarId(string oldId, out string newId)
public static bool TryGetUpdatedCarId(string oldId, out string? newId)
{
return _oldToNewCarIdMap.TryGetValue(oldId, out newId);
}
Expand Down Expand Up @@ -100,7 +94,7 @@ public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
return ((IEnumerable<KeyValuePair<string, string>>)_map).GetEnumerator();
}

public bool TryGetUpdatedName(string oldName, out string newName)
public bool TryGetUpdatedName(string oldName, out string? newName)
{
return _map.TryGetValue(oldName, out newName);
}
Expand Down Expand Up @@ -255,9 +249,9 @@ static Remaps()
});
}

public static bool TryGetUpdatedTextureName(string liveryId, string oldName, out string newName)
public static bool TryGetUpdatedTextureName(string liveryId, string oldName, out string? newName)
{
if (_legacyTextureNameMap.TryGetValue(liveryId, out TextureMapping textureMapping))
if (_legacyTextureNameMap.TryGetValue(liveryId, out TextureMapping? textureMapping))
{
return textureMapping.TryGetUpdatedName(oldName, out newName);
}
Expand All @@ -266,8 +260,4 @@ public static bool TryGetUpdatedTextureName(string liveryId, string oldName, out
return false;
}
}
}

#if PACKAGER
#nullable restore
#endif
}
7 changes: 1 addition & 6 deletions SkinConfigurator/FolderPackager.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using SkinConfigurator.ViewModels;
using SMShared;
using SMShared.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace SkinConfigurator
{
Expand Down Expand Up @@ -75,7 +70,7 @@ protected override void WriteThemeConfig()
for (int i = 0; i < _model.ThemeConfigs.Count; i++)
{
var config = _model.ThemeConfigs[i];
if (config.HideFromStores)
if (config.HasValidImage)
{
string destPath = config.PackagedLabelTexturePath;
File.Copy(config.TempPath, destPath, true);
Expand Down
2 changes: 1 addition & 1 deletion SkinConfigurator/ResourceSelector.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void RefreshAvailableItems()
if ((SkinPack is not null) && (Skin is not null))
{
available = SkinPack.PackComponents
.Where(c => (c.Type == PackComponentType.Resource) && !string.IsNullOrWhiteSpace(c.Name) && (c.CarId == Skin.CarId))
.Where(c => (c.Type == PackComponentType.Resource) && !string.IsNullOrWhiteSpace(c.Name))
.OrderBy(c => c.Name)
.ToList();

Expand Down
2 changes: 1 addition & 1 deletion SkinConfigurator/ViewModels/PackComponentModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ResourceConfigJson JsonModel()
{
Name = Name,
CarId = CarId,
ResourceNames = Resources?.Select(r => r.Name).ToArray(),
ResourceNames = Resources?.Select(r => r.Name!).ToArray(),
BaseTheme = BaseTheme,
};
}
Expand Down
4 changes: 2 additions & 2 deletions SkinConfigurator/ViewModels/SkinFileModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public string FileName
set
{
SetValue(FileNameProperty, value);
CanUpgradeFileName = Remaps.TryGetUpdatedTextureName(Parent.CarId, Path.GetFileNameWithoutExtension(value), out _);
CanUpgradeFileName = Remaps.TryGetUpdatedTextureName(Parent.CarId!, Path.GetFileNameWithoutExtension(value), out _);
FileNameChanged?.Invoke();
}
}
Expand Down Expand Up @@ -61,7 +61,7 @@ public void UpgradeFileName()
{
string name = Path.GetFileNameWithoutExtension(FileName);

if (Remaps.TryGetUpdatedTextureName(Parent.CarId, name, out string newName))
if (Remaps.TryGetUpdatedTextureName(Parent.CarId!, name, out string? newName))
{
FileName = $"{newName}{Extension}";
}
Expand Down
2 changes: 1 addition & 1 deletion SkinConfigurator/ViewModels/SkinModInfoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ModInfoJson JsonModel()
{
Id = Id,
DisplayName = DisplayName,
Version = Version,
Version = Version!,
Author = string.IsNullOrWhiteSpace(Author) ? null : Author,
};
}
Expand Down
6 changes: 5 additions & 1 deletion SkinConfigurator/ViewModels/ThemeConfigModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public ThemeConfigModel(SkinPackModel parent, ThemeConfigItem json, string dirPa
{
ParentPack = parent;
ThemeName = json.Name;
HideFromStores = json.HideFromStores;
PreventRandomSpawning = json.PreventRandomSpawning;
CanPrice = json.CanPrice;

if (!string.IsNullOrEmpty(json.LabelTextureFile))
{
string texturePath = Path.Combine(dirPath, json.LabelTextureFile);
Expand All @@ -169,7 +173,7 @@ public ThemeConfigModel(SkinPackModel parent, ThemeConfigItem json, string dirPa
LabelAccentColorB = TryParseColor(json.LabelAccentColorB);
}

private static Color TryParseColor(string value)
private static Color TryParseColor(string? value)
{
if (!string.IsNullOrEmpty(value))
{
Expand Down
2 changes: 1 addition & 1 deletion SkinManagerMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Global
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
SMShared\SMShared.projitems*{3c5dfee2-5da9-4674-96d8-c1503efca3c0}*SharedItemsImports = 5
SMShared\SMShared.projitems*{bbdceb20-83d5-4fc8-88f9-0e08df1b1dde}*SharedItemsImports = 4
SMShared\SMShared.projitems*{bbdceb20-83d5-4fc8-88f9-0e08df1b1dde}*SharedItemsImports = 5
SMShared\SMShared.projitems*{f951746d-cb16-45ee-80a7-01e07ac461be}*SharedItemsImports = 13
EndGlobalSection
EndGlobal
2 changes: 0 additions & 2 deletions SkinManagerMod/.gitignore

This file was deleted.

Loading

0 comments on commit 25a4a84

Please sign in to comment.