Skip to content

Commit

Permalink
Fix bug that was caused by the context assuming there were links to d…
Browse files Browse the repository at this point in the history
…elete
  • Loading branch information
shibbo committed Nov 7, 2023
1 parent 3688114 commit 8853990
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 35 deletions.
5 changes: 5 additions & 0 deletions Fushigi/course/CourseLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public void DeleteLinkWithDest(ulong hash)
}
}

if (idx == -1)
{
return;
}

mLinks.RemoveAt(idx);
}

Expand Down
44 changes: 9 additions & 35 deletions Fushigi/ui/widgets/CourseScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ private void LinkDeletionCheck()
}
}

if (msgStr == "")
{
activeViewport.mEditorState = LevelViewport.EditorState.DeletingActor;
return;
}

bool status = ImGui.Begin("Link Warning");
ImGui.Text($"The actor you are about to delete is a destination link for the following actors.\n {msgStr} Do you wish to continue?");

Expand All @@ -286,40 +292,6 @@ private void LinkDeletionCheck()
}
}

private void CourseErrorList()
{
bool status = ImGui.Begin("Course Saving Errors");
ImGui.Text($"Error(s) occured in: {mErroringArea}");
CourseArea? area = course.GetArea(mErroringArea);

List<int> badLinks = area.mLinkHolder.DoSanityCheck(area.mActorHolder);

if (badLinks.Count > 0)
{
for (int i = 0; i < badLinks.Count; i++)
{
ImGui.Text($"Link at idx {badLinks[i]} points to an actor that doesn't exist.");
ImGui.NewLine();
CourseLink link = area.mLinkHolder.GetLinks()[badLinks[i]];
CourseActor src = area.mActorHolder[link.GetSrcHash()];
ImGui.Text($"Source actor: {src.mActorName} [{src.mName}]");
ImGui.NewLine();
}
}

List<int> badActors = area.mGroups.DoSanityCheck(area.mActorHolder);

if (badActors.Count > 0)
{

}

if (status)
{
ImGui.End();
}
}

private void ActorsPanel()
{
ImGui.Begin("Actors");
Expand All @@ -329,9 +301,11 @@ private void ActorsPanel()
mShowAddActor = true;
}

ImGui.SameLine();

if (ImGui.Button("Delete Actor"))
{
activeViewport.mEditorState = LevelViewport.EditorState.DeletingActor;
activeViewport.mEditorState = LevelViewport.EditorState.DeleteActorLinkCheck;
}

// actors are in an array
Expand Down
5 changes: 5 additions & 0 deletions Fushigi/ui/widgets/LevelViewport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ public void Draw(Vector2 size, IDictionary<string, bool> layersVisibility)
}
else if (isFocused && mEditorState == EditorState.DeletingActor)
{
if (!isFocused)
{
ImGui.SetWindowFocus();
}

if (mEditContext.IsAnySelected<CourseActor>())
{
mEditContext.DeleteSelectedActors();
Expand Down

0 comments on commit 8853990

Please sign in to comment.