diff --git a/Fushigi/course/CourseActor.cs b/Fushigi/course/CourseActor.cs index 69779402..9d55bffd 100644 --- a/Fushigi/course/CourseActor.cs +++ b/Fushigi/course/CourseActor.cs @@ -13,6 +13,11 @@ namespace Fushigi.course { + public enum WonderViewType{ + Normal, + WonderOff, + WonderOnly + } public class CourseActor { public CourseActor(BymlHashTable actorNode) @@ -222,6 +227,8 @@ public BymlHashTable BuildNode(CourseLinkHolder linkHolder) public string mPackName; public string mName; public string mLayer; + public WonderViewType mWonderView = WonderViewType.Normal; + public bool wonderVisible = true; public System.Numerics.Vector3 mStartingTrans; public System.Numerics.Vector3 mTranslation; public System.Numerics.Vector3 mRotation; @@ -260,7 +267,7 @@ public CourseActor this[ulong hash] get { bool exists = TryGetActor(hash, out CourseActor? actor); - Debug.Assert(exists); + //Debug.Assert(exists); return actor!; } } diff --git a/Fushigi/env/EnvPalette.cs b/Fushigi/env/EnvPalette.cs index 00c6b1e8..3e4d43c7 100644 --- a/Fushigi/env/EnvPalette.cs +++ b/Fushigi/env/EnvPalette.cs @@ -58,7 +58,7 @@ public void Load(string name) string file_path = FileUtil.FindContentPath(local_path); if (!File.Exists(file_path)) { - Debug.Fail(null); + //Debug.Fail(null); return; } diff --git a/Fushigi/gl/Bfres/BfresRender.cs b/Fushigi/gl/Bfres/BfresRender.cs index cc34949a..dc5c5d92 100644 --- a/Fushigi/gl/Bfres/BfresRender.cs +++ b/Fushigi/gl/Bfres/BfresRender.cs @@ -93,7 +93,8 @@ internal void Render(GL gl, BfresRender render, Matrix4x4 transform, Camera came { foreach (var mesh in Meshes) { - mesh.LodMeshes[0].BoundingBox.Transform(transform); + var m = mesh.LodMeshes[0].BoundingBox; + m.Transform(transform); BoundingBox.Include(mesh.LodMeshes[0].BoundingBox); } diff --git a/Fushigi/gl/Bfres/TileBfresRenderer.cs b/Fushigi/gl/Bfres/TileBfresRenderer.cs index 1034b351..96ae9621 100644 --- a/Fushigi/gl/Bfres/TileBfresRenderer.cs +++ b/Fushigi/gl/Bfres/TileBfresRenderer.cs @@ -153,9 +153,9 @@ public void Load(CourseUnitHolder unitHolder) public void Render(GL gl, Camera camera) { + NoCollisionModel.Render(gl, camera); SolidModel.Render(gl, camera); SemisolidModel.Render(gl, camera); - NoCollisionModel.Render(gl, camera); BridgeModel.Render(gl, camera); } diff --git a/Fushigi/ui/CourseAreaEditContext.cs b/Fushigi/ui/CourseAreaEditContext.cs index 6ce74850..4813592c 100644 --- a/Fushigi/ui/CourseAreaEditContext.cs +++ b/Fushigi/ui/CourseAreaEditContext.cs @@ -68,15 +68,17 @@ public void AddLink(CourseLink link) LogAdding($": {link.mSource} -{link.mLinkName}-> {link.mDest}"); //Checks if the the source actor already has links - if(linkList.Any(x => x.mSource == link.mSource)){ + if (linkList.Any(x => x.mSource == link.mSource)){ //Looks through the source actor's links //Then looks through it's links of the same type (If it has any) //Placing the new link in the right spot + var index = linkList.FindLastIndex(x => x.mSource == link.mSource && + (!linkList.Any(y => x.mLinkName == link.mLinkName) || + x.mLinkName == link.mLinkName)); + CommitAction( - area.mLinkHolder.mLinks.RevertableInsert(link, - linkList.FindLastIndex(x => x.mSource == link.mSource - && ((!linkList.Any(y => y.mLinkName == link.mLinkName)) || x.mLinkName == link.mLinkName))+1, + area.mLinkHolder.mLinks.RevertableInsert(link, index+1, $"{IconUtil.ICON_PLUS_CIRCLE} Add {link.mLinkName} Link") ); return; diff --git a/Fushigi/ui/widgets/CourseScene.cs b/Fushigi/ui/widgets/CourseScene.cs index 27da7171..59c702eb 100644 --- a/Fushigi/ui/widgets/CourseScene.cs +++ b/Fushigi/ui/widgets/CourseScene.cs @@ -48,6 +48,11 @@ class CourseScene CourseLink? mSelectedGlobalLink = null; + string[] viewMode = [ + "View All Actors", + "View Normal Actors", + "View Wonder Actors"]; + string[] linkTypes = [ "BasicSignal", "Create", @@ -242,8 +247,6 @@ public void DrawUI(GL gl, double deltaSeconds) ImGui.SameLine(); - ImGui.SameLine(); - string current_palette = area.mInitEnvPalette == null ? "" : area.mInitEnvPalette.Name; void SelectPalette(string name, string palette) @@ -262,8 +265,8 @@ void SelectPalette(string name, string palette) ImGui.SetItemDefaultFocus(); } - ImGui.PushItemWidth(30); - if (ImGui.BeginCombo($"##EnvPalette", $"{IconUtil.ICON_PALETTE}", ImGuiComboFlags.NoArrowButton)) + var flags = ImGuiComboFlags.NoArrowButton | ImGuiComboFlags.WidthFitPreview; + if (ImGui.BeginCombo($"##EnvPalette", $"{IconUtil.ICON_PALETTE}", flags)) { SelectPalette($"Default Palette", area.mAreaParams.EnvPaletteSetting.InitPaletteBaseName); @@ -284,7 +287,6 @@ void SelectPalette(string name, string palette) } ImGui.EndCombo(); } - ImGui.PopItemWidth(); ImGui.SameLine(); @@ -294,6 +296,18 @@ void SelectPalette(string name, string palette) UserSettings.SetGameShaders(useGameShaders); } + ImGui.SameLine(); + + if (ImGui.BeginCombo("Wonder View", viewMode[(int)activeViewport.WonderViewMode], ImGuiComboFlags.WidthFitPreview)) + { + for (int n = 0; n < 3; n++) + { + if (ImGui.Selectable(viewMode[n])) + viewport.WonderViewMode = (WonderViewType)n; + } + ImGui.EndCombo(); + } + ImGui.PopStyleColor(1); ImGui.EndChild(); @@ -498,8 +512,6 @@ private void LocalLinksPanel() { ImGui.Begin("Local Links"); - ImGui.Checkbox("Wonder View", ref activeViewport.IsWonderView); - ImGui.Separator(); AreaLocalLinksView(selectedArea); @@ -1337,7 +1349,7 @@ BGUnitRailSceneObj GetRailSceneObj(object courseObject) if (ImGui.Selectable(name, editContext.IsSelected(unit))) { - editContext.DeselectAllOfType(); + editContext.DeselectAll(); editContext.Select(unit); } if (expanded) @@ -1573,7 +1585,8 @@ private void AreaLocalLinksView(CourseArea area) ImGui.EndChild(); } - private void RecursiveLinkFind(CourseArea area, CourseLinkHolder links, CourseAreaEditContext editContext, float em, IEnumerable linkList) + private void RecursiveLinkFind(CourseArea area, CourseLinkHolder links, + CourseAreaEditContext editContext, float em, IEnumerable linkList) { foreach (CourseActor actor in linkList) { @@ -1601,6 +1614,8 @@ private void RecursiveLinkFind(CourseArea area, CourseLinkHolder links, CourseAr if (!isVisible) ImGui.BeginDisabled(); + UpdateWonderVisibility(actor, links, area); + if (expanded) { foreach (var link in links.GetDestHashesFromSrc(actor.mHash)) @@ -1610,10 +1625,6 @@ private void RecursiveLinkFind(CourseArea area, CourseLinkHolder links, CourseAr { var reLinks = area.GetActors().Where(x => link.Value.Contains(x.mHash)); RecursiveLinkFind(area, links, editContext, em, reLinks); - // foreach (CourseActor linkActor in ) - // { - // - // } ImGui.TreePop(); } ImGui.PopID(); @@ -1670,6 +1681,34 @@ private void RecursiveLinkFind(CourseArea area, CourseLinkHolder links, CourseAr } } + private void UpdateWonderVisibility(CourseActor actor, CourseLinkHolder links, CourseArea area) + { + foreach (var link in links.GetDestHashesFromSrc(actor.mHash)) + { + var reLinks = area.GetActors().Where(x => link.Value.Contains(x.mHash)); + if (!link.Key.Contains("CreateRelative") && + (link.Key.Contains("Create") || + link.Key.Contains("PopUp") || + link.Key.Contains("Delete") || + link.Key.Contains("BasicSignal"))) + { + foreach (CourseActor linkActor in reLinks) + { + if ((actor.mPackName == "ObjectWonderTag" || actor.mWonderView == WonderViewType.WonderOnly) && + (!link.Key.Contains("BasicSignal") || (linkActor.mActorPack?.Category.Contains("Tag") ?? false))) + { + if (link.Key.Contains("Delete")) + linkActor.mWonderView = WonderViewType.WonderOff; + else + linkActor.mWonderView = WonderViewType.WonderOnly; + } + else + linkActor.mWonderView = WonderViewType.Normal; + } + } + } + } + private void UpdateAllLayerVisiblity() { foreach (string layer in mLayersVisibility.Keys) @@ -1950,7 +1989,7 @@ private void CourseMiniView() dl.AddRectFilled( MapPointPixelAligned(pos), MapPointPixelAligned(pos + Vector2.One), - 0xFF444444); + 0xFF666688); } } @@ -1961,7 +2000,6 @@ private void CourseMiniView() .SelectMany(x => x.mTileSubUnits) .OrderBy(x => x.mOrigin.Z); - var t = 0; foreach (var subUnit in foregroundSubUnits) { var type = foregroundTileUnits.First(x => x.mTileSubUnits.Contains(subUnit)).mModelType; @@ -2007,7 +2045,6 @@ private void CourseMiniView() } } - dl.AddRect(lvlRectTopLeft, lvlRectTopLeft + lvlRectSize, ImGui.ColorConvertFloat4ToU32(ImGui.GetStyle().Colors[(int)ImGuiCol.Text]),6,0,3); diff --git a/Fushigi/ui/widgets/LevelViewport.cs b/Fushigi/ui/widgets/LevelViewport.cs index 71a3b946..af80ad5b 100644 --- a/Fushigi/ui/widgets/LevelViewport.cs +++ b/Fushigi/ui/widgets/LevelViewport.cs @@ -36,7 +36,7 @@ public static void DefaultSelect(CourseAreaEditContext ctx, object selectable) { ctx.Select(selectable); } - else if(!ctx.IsSelected(selectable)) + else if(!ctx.IsSelected(selectable)) { ctx.WithSuspendUpdateDo(() => { @@ -82,13 +82,14 @@ internal class LevelViewport(CourseArea area, GL gl, CourseAreaScene areaScene) public bool IsViewportHovered; public bool IsViewportActive; - public bool IsWonderView; + public WonderViewType WonderViewMode = WonderViewType.Normal; public bool PlayAnimations = false; public bool ShowGrid = true; Vector2 mSize = Vector2.Zero; public ulong prevSelectVersion { get; private set; } = 0; + public bool dragRelease; private IDictionary? mLayersVisibility; Vector2 mTopLeft = Vector2.Zero; @@ -359,9 +360,14 @@ TileBfresRender CreateTileRendererForSkin(SkinDivision division, string skinName foreach (var actor in this.mArea.GetActors()) { - if (actor.mActorPack == null || mLayersVisibility.ContainsKey(actor.mLayer) && !mLayersVisibility[actor.mLayer]) - continue; + actor.wonderVisible = WonderViewMode == actor.mWonderView || + WonderViewMode == WonderViewType.Normal || + actor.mWonderView == WonderViewType.Normal; + if (actor.mActorPack == null || (mLayersVisibility.ContainsKey(actor.mLayer) && !mLayersVisibility[actor.mLayer]) || + !actor.wonderVisible) + continue; + RenderActor(actor, actor.mActorPack.ModelInfoRef); RenderActor(actor, actor.mActorPack.DrawArrayModelInfoRef); } @@ -808,22 +814,25 @@ void InteractionWithFocus(KeyboardModifier modifiers) } } - if(mHoveredObject != null && mHoveredObject is CourseActor && - ImGui.IsMouseReleased(ImGuiMouseButton.Left)) + if (ImGui.IsMouseDown(0)) + dragRelease = ImGui.IsMouseDragging(0); + + if(mHoveredObject != null && + mHoveredObject is CourseActor && + !dragRelease && + ImGui.IsMouseReleased(0)) { - if (ImGui.GetIO().MouseDragMaxDistanceSqr[0] <= ImGui.GetIO().MouseDragThreshold) + if(ImGui.IsKeyDown(ImGuiKey.LeftShift) && + prevSelectVersion == mEditContext.SelectionVersion) { - if(ImGui.IsKeyDown(ImGuiKey.LeftShift) - && prevSelectVersion == mEditContext.SelectionVersion) - { - mEditContext.Deselect(mHoveredObject!); - } - else if(!ImGui.IsKeyDown(ImGuiKey.LeftShift)) - { - mEditContext.DeselectAll(); - IViewportSelectable.DefaultSelect(mEditContext, mHoveredObject); - } + mEditContext.Deselect(mHoveredObject!); + } + else if(!ImGui.IsKeyDown(ImGuiKey.LeftShift)) + { + mEditContext.DeselectAll(); + IViewportSelectable.DefaultSelect(mEditContext, mHoveredObject); } + dragRelease = false; } if (ImGui.IsKeyPressed(ImGuiKey.Delete)) @@ -1107,7 +1116,7 @@ Vector2[] GetPoints() string layer = actor.mLayer; - if (mLayersVisibility!.TryGetValue(layer, out bool isVisible) && isVisible) + if (mLayersVisibility!.TryGetValue(layer, out bool isVisible) && isVisible && actor.wonderVisible) { Matrix4x4 transform = Matrix4x4.CreateScale(actor.mScale.X, actor.mScale.Y, actor.mScale.Z