Skip to content
Draft
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
5 changes: 5 additions & 0 deletions Celeste.Mod.mm/Content/Dialog/English.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
# Mod Options
MODOPTIONS_TITLE= EVEREST
MODOPTIONS_NEEDSRELAUNCH= Requires a restart to take effect
MODOPTIONS_DEFAULT= DEFAULT
MODOPTIONS_ISEXPERIMENTAL= Experimental (default OFF), please report issues if turning ON!

# Core Module Options
MODOPTIONS_COREMODULE_UPDATE= Update Everest to ((version))
Expand Down Expand Up @@ -164,10 +166,13 @@

MODOPTIONS_COREMODULE_SEARCHBOX_PLACEHOLDER= Press 'Tab' or 'Enter' to scroll to the next match

MODOPTIONS_COREMODULE_FASTLEVELLOADING= Fast Level Loading

MODOPTIONS_VANILLATRISTATE_NEVER= OFF
MODOPTIONS_VANILLATRISTATE_EVEREST= EVEREST
MODOPTIONS_VANILLATRISTATE_ALWAYS= ALWAYS


# Sound Test
SOUNDTEST_TITLE= SOUND TEST
SOUNDTEST_AUDIOPARAMS_OPEN_1= Press
Expand Down
5 changes: 5 additions & 0 deletions Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public bool LazyLoading {
[SettingIgnore]
public int LogHistoryCountToKeep { get; set; } = 3;

[SettingInGame(false)]
[SettingExperimental]
[SettingNeedsRelaunch]
public bool? FastLevelLoading { get; set; } = null;

[SettingNeedsRelaunch]
[SettingInGame(false)]
[SettingIgnore] // TODO: Show as advanced setting.
Expand Down
29 changes: 29 additions & 0 deletions Celeste.Mod.mm/Mod/Everest/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,35 @@ public static TextMenu.Item NeedsRelaunch(this TextMenu.Item option, patch_TextM
return option;
}

/// <summary>
/// Add an Enter and Leave handler, notifying the user that the current setting is experimental.
/// </summary>
/// <param name="option">The input TextMenu.Item option.</param>
/// <param name="containingMenu">The menu containing the TextMenu.Item option.</param>
/// <param name="isExperimental">This method does nothing if this is set to false.</param>
/// <returns>The passed option.</returns>
public static TextMenu.Item IsExperimental(this TextMenu.Item option, patch_TextMenu containingMenu, bool isExperimental = true) {
if (!isExperimental)
return option;

// build the text menu entry
TextMenuExt.EaseInSubHeaderExt isExperimentalText = new TextMenuExt.EaseInSubHeaderExt(Dialog.Clean("MODOPTIONS_ISEXPERIMENTAL"), false, containingMenu) {
TextColor = Color.OrangeRed,
HeightExtra = 0f
};

List<TextMenu.Item> items = containingMenu.Items;
if (items.Contains(option)) {
// insert the text after the option
containingMenu.Insert(items.IndexOf(option) + 1, isExperimentalText);
}

option.OnEnter += delegate { isExperimentalText.FadeVisible = true; };
option.OnLeave += delegate { isExperimentalText.FadeVisible = false; };

return option;
}

/// <summary>
/// Add an Enter and Leave handler, displaying a description if selected.
/// </summary>
Expand Down
22 changes: 22 additions & 0 deletions Celeste.Mod.mm/Mod/Module/EverestModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ public virtual void CreateModMenuSection(patch_TextMenu menu, bool inGame, Event
SettingInGameAttribute attribInGame;
SettingRangeAttribute attribRange;
SettingNumberInputAttribute attribNumber;
SettingExperimentalAttribute attribExperimental;

// If the settings type has got the InGame attrib, only show it in the matching situation.
if ((attribInGame = type.GetCustomAttribute<SettingInGameAttribute>()) != null &&
Expand Down Expand Up @@ -794,6 +795,23 @@ TextMenu.Item CreateItem(PropertyInfo prop, string name = null, object settingsO
minValueLength
);
});
} else if (propType == typeof(bool?) && (attribExperimental = prop.GetCustomAttribute<SettingExperimentalAttribute>()) != null) {
Dictionary<string, bool?> preferences = new() {
{"MODOPTIONS_DEFAULT", null},
{"OPTIONS_ON", true},
{"OPTIONS_OFF", false},
};

List<string> dialogKeys = preferences.Keys.ToList();
List<bool?> dialogValues = preferences.Values.ToList();

item = new TextMenu.Slider(
label: name,
values: index => Dialog.Clean(dialogKeys[index]),
min: 0,
max: preferences.Count - 1,
value: preferences.Values.ToList().IndexOf((bool?)prop.GetValue(settingsObject))
).Change(value => prop.SetValue(settingsObject, dialogValues[value]));
}

if (item is not null)
Expand Down Expand Up @@ -879,6 +897,10 @@ TextMenu.Item CreateItem(PropertyInfo prop, string name = null, object settingsO
if (prop.GetCustomAttribute<SettingNeedsRelaunchAttribute>() != null)
item.NeedsRelaunch(menu);

if (prop.GetCustomAttribute<SettingExperimentalAttribute>() != null)
item.IsExperimental(menu);


string description = prop.GetCustomAttribute<SettingSubTextAttribute>()?.Description;
if (description != null)
item.AddDescription(menu, description.DialogCleanOrNull() ?? description);
Expand Down
9 changes: 9 additions & 0 deletions Celeste.Mod.mm/Mod/Module/EverestModuleSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ public class SettingIgnoreAttribute : Attribute {
public SettingIgnoreAttribute() {
}
}

/// <summary>
/// Experimental setting, only supported on bool? property type
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class SettingExperimentalAttribute : Attribute {
public SettingExperimentalAttribute() {
}
}

/// <summary>
/// Insert a subheader before the setting.
Expand Down
20 changes: 16 additions & 4 deletions Celeste.Mod.mm/Patches/AreaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value

using Celeste.Mod;
using Celeste.Mod.Core;
using Celeste.Mod.Meta;
using Microsoft.Xna.Framework;
using Monocle;
Expand All @@ -10,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Celeste {
public class patch_AreaData : AreaData {
Expand Down Expand Up @@ -365,7 +367,7 @@ public static patch_AreaData Get(string sid) {
}
}

for (int i = 0; i < Areas.Count; i++) {
static void ProcessMapData(int i) {
patch_AreaData area = Areas[i];
area.ID = i;

Expand All @@ -377,8 +379,9 @@ public static patch_AreaData Get(string sid) {
break;
}
Array.Resize(ref area.Mode, modei);

Logger.Verbose("AreaData", string.Format("{0}: {1} - {2} sides", i, area.SID, area.Mode.Length));
// Do not clutter the log if Fast Level Loading is disabled
LogLevel level = (CoreModule.Settings.FastLevelLoading ?? false) ? LogLevel.Info : LogLevel.Verbose;
Logger.Log(level, "AreaData", $"{i}: {area.SID} - {area.Mode.Length} sides");

// Update old MapData areas and load any new areas.

Expand All @@ -389,7 +392,7 @@ public static patch_AreaData Get(string sid) {
area.Mode[0].MapData = new patch_MapData(area.ToKey());

if (area.IsInterludeUnsafe())
continue;
return;

// A and (some) B sides have PoemIDs. Can be overridden via empty PoemID.
if (area.Mode[0].PoemID == null)
Expand All @@ -411,6 +414,15 @@ public static patch_AreaData Get(string sid) {
}
}

if (CoreModule.Settings.FastLevelLoading ?? false) {
Logger.Info("AreaData", $"Loading map data in parallel");
Parallel.For(0, Areas.Count, ProcessMapData);
} else {
for (int i = 0; i < Areas.Count; i++) {
ProcessMapData(i);
}
}

// Load custom mountains
// This needs to be done after areas are loaded because it depends on the MapMeta
MTNExt.LoadMod();
Expand Down
2 changes: 1 addition & 1 deletion Celeste.Mod.mm/Patches/BinaryPacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Celeste {
static class patch_BinaryPacker {
[MonoModIgnore]
[ThreadStatic]
private static string[] stringLookup;

[MonoModIgnore] // We don't want to change anything about the method...
Expand Down
6 changes: 5 additions & 1 deletion Celeste.Mod.mm/Patches/MapData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
namespace Celeste {
public class patch_MapData : MapData {

private static readonly object locker = new object();

public bool DetectedCassette;
public int DetectedStrawberriesIncludingUntracked;
public List<EntityData> DashlessGoldenberries = new List<EntityData>();
Expand Down Expand Up @@ -177,7 +179,9 @@ private BinaryPacker.Element Process(BinaryPacker.Element root) {
if (root.Children.Find(element => element.Name == "meta") is BinaryPacker.Element meta)
ProcessMeta(meta);

new MapDataFixup(this).Process(root);
lock (locker) {
new MapDataFixup(this).Process(root);
}

return root;
}
Expand Down