diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f40d8a4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf diff --git a/.gitignore b/.gitignore index 74c2b86..3e3e3fd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.old imgui.ini export_presets.cfg +.godot/ diff --git a/Clicky.cs b/Clicky.cs index 6194459..e1b45be 100644 --- a/Clicky.cs +++ b/Clicky.cs @@ -2,20 +2,20 @@ using ImGuiNET; using System; -public class Clicky : Button +public partial class Clicky : Button { private bool show = false; - private void _on_Button_pressed() + private void _on_button2_pressed() { show = !show; } - private void _on_ImGui_IGLayout() + private void _on_imgui_layout() { if (show) { - ImGui.Begin("a new window", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse); + ImGui.Begin("a new window", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.AlwaysAutoResize); ImGui.Text("you clicked the button"); ImGui.End(); } diff --git a/Dear ImGui for Godot Demo.csproj b/Dear ImGui for Godot Demo.csproj index 52cd2cc..8c54f9f 100644 --- a/Dear ImGui for Godot Demo.csproj +++ b/Dear ImGui for Godot Demo.csproj @@ -1,16 +1,9 @@ - + - net472 + net6.0 + true DearImGuiforGodotDemo - - - true - - - true - - - true + True diff --git a/Dear ImGui for Godot Demo.sln b/Dear ImGui for Godot Demo.sln index 081a959..38a8d1e 100644 --- a/Dear ImGui for Godot Demo.sln +++ b/Dear ImGui for Godot Demo.sln @@ -1,6 +1,6 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dear ImGui for Godot Demo", "Dear ImGui for Godot Demo.csproj", "{ABD95615-B4D9-4195-866C-F56F3AEE9BFE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dear ImGui for Godot Demo", "Dear ImGui for Godot Demo.csproj", "{D939DAF9-46BC-4305-9D69-D920E185BDC7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -9,11 +9,11 @@ Global ExportRelease|Any CPU = ExportRelease|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {ABD95615-B4D9-4195-866C-F56F3AEE9BFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ABD95615-B4D9-4195-866C-F56F3AEE9BFE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ABD95615-B4D9-4195-866C-F56F3AEE9BFE}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU - {ABD95615-B4D9-4195-866C-F56F3AEE9BFE}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU - {ABD95615-B4D9-4195-866C-F56F3AEE9BFE}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU - {ABD95615-B4D9-4195-866C-F56F3AEE9BFE}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + {D939DAF9-46BC-4305-9D69-D920E185BDC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D939DAF9-46BC-4305-9D69-D920E185BDC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D939DAF9-46BC-4305-9D69-D920E185BDC7}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {D939DAF9-46BC-4305-9D69-D920E185BDC7}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {D939DAF9-46BC-4305-9D69-D920E185BDC7}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {D939DAF9-46BC-4305-9D69-D920E185BDC7}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU EndGlobalSection EndGlobal diff --git a/Hack-Regular.ttf.import b/Hack-Regular.ttf.import new file mode 100644 index 0000000..2bbf30e --- /dev/null +++ b/Hack-Regular.ttf.import @@ -0,0 +1,32 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://blkln4jih4r2t" +path="res://.godot/imported/Hack-Regular.ttf-4957220eed9c50075bb4de8b4fadc317.fontdata" + +[deps] + +source_file="res://Hack-Regular.ttf" +dest_files=["res://.godot/imported/Hack-Regular.ttf-4957220eed9c50075bb4de8b4fadc317.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/LICENSE b/LICENSE index 0e259d4..d57e61b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,121 +1,21 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. +MIT License + +Copyright (c) 2022 Patrick Dawson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MyGui.cs b/MyGui.cs deleted file mode 100644 index 270d537..0000000 --- a/MyGui.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Godot; -using System; -using ImGuiNET; -using Vector2 = System.Numerics.Vector2; - -public class MyGui : ImGuiNode -{ - public override void Init(ImGuiIOPtr io) - { - // instead of calling base.Init(io) to setup the font, we'll do it ourselves - - // add font directly from the filesystem, not a resource - io.Fonts.AddFontFromFileTTF("Hack-Regular.ttf", 16); - io.Fonts.AddFontDefault(); // just for comparison - ImGuiGD.RebuildFontAtlas(); - } - - public override void Layout() - { - ImGui.ShowDemoWindow(); - - ImGui.Begin("scene changer"); - if (ImGui.Button("back to the first scene")) - { - GetTree().ChangeScene("res://demo.tscn"); - } - ImGui.End(); - - base.Layout(); // this emits the signal - } -} diff --git a/MyNode.cs b/MyNode.cs new file mode 100644 index 0000000..5526b7f --- /dev/null +++ b/MyNode.cs @@ -0,0 +1,15 @@ +using Godot; +using ImGuiNET; + +public partial class MyNode : Node +{ + private void _on_imgui_layout() + { + ImGui.ShowDemoWindow(); + } + + private void _on_button1_pressed() + { + GetTree().ChangeSceneToFile("res://demo2.tscn"); + } +} diff --git a/SomeOtherNode.cs b/MySecondNode.cs similarity index 51% rename from SomeOtherNode.cs rename to MySecondNode.cs index 600510e..8c9188f 100644 --- a/SomeOtherNode.cs +++ b/MySecondNode.cs @@ -1,24 +1,21 @@ using Godot; -using System; using ImGuiNET; +using System; using Vector2 = System.Numerics.Vector2; -public class SomeOtherNode : Node +public partial class MySecondNode : Node { private IntPtr iconTextureId; - private Texture iconTexture; - private bool filter; - private int iconSize; + private Texture2D iconTexture; + private int iconSize = 64; public override void _Ready() { // connect the signal in code or in the editor - // GetNode("/root/Control/ImGui").Connect("IGLayout", this, nameof(_onLayout)); + GetNode("%ImGuiNode").imgui_layout += _on_imgui_layout; - iconTexture = GD.Load("res://icon.png"); + iconTexture = GD.Load("res://icon.svg"); iconTextureId = ImGuiGD.BindTexture(iconTexture); - filter = (iconTexture.Flags & (uint)Texture.FlagsEnum.Filter) != 0; - iconSize = (int)iconTexture.GetSize().x; ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableGamepad; } @@ -28,28 +25,22 @@ public override void _ExitTree() ImGuiGD.UnbindTexture(iconTextureId); } - public void _onLayout() + public void _on_imgui_layout() { ImGui.Begin("test"); - ImGui.Text("hello Godot"); + ImGui.Text("hello Godot 4"); ImGui.Image(iconTextureId, new Vector2(iconSize, iconSize)); ImGui.DragInt("size", ref iconSize, 1.0f, 32, 512); - ImGui.Checkbox("filter", ref filter); ImGui.Dummy(new Vector2(0, 20.0f)); if (ImGui.Button("change scene")) { - GetTree().ChangeScene("res://demo2.tscn"); + GetTree().ChangeSceneToFile("res://demo.tscn"); } ImGui.End(); ImGui.ShowDemoWindow(); - - if (!filter) - iconTexture.Flags &= ~((uint)Texture.FlagsEnum.Filter); - else - iconTexture.Flags |= (uint)Texture.FlagsEnum.Filter; } } diff --git a/README.md b/README.md index 561e42e..2d60d49 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,72 @@ -# imgui-godot -[Godot](https://github.com/godotengine/godot) plugin for integrating [Dear ImGui](https://github.com/ocornut/imgui) +# [Dear ImGui](https://github.com/ocornut/imgui) plugin for [Godot 4](https://github.com/godotengine/godot) (C#) -Still a work in progress, some unfinished stuff, not sure about the interface, probably bugs, resource leaks, etc +![screenshot](doc/screenshot.png) + +Dear ImGui is a popular library for rapidly building tools for debugging and development. This plugin, with the aid of [ImGui.NET](https://github.com/mellinoe/ImGui.NET), allows you to use ImGui in Godot with C#. + +After a little setup, usage is as simple as this: +```csharp +public partial class MyNode : Node +{ + public void _on_imgui_layout() + { + ImGui.Begin("ImGui on Godot 4"); + ImGui.Text("hello world"); + ImGui.End(); + } +} +``` ## Getting Started ### Demo -On Windows, just click `Build` in the top right then play the project. On other platforms, you may need to -run `nuget restore`, then try the build again. +As of Godot 4.0 beta 1, you'll probably get a warning when you open the project. Just click Ok, click Build, then go to `Project > Project Settings > Plugins` and enable the plugin. + +Click `Build` in the top right, then play the project. + +On macOS, you will need to do something like: +``` +cp .godot/mono/temp/bin/Debug/runtimes/osx-universal/native/libcimgui.dylib . +``` ### Your project -1. Create a project and click `Build` in the top right to generate the .csproj file. +1. Create a project and, if you haven't already added some C# code, use `Project > Tools > C# > Create C# solution`. 2. [Install the plugin](https://docs.godotengine.org/en/stable/tutorials/plugins/editor/installing_plugins.html) by copying over the `addons` folder. -3. Enable the plugin in `Project > Project Settings > Plugins`. - -4. In Visual Studio or another IDE, open the solution and allow unsafe blocks in all configurations, and install `ImGui.NET` with NuGet. Save and return to Godot. +3. In Visual Studio or another IDE, open the solution and allow unsafe code, and install `ImGui.NET` with NuGet. Save and return to Godot. (If you prefer to manually edit the .csproj instead, refer to the demo csproj for the necessary modifications, or copy it entirely.) -5. Click `Build` again (if you get errors, you probably need to run `nuget restore`). +4. Back in the Godot editor, click `Build`. + +5. Enable the plugin in `Project > Project Settings > Plugins`. 6. Add an `ImGuiNode` to your scene. 7. Write code! -## Interface - -I've provided two ways to use ImGui. See the demo project scenes for examples. - -### Signals +## Usage 1. Drop an `ImGuiNode` wherever you want in your scene (usually near the end, so it's rendered on top). -2. From a script on any other node (or multiple nodes!), connect the `IGLayout` signal. - -3. In the function which handles this signal, use `ImGuiNET` to create your GUI. - -### Script extension - -If you need to override something, or if you just want to do everything with one node: - -1. Add the `ImGuiNode`, then use `Extend Script`. - -2. The Godot prompt won't let you inherit from `ImGuiNode`, so be sure to fix that after your new script is created. - -3. Override `Layout` - see `MyGui.cs` for details. Be careful when overriding other methods; it should be -ok if you make sure to call the parent method first (using `base`). +2. From a script on any other node (or multiple nodes!), connect the `imgui_layout` signal. -Since this plugin is unfinished, it doesn't make sense to document an API yet. Check the samples and use the static methods provided by ImGuiGD. +3. In the method which handles this signal, use `ImGuiNET` to create your GUI. -## Project export +Use the `Font` and `FontSize` properties to add a custom font. `ImGuiNode` respects the `Visible` property, so that's the best way to hide the GUI as needed. -When exporting your project with Godot, the native code cimgui library won't be included. -On Windows, you can just copy over cimgui.dll (from .mono\temp\bin\ExportRelease) to the same directory as your exe. +For custom textures, call the static methods `BindTexture`, `UnbindTexture`, and `GetTexture` in `ImGuiGD`. -On macOS, I haven't been able to get the .app to work no matter where I put the .dylib. It does work if you run the binary directly. +That's about it. Everything else is provided by ImGui itself, via ImGui.NET. ## Credits -All code written by Patrick Dawson, released to the public domain (Creative Commons Zero v1.0 Universal) +All code written by Patrick Dawson, released under the MIT license -Godot Logo (C) Andrea Calabró Distributed under the terms of the Creative Commons Attribution License version 3.0 (CC-BY 3.0) https://creativecommons.org/licenses/by/3.0/legalcode. +Godot Logo (C) Andrea Calabró, distributed under the terms of the Creative Commons Attribution 4.0 International License (CC-BY-4.0 International) https://creativecommons.org/licenses/by/4.0/ Hack font distributed under the [MIT license](https://github.com/source-foundry/Hack/blob/master/LICENSE.md) diff --git a/addons/imgui-godot/ImGuiGD.cs b/addons/imgui-godot/ImGuiGD.cs index af16a14..f8076a5 100644 --- a/addons/imgui-godot/ImGuiGD.cs +++ b/addons/imgui-godot/ImGuiGD.cs @@ -4,15 +4,135 @@ using System.Collections.Generic; using System.Runtime.InteropServices; -public class ImGuiGD +public partial class ImGuiGD { - private static Dictionary _loadedTextures = new Dictionary(); - private static int _textureId = 100; + public static float JoyAxisDeadZone { get; set; } = 0.15f; + + private static Dictionary _loadedTextures = new Dictionary(); + private static int _textureId = 0x100; private static IntPtr? _fontTextureId; private static List _children = new List(); - private static List _meshes = new List(); + private static Vector2 _mouseWheel = Vector2.Zero; - public static IntPtr BindTexture(Texture tex) + private static readonly Dictionary _keyMap = new Dictionary() + { + { Key.Tab, ImGuiKey.Tab }, + { Key.Left, ImGuiKey.LeftArrow }, + { Key.Right, ImGuiKey.RightArrow }, + { Key.Up, ImGuiKey.UpArrow }, + { Key.Down, ImGuiKey.DownArrow }, + { Key.Pageup, ImGuiKey.PageUp }, + { Key.Pagedown, ImGuiKey.PageDown }, + { Key.Home, ImGuiKey.Home }, + { Key.End, ImGuiKey.End }, + { Key.Insert, ImGuiKey.Insert }, + { Key.Delete, ImGuiKey.Delete }, + { Key.Backspace, ImGuiKey.Backspace }, + { Key.Space, ImGuiKey.Space }, + { Key.Enter, ImGuiKey.Enter }, + { Key.Escape, ImGuiKey.Escape }, + { Key.Menu, ImGuiKey.Menu }, + { Key.Key0, ImGuiKey._0 }, + { Key.Key1, ImGuiKey._1 }, + { Key.Key2, ImGuiKey._2 }, + { Key.Key3, ImGuiKey._3 }, + { Key.Key4, ImGuiKey._4 }, + { Key.Key5, ImGuiKey._5 }, + { Key.Key6, ImGuiKey._6 }, + { Key.Key7, ImGuiKey._7 }, + { Key.Key8, ImGuiKey._8 }, + { Key.Key9, ImGuiKey._9 }, + { Key.Apostrophe, ImGuiKey.Apostrophe }, + { Key.Comma, ImGuiKey.Comma }, + { Key.Minus, ImGuiKey.Minus }, + { Key.Period, ImGuiKey.Period }, + { Key.Slash, ImGuiKey.Slash }, + { Key.Semicolon, ImGuiKey.Semicolon }, + { Key.Equal, ImGuiKey.Equal }, + { Key.Bracketleft, ImGuiKey.LeftBracket }, + { Key.Backslash, ImGuiKey.Backslash }, + { Key.Bracketright, ImGuiKey.RightBracket }, + { Key.Quoteleft, ImGuiKey.GraveAccent }, + { Key.Capslock, ImGuiKey.CapsLock }, + { Key.Scrolllock, ImGuiKey.ScrollLock }, + { Key.Numlock, ImGuiKey.NumLock }, + { Key.Print, ImGuiKey.PrintScreen }, + { Key.Pause, ImGuiKey.Pause }, + { Key.Kp0, ImGuiKey.Keypad0 }, + { Key.Kp1, ImGuiKey.Keypad1 }, + { Key.Kp2, ImGuiKey.Keypad2 }, + { Key.Kp3, ImGuiKey.Keypad3 }, + { Key.Kp4, ImGuiKey.Keypad4 }, + { Key.Kp5, ImGuiKey.Keypad5 }, + { Key.Kp6, ImGuiKey.Keypad6 }, + { Key.Kp7, ImGuiKey.Keypad7 }, + { Key.Kp8, ImGuiKey.Keypad8 }, + { Key.Kp9, ImGuiKey.Keypad9 }, + { Key.KpPeriod, ImGuiKey.KeypadDecimal }, + { Key.KpDivide, ImGuiKey.KeypadDivide }, + { Key.KpMultiply, ImGuiKey.KeypadMultiply }, + { Key.KpSubtract, ImGuiKey.KeypadSubtract }, + { Key.KpAdd, ImGuiKey.KeypadAdd }, + { Key.KpEnter, ImGuiKey.KeypadEnter }, + { Key.A, ImGuiKey.A }, + { Key.B, ImGuiKey.B }, + { Key.C, ImGuiKey.C }, + { Key.D, ImGuiKey.D }, + { Key.E, ImGuiKey.E }, + { Key.F, ImGuiKey.F }, + { Key.G, ImGuiKey.G }, + { Key.H, ImGuiKey.H }, + { Key.I, ImGuiKey.I }, + { Key.J, ImGuiKey.J }, + { Key.K, ImGuiKey.K }, + { Key.L, ImGuiKey.L }, + { Key.M, ImGuiKey.M }, + { Key.N, ImGuiKey.N }, + { Key.O, ImGuiKey.O }, + { Key.P, ImGuiKey.P }, + { Key.Q, ImGuiKey.Q }, + { Key.R, ImGuiKey.R }, + { Key.S, ImGuiKey.S }, + { Key.T, ImGuiKey.T }, + { Key.U, ImGuiKey.U }, + { Key.V, ImGuiKey.V }, + { Key.W, ImGuiKey.W }, + { Key.X, ImGuiKey.X }, + { Key.Y, ImGuiKey.Y }, + { Key.Z, ImGuiKey.Z }, + { Key.F1, ImGuiKey.F1 }, + { Key.F2, ImGuiKey.F2 }, + { Key.F3, ImGuiKey.F3 }, + { Key.F4, ImGuiKey.F4 }, + { Key.F5, ImGuiKey.F5 }, + { Key.F6, ImGuiKey.F6 }, + { Key.F7, ImGuiKey.F7 }, + { Key.F8, ImGuiKey.F8 }, + { Key.F9, ImGuiKey.F9 }, + { Key.F10, ImGuiKey.F10 }, + { Key.F11, ImGuiKey.F11 }, + { Key.F12, ImGuiKey.F12 }, + }; + + private static Dictionary _joypadButtons = new Dictionary + { + { JoyButton.Start, ImGuiKey.GamepadStart }, + { JoyButton.Back, ImGuiKey.GamepadBack }, + { JoyButton.Y, ImGuiKey.GamepadFaceUp }, + { JoyButton.A, ImGuiKey.GamepadFaceDown }, + { JoyButton.X, ImGuiKey.GamepadFaceLeft }, + { JoyButton.B, ImGuiKey.GamepadFaceRight }, + { JoyButton.DpadUp, ImGuiKey.GamepadDpadUp }, + { JoyButton.DpadDown, ImGuiKey.GamepadDpadDown }, + { JoyButton.DpadLeft, ImGuiKey.GamepadDpadLeft }, + { JoyButton.DpadRight, ImGuiKey.GamepadDpadRight }, + { JoyButton.LeftShoulder, ImGuiKey.GamepadL1 }, + { JoyButton.RightShoulder, ImGuiKey.GamepadR1 }, + { JoyButton.LeftStick, ImGuiKey.GamepadL3 }, + { JoyButton.RightStick, ImGuiKey.GamepadR3 }, + }; + + public static IntPtr BindTexture(Texture2D tex) { // decided not to add duplicate prevention, could cause problems var id = new IntPtr(_textureId++); @@ -26,35 +146,21 @@ public static void UnbindTexture(IntPtr textureId) } // used by renderer - public static Texture GetTexture(IntPtr textureId) + public static Texture2D GetTexture(IntPtr textureId) { return _loadedTextures[textureId]; } - public static ImFontPtr AddFont(DynamicFont font) + public static unsafe ImFontPtr AddFont(FontFile fontData, float fontSize) { - return AddFont(font.FontData, font.Size); - } - - public static unsafe ImFontPtr AddFont(DynamicFontData fontData, int fontSize) - { - ImFontPtr rv = null; - - Godot.File fi = new File(); - var err = fi.Open(fontData.FontPath, File.ModeFlags.Read); - byte[] buf = fi.GetBuffer((int)fi.GetLen()); - fi.Close(); - - // can't add a name, ImFontConfig seems unusable - + int len = fontData.Data.Length; // let ImGui manage this memory - IntPtr p = Marshal.AllocHGlobal(buf.Length); - Marshal.Copy(buf, 0, p, buf.Length); - rv = ImGui.GetIO().Fonts.AddFontFromMemoryTTF(p, buf.Length, (float)fontSize); - - return rv; + IntPtr p = Marshal.AllocHGlobal(len); + Marshal.Copy(fontData.Data, 0, p, len); + return ImGui.GetIO().Fonts.AddFontFromMemoryTTF(p, len, fontSize); } + // only call this once, shortly after Init public static unsafe void RebuildFontAtlas() { var io = ImGui.GetIO(); @@ -66,8 +172,7 @@ public static unsafe void RebuildFontAtlas() Image img = new Image(); img.CreateFromData(width, height, false, Image.Format.Rgba8, pixels); - var imgtex = new ImageTexture(); - imgtex.CreateFromImage(img, 0); + var imgtex = ImageTexture.CreateFromImage(img); if (_fontTextureId.HasValue) UnbindTexture(_fontTextureId.Value); _fontTextureId = BindTexture(imgtex); @@ -80,96 +185,42 @@ public static void Init(Viewport vp) { var context = ImGui.CreateContext(); ImGui.SetCurrentContext(context); - var io = ImGui.GetIO(); io.BackendFlags = 0; io.BackendFlags |= ImGuiBackendFlags.HasGamepad; - // io.BackendFlags |= ImGuiBackendFlags.HasMouseCursors; io.BackendFlags |= ImGuiBackendFlags.HasSetMousePos; - // io.BackendPlatformName = "imgui_impl_godot"; - - io.KeyMap[(int)ImGuiKey.Tab] = FixKey(KeyList.Tab); - io.KeyMap[(int)ImGuiKey.LeftArrow] = FixKey(KeyList.Left); - io.KeyMap[(int)ImGuiKey.RightArrow] = FixKey(KeyList.Right); - io.KeyMap[(int)ImGuiKey.UpArrow] = FixKey(KeyList.Up); - io.KeyMap[(int)ImGuiKey.DownArrow] = FixKey(KeyList.Down); - io.KeyMap[(int)ImGuiKey.PageUp] = FixKey(KeyList.Pageup); - io.KeyMap[(int)ImGuiKey.PageDown] = FixKey(KeyList.Pagedown); - io.KeyMap[(int)ImGuiKey.Home] = FixKey(KeyList.Home); - io.KeyMap[(int)ImGuiKey.End] = FixKey(KeyList.End); - io.KeyMap[(int)ImGuiKey.Insert] = FixKey(KeyList.Insert); - io.KeyMap[(int)ImGuiKey.Delete] = FixKey(KeyList.Delete); - io.KeyMap[(int)ImGuiKey.Backspace] = FixKey(KeyList.Backspace); - io.KeyMap[(int)ImGuiKey.Space] = FixKey(KeyList.Space); - io.KeyMap[(int)ImGuiKey.Enter] = FixKey(KeyList.Enter); - io.KeyMap[(int)ImGuiKey.Escape] = FixKey(KeyList.Escape); - io.KeyMap[(int)ImGuiKey.KeypadEnter] = FixKey(KeyList.KpEnter); - io.KeyMap[(int)ImGuiKey.A] = (int)KeyList.A; - io.KeyMap[(int)ImGuiKey.C] = (int)KeyList.C; - io.KeyMap[(int)ImGuiKey.V] = (int)KeyList.V; - io.KeyMap[(int)ImGuiKey.X] = (int)KeyList.X; - io.KeyMap[(int)ImGuiKey.Y] = (int)KeyList.Y; - io.KeyMap[(int)ImGuiKey.Z] = (int)KeyList.Z; - - io.DisplaySize = new System.Numerics.Vector2(vp.Size.x, vp.Size.y); - } + // io.BackendPlatformName = "imgui_impl_godot4"; - private static void UpdateJoypads() - { - var io = ImGui.GetIO(); - if (!io.ConfigFlags.HasFlag(ImGuiConfigFlags.NavEnableGamepad)) - return; + var vpSize = vp.GetVisibleRect().Size; + io.DisplaySize = new System.Numerics.Vector2(vpSize.x, vpSize.y); - void MapAnalog(ImGuiNavInput igni, string act) + // clear orphaned CanvasItems when changing scenes + while (_children.Count > 0) { - if (Input.IsActionPressed(act)) - { - io.NavInputs[(int)igni] = Input.GetActionStrength(act); - } - } - - void MapButton(ImGuiNavInput igni, string act) - { - if (Input.IsActionPressed(act)) - { - io.NavInputs[(int)igni] = 1; - } + RenderingServer.FreeRid(_children[0]); + _children.RemoveAt(0); } - - MapButton(ImGuiNavInput.DpadUp, "ImGui_DpadUp"); - MapButton(ImGuiNavInput.DpadDown, "ImGui_DpadDown"); - MapButton(ImGuiNavInput.DpadLeft, "ImGui_DpadLeft"); - MapButton(ImGuiNavInput.DpadRight, "ImGui_DpadRight"); - - MapAnalog(ImGuiNavInput.LStickUp, "ImGui_ScrollUp"); - MapAnalog(ImGuiNavInput.LStickDown, "ImGui_ScrollDown"); - MapAnalog(ImGuiNavInput.LStickLeft, "ImGui_ScrollLeft"); - MapAnalog(ImGuiNavInput.LStickRight, "ImGui_ScrollRight"); - - MapButton(ImGuiNavInput.Activate, "ImGui_Activate"); - MapButton(ImGuiNavInput.Cancel, "ImGui_Cancel"); - MapButton(ImGuiNavInput.Input, "ImGui_Input"); - MapButton(ImGuiNavInput.Menu, "ImGui_Menu"); } - public static void Update(float delta, Viewport vp) + public static void Update(double delta, Viewport vp) { var io = ImGui.GetIO(); - io.DisplaySize = new System.Numerics.Vector2(vp.Size.x, vp.Size.y); - io.DeltaTime = delta; - - io.KeyCtrl = Input.IsKeyPressed((int)KeyList.Control); - io.KeyAlt = Input.IsKeyPressed((int)KeyList.Alt); - io.KeyShift = Input.IsKeyPressed((int)KeyList.Shift); - io.KeySuper = Input.IsKeyPressed((int)KeyList.SuperL) || Input.IsKeyPressed((int)KeyList.SuperR); + var vpSize = vp.GetVisibleRect().Size; + io.DisplaySize = new System.Numerics.Vector2(vpSize.x, vpSize.y); + io.DeltaTime = (float)delta; if (io.WantSetMousePos) { - vp.WarpMouse(new Godot.Vector2(io.MousePos.X, io.MousePos.Y)); + vp.WarpMouse(new Vector2(io.MousePos.X, io.MousePos.Y)); } - UpdateJoypads(); + // scrolling works better if we allow no more than one event per frame + if (_mouseWheel != Vector2.Zero) + { + io.AddMouseWheelEvent(_mouseWheel.x, _mouseWheel.y); + _mouseWheel = Vector2.Zero; + } ImGui.NewFrame(); } @@ -184,7 +235,7 @@ public static void Shutdown() { foreach (RID rid in _children) { - VisualServer.FreeRid(rid); + RenderingServer.FreeRid(rid); } ImGui.DestroyContext(); } @@ -196,171 +247,193 @@ public static bool ProcessInput(InputEvent evt) if (evt is InputEventMouseMotion mm) { - io.MousePos = new System.Numerics.Vector2(mm.Position.x, mm.Position.y); + io.AddMousePosEvent(mm.Position.x, mm.Position.y); consumed = io.WantCaptureMouse; } else if (evt is InputEventMouseButton mb) { - switch ((ButtonList)mb.ButtonIndex) + switch (mb.ButtonIndex) { - case ButtonList.Left: - io.MouseDown[(int)ImGuiMouseButton.Left] = mb.Pressed; + case MouseButton.Left: + io.AddMouseButtonEvent((int)ImGuiMouseButton.Left, mb.Pressed); break; - case ButtonList.Right: - io.MouseDown[(int)ImGuiMouseButton.Right] = mb.Pressed; + case MouseButton.Right: + io.AddMouseButtonEvent((int)ImGuiMouseButton.Right, mb.Pressed); break; - case ButtonList.Middle: - io.MouseDown[(int)ImGuiMouseButton.Middle] = mb.Pressed; + case MouseButton.Middle: + io.AddMouseButtonEvent((int)ImGuiMouseButton.Middle, mb.Pressed); break; - case ButtonList.WheelUp: - io.MouseWheel = mb.Factor * 1.0f; + case MouseButton.WheelUp: + _mouseWheel.y = mb.Factor; break; - case ButtonList.WheelDown: - io.MouseWheel = mb.Factor * -1.0f; + case MouseButton.WheelDown: + _mouseWheel.y = -mb.Factor; break; - case ButtonList.WheelLeft: - io.MouseWheelH = mb.Factor * -1.0f; + case MouseButton.WheelLeft: + _mouseWheel.x = -mb.Factor; break; - case ButtonList.WheelRight: - io.MouseWheelH = mb.Factor * 1.0f; + case MouseButton.WheelRight: + _mouseWheel.x = mb.Factor; break; - case ButtonList.Xbutton1: - io.MouseDown[(int)ImGuiMouseButton.Middle + 1] = mb.Pressed; + case MouseButton.Xbutton1: + io.AddMouseButtonEvent((int)ImGuiMouseButton.Middle + 1, mb.Pressed); break; - case ButtonList.Xbutton2: - io.MouseDown[(int)ImGuiMouseButton.Middle + 2] = mb.Pressed; - break; - default: - // more buttons not supported + case MouseButton.Xbutton2: + io.AddMouseButtonEvent((int)ImGuiMouseButton.Middle + 2, mb.Pressed); break; }; - consumed = io.WantCaptureMouse; } else if (evt is InputEventKey k) { - KeyList kc = (KeyList)k.Scancode; - int code = FixKey(kc); - - io.KeysDown[code] = k.Pressed; - if (k.Pressed) + UpdateKeyMods(io, k); + Key kc = k.Keycode; + if (_keyMap.TryGetValue(kc, out var igk)) { - io.AddInputCharacter(k.Unicode); + io.AddKeyEvent(igk, k.Pressed); + + if (k.Pressed && k.Unicode != 0) + { + io.AddInputCharacter((uint)k.Unicode); + } } consumed = io.WantCaptureKeyboard || io.WantTextInput; } else if (evt is InputEventPanGesture pg) { - io.MouseWheelH = -pg.Delta.x; - io.MouseWheel = -pg.Delta.y; + _mouseWheel = new Vector2(-pg.Delta.x, -pg.Delta.y); consumed = io.WantCaptureMouse; } + else if (evt is InputEventJoypadButton jb) + { + if (_joypadButtons.TryGetValue(jb.ButtonIndex, out var igk)) + { + io.AddKeyEvent(igk, jb.Pressed); + } + } + else if (evt is InputEventJoypadMotion jm) + { + bool pressed = true; + float v = jm.AxisValue; + if (Math.Abs(v) < JoyAxisDeadZone) + { + v = 0f; + pressed = false; + } + switch (jm.Axis) + { + case JoyAxis.LeftX: + io.AddKeyAnalogEvent(ImGuiKey.GamepadLStickRight, pressed, v); + break; + case JoyAxis.LeftY: + io.AddKeyAnalogEvent(ImGuiKey.GamepadLStickDown, pressed, v); + break; + case JoyAxis.RightX: + io.AddKeyAnalogEvent(ImGuiKey.GamepadRStickRight, pressed, v); + break; + case JoyAxis.RightY: + io.AddKeyAnalogEvent(ImGuiKey.GamepadRStickDown, pressed, v); + break; + case JoyAxis.TriggerLeft: + io.AddKeyAnalogEvent(ImGuiKey.GamepadL2, pressed, v); + break; + case JoyAxis.TriggerRight: + io.AddKeyAnalogEvent(ImGuiKey.GamepadR2, pressed, v); + break; + }; + } return consumed; } - private static int FixKey(KeyList kc) + private static void UpdateKeyMods(ImGuiIOPtr io, InputEventKey k) { - // Godot reserves the first 24 bits for printable characters, but ImGui needs keycodes <512 - if ((int)kc < 256) - return (int)kc; - else - return 256 + (int)((uint)kc & 0xFF); + io.AddKeyEvent(ImGuiKey.ModCtrl, k.CtrlPressed); + io.AddKeyEvent(ImGuiKey.ModShift, k.ShiftPressed); + io.AddKeyEvent(ImGuiKey.ModAlt, k.AltPressed); + io.AddKeyEvent(ImGuiKey.ModSuper, k.MetaPressed); } private static void RenderDrawData(ImDrawDataPtr drawData, RID parent) { // allocate and clear out our CanvasItem pool as needed int neededNodes = 0; - for (int i = 0; i < drawData.CmdListsCount; i++) + for (int i = 0; i < drawData.CmdListsCount; ++i) { neededNodes += drawData.CmdListsRange[i].CmdBuffer.Size; } while (_children.Count < neededNodes) { - RID newChild = VisualServer.CanvasItemCreate(); - VisualServer.CanvasItemSetParent(newChild, parent); - VisualServer.CanvasItemSetDrawIndex(newChild, _children.Count); + RID newChild = RenderingServer.CanvasItemCreate(); + RenderingServer.CanvasItemSetParent(newChild, parent); + RenderingServer.CanvasItemSetDrawIndex(newChild, _children.Count); _children.Add(newChild); - _meshes.Add(new ArrayMesh()); } // trim unused nodes to reduce draw calls while (_children.Count > neededNodes) { int idx = _children.Count - 1; - VisualServer.FreeRid(_children[idx]); + RenderingServer.FreeRid(_children[idx]); _children.RemoveAt(idx); - _meshes.RemoveAt(idx); } // render drawData.ScaleClipRects(ImGui.GetIO().DisplayFramebufferScale); int nodeN = 0; - for (int n = 0; n < drawData.CmdListsCount; n++) + for (int n = 0; n < drawData.CmdListsCount; ++n) { ImDrawListPtr cmdList = drawData.CmdListsRange[n]; int nVert = cmdList.VtxBuffer.Size; - Godot.Vector2[] vertices = new Godot.Vector2[nVert]; - Godot.Color[] colors = new Godot.Color[nVert]; - Godot.Vector2[] uvs = new Godot.Vector2[nVert]; + var vertices = new Vector2[nVert]; + var colors = new Color[nVert]; + var uvs = new Vector2[nVert]; - for (int i = 0; i < cmdList.VtxBuffer.Size; i++) + for (int i = 0; i < cmdList.VtxBuffer.Size; ++i) { var v = cmdList.VtxBuffer[i]; - vertices[i] = new Godot.Vector2(v.pos.X, v.pos.Y); + vertices[i] = new Vector2(v.pos.X, v.pos.Y); // need to reverse the color bytes - byte[] col = BitConverter.GetBytes(v.col); - colors[i] = Godot.Color.Color8(col[0], col[1], col[2], col[3]); - uvs[i] = new Godot.Vector2(v.uv.X, v.uv.Y); + uint rgba = v.col; + float r = (rgba & 0xFFu) / 255f; + rgba >>= 8; + float g = (rgba & 0xFFu) / 255f; + rgba >>= 8; + float b = (rgba & 0xFFu) / 255f; + rgba >>= 8; + float a = (rgba & 0xFFu) / 255f; + colors[i] = new Color(r, g, b, a); + uvs[i] = new Vector2(v.uv.X, v.uv.Y); } - for (int cmdi = 0; cmdi < cmdList.CmdBuffer.Size; cmdi++, nodeN++) + for (int cmdi = 0; cmdi < cmdList.CmdBuffer.Size; ++cmdi, ++nodeN) { ImDrawCmdPtr drawCmd = cmdList.CmdBuffer[cmdi]; - int[] indices = new int[drawCmd.ElemCount]; + var indices = new int[drawCmd.ElemCount]; int idxOffset = (int)drawCmd.IdxOffset; - for (int i = idxOffset, j = 0; i < idxOffset + drawCmd.ElemCount; i++, j++) + for (int i = idxOffset, j = 0; i < idxOffset + drawCmd.ElemCount; ++i, ++j) { indices[j] = cmdList.IdxBuffer[i]; } - var arrays = new Godot.Collections.Array(); - arrays.Resize((int)ArrayMesh.ArrayType.Max); - arrays[(int)ArrayMesh.ArrayType.Vertex] = vertices; - arrays[(int)ArrayMesh.ArrayType.Color] = colors; - arrays[(int)ArrayMesh.ArrayType.TexUv] = uvs; - arrays[(int)ArrayMesh.ArrayType.Index] = indices; - - var mesh = _meshes[nodeN]; - while (mesh.GetSurfaceCount() > 0) - { - mesh.SurfaceRemove(0); - } - mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, arrays); - RID child = _children[nodeN]; - Texture tex = GetTexture(drawCmd.TextureId); - VisualServer.CanvasItemClear(child); - VisualServer.CanvasItemSetClip(child, true); - VisualServer.CanvasItemSetCustomRect(child, true, new Godot.Rect2( + Texture2D tex = GetTexture(drawCmd.GetTexID()); + RenderingServer.CanvasItemClear(child); + RenderingServer.CanvasItemSetClip(child, true); + RenderingServer.CanvasItemSetCustomRect(child, true, new Rect2( drawCmd.ClipRect.X, drawCmd.ClipRect.Y, drawCmd.ClipRect.Z - drawCmd.ClipRect.X, drawCmd.ClipRect.W - drawCmd.ClipRect.Y) ); - VisualServer.CanvasItemAddMesh(child, mesh.GetRid(), null, null, tex.GetRid(), new RID(null)); - - // why doesn't this quite work? - // VisualServer.CanvasItemAddTriangleArray(child, indices, vertices, colors, uvs, null, null, tex.GetRid(), -1, new RID(null)); - idxOffset += (int)drawCmd.ElemCount; + RenderingServer.CanvasItemAddTriangleArray(child, indices, vertices, colors, uvs, null, null, tex.GetRid(), -1); } } } diff --git a/addons/imgui-godot/ImGuiNode.cs b/addons/imgui-godot/ImGuiNode.cs index e7d6f10..4dea7d8 100644 --- a/addons/imgui-godot/ImGuiNode.cs +++ b/addons/imgui-godot/ImGuiNode.cs @@ -1,46 +1,43 @@ using Godot; -using System; -using System.Collections.Generic; using ImGuiNET; -public class ImGuiNode : Node2D +public partial class ImGuiNode : Node2D { [Export] - DynamicFont Font = null; + public FontFile Font = null; + + [Export] + public float FontSize = 16.0f; [Signal] - public delegate void IGLayout(); + public delegate void imgui_layoutEventHandler(); public virtual void Init(ImGuiIOPtr io) { - if (Font is null) + if (Font is not null) { - io.Fonts.AddFontDefault(); + ImGuiGD.AddFont(Font, FontSize); } else { - ImGuiGD.AddFont(Font); + io.Fonts.AddFontDefault(); } - ImGuiGD.RebuildFontAtlas(); - } - - public virtual void Layout() - { - EmitSignal(nameof(IGLayout)); } public override void _EnterTree() { + ProcessPriority = int.MaxValue; // try to be last ImGuiGD.Init(GetViewport()); Init(ImGui.GetIO()); + ImGuiGD.RebuildFontAtlas(); } - public override void _Process(float delta) + public override void _Process(double delta) { if (Visible) { ImGuiGD.Update(delta, GetViewport()); - Layout(); + EmitSignal("imgui_layout"); ImGuiGD.Render(GetCanvasItem()); } } @@ -49,7 +46,7 @@ public override void _Input(InputEvent evt) { if (Visible && ImGuiGD.ProcessInput(evt)) { - GetTree().SetInputAsHandled(); + GetViewport().SetInputAsHandled(); } } diff --git a/addons/imgui-godot/ImGuiPlugin.gd b/addons/imgui-godot/ImGuiPlugin.gd index 26101b9..94cc3f1 100644 --- a/addons/imgui-godot/ImGuiPlugin.gd +++ b/addons/imgui-godot/ImGuiPlugin.gd @@ -1,4 +1,4 @@ -tool +@tool extends EditorPlugin func _enter_tree(): diff --git a/addons/imgui-godot/icon.tres b/addons/imgui-godot/icon.tres index 51cf92a..3ca9a71 100644 --- a/addons/imgui-godot/icon.tres +++ b/addons/imgui-godot/icon.tres @@ -2,7 +2,7 @@ [sub_resource type="Image" id=1] data = { -"data": PoolByteArray( 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 100, 163, 180, 240, 200, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 200, 163, 180, 240, 100, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 200, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 200, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 0, 0, 0, 0, 163, 180, 240, 200, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 200, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 100, 163, 180, 240, 200, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 200, 163, 180, 240, 100, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0 ), +"data": PackedByteArray( 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 100, 163, 180, 240, 200, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 200, 163, 180, 240, 100, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 200, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 200, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 255, 255, 255, 0, 0, 0, 0, 0, 163, 180, 240, 200, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 200, 255, 255, 255, 0, 255, 255, 255, 0, 163, 180, 240, 100, 163, 180, 240, 200, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 255, 163, 180, 240, 200, 163, 180, 240, 100, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0 ), "format": "RGBA8", "height": 16, "mipmaps": false, diff --git a/addons/imgui-godot/imgui-icon.png b/addons/imgui-godot/imgui-icon.png deleted file mode 100644 index 6b6db5e..0000000 Binary files a/addons/imgui-godot/imgui-icon.png and /dev/null differ diff --git a/addons/imgui-godot/imgui-icon.png.import b/addons/imgui-godot/imgui-icon.png.import deleted file mode 100644 index d6ff310..0000000 --- a/addons/imgui-godot/imgui-icon.png.import +++ /dev/null @@ -1,13 +0,0 @@ -[remap] - -importer="image" -type="Image" -path="res://.import/imgui-icon.png-8a48b8bc56072526ca8c04427759b63d.image" - -[deps] - -source_file="res://addons/imgui-godot/imgui-icon.png" -dest_files=[ "res://.import/imgui-icon.png-8a48b8bc56072526ca8c04427759b63d.image" ] - -[params] - diff --git a/addons/imgui-godot/plugin.cfg b/addons/imgui-godot/plugin.cfg index 050deeb..a12ecae 100644 --- a/addons/imgui-godot/plugin.cfg +++ b/addons/imgui-godot/plugin.cfg @@ -3,5 +3,5 @@ name="Dear ImGui for Godot" description="Dear ImGui for Godot" author="Patrick Dawson" -version="1.0" +version="2.0.0" script="ImGuiPlugin.gd" diff --git a/default_env.tres b/default_env.tres index 20207a4..1a5570b 100644 --- a/default_env.tres +++ b/default_env.tres @@ -1,6 +1,6 @@ [gd_resource type="Environment" load_steps=2 format=2] -[sub_resource type="ProceduralSky" id=1] +[sub_resource type="Sky" id=1] [resource] background_mode = 2 diff --git a/demo.tscn b/demo.tscn index f80f41e..cbf7131 100644 --- a/demo.tscn +++ b/demo.tscn @@ -1,59 +1,62 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=5 format=3 uid="uid://sdgew7sm2686"] -[ext_resource path="res://addons/imgui-godot/ImGuiNode.cs" type="Script" id=1] -[ext_resource path="res://guifont.tres" type="DynamicFont" id=2] -[ext_resource path="res://icon.png" type="Texture" id=3] -[ext_resource path="res://SomeOtherNode.cs" type="Script" id=4] -[ext_resource path="res://Clicky.cs" type="Script" id=5] +[ext_resource type="Script" path="res://addons/imgui-godot/ImGuiNode.cs" id="1"] +[ext_resource type="Texture2D" uid="uid://pkj4drhkpad" path="res://icon.svg" id="1_c7hdb"] +[ext_resource type="FontFile" uid="uid://blkln4jih4r2t" path="res://Hack-Regular.ttf" id="3_fjiyg"] +[ext_resource type="Script" path="res://MyNode.cs" id="3_qvd0t"] [node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -__meta__ = { -"_edit_use_anchors_": false -} +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Button1" type="Button" parent="."] +layout_mode = 0 +offset_left = 16.0 +offset_top = 16.0 +offset_right = 211.0 +offset_bottom = 69.0 +theme_override_fonts/font = ExtResource("3_fjiyg") +theme_override_font_sizes/font_size = 24 +text = "Switch scene" [node name="TextureRect" type="TextureRect" parent="."] -margin_left = 279.0 -margin_top = 41.0 -margin_right = 791.0 -margin_bottom = 553.0 -texture = ExtResource( 3 ) -expand = true -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Button" type="Button" parent="."] -margin_left = 107.0 -margin_top = 94.0 -margin_right = 258.0 -margin_bottom = 163.0 -text = "Click Me" -script = ExtResource( 5 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="SomeOtherNode" type="Node" parent="."] -script = ExtResource( 4 ) - -[node name="ImGui" type="Node2D" parent="."] -script = ExtResource( 1 ) -Font = ExtResource( 2 ) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -128.0 +offset_top = -128.0 +offset_right = 128.0 +offset_bottom = 128.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_c7hdb") + +[node name="ImGuiNode" type="Node2D" parent="."] +script = ExtResource("1") [node name="TextureRect2" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 3 anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = -64.0 -margin_top = -64.0 -texture = ExtResource( 3 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[connection signal="pressed" from="Button" to="Button" method="_on_Button_pressed"] -[connection signal="IGLayout" from="ImGui" to="Button" method="_on_ImGui_IGLayout"] -[connection signal="IGLayout" from="ImGui" to="SomeOtherNode" method="_onLayout"] +offset_left = -64.0 +offset_top = -64.0 +grow_horizontal = 0 +grow_vertical = 0 +texture = ExtResource("1_c7hdb") +ignore_texture_size = true + +[node name="MyNode" type="Node" parent="."] +script = ExtResource("3_qvd0t") + +[connection signal="pressed" from="Button1" to="MyNode" method="_on_button1_pressed"] +[connection signal="imgui_layout" from="ImGuiNode" to="MyNode" method="_on_imgui_layout"] diff --git a/demo2.tscn b/demo2.tscn index cc2b4ec..c380401 100644 --- a/demo2.tscn +++ b/demo2.tscn @@ -1,13 +1,35 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=5 format=3 uid="uid://dr8hy6iu5hk8a"] -[ext_resource path="res://MyGui.cs" type="Script" id=1] +[ext_resource type="Script" path="res://Clicky.cs" id="1_luuqi"] +[ext_resource type="Script" path="res://addons/imgui-godot/ImGuiNode.cs" id="1_yojj6"] +[ext_resource type="Script" path="res://MySecondNode.cs" id="2_gnjei"] +[ext_resource type="FontFile" uid="uid://blkln4jih4r2t" path="res://Hack-Regular.ttf" id="3_7cyft"] [node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -__meta__ = { -"_edit_use_anchors_": false -} +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Button2" type="Button" parent="."] +layout_mode = 0 +offset_left = 72.0 +offset_top = 608.0 +offset_right = 177.0 +offset_bottom = 667.0 +text = "click me" +script = ExtResource("1_luuqi") [node name="ImGuiNode" type="Node2D" parent="."] -script = ExtResource( 1 ) +unique_name_in_owner = true +script = ExtResource("1_yojj6") +Font = ExtResource("3_7cyft") +FontSize = 18.0 + +[node name="MySecondNode" type="Node" parent="."] +script = ExtResource("2_gnjei") + +[connection signal="pressed" from="Button2" to="Button2" method="_on_button2_pressed"] +[connection signal="imgui_layout" from="ImGuiNode" to="Button2" method="_on_imgui_layout"] diff --git a/doc/.gdignore b/doc/.gdignore new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshot.png b/doc/screenshot.png new file mode 100644 index 0000000..73a441d Binary files /dev/null and b/doc/screenshot.png differ diff --git a/guifont.tres b/guifont.tres deleted file mode 100644 index a904895..0000000 --- a/guifont.tres +++ /dev/null @@ -1,8 +0,0 @@ -[gd_resource type="DynamicFont" load_steps=2 format=2] - -[ext_resource path="res://Hack-Regular.ttf" type="DynamicFontData" id=1] - -[resource] -size = 18 -use_filter = true -font_data = ExtResource( 1 ) diff --git a/icon.png b/icon.png deleted file mode 100644 index c98fbb6..0000000 Binary files a/icon.png and /dev/null differ diff --git a/icon.png.import b/icon.png.import deleted file mode 100644 index a4c02e6..0000000 --- a/icon.png.import +++ /dev/null @@ -1,35 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://icon.png" -dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..adc26df --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..8f3ec28 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://pkj4drhkpad" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=4.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot index c08cc6a..f47f724 100644 --- a/project.godot +++ b/project.godot @@ -6,97 +6,25 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 - -_global_script_classes=[ ] -_global_script_class_icons={ -} +config_version=5 [application] config/name="Dear ImGui for Godot Demo" run/main_scene="res://demo.tscn" -config/icon="res://icon.png" +config/features=PackedStringArray("4.0", "C#", "Vulkan Clustered") +config/icon="res://icon.svg" [display] -window/size/width=1280 -window/size/height=720 - -[editor_plugins] +window/size/viewport_width=1280 +window/size/viewport_height=720 +window/dpi/allow_hidpi=false -enabled=PoolStringArray( "imgui-godot" ) +[dotnet] -[input] +project/assembly_name="Dear ImGui for Godot Demo" -ImGui_DpadUp={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":false,"script":null) - ] -} -ImGui_DpadDown={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":false,"script":null) - ] -} -ImGui_DpadLeft={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null) - ] -} -ImGui_DpadRight={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":15,"pressure":0.0,"pressed":false,"script":null) - ] -} -ImGui_ScrollUp={ -"deadzone": 0.1, -"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null) - ] -} -ImGui_ScrollDown={ -"deadzone": 0.1, -"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null) - ] -} -ImGui_ScrollLeft={ -"deadzone": 0.1, -"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null) - ] -} -ImGui_ScrollRight={ -"deadzone": 0.1, -"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null) - ] -} -ImGui_Activate={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null) - ] -} -ImGui_Cancel={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null) - ] -} -ImGui_Input={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null) - ] -} -ImGui_Menu={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null) - ] -} - -[rendering] +[editor_plugins] -quality/driver/driver_name="GLES2" -vram_compression/import_etc=true -vram_compression/import_etc2=false -environment/default_environment="res://default_env.tres" +enabled=PackedStringArray("res://addons/imgui-godot/plugin.cfg")