-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathKeyInputWindow.cs
More file actions
132 lines (123 loc) · 6.18 KB
/
Copy pathKeyInputWindow.cs
File metadata and controls
132 lines (123 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Threading.Tasks;
using MapStudio.UI;
using ImGuiNET;
using GLFrameworkEngine;
namespace MapStudio.UI
{
public class KeyInputWindow
{
static string active_edit = "";
public static void Render()
{
Vector2 size = new Vector2(ImGui.GetWindowWidth(), 23);
if (ImGui.Button(TranslationSource.GetText("SAVE"), size))
{
GlobalSettings.Current.InputSettings = InputSettings.INPUT;
GlobalSettings.Current.Save();
}
if (ImGui.Button(TranslationSource.GetText("RESET"), size))
{
//Update input settings to original values
InputSettings.INPUT = new InputSettings();
GlobalSettings.Current.Save();
}
if (ImGui.CollapsingHeader("General", ImGuiTreeNodeFlags.DefaultOpen))
{
ImGui.Columns(2);
DrawConfigurableInput("FullScreen", InputSettings.INPUT.Scene, "FullScreen");
ImGui.Columns(1);
}
if (ImGui.CollapsingHeader("Camera Movement", ImGuiTreeNodeFlags.DefaultOpen))
{
ImGui.Columns(2);
DrawConfigurableInput("Front", InputSettings.INPUT.Camera, "MoveForward");
DrawConfigurableInput("Back", InputSettings.INPUT.Camera, "MoveBack");
DrawConfigurableInput("Left", InputSettings.INPUT.Camera, "MoveLeft");
DrawConfigurableInput("Right", InputSettings.INPUT.Camera, "MoveRight");
DrawConfigurableInput("Up", InputSettings.INPUT.Camera, "MoveUp");
DrawConfigurableInput("Down", InputSettings.INPUT.Camera, "MoveDown");
ImGui.Columns(1);
}
if (ImGui.CollapsingHeader("Viewport", ImGuiTreeNodeFlags.DefaultOpen))
{
ImGui.Columns(2);
DrawConfigurableInput("Focus Selected", InputSettings.INPUT.Camera, "FocusOnSelectedObject");
DrawConfigurableInput("Undo", InputSettings.INPUT.Scene, "Undo");
DrawConfigurableInput("Redo", InputSettings.INPUT.Scene, "Redo");
DrawConfigurableInput("Copy", InputSettings.INPUT.Scene, "Copy");
DrawConfigurableInput("Paste", InputSettings.INPUT.Scene, "Paste");
DrawConfigurableInput("Delete", InputSettings.INPUT.Scene, "Delete");
DrawConfigurableInput("SelectionBox", InputSettings.INPUT.Scene, "SelectionBox");
DrawConfigurableInput("SelectionCircle", InputSettings.INPUT.Scene, "SelectionCircle");
DrawConfigurableInput("SelectAll", InputSettings.INPUT.Scene, "SelectAll");
ImGui.Columns(1);
}
if (ImGui.CollapsingHeader("Tranform", ImGuiTreeNodeFlags.DefaultOpen))
{
ImGui.Columns(2);
DrawConfigurableInput("AxisX", InputSettings.INPUT.Transform, "AxisX");
DrawConfigurableInput("AxisY", InputSettings.INPUT.Transform, "AxisY");
DrawConfigurableInput("AxisZ", InputSettings.INPUT.Transform, "AxisZ");
DrawConfigurableInput("Rotate", InputSettings.INPUT.Transform, "Rotate");
DrawConfigurableInput("Scale", InputSettings.INPUT.Transform, "Scale");
DrawConfigurableInput("Translate", InputSettings.INPUT.Transform, "Translate");
DrawConfigurableInput("Use Translate Gizmo", InputSettings.INPUT.Transform, "TranslateGizmo");
DrawConfigurableInput("Use Rotate Gizmo", InputSettings.INPUT.Transform, "RotateGizmo");
DrawConfigurableInput("Use Scale Gizmo", InputSettings.INPUT.Transform, "ScaleGizmo");
DrawConfigurableInput("Use Rectangle Gizmo", InputSettings.INPUT.Transform, "RectangleGizmo");
ImGui.Columns(1);
}
if (ImGui.CollapsingHeader("Path Edit", ImGuiTreeNodeFlags.DefaultOpen))
{
ImGui.Columns(2);
DrawConfigurableInput("Extrude", InputSettings.INPUT.Scene, "Extrude");
DrawConfigurableInput("Create", InputSettings.INPUT.Scene, "Create");
DrawConfigurableInput("Fill", InputSettings.INPUT.Scene, "Fill");
DrawConfigurableInput("Insert", InputSettings.INPUT.Scene, "Insert");
DrawConfigurableInput("EditMode", InputSettings.INPUT.Scene, "EditMode");
ImGui.Columns(1);
}
}
static void DrawConfigurableInput(string label, object obj, string prop)
{
var field = obj.GetType().GetField(prop);
var value = field.GetValue(obj) as string;
string[] args = value.Split("+");
bool isActive = label == active_edit;
var width = ImGui.GetColumnWidth();
ImGui.Text($"{label}"); ImGui.NextColumn();
if (!isActive)
{
bool pressed = ImGui.Button($"{value}##INPUT_{label}", new System.Numerics.Vector2(width, 23)); ImGui.NextColumn();
if (pressed)
active_edit = label;
}
else
{
bool pressed = ImGui.Button("", new System.Numerics.Vector2(width, 23)); ImGui.NextColumn();
if (KeyEventInfo.State.HasKeyDown())
{
string input = value;
//Check for the active key input
string newInput = KeyEventInfo.State.KeyChars.FirstOrDefault();
if (!string.IsNullOrEmpty(newInput)) {
input = newInput;
if (KeyEventInfo.State.KeyCtrl)
input = $"Ctrl+{input}";
if (KeyEventInfo.State.KeyShift)
input = $"Shift+{input}";
if (KeyEventInfo.State.KeyAlt)
input = $"Alt+{input}";
}
field.SetValue(obj, input);
//Disable active input
active_edit = "";
}
}
}
}
}