Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Classes/Events/EventDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EventDatabase
["EVENT_EVENT1_OPTION1", "EVENT_EVENT1_OPTION2", "EVENT_EVENT1_OPTION3"],
["EVENT_EVENT1_OUTCOME1", "EVENT_EVENT1_OUTCOME2", "EVENT_EVENT1_OUTCOME3"],
[
(self, node) =>
(self, _) =>
{
int randIndex = StageProducer.GlobalRng.RandiRange(
0,
Expand All @@ -33,7 +33,7 @@ public class EventDatabase
localizedName
);
},
(self, node) =>
(self, _) =>
{
int randIndex = StageProducer.GlobalRng.RandiRange(
0,
Expand All @@ -49,12 +49,12 @@ public class EventDatabase
localizedName
);
},
(self, node) =>
(self, _) =>
{
string stolenMoney = (StageProducer.PlayerStats.Money / 2).ToString();
StageProducer.PlayerStats.Money /= 2;

self.OutcomeDescriptions[2] = self.OutcomeDescriptions[0] = string.Format(
self.OutcomeDescriptions[2] = string.Format(
TranslationServer.Translate("EVENT_EVENT1_OUTCOME3"),
stolenMoney
);
Expand Down Expand Up @@ -176,18 +176,18 @@ public class EventDatabase
["EVENT_EVENT3_OPTION1", "EVENT_EVENT3_OPTION2", "EVENT_EVENT3_OPTION3"],
["EVENT_EVENT3_OUTCOME1", "EVENT_EVENT3_OUTCOME2", "EVENT_EVENT3_OUTCOME3"],
[
(self, node) =>
(_, _) =>
{
StageProducer.PlayerStats.CurrentHealth = Math.Min(
StageProducer.PlayerStats.CurrentHealth + 10,
StageProducer.PlayerStats.MaxHealth
);
},
(self, node) =>
(_, _) =>
{
StageProducer.PlayerStats.MaxComboBar -= 5;
},
(self, node) =>
(_, _) =>
{
StageProducer.PlayerStats.Money -= 30;
StageProducer.PlayerStats.AddNote(Scribe.NoteDictionary[3]);
Expand Down
13 changes: 0 additions & 13 deletions Classes/MidiMaestro/MidiMaestro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,12 @@ public partial class MidiMaestro : Resource
private readonly NoteInfo[] _leftNotes;
private readonly NoteInfo[] _rightNotes;

//private MidiFile strippedSong;
/**
* <summary>Constructor loads resource file and populates lane note arrays with NoteInfo</summary>
* <param name="filePath">A string file path to a valid songMap .tres file</param>
*/
public MidiMaestro(NoteChart savedChart)
{
/*if (!OS.HasFeature("editor"))
{
filePath = OS.GetExecutablePath().GetBaseDir() + "/" + filePath;
}

if (!FileAccess.FileExists(filePath))
{
GD.PushError("ERROR: Unable to load level songMap resource file: " + filePath);
}

NoteChart savedChart = ResourceLoader.Load<NoteChart>(filePath);*/

if (savedChart != null)
{
_upNotes = savedChart.GetLane(ArrowType.Up).ToArray();
Expand Down
124 changes: 1 addition & 123 deletions Globals/SaveSystem.cs → Globals/Configkeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* <summary>SaveSystem: Manages FileI/O of configs and save files.</summary>
*/
public static class SaveSystem
public static class Configkeeper
{
#region Config
private const string UserConfigPath = "user://Options.cfg";
Expand All @@ -31,8 +31,6 @@ public static class SaveSystem
private const bool DefaultTypeIsArrow = false;
private const bool DefaultVerticalScroll = true;
private const bool DefaultHighCon = false;
private const bool DefaultFirstTime = true;
private const bool DefaultHasWon = false;

public enum ConfigSettings
{
Expand All @@ -53,8 +51,6 @@ public enum ConfigSettings
LanguageKey,
TypeIsArrow,
HighContrast,
FirstTime,
HasWon,
VerticalScroll,
}

Expand All @@ -81,8 +77,6 @@ private static void InitConfig()
UpdateConfig(ConfigSettings.LanguageKey, DefaultLanguage);
UpdateConfig(ConfigSettings.TypeIsArrow, DefaultTypeIsArrow);
UpdateConfig(ConfigSettings.HighContrast, DefaultHighCon);
UpdateConfig(ConfigSettings.FirstTime, DefaultFirstTime);
UpdateConfig(ConfigSettings.HasWon, DefaultHasWon);
UpdateConfig(ConfigSettings.VerticalScroll, DefaultVerticalScroll);
}

Expand Down Expand Up @@ -151,12 +145,6 @@ public static void UpdateConfig(ConfigSettings setting, Variant value)
case ConfigSettings.HighContrast:
_curConfigData.SetValue("Options", "HighContrast", value);
break;
case ConfigSettings.FirstTime:
_curConfigData.SetValue("Game", "FirstTime", value);
break;
case ConfigSettings.HasWon:
_curConfigData.SetValue("Game", "HasWon", value);
break;
default:
GD.PushError("SaveSystem.UpdateConfig: Invalid config setting passed. " + setting);
break;
Expand Down Expand Up @@ -298,10 +286,6 @@ public static Variant GetConfigValue(ConfigSettings setting)
return _curConfigData.GetValue("Options", "VerticalScroll", DefaultVerticalScroll);
case ConfigSettings.HighContrast:
return _curConfigData.GetValue("Options", "HighContrast", DefaultHighCon);
case ConfigSettings.FirstTime:
return _curConfigData.GetValue("Game", "FirstTime", DefaultFirstTime);
case ConfigSettings.HasWon:
return _curConfigData.GetValue("Game", "HasWon", DefaultHasWon);
default:
GD.PushError("Invalid config setting passed. " + setting);
return float.MinValue;
Expand Down Expand Up @@ -399,110 +383,4 @@ public static void ClearConfig()
InitConfig();
}
#endregion

#region Save

private const string UserSavePath = "user://MidnighRiff.save";

public class SaveFile
{
public ulong RngSeed { get; init; }
public ulong RngState { get; init; }
public int LastRoomIdx { get; init; }
public int Area { get; init; }

public int Money { get; init; }
public int[] NoteIds { get; init; }
public int[] RelicIds { get; init; }
public int[] BattlePool { get; init; }
public int[] EventPool { get; init; }
public int PlayerHealth { get; init; }
public int Shortcuts { get; init; }
public int PlayerMaxCombo { get; init; }

public SaveFile(
ulong rngSeed,
ulong rngState,
int lastRoomIdx,
int[] noteIds,
int[] relicIds,
int[] battlePool,
int[] eventPool,
int playerHealth,
int area,
int money,
int shortcuts,
int playerMaxCombo
)
{
RngSeed = rngSeed;
RngState = rngState;
LastRoomIdx = lastRoomIdx;
NoteIds = noteIds;
RelicIds = relicIds;
BattlePool = battlePool ?? [];
EventPool = eventPool ?? [];
PlayerHealth = playerHealth;
Area = area;
Money = money;
Shortcuts = shortcuts;
PlayerMaxCombo = playerMaxCombo;
}
}

public static void SaveGame()
{
int[] relicIds = StageProducer.PlayerStats.CurRelics.Select(r => r.Id).ToArray();
int[] noteIds = StageProducer.PlayerStats.CurNotes.Select(r => r.Id).ToArray();
SaveFile sv = new SaveFile(
StageProducer.GlobalRng.Seed,
StageProducer.GlobalRng.State,
StageProducer.CurRoom,
noteIds,
relicIds,
StageProducer.BattlePool?.ToArray(),
EventScene.EventPool?.ToArray(),
StageProducer.PlayerStats.CurrentHealth,
StageProducer.CurLevel.Id,
StageProducer.PlayerStats.Money,
StageProducer.PlayerStats.Shortcuts,
StageProducer.PlayerStats.MaxComboBar
);
string json = JsonSerializer.Serialize(sv);

FileAccess file = FileAccess.Open(UserSavePath, FileAccess.ModeFlags.Write);

file.StoreLine(json);
file.Close();
}

/**
* <remarks>Returns null if invalid save or save 404's.</remarks>
*/
public static SaveFile LoadGame()
{
if (!FileAccess.FileExists(UserSavePath))
return null;
FileAccess file = FileAccess.Open(UserSavePath, FileAccess.ModeFlags.Read);
string json = file.GetAsText();

file.Close();
SaveFile sv;
try
{
sv = JsonSerializer.Deserialize<SaveFile>(json);
}
catch (JsonException)
{
GD.PushWarning("Cannot deserialize save file, returning null.");
return null;
}
return sv;
}

public static void ClearSave()
{
DirAccess.RemoveAbsolute(UserSavePath);
}
#endregion
}
1 change: 1 addition & 0 deletions Globals/Configkeeper.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://bbkyrplc17j0w
Loading