From 872e97f09bbeeeded95325e1ea1ea49d6f52f833 Mon Sep 17 00:00:00 2001 From: jixxed Date: Mon, 5 Feb 2024 22:37:55 +0100 Subject: [PATCH] add changelog add progressbar on upload add mod validation add copy option for assemblies fix screwdriver tool --- StationieersMods/AssemblyInfo.cs | 4 +- .../DevelopmentEditor.cs | 57 ++++++++++++- .../StationeersTool.cs | 2 +- .../WorkshopMenuPatch.cs | 82 +++++++++++++++++-- .../StationeersMods/CustomModAbout.cs | 3 + 5 files changed, 135 insertions(+), 13 deletions(-) diff --git a/StationieersMods/AssemblyInfo.cs b/StationieersMods/AssemblyInfo.cs index ddca7f7..5e64f5b 100644 --- a/StationieersMods/AssemblyInfo.cs +++ b/StationieersMods/AssemblyInfo.cs @@ -2,5 +2,5 @@ using System.Runtime.InteropServices; // Shared between projects -[assembly: AssemblyVersion("1.0.17.0")] -[assembly: AssemblyFileVersion("1.0.17.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.18.0")] +[assembly: AssemblyFileVersion("1.0.18.0")] \ No newline at end of file diff --git a/StationieersMods/StationeersMods.Editor/DevelopmentEditor.cs b/StationieersMods/StationeersMods.Editor/DevelopmentEditor.cs index 9b10873..9ddf603 100644 --- a/StationieersMods/StationeersMods.Editor/DevelopmentEditor.cs +++ b/StationieersMods/StationeersMods.Editor/DevelopmentEditor.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Assets.Scripts.Objects.Pipes; +using HarmonyLib; using StationeersMods.Shared; using UnityEditor; using UnityEngine; @@ -123,8 +124,62 @@ public bool Draw(ExportSettings settings) } } GUILayout.EndHorizontal(); - + GUILayout.Space(10); + GUILayout.BeginHorizontal(); + if (GUILayout.Button("Copy game assemblies to project", GUILayout.Width(buttonWidth), GUILayout.Height(35))) + { + try + { + CopyAssemblies(settings); + EditorUtility.DisplayDialog("Complete", "All files have been copied.", "OK"); + } + catch(ArgumentException ex) + { + EditorUtility.DisplayDialog("Error", ex.Message, "OK"); + } + } + GUILayout.EndHorizontal(); return true; } + + private void CopyAssemblies(ExportSettings settings) + { + if (!Directory.Exists(settings.StationeersDirectory)) + { + throw new ArgumentException("Did you configure the Stationeers directory? Could not find " + settings.StationeersDirectory); + } + var assembliesFolder = Path.Combine(Application.dataPath, "Assemblies"); + var assemblies = Path.Combine(assembliesFolder, "copy.txt"); + if (!File.Exists(assemblies)) + { + throw new ArgumentException("Could not find " + assemblies); + } + List errors = new List(); + foreach (var line in File.ReadLines(assemblies)) + { + if (line == "") + { + continue; + } + var assemblyToCopy = Path.Combine(settings.StationeersDirectory, line); + + if (File.Exists(assemblyToCopy)) + { + Debug.Log("Copy: " + assemblyToCopy + " to " + assembliesFolder); + File.Copy(assemblyToCopy,Path.Combine(assembliesFolder, Path.GetFileName(assemblyToCopy)),true); + } + else + { + Debug.LogError("Error: " + assemblyToCopy + " doesn't exist"); + errors.Add(assemblyToCopy); + } + + } + + if (errors.Count > 0) + { + throw new ArgumentException("Failed to copy the following assemblies:\n" + string.Join("\n", errors)); + } + } } } \ No newline at end of file diff --git a/StationieersMods/StationeersMods.Interface/StationeersTool.cs b/StationieersMods/StationeersMods.Interface/StationeersTool.cs index 0fe119a..7b49958 100644 --- a/StationieersMods/StationeersMods.Interface/StationeersTool.cs +++ b/StationieersMods/StationeersMods.Interface/StationeersTool.cs @@ -13,7 +13,7 @@ public class StationeersTool public static StationeersTool FIRE_EXTINGUISHER = new StationeersTool( "ItemFireExtinguisher"); public static StationeersTool LABELLER = new StationeersTool( "ItemLabeller"); public static StationeersTool WRENCH = new StationeersTool( "ItemWrench"); - public static StationeersTool SCREWDRIVER = new StationeersTool( "ItemScrewdrive"); + public static StationeersTool SCREWDRIVER = new StationeersTool( "ItemScrewdriver"); public string PrefabName { get; private set; } public StationeersTool(string prefabName) diff --git a/StationieersMods/StationeersMods.Plugin/WorkshopMenuPatch.cs b/StationieersMods/StationeersMods.Plugin/WorkshopMenuPatch.cs index ec5e96a..6fc3355 100644 --- a/StationieersMods/StationeersMods.Plugin/WorkshopMenuPatch.cs +++ b/StationieersMods/StationeersMods.Plugin/WorkshopMenuPatch.cs @@ -1,11 +1,11 @@ -using System; +using System.Collections.Generic; using System.IO; using System.Reflection; +using Assets.Scripts.Networking.Transports; using Assets.Scripts.Serialization; +using Assets.Scripts.UI; using HarmonyLib; -using JetBrains.Annotations; using UnityEngine; -using UnityEngine.Events; using UnityEngine.UI; namespace StationeersMods.Plugin @@ -29,10 +29,11 @@ public static void RefreshButtonsPostfix(WorkshopMenu __instance) Debug.Log("stationeersmods file found."); __instance.SelectedModButtonRight.GetComponent