rename event

This commit is contained in:
ikpil 2023-07-02 15:53:32 +09:00
parent 9264cf6446
commit 3b9234e83d
7 changed files with 73 additions and 55 deletions

View File

@ -1,6 +1,6 @@
namespace DotRecast.Recast.Demo.Messages;
public class SourceGeomFileSelectedEvent : IRecastDemoMessage
public class GeomLoadBeganEvent : IRecastDemoMessage
{
public required string FilePath { get; init; }
}

View File

@ -0,0 +1,6 @@
namespace DotRecast.Recast.Demo.Messages;
public class NavMeshBuildBeganEvent : IRecastDemoMessage
{
}

View File

@ -1,6 +0,0 @@
namespace DotRecast.Recast.Demo.Messages;
public class NavMeshBuildEvent : IRecastDemoMessage
{
}

View File

@ -0,0 +1,6 @@
namespace DotRecast.Recast.Demo.Messages;
public class NavMeshLoadBeganEvent : IRecastDemoMessage
{
public required string FilePath { get; init; }
}

View File

@ -0,0 +1,6 @@
namespace DotRecast.Recast.Demo.Messages;
public class NavMeshSaveBeganEvent : IRecastDemoMessage
{
}

View File

@ -493,31 +493,6 @@ public class RecastDemo : IRecastDemoChannel
simIter++;
}
if (settingsView.IsNavMeshInputTrigerred())
{
// try (MemoryStack stack = StackPush()) {
// PointerBuffer aFilterPatterns = stack.MallocPointer(4);
// aFilterPatterns.Put(stack.UTF8("*.bin"));
// aFilterPatterns.Put(stack.UTF8("*.zip"));
// aFilterPatterns.Put(stack.UTF8("*.bytes"));
// aFilterPatterns.Put(stack.UTF8("*.navmesh"));
// aFilterPatterns.Flip();
// string filename = TinyFileDialogs.Tinyfd_openFileDialog("Open Nav Mesh File", "", aFilterPatterns,
// "Nav Mesh File", false);
// if (filename != null) {
// File file = new File(filename);
// if (file.Exists()) {
// try {
// LoadNavMesh(file, filename);
// geom = null;
// } catch (Exception e) {
// Console.WriteLine(e);
// }
// }
// }
// }
}
if (!_mouseOverMenu)
{
GLU.GlhUnProjectf(mousePos[0], viewport[3] - 1 - mousePos[1], 0.0f, modelviewMatrix, projectionMatrix, viewport, ref rayStart);
@ -700,17 +675,25 @@ public class RecastDemo : IRecastDemoChannel
private void OnMessage(IRecastDemoMessage message)
{
if (message is SourceGeomFileSelectedEvent args)
if (message is GeomLoadBeganEvent args)
{
OnSourceGeomFileSelected(args);
OnGeomLoadBegan(args);
}
else if (message is NavMeshBuildEvent args2)
else if (message is NavMeshBuildBeganEvent args2)
{
OnNavMeshBuild(args2);
OnNavMeshBuildBegan(args2);
}
else if (message is NavMeshSaveBeganEvent args3)
{
OnNavMeshSaveBegan(args3);
}
else if (message is NavMeshLoadBeganEvent args4)
{
OnNavMeshLoadBegan(args4);
}
}
private void OnSourceGeomFileSelected(SourceGeomFileSelectedEvent args)
private void OnGeomLoadBegan(GeomLoadBeganEvent args)
{
var bytes = Loader.ToBytes(args.FilePath);
var geom = LoadInputMesh(bytes);
@ -718,7 +701,7 @@ public class RecastDemo : IRecastDemoChannel
sample.Update(geom, ImmutableArray<RecastBuilderResult>.Empty, null);
}
private void OnNavMeshBuild(NavMeshBuildEvent args)
private void OnNavMeshBuildBegan(NavMeshBuildBeganEvent args)
{
if (null == sample.GetInputGeom())
{
@ -818,4 +801,34 @@ public class RecastDemo : IRecastDemoChannel
Logger.Information($"{key}: {millis} ms");
}
}
private void OnNavMeshSaveBegan(NavMeshSaveBeganEvent args)
{
}
private void OnNavMeshLoadBegan(NavMeshLoadBeganEvent args)
{
// try (MemoryStack stack = StackPush()) {
// PointerBuffer aFilterPatterns = stack.MallocPointer(4);
// aFilterPatterns.Put(stack.UTF8("*.bin"));
// aFilterPatterns.Put(stack.UTF8("*.zip"));
// aFilterPatterns.Put(stack.UTF8("*.bytes"));
// aFilterPatterns.Put(stack.UTF8("*.navmesh"));
// aFilterPatterns.Flip();
// string filename = TinyFileDialogs.Tinyfd_openFileDialog("Open Nav Mesh File", "", aFilterPatterns,
// "Nav Mesh File", false);
// if (filename != null) {
// File file = new File(filename);
// if (file.Exists()) {
// try {
// LoadNavMesh(file, filename);
// geom = null;
// } catch (Exception e) {
// Console.WriteLine(e);
// }
// }
// }
// }
}
}

View File

@ -44,8 +44,6 @@ public class RcSettingsView : IRcView
private int drawMode = DrawMode.DRAWMODE_NAVMESH.Idx;
private bool navMeshInputTrigerred;
private bool _isHovered;
public bool IsHovered() => _isHovered;
@ -76,7 +74,7 @@ public class RcSettingsView : IRcView
var settings = _sample.GetSettings();
ImGui.Begin("Properties");
// size reset
var size = ImGui.GetItemRectSize();
if (32 >= size.X && 32 >= size.Y)
@ -104,7 +102,7 @@ public class RcSettingsView : IRcView
var picker = ImFilePicker.GetFilePicker(strLoadSourceGeom, Path.Combine(Environment.CurrentDirectory), ".obj");
if (picker.Draw())
{
_channel.SendMessage(new SourceGeomFileSelectedEvent()
_channel.SendMessage(new GeomLoadBeganEvent()
{
FilePath = picker.SelectedFile,
});
@ -192,9 +190,9 @@ public class RcSettingsView : IRcView
ImGui.Separator();
if (ImGui.Button("Build NavMesh"))
{
_channel.SendMessage(new NavMeshBuildEvent());
_channel.SendMessage(new NavMeshBuildBeganEvent());
}
{
const string strLoadNavMesh = "Load NavMesh";
if (ImGui.Button(strLoadNavMesh))
@ -208,7 +206,10 @@ public class RcSettingsView : IRcView
var picker = ImFilePicker.GetFilePicker(strLoadNavMesh, Path.Combine(Environment.CurrentDirectory));
if (picker.Draw())
{
Logger.Information(picker.SelectedFile);
_channel.SendMessage(new NavMeshLoadBeganEvent()
{
FilePath = picker.SelectedFile,
});
ImFilePicker.RemoveFilePicker(strLoadNavMesh);
}
@ -216,12 +217,9 @@ public class RcSettingsView : IRcView
}
}
if (ImGui.Button("Save NavMesh"))
{
const string strSaveNavMesh = "Save NavMesh";
if (ImGui.Button(strSaveNavMesh))
{
}
_channel.SendMessage(new NavMeshSaveBeganEvent());
}
@ -267,9 +265,4 @@ public class RcSettingsView : IRcView
{
this.maxPolys = maxPolys;
}
public bool IsNavMeshInputTrigerred()
{
return navMeshInputTrigerred;
}
}