Skip to content

Commit

Permalink
make sure ALL courses load
Browse files Browse the repository at this point in the history
  • Loading branch information
jupahe64 committed Dec 19, 2023
1 parent d2813a0 commit 9773f80
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Fushigi/course/CourseArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
34 changes: 29 additions & 5 deletions Fushigi/env/EnvPalette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Fushigi.gl;
using ImGuiNET;
using static Fushigi.gl.Bfres.GsysEnvironment;
using System.Diagnostics;

namespace Fushigi.env
{
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down
9 changes: 6 additions & 3 deletions Fushigi/ui/widgets/LevelViewport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9773f80

Please sign in to comment.