private void UpdateSearch(string searchText) { searchText = ImGuiUtility.TrimToNullByte(searchText); if (searchText == _searchText) { return; } _searchText = searchText; _items.Clear(); var isEmptySearch = string.IsNullOrWhiteSpace(_searchText); var assetStore = Context.Game.AssetStore; foreach (var asset in assetStore.GetAllAssets()) { if (isEmptySearch || asset.FullName.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0) { if (!AssetViewConstructors.TryGetValue(asset.GetType(), out var assetViewConstructor)) { assetViewConstructor = DefaultAssetViewConstructor; } AssetView createAssetView() => (AssetView)assetViewConstructor.Invoke(new object[] { Context, asset }); _items.Add(new AssetListItem(asset.FullName, createAssetView)); } } }
private void DrawControlTreeItemRecursive(Control control) { var treeNodeFlags = ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.OpenOnDoubleClick; if (control == _selectedControl) { treeNodeFlags |= ImGuiTreeNodeFlags.Selected; } var opened = ImGui.TreeNodeEx(control.DisplayName, treeNodeFlags); ImGuiUtility.DisplayTooltipOnHover(control.DisplayName); if (ImGuiNative.igIsItemClicked(0) > 0) { SelectControl(control); } if (opened) { foreach (var child in control.Controls) { DrawControlTreeItemRecursive(child); } ImGui.TreePop(); } }
public DeveloperModeView(Game game) { _game = game; var window = game.Window; _imGuiRenderer = AddDisposable(new ImGuiRenderer( window.GraphicsDevice, window.GraphicsDevice.MainSwapchain.Framebuffer.OutputDescription, window.ClientBounds.Width, window.ClientBounds.Height)); void OnWindowSizeChanged(object sender, EventArgs e) { _imGuiRenderer.WindowResized(window.ClientBounds.Width, window.ClientBounds.Height); } window.ClientSizeChanged += OnWindowSizeChanged; AddDisposeAction(() => window.ClientSizeChanged -= OnWindowSizeChanged); _commandList = AddDisposable(window.GraphicsDevice.ResourceFactory.CreateCommandList()); _mainView = AddDisposable(new MainView(new DiagnosticViewContext(game, _imGuiRenderer))); ImGuiUtility.SetupDocking(); }
protected override unsafe void DrawOverride(ref bool isGameViewFocused) { ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", ImGui.GetContentRegionAvail(), true); var clipperPtr = ImGuiNative.ImGuiListClipper_ImGuiListClipper(_items.Count, ImGui.GetTextLineHeightWithSpacing()); var clipper = new ImGuiListClipperPtr(clipperPtr); while (clipper.Step()) { for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { var item = _items[i]; var name = GetObjectName(item); if (ImGui.Selectable(name, item == _currentItem)) { _currentItem = item; Context.SelectedObject = item; } ImGuiUtility.DisplayTooltipOnHover(name); } } clipper.Destroy(); ImGui.EndChild(); }
protected override void DrawOverride(ref bool isGameViewFocused) { ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("strings", Vector2.Zero, false); ImGui.Columns(2, "CSF", true); ImGui.Separator(); ImGui.Text("Name"); ImGui.NextColumn(); ImGui.Text("Value"); ImGui.NextColumn(); ImGui.Separator(); foreach (var label in _labels) { ImGui.Text(label); ImGui.NextColumn(); ImGui.Text(CleanText(label.Translate())); ImGui.NextColumn(); } ImGui.Columns(1, null, false); ImGui.EndChild(); }
private void DrawInspector(GameObject gameObject) { if (ImGui.Button("Kill")) { // TODO: Time isn't right. gameObject.Kill(DeathType.Exploded, Context.Game.MapTime); } if (ImGui.CollapsingHeader("General", ImGuiTreeNodeFlags.DefaultOpen)) { ImGuiUtility.BeginPropertyList(); ImGuiUtility.PropertyRow("DisplayName", gameObject.Definition.DisplayName); ImGuiUtility.PropertyRow("ModelConditionFlags", gameObject.ModelConditionFlags.DisplayName); ImGuiUtility.PropertyRow("Speed", gameObject.Speed); ImGuiUtility.PropertyRow("Lift", gameObject.Lift); ImGuiUtility.EndPropertyList(); } foreach (var drawModule in gameObject.DrawModules) { if (ImGui.CollapsingHeader(drawModule.GetType().Name, ImGuiTreeNodeFlags.DefaultOpen)) { ImGuiUtility.BeginPropertyList(); drawModule.DrawInspector(); ImGuiUtility.EndPropertyList(); } } if (ImGui.CollapsingHeader(gameObject.Body.GetType().Name, ImGuiTreeNodeFlags.DefaultOpen)) { ImGuiUtility.BeginPropertyList(); ImGuiUtility.PropertyRow("Max health", gameObject.Body.MaxHealth); ImGuiUtility.PropertyRow("Health", gameObject.Body.Health); ImGuiUtility.EndPropertyList(); } if (gameObject.CurrentWeapon != null) { var weapon = gameObject.CurrentWeapon; if (ImGui.CollapsingHeader("Weapon", ImGuiTreeNodeFlags.DefaultOpen)) { ImGuiUtility.BeginPropertyList(); ImGuiUtility.PropertyRow("Uses clip", weapon.UsesClip); ImGuiUtility.PropertyRow("Current rounds", weapon.CurrentRounds); ImGuiUtility.PropertyRow("Current target", weapon.CurrentTarget?.TargetType); ImGuiUtility.PropertyRow("Current target position", weapon.CurrentTarget?.TargetPosition); ImGuiUtility.EndPropertyList(); } } foreach (var behaviorModule in gameObject.BehaviorModules) { if (ImGui.CollapsingHeader(behaviorModule.GetType().Name, ImGuiTreeNodeFlags.DefaultOpen)) { ImGuiUtility.BeginPropertyList(); behaviorModule.DrawInspector(); ImGuiUtility.EndPropertyList(); } } }
internal override void DrawInspector() { var entry = FindCastle(); ImGuiUtility.PropertyRow("Camp", entry.Camp); ImGuiUtility.PropertyRow("Unpacked", _unpacked); }
private void UpdateSearch(string searchText) { searchText = ImGuiUtility.TrimToNullByte(searchText); if (searchText == _searchText) { return; } _searchText = searchText; _items.Clear(); var isEmptySearch = string.IsNullOrWhiteSpace(_searchText); var assetStore = Context.Game.AssetStore; foreach (var asset in assetStore.GetAllAssets()) { if (isEmptySearch || asset.FullName.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0) { _items.Add(new AssetListItem(asset.FullName, asset)); } } }
private void UpdateSearch(string searchText) { searchText = ImGuiUtility.TrimToNullByte(searchText); if (searchText == _searchText) { return; } _searchText = searchText; _files.Clear(); if (_bigArchive == null) { return; } if (string.IsNullOrWhiteSpace(_searchText)) { _files.AddRange(_bigArchive.Entries.OrderBy(x => x.FullName)); } else { _files.AddRange(_bigArchive.Entries .Where(entry => entry.FullName.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0) .OrderBy(x => x.FullName)); } }
void IInspectable.DrawInspector() { ImGuiUtility.BeginPropertyList(); DrawObject(_value); ImGuiUtility.EndPropertyList(); }
public override void Draw(ref bool isGameViewFocused) { ImGui.BeginChild("manifest sidebar", new Vector2(300, 0), false, 0); { var panelSize = ImGui.GetContentRegionAvail(); panelSize.Y /= 2; ImGui.BeginChild("manifest contents", panelSize, true, 0); foreach (var asset in _gameStream.ManifestFile.Assets) { if (ImGui.Selectable(asset.Name, asset == _selectedAsset)) { _selectedAsset = asset; } ImGuiUtility.DisplayTooltipOnHover(asset.Name); } ImGui.EndChild(); ImGui.BeginChild("asset properties", ImGui.GetContentRegionAvail(), true, 0); if (_selectedAsset != null) { ImGui.Text($"Name: {_selectedAsset.Name}"); ImGui.Text($"TypeId: {_selectedAsset.Header.TypeId}"); ImGui.Text($"AssetType: {_selectedAsset.AssetType}"); ImGui.Text($"SourceFileName: {_selectedAsset.SourceFileName}"); ImGui.Text($"TypeHash: {_selectedAsset.Header.TypeHash}"); ImGui.Text($"InstanceDataSize: {_selectedAsset.Header.InstanceDataSize}"); ImGui.Text($"ImportsDataSize: {_selectedAsset.Header.ImportsDataSize}"); if (_selectedAsset.AssetImports.Count > 0) { ImGui.Text("Asset references:"); foreach (var assetImport in _selectedAsset.AssetImports) { ImGui.BulletText(assetImport.ImportedAsset?.Name ?? "Import not found"); } } } else { ImGui.Text("Select an asset to view its properties."); } ImGui.EndChild(); } ImGui.EndChild(); //ImGui.SameLine(); //if (_selectedContentView != null) //{ // _selectedContentView.Draw(ref isGameViewFocused); //} }
protected override void DrawOverride(ref bool isGameViewFocused) { var windowPos = ImGui.GetCursorScreenPos(); var availableSize = ImGui.GetContentRegionAvail(); availableSize.Y -= ImGui.GetTextLineHeightWithSpacing(); if (availableSize.X <= 0 || availableSize.Y <= 0) { return; } Game.Panel.EnsureFrame( new Mathematics.Rectangle( (int)windowPos.X, (int)windowPos.Y, (int)availableSize.X, (int)availableSize.Y)); var inputMessages = isGameViewFocused ? ImGuiUtility.TranslateInputMessages(Game.Panel.Frame, Window.MessageQueue) : Array.Empty <InputMessage>(); Game.Update(inputMessages); Game.Render(); var imagePointer = ImGuiRenderer.GetOrCreateImGuiBinding( Game.GraphicsDevice.ResourceFactory, Game.Panel.Framebuffer.ColorTargets[0].Target); if (ImGui.ImageButton( imagePointer, availableSize, Vector2.Zero, Vector2.One, 0, Vector4.Zero, Vector4.One)) { isGameViewFocused = true; } if (isGameViewFocused) { ImGui.TextColored( new Vector4(1.0f, 0.0f, 0.0f, 1.0f), "Press [ESC] to unfocus the game view."); } else { ImGui.Text("Click in the game view to capture mouse input."); } }
private void UpdateSearch(string searchText) { searchText = ImGuiUtility.TrimToNullByte(searchText); if (searchText == _searchText) { return; } _searchText = searchText; UpdateFilesList(); }
private void UpdateSearch(string searchText) { searchText = ImGuiUtility.TrimToNullByte(searchText); if (searchText == _searchText) { return; } _searchText = searchText; _items.Clear(); var isEmptySearch = string.IsNullOrWhiteSpace(_searchText); void AddItem(string assetName, Func <AssetView> createAssetView) { if (isEmptySearch || assetName.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0) { _items.Add(new AssetListItem(assetName, createAssetView)); } } foreach (var asset in Game.ContentManager.CachedObjects) { var assetName = AssetView.GetAssetName(asset); if (assetName == null) { continue; } AddItem(assetName, () => AssetView.CreateAssetView(Context, asset)); } // TODO: Remove these, once audio assets are handled the same as other assets. foreach (var objectDefinition in Context.Game.ContentManager.IniDataContext.Objects) { AddItem($"GameObject:{objectDefinition.Name}", () => new GameObjectView(Context, objectDefinition)); } foreach (var audioFilename in _audioFilenames) { AddItem($"Audio:{audioFilename}", () => new SoundView(Context, audioFilename)); } foreach (var particleSystemDefinition in Context.Game.ContentManager.IniDataContext.ParticleSystems) { AddItem($"ParticleSystem:{particleSystemDefinition.Name}", () => new ParticleSystemView(Context, particleSystemDefinition.ToFXParticleSystemTemplate())); } foreach (var particleSystemTemplate in Context.Game.ContentManager.IniDataContext.FXParticleSystems) { AddItem($"FXParticleSystem:{particleSystemTemplate.Name}", () => new ParticleSystemView(Context, particleSystemTemplate)); } }
internal override void DrawInspector() { if (_phase == null) { ImGui.LabelText("Phase", "<not dying>"); } else { var phase = _phase.Value; if (ImGuiUtility.ComboEnum("Phase", ref phase)) { _phase = phase; } } }
public DeveloperModeView(Game game, GameWindow window) { _game = game; _window = window; _imGuiRenderer = AddDisposable(new ImGuiRenderer( game.GraphicsDevice, game.GraphicsDevice.MainSwapchain.Framebuffer.OutputDescription, window.ClientBounds.Width, window.ClientBounds.Height)); void OnWindowSizeChanged(object sender, EventArgs e) { _imGuiRenderer.WindowResized(window.ClientBounds.Width, window.ClientBounds.Height); } window.ClientSizeChanged += OnWindowSizeChanged; AddDisposeAction(() => window.ClientSizeChanged -= OnWindowSizeChanged); var inputMessageHandler = new CallbackMessageHandler( HandlingPriority.Window, message => { if (_isGameViewFocused && message.MessageType == InputMessageType.KeyDown && message.Value.Key == Key.Escape) { _isGameViewFocused = false; return(InputMessageResult.Handled); } return(InputMessageResult.NotHandled); }); game.InputMessageBuffer.Handlers.Add(inputMessageHandler); AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(inputMessageHandler)); _commandList = AddDisposable(game.GraphicsDevice.ResourceFactory.CreateCommandList()); ImGuiUtility.SetupDocking(); _mainView = AddDisposable(new MainView(new DiagnosticViewContext(game, window, _imGuiRenderer))); }
protected override void DrawOverride(ref bool isGameViewFocused) { ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); foreach (var item in _items) { if (ImGui.Selectable(item.Name, item.Asset == Context.SelectedObject)) { Context.SelectedObject = item.Asset; } ImGuiUtility.DisplayTooltipOnHover(item.Name); } ImGui.EndChild(); }
protected override void DrawOverride(ref bool isGameViewFocused) { ImGui.BeginChild("asset list sidebar", new Vector2(350, 0), true, 0); ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); foreach (var item in _items) { if (ImGui.Selectable(item.Name, item == _currentItem)) { _currentItem = item; RemoveAndDispose(ref _currentAssetView); _currentAssetView = AddDisposable(item.CreateAssetView()); } ImGuiUtility.DisplayTooltipOnHover(item.Name); } ImGui.EndChild(); ImGui.EndChild(); ImGui.SameLine(); if (_currentItem != null) { ImGui.BeginChild("asset view"); _currentAssetView.Draw(); ImGui.EndChild(); } else { ImGui.Text("Select a previewable asset."); } }
private void DrawOpenFileDialog() { ImGuiUtility.InputText("File Path", _filePathBuffer, out var filePath); if (ImGui.Button("Open")) { filePath = ImGuiUtility.TrimToNullByte(filePath); OpenBigFile(filePath); ImGui.CloseCurrentPopup(); } ImGui.SetItemDefaultFocus(); ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } }
private void UpdateSearch(string searchText) { searchText = ImGuiUtility.TrimToNullByte(searchText); if (searchText == _searchText) { return; } _searchText = searchText; _labels.Clear(); foreach (var label in Context.Game.ContentManager.TranslationManager.Labels) { var matchesSearch = label.Contains(searchText, StringComparison.OrdinalIgnoreCase); if (matchesSearch) { _labels.Add(label); } } }
private void UpdateSearch(string searchText) { searchText = ImGuiUtility.TrimToNullByte(searchText); if (searchText == _searchText) { return; } _searchText = searchText; _items.Clear(); var isEmptySearch = string.IsNullOrWhiteSpace(_searchText); foreach (var asset in Context.Game.Scene3D.GameObjects.Items) { var name = GetObjectName(asset); if (isEmptySearch || name.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0) { _items.Add(asset); } } }
private void DrawStatusPanel() { ImGui.BeginChild("statusbar", new Vector2(0, 30), true, 0); ImGui.Text($"{_bigArchive.FilePath} | Version: {_bigArchive.Version} | Size: {ImGuiUtility.GetFormatedSize(_bigArchive.Size)} | Files: {_bigArchive.Entries.Count}"); ImGui.SameLine(); if (_currentFileName != null) { ImGui.Text($"| Selected file: {_currentFileName}"); } ImGui.EndChild(); // end statusbar }
private void DrawFilesList(Vector2 windowSize) { ImGui.BeginChild("sidebar", new Vector2(350, 0), true, 0); ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); ImGui.Columns(2, "Files", false); ImGui.SetColumnWidth(0, 250); ImGui.Separator(); ImGui.Text("Name"); ImGui.NextColumn(); ImGui.Text("Size"); ImGui.NextColumn(); ImGui.Separator(); if (ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.DownArrow)) && _currentFile != _files.Count - 1) { _currentFile++; _scrollY += ImGui.GetIO().DeltaTime * 1000.0f; ImGui.SetScrollY(_scrollY); } if (ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.UpArrow)) && _currentFile != 0) { _currentFile--; _scrollY -= ImGui.GetIO().DeltaTime * 1000.0f; ImGui.SetScrollY(_scrollY); } if (ImGui.IsMouseClicked(0)) { _scrollY = ImGui.GetScrollY(); } for (var i = 0; i < _files.Count; i++) { var entry = _files[i]; if (ImGui.Selectable(entry.FullName, i == _currentFile, ImGuiSelectableFlags.SpanAllColumns) || i == _currentFile) { _currentFile = i; _currentFileName = entry.FullName; switch (Path.GetExtension(entry.FullName).ToLowerInvariant()) { case ".ini": case ".txt": case ".wnd": using (var stream = entry.Open()) using (var reader = new StreamReader(stream)) { _currentFileText = reader.ReadToEnd(); } break; default: _currentFileText = null; break; } } var shouldOpenSaveDialog = false; if (ImGui.BeginPopupContextItem("context" + i)) { _currentFile = i; _currentFileName = entry.FullName; if (ImGui.Selectable("Export...")) { shouldOpenSaveDialog = true; } ImGui.EndPopup(); } ImGui.NextColumn(); ImGui.Text(ImGuiUtility.GetFormatedSize(entry.Length)); ImGui.NextColumn(); if (shouldOpenSaveDialog) { var saveDialog = new SaveFileDialog("Export file"); saveDialog.DefaultFileName = entry.Name; saveDialog.Save(result => ExportFile(entry, result.FileName)); } } ImGui.Columns(1, null, false); ImGui.EndChild(); ImGui.EndChild(); }
internal override void DrawInspector() { ImGuiUtility.ComboEnum("DoorState", ref _currentDoorState); }
private void DrawDisplayListRecursive(int depth, DisplayItem item) { var treeNodeFlags = ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.OpenOnDoubleClick; if (_currentClipDepth.HasValue && (depth > _currentClipDepth.Value)) { _currentClipDepth = null; } if (item.ClipDepth.HasValue) { _currentClipDepth = item.ClipDepth; } if (!(item is SpriteItem)) { treeNodeFlags = ImGuiTreeNodeFlags.Leaf; } if (item == _selectedItem) { treeNodeFlags |= ImGuiTreeNodeFlags.Selected; } if (item.ClipDepth.HasValue) { ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.5f, 1.0f, 0.5f, 1.0f)); } else if (_currentClipDepth.HasValue) { ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.5f, 0.5f, 0.5f, 1.0f)); } bool hasRenderCallback = false; if (item is RenderItem renderItem && renderItem.RenderCallback != null) { hasRenderCallback = true; ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1.0f, 0.5f, 0.5f, 1.0f)); } var opened = ImGui.TreeNodeEx($"[{depth}] {item.Name}", treeNodeFlags); if (hasRenderCallback) { ImGui.PopStyleColor(); } if (_currentClipDepth.HasValue) { ImGui.PopStyleColor(); } ImGuiUtility.DisplayTooltipOnHover("MovieClip: " + item.Character.Container.MovieName); if (ImGuiNative.igIsItemClicked(0) > 0) { SelectDisplayItem(item); } if (opened) { if (item is SpriteItem) { var spriteItem = item as SpriteItem; foreach (var pair in spriteItem.Content.Items) { DrawDisplayListRecursive(pair.Key, pair.Value); } } ImGui.TreePop(); } }
protected override void DrawOverride(ref bool isGameViewFocused) { foreach (var aptWindow in Game.Scene2D.AptWindowManager.WindowStack) { ImGui.BeginChild("DisplayLists", new Vector2(400, 0), true, ImGuiWindowFlags.HorizontalScrollbar); if (ImGui.TreeNodeEx(aptWindow.Name, ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.OpenOnArrow)) { DrawDisplayListRecursive(0, aptWindow.Root); } ImGui.EndChild(); ImGui.SameLine(); ImGui.BeginChild("ScriptObject"); if (_selectedItem != null) { ImGuiUtility.BeginPropertyList(); ImGuiUtility.PropertyRow("Type", _selectedItem.Character.GetType()); ImGuiUtility.PropertyRow("ClipDepth", _selectedItem.ClipDepth); ImGuiUtility.EndPropertyList(); switch (_selectedItem) { case SpriteItem si: ImGuiUtility.BeginPropertyList(); // CurrentFrame shows the next frame that should be played ImGuiUtility.PropertyRow("CurrentFrame", si.CurrentFrame - 1); ImGuiUtility.PropertyRow("State", si.State); ImGuiUtility.EndPropertyList(); if (ImGui.CollapsingHeader("FrameLabels", ImGuiTreeNodeFlags.DefaultOpen)) { ImGuiUtility.BeginPropertyList(); foreach (var frameLabels in si.FrameLabels) { ImGuiUtility.PropertyRow(frameLabels.Key, frameLabels.Value); } ImGuiUtility.EndPropertyList(); } break; case RenderItem ri: if (_selectedItem.Character is Text) { var text = _selectedItem.Character as Text; ImGuiUtility.BeginPropertyList(); ImGuiUtility.PropertyRow("Content", text.Content); ImGuiUtility.PropertyRow("InitialValue", text.Value); ImGuiUtility.PropertyRow("Color", text.Color.ToString()); ImGuiUtility.PropertyRow("Multiline", text.Multiline); ImGuiUtility.PropertyRow("Wordwrap", text.WordWrap); ImGuiUtility.EndPropertyList(); } else if (_selectedItem.Character is Shape) { var shape = _selectedItem.Character as Shape; ImGuiUtility.BeginPropertyList(); ImGuiUtility.PropertyRow("GeometryID", shape.Geometry); ImGuiUtility.EndPropertyList(); } break; } if (ImGui.CollapsingHeader("Variables", ImGuiTreeNodeFlags.DefaultOpen)) { ImGuiUtility.BeginPropertyList(); if (_selectedItem.ScriptObject != null) { foreach (var variable in _selectedItem.ScriptObject.Variables) { ImGuiUtility.PropertyRow(variable.Key, CreateObject(variable.Value)); } } ImGuiUtility.EndPropertyList(); } if (ImGui.CollapsingHeader("Constants", ImGuiTreeNodeFlags.DefaultOpen)) { ImGuiUtility.BeginPropertyList(); int index = 0; if (_selectedItem.ScriptObject != null) { foreach (var variable in _selectedItem.ScriptObject?.Constants) { ImGuiUtility.PropertyRow($"{index++}", CreateObject(variable)); } } ImGuiUtility.EndPropertyList(); } } ImGui.EndChild(); } }
private void DrawMainUi(ref bool isGameViewFocused) { if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Installation")) { foreach (var installation in _installations) { if (ImGui.MenuItem(installation.Game.DisplayName, null, _selectedInstallation == installation, true)) { ChangeInstallation(installation); } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Preferences")) { bool isVSyncEnabled = _isVSyncEnabled; if (ImGui.MenuItem("VSync", null, ref isVSyncEnabled, true)) { SetVSync(isVSyncEnabled); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } ImGui.BeginChild("sidebar", new Vector2(250, 0), true, 0); if (_launcherImage != null) { var availableSize = ImGui.GetContentRegionAvail(); var launcherImageSize = SizeF.CalculateSizeFittingAspectRatio( new SizeF(_launcherImage.Width, _launcherImage.Height), new Size((int)availableSize.X, (int)availableSize.Y)); ImGui.Image( _imGuiRenderer.GetOrCreateImGuiBinding(_gameWindow.GraphicsDevice.ResourceFactory, _launcherImage), new Vector2(launcherImageSize.Width, launcherImageSize.Height), Vector2.Zero, Vector2.One, Vector4.One, Vector4.Zero); } ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); for (var i = 0; i < _files.Count; i++) { var entry = _files[i]; if (ImGui.Selectable(entry.FilePath, i == _currentFile)) { _currentFile = i; RemoveAndDispose(ref _contentView); _game.ContentManager.Unload(); _contentView = AddDisposable(new ContentView( new Views.AssetViewContext(_game, _gamePanel, _imGuiRenderer, entry))); } ImGuiUtility.DisplayTooltipOnHover(entry.FilePath); } ImGui.EndChild(); ImGui.EndChild(); ImGui.SameLine(); if (_contentView != null) { ImGui.BeginChild("content"); ImGui.Text(_contentView.DisplayName); if (isGameViewFocused) { var message = "Press [ESC] to unfocus the 3D view."; ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.CalcTextSize(message).X); ImGui.TextColored(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), message); } ImGui.BeginChild("content view"); _contentView.Draw(ref isGameViewFocused); ImGui.EndChild(); ImGui.EndChild(); } }
static DefaultInspectable() { Drawers = new List <InspectableDrawer>(); Drawers.Add(new InspectableDrawer(typeof(string), (ref object v, DiagnosticViewContext context) => { var s = (string)v; if (ImGui.InputText("", ref s, 1000)) { v = s; return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(bool), (ref object v, DiagnosticViewContext context) => { var b = (bool)v; if (ImGui.Checkbox("", ref b)) { v = b; return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(int), (ref object v, DiagnosticViewContext context) => { var i = (int)v; if (ImGui.DragInt("", ref i)) { v = i; return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(float), (ref object v, DiagnosticViewContext context) => { var f = (float)v; if (ImGui.DragFloat("", ref f)) { v = f; return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(Vector3), (ref object v, DiagnosticViewContext context) => { var c = (Vector3)v; if (ImGui.DragFloat3("", ref c)) { v = c; return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(Percentage), (ref object v, DiagnosticViewContext context) => { var f = (float)(Percentage)v; if (ImGui.DragFloat("", ref f)) { v = new Percentage(f); return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(ColorRgb), (ref object v, DiagnosticViewContext context) => { var c = ((ColorRgb)v).ToVector3(); if (ImGui.ColorEdit3("", ref c)) { v = new ColorRgb( (byte)(c.X * 255.0f), (byte)(c.Y * 255.0f), (byte)(c.Z * 255.0f)); return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(ColorRgba), (ref object v, DiagnosticViewContext context) => { var c = ((ColorRgba)v).ToVector4(); if (ImGui.ColorEdit4("", ref c)) { v = new ColorRgba( (byte)(c.X * 255.0f), (byte)(c.Y * 255.0f), (byte)(c.Z * 255.0f), (byte)(c.W * 255.0f)); return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(ColorRgbF), (ref object v, DiagnosticViewContext context) => { var c = ((ColorRgbF)v).ToVector3(); if (ImGui.ColorEdit3("", ref c)) { v = new ColorRgbF(c.X, c.Y, c.Z); return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(ColorRgbaF), (ref object v, DiagnosticViewContext context) => { var c = ((ColorRgbaF)v).ToVector4(); if (ImGui.ColorEdit4("", ref c)) { v = new ColorRgbaF(c.X, c.Y, c.Z, c.W); return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(Enum), (ref object v, DiagnosticViewContext context) => { var e = (Enum)v; if (ImGuiUtility.ComboEnum(v.GetType(), "", ref e)) { v = e; return(true); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(ILazyAssetReference), (ref object v, DiagnosticViewContext context) => { var asset = (ILazyAssetReference)v; if (asset.Value != null) { if (ImGui.Button(asset.Value.FullName)) { context.SelectedObject = asset.Value; } } else { ImGui.Text("<null>"); } return(false); })); Drawers.Add(new InspectableDrawer(typeof(BaseAsset), (ref object v, DiagnosticViewContext context) => { var asset = (BaseAsset)v; if (ImGui.Button(asset.FullName)) { context.SelectedObject = v; } return(false); })); // Order matters here - this must be last. Drawers.Add(new InspectableDrawer(typeof(object), (ref object v, DiagnosticViewContext context) => { return(false); }, hasChildNodes: true)); }
internal override void DrawInspector() { ImGuiUtility.PropertyRow("DoorState", _currentDoorState); }
private void DrawFilesList() { ImGui.BeginChild("sidebar", new Vector2(350, 0), true, 0); ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); ImGui.Columns(2, "Files", false); ImGui.SetColumnWidth(0, 250); ImGui.Separator(); ImGui.Text("Name"); ImGui.NextColumn(); ImGui.Text("Size"); ImGui.NextColumn(); ImGui.Separator(); for (var i = 0; i < _files.Count; i++) { var entry = _files[i]; if (ImGui.Selectable(entry.FullName, i == _currentFile, ImGuiSelectableFlags.SpanAllColumns)) { _currentFile = i; switch (Path.GetExtension(entry.FullName).ToLowerInvariant()) { case ".ini": case ".txt": case ".wnd": using (var stream = entry.Open()) using (var reader = new StreamReader(stream)) { _currentFileText = reader.ReadToEnd(); } break; default: _currentFileText = null; break; } } var shouldOpenSaveDialog = false; if (ImGui.BeginPopupContextItem("context" + i)) { _currentFile = i; if (ImGui.Selectable("Export...")) { shouldOpenSaveDialog = true; } ImGui.EndPopup(); } ImGui.NextColumn(); ImGui.Text(entry.Length.ToString()); ImGui.NextColumn(); var exportId = "Export##ExportDialog" + i; if (shouldOpenSaveDialog) { ImGui.OpenPopup(exportId); } bool contextMenuOpen = true; if (ImGui.BeginPopupModal(exportId, ref contextMenuOpen, ImGuiWindowFlags.AlwaysAutoResize)) { ImGuiUtility.InputText("File Path", _filePathBuffer, out var filePath); if (ImGui.Button("Save")) { filePath = ImGuiUtility.TrimToNullByte(filePath); using (var entryStream = entry.Open()) { using (var fileStream = File.OpenWrite(filePath)) { entryStream.CopyTo(fileStream); } } ImGui.CloseCurrentPopup(); } ImGui.SetItemDefaultFocus(); ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } ImGui.Columns(1, null, false); ImGui.EndChild(); ImGui.EndChild(); }