From 061f8dad69fd0a51a61ff9290a4d1137587d4123 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 18 Mar 2023 01:55:31 +0900 Subject: [PATCH] change slider int to imgui --- .../Settings/RcSettingsView.cs | 32 +++++++++---------- .../Tools/ConvexVolumeTool.cs | 2 +- .../Tools/CrowdProfilingTool.cs | 10 +++--- src/DotRecast.Recast.Demo/Tools/CrowdTool.cs | 2 +- .../Tools/DynamicUpdateTool.cs | 8 ++--- .../Tools/JumpLinkBuilderTool.cs | 6 ++-- .../Tools/TestNavmeshTool.cs | 7 ++-- 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/DotRecast.Recast.Demo/Settings/RcSettingsView.cs b/src/DotRecast.Recast.Demo/Settings/RcSettingsView.cs index daf6bf7..a790039 100644 --- a/src/DotRecast.Recast.Demo/Settings/RcSettingsView.cs +++ b/src/DotRecast.Recast.Demo/Settings/RcSettingsView.cs @@ -106,11 +106,12 @@ public class RcSettingsView : IRcView ImGui.Text("Region"); ImGui.Separator(); - ImGui.SliderInt("Min Region Size", ref minRegionSize, 1, 150, "%.0f"); - ImGui.SliderInt("Merged Region Size", ref mergedRegionSize, 1, 150, "%.0f"); + ImGui.SliderInt("Min Region Size", ref minRegionSize, 1, 150); + ImGui.SliderInt("Merged Region Size", ref mergedRegionSize, 1, 150); ImGui.NewLine(); ImGui.Text("Partitioning"); + ImGui.Separator(); PartitionType.Values.forEach(partition => { var label = partition.Name.Substring(0, 1).ToUpper() @@ -120,38 +121,32 @@ public class RcSettingsView : IRcView ImGui.NewLine(); ImGui.Text("Filtering"); + ImGui.Separator(); ImGui.Checkbox("Low Hanging Obstacles", ref filterLowHangingObstacles); ImGui.Checkbox("Ledge Spans", ref filterLedgeSpans); ImGui.Checkbox("Walkable Low Height Spans", ref filterWalkableLowHeightSpans); ImGui.NewLine(); ImGui.Text("Polygonization"); - // nk_layout_row_dynamic(ctx, 20, 1); + ImGui.Separator(); ImGui.SliderFloat("Max Edge Length", ref edgeMaxLen, 0f, 50f, "%.1f"); - // nk_layout_row_dynamic(ctx, 20, 1); ImGui.SliderFloat("Max Edge Error", ref edgeMaxError, 0.1f, 3f, "%.1f"); - // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Vert Per Poly", 3, vertsPerPoly, 12, 1, 1); + ImGui.SliderInt("Vert Per Poly", ref vertsPerPoly, 3, 12); ImGui.NewLine(); - // nk_layout_row_dynamic(ctx, 3, 1); - // nk_spacing(ctx, 1); - // nk_layout_row_dynamic(ctx, 18, 1); - // nk_label(ctx, "Detail Mesh", NK_TEXT_ALIGN_LEFT); - // nk_layout_row_dynamic(ctx, 20, 1); + ImGui.Text("Detail Mesh"); + ImGui.Separator(); ImGui.SliderFloat("Sample Distance", ref detailSampleDist, 0f, 16f, "%.1f"); - // nk_layout_row_dynamic(ctx, 20, 1); ImGui.SliderFloat("Max Sample Error", ref detailSampleMaxError, 0f, 16f, "%.1f"); - // - // nk_layout_row_dynamic(ctx, 3, 1); - // nk_spacing(ctx, 1); - // nk_layout_row_dynamic(ctx, 18, 1); + ImGui.NewLine(); + ImGui.Text("Tiling"); + ImGui.Separator(); // nk_layout_row_dynamic(ctx, 20, 1); // tiled = nk_check_text(ctx, "Enable", tiled); // if (tiled) { // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Tile Size", 16, tileSize, 1024, 16, 16); + ImGui.SliderInt("Tile Size", ref tileSize, 16, 1024); // nk_layout_row_dynamic(ctx, 18, 1); // nk_label(ctx, string.format("Tiles %d x %d", tiles[0], tiles[1]), NK_TEXT_ALIGN_RIGHT); // nk_layout_row_dynamic(ctx, 18, 1); @@ -170,7 +165,9 @@ public class RcSettingsView : IRcView // navMeshInputTrigerred = nk_button_text(ctx, "Load Nav Mesh..."); // // nk_layout_row_dynamic(ctx, 18, 1); + ImGui.NewLine(); ImGui.Text("Draw"); + ImGui.Separator(); // drawMode = NuklearUIHelper.nk_radio(ctx, DrawMode.values(), drawMode, dm => dm.toString()); // // nk_window_get_bounds(ctx, rect); @@ -181,6 +178,7 @@ public class RcSettingsView : IRcView // } // nk_end(ctx); // } + ImGui.NewLine(); return mouseInside; } diff --git a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs index d050439..d383cdd 100644 --- a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs @@ -193,7 +193,7 @@ public class ConvexVolumeTool : Tool ImGui.SliderFloat("Shape Descent", ref boxDescent, 0.1f, 20f, "%.1f"); // nk_layout_row_dynamic(ctx, 20, 1); ImGui.SliderFloat("Poly Offset", ref polyOffset, 0.1f, 10f, "%.1f"); - // nk_label(ctx, "Area Type", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Area Type"); // nk_layout_row_dynamic(ctx, 20, 1); // if (nk_option_label(ctx, "Ground", areaType == SampleAreaModifications.SAMPLE_AREAMOD_GROUND)) { // areaType = SampleAreaModifications.SAMPLE_AREAMOD_GROUND; diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs index fb2e191..cc47856 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs @@ -61,11 +61,11 @@ public class CrowdProfilingTool // nk_spacing(ctx, 1); // if (nk_tree_state_push(ctx, 0, "Simulation Options", expandSimOptions)) { // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Agents", 0, agents, 10000, 1, 1); + ImGui.SliderInt("Agents", ref agents, 0, 10000); // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Random Seed", 0, randomSeed, 1024, 1, 1); + ImGui.SliderInt("Random Seed", ref randomSeed, 0, 1024); // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Number of Zones", 0, numberOfZones, 10, 1, 1); + ImGui.SliderInt("Number of Zones", ref numberOfZones, 0, 10); // nk_layout_row_dynamic(ctx, 20, 1); ImGui.SliderFloat("Zone Radius", ref zoneRadius, 0, 100, "%.0f"); // nk_layout_row_dynamic(ctx, 20, 1); @@ -76,9 +76,9 @@ public class CrowdProfilingTool // } // if (nk_tree_state_push(ctx, 0, "Crowd Options", expandCrowdOptions)) { // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Path Queue Size", 0, pathQueueSize, 1024, 1, 1); + ImGui.SliderInt("Path Queue Size", ref pathQueueSize, 0, 1024); // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Max Iterations", 0, maxIterations, 4000, 1, 1); + ImGui.SliderInt("Max Iterations", ref maxIterations, 0, 4000); // nk_tree_state_pop(ctx); // } // nk_layout_row_dynamic(ctx, 1, 1); diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index 8b3df37..08a4571 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -726,7 +726,7 @@ public class CrowdTool : Tool // nk_layout_row_dynamic(ctx, 20, 1); // toolParams.m_obstacleAvoidance = nk_option_text(ctx, "Obstacle Avoidance", toolParams.m_obstacleAvoidance); // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Avoidance Quality", 0, toolParams.m_obstacleAvoidanceType, 3, 1, 0.1f); + ImGui.SliderInt("Avoidance Quality", ref toolParams.m_obstacleAvoidanceType, 0, 3); // nk_layout_row_dynamic(ctx, 20, 1); // toolParams.m_separation = nk_option_text(ctx, "Separation", toolParams.m_separation); // nk_layout_row_dynamic(ctx, 20, 1); diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs index 1ce2fa1..bc831c2 100644 --- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs @@ -513,7 +513,7 @@ public class DynamicUpdateTool : Tool // nk_layout_row_dynamic(ctx, 18, 1); ImGui.Text("Rasterization"); // nk_layout_row_dynamic(ctx, 18, 2); - // nk_label(ctx, "Cell Size", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Cell Size"); // nk_label(ctx, string.format("%.2f", cellSize[0]), NK_TEXT_ALIGN_RIGHT); // nk_layout_row_dynamic(ctx, 1, 1); // nk_spacing(ctx, 1); @@ -526,7 +526,7 @@ public class DynamicUpdateTool : Tool // nk_layout_row_dynamic(ctx, 20, 1); ImGui.SliderFloat("Max Climb", ref walkableClimb, 0f, 10f, "%.2f"); // nk_layout_row_dynamic(ctx, 18, 2); - // nk_label(ctx, "Max Slope", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Max Slope"); // nk_label(ctx, string.format("%.0f", walkableSlopeAngle[0]), NK_TEXT_ALIGN_RIGHT); // // nk_layout_row_dynamic(ctx, 1, 1); @@ -565,12 +565,12 @@ public class DynamicUpdateTool : Tool // nk_layout_row_dynamic(ctx, 20, 1); ImGui.SliderFloat("Max Edge Error", ref maxSimplificationError, 0.1f, 10f, "%.1f"); // nk_layout_row_dynamic(ctx, 20, 1); - // nk_property_int(ctx, "Verts Per Poly", 3, vertsPerPoly, 12, 1, 1); + ImGui.SliderInt("Verts Per Poly", ref vertsPerPoly, 3, 12); // // nk_layout_row_dynamic(ctx, 1, 1); // nk_spacing(ctx, 1); // nk_layout_row_dynamic(ctx, 18, 1); - // nk_label(ctx, "Detail Mesh", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Detail Mesh"); // nk_layout_row_dynamic(ctx, 20, 1); // buildDetailMesh = nk_check_text(ctx, "Enable", buildDetailMesh); // nk_layout_row_dynamic(ctx, 20, 1); diff --git a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs index 86055b4..d008ed6 100644 --- a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs @@ -334,7 +334,7 @@ public class JumpLinkBuilderTool : Tool // nk_spacing(ctx, 1); // // nk_layout_row_dynamic(ctx, 18, 1); - // nk_label(ctx, "Climb Down", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Climb Down"); // nk_layout_row_dynamic(ctx, 20, 1); ImGui.SliderFloat("Distance", ref option.climbDownDistance, 0f, 5f, "%.2f"); // nk_layout_row_dynamic(ctx, 20, 1); @@ -345,7 +345,7 @@ public class JumpLinkBuilderTool : Tool // nk_spacing(ctx, 1); // // nk_layout_row_dynamic(ctx, 18, 1); - // nk_label(ctx, "Jump Down", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Jump Down"); // nk_layout_row_dynamic(ctx, 20, 1); ImGui.SliderFloat("Max Distance", ref option.edgeJumpEndDistance, 0f, 10f, "%.2f"); // nk_layout_row_dynamic(ctx, 20, 1); @@ -417,7 +417,7 @@ public class JumpLinkBuilderTool : Tool // } // nk_spacing(ctx, 1); // nk_layout_row_dynamic(ctx, 18, 1); - // nk_label(ctx, "Debug Draw Options", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Debug Draw Options"); // nk_layout_row_dynamic(ctx, 20, 1); // int newFlags = 0; // newFlags |= nk_option_text(ctx, "Walkable Border", diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index acf0e38..1c5c12c 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -5,6 +5,7 @@ using DotRecast.Core; using DotRecast.Detour; using DotRecast.Recast.Demo.Builder; using DotRecast.Recast.Demo.Draw; +using ImGuiNET; using static DotRecast.Detour.DetourCommon; using static DotRecast.Recast.Demo.Draw.DebugDraw; using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives; @@ -97,7 +98,7 @@ public class TestNavmeshTool : Tool // if (nk_option_label(ctx, "Pathfind Straight", m_toolMode == ToolMode.PATHFIND_STRAIGHT)) { // m_toolMode = ToolMode.PATHFIND_STRAIGHT; // nk_layout_row_dynamic(ctx, 20, 1); - // nk_label(ctx, "Vertices at crossings", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Vertices at crossings"); // nk_layout_row_dynamic(ctx, 20, 1); // if (nk_option_label(ctx, "None", m_straightPathOptions == 0)) { // m_straightPathOptions = 0; @@ -153,7 +154,7 @@ public class TestNavmeshTool : Tool // nk_layout_row_dynamic(ctx, 5, 1); // nk_spacing(ctx, 1); // nk_layout_row_dynamic(ctx, 20, 1); - // nk_label(ctx, "Include Flags", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Include Flags"); // nk_layout_row_dynamic(ctx, 20, 1); // int includeFlags = 0; // if (nk_option_label(ctx, "Walk", @@ -177,7 +178,7 @@ public class TestNavmeshTool : Tool // nk_layout_row_dynamic(ctx, 5, 1); // nk_spacing(ctx, 1); // nk_layout_row_dynamic(ctx, 20, 1); - // nk_label(ctx, "Exclude Flags", NK_TEXT_ALIGN_LEFT); + ImGui.Text("Exclude Flags"); // nk_layout_row_dynamic(ctx, 20, 1); // int excludeFlags = 0; // if (nk_option_label(ctx, "Walk",