Skip to content

Commit

Permalink
finalize steam source feature
Browse files Browse the repository at this point in the history
add manual 'set steam source' feature
  • Loading branch information
DoctorVanGogh committed Sep 30, 2017
1 parent f80e573 commit e11c2fc
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 25 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
10 changes: 8 additions & 2 deletions Languages/English/Keyed/Keyed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<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 @@ -77,8 +82,9 @@
<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.
(Last) copied from Steam at an upload date of: {1}
Current upload date on Steam: {2}
{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>
Expand Down
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
10 changes: 9 additions & 1 deletion Source/ModSwitch/LanguageKeys.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public static class @keyed {
/// </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 @@ -233,7 +241,7 @@ public static class @keyed {
/// </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 /> (Last) copied from Steam at an upload date of: {1}<br /> Current upload date 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>'
/// 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>
Expand Down
2 changes: 1 addition & 1 deletion Source/ModSwitch/ModSwitch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<Compile Include="[UI]\Assets.cs" />
<Compile Include="[UI]\Dialog_MissingMods.cs" />
<Compile Include="[UI]\Dialog_SetText.cs" />
<Compile Include="[UI]\ModsConfig.cs" />
<Compile Include="[UI]\ModsConfigUI.cs" />
<Compile Include="[Util]\Position.cs" />
<Compile Include="[Util]\Util.cs" />
<Compile Include="[Patches]\Patches.cs" />
Expand Down
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.2.0.81")]
[assembly: System.Reflection.AssemblyVersion("1.2.0.86")]


2 changes: 1 addition & 1 deletion Source/ModSwitch/Properties/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0.81
1.2.0.86
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,71 @@ public static void DoContextMenu(ModMetaData mod) {
var option = new FloatMenuOption();
if (tsCopy != null && tsCopy == tsSteam) {
option.Label = Helpers.ExplainError(label, LanguageKeys.keyed.ModSwitch_Sync_Identical.Translate());
}
else {
} else {
option.Label = label;
option.action = () => {
Find.WindowStack.Add(
new Dialog_MessageBox(
LanguageKeys.keyed.ModSwitch_Sync_Message.Translate(
mod.Identifier, Helpers.WrapTimestamp(tsCopy), Helpers.WrapTimestamp(tsSteam)
),
LanguageKeys.keyed.ModSwitch_Sync_Choice_KeepSettings.Translate(),
() => { SyncSteam(mod, localAttributes.SteamOrigin, false); },
LanguageKeys.keyed.ModSwitch_Sync_Choice_CopySteam.Translate(),
() => { SyncSteam(mod, localAttributes.SteamOrigin, true); },
LanguageKeys.keyed.ModSwitch_Confirmation_Title.Translate(),
false) {
doCloseX = true,
closeOnEscapeKey = true
});
};
Find.WindowStack.Add(
new Dialog_MessageBox(
LanguageKeys.keyed.ModSwitch_Sync_Message.Translate(
mod.Identifier, Helpers.WrapTimestamp(tsCopy), Helpers.WrapTimestamp(tsSteam)
),
LanguageKeys.keyed.ModSwitch_Sync_Choice_KeepSettings.Translate(),
() => {
SyncSteam(mod, localAttributes.SteamOrigin, false);
},
LanguageKeys.keyed.ModSwitch_Sync_Choice_CopySteam.Translate(),
() => {
SyncSteam(mod, localAttributes.SteamOrigin, true);
},
LanguageKeys.keyed.ModSwitch_Confirmation_Title.Translate(),
false) {
doCloseX = true,
closeOnEscapeKey = true
});
};
}
options.Add(option);
} else {
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) {
if (SteamAPI.IsSteamRunning()) {
var installed = ModLister.AllInstalledMods.ToArray();

if (installed.Length > 0)
options.Add(new FloatMenuOption(
LanguageKeys.keyed.ModSwitch_SetOrigin.Translate(),
() => Find.WindowStack.Add(
new FloatMenu(
installed
.Where(mmd => mmd.OnSteamWorkshop)
.Select(mmd => new FloatMenuOption(
mmd.Name,
() => Find.WindowStack.Add(
Dialog_MessageBox.CreateConfirmation(
LanguageKeys.keyed.ModSwitch_SetOrigin_Confirm.Translate(mod.Name, mmd.Name),
() => {
var attributes = ms[mod.Identifier];
attributes.SteamOrigin = mmd.Identifier;
Helpers.RebuildModsList();
},
true,
LanguageKeys.keyed.ModSwitch_Confirmation_Title.Translate()
)
)))
.ToList()

))
));
}
else {
options.Add(
new FloatMenuOption(
Helpers.ExplainError(
LanguageKeys.keyed.ModSwitch_SetOrigin.Translate(),
LanguageKeys.keyed.ModSwitch_Error_SteamNotRunning.Translate()
),
null));
}
}
}
}

Expand Down Expand Up @@ -264,7 +308,7 @@ private static List<FloatMenuOption> CreateColorizationOptions(ModMetaData mod)

public static class Helpers {
public static string WrapTimestamp(long? timestamp) {
return timestamp != null ? Util.UnixTimeStampToDateTime(timestamp.Value).ToString("g") : $"<em>{LanguageKeys.keyed.ModSwitch_Sync_UnknownTimestamp.Translate()}</em>";
return timestamp != null ? Util.UnixTimeStampToDateTime(timestamp.Value).ToString("g") : $"<i>{LanguageKeys.keyed.ModSwitch_Sync_UnknownTimestamp.Translate()}</i>";
}

public static string ExplainError(string label, string error) {
Expand Down

0 comments on commit e11c2fc

Please sign in to comment.