Skip to content

Commit

Permalink
merge feature/update
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorVanGogh committed Sep 30, 2017
2 parents 19ea192 + e11c2fc commit 2f46a64
Show file tree
Hide file tree
Showing 19 changed files with 790 additions and 251 deletions.
Binary file modified Assemblies/ModSwitch.dll
Binary file not shown.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Version 1.2

- Adds a search bar to the mod list
- Remembers the original steam mod for mods copied locally and supports *manually* upgrading to the latest steam version (if available)
_(To manually set a steam source for an already created local copy hold SHIFT before opening the right click menu on the copy)_
- Can overwrite existing mod sets when creating a new snapshot
31 changes: 31 additions & 0 deletions Languages/English/Keyed/Keyed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
<ModSwitch.Tip.Undo>Undo</ModSwitch.Tip.Undo>
<ModSwitch.Tip.Apply>Apply mod set</ModSwitch.Tip.Apply>

<ModSwitch.CreateNew>Create new</ModSwitch.CreateNew>
<ModSwitch.OverwritExisting>Overwrite existing...</ModSwitch.OverwritExisting>
<ModSwitch.OverwritExisting.Confirm><![CDATA[Really overwrite {0}?
<i>(You can suppress this dialog by holding SHIFT when you choose this option.)</i>]]></ModSwitch.OverwritExisting.Confirm>

<ModSwitch.SetOrigin>Set Steam origin...</ModSwitch.SetOrigin>
<ModSwitch.SetOrigin.Confirm><![CDATA[Manually set the steam original of {0} to {1}?
<b>WARNING:</b> Setting a steam original source to incorrect values will lead to unexpected behavior should you ever sync the local copy to an updated steam version.]]></ModSwitch.SetOrigin.Confirm>

<ModSwitch.Import>Import</ModSwitch.Import>

<ModSwitch.ModSet.Mods>{0} items</ModSwitch.ModSet.Mods>
Expand Down Expand Up @@ -59,10 +70,30 @@
<ModSwitch.CopyLocal.Result.Copy>Copied mod {0} to {1}.</ModSwitch.CopyLocal.Result.Copy>>
<ModSwitch.CopyLocal.Result.Settings>Copied {0} settings file(s).</ModSwitch.CopyLocal.Result.Settings>>
<ModSwitch.CopyLocal.Result.Skipped>Skipped copying settings.</ModSwitch.CopyLocal.Result.Skipped>>
<ModSwitch.CopyLocal.Result.TimestampUnknown><![CDATA[<b>Warning</b>: Last upload time of the Steam original is unknown - sync support will be degraded.]]></ModSwitch.CopyLocal.Result.TimestampUnknown>


<ModSwitch.MoveTo>Move to...</ModSwitch.MoveTo>
<ModSwitch.MoveTo.Top>Top</ModSwitch.MoveTo.Top>
<ModSwitch.MoveTo.Bottom>Bottom</ModSwitch.MoveTo.Bottom>

<ModSwitch.OpenFolder>Open folder</ModSwitch.OpenFolder>

<ModSwitch.Sync>Sync with Steam original</ModSwitch.Sync>
<ModSwitch.Sync.Identical>identical</ModSwitch.Sync.Identical>
<ModSwitch.Sync.Message><![CDATA[The mod {0} will be updated to the current Steam version.
{1} - Steam upload date at (last) local copy
{2} - Steam upload date currently on Steam
Do you want to keep your existing settings from the local copy or replace them with the version of Steam?]]></ModSwitch.Sync.Message>
<ModSwitch.Sync.UnknownTimestamp>Unknown</ModSwitch.Sync.UnknownTimestamp>
<ModSwitch.Sync.Choice.KeepSettings>Keep existing</ModSwitch.Sync.Choice.KeepSettings>
<ModSwitch.Sync.Choice.CopySteam>Replace with Steam</ModSwitch.Sync.Choice.CopySteam>

<ModSwitch.Search.Watermark>Search...</ModSwitch.Search.Watermark>

<ModSwitch.Source.SteamCopy>Local Steam copy</ModSwitch.Source.SteamCopy>


</LanguageData>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _A Rimworld mod manager_

<p align="center"><img alt="Mod Switch" src="https://raw.githubusercontent.com/DoctorVanGogh/ModSwitch/master/About/preview.png" /></p>

Allows you to save and switch between sets of active mods with one click.
Allows you to save and switch between sets of active mods with one click.

Supports importing your sets from ModListBackup.

Expand Down
1 change: 1 addition & 0 deletions Source/ModSwitch.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/UserRules/=UNION_005FMEMBER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BG/@EntryIndexedValue">BG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MLB/@EntryIndexedValue">MLB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="aaBb_aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="aaBb_AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FCONSTANT/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
Expand Down
64 changes: 62 additions & 2 deletions Source/ModSwitch/LanguageKeys.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using System.Diagnostics.CodeAnalysis;

namespace DoctorVanGogh.ModSwitch {
[GeneratedCode("DefGenerator.tt","0.1")]
[GeneratedCode("DefGenerator.tt","0.2")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public static partial class LanguageKeys {
Expand Down Expand Up @@ -45,6 +45,26 @@ public static class @keyed {
/// </summary>
public const string @ModSwitch_Tip_Apply = "ModSwitch.Tip.Apply";
/// <summary>
/// Get's the translation key for '<em>Create new</em>'
/// </summary>
public const string @ModSwitch_CreateNew = "ModSwitch.CreateNew";
/// <summary>
/// Get's the translation key for '<em>Overwrite existing...</em>'
/// </summary>
public const string @ModSwitch_OverwritExisting = "ModSwitch.OverwritExisting";
/// <summary>
/// Get's the translation key for '<em>Really overwrite {0}?<br /><br />&lt;i&gt;(You can suppress this dialog by holding SHIFT when you choose this option.)&lt;/i&gt;</em>'
/// </summary>
public const string @ModSwitch_OverwritExisting_Confirm = "ModSwitch.OverwritExisting.Confirm";
/// <summary>
/// Get's the translation key for '<em>Set Steam origin...</em>'
/// </summary>
public const string @ModSwitch_SetOrigin = "ModSwitch.SetOrigin";
/// <summary>
/// Get's the translation key for '<em>Manually set the steam original of {0} to {1}?<br /> <br />&lt;b&gt;WARNING:&lt;/b&gt; Setting a steam original source to incorrect values will lead to unexpected behavior should you ever sync the local copy to an updated steam version.</em>'
/// </summary>
public const string @ModSwitch_SetOrigin_Confirm = "ModSwitch.SetOrigin.Confirm";
/// <summary>
/// Get's the translation key for '<em>Import</em>'
/// </summary>
public const string @ModSwitch_Import = "ModSwitch.Import";
Expand Down Expand Up @@ -77,7 +97,7 @@ public static class @keyed {
/// </summary>
public const string @ModSwitch_MissingMods_Choice_Ignore_Tip = "ModSwitch.MissingMods.Choice.Ignore.Tip";
/// <summary>
/// Get's the translation key for '<em>Cancel & Open workshop</em>'
/// Get's the translation key for '<em>Cancel &amp; Open workshop</em>'
/// </summary>
public const string @ModSwitch_MissingMods_Choice_Workshop = "ModSwitch.MissingMods.Choice.Workshop";
/// <summary>
Expand Down Expand Up @@ -193,6 +213,10 @@ public static class @keyed {
/// </summary>
public const string @ModSwitch_CopyLocal_Result_Skipped = "ModSwitch.CopyLocal.Result.Skipped";
/// <summary>
/// Get's the translation key for '<em>&lt;b&gt;Warning&lt;/b&gt;: Last upload time of the Steam original is unknown - sync support will be degraded.</em>'
/// </summary>
public const string @ModSwitch_CopyLocal_Result_TimestampUnknown = "ModSwitch.CopyLocal.Result.TimestampUnknown";
/// <summary>
/// Get's the translation key for '<em>Move to...</em>'
/// </summary>
public const string @ModSwitch_MoveTo = "ModSwitch.MoveTo";
Expand All @@ -204,6 +228,42 @@ public static class @keyed {
/// Get's the translation key for '<em>Bottom</em>'
/// </summary>
public const string @ModSwitch_MoveTo_Bottom = "ModSwitch.MoveTo.Bottom";
/// <summary>
/// Get's the translation key for '<em>Open folder</em>'
/// </summary>
public const string @ModSwitch_OpenFolder = "ModSwitch.OpenFolder";
/// <summary>
/// Get's the translation key for '<em>Sync with Steam original</em>'
/// </summary>
public const string @ModSwitch_Sync = "ModSwitch.Sync";
/// <summary>
/// Get's the translation key for '<em>identical</em>'
/// </summary>
public const string @ModSwitch_Sync_Identical = "ModSwitch.Sync.Identical";
/// <summary>
/// Get's the translation key for '<em>The mod {0} will be updated to the current Steam version.<br /> Steam upload date at (last) local copy: {1}<br /> Steam upload date currently on Steam: {2}<br /><br />Do you want to keep your existing settings from the local copy or replace them with the version of Steam?</em>'
/// </summary>
public const string @ModSwitch_Sync_Message = "ModSwitch.Sync.Message";
/// <summary>
/// Get's the translation key for '<em>Unknown</em>'
/// </summary>
public const string @ModSwitch_Sync_UnknownTimestamp = "ModSwitch.Sync.UnknownTimestamp";
/// <summary>
/// Get's the translation key for '<em>Keep existing</em>'
/// </summary>
public const string @ModSwitch_Sync_Choice_KeepSettings = "ModSwitch.Sync.Choice.KeepSettings";
/// <summary>
/// Get's the translation key for '<em>Replace with Steam</em>'
/// </summary>
public const string @ModSwitch_Sync_Choice_CopySteam = "ModSwitch.Sync.Choice.CopySteam";
/// <summary>
/// Get's the translation key for '<em>Search...</em>'
/// </summary>
public const string @ModSwitch_Search_Watermark = "ModSwitch.Search.Watermark";
/// <summary>
/// Get's the translation key for '<em>Local Steam copy</em>'
/// </summary>
public const string @ModSwitch_Source_SteamCopy = "ModSwitch.Source.SteamCopy";
}
}
}
4 changes: 2 additions & 2 deletions Source/ModSwitch/LanguageKeys.Generated.tt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using System.Diagnostics.CodeAnalysis;
namespace <#= _namespace #> {
<# }
#>
[GeneratedCode("DefGenerator.tt","0.1")]
[GeneratedCode("DefGenerator.tt","0.2")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public static partial class LanguageKeys {
Expand All @@ -52,7 +52,7 @@ namespace <#= _namespace #> {
foreach (XmlNode element in doc.SelectNodes(@"/*/*")) {
#>
/// <summary>
/// Get's the translation key for '<em><#= element.InnerText ?? String.Empty#></em>'
/// Get's the translation key for '<em><#= System.Security.SecurityElement.Escape(element.InnerText ?? String.Empty).Replace("\r\n", "<br />") #></em>'
/// </summary>
public const string <#= SanitizeIdentifier(element.Name) #> = "<#= element.Name #>";
<#
Expand Down
13 changes: 6 additions & 7 deletions Source/ModSwitch/ModSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Harmony;
using UnityEngine;
using Verse;
using Verse.Steam;

namespace DoctorVanGogh.ModSwitch {

Expand All @@ -24,7 +25,7 @@ public ModSwitch(ModContentPack content) : base(content) {

Log.Message("Initialized ModSwitch patches...");

_settings = GetSettings<Settings>();
_settings = GetSettings<Settings>();
}

public override string SettingsCategory() {
Expand All @@ -39,13 +40,10 @@ public void DoModsConfigWindowContents(Rect bottom) {
_settings.DoModsConfigWindowContents(bottom);
}

public Color GetModColor(ModMetaData mod) {
return _settings.GetOrInsertAttributes(mod.Identifier)?.Color ?? Color.white;
}

public void SetModColor(ModMetaData mod, Color value) {
_settings.GetOrInsertAttributes(mod.Identifier).Color = value;
}
public ModAttributes this[string mod] => _settings.GetOrInsertAttributes(mod);
public ModAttributes this[ModMetaData mod] => this[mod.Identifier];


public void MovePosition(ModMetaData mod, Position position) {
List<ModMetaData> mods = (List<ModMetaData>) fiModLister_mods.GetValue(null);
Expand All @@ -61,5 +59,6 @@ public void MovePosition(ModMetaData mod, Position position) {
}
}
}

}
}
1 change: 1 addition & 0 deletions Source/ModSwitch/ModSwitch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="[UI]\Assets.cs" />
<Compile Include="[UI]\Dialog_MissingMods.cs" />
<Compile Include="[UI]\Dialog_SetText.cs" />
<Compile Include="[UI]\ModsConfigUI.cs" />
<Compile Include="[Util]\Position.cs" />
<Compile Include="[Util]\Util.cs" />
<Compile Include="[Patches]\Patches.cs" />
Expand Down
19 changes: 19 additions & 0 deletions Source/ModSwitch/Model/ModAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,29 @@ class ModAttributes : IExposable {

public Color? Color;

/// <summary>
/// For mods copied from steam: original identifier
/// </summary>
public string SteamOrigin;
/// <summary>
/// For mods copied from a steam source: last uploaded TS at time of copy
/// </summary>
// HACK: shoulds be <c>uint</c>, but RW can't deserialize uints....
public long? SteamOriginTS;

/// <summary>
/// For steam mods: last uploaded TS
/// </summary>
/// <remarks>NOT SERIALIZED</remarks>
// HACK: shoulds be <c>uint</c>, but RW can't deserialize uints....
public long? LastUpdateTS;

public void ExposeData() {
Scribe_Values.Look(ref Key, @"key");
Scribe_Collections.Look(ref attributes, false, @"attributes");
Scribe_Values.Look(ref Color, "color", null);
Scribe_Values.Look(ref SteamOrigin, "origin", null);
Scribe_Values.Look(ref SteamOriginTS, "originTS", null);

if (Scribe.mode == LoadSaveMode.LoadingVars) {
if (Color == null)
Expand Down
14 changes: 8 additions & 6 deletions Source/ModSwitch/Model/ModSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ class ModSet : IExposable {
public string Name = String.Empty;

static ModSet() {
var tModsConfig = typeof(ModsConfig);
var tModsConfig = typeof(Verse.ModsConfig);
var tModsConfigData = AccessTools.Inner(tModsConfig, @"ModsConfigData");
fiModsConfigData_activeMods = AccessTools.Field(tModsConfigData, @"activeMods");
fiModsConfigData_buildNumber = AccessTools.Field(tModsConfigData, @"buildNumber");
fiModsConfig_data = AccessTools.Field(tModsConfig, @"data");

rgxSteamModId = new Regex(@"^\d+$", RegexOptions.Singleline | RegexOptions.Compiled);

Util.Log($"ModSet cctor: {tModsConfig != null}, {tModsConfigData != null}, {fiModsConfigData_activeMods != null}, {fiModsConfigData_buildNumber != null}, {fiModsConfig_data != null}");
}

public ModSet(Settings owner) {
Expand Down Expand Up @@ -179,14 +181,14 @@ public void Delete() {
}


public static ModSet FromCurrent(string name, Settings owner) {
public static ModSet FromCurrent(string name, Settings owner) {
object modsConfigData = fiModsConfig_data.GetValue(null);

return new ModSet(owner) {
Name = name,
BuildNumber = (int) fiModsConfigData_buildNumber.GetValue(modsConfigData),
Mods = new List<string>((IEnumerable<string>) fiModsConfigData_activeMods.GetValue(modsConfigData))
};
Name = name,
BuildNumber = (int)fiModsConfigData_buildNumber.GetValue(modsConfigData),
Mods = new List<string>((IEnumerable<string>)fiModsConfigData_activeMods.GetValue(modsConfigData))
};
}
}
}
2 changes: 1 addition & 1 deletion Source/ModSwitch/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
[assembly: System.Reflection.AssemblyCopyright("Copyright © DoctorVanGogh 2017")]
[assembly: System.Runtime.InteropServices.ComVisible(false)]
[assembly: System.Runtime.InteropServices.Guid("ab2e8e89-3d1d-4e36-a0ae-489b6ebc84a6")]
[assembly: System.Reflection.AssemblyVersion("1.1.1.30")]
[assembly: System.Reflection.AssemblyVersion("1.2.0.87")]


2 changes: 1 addition & 1 deletion Source/ModSwitch/Properties/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.1.30
1.2.0.87
Loading

0 comments on commit 2f46a64

Please sign in to comment.