├── .gitattributes ├── .gitignore ├── Generated Files ├── App.g.h ├── App.g.hpp ├── App.xaml ├── App.xbf ├── Overlay.g.h ├── Overlay.g.hpp ├── Overlay.xaml ├── Overlay.xbf ├── XamlBindingInfo.g.h ├── XamlBindingInfo.g.hpp ├── XamlLibMetadataProvider.g.cpp ├── XamlMetaDataProvider.cpp ├── XamlMetaDataProvider.h ├── XamlMetaDataProvider.idl ├── XamlTypeInfo.Impl.g.cpp ├── XamlTypeInfo.g.cpp ├── XamlTypeInfo.g.h └── sources │ ├── XamlMetaDataProvider.cpp │ └── XamlMetaDataProvider.h ├── Images ├── 1.png ├── OverlayApp.png └── Widget.png ├── Include └── json.hpp ├── Instructions.md ├── LICENSE ├── Overlay ├── App.xaml ├── App.xaml.cpp ├── App.xaml.h ├── Assets │ ├── LargeTile.scale-100.png │ ├── LargeTile.scale-125.png │ ├── LargeTile.scale-150.png │ ├── LargeTile.scale-200.png │ ├── LargeTile.scale-400.png │ ├── LockScreenLogo.scale-200.png │ ├── SmallTile.scale-100.png │ ├── SmallTile.scale-125.png │ ├── SmallTile.scale-150.png │ ├── SmallTile.scale-200.png │ ├── SmallTile.scale-400.png │ ├── SplashScreen.scale-100.png │ ├── SplashScreen.scale-125.png │ ├── SplashScreen.scale-150.png │ ├── SplashScreen.scale-200.png │ ├── SplashScreen.scale-400.png │ ├── Square150x150Logo.scale-100.png │ ├── Square150x150Logo.scale-125.png │ ├── Square150x150Logo.scale-150.png │ ├── Square150x150Logo.scale-200.png │ ├── Square150x150Logo.scale-400.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-16.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-24.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-256.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-32.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-48.png │ ├── Square44x44Logo.altform-unplated_targetsize-16.png │ ├── Square44x44Logo.altform-unplated_targetsize-256.png │ ├── Square44x44Logo.altform-unplated_targetsize-32.png │ ├── Square44x44Logo.altform-unplated_targetsize-48.png │ ├── Square44x44Logo.scale-100.png │ ├── Square44x44Logo.scale-125.png │ ├── Square44x44Logo.scale-150.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.scale-400.png │ ├── Square44x44Logo.targetsize-16.png │ ├── Square44x44Logo.targetsize-24.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── Square44x44Logo.targetsize-256.png │ ├── Square44x44Logo.targetsize-32.png │ ├── Square44x44Logo.targetsize-48.png │ ├── StoreLogo.backup.png │ ├── StoreLogo.png │ ├── StoreLogo.scale-100.png │ ├── StoreLogo.scale-125.png │ ├── StoreLogo.scale-150.png │ ├── StoreLogo.scale-200.png │ ├── StoreLogo.scale-400.png │ ├── Wide310x150Logo.scale-100.png │ ├── Wide310x150Logo.scale-125.png │ ├── Wide310x150Logo.scale-150.png │ ├── Wide310x150Logo.scale-200.png │ └── Wide310x150Logo.scale-400.png ├── Graphics │ ├── Drawing.cpp │ ├── Drawing.h │ ├── Entities │ │ ├── Button.cpp │ │ ├── Button.h │ │ ├── ColourPicker.cpp │ │ ├── ColourPicker.h │ │ ├── ComboBox.cpp │ │ ├── ComboBox.h │ │ ├── DropDown.cpp │ │ ├── DropDown.h │ │ ├── Entity.cpp │ │ ├── Entity.h │ │ ├── Form.cpp │ │ ├── Form.h │ │ ├── GroupBox.cpp │ │ ├── GroupBox.h │ │ ├── KeyBind.cpp │ │ ├── KeyBind.h │ │ ├── Label.cpp │ │ ├── Label.h │ │ ├── Slider.h │ │ ├── Tab.cpp │ │ ├── Tab.h │ │ ├── TabController.cpp │ │ ├── TabController.h │ │ ├── TabListBox.cpp │ │ ├── TabListBox.h │ │ ├── TabListBoxController.cpp │ │ ├── TabListBoxController.h │ │ ├── TextBox.cpp │ │ ├── TextBox.h │ │ ├── Toggle.cpp │ │ └── Toggle.h │ ├── Graphics.h │ ├── Start Up │ │ ├── GUI.cpp │ │ └── GUI.h │ └── Utility │ │ ├── Animation.cpp │ │ ├── Animation.h │ │ ├── Colour.cpp │ │ ├── Colour.h │ │ ├── Font.cpp │ │ └── Font.h ├── Images │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png ├── Misc │ ├── Input.cpp │ ├── Input.h │ ├── Pch │ │ ├── pch.cpp │ │ └── pch.h │ ├── Vector.cpp │ └── Vector.h ├── Overlay.vcxproj ├── Overlay.vcxproj.filters ├── Overlay.xaml ├── Overlay.xaml.cpp ├── Overlay.xaml.h ├── Package.appxmanifest └── packages.config ├── OverlayGUI.sln ├── README.md └── installer script.bat /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Generated Files/App.g.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | //------------------------------------------------------------------------------ 8 | 9 | #include "XamlTypeInfo.g.h" 10 | 11 | namespace Cheat 12 | { 13 | partial ref class App : public ::Windows::UI::Xaml::Application, 14 | public ::Windows::UI::Xaml::Markup::IXamlMetadataProvider 15 | { 16 | public: 17 | void InitializeComponent(); 18 | [::Windows::Foundation::Metadata::DefaultOverload] 19 | virtual ::Windows::UI::Xaml::Markup::IXamlType^ GetXamlType(::Windows::UI::Xaml::Interop::TypeName type); 20 | virtual ::Windows::UI::Xaml::Markup::IXamlType^ GetXamlType(::Platform::String^ fullName); 21 | virtual ::Platform::Array<::Windows::UI::Xaml::Markup::XmlnsDefinition>^ GetXmlnsDefinitions(); 22 | private: 23 | ::XamlTypeInfo::InfoProvider::XamlTypeInfoProvider^ __provider; 24 | bool _contentLoaded; 25 | property ::XamlTypeInfo::InfoProvider::XamlTypeInfoProvider^ _AppProvider 26 | { 27 | ::XamlTypeInfo::InfoProvider::XamlTypeInfoProvider^ get(); 28 | } 29 | }; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Generated Files/App.g.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // This code was generated by a tool. 3 | // 4 | // Changes to this file may cause incorrect behavior and will be lost if 5 | // the code is regenerated. 6 | //------------------------------------------------------------------------------ 7 | 8 | #include "pch.h" 9 | #include "App.xaml.h" 10 | 11 | 12 | #if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION 13 | extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); 14 | #endif 15 | 16 | 17 | #if (defined(_M_IX86) || defined(_M_AMD64)) && !defined(_VSDESIGNER_DONT_LOAD_AS_DLL) 18 | #if defined(_M_IX86) 19 | #pragma comment(linker, "/EXPORT:DllGetActivationFactory=_DllGetActivationFactory@8,PRIVATE") 20 | #pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow@0,PRIVATE") 21 | #pragma comment(linker, "/EXPORT:VSDesignerDllMain=_VSDesignerDllMain@12,PRIVATE") 22 | #pragma comment(linker, "/INCLUDE:___refMTAThread") 23 | #elif defined(_M_AMD64) 24 | #pragma comment(linker, "/EXPORT:DllGetActivationFactory=DllGetActivationFactory,PRIVATE") 25 | #pragma comment(linker, "/EXPORT:DllCanUnloadNow,PRIVATE") 26 | #pragma comment(linker, "/EXPORT:VSDesignerDllMain,PRIVATE") 27 | #pragma comment(linker, "/INCLUDE:__refMTAThread") 28 | #endif 29 | 30 | extern int __abi___threading_model; 31 | 32 | extern "C" 33 | { 34 | int __stdcall _DllMainCRTStartup(void* hinstDLL, unsigned long fdwReason, void** lpvReserved); 35 | 36 | int __stdcall VSDesignerDllMain(void* hinstDLL, unsigned long fdwReason, void** lpvReserved) 37 | { 38 | __abi___threading_model = _VCCORLIB_THREADING_MODEL_OVERRIDE; 39 | return _DllMainCRTStartup(hinstDLL, fdwReason, lpvReserved); 40 | } 41 | } 42 | 43 | #endif // (defined(_M_IX86) || defined(_M_AMD64)) && !defined(_VSDESIGNER_DONT_LOAD_AS_DLL) 44 | 45 | void ::Cheat::App::InitializeComponent() 46 | { 47 | #if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION 48 | UnhandledException += ref new ::Windows::UI::Xaml::UnhandledExceptionEventHandler( 49 | [](::Platform::Object^ sender, ::Windows::UI::Xaml::UnhandledExceptionEventArgs^ e) 50 | { 51 | (void)sender; // Unused parameter 52 | if (IsDebuggerPresent()) 53 | { 54 | ::Platform::String^ errorMessage = e->Message; 55 | __debugbreak(); 56 | } 57 | }); 58 | #endif 59 | } 60 | 61 | ::Windows::UI::Xaml::Markup::IXamlType^ ::Cheat::App::GetXamlType(::Windows::UI::Xaml::Interop::TypeName type) 62 | { 63 | return _AppProvider->GetXamlTypeByType(type); 64 | } 65 | 66 | ::Windows::UI::Xaml::Markup::IXamlType^ ::Cheat::App::GetXamlType(::Platform::String^ fullName) 67 | { 68 | return _AppProvider->GetXamlTypeByName(fullName); 69 | } 70 | 71 | ::Platform::Array<::Windows::UI::Xaml::Markup::XmlnsDefinition>^ ::Cheat::App::GetXmlnsDefinitions() 72 | { 73 | return ref new ::Platform::Array<::Windows::UI::Xaml::Markup::XmlnsDefinition>(0); 74 | } 75 | 76 | ::XamlTypeInfo::InfoProvider::XamlTypeInfoProvider^ ::Cheat::App::_AppProvider::get() 77 | { 78 | if (__provider == nullptr) 79 | { 80 | __provider = ref new ::XamlTypeInfo::InfoProvider::XamlTypeInfoProvider(); 81 | } 82 | return __provider; 83 | } 84 | 85 | #ifndef DISABLE_XAML_GENERATED_MAIN 86 | int __cdecl main(::Platform::Array<::Platform::String^>^ args) 87 | { 88 | (void)args; // Unused parameter 89 | ::Windows::UI::Xaml::Application::Start(ref new ::Windows::UI::Xaml::ApplicationInitializationCallback( 90 | [](::Windows::UI::Xaml::ApplicationInitializationCallbackParams^ p) { 91 | (void)p; // Unused parameter 92 | auto app = ref new ::Cheat::App(); 93 | })); 94 | } 95 | #endif 96 | 97 | 98 | -------------------------------------------------------------------------------- /Generated Files/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | -------------------------------------------------------------------------------- /Generated Files/App.xbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Generated Files/App.xbf -------------------------------------------------------------------------------- /Generated Files/Overlay.g.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | //------------------------------------------------------------------------------ 8 | 9 | 10 | namespace Microsoft { 11 | namespace Graphics { 12 | namespace Canvas { 13 | namespace UI { 14 | namespace Xaml { 15 | ref class CanvasSwapChainPanel; 16 | } 17 | } 18 | } 19 | } 20 | } 21 | 22 | namespace Cheat 23 | { 24 | [::Windows::Foundation::Metadata::WebHostHidden] 25 | partial ref class Overlay : public ::Windows::UI::Xaml::Controls::Page, 26 | public ::Windows::UI::Xaml::Markup::IComponentConnector, 27 | public ::Windows::UI::Xaml::Markup::IComponentConnector2 28 | { 29 | public: 30 | void InitializeComponent(); 31 | virtual void Connect(int connectionId, ::Platform::Object^ target); 32 | virtual ::Windows::UI::Xaml::Markup::IComponentConnector^ GetBindingConnector(int connectionId, ::Platform::Object^ target); 33 | 34 | private: 35 | void UnloadObject(::Windows::UI::Xaml::DependencyObject^ dependencyObject); 36 | void DisconnectUnloadedObject(int connectionId); 37 | 38 | private: 39 | bool _contentLoaded; 40 | 41 | class Overlay_obj1_Bindings; 42 | 43 | private: ::Microsoft::Graphics::Canvas::UI::Xaml::CanvasSwapChainPanel^ SwapChainPanel; 44 | }; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Generated Files/Overlay.g.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // This code was generated by a tool. 3 | // 4 | // Changes to this file may cause incorrect behavior and will be lost if 5 | // the code is regenerated. 6 | //------------------------------------------------------------------------------ 7 | #include "pch.h" 8 | 9 | #pragma warning(push) 10 | #pragma warning(disable: 4100) // unreferenced formal parameter 11 | 12 | #if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BINDING_DEBUG_OUTPUT 13 | extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); 14 | #endif 15 | 16 | #include "Overlay.xaml.h" 17 | 18 | void ::Cheat::Overlay::InitializeComponent() 19 | { 20 | if (_contentLoaded) 21 | { 22 | return; 23 | } 24 | _contentLoaded = true; 25 | ::Windows::Foundation::Uri^ resourceLocator = ref new ::Windows::Foundation::Uri(L"ms-appx:///Overlay.xaml"); 26 | ::Windows::UI::Xaml::Application::LoadComponent(this, resourceLocator, ::Windows::UI::Xaml::Controls::Primitives::ComponentResourceLocation::Application); 27 | } 28 | 29 | void ::Cheat::Overlay::Connect(int __connectionId, ::Platform::Object^ __target) 30 | { 31 | switch (__connectionId) 32 | { 33 | case 2: 34 | { 35 | this->SwapChainPanel = safe_cast<::Microsoft::Graphics::Canvas::UI::Xaml::CanvasSwapChainPanel^>(__target); 36 | (safe_cast<::Microsoft::Graphics::Canvas::UI::Xaml::CanvasSwapChainPanel^>(this->SwapChainPanel))->Loaded += ref new ::Windows::UI::Xaml::RoutedEventHandler(this, (void (::Cheat::Overlay::*) 37 | (::Platform::Object^, ::Windows::UI::Xaml::RoutedEventArgs^))&Overlay::SwapChainPanel_Loaded); 38 | (safe_cast<::Microsoft::Graphics::Canvas::UI::Xaml::CanvasSwapChainPanel^>(this->SwapChainPanel))->PointerMoved += ref new ::Windows::UI::Xaml::Input::PointerEventHandler(this, (void (::Cheat::Overlay::*) 39 | (::Platform::Object^, ::Windows::UI::Xaml::Input::PointerRoutedEventArgs^))&Overlay::PointerMoved); 40 | (safe_cast<::Microsoft::Graphics::Canvas::UI::Xaml::CanvasSwapChainPanel^>(this->SwapChainPanel))->PointerPressed += ref new ::Windows::UI::Xaml::Input::PointerEventHandler(this, (void (::Cheat::Overlay::*) 41 | (::Platform::Object^, ::Windows::UI::Xaml::Input::PointerRoutedEventArgs^))&Overlay::PointerPressed); 42 | (safe_cast<::Microsoft::Graphics::Canvas::UI::Xaml::CanvasSwapChainPanel^>(this->SwapChainPanel))->PointerReleased += ref new ::Windows::UI::Xaml::Input::PointerEventHandler(this, (void (::Cheat::Overlay::*) 43 | (::Platform::Object^, ::Windows::UI::Xaml::Input::PointerRoutedEventArgs^))&Overlay::PointerReleased); 44 | } 45 | break; 46 | } 47 | _contentLoaded = true; 48 | } 49 | 50 | ::Windows::UI::Xaml::Markup::IComponentConnector^ ::Cheat::Overlay::GetBindingConnector(int __connectionId, ::Platform::Object^ __target) 51 | { 52 | __connectionId; // unreferenced 53 | __target; // unreferenced 54 | return nullptr; 55 | } 56 | 57 | #pragma warning(pop) 58 | 59 | 60 | -------------------------------------------------------------------------------- /Generated Files/Overlay.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Generated Files/Overlay.xbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Generated Files/Overlay.xbf -------------------------------------------------------------------------------- /Generated Files/XamlBindingInfo.g.hpp: -------------------------------------------------------------------------------- 1 |  2 | //------------------------------------------------------------------------------ 3 | // 4 | // This code was generated by a tool. 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | #include "pch.h" 11 | #include "XamlBindingInfo.g.h" 12 | 13 | // XamlBindings 14 | 15 | ::XamlBindingInfo::XamlBindings::XamlBindings(::XamlBindingInfo::IXamlBindings* pBindings) 16 | : _pBindings(pBindings) 17 | { 18 | _pBindings->SetOwningBindingsClass(this); 19 | } 20 | 21 | ::XamlBindingInfo::XamlBindings::~XamlBindings() 22 | { 23 | delete _pBindings; 24 | } 25 | 26 | void ::XamlBindingInfo::XamlBindings::Initialize() 27 | { 28 | if (!this->_pBindings->IsInitialized()) 29 | { 30 | this->_pBindings->Update(); 31 | } 32 | } 33 | 34 | void ::XamlBindingInfo::XamlBindings::Update() 35 | { 36 | this->_pBindings->Update(); 37 | } 38 | 39 | void ::XamlBindingInfo::XamlBindings::StopTracking() 40 | { 41 | this->_pBindings->StopTracking(); 42 | } 43 | 44 | void ::XamlBindingInfo::XamlBindings::Loading(::Windows::UI::Xaml::FrameworkElement^, ::Platform::Object^) 45 | { 46 | this->Initialize(); 47 | } 48 | 49 | void ::XamlBindingInfo::XamlBindings::DataContextChanged(::Windows::UI::Xaml::FrameworkElement^, ::Windows::UI::Xaml::DataContextChangedEventArgs^ args) 50 | { 51 | if (this->_pBindings->SetDataRoot(args->NewValue)) 52 | { 53 | this->Update(); 54 | } 55 | } 56 | 57 | void ::XamlBindingInfo::XamlBindings::SubscribeForDataContextChanged(::Windows::UI::Xaml::FrameworkElement^ object) 58 | { 59 | this->_pBindings->SubscribeForDataContextChanged(object, this); 60 | } 61 | 62 | void ::XamlBindingInfo::XamlBindings::DisconnectUnloadedObject(int connectionId) 63 | { 64 | this->_pBindings->DisconnectUnloadedObject(connectionId); 65 | } 66 | 67 | void ::XamlBindingInfo::XamlBindings::Connect(int connectionId, ::Platform::Object^ target) 68 | { 69 | this->_pBindings->Connect(connectionId, target); 70 | } 71 | 72 | bool ::XamlBindingInfo::XamlBindings::ProcessBinding(unsigned int) 73 | { 74 | throw ref new ::Platform::NotImplementedException(); 75 | } 76 | 77 | int ::XamlBindingInfo::XamlBindings::ProcessBindings(::Windows::UI::Xaml::Controls::ContainerContentChangingEventArgs^ args) 78 | { 79 | int nextPhase = -1; 80 | int phase = static_cast(args->Phase); 81 | if (phase < 0) 82 | { 83 | throw ref new ::Platform::InvalidArgumentException(); 84 | } 85 | this->_pBindings->ProcessBindings(args->Item, args->ItemIndex, phase, &nextPhase); 86 | return nextPhase; 87 | } 88 | 89 | void ::XamlBindingInfo::XamlBindings::ResetTemplate() 90 | { 91 | this->_pBindings->Recycle(); 92 | } 93 | 94 | void ::XamlBindingInfo::XamlBindings::ProcessBindings(::Platform::Object^ item, int itemIndex, int phase, int* nextPhase) 95 | { 96 | this->_pBindings->ProcessBindings(item, itemIndex, phase, nextPhase); 97 | } 98 | 99 | void ::XamlBindingInfo::XamlBindings::Recycle() 100 | { 101 | this->_pBindings->Recycle(); 102 | } 103 | 104 | void ::XamlBindingInfo::XamlBindings::Disable(int lineNumber, int columnNumber) 105 | { 106 | this->_pBindings->Disable(lineNumber, columnNumber); 107 | } 108 | 109 | ::Windows::UI::Xaml::Markup::IComponentConnector^ ::XamlBindingInfo::XamlBindings::GetBindingConnector(int connectionId, ::Platform::Object^ target) 110 | { 111 | return this->_pBindings->GetBindingConnector(connectionId, target); 112 | } 113 | 114 | ::XamlBindingInfo::XamlBindings^ ::XamlBindingInfo::XamlBindings::GetParent() 115 | { 116 | return this->_pBindings->GetParent(); 117 | } 118 | 119 | void ::XamlBindingInfo::XamlBindings::SetParent(::XamlBindingInfo::XamlBindings^ parent) 120 | { 121 | this->_pBindings->SetParent(parent); 122 | } 123 | 124 | bool ::XamlBindingInfo::XamlBindings::ContainsElement(int connectionId) 125 | { 126 | return this->_pBindings->ContainsElement(connectionId); 127 | } 128 | 129 | void ::XamlBindingInfo::XamlBindings::RegisterForElementConnection(int connectionId, ::XamlBindingInfo::XamlBindings^ connector) 130 | { 131 | this->_pBindings->RegisterForElementConnection(connectionId, connector); 132 | } 133 | 134 | // XamlBindingTrackingBase 135 | 136 | ::XamlBindingInfo::XamlBindingTrackingBase::XamlBindingTrackingBase() 137 | { 138 | } 139 | 140 | void ::XamlBindingInfo::XamlBindingTrackingBase::SetListener(::XamlBindingInfo::IXamlBindingTracking* pBindings) 141 | { 142 | this->_pBindingsTrackingWeakRef = pBindings; 143 | } 144 | 145 | void ::XamlBindingInfo::XamlBindingTrackingBase::PropertyChanged(Platform::Object^ sender, ::Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e) 146 | { 147 | if (this->_pBindingsTrackingWeakRef != nullptr) 148 | { 149 | this->_pBindingsTrackingWeakRef->PropertyChanged(sender, e); 150 | } 151 | } 152 | 153 | void ::XamlBindingInfo::XamlBindingTrackingBase::CollectionChanged(::Platform::Object^ sender, ::Windows::UI::Xaml::Interop::NotifyCollectionChangedEventArgs^ e) 154 | { 155 | if (this->_pBindingsTrackingWeakRef != nullptr) 156 | { 157 | this->_pBindingsTrackingWeakRef->CollectionChanged(sender, e); 158 | } 159 | } 160 | 161 | void ::XamlBindingInfo::XamlBindingTrackingBase::DependencyPropertyChanged(::Windows::UI::Xaml::DependencyObject^ sender, ::Windows::UI::Xaml::DependencyProperty^ prop) 162 | { 163 | if (this->_pBindingsTrackingWeakRef != nullptr) 164 | { 165 | this->_pBindingsTrackingWeakRef->DependencyPropertyChanged(sender, prop); 166 | } 167 | } 168 | 169 | void ::XamlBindingInfo::XamlBindingTrackingBase::VectorChanged(::Platform::Object^ sender, ::Windows::Foundation::Collections::IVectorChangedEventArgs^ e) 170 | { 171 | if (this->_pBindingsTrackingWeakRef != nullptr) 172 | { 173 | this->_pBindingsTrackingWeakRef->VectorChanged(sender, e); 174 | } 175 | } 176 | 177 | void ::XamlBindingInfo::XamlBindingTrackingBase::MapChanged(::Platform::Object^ sender, ::Windows::Foundation::Collections::IMapChangedEventArgs<::Platform::String^>^ e) 178 | { 179 | if (this->_pBindingsTrackingWeakRef != nullptr) 180 | { 181 | this->_pBindingsTrackingWeakRef->MapChanged(sender, e); 182 | } 183 | } 184 | 185 | void ::XamlBindingInfo::XamlBindingTrackingBase::UpdatePropertyChangedListener(::Windows::UI::Xaml::Data::INotifyPropertyChanged^ obj, ::Windows::UI::Xaml::Data::INotifyPropertyChanged^* pCache, ::Windows::Foundation::EventRegistrationToken* pToken) 186 | { 187 | if (*pCache != nullptr && !(*pCache)->Equals(obj)) 188 | { 189 | (*pCache)->PropertyChanged -= *pToken; 190 | *pCache = nullptr; 191 | } 192 | 193 | if (*pCache == nullptr && obj != nullptr) 194 | { 195 | *pCache = obj; 196 | *pToken = obj->PropertyChanged += ref new ::Windows::UI::Xaml::Data::PropertyChangedEventHandler( 197 | this, &::XamlBindingInfo::XamlBindingTrackingBase::PropertyChanged); 198 | } 199 | } 200 | 201 | void ::XamlBindingInfo::XamlBindingTrackingBase::UpdatePropertyChangedListener(::Windows::UI::Xaml::Data::INotifyPropertyChanged^ obj, ::Platform::WeakReference& cacheRef, ::Windows::Foundation::EventRegistrationToken* pToken) 202 | { 203 | ::Windows::UI::Xaml::Data::INotifyPropertyChanged^ cache = cacheRef.Resolve<::Windows::UI::Xaml::Data::INotifyPropertyChanged>(); 204 | if (cache != nullptr && !cache->Equals(obj)) 205 | { 206 | cache->PropertyChanged -= *pToken; 207 | cache = nullptr; 208 | cacheRef = nullptr; 209 | } 210 | 211 | if (cache == nullptr && obj != nullptr) 212 | { 213 | cacheRef = cache = obj; 214 | *pToken = obj->PropertyChanged += ref new ::Windows::UI::Xaml::Data::PropertyChangedEventHandler( 215 | this, &::XamlBindingInfo::XamlBindingTrackingBase::PropertyChanged); 216 | } 217 | } 218 | 219 | void ::XamlBindingInfo::XamlBindingTrackingBase::UpdateCollectionChangedListener(::Windows::UI::Xaml::Interop::INotifyCollectionChanged^ obj, ::Windows::UI::Xaml::Interop::INotifyCollectionChanged^* pCache, ::Windows::Foundation::EventRegistrationToken* pToken) 220 | { 221 | if (*pCache != nullptr && !(*pCache)->Equals(obj)) 222 | { 223 | (*pCache)->CollectionChanged -= *pToken; 224 | *pCache = nullptr; 225 | } 226 | 227 | if (*pCache == nullptr && obj != nullptr) 228 | { 229 | *pCache = obj; 230 | *pToken = obj->CollectionChanged += ref new ::Windows::UI::Xaml::Interop::NotifyCollectionChangedEventHandler( 231 | this, &::XamlBindingInfo::XamlBindingTrackingBase::CollectionChanged); 232 | } 233 | } 234 | 235 | void ::XamlBindingInfo::XamlBindingTrackingBase::UpdateDependencyPropertyChangedListener(::Windows::UI::Xaml::DependencyObject^ obj, ::Windows::UI::Xaml::DependencyProperty^ property, ::Windows::UI::Xaml::DependencyObject^* pCache, __int64* pToken) 236 | { 237 | if (*pCache != nullptr && !(*pCache)->Equals(obj)) 238 | { 239 | (*pCache)->UnregisterPropertyChangedCallback(property, *pToken); 240 | *pCache = nullptr; 241 | } 242 | 243 | if (*pCache == nullptr && obj != nullptr) 244 | { 245 | *pCache = obj; 246 | *pToken = obj->RegisterPropertyChangedCallback(property, ref new ::Windows::UI::Xaml::DependencyPropertyChangedCallback( 247 | this, &::XamlBindingInfo::XamlBindingTrackingBase::DependencyPropertyChanged)); 248 | } 249 | } 250 | 251 | void ::XamlBindingInfo::XamlBindingTrackingBase::UpdateDependencyPropertyChangedListener(::Windows::UI::Xaml::DependencyObject^ obj, ::Windows::UI::Xaml::DependencyProperty^ property, ::Platform::WeakReference& cacheRef, __int64* pToken) 252 | { 253 | ::Windows::UI::Xaml::DependencyObject^ cache = cacheRef.Resolve<::Windows::UI::Xaml::DependencyObject>(); 254 | if (cache != nullptr && !cache->Equals(obj)) 255 | { 256 | cache->UnregisterPropertyChangedCallback(property, *pToken); 257 | cache = nullptr; 258 | cacheRef = nullptr; 259 | } 260 | 261 | if (cache == nullptr && obj != nullptr) 262 | { 263 | cacheRef = cache = obj; 264 | *pToken = obj->RegisterPropertyChangedCallback(property, ref new ::Windows::UI::Xaml::DependencyPropertyChangedCallback( 265 | this, &::XamlBindingInfo::XamlBindingTrackingBase::DependencyPropertyChanged)); 266 | } 267 | } 268 | 269 | -------------------------------------------------------------------------------- /Generated Files/XamlLibMetadataProvider.g.cpp: -------------------------------------------------------------------------------- 1 |  2 | #include "pch.h" 3 | -------------------------------------------------------------------------------- /Generated Files/XamlMetaDataProvider.cpp: -------------------------------------------------------------------------------- 1 | // This file is generated by the build to support Xaml apps 2 | #include "pch.h" 3 | #include "XamlMetaDataProvider.h" 4 | #include "XamlMetaDataProvider.g.cpp" 5 | -------------------------------------------------------------------------------- /Generated Files/XamlMetaDataProvider.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "XamlTypeInfo.xaml.g.h" 16 | #include "XamlMetaDataProvider.g.h" 17 | 18 | /* 19 | If the file above was not generated, you may be missing a declaration 20 | for the XamlMetaDataProvider runtimeclass in your IDL. 21 | 22 | namespace WidgetSampleCX 23 | { 24 | runtimeclass XamlMetaDataProvider : Windows.UI.Xaml.Markup.IXamlMetadataProvider 25 | { 26 | XamlMetaDataProvider(); 27 | }; 28 | } 29 | */ 30 | 31 | namespace winrt::WidgetSampleCX::implementation 32 | { 33 | using IXamlMember = ::winrt::Windows::UI::Xaml::Markup::IXamlMember; 34 | using IXamlType = ::winrt::Windows::UI::Xaml::Markup::IXamlType; 35 | 36 | struct XamlMetaDataProvider : public ::winrt::WidgetSampleCX::implementation::XamlMetaDataProvider_base 37 | { 38 | IXamlType GetXamlType(::winrt::Windows::UI::Xaml::Interop::TypeName const& type); 39 | IXamlType GetXamlType(::winrt::hstring const& fullName); 40 | ::winrt::com_array<::winrt::Windows::UI::Xaml::Markup::XmlnsDefinition> GetXmlnsDefinitions(); 41 | 42 | private: 43 | std::shared_ptr _provider; 44 | std::shared_ptr Provider(); 45 | }; 46 | } 47 | 48 | namespace winrt::WidgetSampleCX::factory_implementation 49 | { 50 | struct XamlMetaDataProvider : XamlMetaDataProviderT 51 | { 52 | }; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Generated Files/XamlMetaDataProvider.idl: -------------------------------------------------------------------------------- 1 | // This file is generated by the build to support Xaml apps 2 | 3 | namespace WidgetSampleCX 4 | { 5 | runtimeclass XamlMetaDataProvider : [default] Windows.UI.Xaml.Markup.IXamlMetadataProvider 6 | { 7 | XamlMetaDataProvider(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Generated Files/sources/XamlMetaDataProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "XamlMetaDataProvider.h" 2 | 3 | // WARNING: This file is automatically generated by a tool. Do not directly 4 | // add this file to your project, as any changes you make will be lost. 5 | // This file is a stub you can use as a starting point for your implementation. 6 | // 7 | // To add a copy of this file to your project: 8 | // 1. Copy this file from its original location to the location where you store 9 | // your other source files (e.g. the project root). 10 | // 2. Add the copied file to your project. In Visual Studio, you can use 11 | // Project -> Add Existing Item. 12 | // 3. Delete this comment and the 'static_assert' (below) from the copied file. 13 | // Do not modify the original file. 14 | // 15 | // To update an existing file in your project: 16 | // 1. Copy the relevant changes from this file and merge them into the copy 17 | // you made previously. 18 | // 19 | // This assertion helps prevent accidental modification of generated files. 20 | static_assert(false, "This file is generated by a tool and will be overwritten. Open this error and view the comment for assistance."); 21 | 22 | namespace winrt::WidgetSampleCX::implementation 23 | { 24 | winrt::Windows::UI::Xaml::Markup::IXamlType XamlMetaDataProvider::GetXamlType(winrt::Windows::UI::Xaml::Interop::TypeName const& type) 25 | { 26 | throw hresult_not_implemented(); 27 | } 28 | winrt::Windows::UI::Xaml::Markup::IXamlType XamlMetaDataProvider::GetXamlType(hstring const& fullName) 29 | { 30 | throw hresult_not_implemented(); 31 | } 32 | com_array XamlMetaDataProvider::GetXmlnsDefinitions() 33 | { 34 | throw hresult_not_implemented(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Generated Files/sources/XamlMetaDataProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "XamlMetaDataProvider.g.h" 3 | 4 | // WARNING: This file is automatically generated by a tool. Do not directly 5 | // add this file to your project, as any changes you make will be lost. 6 | // This file is a stub you can use as a starting point for your implementation. 7 | // 8 | // To add a copy of this file to your project: 9 | // 1. Copy this file from its original location to the location where you store 10 | // your other source files (e.g. the project root). 11 | // 2. Add the copied file to your project. In Visual Studio, you can use 12 | // Project -> Add Existing Item. 13 | // 3. Delete this comment and the 'static_assert' (below) from the copied file. 14 | // Do not modify the original file. 15 | // 16 | // To update an existing file in your project: 17 | // 1. Copy the relevant changes from this file and merge them into the copy 18 | // you made previously. 19 | // 20 | // This assertion helps prevent accidental modification of generated files. 21 | static_assert(false, "This file is generated by a tool and will be overwritten. Open this error and view the comment for assistance."); 22 | 23 | namespace winrt::WidgetSampleCX::implementation 24 | { 25 | struct XamlMetaDataProvider : XamlMetaDataProviderT 26 | { 27 | XamlMetaDataProvider() = default; 28 | 29 | winrt::Windows::UI::Xaml::Markup::IXamlType GetXamlType(winrt::Windows::UI::Xaml::Interop::TypeName const& type); 30 | winrt::Windows::UI::Xaml::Markup::IXamlType GetXamlType(hstring const& fullName); 31 | com_array GetXmlnsDefinitions(); 32 | }; 33 | } 34 | namespace winrt::WidgetSampleCX::factory_implementation 35 | { 36 | struct XamlMetaDataProvider : XamlMetaDataProviderT 37 | { 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /Images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Images/1.png -------------------------------------------------------------------------------- /Images/OverlayApp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Images/OverlayApp.png -------------------------------------------------------------------------------- /Images/Widget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Images/Widget.png -------------------------------------------------------------------------------- /Instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | * Firstly you need to compile the solution. 3 | * If you encounter any issues then go into your visual studio installer and install UWP app support. 4 | * Copy the ```installer script.bat``` from the base project directory to ```Build\Debug``` OR ```Build\Release``` 5 | * Run the script 6 | * Once the script is installed click Win + G to open the GameBar 7 | * Open the widget menu(Left Side Of Top Interaction Bar) 8 | * Navigate down to the overlay app 9 | * Open it 10 | * If it doesn't full screen then close it and reopen it 11 |

12 | 14 |

15 |
16 |

17 | 19 |

20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 SDM 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Overlay/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | -------------------------------------------------------------------------------- /Overlay/App.xaml.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // App.xaml.cpp 3 | // Implementation of the App class. 4 | // 5 | 6 | #include "pch.h" 7 | #include "Overlay.xaml.h" 8 | #pragma comment(lib, "user32.lib") 9 | 10 | using namespace Cheat; 11 | 12 | using namespace Platform; 13 | using namespace Windows::ApplicationModel; 14 | using namespace Windows::ApplicationModel::Activation; 15 | using namespace Windows::Foundation; 16 | using namespace Windows::Foundation::Collections; 17 | using namespace Windows::UI::Xaml; 18 | using namespace Windows::UI::Xaml::Controls; 19 | using namespace Windows::UI::Xaml::Controls::Primitives; 20 | using namespace Windows::UI::Xaml::Data; 21 | using namespace Windows::UI::Xaml::Input; 22 | using namespace Windows::UI::Xaml::Interop; 23 | using namespace Windows::UI::Xaml::Media; 24 | using namespace Windows::UI::Xaml::Navigation; 25 | using namespace Microsoft::Gaming::XboxGameBar; 26 | 27 | using namespace Windows::Foundation; 28 | using namespace Windows::UI::Core; 29 | using namespace Windows::System; 30 | using namespace Windows::UI::ViewManagement; 31 | 32 | App::App() 33 | { 34 | InitializeComponent(); 35 | Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); 36 | 37 | } 38 | 39 | // Get the horizontal and vertical screen sizes in pixel 40 | void GetDesktopResolution(int& horizontal, int& vertical) 41 | { 42 | RECT desktop; 43 | // Get a handle to the desktop window 44 | const HWND hDesktop = GetDesktopWindow(); 45 | // Get the size of screen to the variable desktop 46 | GetWindowRect(hDesktop, &desktop); 47 | // The top left corner will have coordinates (0,0) 48 | // and the bottom right corner will have coordinates 49 | // (horizontal, vertical) 50 | horizontal = desktop.right; 51 | vertical = desktop.bottom; 52 | } 53 | 54 | void App::OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs^ e) 55 | { 56 | XboxGameBarWidgetActivatedEventArgs^ widgetArgs = nullptr; 57 | 58 | if (e->Kind == ActivationKind::Protocol) 59 | { 60 | auto protocolArgs = dynamic_cast(e); 61 | if (protocolArgs) 62 | { 63 | // If scheme name is ms-gamebarwidget, Xbox Game Bar is activating us. 64 | const wchar_t* scheme = protocolArgs->Uri->SchemeName->Data(); 65 | if (0 == wcscmp(scheme, L"ms-gamebarwidget")) 66 | { 67 | widgetArgs = dynamic_cast(e); 68 | } 69 | } 70 | } 71 | 72 | if (widgetArgs) 73 | { 74 | if (widgetArgs->IsLaunchActivation) 75 | { 76 | auto rootFrame = ref new Frame(); 77 | rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed); 78 | Window::Current->Content = rootFrame; 79 | 80 | // Create Game Bar widget object which bootstraps the connection with Game Bar 81 | m_Overlay = ref new XboxGameBarWidget(widgetArgs, Window::Current->CoreWindow, rootFrame); 82 | 83 | m_Overlay->VerticalResizeSupported = true; 84 | m_Overlay->HorizontalResizeSupported = true; 85 | 86 | float width = GetSystemMetrics(SM_CXSCREEN); 87 | float height = GetSystemMetrics(SM_CYSCREEN); 88 | 89 | m_Overlay->MinWindowSize = Windows::Foundation::Size(width, height - 40); 90 | m_Overlay->MaxWindowSize = Windows::Foundation::Size(7680, 4320); 91 | 92 | m_Overlay->CenterWindowAsync(); 93 | m_Overlay->TryResizeWindowAsync(Windows::Foundation::Size(width, height - 40)); 94 | 95 | rootFrame->Navigate(TypeName(Overlay::typeid), nullptr); 96 | 97 | m_OverlayWindowClosedHandlerToken = Window::Current->Closed += ref new WindowClosedEventHandler(this, &Cheat::App::OverlayWindowClosedHandler); 98 | 99 | Window::Current->Activate(); 100 | } 101 | } 102 | } 103 | 104 | void App::OverlayWindowClosedHandler(Platform::Object^ /*sender*/, Windows::UI::Core::CoreWindowEventArgs^ /*e*/) 105 | { 106 | m_Overlay = nullptr; 107 | Window::Current->Closed -= m_OverlayWindowClosedHandlerToken; 108 | } 109 | 110 | void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) 111 | { 112 | auto rootFrame = dynamic_cast(Window::Current->Content); 113 | 114 | if (rootFrame) 115 | { 116 | if (e->PrelaunchActivated == false) 117 | { 118 | if (rootFrame->Content == nullptr) 119 | { 120 | // When the navigation stack isn't restored navigate to the first page, 121 | // configuring the new page by passing required information as a navigation 122 | // parameter 123 | rootFrame->Navigate(TypeName(Overlay::typeid), e->Arguments); 124 | } 125 | 126 | // Ensure the current window is active 127 | Window::Current->Activate(); 128 | } 129 | } 130 | else 131 | { 132 | //assume this is 'startup' when a user is logged into the hack we launch this, then this gives them the xbox live store option 133 | if (!rootFrame) 134 | { 135 | auto rootFrame = ref new Frame(); 136 | Window::Current->Content = rootFrame; 137 | rootFrame->Navigate(TypeName(Overlay::typeid), e->Arguments); 138 | Window::Current->Activate(); 139 | } 140 | } 141 | } 142 | 143 | void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e) 144 | { 145 | (void) sender; // Unused parameter 146 | (void) e; // Unused parameter 147 | 148 | m_Overlay = nullptr; 149 | } 150 | 151 | void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e) 152 | { 153 | throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name); 154 | } 155 | -------------------------------------------------------------------------------- /Overlay/App.xaml.h: -------------------------------------------------------------------------------- 1 | // 2 | // App.xaml.h 3 | // Declaration of the App class. 4 | // 5 | 6 | #pragma once 7 | 8 | #include "App.g.h" 9 | 10 | namespace Cheat 11 | { 12 | /// 13 | /// Provides application-specific behavior to supplement the default Application class. 14 | /// 15 | ref class App sealed 16 | { 17 | protected: 18 | virtual void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs^ e) override; 19 | virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; 20 | 21 | internal: 22 | App(); 23 | 24 | private: 25 | void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); 26 | void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e); 27 | void OverlayWindowClosedHandler(Platform::Object^ sender, Windows::UI::Core::CoreWindowEventArgs^ e); 28 | 29 | Windows::Foundation::EventRegistrationToken m_OverlayWindowClosedHandlerToken{}; 30 | Microsoft::Gaming::XboxGameBar::XboxGameBarWidget^ m_Overlay{ nullptr }; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Overlay/Assets/LargeTile.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/LargeTile.scale-100.png -------------------------------------------------------------------------------- /Overlay/Assets/LargeTile.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/LargeTile.scale-125.png -------------------------------------------------------------------------------- /Overlay/Assets/LargeTile.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/LargeTile.scale-150.png -------------------------------------------------------------------------------- /Overlay/Assets/LargeTile.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/LargeTile.scale-200.png -------------------------------------------------------------------------------- /Overlay/Assets/LargeTile.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/LargeTile.scale-400.png -------------------------------------------------------------------------------- /Overlay/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /Overlay/Assets/SmallTile.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SmallTile.scale-100.png -------------------------------------------------------------------------------- /Overlay/Assets/SmallTile.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SmallTile.scale-125.png -------------------------------------------------------------------------------- /Overlay/Assets/SmallTile.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SmallTile.scale-150.png -------------------------------------------------------------------------------- /Overlay/Assets/SmallTile.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SmallTile.scale-200.png -------------------------------------------------------------------------------- /Overlay/Assets/SmallTile.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SmallTile.scale-400.png -------------------------------------------------------------------------------- /Overlay/Assets/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /Overlay/Assets/SplashScreen.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SplashScreen.scale-125.png -------------------------------------------------------------------------------- /Overlay/Assets/SplashScreen.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SplashScreen.scale-150.png -------------------------------------------------------------------------------- /Overlay/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /Overlay/Assets/SplashScreen.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/SplashScreen.scale-400.png -------------------------------------------------------------------------------- /Overlay/Assets/Square150x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square150x150Logo.scale-100.png -------------------------------------------------------------------------------- /Overlay/Assets/Square150x150Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square150x150Logo.scale-125.png -------------------------------------------------------------------------------- /Overlay/Assets/Square150x150Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square150x150Logo.scale-150.png -------------------------------------------------------------------------------- /Overlay/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /Overlay/Assets/Square150x150Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square150x150Logo.scale-400.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-unplated_targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-unplated_targetsize-16.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-unplated_targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-unplated_targetsize-256.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-unplated_targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-unplated_targetsize-32.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.altform-unplated_targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.altform-unplated_targetsize-48.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.scale-100.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.scale-125.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.scale-150.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.scale-400.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.targetsize-16.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.targetsize-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.targetsize-24.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.targetsize-256.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.targetsize-32.png -------------------------------------------------------------------------------- /Overlay/Assets/Square44x44Logo.targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Square44x44Logo.targetsize-48.png -------------------------------------------------------------------------------- /Overlay/Assets/StoreLogo.backup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/StoreLogo.backup.png -------------------------------------------------------------------------------- /Overlay/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/StoreLogo.png -------------------------------------------------------------------------------- /Overlay/Assets/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /Overlay/Assets/StoreLogo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/StoreLogo.scale-125.png -------------------------------------------------------------------------------- /Overlay/Assets/StoreLogo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/StoreLogo.scale-150.png -------------------------------------------------------------------------------- /Overlay/Assets/StoreLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/StoreLogo.scale-200.png -------------------------------------------------------------------------------- /Overlay/Assets/StoreLogo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/StoreLogo.scale-400.png -------------------------------------------------------------------------------- /Overlay/Assets/Wide310x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Wide310x150Logo.scale-100.png -------------------------------------------------------------------------------- /Overlay/Assets/Wide310x150Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Wide310x150Logo.scale-125.png -------------------------------------------------------------------------------- /Overlay/Assets/Wide310x150Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Wide310x150Logo.scale-150.png -------------------------------------------------------------------------------- /Overlay/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /Overlay/Assets/Wide310x150Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelSDM/GameBarGUI/df8c643ca1e15f87a35d756311733c77c8c7426a/Overlay/Assets/Wide310x150Logo.scale-400.png -------------------------------------------------------------------------------- /Overlay/Graphics/Drawing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /* 3 | Instructions on sprite batching: 4 | Call SetDrawingSession 5 | call your spritebatch drawing calls 6 | call PackSpriteSession when you're finished with your draws. 7 | */ 8 | enum FontAlignment 9 | { 10 | Left = 0, 11 | Centre = 1, 12 | Right = 2, 13 | CentreLeft = 3, 14 | CentreRight = 4, 15 | CentreCentre = 5, 16 | None = 6 17 | }; 18 | void DrawText(int x, int y, std::wstring text, std::string font, int fontsize, Color colour, FontAlignment alignment); 19 | void DrawTextClipped(int x, int y, int width, int height, std::wstring text, std::string font, int fontsize, Color colour, FontAlignment alignment); 20 | void FilledRectangle(int x, int y, int width, int height, Color colour); 21 | void OutlineRectangle(int x, int y, int width, int height, int thickness, Color colour); 22 | void FilledRoundedRectangle(int x, int y, int width, int height, int aax, int aay, Color colour); 23 | void OutlineRoundedRectangle(int x, int y, int width, int height, int aax, int aay, Color colour); 24 | void OutlineCircle(int x, int y, int radius, int thickness, Color colour); 25 | void FilledCircle(int x, int y, int radius, int thickness, Color colour); 26 | void AlphaSlider(int x, int y, int width, int height, Color col); 27 | void HueSlider(int x, int y, int width, int height); 28 | void SaturationSlider(int x, int y, int width, int height, Color colour); 29 | void FilledTriangle(int x1, int y1, int x2, int y2, int x3, int y3, Color colour); 30 | void FilledLine(int x1, int y1, int x2, int y2, int thickness, Color colour); 31 | 32 | 33 | void FilledRectangleOnSpriteBatch(int x, int y, int width, int height, Color colour); 34 | void OutlineRectangleOnSpriteBatch(int x, int y, int width, int height, int thickness, Color colour); 35 | void FilledRoundedRectangleOnSpriteBatch(int x, int y, int width, int height, int aax, int aay, Color colour); 36 | void OutlineRoundedRectangleOnSpriteBatch(int x, int y, int width, int height, int aax, int aay, Color colour); 37 | void OutlineCircleOnSpriteBatch(int x, int y, int radius, int thickness, Color colour); 38 | void FilledCircleOnSpriteBatch(int x, int y, int radius, int thickness, Color colour); 39 | void ColourPickerOnSpriteBatch(int x, int y, int width, int height, Color colour); 40 | void ColourPickerSliderOnSpriteBatch(int x, int y, int width, int height); 41 | void FilledTriangleOnSpriteBatch(int x1, int y1, int x2, int y2, int x3, int y3, Color colour); 42 | void FilledLineOnSpriteBatch(int x1, int y1, int x2, int y2, int thickness, Color colour); 43 | void DrawTextOnSpriteBatch(int x, int y, std::wstring text, std::string font, int fontsize, Color colour, FontAlignment alignment); 44 | void PackSpriteSession(); 45 | void SetDrawingSession(); -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Button.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Input.h" 3 | #include "Drawing.h" 4 | #include "Button.h" 5 | #include "Font.h"; 6 | 7 | Button::Button(float x, float y, std::wstring text, std::function click) 8 | { 9 | Button::Pos = { x,y }; 10 | Button::Size = { 70,20 }; 11 | Button::Name = text; 12 | Button::Action = click; 13 | Button::SetWidth(); 14 | SetVisible(true); 15 | } 16 | void Button::SetWidth() 17 | { 18 | Button::Size.x = GetTextWidth(Button::Name, 11, "Verdana") + 20; 19 | 20 | } 21 | void Button::Update() 22 | { 23 | if (!Button::Parent) 24 | Button::SetVisible(false); 25 | if (!Button::IsVisible()) 26 | return; 27 | 28 | 29 | Button::ParentPos = Button::Parent->GetParentPos(); 30 | if (!Button::Blocked) 31 | { 32 | if (IsMouseInRectangle(Button::Pos + ParentPos, Button::Size) && IsKeyClicked(VK_LBUTTON) && Button::LastClick < (clock() * 0.00001f)) 33 | { 34 | Button::Action(); 35 | Button::LastClick = (clock() * 0.00001f) + 0.002f; 36 | } 37 | } 38 | } 39 | 40 | void Button::Draw() 41 | { 42 | //Button::Parent->GetParent()->GetParent()->GetPos(); 43 | if (!Button::Parent) 44 | Button::SetVisible(false); 45 | if (!Button::IsVisible()) 46 | return; 47 | 48 | FilledRectangle(ParentPos.x + Button::Pos.x, ParentPos.y + Button::Pos.y, Button::Size.x, Button::Size.y, Colour(80, 80, 80, 255)); 49 | OutlineRectangle(ParentPos.x + Pos.x - 1, ParentPos.y + Pos.y - 1, Size.x + 1, Size.y + 1, 1, Colour(130, 130, 130, 255)); 50 | DrawText( ParentPos.x + Button::Pos.x + (Button::Size.x / 2), ParentPos.y + Button::Pos.y + (Button::Size.y / 2), Button::Name, "Verdana", 12, Colour(240, 240, 240, 255), CentreCentre); 51 | 52 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Button.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class Button : public Entity 4 | { 5 | protected: 6 | 7 | std::function< void()> Action; 8 | void SetWidth(); 9 | public: 10 | Button(float x, float y, std::wstring text, std::function click); 11 | void Update(); 12 | void Draw(); 13 | }; 14 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/ColourPicker.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ColourPicker.h" 3 | #include "Input.h" 4 | #include "Drawing.h" 5 | #include "GUI.h" 6 | ColourPicker::ColourPicker(float x, float y, Color* colour) 7 | { 8 | ColourPicker::MainColour = colour; 9 | ColourPicker::Size = {20,10}; 10 | ColourPicker::Pos = { x,y }; 11 | ColourPicker::Open = false; 12 | ColourPicker::Hue = RGBToHue(ColourPicker::MainColour->R, ColourPicker::MainColour->G, ColourPicker::MainColour->B); 13 | ColourPicker::Alpha = MainColour->A; 14 | ColourPicker::Saturation = RgbToHsv(ColourPicker::MainColour->R, ColourPicker::MainColour->G, ColourPicker::MainColour->B).V; 15 | ColourPicker::Brightness = RgbToHsv(ColourPicker::MainColour->R, ColourPicker::MainColour->G, ColourPicker::MainColour->B).S; 16 | ColourPicker::ContextSize = { 80.0f,20.0f * (int)ColourPicker::ContextNames.size() }; 17 | SetVisible(true); 18 | } 19 | float ColourPicker::HueToSliderValue(float hue) 20 | { 21 | return hue / 360.0f; 22 | } 23 | 24 | float ColourPicker::SliderValueToHue(float slidervalue) 25 | { 26 | return slidervalue * 360.0f; 27 | } 28 | 29 | float ColourPicker::AlphaToSliderValue(float alpha) 30 | { 31 | return alpha / 255.0f; 32 | } 33 | float ColourPicker::SaturationToSliderValue(float saturation) 34 | { 35 | return saturation / 255.0f; 36 | } 37 | void ColourPicker::Copy() 38 | { 39 | ColourPickerClipBoard = *ColourPicker::MainColour; 40 | 41 | } 42 | void ColourPicker::Paste() 43 | { 44 | *ColourPicker::MainColour = ColourPickerClipBoard; 45 | ColourPicker::Alpha = ColourPickerClipBoard.A; 46 | ColourPicker::Saturation = RgbToHsv(ColourPicker::MainColour->R, ColourPicker::MainColour->G, ColourPicker::MainColour->B).V; 47 | ColourPicker::Brightness = RgbToHsv(ColourPicker::MainColour->R, ColourPicker::MainColour->G, ColourPicker::MainColour->B).S; 48 | ColourPicker::Hue = RGBToHue(ColourPicker::MainColour->R, ColourPicker::MainColour->G, ColourPicker::MainColour->B); 49 | ColourPicker::ValueChangeEvent(); 50 | } 51 | void ColourPicker::ContextMenu() 52 | { 53 | if (IsMouseInRectangle(ColourPicker::Pos + ColourPicker::ParentPos, ColourPicker::Size) && IsKeyClicked(VK_RBUTTON) && !ColourPicker::Blocked && !ColourPicker::Open) 54 | { 55 | ColourPicker::ContextActive = true; 56 | ColourPicker::Open = false; 57 | ColourPicker::ContextPos = MousePos; 58 | SetBlockedSiblings(true); 59 | } 60 | if (!IsMouseInRectangle(ColourPicker::ContextPos, ColourPicker::ContextSize) && IsKeyClicked(VK_LBUTTON)) 61 | { 62 | if (ColourPicker::ContextActive) 63 | SetBlockedSiblings(false); 64 | ColourPicker::ContextActive = false; 65 | } 66 | if (!ColourPicker::ContextActive) 67 | return; 68 | int i = 0; 69 | for (auto& pair : ColourPicker::ContextNames) 70 | { 71 | if (IsMouseInRectangle(ColourPicker::ContextPos.x, ColourPicker::ContextPos.y + (i * 20), ColourPicker::ContextSize.x, 20) && IsKeyClicked(VK_LBUTTON) && ColourPicker::LastClick < (clock() * 0.00001f)) 72 | { 73 | pair.second(); 74 | ColourPicker::LastClick = (clock() * 0.00001f) + 0.002f; 75 | } 76 | i++; 77 | } 78 | } 79 | void ColourPicker::Update() 80 | { 81 | if (!ColourPicker::Parent) 82 | ColourPicker::SetVisible(false); 83 | if (!ColourPicker::IsVisible()) 84 | return; 85 | ColourPicker::ParentPos = ColourPicker::Parent->GetParentPos(); 86 | ColourPicker::ContextMenu(); 87 | if (!(IsMouseInRectangle(ColourPicker::ParentPos.x + ColourPicker::Pos.x, ColourPicker::ParentPos.y + ColourPicker::Pos.y, ColourPicker::Size.x, ColourPicker::Size.y) || IsMouseInRectangle(ClickedPos.x - 5, ClickedPos.y - 5, 175, 175)) && IsKeyClicked(VK_LBUTTON) && ColourPicker::Open) 88 | { 89 | ColourPicker::Open = false; 90 | 91 | SetBlockedSiblings(false); 92 | 93 | } 94 | if (ColourPicker::Blocked) 95 | return; 96 | if (IsMouseInRectangle(ColourPicker::ParentPos.x + ColourPicker::Pos.x, ColourPicker::ParentPos.y + ColourPicker::Pos.y, ColourPicker::Size.x, ColourPicker::Size.y) && IsKeyClicked(VK_LBUTTON) && ColourPicker::LastClick < (clock() * 0.00001f) && !(IsMouseInRectangle(ClickedPos.x - 5, ClickedPos.y - 5, 185, 175) && ColourPicker::Open)) 97 | { 98 | ClickedPos = MousePos; 99 | ColourPicker::Open = !ColourPicker::Open; 100 | ColourPicker::LastClick = (clock() * 0.00001f) + 0.002f; 101 | ColourPicker::ContextActive = false; 102 | if(ColourPicker::Open) 103 | SetBlockedSiblings(true); 104 | if (!ColourPicker::Open) 105 | SetBlockedSiblings(false); 106 | } 107 | if (!IsKeyDown(VK_LBUTTON) && !ColourPicker::ContextActive) 108 | { 109 | if(ColourPicker::HeldHue || ColourPicker::Alpha || ColourPicker::HeldSaturation) 110 | ColourPicker::ValueChangeEvent(); 111 | ColourPicker::HeldHue = false; 112 | ColourPicker::HeldAlpha = false; 113 | ColourPicker::HeldSaturation = false; 114 | *ColourPicker::MainColour = HsvToRgb(ColourPicker::Hue, ColourPicker::Brightness, ColourPicker::Saturation, ColourPicker::Alpha); 115 | } 116 | 117 | if (!ColourPicker::Open) 118 | return; 119 | if (IsMouseInRectangle(ClickedPos.x, ClickedPos.y, 150, 150) && IsKeyClicked(VK_LBUTTON) && ColourPicker::LastClick < (clock() * 0.00001f)) 120 | { 121 | ColourPicker::HeldSaturation = true; 122 | ColourPicker::LastClick = (clock() * 0.00001f) + 0.002f; 123 | } 124 | if (IsMouseInRectangle(ClickedPos.x, ClickedPos.y+155, 150, 10) && IsKeyClicked(VK_LBUTTON) && ColourPicker::LastClick < (clock() * 0.00001f)) 125 | { 126 | ColourPicker::HeldHue = true; 127 | ColourPicker::LastClick = (clock() * 0.00001f) + 0.002f; 128 | } 129 | if (IsMouseInRectangle(ClickedPos.x + 155, ClickedPos.y, 20, 165) && IsKeyClicked(VK_LBUTTON) && ColourPicker::LastClick < (clock() * 0.00001f)) 130 | { 131 | ColourPicker::HeldAlpha = true; 132 | ColourPicker::LastClick = (clock() * 0.00001f) + 0.002f; 133 | } 134 | if (HeldHue) 135 | { 136 | // Calculate the slider value from the mouse position 137 | const float clamp = std::clamp((float)MousePos.x - (float)(ClickedPos.x), 0.00f, (float)150); 138 | const float ratio = clamp /150; 139 | ColourPicker::Hue = 0.0f + (360.0f - 0.0f) * ratio; 140 | // second var creates brigthness/ fullcolour - white, second one does black to full colour 141 | *ColourPicker::MainColour = HsvToRgb(ColourPicker::Hue, ColourPicker::Brightness, ColourPicker::Saturation, ColourPicker::Alpha); 142 | } 143 | if (HeldAlpha) 144 | { 145 | // Calculate the slider value from the mouse position 146 | const float clamp = std::clamp((float)MousePos.y - (float)(ClickedPos.y), 0.00f, (float)165); 147 | const float ratio = clamp / 165; 148 | ColourPicker::Alpha = (1.0f - ratio) * 255; 149 | ColourPicker::MainColour->A = ColourPicker::Alpha; 150 | } 151 | if (HeldSaturation) 152 | { 153 | // Calculate the saturation values from the mouse position 154 | const float xclamp = std::clamp((float)MousePos.x - (float)(ClickedPos.x), 0.00f, (float)150); 155 | const float yclamp = std::clamp((float)MousePos.y - (float)(ClickedPos.y), 0.00f, (float)150); 156 | 157 | const float xratio = xclamp / 150.0f; 158 | const float yratio = (150.0f - yclamp) / 150.0f; 159 | ColourPicker::Saturation = yratio * 255.0f; 160 | ColourPicker::Brightness = xratio * 255.0f; 161 | // ColourPicker::Saturation = std::sqrt(xratio * xratio + yratio * yratio) * 255.0f; 162 | if (ColourPicker::Saturation > 255.0f) 163 | ColourPicker::Saturation = 255.0f; 164 | if (ColourPicker::Brightness > 255.0f) 165 | ColourPicker::Brightness = 255.0f; 166 | 167 | } 168 | } 169 | 170 | void ColourPicker::Draw() 171 | { 172 | if (!ColourPicker::Parent) 173 | ColourPicker::SetVisible(false); 174 | if (!ColourPicker::IsVisible()) 175 | return; 176 | FilledRectangle(ColourPicker::ParentPos.x + ColourPicker::Pos.x, ColourPicker::ParentPos.y + ColourPicker::Pos.y, ColourPicker::Size.x, ColourPicker::Size.y, *ColourPicker::MainColour); 177 | OutlineRectangle(ColourPicker::ParentPos.x + ColourPicker::Pos.x, ColourPicker::ParentPos.y + ColourPicker::Pos.y, ColourPicker::Size.x, ColourPicker::Size.y, 1, Colour(85, 85, 85, 255)); 178 | 179 | 180 | 181 | if (ColourPicker::Open) 182 | { 183 | FilledRectangle(ClickedPos.x - 5, ClickedPos.y - 5, 185, 175, Colour(85, 85, 85, 255)); 184 | OutlineRectangle(ClickedPos.x - 5, ClickedPos.y - 5, 185, 175,1, Colour(180, 180, 180, 255)); 185 | SaturationSlider(ClickedPos.x, ClickedPos.y, 150, 150, HsvToRgb(ColourPicker::Hue, 255.0f, 255.0f,ColourPicker::Alpha)); 186 | 187 | 188 | // alpha 189 | OutlineRectangle(ClickedPos.x + 155, ClickedPos.y, 20, 165, 1, Colour(180, 180, 180, 255)); 190 | AlphaSlider(ClickedPos.x + 155, ClickedPos.y, 20, 165, *ColourPicker::MainColour); 191 | float alphavalue = ColourPicker::AlphaToSliderValue(ColourPicker::Alpha); 192 | FilledRectangle(ClickedPos.x + 155, ClickedPos.y + ((int)165 * (1.0f - alphavalue)), 20, 2, Colour(255, 255, 255, 255)); 193 | 194 | // hue 195 | HueSlider(ClickedPos.x, ClickedPos.y + 155, 150, 10); 196 | float huevalue = ColourPicker::HueToSliderValue(ColourPicker::Hue); 197 | FilledRectangle(ClickedPos.x + ((int)150 * huevalue), ClickedPos.y + 155, 2, 10, Colour(255, 255, 255, 255)); 198 | } 199 | if (ColourPicker::ContextActive) 200 | { 201 | OutlineRectangle(ColourPicker::ContextPos.x, ColourPicker::ContextPos.y, ColourPicker::ContextSize.x, ColourPicker::ContextSize.y, 1, Colour(255, 255, 255, 255)); 202 | FilledRectangle(ColourPicker::ContextPos.x, ColourPicker::ContextPos.y, ColourPicker::ContextSize.x, ColourPicker::ContextSize.y, Colour(80, 80, 80, 255)); 203 | int i = 0; 204 | for (auto pair : ColourPicker::ContextNames) 205 | { 206 | if (i != 0) 207 | FilledLine(ColourPicker::ContextPos.x, ColourPicker::ContextPos.y + i * 20, ColourPicker::ContextPos.x + ColourPicker::ContextSize.x, ColourPicker::ContextPos.y + i * 20, 1.0f, Colour(255, 255, 255, 255)); 208 | 209 | if (IsMouseInRectangle(ColourPicker::ContextPos.x, ColourPicker::ContextPos.y + (i * 20), ColourPicker::ContextSize.x, 20)) 210 | FilledRectangle(ColourPicker::ContextPos.x, ColourPicker::ContextPos.y + (i * 20), ColourPicker::ContextSize.x, 20, Colour(120, 120, 120, 255)); 211 | DrawText(ColourPicker::ContextPos.x + (ColourPicker::ContextSize.x / 2), ColourPicker::ContextPos.y + (i * 20) + 10, pair.first, "Verdana", 11, Colour(255, 255, 255, 255), CentreCentre); 212 | 213 | i++; 214 | } 215 | } 216 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/ColourPicker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class ColourPicker : public Entity 4 | { 5 | protected: 6 | Vector2 ClickedPos; 7 | Color* MainColour; 8 | Color* RangeColour; 9 | Color* SelectedColour; 10 | Vector2 SelectedPos; 11 | 12 | float Saturation = 255; 13 | float Brightness = 255; 14 | bool HeldSaturation = false; 15 | 16 | float Hue = 360; 17 | bool HeldHue = false; 18 | 19 | bool HeldAlpha = false; 20 | float Alpha = 255; 21 | 22 | bool ContextActive = false; 23 | Vector2 ContextPos; 24 | Vector2 ContextSize; 25 | void ContextMenu(); 26 | void Copy(); 27 | void Paste(); 28 | std::map> ContextNames = { 29 | { L"Copy", [this]() { Copy(); } }, 30 | { L"Paste", [this]() { Paste(); } } 31 | }; 32 | 33 | bool Open = false; 34 | static float HueToSliderValue(float hue); 35 | static float SliderValueToHue(float slidervalue); 36 | static float AlphaToSliderValue(float alpha); 37 | static float SaturationToSliderValue(float saturation); 38 | public: 39 | ColourPicker(float x, float y, Color* colour); 40 | void Update(); 41 | void Draw(); 42 | }; 43 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/ComboBox.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Input.h" 3 | #include "Drawing.h" 4 | #include "ComboBox.h" 5 | #include "Font.h" 6 | ComboBox::ComboBox(float x, float y, std::wstring text, std::listitems, std::listnames) 7 | { 8 | ComboBox::Pos = { x,y }; 9 | ComboBox::Name = text; 10 | ComboBox::Items = items; 11 | ComboBox::Names = names; 12 | ComboBox::Size = { 120,20 }; 13 | ComboBox::CalculateBuffer(); 14 | ComboBox::ConvertSelectedName(); 15 | 16 | if (ComboBox::MaxVisibleItems > items.size()) 17 | { 18 | ComboBox::MaxVisibleItems = items.size(); 19 | } 20 | ComboBox::PointerStart = 0; 21 | ComboBox::PointerEnd = ComboBox::MaxVisibleItems; 22 | SetVisible(true); 23 | } 24 | void ComboBox::CalculateBuffer() 25 | { 26 | if (!ComboBox::Active) 27 | ComboBox::CutOffBuffer = 15; 28 | else 29 | ComboBox::CutOffBuffer = 0; 30 | } 31 | void ComboBox::SetComboBoxWidth() 32 | { 33 | float width = 0; 34 | for (std::wstring str : ComboBox::Names) 35 | { 36 | float wdth = GetTextWidth(str, 11, "Verdana"); 37 | if (wdth > width) 38 | width = wdth; 39 | } 40 | ComboBox::DropWidth = width; 41 | } 42 | void ComboBox::ConvertSelectedName() 43 | { 44 | 45 | std::wstring combinedstr = L""; 46 | for (int i = 0; i < ComboBox::Names.size(); i++) 47 | { 48 | auto it = ComboBox::Names.begin(); 49 | std::advance(it, i); 50 | std::advance(std::begin(ComboBox::Items), i); 51 | auto itbool = ComboBox::Items.begin(); 52 | std::advance(itbool, i); 53 | 54 | if (**itbool == true) 55 | combinedstr += *it + L","; 56 | } 57 | if (combinedstr.length() == 0) 58 | { 59 | combinedstr = L"Unselected"; 60 | float originalwidth = GetTextWidth(combinedstr, 11, "Verdana"); 61 | if (originalwidth < ComboBox::Size.x - ComboBox::CutOffBuffer) 62 | { 63 | ComboBox::TextWidth = originalwidth; 64 | ComboBox::SelectedName = combinedstr; 65 | return; 66 | } 67 | else 68 | { 69 | for (int i = combinedstr.length(); i > 0; i--) 70 | { 71 | combinedstr.erase(std::prev((combinedstr).end())); 72 | float width = GetTextWidth(combinedstr + L"..", 11, "Verdana"); 73 | if (width < ComboBox::Size.x - ComboBox::CutOffBuffer) 74 | { 75 | ComboBox::SelectedName = combinedstr + L".."; 76 | ComboBox::TextWidth = width; 77 | return; 78 | } 79 | } 80 | } 81 | 82 | } 83 | 84 | combinedstr.erase(std::prev((combinedstr).end())); // last character will be "," and we dont need that 85 | float originalwidth = GetTextWidth(combinedstr, 11, "Verdana"); 86 | 87 | if (originalwidth < ComboBox::Size.x - ComboBox::CutOffBuffer) 88 | { 89 | ComboBox::SelectedName = combinedstr; 90 | ComboBox::TextWidth = originalwidth; 91 | return; 92 | } 93 | else 94 | { 95 | std::wstring str = combinedstr; 96 | for (int i = str.length(); i > 0; i--) 97 | { 98 | str.erase(std::prev((str).end())); 99 | float width = GetTextWidth(str + L"..", 11, "Verdana"); 100 | if (width < ComboBox::Size.x - ComboBox::CutOffBuffer) 101 | { 102 | ComboBox::SelectedName = str + L".."; 103 | ComboBox::TextWidth = width; 104 | return; 105 | } 106 | } 107 | ComboBox::SelectedName = str + L".."; 108 | ComboBox::TextWidth = GetTextWidth(str + L"..", 11, "Verdana"); 109 | } 110 | 111 | } 112 | void ComboBox::ArrowNavigation() 113 | { 114 | if (!ComboBox::Active) 115 | return; 116 | if (IsKeyClicked(VK_DOWN) && ComboBox::LastClick < (clock() * 0.00001f)) 117 | { 118 | if (ComboBox::Names.size() - 1 > ComboBox::PointerEnd) 119 | { 120 | ComboBox::PointerEnd++; 121 | ComboBox::PointerStart++; 122 | ComboBox::LastClick = (clock() * 0.00001f) + 0.002f; 123 | } 124 | } 125 | if (IsKeyClicked(VK_UP) && ComboBox::LastClick < (clock() * 0.00001f)) 126 | { 127 | if (ComboBox::PointerStart > 0) 128 | { 129 | ComboBox::PointerEnd--; 130 | ComboBox::PointerStart--; 131 | ComboBox::LastClick = (clock() * 0.00001f) + 0.002f; 132 | } 133 | } 134 | } 135 | void ComboBox::Update() 136 | { 137 | if (!ComboBox::Parent) 138 | ComboBox::SetVisible(false); 139 | if (!ComboBox::IsVisible()) 140 | return; 141 | ComboBox::ArrowNavigation(); 142 | ComboBox::ParentPos = ComboBox::Parent->GetParentPos(); 143 | ComboBox::CalculateBuffer(); 144 | ComboBox::UpdateScrollBar(); 145 | if (!ComboBox::Blocked) 146 | { 147 | if (IsMouseInRectangle(ComboBox::Pos + ParentPos, ComboBox::Size) && IsKeyClicked(VK_LBUTTON) && ComboBox::LastClick < (clock() * 0.00001f)) 148 | { 149 | if (!ComboBox::Active) 150 | { 151 | ComboBox::Active = true; 152 | ComboBox::SetBlockedSiblings(true); 153 | ComboBox::LastClick = (clock() * 0.00001f) + 0.002f; 154 | ComboBox::CalculateBuffer(); 155 | ComboBox::ConvertSelectedName(); 156 | } 157 | else 158 | { 159 | ComboBox::Active = false; 160 | ComboBox::SetBlockedSiblings(false); 161 | ComboBox::CalculateBuffer(); 162 | ComboBox::ConvertSelectedName(); 163 | ComboBox::LastClick = (clock() * 0.00001f) + 0.002f; 164 | } 165 | } 166 | } 167 | if (IsKeyClicked(VK_LBUTTON) && ComboBox::Active && !(IsMouseInRectangle(ComboBox::Pos + ParentPos, ComboBox::Size) || IsMouseInRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x - (ComboBox::SizeDifference / 2), ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 5, ComboBox::DropWidth, ComboBox::Names.size() * ComboBox::Size.y) || IsMouseInRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x + ComboBox::Size.x + (ComboBox::SizeDifference / 2), ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 4, 6, (ComboBox::PointerEnd - ComboBox::PointerStart) * ComboBox::Size.y))) 168 | { 169 | ComboBox::Active = false; 170 | ComboBox::SetBlockedSiblings(false); 171 | ComboBox::CalculateBuffer(); 172 | ComboBox::ConvertSelectedName(); 173 | } 174 | if ((IsKeyClicked(VK_RETURN) || IsKeyClicked(VK_ESCAPE)) && ComboBox::Active) 175 | { 176 | ComboBox::Active = false; 177 | ComboBox::SetBlockedSiblings(false); 178 | ComboBox::CalculateBuffer(); 179 | ComboBox::ConvertSelectedName(); 180 | } 181 | if (ComboBox::Active) 182 | { 183 | ComboBox::SizeDifference = ComboBox::DropWidth - ComboBox::TextWidth; 184 | ComboBox::SetComboBoxWidth(); 185 | int i = 0; 186 | for (const std::wstring& name : ComboBox::Names) 187 | { 188 | if (i < ComboBox::PointerStart) 189 | { 190 | i++; 191 | continue; 192 | } 193 | if (i > ComboBox::PointerEnd-1) 194 | { 195 | i++; 196 | continue; 197 | } 198 | float itemposy = ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 5 + ((i - ComboBox::PointerStart) * ComboBox::Size.y); 199 | 200 | if (IsMouseInRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x, itemposy, ComboBox::DropWidth + (ComboBox::SizeDifference / 2), ComboBox::Size.y) && IsKeyClicked(VK_LBUTTON) && ComboBox::LastClick < (clock() * 0.00001f)) 201 | { 202 | auto it = ComboBox::Items.begin(); 203 | std::advance(it, i); 204 | ComboBox::ValueChangeEvent(); 205 | **it = !**it; 206 | ComboBox::LastClick = (clock() * 0.00001f) + 0.002f; 207 | ComboBox::ConvertSelectedName(); 208 | Sleep(50); // bandage click through fix 209 | } 210 | i++; 211 | } 212 | } 213 | } 214 | void ComboBox::UpdateScrollBar() 215 | { 216 | if (!IsKeyDown(VK_LBUTTON)) 217 | ComboBox::ScrollBarHeld = false; 218 | if (IsMouseInRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x + ComboBox::Size.x +(ComboBox::SizeDifference / 2), ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 4, 6, (ComboBox::PointerEnd - ComboBox::PointerStart) * ComboBox::Size.y) && IsKeyClicked(VK_LBUTTON)) 219 | ComboBox::ScrollBarHeld = true; 220 | if (ComboBox::ScrollBarHeld) 221 | { 222 | float ratio = (MousePos.y - (float)(ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 4)) / (float)((ComboBox::MaxVisibleItems - 1) * ComboBox::Size.y); 223 | ratio = std::clamp(ratio, 0.0f, 1.0f); 224 | ComboBox::PointerEnd = (int)(ComboBox::MaxVisibleItems + (ComboBox::Names.size() - ComboBox::MaxVisibleItems) * ratio); 225 | 226 | } 227 | ComboBox::PointerStart = ComboBox::PointerEnd - ComboBox::MaxVisibleItems; 228 | } 229 | 230 | void ComboBox::Draw() 231 | { 232 | if (!ComboBox::Parent) 233 | ComboBox::SetVisible(false); 234 | if (!ComboBox::IsVisible()) 235 | return; 236 | OutlineRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x - 1, ComboBox::ParentPos.y + ComboBox::Pos.y - 1, ComboBox::Size.x + 1, ComboBox::Size.y + 1, 1, Colour(130, 130, 130, 255)); 237 | FilledRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x, ComboBox::ParentPos.y + ComboBox::Pos.y, ComboBox::Size.x, ComboBox::Size.y, Colour(80, 80, 80, 255)); 238 | float trianglex1 = ComboBox::ParentPos.x + ComboBox::Pos.x + ComboBox::Size.x - 12; 239 | float triangley1 = ComboBox::ParentPos.y + ComboBox::Pos.y + 3; 240 | float trianglex2 = ComboBox::ParentPos.x + ComboBox::Pos.x + ComboBox::Size.x - 3; 241 | float triangley2 = ComboBox::Pos.y + ComboBox::ParentPos.y + 3; 242 | float trianglex3 = ComboBox::ParentPos.x + ComboBox::Pos.x + ComboBox::Size.x - 7; 243 | float triangley3 = ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y - 3; 244 | if (!ComboBox::Active) 245 | FilledTriangle(trianglex1, triangley1, trianglex2, triangley2, trianglex3, triangley3, Colour(255, 0, 0, 255)); 246 | DrawText(ComboBox::ParentPos.x + ComboBox::Pos.x + 5, ComboBox::ParentPos.y + ComboBox::Pos.y + (ComboBox::Size.y / 8), ComboBox::SelectedName, "Verdana", 11, Colour(240, 240, 240, 255), None); 247 | 248 | if (ComboBox::DropWidth < ComboBox::Size.x) 249 | { 250 | ComboBox::DropWidth = ComboBox::Size.x; 251 | ComboBox::SizeDifference = 0; 252 | } 253 | if (ComboBox::Active) 254 | { 255 | OutlineRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x - (ComboBox::SizeDifference / 2) - 1, ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 4, ComboBox::DropWidth + 1, (ComboBox::PointerEnd - ComboBox::PointerStart) * ComboBox::Size.y + 1, 1, Colour(130, 130, 130, 255)); 256 | FilledRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x - (ComboBox::SizeDifference / 2), ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 5, ComboBox::DropWidth, (ComboBox::PointerEnd - ComboBox::PointerStart) * ComboBox::Size.y, Colour(80, 80, 80, 255)); 257 | 258 | int i = 0; 259 | for (const std::wstring& name : ComboBox::Names) 260 | { 261 | if (i < ComboBox::PointerStart) 262 | { 263 | i++; 264 | continue; 265 | } 266 | if (i > ComboBox::PointerEnd-1) 267 | { 268 | i++; 269 | continue; 270 | } 271 | float itemposy = ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 5 + ((i - ComboBox::PointerStart) * ComboBox::Size.y); 272 | if (IsMouseInRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x - (ComboBox::SizeDifference / 2), itemposy, ComboBox::DropWidth, ComboBox::Size.y)) 273 | { 274 | FilledRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x - (ComboBox::SizeDifference / 2), itemposy, ComboBox::DropWidth, ComboBox::Size.y, Colour(150, 150, 150, 120)); 275 | 276 | } 277 | 278 | auto it = ComboBox::Items.begin(); 279 | std::advance(it, i); 280 | 281 | if (**it == true) 282 | DrawText(ComboBox::ParentPos.x + ComboBox::Pos.x + 5 - (ComboBox::SizeDifference / 2), itemposy + (ComboBox::Size.y / 8), name, "Verdana", 11, Colour(255, 0, 0, 255), None); 283 | else 284 | DrawText(ComboBox::ParentPos.x + ComboBox::Pos.x + 5 - (ComboBox::SizeDifference / 2), itemposy + (ComboBox::Size.y / 8), name, "Verdana", 11, Colour(240, 240, 240, 255), None); 285 | i++; 286 | } 287 | OutlineRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x + ComboBox::Size.x + (ComboBox::SizeDifference /2), ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 4, 6, (ComboBox::PointerEnd - ComboBox::PointerStart) * ComboBox::Size.y + 1, 1, Colour(130, 130, 130, 255)); 288 | int unselectedelements = Names.size() - MaxVisibleItems; 289 | float unselectedclamp = std::clamp(unselectedelements, 1, (int)Names.size()); 290 | float scrollheight = ((ComboBox::PointerEnd - ComboBox::PointerStart) * ComboBox::Size.y) / (unselectedclamp); 291 | float scrolly = ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 5 + (((PointerEnd - MaxVisibleItems) * Size.y)); 292 | float scrollyclamp = std::clamp(scrolly, ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 5, ComboBox::ParentPos.y + ComboBox::Pos.y + ComboBox::Size.y + 5 + ((ComboBox::PointerEnd - ComboBox::PointerStart) * ComboBox::Size.y) - scrollheight); 293 | 294 | FilledRectangle(ComboBox::ParentPos.x + ComboBox::Pos.x + ComboBox::Size.x + (ComboBox::SizeDifference / 2), scrollyclamp, 6, scrollheight, Colour(255, 0, 0, 255)); 295 | } 296 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/ComboBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class ComboBox : public Entity 4 | { 5 | protected: 6 | float DropWidth; 7 | std::listNames; 8 | std::listItems; 9 | bool Active = false; 10 | std::wstring SelectedName; 11 | float TextWidth = 0; 12 | float CutOffBuffer = 0; 13 | float SizeDifference; 14 | 15 | int MaxVisibleItems = 5; 16 | 17 | int PointerStart = 0; 18 | int PointerEnd = MaxVisibleItems; 19 | 20 | void ConvertSelectedName(); 21 | void CalculateBuffer(); 22 | void SetComboBoxWidth(); 23 | void ArrowNavigation(); 24 | void UpdateScrollBar(); 25 | 26 | bool ScrollBarHeld = false; 27 | 28 | 29 | public: 30 | ComboBox(float x, float y, std::wstring text, std::listitems, std::listnames); 31 | void Update(); 32 | void Draw(); 33 | }; 34 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/DropDown.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Input.h" 3 | #include "Drawing.h" 4 | #include "DropDown.h" 5 | #include "Font.h" 6 | DropDown::DropDown(float x, float y, std::wstring text, int* index, std::listnames) 7 | { 8 | DropDown::Pos = { x,y }; 9 | DropDown::Name = text; 10 | DropDown::Index = index; 11 | DropDown::Names = names; 12 | DropDown::Size = { 120,20 }; 13 | DropDown::CalculateBuffer(); 14 | DropDown::ConvertSelectedName(); 15 | if (DropDown::MaxVisibleItems > DropDown::Names.size()) 16 | { 17 | DropDown::MaxVisibleItems = DropDown::Names.size(); 18 | } 19 | DropDown::PointerStart = 0; 20 | DropDown::PointerEnd = DropDown::MaxVisibleItems; 21 | SetVisible(true); 22 | } 23 | void DropDown::CalculateBuffer() 24 | { 25 | if (!DropDown::Active) 26 | DropDown::CutOffBuffer = 15; 27 | else 28 | DropDown::CutOffBuffer = 0; 29 | } 30 | void DropDown::SetDropDownWidth() 31 | { 32 | float width = 0; 33 | for (std::wstring str : DropDown::Names) 34 | { 35 | float wdth = GetTextWidth(str, 11, "Verdana"); 36 | if (wdth > width) 37 | width = wdth; 38 | } 39 | DropDown::DropWidth = width; 40 | } 41 | void DropDown::ConvertSelectedName() 42 | { 43 | auto it = DropDown::Names.begin(); 44 | std::advance(it, *Index); 45 | float originalwidth = GetTextWidth(*it, 11, "Verdana"); 46 | 47 | if (originalwidth < DropDown::Size.x - DropDown::CutOffBuffer) 48 | { 49 | DropDown::SelectedName = *it; 50 | TextWidth = originalwidth; 51 | return; 52 | } 53 | else 54 | { 55 | std::wstring str = *it; 56 | for (int i = str.length(); i > 0; i--) 57 | { 58 | str.erase(std::prev((str).end())); 59 | float width = GetTextWidth(str + L"..", 11, "Verdana"); 60 | if (width < DropDown::Size.x - DropDown::CutOffBuffer) 61 | { 62 | DropDown::SelectedName = str + L".."; 63 | TextWidth = width; 64 | return; 65 | } 66 | } 67 | DropDown::SelectedName = str + L".."; 68 | TextWidth = GetTextWidth(str + L"..", 11, "Verdana"); 69 | } 70 | 71 | } 72 | void DropDown::ArrowNavigation() 73 | { 74 | if (!DropDown::Active) 75 | return; 76 | if (IsKeyClicked(VK_DOWN) && DropDown::LastClick < (clock() * 0.00001f)) 77 | { 78 | if (DropDown::Names.size()-1> DropDown::PointerEnd) 79 | { 80 | DropDown::PointerEnd++; 81 | DropDown::PointerStart++; 82 | DropDown::LastClick = (clock() * 0.00001f) + 0.002f; 83 | } 84 | } 85 | if (IsKeyClicked(VK_UP) && DropDown::LastClick < (clock() * 0.00001f)) 86 | { 87 | if (DropDown::PointerStart > 0) 88 | { 89 | DropDown::PointerEnd--; 90 | DropDown::PointerStart--; 91 | DropDown::LastClick = (clock() * 0.00001f) + 0.002f; 92 | } 93 | } 94 | } 95 | void DropDown::Update() 96 | { 97 | if (!DropDown::Parent) 98 | DropDown::SetVisible(false); 99 | if (!DropDown::IsVisible()) 100 | return; 101 | DropDown::ArrowNavigation(); 102 | DropDown::ParentPos = DropDown::Parent->GetParentPos(); 103 | DropDown::CalculateBuffer(); 104 | DropDown::UpdateScrollBar(); 105 | if (!DropDown::Blocked) 106 | { 107 | if (IsMouseInRectangle(DropDown::Pos + ParentPos, DropDown::Size) && IsKeyClicked(VK_LBUTTON) && DropDown::LastClick < (clock() * 0.00001f)) 108 | { 109 | if (!DropDown::Active) 110 | { 111 | DropDown::Active = true; 112 | DropDown::SetBlockedSiblings(true); 113 | DropDown::LastClick = (clock() * 0.00001f) + 0.002f; 114 | DropDown::CalculateBuffer(); 115 | DropDown::ConvertSelectedName(); 116 | } 117 | else 118 | { 119 | DropDown::Active = false; 120 | DropDown::SetBlockedSiblings(false); 121 | DropDown::CalculateBuffer(); 122 | DropDown::ConvertSelectedName(); 123 | DropDown::LastClick = (clock() * 0.00001f) + 0.002f; 124 | } 125 | } 126 | } 127 | if ( IsKeyClicked(VK_LBUTTON) && DropDown::Active && !(IsMouseInRectangle(DropDown::Pos + ParentPos, DropDown::Size) || IsMouseInRectangle(DropDown::ParentPos.x + DropDown::Pos.x - (DropDown::SizeDifference / 2), DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y +5, DropDown::DropWidth, DropDown::Names.size() * DropDown::Size.y) || IsMouseInRectangle(DropDown::ParentPos.x + DropDown::Pos.x + DropDown::Size.x + (DropDown::SizeDifference / 2), DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 4, 6, (DropDown::PointerEnd - DropDown::PointerStart) * DropDown::Size.y))) 128 | { 129 | DropDown::Active = false; 130 | DropDown::SetBlockedSiblings(false); 131 | DropDown::CalculateBuffer(); 132 | DropDown::ConvertSelectedName(); 133 | } 134 | if ((IsKeyClicked(VK_RETURN) || IsKeyClicked(VK_ESCAPE)) && DropDown::Active) 135 | { 136 | DropDown::Active = false; 137 | DropDown::SetBlockedSiblings(false); 138 | DropDown::CalculateBuffer(); 139 | DropDown::ConvertSelectedName(); 140 | } 141 | if (DropDown::Active) 142 | { 143 | DropDown::SizeDifference = DropDown::DropWidth - DropDown::TextWidth; 144 | DropDown::SetDropDownWidth(); 145 | int i = 0; 146 | for (const std::wstring& name : DropDown::Names) 147 | { 148 | if (i < DropDown::PointerStart) 149 | { 150 | i++; 151 | continue; 152 | } 153 | if (i > DropDown::PointerEnd-1) 154 | { 155 | i++; 156 | continue; 157 | } 158 | float itemposy = DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 5 + ((i - DropDown::PointerStart) * DropDown::Size.y); 159 | 160 | if (IsMouseInRectangle(DropDown::ParentPos.x + DropDown::Pos.x , itemposy, DropDown::DropWidth + (DropDown::SizeDifference/2), DropDown::Size.y) && IsKeyClicked(VK_LBUTTON)) 161 | { 162 | *DropDown::Index = i; 163 | DropDown::Active = false; 164 | DropDown::SetBlockedSiblings(false); 165 | DropDown::CalculateBuffer(); 166 | DropDown::ConvertSelectedName(); 167 | DropDown::ValueChangeEvent(); 168 | Sleep(50); // bandage fix to stop click through 169 | } 170 | i++; 171 | } 172 | } 173 | } 174 | void DropDown::UpdateScrollBar() 175 | { 176 | if (!IsKeyDown(VK_LBUTTON)) 177 | DropDown::ScrollBar = false; 178 | if (IsMouseInRectangle(DropDown::ParentPos.x + DropDown::Pos.x + DropDown::Size.x + (DropDown::SizeDifference / 2), DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 4, 6, (DropDown::PointerEnd - DropDown::PointerStart) * DropDown::Size.y) && IsKeyClicked(VK_LBUTTON)) 179 | DropDown::ScrollBar = true; 180 | if (DropDown::ScrollBar) 181 | { 182 | float ratio = (MousePos.y - (float)(DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 4)) / (float)((DropDown::MaxVisibleItems - 1) * DropDown::Size.y); 183 | ratio = std::clamp(ratio, 0.0f, 1.0f); 184 | DropDown::PointerEnd = (int)(DropDown::MaxVisibleItems + (DropDown::Names.size() - DropDown::MaxVisibleItems) * ratio); 185 | 186 | } 187 | DropDown::PointerStart = DropDown::PointerEnd - DropDown::MaxVisibleItems; 188 | } 189 | 190 | void DropDown::Draw() 191 | { 192 | if (!DropDown::Parent) 193 | DropDown::SetVisible(false); 194 | if (!DropDown::IsVisible()) 195 | return; 196 | OutlineRectangle(DropDown::ParentPos.x + DropDown::Pos.x - 1, DropDown::ParentPos.y + DropDown::Pos.y - 1, DropDown::Size.x + 1, DropDown::Size.y + 1, 1, Colour(130, 130, 130, 255)); 197 | FilledRectangle(DropDown::ParentPos.x + DropDown::Pos.x, DropDown::ParentPos.y +DropDown::Pos.y, DropDown::Size.x, DropDown::Size.y, Colour(80, 80, 80, 255)); 198 | float trianglex1 = DropDown::ParentPos.x + DropDown::Pos.x + DropDown::Size.x - 12; 199 | float triangley1 = DropDown::ParentPos.y + DropDown::Pos.y +3; 200 | float trianglex2 = DropDown::ParentPos.x + DropDown::Pos.x + DropDown::Size.x - 3; 201 | float triangley2 = DropDown::Pos.y + DropDown::ParentPos.y + 3; 202 | float trianglex3 = DropDown::ParentPos.x + DropDown::Pos.x + DropDown::Size.x - 7; 203 | float triangley3 = DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y - 3; 204 | if(!DropDown::Active) 205 | FilledTriangle(trianglex1, triangley1, trianglex2, triangley2, trianglex3, triangley3, Colour(255, 0, 0, 255)); 206 | DrawText(DropDown::ParentPos.x + DropDown::Pos.x + 5, DropDown::ParentPos.y + DropDown::Pos.y + (DropDown::Size.y /8),DropDown::SelectedName, "Verdana", 11, Colour(240, 240, 240, 255), None); 207 | 208 | if (DropDown::DropWidth < DropDown::Size.x) 209 | { 210 | DropDown::DropWidth = DropDown::Size.x; 211 | DropDown::SizeDifference = 0; 212 | } 213 | if (DropDown::Active) 214 | { 215 | OutlineRectangle(DropDown::ParentPos.x + DropDown::Pos.x - (DropDown::SizeDifference / 2) - 1, DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y +4, DropDown::DropWidth + 1, (DropDown::PointerEnd - DropDown::PointerStart) * DropDown::Size.y + 1, 1, Colour(130, 130, 130, 255)); 216 | FilledRectangle(DropDown::ParentPos.x + DropDown::Pos.x - (DropDown::SizeDifference / 2), DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y +5, DropDown::DropWidth, (DropDown::PointerEnd - DropDown::PointerStart) * DropDown::Size.y,Colour(80,80,80,255)); 217 | 218 | int i = 0; 219 | for (const std::wstring& name : DropDown::Names) 220 | { 221 | if (i < DropDown::PointerStart) 222 | { 223 | i++; 224 | continue; 225 | } 226 | if (i > DropDown::PointerEnd-1) 227 | { 228 | i++; 229 | continue; 230 | } 231 | float itemposy = DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 5 + ((i- DropDown::PointerStart) * DropDown::Size.y); 232 | if (IsMouseInRectangle(DropDown::ParentPos.x + DropDown::Pos.x - (DropDown::SizeDifference / 2), itemposy, DropDown::DropWidth, DropDown::Size.y)) 233 | { 234 | FilledRectangle(DropDown::ParentPos.x + DropDown::Pos.x - (DropDown::SizeDifference / 2), itemposy, DropDown::DropWidth, DropDown::Size.y, Colour(150, 150, 150, 120)); 235 | 236 | } 237 | if(i == *DropDown::Index) 238 | DrawText(DropDown::ParentPos.x + DropDown::Pos.x + 5 - (DropDown::SizeDifference / 2), itemposy + (DropDown::Size.y / 8), name, "Verdana", 11, Colour(255, 0, 0, 255), None); 239 | else 240 | DrawText(DropDown::ParentPos.x + DropDown::Pos.x + 5 - (DropDown::SizeDifference / 2), itemposy + (DropDown::Size.y / 8), name, "Verdana", 11, Colour(240, 240, 240, 255), None); 241 | i++; 242 | } 243 | OutlineRectangle(DropDown::ParentPos.x + DropDown::Pos.x + DropDown::Size.x + (DropDown::SizeDifference / 2), DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 4, 6, (DropDown::PointerEnd - DropDown::PointerStart) * DropDown::Size.y + 1, 1, Colour(130, 130, 130, 255)); 244 | int unselectedelements = Names.size() - MaxVisibleItems; 245 | float unselectedclamp = std::clamp(unselectedelements, 1, (int)Names.size()); 246 | float scrollheight = ((DropDown::PointerEnd - DropDown::PointerStart) * DropDown::Size.y) / (unselectedclamp); 247 | float scrolly = DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 5 + (((PointerEnd - MaxVisibleItems) * Size.y)); 248 | float scrollyclamp = std::clamp(scrolly, DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 5, DropDown::ParentPos.y + DropDown::Pos.y + DropDown::Size.y + 5 + ((DropDown::PointerEnd - DropDown::PointerStart) * DropDown::Size.y) - scrollheight); 249 | 250 | 251 | FilledRectangle(DropDown::ParentPos.x + DropDown::Pos.x + DropDown::Size.x + (DropDown::SizeDifference / 2), scrollyclamp, 6, scrollheight, Colour(255, 0, 0, 255)); 252 | } 253 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/DropDown.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class DropDown : public Entity 4 | { 5 | protected: 6 | float DropWidth; 7 | std::listNames; 8 | int* Index; 9 | bool Active = false; 10 | std::wstring SelectedName; 11 | float TextWidth = 0; 12 | float CutOffBuffer = 0; 13 | float SizeDifference; 14 | 15 | int MaxVisibleItems = 5; 16 | 17 | int PointerStart = 0; 18 | int PointerEnd = MaxVisibleItems; 19 | 20 | void ConvertSelectedName(); 21 | void CalculateBuffer(); 22 | void SetDropDownWidth(); 23 | void ArrowNavigation(); 24 | void UpdateScrollBar(); 25 | 26 | bool ScrollBar = false; 27 | 28 | 29 | public: 30 | DropDown(float x, float y, std::wstring text, int* items,std::listnames); 31 | void Update(); 32 | void Draw(); 33 | }; 34 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Entity.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Entity.h" 3 | #include "drawing.h" 4 | #pragma region Entity 5 | 6 | bool Entity::IsVisible() 7 | { 8 | if (Entity::Condition) 9 | return Entity::Condition(); 10 | 11 | return Entity::Visible; 12 | } 13 | void Entity::SetCondition(condition condition) 14 | { 15 | Entity::Condition = condition; 16 | } 17 | 18 | void Entity::SetVisible(bool visible) 19 | { 20 | Entity::Visible = visible; 21 | } 22 | 23 | void Entity::SetBlocked(bool block) 24 | { 25 | Entity::Blocked = block; 26 | } 27 | 28 | child Entity::GetParent() 29 | { 30 | return Entity::Parent; 31 | } 32 | child Entity::GetChildRelativeParent() 33 | { 34 | return Entity::ChildRelativeParent; 35 | } 36 | void Entity::SetBlockedSiblings(bool block) 37 | { 38 | for (auto& it : Entity::Parent->GetContainer()) 39 | { 40 | if (it == shared_from_this()) 41 | continue; 42 | 43 | it->SetBlocked(block); 44 | } 45 | } 46 | Entity* Entity::GetInstance() 47 | { 48 | return Entity::Instance; 49 | } 50 | 51 | float Entity::GetLastClick() 52 | { 53 | return Entity::LastClick; 54 | } 55 | 56 | void Entity::SetLastClick(float value) 57 | { 58 | Entity::LastClick = value; 59 | } 60 | 61 | void Entity::SetParent(child parent) 62 | { 63 | Entity::Parent = parent; 64 | } 65 | void Entity::SetRelativeParent(child parent) 66 | { 67 | Entity::ChildRelativeParent = parent; 68 | } 69 | #pragma endregion 70 | 71 | #pragma region Events 72 | 73 | void Entity::SetValueChangedEvent(std::function evnt) 74 | { 75 | Entity::ValueChangeEvent = evnt; 76 | } 77 | 78 | std::function Entity::GetValueChangedEvent() 79 | { 80 | return Entity::ValueChangeEvent; 81 | } 82 | #pragma endregion 83 | 84 | #pragma region Container 85 | void Container::Draw() 86 | { 87 | // Reverse iterate 88 | 89 | for (auto it = ContainerInstance.crbegin(); it != ContainerInstance.crend(); it++) 90 | { 91 | (*it)->Draw(); 92 | } 93 | } 94 | void Container::Update() 95 | { 96 | for (auto it = ContainerInstance.crbegin(); it != ContainerInstance.crend(); it++) 97 | { 98 | (*it)->Update(); 99 | } 100 | } 101 | /*childcontainer& Container::Container() 102 | { 103 | return Container::ContainerInstance; 104 | }*/ 105 | 106 | /*size_t Container::GetChildren() 107 | { 108 | return Container::ContainerInstance.size(); 109 | }*/ 110 | #pragma endregion -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Entity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class Entity; 3 | using condition = std::function< bool() >; 4 | using child = std::shared_ptr; 5 | using childcontainer = std::vector< child >; 6 | 7 | class Entity : public std::enable_shared_from_this 8 | { 9 | 10 | protected: 11 | bool Visible; 12 | bool Blocked = false; 13 | 14 | condition Condition; 15 | 16 | child Parent; 17 | child ChildRelativeParent; 18 | 19 | Vector2 Pos; 20 | Vector2 Size; 21 | Vector2 OriginalSize; 22 | Vector2 Scale; 23 | Vector2 TextSize; 24 | Vector2 ParentPos; 25 | Vector2 ParentSize; 26 | 27 | std::wstring Name; 28 | 29 | Entity* Instance = this; 30 | 31 | float LastClick = 0; 32 | 33 | // event handlers. 34 | std::function< void()> ValueChangeEvent = []() {}; // blank event 35 | public: 36 | // This can be overriden by the parent. 37 | virtual void Draw() {}; 38 | virtual void Update() {}; 39 | 40 | virtual childcontainer& GetContainer() { static childcontainer bad{}; return bad; } 41 | virtual size_t Children() { return 0; } 42 | 43 | virtual Vector2 GetPos() { return Pos; } 44 | virtual Vector2 GetSize() { return Size; } 45 | virtual Vector2 GetScale() { return Scale; } 46 | virtual Vector2 GetParentPos() { return ParentPos; } 47 | virtual Vector2 GetParentSize() { return ParentSize; } 48 | virtual std::wstring GetName() { return Name; } 49 | 50 | 51 | child GetChildRelativeParent(); 52 | child GetParent(); 53 | Entity* GetInstance(); 54 | 55 | 56 | 57 | bool IsVisible(); 58 | 59 | float GetLastClick(); 60 | 61 | void SetLastClick(float value); 62 | void SetCondition(condition condition); 63 | void SetVisible(bool visible); 64 | void SetBlocked(bool block); 65 | void SetBlockedSiblings(bool block); 66 | void SetParent(child parent); 67 | void SetRelativeParent(child parent); 68 | 69 | // event handlers 70 | void SetValueChangedEvent(std::function< void()> evnt); 71 | std::function< void()> GetValueChangedEvent(); 72 | 73 | 74 | friend class Container; 75 | friend class Tab; 76 | friend class ListBoxTab; 77 | friend class GroupBox; 78 | }; 79 | class Container : public Entity 80 | { 81 | protected: 82 | childcontainer ContainerInstance; 83 | public: 84 | virtual child Push(child child) 85 | { 86 | 87 | child.get()->Parent = shared_from_this(); 88 | ContainerInstance.emplace_back(child); 89 | return child; 90 | 91 | } 92 | void Draw(); 93 | void Update(); 94 | virtual childcontainer& GetContainer() override { return ContainerInstance; } 95 | virtual size_t Children() override { return ContainerInstance.size(); } 96 | 97 | 98 | }; 99 | using EntityVector = std::shared_ptr< Container >; -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Form.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Form.h" 3 | #include "pch.h" 4 | #include "Form.h" 5 | #include "Drawing.h" 6 | #include "input.h" 7 | #include "Entity.h" 8 | #include "GUI.h" 9 | Form::Form(float x, float y, float w, float h, float borderwidth, float borderheight, std::wstring text, bool stretch) 10 | { 11 | Form::Name = text; 12 | Form::Pos = { x, y }; 13 | Form::Size = { w, h }; 14 | Form::OriginalSize = Form::Size; 15 | Form::SetVisible(true); 16 | Form::Stretching = false; 17 | Form::Dragging = false; 18 | Form::Drag = { 0,0 }; 19 | Form::Scale.x = (Form::Size.x / Form::OriginalSize.x); 20 | Form::Scale.y = (Form::Size.y / Form::OriginalSize.y); 21 | Form::Border.x = borderwidth; 22 | Form::Border.y = borderheight; 23 | Form::CanStretch = stretch; 24 | Form::CanClose = true; 25 | Form::CanMinimize = true; 26 | SetVisible(true); 27 | 28 | } 29 | void Form::DragAction() 30 | { 31 | if (Form::Dragging && !IsKeyDown(VK_LBUTTON)) 32 | Form::Dragging = false; 33 | 34 | if (Form::Dragging) 35 | { 36 | 37 | Form::Pos.x = Form::Cursor.x - Form::Drag.x; 38 | Form::Pos.y = Form::Cursor.y - Form::Drag.y; 39 | } 40 | if (IsMouseInRectangle(Form::Pos, Form::TitleBar)) 41 | { 42 | 43 | if (IsKeyClicked(VK_LBUTTON)) // This prevents a user holding down and hovering over the title bar to drag it. You need to actually click down. 44 | Form::Dragging = true; 45 | 46 | Form::Drag.x = Form::Cursor.x - Form::Pos.x; 47 | Form::Drag.y = Form::Cursor.y - Form::Pos.y; 48 | } 49 | } 50 | void Form::StretchAction() 51 | { 52 | if (Form::Blocked) 53 | return; 54 | // If the user clicks in the rectangle we go through all forms and then set this one as the highest priority to draw 55 | StretchPoint1 = Vector2{ Form::Pos.x + Form::Size.x, Form::Pos.y + Form::Size.y }; 56 | StretchPoint2 = Vector2{ Form::Pos.x + Form::Size.x - (25 * Form::Scale.x), Form::Pos.y + Form::Size.y }; 57 | StretchPoint3 = Vector2{ Form::Pos.x + Form::Size.x, Form::Pos.y + Form::Size.y - (25 * Form::Scale.y) }; 58 | 59 | if (Form::Stretching && !IsKeyDown(VK_LBUTTON)) 60 | { 61 | Form::Stretching = false; 62 | } 63 | if (Form::Stretching) 64 | { 65 | float stretchx = Form::Cursor.x - Form::Stretch.x; 66 | float stretchy = Form::Cursor.y - Form::Stretch.y; 67 | Vector2 Stretched{ stretchx,stretchy }; 68 | // Prevent the gui going below the original scale 69 | if (stretchx > Form::OriginalSize.x && stretchy > Form::OriginalSize.y) 70 | { 71 | Form::Scale.x = (Form::Size.x / Form::OriginalSize.x); 72 | Form::Scale.y = (Form::Size.y / Form::OriginalSize.y); 73 | Form::Size.x = stretchx; 74 | Form::Size.y = stretchy; 75 | } 76 | } 77 | if (IsMouseInTriangle(StretchPoint1, StretchPoint2, StretchPoint3) && Form::CanStretch) 78 | { 79 | if (IsKeyClicked(VK_LBUTTON)) 80 | Form::Stretching = true; 81 | 82 | Form::Stretch.x = Form::Cursor.x - (Form::Size.x); 83 | Form::Stretch.y = Form::Cursor.y - (Form::Size.y); 84 | 85 | } 86 | } 87 | void Form::Update() 88 | { 89 | 90 | if (!Form::Parent) 91 | Form::SetVisible(false); 92 | if (!Form::IsVisible()) 93 | return; 94 | //SetCursor() 95 | Form::TitleBar = { Form::Size.x, Form::Border.y }; 96 | Form::Cursor = MousePos; 97 | Form::ParentPos = { Form::Pos.x + Form::Border.x,Form::Pos.y + Form::Border.y }; 98 | if (Form::Blocked) 99 | return; 100 | Form::DragAction(); 101 | Form::StretchAction(); 102 | 103 | Container::Update(); 104 | 105 | } 106 | 107 | void Form::Draw() 108 | { 109 | 110 | if (!Form::IsVisible()) 111 | return; 112 | // when someone clicks into a form it will prioritize the drawing of the form. 113 | if (IsMouseInRectangle(Form::Pos, Form::Size) && IsKeyClicked(VK_LBUTTON)) 114 | { 115 | Form::SetLastClick(clock() * 0.00001f); // we multiple it for accuracy purposes to turn it into a float 116 | } 117 | if (!IsMouseInTriangle(StretchPoint1, StretchPoint2, StretchPoint3) && IsMouseInRectangle(Form::Pos, Form::Size) && GetCurrentCursor() == Cursors["Corner Drag"] && !Form::Stretching) 118 | SetCurrentCursor("Default"); 119 | if (IsMouseInTriangle(StretchPoint1, StretchPoint2, StretchPoint3) && Form::CanStretch) 120 | SetCurrentCursor("Corner Drag"); 121 | 122 | OutlineRectangle((Form::Pos.x - Form::Border.x / 2) + 1, (Form::Pos.y - Form::Border.x / 2) + 1, Form::Size.x + Form::Border.x - 1, Form::Size.y + Form::Border.x - 1, 1, Colour(140, 140, 140, 255)); // Draw Border 123 | FilledRectangle(Form::Pos.x, Form::Pos.y, Form::Size.x, Form::Size.y, Colour(40, 40, 40, 255)); 124 | FilledRectangle(Form::Pos.x, Form::Pos.y, Form::Size.x, Form::Border.y, Colour(30, 30, 30, 255)); // header 125 | DrawText(Form::Pos.x + 5, Form::Pos.y + 5, Form::Name, "Verdana", 12, Colour(255, 255, 255, 255), None); 126 | if (Form::CanStretch) 127 | FilledTriangle(StretchPoint1.x, StretchPoint1.y, StretchPoint2.x, StretchPoint2.y, StretchPoint3.x, StretchPoint3.y, Colour(255, 0, 0)); 128 | 129 | 130 | Container::Draw(); 131 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Form.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class Form : public Container 4 | { 5 | protected: 6 | bool Dragging; 7 | bool Stretching; 8 | bool CanStretch; 9 | bool CanMinimize; 10 | bool CanClose; 11 | 12 | float InitTime; 13 | 14 | Vector2 Drag; 15 | Vector2 Stretch; 16 | Vector2 Border; 17 | Vector2 TitleBar; 18 | 19 | Vector2 Cursor; 20 | 21 | Vector2 StretchPoint1; 22 | Vector2 StretchPoint2; 23 | Vector2 StretchPoint3; 24 | 25 | void DragAction(); 26 | void StretchAction(); 27 | 28 | public: 29 | Form(float x, float y, float w, float h, float borderwidth, float borderheight, std::wstring text, bool drag); 30 | void Draw(); 31 | void Update(); 32 | }; -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/GroupBox.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "GroupBox.h" 3 | #include "Input.h" 4 | #include "Gui.h" 5 | #include "Drawing.h" 6 | #include "Font.h" 7 | GroupBox::GroupBox(std::wstring name, float x, float y, float width, float height) 8 | { 9 | GroupBox::Size = { width,height }; 10 | GroupBox::SetVisible(true); 11 | GroupBox::Pos = { x,y }; 12 | GroupBox::Name = name; 13 | GroupBox::TextHeight = GetTextHeight(GroupBox::Name, 12, "Verdana"); 14 | GroupBox::TextWidth = GetTextWidth(GroupBox::Name, 12, "Verdana"); 15 | GroupBox::TextStartOffset = 5; 16 | SetVisible(true); 17 | } 18 | void GroupBox::Update() 19 | { 20 | if (!GroupBox::Parent) 21 | GroupBox::SetVisible(false); 22 | 23 | if (!GroupBox::IsVisible()) 24 | return; 25 | GroupBox::TextStartPos = GroupBox::Parent->GetParent()->GetPos().x + GroupBox::Pos.x + GroupBox::TextStartOffset; 26 | GroupBox::ParentPos = { GroupBox::Parent->GetParent()->GetPos().x + GroupBox::Pos.x + 5, GroupBox::Parent->GetParent()->GetPos().y + GroupBox::Pos.y + 10}; 27 | GroupBox::ParentSize = { GroupBox::Size }; 28 | 29 | for (child& it : GroupBox::GetContainer()) 30 | { 31 | // if it exceeds the position/size of this then dont draw it. 32 | bool inbox = ( 33 | GroupBox::ParentPos.x + it->Pos.x > GroupBox::Pos.x && 34 | GroupBox::ParentPos.y + it->Pos.y > GroupBox::Pos.y && 35 | GroupBox::ParentPos.x + it->Pos.x + it->Size.x < GroupBox::ParentPos.x + GroupBox::Pos.x + GroupBox::Size.x && 36 | GroupBox::ParentPos.y + it->Pos.y + it->Size.y < GroupBox::ParentPos.y+ GroupBox::Pos.y + GroupBox::Size.y 37 | ); 38 | it->SetVisible(inbox); 39 | 40 | } 41 | 42 | 43 | } 44 | void GroupBox::Draw() 45 | { 46 | if (!GroupBox::IsVisible()) 47 | return; 48 | FilledLine(GroupBox::Parent->GetParent()->GetPos().x + GroupBox::Pos.x, GroupBox::Parent->GetParent()->GetPos().y + GroupBox::Pos.y, TextStartPos, GroupBox::Parent->GetParent()->GetPos().y + GroupBox::Pos.y, 2, Colour(0, 0, 0, 255)); // draw up to text 49 | FilledLine(TextStartPos + GroupBox::TextWidth, GroupBox::Parent->GetParent()->GetPos().y + GroupBox::Pos.y, GroupBox::Parent->GetParent()->GetPos().x + GroupBox::Pos.x + GroupBox::Size.x, GroupBox::Parent->GetParent()->GetPos().y + GroupBox::Pos.y, 2, Colour(0, 0, 0, 255)); // draw past 50 | OutlineRectangle(GroupBox::Parent->GetParent()->GetPos().x + GroupBox::Pos.x, GroupBox::Parent->GetParent()->GetPos().y + GroupBox::Pos.y +1, GroupBox::Size.x, GroupBox::Size.y-1, 2, Colour(0, 0, 0, 255)); 51 | FilledRectangle(GroupBox::Parent->GetParent()->GetPos().x + GroupBox::Pos.x, GroupBox::Parent->GetParent()->GetPos().y + GroupBox::Pos.y, GroupBox::Size.x, GroupBox::Size.y, Colour(30, 30, 30, 255)); 52 | 53 | DrawText(TextStartPos + 1, GroupBox::Parent->GetParent()->GetPos().y + GroupBox::Pos.y - (TextHeight / 2), GroupBox::Name, "Verdana", 12, Colour(255, 255, 255, 255), None); 54 | Container::Draw(); 55 | Container::Update(); 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/GroupBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class GroupBox : public Container 4 | { 5 | protected: 6 | float TextWidth; 7 | float TextHeight; 8 | float TextStartPos; 9 | int TextStartOffset; 10 | 11 | float YBuffer; 12 | public: 13 | GroupBox(std::wstring name, float x, float y, float width, float height); 14 | void Update(); 15 | void Draw(); 16 | }; 17 | 18 | 19 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/KeyBind.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "KeyBind.h" 3 | #include "Drawing.h" 4 | #include "Input.h" 5 | #include "GUI.h" 6 | KeyBind::KeyBind(float x, float y, std::wstring text, int* key) 7 | { 8 | KeyBind::Pos = {x,y}; 9 | KeyBind::Name = text; 10 | KeyBind::Key = key; 11 | KeyBind::Size = { 80,20 }; 12 | KeyBind::ConvertKeyToName(); 13 | KeyBind::ContextSize = { 80.0f,20.0f * (int)KeyBind::ContextNames.size() }; 14 | SetVisible(true); 15 | } 16 | void KeyBind::ConvertKeyToName() 17 | { 18 | if (KeyBind::Active) 19 | { 20 | KeyBind::KeyName = L"[Click A Key]"; 21 | return; 22 | } 23 | if (*KeyBind::Key == NULL && !KeyBind::Active) 24 | { 25 | KeyBind::KeyName = L"[Unbound]"; 26 | return; 27 | } 28 | 29 | int keycode = *KeyBind::Key; 30 | int scancode = MapVirtualKey(keycode, MAPVK_VK_TO_VSC); 31 | WCHAR keyname[256] = { 0 }; 32 | if (SymbolKeys[keycode] != L"") 33 | { 34 | KeyBind::KeyName = SymbolKeys[keycode]; 35 | return; 36 | } 37 | if (GetKeyNameTextW((scancode << 16), keyname, sizeof(keyname) / sizeof(keyname[0])) == 0 && KeyBind::Key != NULL) 38 | { 39 | KeyBind::KeyName = L"[Unknown Key]"; 40 | } 41 | else 42 | { 43 | KeyBind::KeyName = keyname; 44 | } 45 | 46 | } 47 | void KeyBind::Update() 48 | { 49 | if (!KeyBind::Parent) 50 | KeyBind::SetVisible(false); 51 | if (!KeyBind::IsVisible()) 52 | return; 53 | 54 | KeyBind::ContextMenu(); 55 | KeyBind::ParentPos = KeyBind::Parent->GetParentPos(); 56 | if (!KeyBind::Blocked) 57 | { 58 | if (IsMouseInRectangle(KeyBind::Pos + ParentPos, KeyBind::Size) && IsKeyClicked(VK_LBUTTON) && KeyBind::LastClick < (clock() * 0.00001f) && !KeyBind::Blocked && !KeyBind::Active) 59 | { 60 | // KeyBind::SetBlockedSiblings(true); 61 | KeyBind::Blocked = true; 62 | KeyBind::LastClick = (clock() * 0.00001f) + 0.002f; 63 | KeyBind::Active = true; 64 | KeyBind::Blocked = false; 65 | } 66 | } 67 | if (Active) 68 | { 69 | *KeyBind::Key = 0; 70 | KeyBind::KeyName = L"[Click A Key]"; 71 | KeyBind::CollectInput(); 72 | KeyBind::ConvertKeyToName(); 73 | } 74 | 75 | } 76 | void KeyBind::ContextMenu() 77 | { 78 | if (IsMouseInRectangle(KeyBind::Pos + KeyBind::ParentPos, KeyBind::Size) && IsKeyClicked(VK_RBUTTON) && !KeyBind::Blocked && !KeyBind::Active) 79 | { 80 | KeyBind::ContextActive = true; 81 | KeyBind::Active = false; 82 | KeyBind::ContextPos = MousePos; 83 | SetBlockedSiblings(true); 84 | } 85 | if (!IsMouseInRectangle(KeyBind::ContextPos, KeyBind::ContextSize) && IsKeyClicked(VK_LBUTTON)) 86 | { 87 | if (KeyBind::ContextActive) 88 | SetBlockedSiblings(false); 89 | KeyBind::ContextActive = false; 90 | } 91 | if (!KeyBind::ContextActive) 92 | return; 93 | int i = 0; 94 | for (auto& pair : KeyBind::ContextNames) 95 | { 96 | if (IsMouseInRectangle(KeyBind::ContextPos.x, KeyBind::ContextPos.y + (i * 20), KeyBind::ContextSize.x, 20) && IsKeyClicked(VK_LBUTTON) && KeyBind::LastClick < (clock() * 0.00001f)) 97 | { 98 | pair.second(); 99 | KeyBind::LastClick = (clock() * 0.00001f) + 0.002f; 100 | } 101 | i++; 102 | } 103 | } 104 | void KeyBind::Copy() 105 | { 106 | KeyBindClipBoard = *KeyBind::Key; 107 | } 108 | void KeyBind::Paste() 109 | { 110 | *KeyBind::Key = KeyBindClipBoard; 111 | KeyBind::ConvertKeyToName(); 112 | KeyBind::ValueChangeEvent(); 113 | } 114 | void KeyBind::CollectInput() 115 | { 116 | for (int i=0; i <= 255; i++) 117 | { 118 | if (IsKeyClicked(VK_RETURN) || IsKeyClicked(VK_ESCAPE)) 119 | { 120 | KeyBind::Active = false; 121 | return; 122 | } 123 | if (IsKeyClicked(i) && KeyBind::LastClick < (clock() * 0.00001f)) 124 | { 125 | *KeyBind::Key = i; 126 | KeyBind::Active = false; 127 | KeyBind::LastClick = (clock() * 0.00001f) + 0.002f; 128 | KeyBind::ValueChangeEvent(); 129 | return; 130 | 131 | } 132 | } 133 | } 134 | void KeyBind::Draw() 135 | { 136 | if (!KeyBind::Parent) 137 | KeyBind::SetVisible(false); 138 | if (!KeyBind::IsVisible()) 139 | return; 140 | 141 | OutlineRectangle(ParentPos.x + Pos.x-1, ParentPos.y + Pos.y-1, Size.x + 1, Size.y + 1, 1, Colour(130, 130, 130, 255)); 142 | FilledRectangle(ParentPos.x + KeyBind::Pos.x, ParentPos.y + KeyBind::Pos.y, KeyBind::Size.x, KeyBind::Size.y, Colour(80, 80, 80, 255)); 143 | DrawText(ParentPos.x + KeyBind::Pos.x, ParentPos.y + KeyBind::Pos.y -KeyBind::Size.y, KeyBind::Name, "Verdana", 12, Colour(240, 240, 240, 255), None); 144 | DrawText(ParentPos.x + KeyBind::Pos.x + (KeyBind::Size.x / 2), ParentPos.y + KeyBind::Pos.y + (KeyBind::Size.y / 2),KeyName, "Verdana", 10, Colour(240, 240, 240, 255), CentreCentre); 145 | if (KeyBind::ContextActive) 146 | { 147 | OutlineRectangle(KeyBind::ContextPos.x, KeyBind::ContextPos.y, KeyBind::ContextSize.x, KeyBind::ContextSize.y, 1, Colour(255, 255, 255, 255)); 148 | FilledRectangle(KeyBind::ContextPos.x, KeyBind::ContextPos.y, KeyBind::ContextSize.x, KeyBind::ContextSize.y, Colour(80, 80, 80, 255)); 149 | int i = 0; 150 | for (auto pair : KeyBind::ContextNames) 151 | { 152 | if (i != 0) 153 | FilledLine(KeyBind::ContextPos.x, KeyBind::ContextPos.y + i * 20, KeyBind::ContextPos.x + KeyBind::ContextSize.x, KeyBind::ContextPos.y + i * 20, 1.0f, Colour(255, 255, 255, 255)); 154 | 155 | if (IsMouseInRectangle(KeyBind::ContextPos.x, KeyBind::ContextPos.y + (i * 20), KeyBind::ContextSize.x, 20)) 156 | FilledRectangle(KeyBind::ContextPos.x, KeyBind::ContextPos.y + (i * 20), KeyBind::ContextSize.x, 20, Colour(120, 120, 120, 255)); 157 | DrawText(KeyBind::ContextPos.x + (KeyBind::ContextSize.x / 2), KeyBind::ContextPos.y + (i * 20) + 10, pair.first, "Verdana", 11, Colour(255, 255, 255, 255), CentreCentre); 158 | 159 | i++; 160 | } 161 | } 162 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/KeyBind.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class KeyBind : public Entity 4 | { 5 | protected: 6 | int* Key; 7 | void CollectInput(); 8 | std::wstring KeyName; 9 | bool Active = false; 10 | void ConvertKeyToName(); 11 | 12 | bool ContextActive = false; 13 | Vector2 ContextPos; 14 | Vector2 ContextSize; 15 | void ContextMenu(); 16 | void Copy(); 17 | void Paste(); 18 | std::map> ContextNames = { 19 | { L"Copy", [this]() { Copy(); } }, 20 | { L"Paste", [this]() { Paste(); } } 21 | }; 22 | 23 | std::map SymbolKeys = { {VK_LEFT,L"Left"},{VK_RIGHT,L"Right"},{VK_UP,L"Up"},{VK_DOWN,L"Down"},{VK_LWIN,L"Win"},{VK_RWIN,L"Win"} 24 | ,{VK_RWIN,L"Win"} ,{VK_DELETE,L"Delete"} ,{VK_INSERT,L"Insert"},{VK_END,L"End"},{VK_HOME,L"Home"},{VK_NEXT,L"Pg Up"},{VK_DOWN,L"Pg Down"} 25 | ,{VK_NUMLOCK,L"Num Lock"} ,{VK_DIVIDE,L"Num /"},{VK_LBUTTON,L"Mouse 1"},{VK_RBUTTON,L"Mouse 2"},{VK_MBUTTON,L"Mid Mouse"},{VK_XBUTTON1,L"Mouse 4"},{VK_XBUTTON2,L"Mouse5"} 26 | ,{VK_MENU,L"Alt"},{VK_RMENU,L"Right Alt"} ,{VK_LMENU,L"Left Alt"} }; 27 | public: 28 | KeyBind(float x, float y, std::wstring text, int* key); 29 | void Update(); 30 | void Draw(); 31 | }; 32 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Label.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Drawing.h" 3 | #include "label.h" 4 | 5 | Label::Label(std::wstring text, float posx, float posy) 6 | { 7 | Label::Pos = { posx,posy }; 8 | Label::Name = text; 9 | SetVisible(true); 10 | } 11 | void Label::Update() 12 | { 13 | if (!Label::Parent) 14 | Label::SetVisible(false); 15 | if (!Label::IsVisible()) 16 | return; 17 | Label::ParentPos = Label::Parent->GetParentPos(); 18 | } 19 | void Label::Draw() 20 | { 21 | if (!Label::Parent) 22 | Label::SetVisible(false); 23 | if (!Label::IsVisible()) 24 | return; 25 | DrawText( Label::ParentPos.x + Label::Pos.x, Label::ParentPos.y + Label::Pos.y, Label::Name, "Verdana", 12, Colour(255, 255, 255, 255), None); 26 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Label.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | 4 | class Label : public Entity 5 | { 6 | protected: 7 | bool Tabbed; 8 | public: 9 | Label(std::wstring, float, float); 10 | void Update(); 11 | void Draw(); 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Slider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | #include "Drawing.h" 4 | #include "Input.h" 5 | // due to using templates in c++ classes it is illegal to use a c++ file so this will look rather odd to the other code. 6 | template 7 | class Slider : public Entity 8 | { 9 | protected: 10 | T MinValue; 11 | T MaxValue; 12 | T* Value; 13 | T OutputValue; 14 | 15 | bool Held = false; 16 | 17 | std::wstring Measurement; 18 | std::wstring OutputString; 19 | 20 | void ConvertValueToString() 21 | { 22 | OutputString = std::to_wstring(OutputValue); 23 | size_t dotpos = OutputString.find(L"."); 24 | if (dotpos != std::string::npos) { 25 | if (OutputString.length() > dotpos + 2) { 26 | OutputString.resize(dotpos + 3); // Truncate to two places after the decimal place 27 | } 28 | } 29 | } 30 | 31 | public: 32 | void Update() 33 | { 34 | if (!Parent) 35 | SetVisible(false); 36 | if (!IsVisible()) 37 | return; 38 | 39 | ParentPos = Parent->GetParentPos(); 40 | 41 | 42 | if (!IsKeyDown(VK_LBUTTON)) 43 | { 44 | if(Held == true) 45 | ValueChangeEvent(); 46 | Held = false; 47 | } 48 | if (IsMouseInRectangle(ParentPos.x + Pos.x - 2, ParentPos.y + (Pos.y + 15) - 2, Size.x + 3, Size.y + 3) && IsKeyClicked(VK_LBUTTON) && !Blocked) 49 | { 50 | Held = true; 51 | } 52 | if (Held) 53 | { 54 | // make sure no clicks go through when holding. 55 | const float clamp = std::clamp((float)MousePos.x - (float)(Pos.x + ParentPos.x), 0.00f, (float)Size.x); 56 | const float ratio = clamp / Size.x; 57 | *Value = MinValue + (MaxValue - MinValue) * ratio; 58 | OutputValue = *Value; 59 | ConvertValueToString(); 60 | } 61 | } 62 | void Draw() 63 | { 64 | if (!IsVisible()) 65 | return; 66 | if (!Parent) 67 | SetVisible(false); 68 | DrawText(ParentPos.x + Pos.x, (ParentPos.y + Pos.y) - 5, Name + L": " + OutputString + Measurement, "Verdana", 12, Colour(255, 255, 255, 255), None); 69 | OutlineRectangle(ParentPos.x + Pos.x - 1, ParentPos.y + (Pos.y + 15) - 1, Size.x + 2, Size.y + 2, 1, Colour(255, 255, 255, 255)); 70 | FilledRectangle(ParentPos.x + Pos.x, ParentPos.y + (Pos.y + 15), Size.x, Size.y, Colour(80, 80, 80, 255)); 71 | float ratio = (float)(*Value - (float)MinValue) / float(MaxValue - MinValue); 72 | FilledRectangle(ParentPos.x + Pos.x, ParentPos.y + (Pos.y + 15), (int)Size.x * ratio, Size.y, Colour(255, 0, 0, 255)); 73 | } 74 | Slider(int x, int y, std::wstring name, std::wstring measurement, T minvalue, T maxvalue, T* value) : Measurement(measurement), MaxValue(maxvalue), MinValue(minvalue), Value(value) 75 | { 76 | Pos = { (float)x,(float)y }; 77 | Name = name; 78 | Size = { 100,7 }; 79 | OutputValue = *Value; 80 | ConvertValueToString(); 81 | SetVisible(true); 82 | } 83 | 84 | }; -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Tab.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Tab.h" 3 | #include "Input.h" 4 | #include "Gui.h" 5 | #include "Drawing.h" 6 | Tab::Tab(std::wstring name, float x, float y, float width, float height, int* selectedtab = nullptr) 7 | { 8 | Tab::Size = { width,height }; 9 | Tab::SetVisible(true); 10 | Tab::Index = TabCount; // this doesn't need to be changed for a different set of tabs or whatever, you dont need to import a value here you just need a nonce value so you never get a repeated one 11 | Tab::Pos = { x,y }; 12 | Tab::Selected = selectedtab; 13 | Tab::Name = name; 14 | // Tab::Size.x += 1; 15 | TabCount++; 16 | SetVisible(true); 17 | } 18 | void Tab::Update() 19 | { 20 | if (!Tab::Parent) 21 | Tab::SetVisible(false); 22 | 23 | if (!Tab::IsVisible()) 24 | return; 25 | Tab::ParentPos = Tab::GetParent()->GetParentPos(); 26 | Tab::ParentSize = Tab::GetParent()->GetSize(); 27 | 28 | size_t ignorecount = 0; 29 | 30 | for (child& it : Tab::Parent->GetContainer()) 31 | { 32 | if (it == shared_from_this()) 33 | break; 34 | 35 | if (!it->IsVisible()) 36 | ++ignorecount; 37 | } 38 | bool selected = Index == *Selected; 39 | if (!selected && !Tab::Blocked) 40 | { 41 | if (IsMouseInRectangle(Tab::ParentPos.x + Tab::Pos.x, (Tab::ParentPos.y + Tab::ParentSize.y) - Tab::Pos.y, Tab::Size.x, Tab::Size.y) && IsKeyClicked(VK_LBUTTON) && !selected && Tab::LastClick < (clock() * 0.00001f)) 42 | { 43 | 44 | *Selected = Index; 45 | // ideally you just want to make a timer and use that but since this is just poc we do this 46 | Tab::LastClick = (clock() * 0.00001f) + 0.002f; 47 | Tab::ValueChangeEvent(); 48 | } 49 | } 50 | 51 | } 52 | void Tab::Draw() 53 | { 54 | if (!Tab::IsVisible()) 55 | return; 56 | 57 | Color textcolour = Colour(0, 0, 255, 255); 58 | bool selected = Index == *Selected; 59 | 60 | textcolour = Colour(255, 0, 0, 255); 61 | FilledRectangle(Tab::ParentPos.x + Tab::Pos.x, (Tab::ParentPos.y + Tab::ParentSize.y) - Tab::Pos.y, Tab::Size.x, Tab::Size.y, Colour(80, 80, 80, 255)); 62 | DrawText(Tab::ParentPos.x + Tab::Pos.x + (Tab::Size.x / 2), ((Tab::ParentPos.y + Tab::ParentSize.y) - Tab::Pos.y) + (Tab::Size.y / 2), Tab::Name, "Verdana", 12, Colour(255, 255, 255, 255), CentreCentre); 63 | 64 | if (selected) 65 | { 66 | Container::Draw(); 67 | Container::Update(); 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Tab.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class Tab : public Container 4 | { 5 | protected: 6 | int Index; 7 | int* Selected; 8 | public: 9 | Tab(std::wstring name, float x, float y, float width, float height, int* selectedtab); 10 | void Update(); 11 | void Draw(); 12 | }; 13 | 14 | 15 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/TabController.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TabController.h" 3 | TabController::TabController() 4 | { 5 | TabController::SetVisible(true); 6 | } 7 | 8 | void TabController::Update() 9 | { 10 | if (!TabController::Parent) 11 | TabController::SetVisible(false); 12 | 13 | // The tab control is NOT valid, or disabled. 14 | if (!TabController::IsVisible()) 15 | return; 16 | TabController::ParentPos = TabController::Parent->GetParentPos(); 17 | TabController::Pos.x = TabController::Parent->GetPos().x; 18 | TabController::Pos.y = TabController::Parent->GetPos().y; 19 | TabController::Size = TabController::Parent->GetSize(); 20 | TabController::Container::Update(); 21 | } 22 | 23 | void TabController::Draw() 24 | { 25 | if (!TabController::IsVisible()) 26 | return; 27 | int size = TabController::Size.x / 12; 28 | // FilledRectangle(TabController::Pos.x, TabController::Pos.y + TabController::Size.y - size, TabController::Size.x, size, Colour(25, 25, 25, 255)); 29 | 30 | TabController::Container::Draw(); 31 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/TabController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class TabController : public Container 4 | { 5 | public: 6 | TabController(); 7 | void Update(); 8 | void Draw(); 9 | }; -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/TabListBox.cpp: -------------------------------------------------------------------------------- 1 | #include "Pch.h" 2 | #include "TabListBox.h" 3 | #include "GUI.h" 4 | #include "Input.h" 5 | #include "Drawing.h" 6 | #include "Font.h" 7 | #include "Graphics.h" 8 | 9 | TabListBox::TabListBox(std::wstring name) 10 | { 11 | TabListBox::Name = name; 12 | TabListBox::Index = TabCount; 13 | TabCount++; 14 | SetVisible(true); 15 | } 16 | 17 | void TabListBox::Update() 18 | { 19 | TabListBox::ParentPos = TabListBox::Parent->GetParentPos(); 20 | TabListBox::Pos = TabListBox::Parent->GetParentPos(); 21 | Container::Update(); 22 | } 23 | void TabListBox::Draw() 24 | { 25 | Container::Draw(); 26 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/TabListBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class TabListBox : public Container 4 | { 5 | protected: 6 | int* Selected; 7 | public: 8 | TabListBox(std::wstring name); 9 | int Index; 10 | void Update(); 11 | void Draw(); 12 | }; 13 | 14 | 15 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/TabListBoxController.cpp: -------------------------------------------------------------------------------- 1 | #include "Pch.h" 2 | #include "TabListBoxController.h" 3 | #include "GUI.h" 4 | #include "Input.h" 5 | #include "Drawing.h" 6 | #include "Font.h" 7 | #include "Graphics.h" 8 | #include "TabListBox.h" 9 | TabListBoxController::TabListBoxController(float x, float y, float width, float height) 10 | { 11 | TabListBoxController::Pos = { x,y }; 12 | TabListBoxController::Size = { width,height }; 13 | TabListBoxController::Selected = 0; 14 | TabListBoxController::PointerEnd = TabListBoxController::Size.y / 20; 15 | TabListBoxController::PointerStart = 0; 16 | TabListBoxController::SetActiveIndex(); 17 | SetVisible(true); 18 | } 19 | void TabListBoxController::SetActiveIndex() 20 | { 21 | int i = 0; 22 | for (auto tab : TabListBoxController::Tabs) 23 | { 24 | if (tab->Index == TabListBoxController::Selected) 25 | { 26 | TabListBoxController::ActiveIndex = i; 27 | return; 28 | } 29 | i++; 30 | } 31 | } 32 | void TabListBoxController::UpdateCulledNames() 33 | { 34 | CulledNames.clear(); 35 | for (std::wstring str : TabListBoxController::Names) 36 | { 37 | std::wstring culledname = L""; 38 | float width = GetTextWidth(str, 11, "Verdana"); 39 | if (width < TabListBoxController::Size.x - TabListBoxController::ScrollWidth + 2) 40 | { 41 | CulledNames.push_back(str); 42 | 43 | } 44 | else 45 | { 46 | culledname = str; 47 | for (int i = culledname.length(); i > 0; i--) 48 | { 49 | culledname.erase(std::prev((culledname).end())); 50 | float width = GetTextWidth(culledname + L"..", 11, "Verdana"); 51 | if (width < TabListBoxController::Size.x - TabListBoxController::ScrollWidth + 2) 52 | { 53 | CulledNames.push_back(culledname + L".."); 54 | break; 55 | } 56 | } 57 | 58 | } 59 | } 60 | 61 | 62 | } 63 | void TabListBoxController::ArrowKeyNavigation() 64 | { 65 | if (TabListBoxController::Tabs.size() < TabListBoxController::Size.y / 20) 66 | return; 67 | if (!Active) 68 | return; 69 | if (IsKeyClicked(VK_DOWN) && TabListBoxController::LastClick < (clock() * 0.00001f)) 70 | { 71 | if (TabListBoxController::Tabs.size() > TabListBoxController::PointerEnd) 72 | { 73 | TabListBoxController::PointerEnd++; 74 | TabListBoxController::PointerStart++; 75 | TabListBoxController::LastClick = (clock() * 0.00001f) + 0.002f; 76 | } 77 | } 78 | if (IsKeyClicked(VK_UP) && TabListBoxController::LastClick < (clock() * 0.00001f)) 79 | { 80 | if (TabListBoxController::PointerStart > 0) 81 | { 82 | TabListBoxController::PointerEnd--; 83 | TabListBoxController::PointerStart--; 84 | TabListBoxController::LastClick = (clock() * 0.00001f) + 0.002f; 85 | } 86 | } 87 | } 88 | void TabListBoxController::SetActive() 89 | { 90 | if (IsMouseInRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x, TabListBoxController::ParentPos.y + TabListBoxController::Pos.y, TabListBoxController::Size.x, TabListBoxController::Size.y)) 91 | Active = true; 92 | else 93 | Active = false; 94 | 95 | } 96 | void TabListBoxController::Update() 97 | { 98 | if (!TabListBoxController::Parent) 99 | TabListBoxController::SetVisible(false); 100 | if (!TabListBoxController::IsVisible()) 101 | return; 102 | 103 | TabListBoxController::ParentPos = TabListBoxController::Parent->GetParentPos(); 104 | TabListBoxController::ArrowKeyNavigation(); 105 | TabListBoxController::ScrollBarAction(); 106 | TabListBoxController::SetActive(); 107 | int i = 0; 108 | for (auto tab : TabListBoxController::Tabs) 109 | { 110 | if (i < TabListBoxController::PointerStart) 111 | { 112 | i++; 113 | continue; 114 | } 115 | if (i > TabListBoxController::PointerEnd - 1) 116 | { 117 | i++; 118 | continue; 119 | } 120 | float itemposy = TabListBoxController::ParentPos.y + TabListBoxController::Pos.y + ((i - TabListBoxController::PointerStart) * 20); 121 | if (IsMouseInRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2, (itemposy), TabListBoxController::Size.x - (TabListBoxController::ScrollWidth + 2), 20) && TabListBoxController::LastClick < (clock() * 0.00001f) && IsKeyClicked(VK_LBUTTON)) 122 | { 123 | TabListBoxController::ValueChangeEvent(); 124 | Selected = tab->Index; 125 | TabListBoxController::SetActiveIndex(); 126 | TabListBoxController::LastClick = (clock() * 0.00001f) + 0.002f; 127 | } 128 | i++; 129 | } 130 | } 131 | void TabListBoxController::ScrollBarAction() 132 | { 133 | if (TabListBoxController::Tabs.size() < TabListBoxController::Size.y / 20) 134 | return; 135 | if (!IsKeyDown(VK_LBUTTON)) 136 | TabListBoxController::ScrollBarHeld = false; 137 | if (IsMouseInRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x, TabListBoxController::ParentPos.y + TabListBoxController::Pos.y, 5, TabListBoxController::Size.y) && IsKeyClicked(VK_LBUTTON)) 138 | TabListBoxController::ScrollBarHeld = true; 139 | if (TabListBoxController::ScrollBarHeld) 140 | { 141 | float ratio = (MousePos.y - (float)(TabListBoxController::ParentPos.y + TabListBoxController::Pos.y)) / (float)((TabListBoxController::MaxVisibleItems - 1) * 20); 142 | ratio = std::clamp(ratio, 0.0f, 1.0f); 143 | TabListBoxController::PointerEnd = (int)(TabListBoxController::MaxVisibleItems + (TabListBoxController::Names.size() - TabListBoxController::MaxVisibleItems) * ratio); 144 | 145 | } 146 | TabListBoxController::PointerStart = TabListBoxController::PointerEnd - TabListBoxController::MaxVisibleItems; 147 | } 148 | void TabListBoxController::Draw() 149 | { 150 | if (!TabListBoxController::IsVisible()) 151 | return; 152 | for (std::shared_ptr tab : TabListBoxController::Tabs) 153 | { 154 | if (tab->Index == Selected) 155 | { 156 | tab->Draw(); 157 | tab->Update(); 158 | } 159 | } 160 | FilledRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x, TabListBoxController::ParentPos.y + TabListBoxController::Pos.y, TabListBoxController::Size.x, TabListBoxController::Size.y, Colour(80, 80, 80, 255)); 161 | OutlineRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x-1, TabListBoxController::ParentPos.y + TabListBoxController::Pos.y-1, TabListBoxController::Size.x+1, TabListBoxController::Size.y+1,1,Colour(150, 150, 150, 255)); 162 | 163 | int i = 0; 164 | for (std::wstring culledname : TabListBoxController::CulledNames) 165 | { 166 | if (i < TabListBoxController::PointerStart) 167 | { 168 | i++; 169 | continue; 170 | } 171 | if (i > TabListBoxController::PointerEnd-1) 172 | { 173 | i++; 174 | continue; 175 | } 176 | float itemposy = TabListBoxController::ParentPos.y + TabListBoxController::Pos.y + ((i - TabListBoxController::PointerStart) * 20); 177 | if (!IsMouseInRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2, (itemposy), TabListBoxController::Size.x - (TabListBoxController::ScrollWidth + 2), 20)) 178 | { 179 | if (i == TabListBoxController::ActiveIndex) 180 | { 181 | DrawText(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2, (itemposy), culledname, "Verdana", 11, Colour(255, 0, 0, 255), None); 182 | } 183 | else 184 | DrawText(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2, (itemposy), culledname, "Verdana", 11, Colour(255, 255, 255, 255), None); 185 | } 186 | i++; 187 | } 188 | // do this in a seperate loop so we can draw over all culled names 189 | i = 0; 190 | for (std::wstring name : TabListBoxController::Names) 191 | { 192 | if (i < TabListBoxController::PointerStart) 193 | { 194 | i++; 195 | continue; 196 | } 197 | if (i > TabListBoxController::PointerEnd - 1) 198 | { 199 | i++; 200 | continue; 201 | } 202 | float itemposy = TabListBoxController::ParentPos.y + TabListBoxController::Pos.y + ((i - TabListBoxController::PointerStart) * 20); 203 | if (IsMouseInRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2, (itemposy), TabListBoxController::Size.x - (TabListBoxController::ScrollWidth + 2), 20)) 204 | { 205 | int width = GetTextWidth(name, 11, "Verdana"); 206 | if (width + TabListBoxController::ScrollWidth + 2 + 5 < TabListBoxController::Size.x) 207 | { 208 | FilledRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 5, (itemposy), TabListBoxController::Size.x - (TabListBoxController::ScrollWidth + 5), 20, Colour(120, 120, 120, 255)); 209 | if (i == TabListBoxController::ActiveIndex) 210 | DrawText(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2 + 5, (itemposy)+5, name, "Verdana", 11, Colour(255, 0, 0, 255), None); 211 | else 212 | DrawText(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2 + 5, (itemposy), name, "Verdana", 11, Colour(255,255, 255, 255), None); 213 | 214 | } 215 | else 216 | { 217 | FilledRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2 + 5, (itemposy), width, 20, Colour(120,120,120,255)); 218 | if (i == TabListBoxController::ActiveIndex) 219 | DrawText(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2 + 5, (itemposy)+5, name, "Verdana", 11, Colour(255, 0, 0, 255), None); 220 | else 221 | DrawText(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x + TabListBoxController::ScrollWidth + 2 + 5, (itemposy) + 5, name, "Verdana", 11, Colour(255, 255, 255, 255), None); 222 | 223 | } 224 | } 225 | 226 | i++; 227 | } 228 | if (TabListBoxController::Tabs.size() > TabListBoxController::Size.y / 20) 229 | { 230 | int unselectedelements = Tabs.size() - MaxVisibleItems; 231 | float unselectedclamp = std::clamp(unselectedelements, 1, (int)Names.size()); 232 | float scrollheight = (TabListBoxController::Size.y / unselectedclamp) * 1.2; 233 | float scrolly = TabListBoxController::ParentPos.y + TabListBoxController::Pos.y + (((PointerEnd - MaxVisibleItems) * 20)); 234 | float scrollyclamp = std::clamp(scrolly, TabListBoxController::ParentPos.y + TabListBoxController::Pos.y, TabListBoxController::ParentPos.y + TabListBoxController::Pos.y + 5 + ((TabListBoxController::PointerEnd - TabListBoxController::PointerStart) * 20) - scrollheight); 235 | 236 | FilledRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x, TabListBoxController::ParentPos.y + TabListBoxController::Pos.y, TabListBoxController::ScrollWidth, TabListBoxController::Size.y, Colour(130, 130, 130, 255)); 237 | FilledRectangle(TabListBoxController::ParentPos.x + TabListBoxController::Pos.x, scrollyclamp, 5, scrollheight, Colour(255, 0, 0, 255)); 238 | } 239 | } 240 | void TabListBoxController::PushBack(std::shared_ptr tab) 241 | { 242 | TabListBoxController::Tabs.push_back(tab); 243 | TabListBoxController::Names.push_back(tab->GetName()); 244 | if (!FirstItem) 245 | { 246 | TabListBoxController::Selected = tab->Index; 247 | FirstItem = true; 248 | } 249 | TabListBoxController::Push(tab); 250 | TabListBoxController::UpdateCulledNames(); 251 | TabListBoxController::PointerEnd = TabListBoxController::Tabs.size(); 252 | TabListBoxController::MaxVisibleItems = TabListBoxController::Tabs.size(); 253 | if (TabListBoxController::Tabs.size() > TabListBoxController::Size.y / 20) 254 | TabListBoxController::MaxVisibleItems = TabListBoxController::Size.y / 20; 255 | if (TabListBoxController::PointerEnd > TabListBoxController::Size.y / 20) 256 | TabListBoxController::PointerEnd = TabListBoxController::Size.y / 20; 257 | 258 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/TabListBoxController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | #include "TabListBox.h" 4 | class TabListBoxController : public Container 5 | { 6 | protected: 7 | std::list> Tabs; 8 | std::list Names; 9 | std::list CulledNames; 10 | int ScrollWidth = 5; 11 | int Selected; 12 | bool ScrollBarHeld = false; 13 | bool Active = false; 14 | 15 | void UpdateCulledNames(); 16 | void ArrowKeyNavigation(); 17 | void ScrollBarAction(); 18 | void SetActiveIndex(); 19 | void SetActive(); 20 | int PointerStart = 2; 21 | int PointerEnd; 22 | int MaxVisibleItems = TabListBoxController::Size.y / 20; 23 | int ActiveIndex = 0; 24 | 25 | bool FirstItem = false; 26 | public: 27 | TabListBoxController(float x, float y, float width, float height); 28 | void Update(); 29 | void Draw(); 30 | void PushBack(std::shared_ptr tab); 31 | }; -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/TextBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class TextBox : public Entity 4 | { 5 | protected: 6 | 7 | std::chrono::time_point AnimationStart; 8 | float AnimationInterval = 1.0f; 9 | 10 | std::chrono::time_point SelectingAnimationStart; 11 | float SelectingAnimationInterval = 0.005f; 12 | 13 | int SelectedPoint; 14 | float SelectedPosition; 15 | 16 | int SelectionStart; 17 | int SelectionEnd; 18 | float SelectingStartPosition = 0; 19 | float SelectingEndPosition = 0; 20 | 21 | int VisiblePointerStart; 22 | int VisiblePointerEnd; 23 | void SetStartIndex(); 24 | 25 | std::wstring* MainString; 26 | std::wstring VisibleString; 27 | 28 | float TextWidth = 0; 29 | 30 | bool ContextActive = false; 31 | Vector2 ContextPos; 32 | Vector2 ContextSize; 33 | void ContextCopyText(); 34 | void ContextSelectAll(); 35 | void ContextPasteText(); 36 | std::map> ContextNames = { 37 | { L"Select All", [this]() { ContextSelectAll(); } }, 38 | { L"Copy", [this]() { ContextCopyText(); } }, 39 | { L"Paste", [this]() { ContextPasteText(); } } 40 | }; 41 | 42 | 43 | bool Active = false; 44 | bool Selecting = false; 45 | bool Held = false; 46 | 47 | bool IsKeyAcceptable(); 48 | 49 | void SetState(); 50 | void ArrowKeyNavition(); 51 | void InputText(); 52 | void DeleteText(); 53 | void ClearText(); 54 | void SetSelectionPoint(); 55 | void SelectionDragging(); 56 | void CopyText(); 57 | void PasteText(); 58 | void ContextMenu(); 59 | void SetSelection(); 60 | 61 | public: 62 | TextBox(float x, float y, std::wstring text, std::wstring* data); 63 | void Update(); 64 | void Draw(); 65 | bool IsTabbed; 66 | }; 67 | -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Toggle.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Toggle.h" 3 | #include "Input.h" 4 | #include "Drawing.h" 5 | #include "Font.h" 6 | 7 | 8 | Toggle::Toggle(float x, float y, std::wstring text, bool* data = nullptr) 9 | { 10 | Toggle::Pos = { x,y }; 11 | Toggle::Size = { 11,11 }; 12 | Toggle::Name = text; 13 | Toggle::TextHeight = GetTextHeight(text, 12, "Verdana"); 14 | Toggle::TextWidth = GetTextWidth(text, 12, "Verdana"); 15 | Data = data; 16 | SetVisible(true); 17 | 18 | } 19 | 20 | 21 | void Toggle::Update() 22 | { 23 | 24 | if (!Toggle::Parent) 25 | Toggle::SetVisible(false); 26 | if (!Toggle::IsVisible()) 27 | return; 28 | 29 | Toggle::ParentPos = Toggle::Parent->GetParentPos(); 30 | if (!Toggle::Blocked) 31 | { 32 | // square click check 33 | if (IsMouseInRectangle(Toggle::Pos + Toggle::ParentPos, Toggle::Size) && IsKeyClicked(VK_LBUTTON) && Toggle::LastClick < (clock() * 0.00001f)) 34 | { 35 | 36 | *Toggle::Data = !(*Toggle::Data); 37 | Toggle::LastClick = (clock() * 0.00001f) + 0.002f; 38 | Toggle::ValueChangeEvent(); 39 | } 40 | // text click check 41 | Vector2 textdimensions = { Toggle::TextWidth + 4,Toggle::TextHeight }; 42 | if (IsMouseInRectangle(Toggle::ParentPos.x + Toggle::Pos.x + (Toggle::Size.x), Toggle::ParentPos.y + Toggle::Pos.y - 1, Toggle::TextWidth, Toggle::TextHeight) && IsKeyClicked(VK_LBUTTON) && Toggle::LastClick < (clock() * 0.00001f)) 43 | { 44 | 45 | *Toggle::Data = !(*Toggle::Data); 46 | Toggle::LastClick = (clock() * 0.00001f) + 0.002f; 47 | Toggle::ValueChangeEvent(); 48 | } 49 | } 50 | } 51 | 52 | void Toggle::Draw() 53 | { 54 | //Button::Parent->GetParent()->GetParent()->GetPos(); 55 | if (!Toggle::Parent) 56 | Toggle::SetVisible(false); 57 | if (!Toggle::IsVisible()) 58 | return; 59 | 60 | OutlineRectangle(ParentPos.x + Pos.x, ParentPos.y + Pos.y, Size.x, Size.y, 1, Colour(130, 130, 130, 255)); 61 | FilledRectangle(ParentPos.x + Pos.x, ParentPos.y + Pos.y, Size.x, Size.y, Colour(80, 80, 80, 255)); 62 | if (*Toggle::Data == true) 63 | FilledRectangle(ParentPos.x + Pos.x + 1, ParentPos.y + Pos.y + 1, Size.x - 2, Size.y - 2, Colour(255, 0, 0, 255)); 64 | //FilledRectangle(Toggle::ParentPos.x + Toggle::Pos.x + (Toggle::Size.x) + 2, Toggle::ParentPos.y + Toggle::Pos.y - 1, Toggle::TextWidth + 4, Toggle::TextHeight, Colour(200, 0, 0, 255)); 65 | DrawText( Toggle::ParentPos.x + Toggle::Pos.x + (Toggle::Size.x) + 3, Toggle::ParentPos.y + Toggle::Pos.y - (Toggle::Size.y / 8), Toggle::Name, "Verdana", 12, Colour(255, 255, 255, 255), None); 66 | 67 | } -------------------------------------------------------------------------------- /Overlay/Graphics/Entities/Toggle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entity.h" 3 | class Toggle : public Entity 4 | { 5 | protected: 6 | 7 | bool* Data; 8 | bool Tabbed = false; 9 | 10 | float TextWidth = 0; 11 | float TextHeight = 0; 12 | 13 | public: 14 | Toggle(float x, float y, std::wstring text, bool* data); 15 | void Update(); 16 | void Draw(); 17 | }; 18 | -------------------------------------------------------------------------------- /Overlay/Graphics/Graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | extern CanvasDrawingSession^ SwapChain; 3 | extern int WindowWidth; 4 | extern int WindowHeight; -------------------------------------------------------------------------------- /Overlay/Graphics/Start Up/GUI.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "GUI.h" 3 | #include "entity.h" 4 | #include "Form.h" 5 | #include "Tab.h" 6 | #include "Toggle.h" 7 | #include "Label.h" 8 | #include "Button.h" 9 | #include "TextBox.h" 10 | #include "Slider.h" 11 | #include "TabController.h" 12 | #include "ColourPicker.h" 13 | #include "KeyBind.h" 14 | #include "DropDown.h" 15 | #include "ComboBox.h" 16 | #include "TabListBoxController.h" 17 | #include "GroupBox.h" 18 | Color ColourPickerClipBoard = Colors::Red; 19 | int KeyBindClipBoard = 0; 20 | EntityVector MenuEntity; 21 | int SelectedTab = 1; 22 | int SelectedSubTab = 0; 23 | int TabCount=0; 24 | bool ToggleTest; 25 | bool ToggleTest1 = true; 26 | std::wstring TextBoxText = L"txtboxdsgdsdshchgkhdsgsdgsdgWWWWAAAA"; 27 | int intvalue = 3; 28 | float floatvalue = 8.5f; 29 | Color Col = Colour(255, 255, 255, 255); 30 | int Key = 0; 31 | int Down = 1; 32 | bool Combo1 = true; 33 | bool Combo2 = false; 34 | bool Combo3 = false; 35 | bool Combo4 = true; 36 | bool Combo5 = false; 37 | void CreateGUI() 38 | { 39 | MenuEntity = std::make_shared< Container >(); 40 | // We use the makeshared function instead of declaring new variables because they are automatically disposed 41 | auto form = std::make_shared
(100, 100.0f, 480, 300, 2, 30, L"FORM", true); 42 | { 43 | auto tabcontroller = std::make_shared(); 44 | form->Push(tabcontroller); 45 | //std::string name, float x, float y, float width, float height, int* selectedtab = nullptr 46 | auto tab = std::make_shared(L"Tab1", 5, 55, 50, 20, &SelectedTab); 47 | { 48 | auto colourpicker = std::make_shared(200, 10, &Col); 49 | tab->Push(colourpicker); 50 | auto toggle = std::make_shared(10,10, L"Toggle", &ToggleTest); 51 | tab->Push(toggle); 52 | auto toggle1 = std::make_shared(10, 30, L"Toggle", &ToggleTest1); 53 | tab->Push(toggle1); 54 | auto label = std::make_shared