Skip to content

Commit

Permalink
Save When Quitting mod
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd committed Apr 11, 2022
1 parent e4c3f93 commit 15a875a
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ by deleting the directory itself.

| Cheats | UI/QoL | Other |
|---|---|---|
| [Asteroid Landing Position Override](#cheat-asteroid-landing-position-override)<br/>[Auto Consume Oxygen-Water-Food](#cheat-auto-consume-oxygen-water-food)<br/>[Highlight Nearby Resources](#cheat-highlight-nearby-resources)<br/>[Inventory Capacity Override](#cheat-inventory-capacity-override)<br/>[Machines Deposit Into Remote Containers](#cheat-machines-deposit-into-remote-containers)<br/>[Minimap](#cheat-minimap)<br/>[Photomode Hide Water](#cheat-photomode-hide-water)<br/>[Teleport to Nearest Minable](#cheat-teleport-to-nearest-minable) | [Craft Equipment Inplace](#ui-craft-equipment-inplace)<br/>[Customize Inventory Sort Order](#ui-customize-inventory-sort-order)<br/>[Don't Close Craft Window](#ui-dont-close-craft-window)<br/>[Grower Grab Vegetable Only](#ui-grower-grab-vegetable-only)<br/>[Hide Beacons in Photomode](#ui-hide-beacons-in-photomode)<br/>[Inventory Move Multiple Items](#ui-inventory-move-multiple-items)<br/>[Show Container Content Info](#ui-show-container-content-info)<br/>[Show Player Inventory Counts](#ui-show-player-inventory-counts)<br/>[Show Player Tooltip Item Count](#ui-show-player-tooltip-item-count)<br/>[Show Rocket Counts](#ui-show-rocket-counts)<br/>[Pin Recipe to Screen](#ui-pin-recipe-to-screen) | [Load Inventories Faster](#perf-load-inventories-faster)<br/>[Reduce Save Size](#perf-reduce-save-size)<br/>[Support Mods with Load n Save](#lib-support-mods-with-load-n-save) |
| [Asteroid Landing Position Override](#cheat-asteroid-landing-position-override)<br/>[Auto Consume Oxygen-Water-Food](#cheat-auto-consume-oxygen-water-food)<br/>[Highlight Nearby Resources](#cheat-highlight-nearby-resources)<br/>[Inventory Capacity Override](#cheat-inventory-capacity-override)<br/>[Machines Deposit Into Remote Containers](#cheat-machines-deposit-into-remote-containers)<br/>[Minimap](#cheat-minimap)<br/>[Photomode Hide Water](#cheat-photomode-hide-water)<br/>[Teleport to Nearest Minable](#cheat-teleport-to-nearest-minable) | [Craft Equipment Inplace](#ui-craft-equipment-inplace)<br/>[Customize Inventory Sort Order](#ui-customize-inventory-sort-order)<br/>[Don't Close Craft Window](#ui-dont-close-craft-window)<br/>[Grower Grab Vegetable Only](#ui-grower-grab-vegetable-only)<br/>[Hide Beacons in Photomode](#ui-hide-beacons-in-photomode)<br/>[Inventory Move Multiple Items](#ui-inventory-move-multiple-items)<br/>[Save When Quitting](#ui-save-when-quitting)<br/>[Show Container Content Info](#ui-show-container-content-info)<br/>[Show Player Inventory Counts](#ui-show-player-inventory-counts)<br/>[Show Player Tooltip Item Count](#ui-show-player-tooltip-item-count)<br/>[Show Rocket Counts](#ui-show-rocket-counts)<br/>[Pin Recipe to Screen](#ui-pin-recipe-to-screen) | [Load Inventories Faster](#perf-load-inventories-faster)<br/>[Reduce Save Size](#perf-reduce-save-size)<br/>[Support Mods with Load n Save](#lib-support-mods-with-load-n-save) |


## (Cheat) Asteroid Landing Position Override
Expand Down Expand Up @@ -397,6 +397,14 @@ the crafting action will succeed if the rest of the materials are in your backpa

None.

## (UI) Save When Quitting

Automatically saves the game when clicking the "Exit to main menu" button.

### Configuration

None.

## (Lib) Support Mods with Load n Save

This mod alters the loading and saving of the game by parsing/appending custom information based on
Expand Down
6 changes: 6 additions & 0 deletions ThePlanetCrafterMods.sln
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UICraftEquipmentInplace", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CheatMinimap", "CheatMinimap\CheatMinimap.csproj", "{99714257-AC6F-4EE3-8321-713808D00B93}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UISaveOnQuit", "UISaveOnQuit\UISaveOnQuit.csproj", "{B38DD082-BCBF-4A0B-8EFC-3095F1FC9496}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -152,6 +154,10 @@ Global
{99714257-AC6F-4EE3-8321-713808D00B93}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99714257-AC6F-4EE3-8321-713808D00B93}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99714257-AC6F-4EE3-8321-713808D00B93}.Release|Any CPU.Build.0 = Release|Any CPU
{B38DD082-BCBF-4A0B-8EFC-3095F1FC9496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B38DD082-BCBF-4A0B-8EFC-3095F1FC9496}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B38DD082-BCBF-4A0B-8EFC-3095F1FC9496}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B38DD082-BCBF-4A0B-8EFC-3095F1FC9496}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions UISaveOnQuit/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
</packageSources>
</configuration>
31 changes: 31 additions & 0 deletions UISaveOnQuit/Plugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using BepInEx;
using MijuTools;
using BepInEx.Configuration;
using SpaceCraft;
using UnityEngine.InputSystem;
using HarmonyLib;
using UnityEngine.EventSystems;
using System.Collections.Generic;

namespace UISaveOnQuit
{
[BepInPlugin("akarnokd.theplanetcraftermods.saveonquit", "(UI) Save When Quitting", "1.0.0.0")]
public class Plugin : BaseUnityPlugin
{

private void Awake()
{
// Plugin startup logic
Logger.LogInfo($"Plugin is loaded!");

Harmony.CreateAndPatchAll(typeof(Plugin));
}

[HarmonyPrefix]
[HarmonyPatch(typeof(UiWindowPause), nameof(UiWindowPause.OnQuit))]
static void UiWindowPause_OnQuit(UiWindowPause __instance)
{
__instance.OnSave();
}
}
}
66 changes: 66 additions & 0 deletions UISaveOnQuit/UISaveOnQuit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<AssemblyName>UISaveOnQuit</AssemblyName>
<Description>(UI) Save When Quitting</Description>
<Version>1.0.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<Platforms>AnyCPU</Platforms>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="Exists('c:\Program Files (x86)\Steam\steamapps\common\The Planet Crafter')">
<GameDir>c:\Program Files (x86)\Steam\steamapps\common\The Planet Crafter\</GameDir>
<GameManaged>$(GameDir)Planet Crafter_Data\Managed\</GameManaged>
<PluginsFolder>$(GameDir)\BepInEx\plugins</PluginsFolder>
</PropertyGroup>
<PropertyGroup Condition="Exists('e:\Steam\steamapps\common\The Planet Crafter')">
<GameDir>e:\Steam\steamapps\common\The Planet Crafter\</GameDir>
<GameManaged>$(GameDir)Planet Crafter_Data\Managed\</GameManaged>
<PluginsFolder>$(GameDir)\BepInEx\plugins</PluginsFolder>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2020.3.26" IncludeAssets="compile" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(GameManaged)\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="com.mijugames.miju-tools">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(GameManaged)com.mijugames.miju-tools.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Unity.InputSystem">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(GameManaged)unity.inputsystem.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(GameManaged)unityengine.ui.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>

<Target Name="CopyDLLs" AfterTargets="Build">
<Copy SourceFiles="$(TargetDir)$(AssemblyName).dll" DestinationFolder="$(PluginsFolder)\akarnokd - $(Description)" />
<Copy SourceFiles="$(TargetDir)$(AssemblyName).dll" DestinationFolder="$(TargetDir)\$(AssemblyName)\akarnokd - $(Description)" />
<ZipDirectory
SourceDirectory="$(TargetDir)\$(AssemblyName)"
DestinationFile="$(OutputPath)\..\..\..\..\akarnokd-$(AssemblyName).zip"
Overwrite="true" />
</Target>
</Project>

0 comments on commit 15a875a

Please sign in to comment.