From ba2a395da7026de4be32733fc27011e161ead255 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 26 May 2024 12:06:27 -0400 Subject: Added AP icon for treasure chests --- AnodyneArchipelago/ArchipelagoTreasure.cs | 2 +- AnodyneArchipelago/Patches/StatePatches.cs | 29 +++++++++++++++++++++++++++ AnodyneArchipelago/Plugin.cs | 2 ++ README.md | 1 + Resources/LICENSE.archipelago-asset-pack.txt | 1 + Resources/archipelago.png | Bin 0 -> 710 bytes 6 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Resources/LICENSE.archipelago-asset-pack.txt create mode 100644 Resources/archipelago.png diff --git a/AnodyneArchipelago/ArchipelagoTreasure.cs b/AnodyneArchipelago/ArchipelagoTreasure.cs index 90f979c..9074108 100644 --- a/AnodyneArchipelago/ArchipelagoTreasure.cs +++ b/AnodyneArchipelago/ArchipelagoTreasure.cs @@ -9,7 +9,7 @@ namespace AnodyneArchipelago { private string _location; - public ArchipelagoTreasure(string location, Vector2 pos) : base("item_jump_shoes", pos, 0, -1) + public ArchipelagoTreasure(string location, Vector2 pos) : base("archipelago", pos, 0, -1) { _location = location; } diff --git a/AnodyneArchipelago/Patches/StatePatches.cs b/AnodyneArchipelago/Patches/StatePatches.cs index c1e03fe..6da5eb5 100644 --- a/AnodyneArchipelago/Patches/StatePatches.cs +++ b/AnodyneArchipelago/Patches/StatePatches.cs @@ -10,9 +10,24 @@ using static AnodyneSharp.AnodyneGame; using AnodyneSharp.Drawing; using System.IO; using System; +using AnodyneSharp.Resources; +using BepInEx; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using System.Collections.Generic; namespace AnodyneArchipelago.Patches { + [HarmonyPatch(typeof(AnodyneGame), "LoadContent")] + class AnodyneLoadContentPatch + { + static void Prefix(AnodyneGame __instance) + { + FieldInfo gdmField = typeof(AnodyneGame).GetField("graphics", BindingFlags.NonPublic | BindingFlags.Instance); + Plugin.GraphicsDevice = ((GraphicsDeviceManager)gdmField.GetValue(__instance)).GraphicsDevice; + } + } + [HarmonyPatch(typeof(AnodyneGame), "Update")] class GameUpdatePatch { @@ -127,4 +142,18 @@ namespace AnodyneArchipelago.Patches Plugin.ArchipelagoManager.ActivateGoal(); } } + + [HarmonyPatch(typeof(ResourceManager), nameof(ResourceManager.LoadResources))] + static class LoadResourcesPatch + { + static void Postfix() + { + FileStream filestream = File.OpenRead($"{Paths.GameRootPath}\\Resources\\archipelago.png"); + Texture2D apSprite = Texture2D.FromStream(Plugin.GraphicsDevice, filestream); + + FieldInfo texturesField = typeof(ResourceManager).GetField("_textures", BindingFlags.NonPublic | BindingFlags.Static); + Dictionary textures = (Dictionary)texturesField.GetValue(null); + textures["archipelago"] = apSprite; + } + } } diff --git a/AnodyneArchipelago/Plugin.cs b/AnodyneArchipelago/Plugin.cs index 18f0d36..6c1333d 100644 --- a/AnodyneArchipelago/Plugin.cs +++ b/AnodyneArchipelago/Plugin.cs @@ -3,6 +3,7 @@ using BepInEx; using BepInEx.NET.Common; using HarmonyLib; using HarmonyLib.Tools; +using Microsoft.Xna.Framework.Graphics; using System; using System.Reflection; @@ -13,6 +14,7 @@ namespace AnodyneArchipelago { public static Plugin Instance = null; + public static GraphicsDevice GraphicsDevice = null; public static Player Player = null; public static ArchipelagoManager ArchipelagoManager = null; public static bool IsGamePaused = false; diff --git a/README.md b/README.md index c087917..6484058 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ The layout of the `AnodyneArchipelago` release is as follows: `MonoMod.RuntimeDetour.dll`, `MonoMod.Utils.dll`, `SemanticVersioning.dll`. - The `AnodyneArchipelago` dependencies: `Archipelago.MultiClient.Net.dll`, `Newtonsoft.Json.dll`. +- The `Resources` folder from the repository root. - A folder called `BepInEx`, containing two subfolders: `config`, which contains `BepInEx.cfg` from the repository root, and `plugins`, which contains `AnodyneArchipelago.dll` itself. diff --git a/Resources/LICENSE.archipelago-asset-pack.txt b/Resources/LICENSE.archipelago-asset-pack.txt new file mode 100644 index 0000000..24bc1fb --- /dev/null +++ b/Resources/LICENSE.archipelago-asset-pack.txt @@ -0,0 +1 @@ +This work © 2022 by Krista Corkos and Christopher Wilson is licensed under Attribution-NonCommercial 4.0 International. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ \ No newline at end of file diff --git a/Resources/archipelago.png b/Resources/archipelago.png new file mode 100644 index 0000000..3ce37df Binary files /dev/null and b/Resources/archipelago.png differ -- cgit 1.4.1