Skip to content

Commit

Permalink
Merge pull request ExOK#69 from echoslabs/saves
Browse files Browse the repository at this point in the history
Adding Save Selection Screen, Splitting Up Save and Settings Files, and Refactoring Save system to support versioning
  • Loading branch information
jasminegamedev authored Mar 28, 2024
2 parents 35ada38 + 5787208 commit 963f320
Show file tree
Hide file tree
Showing 51 changed files with 1,863 additions and 645 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Content/Sprites/Controls/PC/copyfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Content/Sprites/Controls/PC/createfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Content/Sprites/Controls/PC/deletefile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Content/Sprites/Controls/PlayStation 4/copyfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Content/Sprites/Controls/PlayStation 5/copyfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Content/Sprites/Controls/Xbox Series/copyfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Content/Sprites/Controls/Xbox Series/createfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Content/Sprites/Controls/Xbox Series/deletefile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions Content/Text/English.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"Restart": "Restart",
"Start": "Start",
"Exit": "Exit",
"Load": "Load",
"Create": "Create",
"Delete": "Delete",
"Copy": "Copy",
"RestartLevel": "Clear Save & Restart Level",
"PauseTitle": "Paused",
"PauseResume": "Resume",
Expand All @@ -20,6 +24,10 @@
"PauseOptions.desc": "Update the Game Options",
"PauseSaveQuit": "Save & Quit",
"PauseSaveQuit.desc": "Save & Quit to the Title Screen",
"PauseSaves": "Saves",
"PauseSaves.desc": "Open the Save Select Menu",
"PauseModsMenu" : "Mods",
"PauseModsMenu.desc" : "Open the Mods Menu",
"OptionsTitle": "Options",
"OptionsFullscreen": "Fullscreen",
"OptionsFullscreen.desc": "Control if the Game is Fullscreen or Windowed",
Expand All @@ -35,8 +43,16 @@
"OptionsInvertCamera.desc": "Control if the Camera X and Y axes are inverted",
"OptionsToggleOn": "ON",
"OptionsToggleOff": "OFF",
"OptionsYes": "Yes",
"OptionsNo": "No",

"Skin": "Skin",
"Skin.desc": "Choose a Skin to Wear",

"SaveCreateFile": "Create new file?" ,
"SaveDeleteFile": "Delete this file?" ,
"SaveDeleteDefaultFile": "Cannot fully delete default save file:'{0}'. Reset it to default instead?",
"SaveCopyFile": "Copy this file?" ,
"FujiOptions": "Fuji Options...",
"FujiOptions.desc": "Configure Options for the Fuji Mod Loader",
"FujiWriteLog": "Write Log File",
Expand All @@ -52,8 +68,6 @@
"FujiContinueToMods.desc": "Continue to the Mods Menu",
"FujiOverworldModSlideNote": "Use Up/Down to filter by mod",
"FailedToLoadMods": "Failed to load {0} mods. Check Mods Menu for details.",
"Mods": "Mods",
"Mods.desc": "Access Mod Info and Settings",
"ModEnabled": "Enabled",
"ModOptions": "Mod Options",
"ConfirmDisableMod": "Continue & Disable Mod",
Expand Down
8 changes: 4 additions & 4 deletions Source/Actors/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public Player()
PointShadowAlpha = 1.0f;
LocalBounds = new BoundingBox(new Vec3(0, 0, 10), 10);
UpdateOffScreen = true;
Skin = Save.Instance.GetSkin();
Skin = Save.GetSkin();

// setup model
{
Expand Down Expand Up @@ -525,7 +525,7 @@ public override void Update()
{
// Rotate Camera
{
var invertX = Save.Instance.InvertCamera == Save.InvertCameraOptions.X || Save.Instance.InvertCamera == Save.InvertCameraOptions.Both;
var invertX = Settings.InvertCamera == InvertCameraOptions.X || Settings.InvertCamera == InvertCameraOptions.Both;
var rot = new Vec2(CameraTargetForward.X, CameraTargetForward.Y).Angle();
rot -= Controls.Camera.Value.X * Time.Delta * 4 * (invertX ? -1 : 1);

Expand All @@ -536,7 +536,7 @@ public override void Update()
// Move Camera in / out
if (Controls.Camera.Value.Y != 0)
{
var invertY = Save.Instance.InvertCamera == Save.InvertCameraOptions.Y || Save.Instance.InvertCamera == Save.InvertCameraOptions.Both;
var invertY = Settings.InvertCamera == InvertCameraOptions.Y || Settings.InvertCamera == InvertCameraOptions.Both;
CameraTargetDistance += Controls.Camera.Value.Y * Time.Delta * (invertY ? -1 : 1);
CameraTargetDistance = Calc.Clamp(CameraTargetDistance, 0, 1);
}
Expand Down Expand Up @@ -2640,7 +2640,7 @@ public virtual void CollectSprites(List<Sprite> populate)
}
}

if (!OnGround && !Dead && PointShadowAlpha > 0 && !InBubble && Save.Instance.ZGuide)
if (!OnGround && !Dead && PointShadowAlpha > 0 && !InBubble && Settings.ZGuide)
{
var distance = 1000.0f;
if (World.SolidRayCast(Position, -Vec3.UnitZ, distance, out var hit))
Expand Down
20 changes: 10 additions & 10 deletions Source/Celeste64.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FosterFramework" Version="0.1.18-alpha"/>
<PackageReference Include="SharpGLTF.Runtime" Version="1.0.0-alpha0031"/>
<PackageReference Include="Sledge.Formats.Map" Version="1.1.5"/>
<PackageReference Include="FosterFramework" Version="0.1.18-alpha" />
<PackageReference Include="SharpGLTF.Runtime" Version="1.0.0-alpha0031" />
<PackageReference Include="Sledge.Formats.Map" Version="1.1.5" />

<PackageReference Include="MonoMod.RuntimeDetour" Version="25.1.0-prerelease.2"/>
<PackageReference Include="ImGui.NET" Version="1.90.1.1"/>
<PackageReference Include="MonoMod.RuntimeDetour" Version="25.1.0-prerelease.2" />
<PackageReference Include="ImGui.NET" Version="1.90.1.1" />

<ProjectReference Include="..\Celeste64.HookGen\Celeste64.HookGen.csproj" OutputItemType="Analyzer" Private="false" PrivateAssets="All" />
</ItemGroup>
Expand Down Expand Up @@ -53,23 +53,23 @@
</PropertyGroup>

<ItemGroup Condition="$(IsLinux) == 'true' and $(IsArm64) == 'true'">
<Content Include="Audio/FMOD/libs/libarm64/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)"/>
<Content Include="Audio/FMOD/libs/libarm64/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup Condition="$(IsLinux) == 'true' and $(IsArm) == 'true'">
<Content Include="Audio/FMOD/libs/libarm/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)"/>
<Content Include="Audio/FMOD/libs/libarm/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup Condition="$(IsLinux) == 'true' and $(IsArm64) != 'true' and $(IsArm) != 'true'">
<Content Include="Audio/FMOD/libs/lib64/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)"/>
<Content Include="Audio/FMOD/libs/lib64/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup Condition="$(IsWindows) == 'true'">
<Content Include="Audio/FMOD/libs/x64/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)"/>
<Content Include="Audio/FMOD/libs/x64/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup Condition="$(IsMacOS) == 'true'">
<Content Include="Audio/FMOD/libs/osx/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)"/>
<Content Include="Audio/FMOD/libs/osx/**" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
Expand Down
69 changes: 64 additions & 5 deletions Source/Data/Controls.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using Celeste64.Mod;
using System.Text.Json;

namespace Celeste64;

public static class Controls
Expand All @@ -11,23 +14,61 @@ public static class Controls
public static readonly VirtualButton Confirm = new("Confirm");
public static readonly VirtualButton Cancel = new("Cancel");
public static readonly VirtualButton Pause = new("Pause");
public static readonly VirtualButton CopyFile = new("CopyFile");
public static readonly VirtualButton DeleteFile = new("DeleteFile");
public static readonly VirtualButton CreateFile = new("CreateFile");

public static ControlsConfig_V01 Instance = new();

public const string DefaultFileName = "controls.json";

[DisallowHooks]
internal static void LoadControlsByFileName(string file_name)
{
if (file_name == string.Empty) file_name = DefaultFileName;
var controlsFile = Path.Join(App.UserPath, file_name);

ControlsConfig_V01? controls = null;
if (File.Exists(controlsFile))
{
try
{
controls = Instance.Deserialize<ControlsConfig_V01>(File.ReadAllText(controlsFile)) ?? null;
}
catch
{
controls = null;
}
}

if (controls == null)
{
controls = ControlsConfig_V01.Defaults;
using var stream = File.Create(controlsFile);
JsonSerializer.Serialize(stream, ControlsConfig_V01.Defaults, ControlsConfig_V01Context.Default.ControlsConfig_V01);
stream.Flush();
}

Instance = controls;
LoadConfig(Instance);
}

public static void Load(ControlsConfig? config = null)
public static void LoadConfig(ControlsConfig_V01? config = null)
{
static ControlsConfig.Stick FindStick(ControlsConfig? config, string name)
static ControlsConfigStick_V01 FindStick(ControlsConfig_V01? config, string name)
{
if (config != null && config.Sticks.TryGetValue(name, out var stick))
return stick;
if (ControlsConfig.Defaults.Sticks.TryGetValue(name, out stick))
if (ControlsConfig_V01.Defaults.Sticks.TryGetValue(name, out stick))
return stick;
throw new Exception($"Missing Stick Binding for '{name}'");
}

static List<ControlsConfig.Binding> FindAction(ControlsConfig? config, string name)
static List<ControlsConfigBinding_V01> FindAction(ControlsConfig_V01? config, string name)
{
if (config != null && config.Actions.TryGetValue(name, out var action))
return action;
if (ControlsConfig.Defaults.Actions.TryGetValue(name, out action))
if (ControlsConfig_V01.Defaults.Actions.TryGetValue(name, out action))
return action;
throw new Exception($"Missing Action Binding for '{name}'");
}
Expand All @@ -50,6 +91,12 @@ static ControlsConfig.Stick FindStick(ControlsConfig? config, string name)
it.BindTo(Cancel);
foreach (var it in FindAction(config, "Pause"))
it.BindTo(Pause);
foreach (var it in FindAction(config, "CopyFile"))
it.BindTo(CopyFile);
foreach (var it in FindAction(config, "DeleteFile"))
it.BindTo(DeleteFile);
foreach (var it in FindAction(config, "CreateFile"))
it.BindTo(CreateFile);

}

Expand All @@ -64,6 +111,9 @@ public static void Clear()
Confirm.Clear();
Cancel.Clear();
Pause.Clear();
CopyFile.Clear();
DeleteFile.Clear();
CreateFile.Clear();
}

public static void Consume()
Expand All @@ -77,6 +127,9 @@ public static void Consume()
Confirm.Consume();
Cancel.Consume();
Pause.Consume();
CopyFile.Consume();
DeleteFile.Consume();
CreateFile.Consume();
}

private static readonly Dictionary<string, Dictionary<string, string>> prompts = [];
Expand Down Expand Up @@ -113,6 +166,12 @@ public static string GetPromptLocation(VirtualButton button)
return GetPromptLocation("confirm");
else if (button == Cancel)
return GetPromptLocation("cancel");
else if (button == CreateFile)
return GetPromptLocation("createfile");
else if (button == DeleteFile)
return GetPromptLocation("deletefile");
else if (button == CopyFile)
return GetPromptLocation("copyfile");
else
return GetPromptLocation("pause");
}
Expand Down
Loading

0 comments on commit 963f320

Please sign in to comment.