diff --git a/Fushigi/course/CourseActor.cs b/Fushigi/course/CourseActor.cs index 9d55bff..e4facfa 100644 --- a/Fushigi/course/CourseActor.cs +++ b/Fushigi/course/CourseActor.cs @@ -284,7 +284,8 @@ public BymlArrayNode SerializeToArray(CourseLinkHolder linkHolder) return node; } - public List mActors = new List(); + public List mActors = []; + public List mSortedActors = []; } public class CourseActorRender //This can be overridden per actor for individual behavior diff --git a/Fushigi/course/CourseArea.cs b/Fushigi/course/CourseArea.cs index 74aeccd..6f9e7b1 100644 --- a/Fushigi/course/CourseArea.cs +++ b/Fushigi/course/CourseArea.cs @@ -159,6 +159,16 @@ public IReadOnlyList GetActors() return mActorHolder.mActors; } + public IReadOnlyList GetSortedActors() + { + if (!mActorHolder.mActors.TrueForAll(mActorHolder.mSortedActors.Contains)) + { + mActorHolder.mSortedActors = new List(mActorHolder.mActors); + mActorHolder.mSortedActors.Sort((x, y) => x.mTranslation.Z.CompareTo(y.mTranslation.Z)); + } + return mActorHolder.mSortedActors; + } + public string mAreaName; public uint mRootHash; string mStageParams; diff --git a/Fushigi/course/CourseRail.cs b/Fushigi/course/CourseRail.cs index 936c5fa..0762cfd 100644 --- a/Fushigi/course/CourseRail.cs +++ b/Fushigi/course/CourseRail.cs @@ -18,12 +18,30 @@ namespace Fushigi.course { public class CourseRail { - public CourseRail(uint areaHash) + public CourseRail(uint areaHash, string type = "Default") { + mType = type; mHash = RandomUtil.GetRandom(); mAreaHash = areaHash; - mRailParam = "Work/Gyml/Rail/RailParam/Default.game__rail__RailParam.gyml"; + mRailParam = "Work/Gyml/Rail/RailParam/"+type+".game__rail__RailParam.gyml"; mIsClosed = false; + var railParams = ParamDB.GetRailComponent(mType); + var railParent = ParamDB.GetRailComponentParent(railParams); + var comp = ParamDB.GetRailComponentParams(railParams); + if (railParent != "null") + { + var parentComp = ParamDB.GetRailComponentParams(railParent); + foreach (var component in parentComp) + { + comp.TryAdd(component.Key, component.Value); + } + } + + foreach (string component in comp.Keys) + { + var c = comp[component]; + mParameters.Add(component, c.InitValue); + } } public CourseRail(BymlHashTable node) @@ -33,8 +51,8 @@ public CourseRail(BymlHashTable node) mHash = BymlUtil.GetNodeData(node["Hash"]); mIsClosed = BymlUtil.GetNodeData(node["IsClosed"]); - string pointParam = Path.GetFileNameWithoutExtension(BymlUtil.GetNodeData(node["Gyaml"])).Split(".game")[0]; - var railParams = ParamDB.GetRailComponent(pointParam); + mType = Path.GetFileNameWithoutExtension(BymlUtil.GetNodeData(node["Gyaml"])).Split(".game")[0]; + var railParams = ParamDB.GetRailComponent(mType); var railParent = ParamDB.GetRailComponentParent(railParams); var comp = ParamDB.GetRailComponentParams(railParams); if (railParent != "null") @@ -76,7 +94,7 @@ public CourseRail(BymlHashTable node) foreach(BymlHashTable rail in railArray.Array) { - mPoints.Add(new CourseRailPoint(rail, pointParam)); + mPoints.Add(new CourseRailPoint(rail, mType)); } } @@ -131,6 +149,7 @@ public CourseRailPoint this[ulong hash] public uint mAreaHash; public string mRailParam; public ulong mHash; + public string mType; public bool mIsClosed; public List mPoints = new(); public Dictionary mParameters = new(); diff --git a/Fushigi/ui/widgets/CourseScene.cs b/Fushigi/ui/widgets/CourseScene.cs index 59c22c1..a206dc4 100644 --- a/Fushigi/ui/widgets/CourseScene.cs +++ b/Fushigi/ui/widgets/CourseScene.cs @@ -105,7 +105,19 @@ class CourseScene "DvFar9", "DvFar10" ]; - public static Regex NumberRegex = new(@"\d+"); + + public static readonly string[] RailTypes = [ + "Default", + "NextGoTo", + "BadgeChallenge", + "CRing", + "Scroll", + "SectionFrame", + "ShabonMove", + "SwitchON", + "SwitchOFF", + ]; + public static readonly Regex NumberRegex = new(@"\d+"); // This code sorts the layer order on the layer panel. // You can look through it before deciding if it's optimized enough to include. @@ -1146,7 +1158,7 @@ void ProcessRail(BGUnitRail rail) else if (editContext.IsSingleObjectSelected(out CourseRail? mSelectedRail)) { ImGui.AlignTextToFramePadding(); - ImGui.Text($"Selected Rail"); + ImGui.Text($"Selected {mSelectedRail.mType} Rail"); ImGui.NewLine(); ImGui.Separator(); @@ -1624,14 +1636,27 @@ void SelectRail() removed_tile_units.Clear(); } } - - private void CourseRailsView(CourseRailHolder railHolder) + private async void CourseRailsView(CourseRailHolder railHolder) { var editContext = areaScenes[selectedArea].EditContext; - if (ImGui.Button("Add Rail")) + ImGui.Text("Select a Rail"); + ImGui.Text("Alt + Left Click to add point"); + ImGui.Text("Double click to add/remove a curve point"); + ImGui.Text("Delete to remove point"); + + ImGui.SetNextWindowSize(ImGui.GetContentRegionAvail()); + if (ImGui.BeginCombo("##Add Rail", "Add Rail")) { - railHolder.mRails.Add(new CourseRail(this.selectedArea.mRootHash)); + foreach (string type in RailTypes) + { + ImGui.Selectable(type); + + if (ImGui.IsItemHovered() && ImGui.IsMouseClicked(0)) + railHolder.mRails.Add(new CourseRail(this.selectedArea.mRootHash, type)); + } + + ImGui.EndCombo(); } ImGui.SameLine(); if (ImGui.Button("Remove Rail")) diff --git a/Fushigi/ui/widgets/LevelViewport.cs b/Fushigi/ui/widgets/LevelViewport.cs index 5007e68..4556f05 100644 --- a/Fushigi/ui/widgets/LevelViewport.cs +++ b/Fushigi/ui/widgets/LevelViewport.cs @@ -364,7 +364,7 @@ TileBfresRender CreateTileRendererForSkin(SkinDivision division, string skinName // Actors are listed in the order they were pulled from the yaml. // So they are ordered by depth for rendering. - foreach (var actor in this.mArea.GetActors().OrderBy(x => x.mTranslation.Z)) + foreach (var actor in this.mArea.GetSortedActors()) { actor.wonderVisible = WonderViewMode == actor.mWonderView || WonderViewMode == WonderViewType.Normal ||