diff --git a/Fushigi/course/CourseArea.cs b/Fushigi/course/CourseArea.cs index cd5284d1..74aeccd5 100644 --- a/Fushigi/course/CourseArea.cs +++ b/Fushigi/course/CourseArea.cs @@ -30,8 +30,10 @@ public void Load() mAreaParams = new AreaParam(new Byml.Byml(new MemoryStream(File.ReadAllBytes(areaParamPath)))); //Load env settings - if (mAreaParams.EnvPaletteSetting != null) + if (mAreaParams.EnvPaletteSetting != null && mAreaParams.EnvPaletteSetting.InitPaletteBaseName != null) mInitEnvPalette = new EnvPalette(mAreaParams.EnvPaletteSetting.InitPaletteBaseName); + else + mInitEnvPalette = new EnvPalette(); string levelPath = FileUtil.FindContentPath( diff --git a/Fushigi/env/EnvPalette.cs b/Fushigi/env/EnvPalette.cs index c9965d3f..734f0369 100644 --- a/Fushigi/env/EnvPalette.cs +++ b/Fushigi/env/EnvPalette.cs @@ -12,6 +12,7 @@ using Fushigi.gl; using ImGuiNET; using static Fushigi.gl.Bfres.GsysEnvironment; +using System.Diagnostics; namespace Fushigi.env { @@ -39,6 +40,11 @@ public class EnvPalette : BymlObject public bool IsApplyEnvColor { get; set; } public bool IsApplyObjLight { get; set; } + public EnvPalette() + { + + } + public EnvPalette(string name) { Load(name); @@ -51,7 +57,10 @@ public void Load(string name) string local_path = Path.Combine("Gyml", "Gfx", "EnvPaletteParam", $"{name}.game__gfx__EnvPaletteParam.bgyml"); string file_path = FileUtil.FindContentPath(local_path); if (!File.Exists(file_path)) + { + Debug.Fail(null); return; + } var byml = new Byml.Byml(new MemoryStream(File.ReadAllBytes(file_path))); this.Load((BymlHashTable)byml.Root); @@ -256,11 +265,11 @@ public class EnvColorList public class EnvFogList { - public EnvFog Cloud { get; set; } - public EnvFog CloudWorld { get; set; } - public EnvFog Main { get; set; } - public EnvFog MainWorld { get; set; } - public EnvFog Option { get; set; } + public EnvFog Cloud { get; set; } = new EnvFog(); + public EnvFog CloudWorld { get; set; } = new EnvFog(); + public EnvFog Main { get; set; } = new EnvFog(); + public EnvFog MainWorld { get; set; } = new EnvFog(); + public EnvFog Option { get; set; } = new EnvFog(); } public class EnvFog @@ -351,6 +360,21 @@ public byte[] ComputeRgba8(int width = 64) public float[] ComputeRgba32(int width = 64) { + if (Curve == null) // Always means constant? + { + var color = ColorEnd.ToVector4(); + var tmp = new float[width * 4]; + for (int i = 0; i < width * 4; i += 4) + { + tmp[i + 0] = Math.Clamp(color.X, 0, 1f); + tmp[i + 1] = Math.Clamp(color.Y, 0, 1f); + tmp[i + 2] = Math.Clamp(color.Z, 0, 1f); + tmp[i + 3] = Math.Clamp(color.W, 0, 1f); + } + + return tmp; + } + var type = Curve.GetCurveType(); var data = Curve.Data.ToArray(); diff --git a/Fushigi/ui/widgets/LevelViewport.cs b/Fushigi/ui/widgets/LevelViewport.cs index fd68d32d..fe604c08 100644 --- a/Fushigi/ui/widgets/LevelViewport.cs +++ b/Fushigi/ui/widgets/LevelViewport.cs @@ -894,9 +894,12 @@ Vector2[] GetPoints() calc = actor.mActorPack.ShapeParams.mPoly[0].mCalc; } - min = calc.mMin; - max = calc.mMax; - center = calc.mCenter; + if (calc != null) + { + min = calc.mMin; + max = calc.mMax; + center = calc.mCenter; + } } string layer = actor.mLayer;