diff --git a/1.4/Assemblies/AchtungMod.dll b/1.4/Assemblies/AchtungMod.dll index 7c8fec2..b896c41 100644 Binary files a/1.4/Assemblies/AchtungMod.dll and b/1.4/Assemblies/AchtungMod.dll differ diff --git a/About/Preview.png b/About/Preview.png index 48e5ec9..cdc3f52 100644 Binary files a/About/Preview.png and b/About/Preview.png differ diff --git a/About/Resources/01_Welcome.png b/About/Resources/01_Welcome.png new file mode 100644 index 0000000..06af4a6 Binary files /dev/null and b/About/Resources/01_Welcome.png differ diff --git a/About/Resources/02_Forcing.mp4 b/About/Resources/02_Forcing.mp4 new file mode 100644 index 0000000..1302c82 Binary files /dev/null and b/About/Resources/02_Forcing.mp4 differ diff --git a/About/Resources/03_Formations.mp4 b/About/Resources/03_Formations.mp4 new file mode 100644 index 0000000..bd36c54 Binary files /dev/null and b/About/Resources/03_Formations.mp4 differ diff --git a/About/Resources/04_Cooperation.mp4 b/About/Resources/04_Cooperation.mp4 new file mode 100644 index 0000000..d261f33 Binary files /dev/null and b/About/Resources/04_Cooperation.mp4 differ diff --git a/About/Resources/05_ThreeModes.mp4 b/About/Resources/05_ThreeModes.mp4 new file mode 100644 index 0000000..e19917b Binary files /dev/null and b/About/Resources/05_ThreeModes.mp4 differ diff --git a/Languages/Dutch/Keyed/Text.xml b/Languages/Dutch/Keyed/Text.xml index 8255632..ae41170 100644 --- a/Languages/Dutch/Keyed/Text.xml +++ b/Languages/Dutch/Keyed/Text.xml @@ -1,6 +1,12 @@ + Welkom bij Achtung! + Dwingen + Formaties + Samenwerking + Drie Modi + Aangepaste muispositionering Maakt gevechtspositionering mogelijk voor je muisklikken/slepen (zie onderstaande instellingen) diff --git a/Languages/English/Keyed/Text.xml b/Languages/English/Keyed/Text.xml index dde2aea..dfcc843 100644 --- a/Languages/English/Keyed/Text.xml +++ b/Languages/English/Keyed/Text.xml @@ -2,11 +2,10 @@ Welcome to Achtung! - Three Modes - Drafted & Undrafted - Lineup Forcing - Advanced Forcing + Formations + Cooperation + Three Modes Custom mouse positioning Enables combat positioning for your mouse clicks/drags (see settings below) diff --git a/Languages/German/Keyed/Text.xml b/Languages/German/Keyed/Text.xml index 8c7f6e1..6ea9612 100644 --- a/Languages/German/Keyed/Text.xml +++ b/Languages/German/Keyed/Text.xml @@ -1,6 +1,12 @@  + Willkommen zu Achtung! + Erzwingen + Formationen + Zusammenarbeit + Drei Modi + Benutzerdef. Positionierung via Maus Aktiviert die Kampfpositionierung beim Klicken/Ziehen der Maus (siehe Einstellungen unten). diff --git a/Languages/Spanish/Keyed/Text.xml b/Languages/Spanish/Keyed/Text.xml index 48d8fba..226564a 100644 --- a/Languages/Spanish/Keyed/Text.xml +++ b/Languages/Spanish/Keyed/Text.xml @@ -1,6 +1,12 @@  + ¡Bienvenido a Achtung! + Forzar + Formaciones + Cooperación + Tres Modos + Posicionamiento del ratón personalizado Permite el posicionamiento en combate con un click o arrastre de tu ratón (ver preferencias abajo) diff --git a/Languages/Swedish/Keyed/Text.xml b/Languages/Swedish/Keyed/Text.xml index 753a18a..1552a0b 100644 --- a/Languages/Swedish/Keyed/Text.xml +++ b/Languages/Swedish/Keyed/Text.xml @@ -1,6 +1,12 @@  + Välkommen till Achtung! + Tvinga + Formationer + Samarbete + Tre Lägen + Aktivera positioningen för kolonister Aktiverar muskommandos för positioneringen av kolonister (se inställningar nere) diff --git a/Source/Dialog_ModFeatures.cs b/Source/Dialog_ModFeatures.cs index 328bb49..557d1a5 100644 --- a/Source/Dialog_ModFeatures.cs +++ b/Source/Dialog_ModFeatures.cs @@ -2,12 +2,31 @@ using System; using System.IO; using System.Linq; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Json; using UnityEngine; using UnityEngine.Video; using Verse; namespace AchtungMod { + [DataContract] + class Configuration + { + [DataMember] string[] Dismissed { get; set; } = new string[0]; + + internal bool IsDismissed(string topic) => Dismissed.Contains(topic); + + internal void MarkDismissed(string topic) + { + if (IsDismissed(topic) == false) + { + Dismissed = Dismissed.Concat(new[] { topic }).ToArray(); + Dialog_ModFeatures.Save(); + } + } + } + internal class Dialog_ModFeatures : Window { const float listWidth = 240; @@ -22,9 +41,12 @@ internal class Dialog_ModFeatures : Window VideoPlayer videoPlayer; string title = ""; + static readonly string configurationPath = Path.Combine(GenFilePaths.ConfigFolderPath, "ModFeatures.json"); + static Configuration configuration = new Configuration(); + readonly string resourceDir; - readonly string[] topicResources; - readonly Texture2D[] topicTextures; + string[] topicResources; + Texture2D[] topicTextures; string TopicTranslated(int i) => $"Topic_{topicResources[i].Substring(3).Replace(".png", "").Replace(".mp4", "")}".Translate(); string TopicType(int i) => topicResources[i].EndsWith(".png") ? "image" : "video"; @@ -39,17 +61,56 @@ public Dialog_ModFeatures(Type type) silenceAmbientSound = true; closeOnClickedOutside = true; + Load(); + var rootDir = LoadedModManager.RunningMods.FirstOrDefault(mod => mod.assemblies.loadedAssemblies.Contains(type.Assembly))?.RootDir; if (rootDir == null) throw new Exception($"Could not find root mod directory for {type.Assembly.FullName}"); resourceDir = $"{rootDir}{Path.DirectorySeparatorChar}{ModMetaData.AboutFolderName}{Path.DirectorySeparatorChar}Resources"; + ReloadTextures(); + } + + internal void ReloadTextures() + { topicResources = Directory.GetFiles(resourceDir) .Select(f => Path.GetFileName(f)) + .Where(topic => configuration.IsDismissed(topic) == false) .ToArray(); topicTextures = new Texture2D[topicResources.Length]; } + static void Load() + { + try + { + if (File.Exists(configurationPath)) + { + var serializer = new DataContractJsonSerializer(typeof(Configuration)); + using var stream = new FileStream(configurationPath, FileMode.Open); + configuration = (Configuration)serializer.ReadObject(stream); + return; + } + } + catch + { + } + configuration = new Configuration(); + } + + internal static void Save() + { + try + { + var serializer = new DataContractJsonSerializer(typeof(Configuration)); + using var stream = new FileStream(configurationPath, FileMode.OpenOrCreate); + serializer.WriteObject(stream, configuration); + } + finally + { + } + } + public override float Margin => margin; public int TopicCount => topicResources.Length; @@ -103,6 +164,8 @@ public void ShowTopic(int i) videoPlayer.Play(); } + static readonly Color[] frameColors = new[] { Color.yellow.ToTransparent(0.2f), Color.yellow.ToTransparent(0.3f), }; + static readonly Color[] bgColors = new[] { Color.yellow.ToTransparent(0.05f), Color.yellow.ToTransparent(0.1f), }; public override void DoWindowContents(Rect inRect) { var font = Text.Font; @@ -119,7 +182,24 @@ public override void DoWindowContents(Rect inRect) for (var i = 0; i < topicResources.Length; i++) { var r = new Rect(0f, (rowHeight + rowSpacing) * i, viewRect.width, rowHeight); - if (Widgets.ButtonText(r, TopicTranslated(i))) + var hover = Mouse.IsOver(r) ? 1 : 0; + Widgets.DrawBoxSolid(r, bgColors[hover]); + Widgets.DrawBox(r, 1, SolidColorMaterials.NewSolidColorTexture(frameColors[hover])); + var anchor = Text.Anchor; + Text.Anchor = TextAnchor.MiddleLeft; + Widgets.Label(r.RightPartPixels(r.width - margin), TopicTranslated(i)); + Text.Anchor = anchor; + r = r.RightPartPixels(rowHeight).ExpandedBy(-titleHeight / 2); + if (Widgets.ButtonImage(r, MainTabWindow_Quests.DismissIcon)) + { + configuration.MarkDismissed(topicResources[i]); + currentTexture = null; + title = ""; + ReloadTextures(); + if (TopicCount == 0) + Close(); + } + else if (hover == 1 && Mouse.IsOver(r) == false && Input.GetMouseButton(0)) ShowTopic(i); } Widgets.EndScrollView(); diff --git a/Source/Main.cs b/Source/Main.cs index 92cd00b..1937b24 100644 --- a/Source/Main.cs +++ b/Source/Main.cs @@ -104,17 +104,17 @@ public static void Prefix() } } - [HarmonyPatch(typeof(UIRoot_Entry))] - [HarmonyPatch(nameof(UIRoot_Entry.Init))] - static class VideoPatch1 - { - public static void Postfix() - { - var dialog = new Dialog_ModFeatures(typeof(Achtung)); - if (dialog.TopicCount > 0) - Find.WindowStack.Add(dialog); - } - } + // [HarmonyPatch(typeof(UIRoot_Entry))] + // [HarmonyPatch(nameof(UIRoot_Entry.Init))] + // static class VideoPatch1 + // { + // public static void Postfix() + // { + // var dialog = new Dialog_ModFeatures(typeof(Achtung)); + // if (dialog.TopicCount > 0) + // Find.WindowStack.Add(dialog); + // } + // } [HarmonyPatch(typeof(Map))] [HarmonyPatch(nameof(Map.FinalizeInit))] @@ -243,6 +243,23 @@ public static void Postfix(Pawn ___pawn, WorkTypeDef w, ref bool __result) __result = ___pawn.workSettings.GetPriority(w) == 0; } } + // + [HarmonyPatch(typeof(Alert_HunterLacksRangedWeapon))] + [HarmonyPatch(nameof(Alert_HunterLacksRangedWeapon.HuntersWithoutRangedWeapon), MethodType.Getter)] + static class Alert_HunterLacksRangedWeapon_HuntersWithoutRangedWeapon_Patch + { + static bool WorkIsActive(Pawn_WorkSettings instance, WorkTypeDef w) + { + return instance.GetPriority(w) > 0; // "unpatch" it + } + + public static IEnumerable Transpiler(IEnumerable instructions) + { + var fromMethod = SymbolExtensions.GetMethodInfo((Pawn_WorkSettings workSettings) => workSettings.WorkIsActive(null)); + var toMethod = SymbolExtensions.GetMethodInfo(() => WorkIsActive(null, null)); + return instructions.MethodReplacer(fromMethod, toMethod); + } + } // forced hauling outside of allowed area // @@ -404,6 +421,32 @@ public static IEnumerable Transpiler(IEnumerable pawn.IsColonist && pawn.Drafted) > 1) + __result = false; + } + } + // + [HarmonyPatch(typeof(CellInspectorDrawer))] + [HarmonyPatch(nameof(CellInspectorDrawer.ShouldShow))] + static class CellInspectorDrawer_ShouldShow_Patch + { + public static void Postfix(ref bool __result) + { + if (__result == false) + return; + if (Find.Selector.SelectedPawns.Count(pawn => pawn.IsColonist && pawn.Drafted) > 1) + __result = false; + } + } + // allow multiple colonists by reserving the exit path from a build place /* * ### ENABLE AGAIN FOR SMART BUILDING diff --git a/Source/Originals/QuickTutorial.afphoto b/Source/Originals/QuickTutorial.afphoto new file mode 100644 index 0000000..c2d7993 Binary files /dev/null and b/Source/Originals/QuickTutorial.afphoto differ diff --git a/Source/Originals/Screenshot.afphoto b/Source/Originals/Screenshot.afphoto new file mode 100644 index 0000000..cbf0e43 Binary files /dev/null and b/Source/Originals/Screenshot.afphoto differ diff --git a/Source/Originals/Screenshot.psd b/Source/Originals/Screenshot.psd deleted file mode 100644 index 4549e9d..0000000 Binary files a/Source/Originals/Screenshot.psd and /dev/null differ