From 8b987b3dbe62131bcf84402e4d12a66c18ee90db Mon Sep 17 00:00:00 2001 From: Lisias T Date: Sun, 10 Sep 2023 08:26:53 -0300 Subject: [PATCH 1/3] Project normalizing --- .gitattributes | 56 ++++++++++++++++++++++++++++++++++++++++--- .gitignore | 65 ++++++++++++-------------------------------------- 2 files changed, 68 insertions(+), 53 deletions(-) diff --git a/.gitattributes b/.gitattributes index 6ecf0fa..2a9c0b3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,20 @@ # allow git to guess types we don't specify -* text=auto +#* text=auto -# explictly specify most everything +# Source code +*.c text *.cs text diff=csharp +*.cpp text diff=cpp +*.java text diff=java +*.py text diff=python + +*.htm text diff=html +*.html text diff=html +*.css text diff=css +*.js text +*.md text diff=markdown + +# explictly specify most everything *.cfg text *.asset text *.shader text @@ -11,9 +23,47 @@ *.txt text *.resx text +# Image and other binaries *.png binary *.dds binary *.mu binary -*.zip binary *.dll binary *.bundle binary + +# Compression utilities +*.zip binary +*.7z binary +*.rar binary +*.gz binary +*.bz2 binary +*.lz binary +*.lz4 binary +*.lzo binary +*.lzma binary +*.xz binary +*.z binary +*.Z binary + +# Visual Studio +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +# More known and most used filetypes +*.csv text +*.fods text diff=html +*.my binary diff --git a/.gitignore b/.gitignore index 5e99f3e..b89f08b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,50 +1,15 @@ -Thumbs.db - -/KodeUI-Unity/Assets/Builtin skin/ -/KodeUI-Unity/Assets/Builtin skin.meta -/KodeUI-Unity/Assets/TextMesh Pro/ -/KodeUI-Unity/Assets/TextMesh Pro.meta - -/KodeUI-Unity/[Ll]ibrary/ -/KodeUI-Unity/[Tt]emp/ -/KodeUI-Unity/[Oo]bj/ -/KodeUI-Unity/[Bb]uild/ -/KodeUI-Unity/[Bb]uilds/ -/KodeUI-Unity/[Uu]nity[Pp]ackage[Mm]anager/ -/KodeUI-Unity/Assets/AssetStoreTools* -/KodeUI-Unity/Assets/Assembly/*.meta -/KodeUI-Unity/Assets/Assembly.meta -/KodeUI-Unity/Assets/Makefile.meta - -# Visual Studio 2015 cache directory -/KodeUI-Unity/.vs/ - -# Autogenerated VS/MD/Consulo solution and project files -/KodeUI-Unity/ExportedObj/ -/KodeUI-Unity/.consulo/ -*.csproj -*.unityproj -*.sln -*.suo -*.tmp -*.user -*.userprefs -*.pidb -*.booproj -*.svd -*.pdb -*.swp - -# Unity3D generated meta files -*.pidb.meta -*.pdb.meta - -# Unity3D Generated File On Crash Reports -sysinfo.txt - -# Builds -*.apk -*.unitypackage - -*.log -*.zip +.vs +Archive +GameData/**/*.dll +GameData/**/LICENSE* +GameData/**/NOTICE +GameData/**/README.md +GameData/**/CHANGE_LOG.md +GameData/**/KNOWN_ISSUES.md +GameData/**/*.version +Source/**/Properties/Version.cs +Source/**/Properties/Configuration.cs +Source/*/*.user +bin +obj +packages From e6ccb81ce22ae7d7d96237f495b157f6767413bd Mon Sep 17 00:00:00 2001 From: Lisias T Date: Sun, 10 Sep 2023 08:31:08 -0300 Subject: [PATCH 2/3] Project to Compile the thing into Unity 2019/KSP >= 1.8 --- KodeUI.sln | 25 +++++++ KodeUI/KodeUI.u2019.csproj | 115 ++++++++++++++++++++++++++++++ KodeUI/Properties/AssemblyInfo.cs | 26 +++++++ 3 files changed, 166 insertions(+) create mode 100644 KodeUI.sln create mode 100644 KodeUI/KodeUI.u2019.csproj create mode 100644 KodeUI/Properties/AssemblyInfo.cs diff --git a/KodeUI.sln b/KodeUI.sln new file mode 100644 index 0000000..968cdfc --- /dev/null +++ b/KodeUI.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.810.25 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KodeUI.u2918", "KodeUI/KodeUI.u2019.csproj", "{3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1FD46BC5-D633-49B7-8223-BC9CA6F3FB00} + EndGlobalSection +EndGlobal diff --git a/KodeUI/KodeUI.u2019.csproj b/KodeUI/KodeUI.u2019.csproj new file mode 100644 index 0000000..a0a48b4 --- /dev/null +++ b/KodeUI/KodeUI.u2019.csproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + {3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8} + Library + KodeUI + KodeUI + v4.5 + ..\obj\u2019 + + + true + full + false + ..\bin\Debug + DEBUG; + prompt + 4 + false + + + true + ..\bin\Release + prompt + 4 + false + + + + + ..\..\..\..\..\LIB\managed\1.8.1\UnityEngine.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\Assembly-CSharp.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\Assembly-CSharp-firstpass.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\UnityEngine.CoreModule.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\UnityEngine.UI.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\UnityEngine.UIElementsModule.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\UnityEngine.UIModule.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\UnityEngine.IMGUIModule.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\UnityEngine.TextRenderingModule.dll + False + + + ..\..\..\..\..\LIB\managed\1.8.1\UnityEngine.Physics2DModule.dll + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/KodeUI/Properties/AssemblyInfo.cs b/KodeUI/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b8138ba --- /dev/null +++ b/KodeUI/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("KodeUI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("${AuthorCopyright}")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] From ed05b7ad14cfbc2185a81886541ebe632779fa8b Mon Sep 17 00:00:00 2001 From: Lisias T Date: Sun, 10 Sep 2023 09:52:12 -0300 Subject: [PATCH 3/3] Adding a Unity 2017 Project; Butchering the KodeUI-Unity with #if #endif to cope with API differences that coudln't be handled with Extensions (Extensions with Properties were added only on C# from 2022 and newer, as it appears). --- KodeUI-Unity/Assets/KodeUI/Style.cs | 6 +- KodeUI-Unity/Assets/KodeUI/TreeView.cs | 4 ++ KodeUI.sln | 2 +- KodeUI/KodeUI.u2017.csproj | 98 ++++++++++++++++++++++++++ KodeUI/KodeUI.u2019.csproj | 4 +- KodeUI/Utils/ToggleExtensions.cs | 31 ++++++++ KodeUI/Utils/ToggleGroupExtensions.cs | 31 ++++++++ 7 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 KodeUI/KodeUI.u2017.csproj create mode 100644 KodeUI/Utils/ToggleExtensions.cs create mode 100644 KodeUI/Utils/ToggleGroupExtensions.cs diff --git a/KodeUI-Unity/Assets/KodeUI/Style.cs b/KodeUI-Unity/Assets/KodeUI/Style.cs index 7bd0a5d..d817d35 100644 --- a/KodeUI-Unity/Assets/KodeUI/Style.cs +++ b/KodeUI-Unity/Assets/KodeUI/Style.cs @@ -85,7 +85,9 @@ static RectOffset ParseRectOffset (string str) colorBlock.pressedColor = c; }} {if (ParseColor(node.GetValue ("selectedColor")) is Color c) { - colorBlock.selectedColor = c; +#if U2019 + colorBlock.selectedColor = c; +#endif }} {if (ParseColor(node.GetValue ("disabledColor")) is Color c) { colorBlock.disabledColor = c; @@ -113,7 +115,9 @@ static RectOffset ParseRectOffset (string str) sprites.pressedSprite = s; }} {if (SpriteLoader.GetSprite (node.GetValue ("selectedSprite")) is Sprite s) { +#if U2019 sprites.selectedSprite = s; +#endif }} {if (SpriteLoader.GetSprite (node.GetValue ("disabledSprite")) is Sprite s) { sprites.disabledSprite = s; diff --git a/KodeUI-Unity/Assets/KodeUI/TreeView.cs b/KodeUI-Unity/Assets/KodeUI/TreeView.cs index b6a6fba..c34904d 100644 --- a/KodeUI-Unity/Assets/KodeUI/TreeView.cs +++ b/KodeUI-Unity/Assets/KodeUI/TreeView.cs @@ -171,7 +171,11 @@ void SetSelectionState (bool instant) } } else { if (selected) { +#if U2017 + tintColor = colors.pressedColor; +#else tintColor = colors.selectedColor; +#endif } else { tintColor = colors.normalColor; } diff --git a/KodeUI.sln b/KodeUI.sln index 968cdfc..eae015d 100644 --- a/KodeUI.sln +++ b/KodeUI.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.810.25 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KodeUI.u2918", "KodeUI/KodeUI.u2019.csproj", "{3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KodeUI.u2017", "KodeUI\KodeUI.u2017.csproj", "{3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/KodeUI/KodeUI.u2017.csproj b/KodeUI/KodeUI.u2017.csproj new file mode 100644 index 0000000..3f50f97 --- /dev/null +++ b/KodeUI/KodeUI.u2017.csproj @@ -0,0 +1,98 @@ + + + + Debug + AnyCPU + {3C4F5F45-D5A4-4C96-84D9-86ECF68DB7A8} + Library + KodeUI + KodeUI + v4.5 + ..\obj\u2017 + KodeUI.u2017 + + + true + full + false + ..\bin\Debug + U2017;DEBUG; + prompt + 4 + false + + + true + ..\bin\Release + U2017 + prompt + 4 + false + + + + + ..\..\..\..\..\LIB\managed\1.4.1\Assembly-CSharp-firstpass.dll + False + + + ..\..\..\..\..\LIB\managed\1.4.1\Assembly-CSharp.dll + False + + + ..\..\..\..\..\LIB\managed\1.4.1\UnityEngine.dll + False + + + ..\..\..\..\..\LIB\managed\1.4.1\UnityEngine.UI.dll + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/KodeUI/KodeUI.u2019.csproj b/KodeUI/KodeUI.u2019.csproj index a0a48b4..5f8e43e 100644 --- a/KodeUI/KodeUI.u2019.csproj +++ b/KodeUI/KodeUI.u2019.csproj @@ -9,13 +9,14 @@ KodeUI v4.5 ..\obj\u2019 + KodeUI.u2019 true full false ..\bin\Debug - DEBUG; + U2019;DEBUG; prompt 4 false @@ -23,6 +24,7 @@ true ..\bin\Release + U2019 prompt 4 false diff --git a/KodeUI/Utils/ToggleExtensions.cs b/KodeUI/Utils/ToggleExtensions.cs new file mode 100644 index 0000000..5639dff --- /dev/null +++ b/KodeUI/Utils/ToggleExtensions.cs @@ -0,0 +1,31 @@ +using System.Reflection; + +namespace KodeUI +{ + // Based on https://forum.unity.com/threads/change-the-value-of-a-toggle-without-triggering-onvaluechanged.275056/#post-2307765 + public static class ToggleExtensions + { + static MethodInfo toggleSetMethod; + + static ToggleExtensions() + { + MethodInfo[] methods = typeof(UnityEngine.UI.Toggle).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance); + for (var i = 0;i < methods.Length;i++) + { + if (methods[i].Name == "Set" && methods[i].GetParameters().Length == 2) + { + toggleSetMethod = methods[i]; + break; + } + } + } + public static void Set(this UnityEngine.UI.Toggle instance, bool value, bool sendCallback) + { + toggleSetMethod.Invoke(instance, new object[] { value, sendCallback }); + } + public static void SetIsOnWithoutNotify(this UnityEngine.UI.Toggle instance, bool value) + { + toggleSetMethod.Invoke(instance, new object[] { value, false }); + } + } +} diff --git a/KodeUI/Utils/ToggleGroupExtensions.cs b/KodeUI/Utils/ToggleGroupExtensions.cs new file mode 100644 index 0000000..0054c46 --- /dev/null +++ b/KodeUI/Utils/ToggleGroupExtensions.cs @@ -0,0 +1,31 @@ +using System.Reflection; + +namespace KodeUI +{ + public static class ToggleGroupExtensions + { + static MethodInfo toggleSetMethod; + + static ToggleGroupExtensions() + { + MethodInfo[] methods = typeof(UnityEngine.UI.ToggleGroup).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance); + for (var i = 0;i < methods.Length;i++) + { + if (methods[i].Name == "Set" && methods[i].GetParameters().Length == 2) + { + toggleSetMethod = methods[i]; + break; + } + } + } + public static void Set(this UnityEngine.UI.ToggleGroup instance, bool value, bool sendCallback) + { + toggleSetMethod.Invoke(instance, new object[] { value, sendCallback }); + } + public static void SetAllTogglesOff(this UnityEngine.UI.ToggleGroup instance, bool value) + { + foreach (UnityEngine.UI.Toggle i in instance.ActiveToggles()) + i.Set(false, value); + } + } +}