Skip to content

Commit

Permalink
add 'copy local' option to steam mods
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorVanGogh committed Sep 20, 2017
1 parent fb5217d commit 11148d2
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 35 deletions.
Binary file modified Assemblies/ModSwitch.dll
Binary file not shown.
20 changes: 19 additions & 1 deletion Languages/English/Keyed/Keyed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<ModSwitch.Import.Choice.Replace>Replace</ModSwitch.Import.Choice.Replace>
<ModSwitch.Import.Choice.Append>Append</ModSwitch.Import.Choice.Append>

<ModSwitch.Color>Color</ModSwitch.Color>
<ModSwitch.Color>Color...</ModSwitch.Color>

<ModSwitch.Color.white>white</ModSwitch.Color.white>
<ModSwitch.Color.black>black</ModSwitch.Color.black>
Expand All @@ -44,6 +44,24 @@
<ModSwitch.Color.cyan>cyan</ModSwitch.Color.cyan>
<ModSwitch.Color.yellow>yellow</ModSwitch.Color.yellow>

<ModSwitch.CopyLocal>Create a local copy</ModSwitch.CopyLocal>

<ModSwitch.Error.SteamNotRunning>Steam currently not running/available</ModSwitch.Error.SteamNotRunning>

<ModSwitch.ExistingSettings>There are already stored settings for the mod under the new name {0}. You can confirm overwriting the existing settings or skip copying settings.</ModSwitch.ExistingSettings>
<ModSwitch.ExistingSettings.Choice.Overwrite>Overwrite.</ModSwitch.ExistingSettings.Choice.Overwrite>
<ModSwitch.ExistingSettings.Choice.Skip>Skip.</ModSwitch.ExistingSettings.Choice.Skip>

<ModSwitch.Error.InvalidChars>Contains invalid characters</ModSwitch.Error.InvalidChars>
<ModSwitch.Error.TargetExists>Target already exists</ModSwitch.Error.TargetExists>

<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.MoveTo>Move to...</ModSwitch.MoveTo>
<ModSwitch.MoveTo.Top>Top</ModSwitch.MoveTo.Top>
<ModSwitch.MoveTo.Bottom>Bottom</ModSwitch.MoveTo.Bottom>


</LanguageData>
58 changes: 55 additions & 3 deletions Source/ModSwitch/LanguageKeys.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ 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>Open workshop</em>'
/// Get's the translation key for '<em>Cancel & Open workshop</em>'
/// </summary>
public const string @ModSwitch_MissingMods_Choice_Workshop = "ModSwitch.MissingMods.Choice.Workshop";
/// <summary>
/// Get's the translation key for '<em>Try retrieving applicable mods from the Steam Workshop. Keep in mind those mods might no longer be available.</em>'
/// Get's the translation key for '<em>Dont apply the Mod Set. Instead try retrieving applicable mods from the Steam Workshop. Keep in mind those mods might no longer be available.</em>'
/// </summary>
public const string @ModSwitch_MissingMods_Choice_Workshop_Tip = "ModSwitch.MissingMods.Choice.Workshop.Tip";
/// <summary>
Expand Down Expand Up @@ -109,7 +109,7 @@ public static class @keyed {
/// </summary>
public const string @ModSwitch_Import_Choice_Append = "ModSwitch.Import.Choice.Append";
/// <summary>
/// Get's the translation key for '<em>Color</em>'
/// Get's the translation key for '<em>Color...</em>'
/// </summary>
public const string @ModSwitch_Color = "ModSwitch.Color";
/// <summary>
Expand Down Expand Up @@ -148,6 +148,58 @@ public static class @keyed {
/// Get's the translation key for '<em>yellow</em>'
/// </summary>
public const string @ModSwitch_Color_yellow = "ModSwitch.Color.yellow";
/// <summary>
/// Get's the translation key for '<em>Create a local copy</em>'
/// </summary>
public const string @ModSwitch_CopyLocal = "ModSwitch.CopyLocal";
/// <summary>
/// Get's the translation key for '<em>Steam currently not running/available</em>'
/// </summary>
public const string @ModSwitch_Error_SteamNotRunning = "ModSwitch.Error.SteamNotRunning";
/// <summary>
/// Get's the translation key for '<em>There are already stored settings for the mod under the new name {0}. You can confirm overwriting the existing settings or skip copying settings.</em>'
/// </summary>
public const string @ModSwitch_ExistingSettings = "ModSwitch.ExistingSettings";
/// <summary>
/// Get's the translation key for '<em>Overwrite.</em>'
/// </summary>
public const string @ModSwitch_ExistingSettings_Choice_Overwrite = "ModSwitch.ExistingSettings.Choice.Overwrite";
/// <summary>
/// Get's the translation key for '<em>Skip.</em>'
/// </summary>
public const string @ModSwitch_ExistingSettings_Choice_Skip = "ModSwitch.ExistingSettings.Choice.Skip";
/// <summary>
/// Get's the translation key for '<em>Contains invalid characters</em>'
/// </summary>
public const string @ModSwitch_Error_InvalidChars = "ModSwitch.Error.InvalidChars";
/// <summary>
/// Get's the translation key for '<em>Target already exists</em>'
/// </summary>
public const string @ModSwitch_Error_TargetExists = "ModSwitch.Error.TargetExists";
/// <summary>
/// Get's the translation key for '<em>Copied mod {0} to {1}.</em>'
/// </summary>
public const string @ModSwitch_CopyLocal_Result_Copy = "ModSwitch.CopyLocal.Result.Copy";
/// <summary>
/// Get's the translation key for '<em>Copied {0} settings file(s).</em>'
/// </summary>
public const string @ModSwitch_CopyLocal_Result_Settings = "ModSwitch.CopyLocal.Result.Settings";
/// <summary>
/// Get's the translation key for '<em>Skipped copying settings.</em>'
/// </summary>
public const string @ModSwitch_CopyLocal_Result_Skipped = "ModSwitch.CopyLocal.Result.Skipped";
/// <summary>
/// Get's the translation key for '<em>Move to...</em>'
/// </summary>
public const string @ModSwitch_MoveTo = "ModSwitch.MoveTo";
/// <summary>
/// Get's the translation key for '<em>Top</em>'
/// </summary>
public const string @ModSwitch_MoveTo_Top = "ModSwitch.MoveTo.Top";
/// <summary>
/// Get's the translation key for '<em>Bottom</em>'
/// </summary>
public const string @ModSwitch_MoveTo_Bottom = "ModSwitch.MoveTo.Bottom";
}
}
}
24 changes: 24 additions & 0 deletions Source/ModSwitch/ModSwitch.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Harmony;
using UnityEngine;
using Verse;
Expand All @@ -9,6 +12,12 @@ namespace DoctorVanGogh.ModSwitch {
class ModSwitch : Mod {
private Settings _settings;

private static readonly FieldInfo fiModLister_mods;

static ModSwitch() {
fiModLister_mods = AccessTools.Field(typeof(ModLister), "mods");
}

public ModSwitch(ModContentPack content) : base(content) {
var harmony = HarmonyInstance.Create("DoctorVanGogh.ModSwitch");
harmony.PatchAll(typeof(ModSwitch).Assembly);
Expand Down Expand Up @@ -37,5 +46,20 @@ public Color GetModColor(ModMetaData mod) {
public void SetModColor(ModMetaData mod, Color value) {
_settings.GetOrInsertAttributes(mod.Identifier).Color = value;
}

public void MovePosition(ModMetaData mod, Position position) {
List<ModMetaData> mods = (List<ModMetaData>) fiModLister_mods.GetValue(null);

if (mods.Remove(mod)) {
switch (position) {
case Position.Top:
mods.Insert(0, mod);
break;
case Position.Bottom:
mods.Add(mod);
break;
}
}
}
}
}
2 changes: 1 addition & 1 deletion 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="[Util]\Position.cs" />
<Compile Include="[Util]\Util.cs" />
<Compile Include="[Patches]\Patches.cs" />
<Compile Include="[Util]\Linq.cs" />
Expand Down Expand Up @@ -109,5 +110,4 @@
</Target>
<Target Name="AfterBuild">
</Target>

</Project>
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.0.0.10")]
[assembly: System.Reflection.AssemblyVersion("1.1.0.27")]


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

0 comments on commit 11148d2

Please sign in to comment.