├── ApexLegends ├── ApexLegends.vcxproj ├── ApexLegends.vcxproj.filters ├── ApexLegends.vcxproj.user ├── ChaoticUI_impl_dx11.cpp ├── ChaoticUI_impl_dx11.h ├── Communication.h ├── DD64.dll ├── Drawer.h ├── FGUI │ ├── FGUI.hh │ ├── controls │ │ ├── button.cc │ │ ├── button.hh │ │ ├── checkbox.cc │ │ ├── checkbox.hh │ │ ├── colorlist.cc │ │ ├── colorlist.hh │ │ ├── colorpicker.cc │ │ ├── colorpicker.hh │ │ ├── combobox.cc │ │ ├── combobox.hh │ │ ├── container.cc │ │ ├── container.hh │ │ ├── element.cc │ │ ├── element.hh │ │ ├── keybinder.cc │ │ ├── keybinder.hh │ │ ├── label.cc │ │ ├── label.hh │ │ ├── listbox.cc │ │ ├── listbox.hh │ │ ├── multibox.cc │ │ ├── multibox.hh │ │ ├── slider.cc │ │ ├── slider.hh │ │ ├── spinner.cc │ │ ├── spinner.hh │ │ ├── tabs.cc │ │ ├── tabs.hh │ │ ├── textbox.cc │ │ └── textbox.hh │ ├── dependencies │ │ ├── aliases.hh │ │ ├── color.hh │ │ ├── definitions.hh │ │ ├── input.hh │ │ └── json.hh │ ├── handler │ │ ├── handler.cc │ │ └── handler.hh │ └── notifications │ │ ├── notifications.cc │ │ └── notifications.hh ├── dd.cpp ├── dd.h ├── examples │ ├── d3d9 │ │ ├── input.hpp │ │ └── renderer.hpp │ └── surface │ │ ├── input.hpp │ │ └── renderer.hpp └── globals.hpp ├── Ark - Apex.sln └── README.md /ApexLegends/ApexLegends.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {13F42F30-64C2-4405-A324-C4F4982021D8} 24 | ApexLoader 25 | ApexLoader 26 | 10.0.19041.0 27 | 4.5 28 | 29 | 30 | 31 | Application 32 | true 33 | v142 34 | MultiByte 35 | 36 | 37 | Application 38 | false 39 | v142 40 | true 41 | MultiByte 42 | 43 | 44 | true 45 | v142 46 | MultiByte 47 | 48 | 49 | true 50 | MultiByte 51 | Application 52 | v142 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | .exe 74 | 75 | 76 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath) 77 | $(LibraryPath) 78 | .exe 79 | 80 | 81 | 82 | Level3 83 | Disabled 84 | true 85 | true 86 | 87 | 88 | 89 | 90 | TurnOffAllWarnings 91 | Disabled 92 | true 93 | true 94 | %(DisableSpecificWarnings) 95 | stdcpp17 96 | Sync 97 | 98 | 99 | d3d11.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies) 100 | 101 | 102 | Console 103 | true 104 | true 105 | true 106 | 107 | 108 | 109 | 110 | Level3 111 | MaxSpeed 112 | true 113 | true 114 | true 115 | true 116 | 117 | 118 | true 119 | true 120 | 121 | 122 | 123 | 124 | TurnOffAllWarnings 125 | MaxSpeed 126 | true 127 | true 128 | true 129 | true 130 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;%(AdditionalIncludeDirectories) 131 | _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 132 | false 133 | %(DisableSpecificWarnings) 134 | Sync 135 | stdcpp17 136 | 137 | 138 | true 139 | true 140 | VMProtectSDK64.lib;d3d11.lib;d3d9.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies) 141 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;C:\CheatCompilation\TEST\New folder %282%29\Original - Copy\ApexLegends;%(AdditionalLibraryDirectories) 142 | true 143 | 144 | true 145 | RequireAdministrator 146 | Windows 147 | true 148 | true 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /ApexLegends/ApexLegends.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {} 6 | 7 | 8 | {} 9 | 10 | 11 | {} 12 | 13 | 14 | {} 15 | 16 | 17 | {86dd2920-8f2d-4e72-9307-1219b8199ebc} 18 | 19 | 20 | {098dd32e-a2fa-4746-8f8e-86c0193dfe1b} 21 | 22 | 23 | 24 | 25 | Header 26 | 27 | 28 | Header 29 | 30 | 31 | Header 32 | 33 | 34 | Header 35 | 36 | 37 | Header 38 | 39 | 40 | Header 41 | 42 | 43 | ChaoticUI 44 | 45 | 46 | ChaoticUI 47 | 48 | 49 | ChaoticUI 50 | 51 | 52 | ChaoticUI 53 | 54 | 55 | ChaoticUI 56 | 57 | 58 | ChaoticUI 59 | 60 | 61 | ChaoticUI 62 | 63 | 64 | ChaoticUI 65 | 66 | 67 | Header 68 | 69 | 70 | include 71 | 72 | 73 | include 74 | 75 | 76 | include 77 | 78 | 79 | Header 80 | 81 | 82 | Source 83 | 84 | 85 | Source 86 | 87 | 88 | 89 | 90 | 91 | Source 92 | 93 | 94 | Directx11 95 | 96 | 97 | Source 98 | 99 | 100 | ChaoticUI 101 | 102 | 103 | ChaoticUI 104 | 105 | 106 | ChaoticUI 107 | 108 | 109 | Source 110 | 111 | 112 | 113 | 114 | include 115 | 116 | 117 | include 118 | 119 | 120 | -------------------------------------------------------------------------------- /ApexLegends/ApexLegends.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /ApexLegends/ChaoticUI_impl_dx11.h: -------------------------------------------------------------------------------- 1 | struct ID3D11Device; 2 | struct ID3D11DeviceContext; 3 | 4 | Var_ChaoticUI_API bool Var_ChaoticUI_ImplDX11_Init(void* hwnd, ID3D11Device* device, ID3D11DeviceContext* device_context); 5 | Var_ChaoticUI_API void Var_ChaoticUI_ImplDX11_Shutdown(); 6 | Var_ChaoticUI_API void Var_ChaoticUI_ImplDX11_NewFrame(); 7 | Var_ChaoticUI_API void Var_ChaoticUI_ImplDX11_RenderDrawData(Var_ChaoticUIDrawData* draw_data); 8 | 9 | // Use if you want to reset your rendering device without losing Var_ChaoticUI state. 10 | Var_ChaoticUI_API void Var_ChaoticUI_ImplDX11_InvalidateDeviceObjects(); 11 | Var_ChaoticUI_API bool Var_ChaoticUI_ImplDX11_CreateDeviceObjects(); 12 | -------------------------------------------------------------------------------- /ApexLegends/Communication.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "Structs.h" 24 | #include 25 | #pragma comment(lib, "urlmon.lib") 26 | 27 | using namespace std; 28 | 29 | #include "Main.h" 30 | 31 | using namespace std; 32 | 33 | uintptr_t BaseAddress = 0; 34 | uint32_t ProcessId = 0; 35 | uint32_t CheckProcess = 0; 36 | 37 | typedef struct _SERAPH_MEMORY 38 | { 39 | void* BufferAddress; 40 | UINT_PTR Address; 41 | ULONGLONG Size; 42 | ULONG ProcessId; 43 | BOOLEAN Write; 44 | BOOLEAN Read; 45 | BOOLEAN RequestBase; 46 | void* Output; 47 | const char* ModuleName; 48 | ULONG64 BaseAddress; 49 | BOOLEAN ClearPiddb; 50 | BOOLEAN Mmunload; 51 | }SERAPH_MEMORY; 52 | 53 | template 54 | uint64_t call_hook(const Arg ... args) 55 | { 56 | void* hooked_func = GetProcAddress(LoadLibrary("win32u.dll"), "NtQueryCompositionSurfaceStatistics"); 57 | 58 | auto func = static_cast(hooked_func); 59 | 60 | return func(args ...); 61 | } 62 | 63 | struct HandleDisposer 64 | { 65 | using pointer = HANDLE; 66 | void operator()(HANDLE handle) const 67 | { 68 | if (handle != NULL || handle != INVALID_HANDLE_VALUE) 69 | { 70 | CloseHandle(handle); 71 | } 72 | } 73 | }; 74 | 75 | using unique_handle = std::unique_ptr; 76 | 77 | std::uint32_t _GetProcessId(std::string_view process_name) 78 | { 79 | PROCESSENTRY32 processentry; 80 | const unique_handle snapshot_handle(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL)); 81 | 82 | if (snapshot_handle.get() == INVALID_HANDLE_VALUE) 83 | return NULL; 84 | 85 | processentry.dwSize = sizeof(MODULEENTRY32); 86 | 87 | while (Process32Next(snapshot_handle.get(), &processentry) == TRUE) 88 | { 89 | if (process_name.compare(processentry.szExeFile) == NULL) 90 | { 91 | return processentry.th32ProcessID; 92 | } 93 | } 94 | return NULL; 95 | } 96 | 97 | static ULONG64 GetModuleBase(const char* module_name) 98 | { 99 | SERAPH_MEMORY Seraph = { 0 }; 100 | Seraph.ProcessId = ProcessId; 101 | Seraph.RequestBase = TRUE; 102 | Seraph.Read = FALSE; 103 | Seraph.Write = FALSE; 104 | Seraph.ClearPiddb = FALSE; 105 | Seraph.Mmunload = FALSE; 106 | Seraph.ModuleName = module_name; 107 | call_hook(&Seraph); 108 | 109 | ULONG64 base = NULL; 110 | base = Seraph.BaseAddress; 111 | return base; 112 | } 113 | 114 | void Piddbclear() 115 | { 116 | SERAPH_MEMORY Seraph; 117 | Seraph.Read = FALSE; 118 | Seraph.Write = FALSE; 119 | Seraph.ClearPiddb = TRUE; 120 | Seraph.Mmunload = FALSE; 121 | Seraph.RequestBase = FALSE; 122 | call_hook(&Seraph); 123 | 124 | std::cout << XorString("[+] Clear The Caches") << std::endl; 125 | 126 | return; 127 | } 128 | 129 | void Mmunload() 130 | { 131 | SERAPH_MEMORY Seraph; 132 | Seraph.Read = FALSE; 133 | Seraph.Write = FALSE; 134 | Seraph.ClearPiddb = FALSE; 135 | Seraph.Mmunload = TRUE; 136 | Seraph.RequestBase = FALSE; 137 | call_hook(&Seraph); 138 | 139 | std::cout << XorString("[+] Clear The Threads") << std::endl; 140 | 141 | return; 142 | } 143 | 144 | template 145 | T Read(UINT_PTR read_address) 146 | { 147 | T Response{}; 148 | SERAPH_MEMORY Seraph; 149 | Seraph.ProcessId = ProcessId; 150 | Seraph.Size = sizeof(T); 151 | Seraph.Address = read_address; 152 | Seraph.Read = TRUE; 153 | Seraph.Write = FALSE; 154 | Seraph.ClearPiddb = FALSE; 155 | Seraph.Mmunload = FALSE; 156 | Seraph.RequestBase = FALSE; 157 | Seraph.Output = &Response; 158 | call_hook(&Seraph); 159 | 160 | return Response; 161 | } 162 | 163 | template 164 | T ReadString(UINT_PTR read_address) 165 | { 166 | 167 | std::vector buffer(sizeof(DWORD64), char{ 0 }); 168 | 169 | T Response{}; 170 | SERAPH_MEMORY Seraph; 171 | Seraph.ProcessId = ProcessId; 172 | Seraph.Size = sizeof(DWORD64); 173 | Seraph.Address = read_address; 174 | Seraph.Read = TRUE; 175 | Seraph.Write = FALSE; 176 | Seraph.ClearPiddb = FALSE; 177 | Seraph.Mmunload = FALSE; 178 | Seraph.RequestBase = FALSE; 179 | Seraph.Output = static_cast(&buffer[0]); 180 | call_hook(&Seraph); 181 | 182 | return std::string(buffer.data()); 183 | } 184 | 185 | template 186 | T ReadName(UINT_PTR read_address) 187 | { 188 | 189 | std::vector buffer(24, char{ 0 }); 190 | 191 | T Response{}; 192 | SERAPH_MEMORY Seraph; 193 | Seraph.ProcessId = ProcessId; 194 | Seraph.Size = 24; 195 | Seraph.Address = read_address; 196 | Seraph.Read = TRUE; 197 | Seraph.Write = FALSE; 198 | Seraph.ClearPiddb = FALSE; 199 | Seraph.Mmunload = FALSE; 200 | Seraph.RequestBase = FALSE; 201 | Seraph.Output = static_cast(&buffer[0]); 202 | call_hook(&Seraph); 203 | 204 | return std::string(buffer.data()); 205 | } 206 | 207 | bool write_memory(UINT_PTR write_address, UINT_PTR source_address, SIZE_T write_size) 208 | { 209 | SERAPH_MEMORY Seraph; 210 | Seraph.Address = write_address; 211 | Seraph.ProcessId = ProcessId; 212 | Seraph.Write = TRUE; 213 | Seraph.Read = FALSE; 214 | Seraph.ClearPiddb = FALSE; 215 | Seraph.Mmunload = FALSE; 216 | Seraph.RequestBase = FALSE; 217 | Seraph.BufferAddress = (void*)source_address; 218 | Seraph.Size = write_size; 219 | 220 | call_hook(&Seraph); 221 | 222 | return true; 223 | } 224 | 225 | template 226 | bool write(UINT_PTR write_address, const S& value) 227 | { 228 | return write_memory(write_address, (UINT_PTR)&value, sizeof(S)); 229 | } 230 | 231 | 232 | template 233 | std::string read_string(uint64_t address, SIZE_T Size) 234 | { 235 | std::string blank = "CAN'T"; 236 | 237 | std::vector buffer(Size, char{ 0 }); 238 | 239 | SERAPH_MEMORY Seraph = { 0 }; 240 | Seraph.ProcessId = ProcessId; 241 | Seraph.Address = address; 242 | Seraph.Size = buffer.size(); 243 | Seraph.Output = static_cast(&buffer[0]); 244 | 245 | if (call_hook(&Seraph)) { 246 | return std::string(buffer.data()); 247 | } 248 | else { 249 | return blank; 250 | } 251 | } -------------------------------------------------------------------------------- /ApexLegends/DD64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekdms05/Seraph-APEX/54cff8d9212ea2c20925348019d11d08b1ab60f7/ApexLegends/DD64.dll -------------------------------------------------------------------------------- /ApexLegends/Drawer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "main.h" 3 | 4 | class Renderer 5 | { 6 | public: 7 | void Initialize(); 8 | void BeginScene(); 9 | void DrawScene(); 10 | void EndScene(); 11 | 12 | static Renderer* GetInstance(); 13 | 14 | Var_ChaoticUIFont* m_pFont; 15 | 16 | Renderer(); 17 | ~Renderer(); 18 | 19 | float DrawMyText(Var_ChaoticUIFont* pFont, PCHAR text, const DirectX::XMFLOAT2& pos, float size, DirectX::XMFLOAT4 color, bool center); 20 | void DrawLine(const DirectX::XMFLOAT2& from, const DirectX::XMFLOAT2& to, DirectX::XMFLOAT4 color, float thickness); 21 | void DrawBox(const DirectX::XMFLOAT2& from, const DirectX::XMFLOAT2& size, DirectX::XMFLOAT4 color, float rounding, float thickness); 22 | void DrawBoxFilled(const DirectX::XMFLOAT2& from, const DirectX::XMFLOAT2& size, DirectX::XMFLOAT4 color, float rounding); 23 | void DrawCircle(const DirectX::XMFLOAT2& from, float radius, DirectX::XMFLOAT4 color, float thickness = 1.f); 24 | void DrawCircleFilled(const DirectX::XMFLOAT2& from, float radius, DirectX::XMFLOAT4 color); 25 | private: 26 | static Renderer* m_pInstance; 27 | }; -------------------------------------------------------------------------------- /ApexLegends/FGUI/FGUI.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include "handler/handler.hh" 9 | #include "controls/tabs.hh" 10 | #include "controls/button.hh" 11 | #include "controls/checkbox.hh" 12 | #include "controls/colorpicker.hh" 13 | #include "controls/combobox.hh" 14 | #include "controls/element.hh" 15 | #include "controls/keybinder.hh" 16 | #include "controls/label.hh" 17 | #include "controls/listbox.hh" 18 | #include "controls/multibox.hh" 19 | #include "controls/slider.hh" 20 | #include "controls/spinner.hh" 21 | #include "controls/textbox.hh" 22 | #include "controls/colorlist.hh" 23 | #include "controls/container.hh" 24 | #include "dependencies/aliases.hh" 25 | #include "notifications/notifications.hh" 26 | 27 | #pragma region MACROS 28 | 29 | #define REGISTER_TAB( tab, x, y, font, style, parent, page ) \ 30 | { \ 31 | tab = std::make_shared(); \ 32 | tab->set_position(x, y); \ 33 | tab->set_font(font); \ 34 | tab->set_style = style; \ 35 | parent->add_control(tab, page, true);\ 36 | } \ 37 | 38 | #define REGISTER_CURSOR( cursor_type, input_state ); \ 39 | { \ 40 | fgui::handler::set_cursor(cursor_type); \ 41 | fgui::handler::set_input_state(input_state); \ 42 | } \ 43 | 44 | #define REGISTER_NOTIFICATIONS( notification_font ); \ 45 | { \ 46 | fgui::handler::register_notifications(notification_font); \ 47 | } \ 48 | 49 | #define ADD_BUTTON( element, x, y, name, width, height, font, parent, page ) \ 50 | { \ 51 | element = std::make_shared(); \ 52 | element->set_position(x, y); \ 53 | element->set_title(name); \ 54 | element->set_size(width, height); \ 55 | element->set_font(font); \ 56 | parent->add_control(element, page, true); \ 57 | } \ 58 | 59 | #define ADD_CHECKBOX( element, x, y, name, identificator, font, parent, page ) \ 60 | { \ 61 | element = std::make_shared(); \ 62 | element->set_position(x, y); \ 63 | element->set_title(name); \ 64 | element->set_identificator(identificator); \ 65 | element->set_font(font); \ 66 | parent->add_control(element, page); \ 67 | } \ 68 | 69 | #define ADD_COLORLIST( element, x, y, name, width, height, identificator, font, parent, page ) \ 70 | { \ 71 | element = std::make_shared(); \ 72 | element->set_position(x, y); \ 73 | element->set_title(name); \ 74 | element->set_size(width, height); \ 75 | element->set_identificator(identificator); \ 76 | element->set_font(font); \ 77 | parent->add_control(element, page, true); \ 78 | } \ 79 | 80 | #define ADD_COLORPICKER( element, x, y, color, identificator, font, parent, page ) \ 81 | { \ 82 | element = std::make_shared(); \ 83 | element->set_position(x, y); \ 84 | element->set_color(color); \ 85 | element->set_identificator(identificator); \ 86 | element->set_font(font); \ 87 | parent->add_control(element, page); \ 88 | } \ 89 | 90 | #define ADD_COMBOBOX( element, x, y, name, identificator, font, parent, page ) \ 91 | { \ 92 | element = std::make_shared(); \ 93 | element->set_position(x, y); \ 94 | element->set_title(name); \ 95 | element->set_identificator(identificator); \ 96 | element->set_font(font); \ 97 | parent->add_control(element, page); \ 98 | } \ 99 | 100 | #define ADD_GROUPBOX( element, x, y, name, width, height, font, parent, page, scrollable, resizeable, hideable) \ 101 | { \ 102 | element = std::make_shared(); \ 103 | element->set_position(x, y); \ 104 | element->set_title(name); \ 105 | element->set_size(width, height); \ 106 | element->set_font(font); \ 107 | element->set_scrollbar_state(scrollable); \ 108 | element->set_resize_state(resizeable); \ 109 | element->set_hidden_state(hideable); \ 110 | parent->add_control(element, page, true);\ 111 | } \ 112 | 113 | #define ADD_KEYBINDER( element, x, y, name, key, identificator, font, parent, page ) \ 114 | { \ 115 | element = std::make_shared(); \ 116 | element->set_position(x, y); \ 117 | element->set_title(name); \ 118 | element->set_key(key); \ 119 | element->set_identificator(identificator); \ 120 | element->set_font(font); \ 121 | parent->add_control(element, page); \ 122 | } \ 123 | 124 | #define ADD_LABEL( element, x, y, text, type, font, parent, page ) \ 125 | { \ 126 | element = std::make_shared(); \ 127 | element->set_position(x, y); \ 128 | element->set_text(text); \ 129 | element->set_type(type); \ 130 | element->set_font(font); \ 131 | parent->add_control(element, page); \ 132 | } \ 133 | 134 | #define ADD_LISTBOX( element, x, y, name, width, height, identificator, font, parent, page ) \ 135 | { \ 136 | element = std::make_shared(); \ 137 | element->set_position(x, y); \ 138 | element->set_title(name); \ 139 | element->set_size(width, height); \ 140 | element->set_identificator(identificator); \ 141 | element->set_font(font); \ 142 | parent->add_control(element, page, true); \ 143 | } \ 144 | 145 | #define ADD_MULTIBOX( element, x, y, name, identificator, font, parent, page ) \ 146 | { \ 147 | element = std::make_shared(); \ 148 | element->set_position(x, y); \ 149 | element->set_title(name); \ 150 | element->set_identificator(identificator); \ 151 | element->set_font(font); \ 152 | parent->add_control(element, page); \ 153 | } \ 154 | 155 | #define ADD_SLIDER( element, x, y, name, value, min, max, identificator, font, parent, page ) \ 156 | { \ 157 | element = std::make_shared(); \ 158 | element->set_position(x, y); \ 159 | element->set_title(name); \ 160 | element->set_value(value); \ 161 | element->set_boundaries(min, max); \ 162 | element->set_identificator(identificator); \ 163 | element->set_font(font); \ 164 | parent->add_control(element, page); \ 165 | } \ 166 | 167 | #define ADD_SPINNER( element, x, y, name, value, min, max, identificator, font, parent, page ) \ 168 | { \ 169 | element = std::make_shared(); \ 170 | element->set_position(x, y); \ 171 | element->set_title(name); \ 172 | element->set_value(value); \ 173 | element->set_boundaries(min, max); \ 174 | element->set_identificator(identificator); \ 175 | element->set_font(font); \ 176 | parent->add_control(element, page, true); \ 177 | } \ 178 | 179 | #define ADD_TEXTBOX( element, x, y, name, text, max_length, flag, identificator, font, parent, page ) \ 180 | { \ 181 | element = std::make_shared(); \ 182 | element->set_position(x, y); \ 183 | element->set_title(name); \ 184 | element->set_text(text); \ 185 | element->set_identificator(identificator); \ 186 | element->set_length(max_length); \ 187 | element->set_text_flag(flag); \ 188 | element->set_font(font); \ 189 | parent->add_control(element, page); \ 190 | } \ 191 | 192 | #define ADD_WINDOW( window, x, y, title, width, height, key, font ) \ 193 | { \ 194 | window = std::make_shared(); \ 195 | window->set_position(x, y); \ 196 | window->set_title(title); \ 197 | window->set_size(width, height); \ 198 | window->set_font(font); \ 199 | \ 200 | \ 201 | fgui::handler::register_window(window); \ 202 | fgui::handler::set_key(key, window); \ 203 | } \ 204 | 205 | #define ADD_TAB( tabs, name ); \ 206 | tabs->add_tab(name); \ 207 | \ 208 | 209 | // comboboxes and multiboxes 210 | #define ADD_ITEM( element, name, value ); \ 211 | element->add_item(name, value); \ 212 | \ 213 | 214 | #define ADD_CONTROLLER( element, controller ) \ 215 | element->set_controller(controller); \ 216 | \ 217 | 218 | #define ADD_TOOLTIP( element, tooltip ) \ 219 | element->set_tooltip(tooltip); \ 220 | \ 221 | 222 | // button, comboboxes and containers 223 | #define ADD_FUNCTION( element, function ) \ 224 | element->set_function(function); \ 225 | \ 226 | 227 | // colorlist 228 | #define ADD_COLOR( element, label, color, gradient ) \ 229 | element->add_color(label, color, gradient); \ 230 | \ 231 | 232 | // slider 233 | #define ADD_BOUNDARIES_TEXT( element, min_text, max_text ) \ 234 | element->set_boundaries_text(min_text, max_text); \ 235 | \ 236 | 237 | #pragma endregion 238 | -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/button.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "button.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | 10 | fgui::button::button() { 11 | 12 | fgui::button::m_width = 150; 13 | fgui::button::m_height = 20; 14 | fgui::button::m_title = "button"; 15 | fgui::button::m_callback = nullptr; 16 | fgui::button::m_font = fgui::element::m_font; 17 | fgui::button::m_type = static_cast(fgui::detail::element_type::BUTTON); 18 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE); 19 | } 20 | 21 | //--------------------------------------------------------- 22 | void fgui::button::draw() { 23 | 24 | // get the current position of the window 25 | fgui::point a = fgui::element::get_absolute_position(); 26 | 27 | // get the window style 28 | auto style = handler::get_style(); 29 | 30 | // get the control area 31 | fgui::rect area = { a.x, a.y, m_width, m_height }; 32 | 33 | // button title text size 34 | fgui::dimension text_size = fgui::render.get_text_size(fgui::button::get_font(), m_title); 35 | 36 | // button body 37 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.button.at(0))); 38 | 39 | if (fgui::input_system::mouse_in_area(area)) 40 | fgui::render.outline(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.button.at(3))); 41 | else 42 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.button.at(1))); 43 | 44 | fgui::render.colored_gradient(area.left + 3, area.top + 3, area.right - 6, area.bottom - 6, fgui::color(style.button.at(2)), fgui::color(style.button.at(1)), false); 45 | 46 | // button label 47 | fgui::render.text(area.left + (area.right / 2) - (text_size.width / 2), area.top + (area.bottom / 2) - (text_size.height / 2), fgui::color(style.text.at(0)), fgui::button::get_font(), m_title); 48 | } 49 | 50 | //--------------------------------------------------------- 51 | void fgui::button::handle_input() { 52 | 53 | // get the current position of the window 54 | fgui::point a = fgui::element::get_absolute_position(); 55 | 56 | // get the control area 57 | fgui::rect area = { a.x, a.y, m_width, m_height }; 58 | 59 | if (fgui::input_system::mouse_in_area(area)) { 60 | 61 | // call the custom function 62 | if (m_callback) 63 | m_callback(); 64 | } 65 | } 66 | 67 | //--------------------------------------------------------- 68 | void fgui::button::update() {} 69 | 70 | //--------------------------------------------------------- 71 | void fgui::button::tooltip() { 72 | 73 | // get the current position of the window 74 | fgui::point a = fgui::element::get_absolute_position(); 75 | 76 | // get the window style 77 | auto style = handler::get_style(); 78 | 79 | // get the control area 80 | fgui::rect area = { a.x, a.y, m_width, m_height }; 81 | 82 | if (m_tooltip.length() > 0) { 83 | 84 | // tooltip text size 85 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 86 | 87 | // cursor position 88 | fgui::point cursor = fgui::input_system::mouse_position(); 89 | 90 | if (fgui::input_system::mouse_in_area(area)) { 91 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.button.at(3))); 92 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 93 | } 94 | } 95 | } 96 | 97 | //--------------------------------------------------------- 98 | void fgui::button::save(nlohmann::json& json_module) {} 99 | 100 | //--------------------------------------------------------- 101 | void fgui::button::load(const std::string_view file_name) {} -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/button.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | #include 11 | 12 | // framework includes 13 | #include "element.hh" 14 | 15 | namespace fgui { 16 | 17 | class button : public fgui::element { 18 | public: 19 | button(); 20 | 21 | // draw the element 22 | void draw(); 23 | 24 | // set the function that the button will call when clicked 25 | inline void set_function(const std::function &callback) noexcept { 26 | 27 | m_callback = callback; 28 | } 29 | 30 | // handle keyboard and mouse input 31 | void handle_input(); 32 | 33 | // handle the element updates 34 | void update(); 35 | 36 | // element tooltip 37 | void tooltip(); 38 | 39 | // save the element state 40 | void save(nlohmann::json& json_module); 41 | 42 | // load the element state 43 | void load(const std::string_view file_name); 44 | private: 45 | std::function m_callback; 46 | }; 47 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/checkbox.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "checkbox.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | 10 | fgui::checkbox::checkbox() { 11 | 12 | fgui::checkbox::m_width = 15; 13 | fgui::checkbox::m_height = 15; 14 | fgui::checkbox::m_original_width = fgui::checkbox::m_width; 15 | fgui::checkbox::m_checked = false; 16 | fgui::checkbox::m_title = "checkbox"; 17 | fgui::checkbox::m_font = fgui::element::m_font; 18 | fgui::checkbox::m_original_width = fgui::checkbox::m_width; 19 | fgui::checkbox::m_type = static_cast(fgui::detail::element_type::CHECKBOX); 20 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE) | static_cast(fgui::detail::element_flags::SAVABLE); 21 | } 22 | 23 | //--------------------------------------------------------- 24 | void fgui::checkbox::draw() { 25 | 26 | // get the current position of the window 27 | fgui::point a = fgui::element::get_absolute_position(); 28 | 29 | // get the window style 30 | auto style = handler::get_style(); 31 | 32 | // checkbox area 33 | fgui::rect area = { a.x, a.y, m_original_width, m_height }; 34 | 35 | // checkbox body 36 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.checkbox.at(0))); 37 | fgui::render.colored_gradient(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.checkbox.at(1)), fgui::color(style.checkbox.at(2)), false); 38 | 39 | if (fgui::input_system::mouse_in_area(area) || m_checked) 40 | fgui::render.outline(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.checkbox.at(3))); 41 | 42 | if (m_checked) 43 | fgui::render.colored_gradient(area.left + 3, area.top + 3, area.right - 6, area.bottom - 6, fgui::color(style.checkbox.at(3)), fgui::color(style.checkbox.at(4)), false); 44 | 45 | // checkbox label 46 | fgui::render.text(area.left + area.right + 5, area.top + 2, fgui::color(style.text.at(0)), fgui::checkbox::get_font(), m_title); 47 | } 48 | 49 | //--------------------------------------------------------- 50 | void fgui::checkbox::handle_input() { 51 | 52 | // get the current position of the window 53 | fgui::point a = fgui::element::get_absolute_position(); 54 | 55 | // control area 56 | fgui::rect area = { a.x, a.y, a.x + m_width, m_height }; 57 | 58 | // switch 59 | if (fgui::input_system::mouse_in_area(area)) 60 | m_checked = !m_checked; 61 | } 62 | 63 | //--------------------------------------------------------- 64 | void fgui::checkbox::update() { 65 | 66 | // get the label text size 67 | fgui::dimension text_size = fgui::render.get_text_size(fgui::checkbox::get_font(), m_title); 68 | 69 | m_width = m_original_width + (5 + text_size.width); 70 | } 71 | 72 | //--------------------------------------------------------- 73 | void fgui::checkbox::tooltip() { 74 | 75 | // get the current position of the window 76 | fgui::point a = fgui::element::get_absolute_position(); 77 | 78 | // get the window style 79 | auto style = handler::get_style(); 80 | 81 | // get the control area 82 | fgui::rect area = { a.x, a.y, m_width, m_height }; 83 | 84 | if (m_tooltip.length() > 0) { 85 | 86 | // tooltip text size 87 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 88 | 89 | // cursor position 90 | fgui::point cursor = fgui::input_system::mouse_position(); 91 | 92 | if (fgui::input_system::mouse_in_area(area)) { 93 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.checkbox.at(3))); 94 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 95 | } 96 | } 97 | } 98 | 99 | //--------------------------------------------------------- 100 | void fgui::checkbox::save(nlohmann::json& json_module) { 101 | 102 | json_module[m_identificator.data()] = m_checked; 103 | } 104 | 105 | //--------------------------------------------------------- 106 | void fgui::checkbox::load(const std::string_view file_name) { 107 | 108 | nlohmann::json json_module; 109 | 110 | // open the file 111 | std::ifstream file_to_load(file_name.data(), std::ifstream::binary); 112 | 113 | if (file_to_load.fail()) // todo: make an exception handler 114 | return; 115 | 116 | // read config file 117 | json_module = nlohmann::json::parse(file_to_load); 118 | 119 | // change the element state to match the one stored on file 120 | m_checked = json_module[m_identificator.data()]; 121 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/checkbox.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | // framework includes 12 | #include "element.hh" 13 | 14 | namespace fgui { 15 | 16 | class checkbox : public fgui::element { 17 | public: 18 | checkbox(); 19 | 20 | // draw the element 21 | void draw(); 22 | 23 | // defines the state of the checkbox 24 | inline void set_bool(const bool &onoff) noexcept { 25 | 26 | m_checked = onoff; 27 | } 28 | 29 | // returns the checkbox state 30 | inline bool get_bool() const noexcept { 31 | 32 | return m_checked; 33 | } 34 | 35 | // handle keyboard and mouse input 36 | void handle_input(); 37 | 38 | // handle the element updates 39 | void update(); 40 | 41 | // element tooltip 42 | void tooltip(); 43 | 44 | // save the element state 45 | void save(nlohmann::json& json_module); 46 | 47 | // load the element state 48 | void load(const std::string_view file_name); 49 | private: 50 | bool m_checked; 51 | }; 52 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/colorlist.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | #include 11 | 12 | // framework includes 13 | #include "button.hh" 14 | #include "slider.hh" 15 | #include "element.hh" 16 | #include "checkbox.hh" 17 | #include "../dependencies/color.hh" 18 | 19 | namespace fgui { 20 | 21 | struct color_info { 22 | color_info(const std::string_view _identificator, const fgui::color &_color, bool _gradient = false) { 23 | 24 | alpha_slider = std::make_shared(); 25 | alpha_slider->set_title("alpha"); 26 | alpha_slider->set_value(first_color.m_alpha / 2.55f); 27 | alpha_slider->set_boundaries(0, (255 / 2.55f)); 28 | alpha_slider->set_tooltip("Change the color alpha percentage"); 29 | alpha_slider->set_font("Tahoma", 12, 0x0 /* NONE */, false); 30 | alpha_slider->set_boundaries_text("transparent", "opaque"); 31 | 32 | plus_button = std::make_shared(); 33 | plus_button->set_title("+"); 34 | plus_button->set_size(16, 16); 35 | plus_button->set_tooltip("Add a new color into the sequence"); 36 | plus_button->set_font("Tahoma", 11, 0x0 /* NONE */, true); 37 | 38 | minus_button = std::make_shared(); 39 | minus_button->set_title("-"); 40 | minus_button->set_size(16, 16); 41 | minus_button->set_tooltip("Remove the last added color of the sequence"); 42 | minus_button->set_font("Tahoma", 11, 0x0 /* NONE */, true); 43 | 44 | gradient_checkbox = std::make_shared(); 45 | gradient_checkbox->set_title("Gradient"); 46 | gradient_checkbox->set_tooltip("Enable color interpolation"); 47 | gradient_checkbox->set_font("Tahoma", 12, 0x0 /* NONE */, false); 48 | 49 | second_color_added = false; 50 | identificator = _identificator; 51 | first_color = _color; 52 | backup_color = first_color; 53 | gradient_checkbox->set_bool(_gradient); 54 | } 55 | 56 | std::string identificator; 57 | fgui::color first_color = { 0, 0, 0 }; 58 | fgui::color second_color = { 0, 0, 0 }; 59 | fgui::color backup_color = { 0, 0, 0 }; 60 | std::shared_ptr alpha_slider; 61 | std::shared_ptr plus_button, minus_button; 62 | std::shared_ptr gradient_checkbox; 63 | bool second_color_added = false; 64 | }; 65 | 66 | class colorlist : public fgui::element { 67 | public: 68 | colorlist(); 69 | 70 | // draw the element 71 | void draw(); 72 | 73 | // add a new color to the list 74 | inline void add_color(const std::string_view identificator, const fgui::color &color, bool gradient_state = false) noexcept { 75 | 76 | m_color_list.push_back( {identificator, color, gradient_state}); 77 | } 78 | 79 | // set the color and the gradient state of a specific color on the list 80 | inline void set_color(const int &index, const fgui::color &color, bool gradient_state = false) noexcept { 81 | 82 | m_color_list[index].first_color = color; 83 | 84 | m_color_list[index].gradient_checkbox->set_bool(gradient_state); 85 | } 86 | 87 | // get info the color of a specified color picker index 88 | fgui::color get_color(int index); 89 | 90 | // handle keyboard and mouse input 91 | void handle_input(); 92 | 93 | // handle the element updates 94 | void update(); 95 | 96 | // element tooltip 97 | void tooltip(); 98 | 99 | // save the element state 100 | void save(nlohmann::json& json_module); 101 | 102 | // load the element state 103 | void load(const std::string_view file_name); 104 | private: 105 | 106 | int m_selected; 107 | bool m_dragging; 108 | int m_slider_top; 109 | int m_item_height; 110 | std::vector m_color_list; 111 | }; 112 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/colorpicker.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "colorpicker.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | 10 | fgui::colorpicker::colorpicker() { 11 | 12 | fgui::colorpicker::m_width = 20; 13 | fgui::colorpicker::m_height = 16; 14 | fgui::colorpicker::m_opened = false; 15 | fgui::colorpicker::m_title = "color picker"; 16 | fgui::colorpicker::m_color = { 0, 0, 0 }; 17 | fgui::colorpicker::m_font = fgui::element::m_font; 18 | fgui::colorpicker::m_original_width = fgui::colorpicker::m_width; 19 | fgui::colorpicker::m_original_height = fgui::colorpicker::m_height; 20 | fgui::colorpicker::m_type = static_cast(fgui::detail::element_type::COLORPICKER); 21 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE) | static_cast(fgui::detail::element_flags::FOCUSABLE) | static_cast(fgui::detail::element_flags::SAVABLE); 22 | } 23 | 24 | //--------------------------------------------------------- 25 | void fgui::colorpicker::draw() { 26 | 27 | // get the current position of the window 28 | fgui::point a = fgui::element::get_absolute_position(); 29 | 30 | // get the window style 31 | auto style = handler::get_style(); 32 | 33 | // color preview area 34 | fgui::rect area = { a.x, a.y, m_original_width, m_original_height }; 35 | 36 | // color preview body 37 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.colorpicker.at(0))); 38 | 39 | if (fgui::input_system::mouse_in_area(area) || m_opened) 40 | fgui::render.outline(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.colorpicker.at(3))); 41 | else 42 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.colorpicker.at(2))); 43 | 44 | fgui::render.rect(area.left + 3, area.top + 3, area.right - 6, area.bottom - 6, fgui::color(style.colorpicker.at(1))); 45 | fgui::render.colored_gradient(area.left + 3, area.top + 3, area.right - 6, area.bottom - 6, fgui::color(m_color), fgui::color(style.colorpicker.at(2), m_color.m_alpha), false); 46 | 47 | if (m_opened) { 48 | 49 | // cursor position 50 | fgui::point cursor = fgui::input_system::mouse_position(); 51 | 52 | // picker area 53 | fgui::rect picker_area = { a.x + 25, a.y, 150, 150 }; 54 | 55 | // color picker pixelation value 56 | constexpr int pixelation = 3; 57 | 58 | // color picker body 59 | fgui::render.outline(picker_area.left, picker_area.top, (picker_area.right + 47), (picker_area.bottom + 5), fgui::color(style.colorpicker.at(0))); 60 | fgui::render.rect(picker_area.left + 1, picker_area.top + 1, (picker_area.right + 47) - 2, (picker_area.bottom + 5) - 2, fgui::color(style.colorpicker.at(1))); 61 | 62 | for (std::size_t i = 0; i < static_cast(picker_area.bottom); i += pixelation) { 63 | 64 | // colors 65 | fgui::color hue_color = fgui::color::hsb_to_rgb(i / 150.f, 1, 1); 66 | fgui::color alpha_color = fgui::color(m_color.m_red, m_color.m_green, m_color.m_blue, i / static_cast(picker_area.bottom) * 255); 67 | 68 | // hue 69 | fgui::render.rect((picker_area.left + picker_area.right) + 10, (picker_area.top + 3) + i, 15, pixelation, fgui::color(hue_color)); 70 | 71 | // alpha 72 | fgui::render.rect((picker_area.left + picker_area.right) + 30, (picker_area.top + 3) + i, 15, pixelation, fgui::color(alpha_color)); 73 | 74 | for (std::size_t j = 0; j < static_cast(picker_area.right); j += pixelation) { 75 | 76 | // color 77 | fgui::color hsb_color = fgui::color::hsb_to_rgb(fgui::color::get_hue(m_color), j / static_cast(picker_area.right), i / static_cast(picker_area.bottom), m_color.m_alpha); 78 | 79 | // hsb 80 | fgui::render.rect((picker_area.left + 3) + j, (picker_area.top + 3) + i, pixelation, pixelation, fgui::color(hsb_color)); 81 | } 82 | } 83 | 84 | // color hsb body 85 | fgui::render.outline(picker_area.left + 2, picker_area.top + 2, picker_area.right + 1, picker_area.bottom + 1, fgui::color(style.colorpicker.at(0))); 86 | 87 | // hue bar body 88 | fgui::render.outline((picker_area.left + picker_area.right) + 9, (picker_area.top + 2), 15 + 1, picker_area.bottom + 1, fgui::color(style.colorpicker.at(0))); 89 | fgui::render.rect((picker_area.left + picker_area.right) + 5, (picker_area.top + 2) + picker_area.bottom * fgui::color::get_hue(m_color), 3, 3, fgui::color(style.colorlist.at(3))); 90 | 91 | // alpha bar body 92 | fgui::render.outline((picker_area.left + picker_area.right) + 29, (picker_area.top + 2), 15 + 1, picker_area.bottom + 1, fgui::color(style.colorpicker.at(0))); 93 | fgui::render.rect((picker_area.left + picker_area.right) + 25, (picker_area.top + 2) + picker_area.bottom * (m_color.m_alpha / 255.f), 3, 3, fgui::color(style.colorlist.at(3))); 94 | 95 | // draw color code 96 | if (fgui::input_system::mouse_in_area(picker_area) && fgui::input_system::key_held(fgui::external::MOUSE_LEFT)) 97 | fgui::render.text(cursor.x - 8, cursor.y + 8, fgui::color(style.text.at(0)), fgui::colorpicker::get_font(), "rgba: " + std::to_string(m_color.m_red) + ", " + std::to_string(m_color.m_green) + ", " + 98 | std::to_string(m_color.m_blue) + ", " + std::to_string(m_color.m_alpha)); 99 | } 100 | } 101 | 102 | //--------------------------------------------------------- 103 | void fgui::colorpicker::handle_input() { 104 | 105 | // get the current position of the window 106 | fgui::point a = fgui::element::get_absolute_position(); 107 | 108 | // get the control area 109 | fgui::rect area = { a.x, a.y, m_original_width, m_original_height }; 110 | 111 | if (fgui::input_system::mouse_in_area(area)) 112 | m_opened = !m_opened; 113 | } 114 | 115 | //--------------------------------------------------------- 116 | void fgui::colorpicker::update() { 117 | 118 | // get the current position of the window 119 | fgui::point a = fgui::element::get_absolute_position(); 120 | 121 | if (m_opened) { 122 | 123 | // areas 124 | fgui::rect picker_area = { a.x + 25, a.y, 150, 150 }; 125 | fgui::rect hsb_area = { picker_area.left, picker_area.top + 2, picker_area.right + 1, picker_area.bottom + 1 }; 126 | fgui::rect hue_area = { picker_area.left + picker_area.right + 9, picker_area.top + 2, 15 + 1, picker_area.bottom + 1 }; 127 | fgui::rect alpha_area = { picker_area.left + picker_area.right + 29, picker_area.top + 2, 15 + 1, picker_area.bottom + 1 }; 128 | 129 | static bool hue_selected = false; 130 | static bool hsb_selected = false; 131 | static bool alpha_selected = false; 132 | 133 | // cursor position 134 | fgui::point cursor = fgui::input_system::mouse_position(); 135 | 136 | if (fgui::input_system::key_press(fgui::external::MOUSE_LEFT)) { 137 | 138 | hue_selected = fgui::input_system::mouse_in_area(hue_area); 139 | alpha_selected = fgui::input_system::mouse_in_area(alpha_area); 140 | hsb_selected = fgui::input_system::mouse_in_area(hsb_area); 141 | } 142 | 143 | else if (!fgui::input_system::key_held(fgui::external::MOUSE_LEFT)) { 144 | 145 | hue_selected = false; 146 | alpha_selected = false; 147 | hsb_selected = false; 148 | } 149 | 150 | if (hsb_selected) { 151 | 152 | fgui::precision_point relative_pos = { cursor.x - static_cast(hsb_area.left), cursor.y - static_cast(hsb_area.top) }; 153 | m_color = fgui::color::hsb_to_rgb(fgui::color::get_hue(m_color), relative_pos.x / picker_area.right, relative_pos.y / picker_area.bottom, m_color.m_alpha); 154 | } 155 | 156 | else if (hue_selected) { 157 | 158 | float hue = (cursor.y - hue_area.top) / 150.f; 159 | 160 | m_color = fgui::color::hsb_to_rgb(std::clamp(hue, 0.f, 1.f), 1, 1); 161 | } 162 | 163 | else if (alpha_selected) { 164 | 165 | int alpha = (cursor.y - alpha_area.top) / 150.f * 255; 166 | 167 | m_color.m_alpha = std::clamp(alpha, 0, 255); 168 | } 169 | } 170 | 171 | if (m_opened) { 172 | 173 | // get the control area 174 | fgui::rect area = { a.x, a.y, m_width, m_height }; 175 | 176 | m_width = 25 /* picker_area.left */ + 197 /* picker_area.right + 47 */; 177 | m_height = 155 /* picker_area.bottom + 5 */; 178 | 179 | if (!fgui::input_system::mouse_in_area(area)) { 180 | 181 | if (fgui::input_system::key_press(fgui::external::MOUSE_LEFT)) 182 | m_opened = false; 183 | } 184 | } 185 | 186 | else if (!m_opened) { 187 | 188 | // restore the width and height 189 | m_width = m_original_width; 190 | m_height = m_original_height; 191 | } 192 | } 193 | 194 | //--------------------------------------------------------- 195 | void fgui::colorpicker::tooltip() { 196 | 197 | // get the current position of the window 198 | fgui::point a = fgui::element::get_absolute_position(); 199 | 200 | // get the window style 201 | auto style = handler::get_style(); 202 | 203 | // get the control area 204 | fgui::rect area = { a.x, a.y, m_width, m_height }; 205 | 206 | if (m_tooltip.length() > 0) { 207 | 208 | // tooltip text size 209 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 210 | 211 | // cursor position 212 | fgui::point cursor = fgui::input_system::mouse_position(); 213 | 214 | if (fgui::input_system::mouse_in_area(area)) { 215 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.colorpicker.at(3))); 216 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 217 | } 218 | } 219 | } 220 | 221 | //--------------------------------------------------------- 222 | void fgui::colorpicker::save(nlohmann::json& json_module) { 223 | 224 | json_module[m_identificator.data()]["red"] = m_color.m_red; 225 | json_module[m_identificator.data()]["green"] = m_color.m_green; 226 | json_module[m_identificator.data()]["blue"] = m_color.m_blue; 227 | json_module[m_identificator.data()]["alpha"] = m_color.m_alpha; 228 | } 229 | 230 | //--------------------------------------------------------- 231 | void fgui::colorpicker::load(const std::string_view file_name) { 232 | 233 | nlohmann::json json_module; 234 | 235 | // open the file 236 | std::ifstream file_to_load(file_name.data(), std::ifstream::binary); 237 | 238 | if (file_to_load.fail()) // todo: make an exception handler 239 | return; 240 | 241 | // read config file 242 | json_module = nlohmann::json::parse(file_to_load); 243 | 244 | // change the element state to match the one stored on file 245 | m_color.m_red = json_module[m_identificator.data()]["red"]; 246 | m_color.m_green = json_module[m_identificator.data()]["green"]; 247 | m_color.m_blue = json_module[m_identificator.data()]["blue"]; 248 | m_color.m_alpha = json_module[m_identificator.data()]["alpha"]; 249 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/colorpicker.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // framework includes 8 | #include "element.hh" 9 | #include "../dependencies/color.hh" 10 | 11 | namespace fgui { 12 | 13 | class colorpicker : public fgui::element { 14 | public: 15 | colorpicker(); 16 | 17 | // draw the element 18 | void draw(); 19 | 20 | // set a custom color for the color picker 21 | inline void set_color(const int &red, const int &green, const int &blue, const int &alpha = 255) noexcept { 22 | 23 | m_color = { red, green, blue, alpha }; 24 | } 25 | 26 | inline void set_color(const fgui::color &color) noexcept { 27 | 28 | m_color = color; 29 | } 30 | 31 | // returns the current selected color 32 | inline fgui::color get_color() const noexcept { 33 | 34 | return m_color; 35 | } 36 | 37 | // sets a custom state for the color picker (if the color pallet is opened or not) 38 | inline void set_state(const fgui::state &state) noexcept { 39 | 40 | m_opened = state; 41 | } 42 | 43 | // returns the current state of the color picker (if the color pallet is opened or not) 44 | inline fgui::state get_state() const noexcept { 45 | 46 | return m_opened; 47 | } 48 | 49 | // handle keyboard and mouse input 50 | void handle_input(); 51 | 52 | // handle the element updates 53 | void update(); 54 | 55 | // element tooltip 56 | void tooltip(); 57 | 58 | // save the element state 59 | void save(nlohmann::json& json_module); 60 | 61 | // load the element state 62 | void load(const std::string_view file_name); 63 | private: 64 | fgui::state m_opened; 65 | fgui::color m_color = { 0, 0, 0 }; 66 | }; 67 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/combobox.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | #include 11 | 12 | // framework includes 13 | #include "element.hh" 14 | 15 | namespace fgui { 16 | 17 | class combobox : public fgui::element { 18 | public: 19 | combobox(); 20 | 21 | // draw the element 22 | void draw(); 23 | 24 | // add a new entry in the combobox 25 | inline void add_item(const std::string_view item, const int &value = 0) noexcept { 26 | 27 | m_info.push_back({ item, value }); 28 | } 29 | 30 | // clear all entries of the combobox 31 | inline void clear_items() noexcept { 32 | 33 | m_info.clear(); 34 | } 35 | 36 | // this will trigger a function when the user selects a new item 37 | inline void set_function(const std::function &callback) noexcept { 38 | 39 | m_callback = callback; 40 | } 41 | 42 | // select a specific entry of the combobox 43 | inline void set_index(int index) noexcept { 44 | 45 | m_index = index; 46 | } 47 | 48 | // get the index of the current selected entry 49 | inline int get_index() const noexcept { 50 | 51 | return m_index; 52 | } 53 | 54 | // get the value of the selected item 55 | inline int get_value() const noexcept { 56 | 57 | return m_info[m_index].value; 58 | } 59 | 60 | // sets a custom state for the combobox (if the dropdown list is opened or not) 61 | inline void set_state(fgui::state state) { 62 | 63 | m_opened = state; 64 | } 65 | 66 | // returns the current state of the combobox (if the dropdown list is opened or not) 67 | inline fgui::state get_state() const noexcept { 68 | 69 | return m_opened; 70 | } 71 | 72 | // handle keyboard and mouse input 73 | void handle_input(); 74 | 75 | // handle the element updates 76 | void update(); 77 | 78 | // element tooltip 79 | void tooltip(); 80 | 81 | // save the element state 82 | void save(nlohmann::json& json_module); 83 | 84 | // load the element state 85 | void load(const std::string_view file_name); 86 | private: 87 | 88 | int m_index; 89 | bool m_dragging; 90 | int m_slider_top; 91 | int m_item_height; 92 | fgui::state m_opened; 93 | std::function m_callback; 94 | std::vector m_info; 95 | }; 96 | } 97 | -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/container.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | // framework includes 15 | #include "element.hh" 16 | 17 | namespace fgui { 18 | 19 | class container : public fgui::element { 20 | public: 21 | container(); 22 | 23 | // draw the element 24 | void draw(); 25 | 26 | // set the container state (this will be used for windows) 27 | inline void set_state(const fgui::state& state) noexcept { 28 | 29 | m_opened = state; 30 | } 31 | 32 | // returns the state of the container 33 | inline fgui::state get_state() const noexcept { 34 | 35 | return m_opened; 36 | } 37 | 38 | // save all elements inside a config file 39 | void save_config(const std::string_view file_name); 40 | 41 | // add a new control in the container 42 | void add_control(const std::shared_ptr& control, int page_index = -1, bool manual_size = false); 43 | 44 | // set whether or not the scrollbar should be used 45 | inline void set_scrollbar_state(const fgui::state& state) noexcept { 46 | 47 | m_scrollable = state; 48 | } 49 | 50 | // enable/disable the resizeable option of the container 51 | inline void set_resize_state(const fgui::state& state) noexcept { 52 | 53 | m_resizeable = state; 54 | } 55 | 56 | // enable/disable the hidden state of the container (hover to unhide) 57 | inline void set_hidden_state(const fgui::state& state) noexcept { 58 | 59 | m_hideable = state; 60 | } 61 | 62 | // returns true if the container has a scrollbar 63 | inline fgui::state get_scrollbar_state() const noexcept { 64 | 65 | return m_scrollable; 66 | } 67 | 68 | // get the amount that a element is suposed to move according with the scrollbar 69 | inline int get_scroll_offset() const noexcept { 70 | 71 | return m_scroll_offset; 72 | } 73 | 74 | // call a function when the window is opened 75 | inline void set_function(const std::function& callback) noexcept { 76 | 77 | m_callback = callback; 78 | } 79 | 80 | // handle keyboard and mouse input 81 | void handle_input(); 82 | 83 | // handle the element updates 84 | void update(); 85 | 86 | // element tooltip 87 | void tooltip(); 88 | 89 | // save the element state 90 | void save(nlohmann::json& json_module); 91 | 92 | // load the element state 93 | void load(const std::string_view file_name); 94 | private: 95 | 96 | int m_scroll_offset, m_bottom_element_pos; 97 | fgui::state m_opened, m_scrollable, m_resizeable, m_hideable; 98 | bool m_dragging_container, m_size_changing, m_dragging_scrollbar; 99 | std::vector> m_elements; 100 | std::function m_callback; 101 | }; 102 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/element.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "tabs.hh" 7 | #include "listbox.hh" 8 | #include "element.hh" 9 | #include "combobox.hh" 10 | #include "checkbox.hh" 11 | #include "multibox.hh" 12 | #include "container.hh" 13 | 14 | //--------------------------------------------------------- 15 | bool fgui::element::unlocked() { 16 | 17 | if (!m_controller || m_page_index == -1) 18 | return true; 19 | 20 | switch (m_controller->m_type) { 21 | 22 | case static_cast(fgui::detail::element_type::COMBOBOX): 23 | return std::reinterpret_pointer_cast(m_controller)->get_index() == m_page_index; 24 | 25 | case static_cast(fgui::detail::element_type::CHECKBOX): 26 | return std::reinterpret_pointer_cast(m_controller)->get_bool() == m_page_index; 27 | 28 | case static_cast(fgui::detail::element_type::LISTBOX): 29 | return std::reinterpret_pointer_cast(m_controller)->get_index() == m_page_index; 30 | 31 | case static_cast(fgui::detail::element_type::MULTIBOX): 32 | return std::reinterpret_pointer_cast(m_controller)->get_selected(m_page_index); 33 | 34 | case static_cast(fgui::detail::element_type::TAB): 35 | return std::reinterpret_pointer_cast(m_controller)->get_index() == m_page_index; 36 | } 37 | 38 | return false; 39 | } 40 | 41 | //--------------------------------------------------------- 42 | std::shared_ptr fgui::element::get_window() { 43 | 44 | std::shared_ptr current_container = shared_from_this(); 45 | 46 | while (current_container->m_parent_element) 47 | current_container = current_container->m_parent_element; 48 | 49 | return current_container; 50 | } 51 | 52 | //--------------------------------------------------------- 53 | std::shared_ptr fgui::element::get_first_container() { 54 | 55 | std::shared_ptr first_container = shared_from_this(); 56 | 57 | while (!first_container->get_family(fgui::detail::element_type::CONTAINER)) 58 | first_container = first_container->m_parent_element; 59 | 60 | return first_container; 61 | } 62 | 63 | //--------------------------------------------------------- 64 | fgui::point fgui::element::get_absolute_position() { 65 | 66 | m_absolute_position = { 0, 0 }; 67 | 68 | // 69 | // this is the size of the window header bar in pixels 70 | // 71 | constexpr int header_bar_size = 25; 72 | 73 | if (!m_parent_element) 74 | return { get_position().x, get_position().y }; 75 | 76 | fgui::point position = m_parent_element->get_absolute_position(); 77 | 78 | m_absolute_position.x = m_x + position.x; 79 | m_absolute_position.y = m_y + position.y; 80 | 81 | if (m_parent_element->get_family(fgui::detail::element_type::CONTAINER) && std::reinterpret_pointer_cast(m_parent_element)->get_scrollbar_state()) 82 | m_absolute_position.y -= std::reinterpret_pointer_cast(m_parent_element)->get_scroll_offset(); 83 | 84 | // element usable area 85 | if (m_parent_element == get_window()) 86 | m_absolute_position.y += header_bar_size; 87 | 88 | else if (m_parent_element != get_window()) 89 | m_absolute_position.y += 1; 90 | 91 | return m_absolute_position; 92 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/element.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | // framework includes 14 | #include "../dependencies/json.hh" 15 | #include "../dependencies/aliases.hh" 16 | #include "../dependencies/definitions.hh" 17 | 18 | namespace fgui { 19 | 20 | // declarations 21 | class container; 22 | 23 | class element : public std::enable_shared_from_this { 24 | friend class fgui::container; 25 | public: 26 | 27 | // sets a custom position for the element 28 | inline void set_position(const int &x, const int &y) noexcept { 29 | m_x = x; 30 | m_y = y; 31 | } 32 | 33 | // sets the a custom size for the element 34 | inline void set_size(const int &width, const int &height) noexcept { 35 | 36 | m_width = width; 37 | m_height = height; 38 | } 39 | 40 | // check if the element is being controlled by a controller 41 | bool unlocked(); 42 | 43 | // get the current size of the element 44 | inline fgui::dimension get_size() const noexcept { 45 | 46 | return { m_width, m_height }; 47 | } 48 | 49 | // get the current position of the element 50 | inline fgui::point get_position() const noexcept { 51 | 52 | return { m_x, m_y }; 53 | } 54 | 55 | // sets a custom title for the element 56 | inline void set_title(const std::string_view title) noexcept { 57 | 58 | m_title = title; 59 | } 60 | 61 | // returns the title of the element 62 | inline std::string_view get_title() const noexcept { 63 | 64 | return m_title; 65 | } 66 | 67 | // sets a custom tooltip for the element 68 | inline void set_tooltip(const std::string_view tooltip) noexcept { 69 | 70 | m_tooltip = tooltip; 71 | } 72 | 73 | // get the container that is behaving like a window 74 | std::shared_ptr get_window(); 75 | 76 | // get the first container available 77 | std::shared_ptr get_first_container(); 78 | 79 | // get the container window area (position) 80 | fgui::point get_absolute_position(); 81 | 82 | // sets a custom flag for the element 83 | inline void set_flag(const int &flag) noexcept { 84 | 85 | m_flags |= static_cast(flag); 86 | } 87 | 88 | // get the flag of the element 89 | inline bool get_flag(const fgui::detail::element_flags &flag) const noexcept { 90 | 91 | if (m_flags & static_cast(flag)) 92 | return true; 93 | 94 | return false; 95 | } 96 | 97 | // set the element family 98 | inline void set_family(const int &type) noexcept { 99 | 100 | m_type = static_cast(type); 101 | } 102 | 103 | // get the element type 104 | inline bool get_family(const fgui::detail::element_type &type) const noexcept { 105 | 106 | if (m_type == static_cast(type)) 107 | return true; 108 | 109 | return false; 110 | } 111 | 112 | // set the element page controller (element bound) 113 | inline void set_controller(const std::shared_ptr &controller) noexcept { 114 | 115 | m_controller = controller; 116 | } 117 | 118 | // sets a custom indentificator for the element (this is used by the config system) 119 | inline void set_identificator(const std::string_view identificator) noexcept { 120 | 121 | m_identificator = identificator; 122 | } 123 | 124 | // get the current identificator of the element 125 | inline std::string_view get_identificator() const noexcept { 126 | 127 | return m_identificator; 128 | } 129 | 130 | // allows the user to change the font of the element 131 | inline void set_font(const std::string_view font_family, int size, int flags = 0, bool bold = false) noexcept { 132 | 133 | fgui::render.create_font(m_font, font_family, size, flags, bold); 134 | } 135 | 136 | inline void set_font(const fgui::element_font &element_font) noexcept { 137 | 138 | fgui::render.create_font(m_font, element_font.family, element_font.size, element_font.flags, element_font.bold); 139 | } 140 | 141 | // returns the font that the element is currently using 142 | inline fgui::font get_font() const noexcept { 143 | 144 | return m_font; 145 | } 146 | 147 | protected: 148 | virtual void draw() = 0; // draw the element 149 | virtual void handle_input() = 0; // handles the element keyboard and mouse input 150 | virtual void update() = 0; // handles the element updates 151 | virtual void tooltip() = 0; // draw the element tooltip 152 | virtual void save(nlohmann::json& json_module) = 0; // write the element state on a file 153 | virtual void load(const std::string_view file_name) = 0; // read the element state of a file 154 | protected: 155 | int m_type; 156 | int m_flags; 157 | int m_x, m_y; 158 | int m_page_index; 159 | fgui::font m_font; 160 | int m_width, m_height; 161 | std::string_view m_title; 162 | std::string_view m_tooltip; 163 | std::string_view m_identificator; 164 | fgui::point m_absolute_position; 165 | int m_original_width, m_original_height; 166 | std::shared_ptr m_controller; 167 | std::shared_ptr m_parent_element; 168 | }; 169 | } 170 | -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/keybinder.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "keybinder.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | 10 | fgui::keybinder::keybinder() { 11 | 12 | fgui::keybinder::m_width = 100; 13 | fgui::keybinder::m_height = 20; 14 | fgui::keybinder::m_title = "keybinder"; 15 | fgui::keybinder::m_font = fgui::element::m_font; 16 | fgui::keybinder::m_is_getting_key = false; 17 | fgui::keybinder::m_key = -1; /* KEY_INVALID */ 18 | fgui::keybinder::m_type = static_cast(fgui::detail::element_type::KEYBINDER); 19 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE) | static_cast(fgui::detail::element_flags::SAVABLE); 20 | } 21 | 22 | //--------------------------------------------------------- 23 | void fgui::keybinder::draw() { 24 | 25 | // get the current position of the window 26 | fgui::point a = fgui::element::get_absolute_position(); 27 | 28 | // get the window style 29 | auto style = handler::get_style(); 30 | 31 | // get the control area 32 | fgui::rect area = { a.x, a.y, m_width, m_height }; 33 | 34 | // keybinder title text size 35 | fgui::dimension text_size = fgui::render.get_text_size(fgui::keybinder::get_font(), m_title); 36 | 37 | // keybinder body 38 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.keybinder.at(0))); 39 | 40 | if (fgui::input_system::mouse_in_area(area) || m_is_getting_key) 41 | fgui::render.outline(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.keybinder.at(3))); 42 | else 43 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.keybinder.at(2))); 44 | 45 | fgui::render.colored_gradient(area.left + 3, area.top + 3, area.right - 6, area.bottom - 6, fgui::color(style.keybinder.at(1)), fgui::color(style.keybinder.at(2)), false); 46 | 47 | // keybinder label 48 | fgui::render.text(area.left, (area.top - text_size.height) - 2, fgui::color(style.text.at(0)), fgui::keybinder::get_font(), m_title); 49 | 50 | // bound key text size 51 | fgui::dimension bound_key_text_size = fgui::render.get_text_size(fgui::keybinder::get_font(), m_key > 0 ? m_iinput_system[m_key].data() : "Not Bound"); 52 | 53 | // draw the current key 54 | fgui::render.text(area.left + (area.right / 2) - (bound_key_text_size.width / 2), area.top + (area.bottom / 2) - (text_size.height / 2) - 1, fgui::color(style.text.at(0)), fgui::keybinder::get_font(), m_key > 0 ? m_iinput_system[m_key].data() : "Not Bound"); 55 | } 56 | 57 | //--------------------------------------------------------- 58 | void fgui::keybinder::handle_input() { 59 | 60 | // get the current position of the window 61 | fgui::point a = fgui::element::get_absolute_position(); 62 | 63 | // get the control area 64 | fgui::rect area = { a.x, a.y, m_width, m_height }; 65 | 66 | // unlock the key binder 67 | if (fgui::input_system::mouse_in_area(area)) 68 | m_is_getting_key = !m_is_getting_key; 69 | } 70 | 71 | //--------------------------------------------------------- 72 | void fgui::keybinder::update() { 73 | 74 | // get the current position of the window 75 | fgui::point a = fgui::element::get_absolute_position(); 76 | 77 | // get the control area 78 | fgui::rect area = { a.x, a.y, m_width, m_height }; 79 | 80 | // if the key binder is unlocked 81 | if (m_is_getting_key) { 82 | 83 | for (std::size_t i = 0; i < 256 /* KEY_MAX */; i++) { 84 | 85 | // if the user has pressed a valid key 86 | if (fgui::input_system::key_press(i)) { 87 | 88 | // if the user hits escape, lock the keybinder 89 | if (i == fgui::external::KEY_ESCAPE) { 90 | 91 | // select the key 92 | m_key = -1 /* KEY_INVALID */; 93 | 94 | // change key binder status 95 | m_status = "Not Bound"; 96 | 97 | // block the keybinder from receiving input 98 | m_is_getting_key = false; 99 | } 100 | 101 | else if (i != fgui::external::KEY_ESCAPE) { 102 | 103 | m_key = i; 104 | 105 | // display the current selected key 106 | fgui::m_iinput_system[m_key].data(); 107 | 108 | // block the key binder from receiving input 109 | m_is_getting_key = false; 110 | } 111 | } 112 | } 113 | } 114 | } 115 | 116 | //--------------------------------------------------------- 117 | void fgui::keybinder::tooltip() { 118 | 119 | // get the current position of the window 120 | fgui::point a = fgui::element::get_absolute_position(); 121 | 122 | // get the window style 123 | auto style = handler::get_style(); 124 | 125 | // get the control area 126 | fgui::rect area = { a.x, a.y, m_width, m_height }; 127 | 128 | if (m_tooltip.length() > 0) { 129 | 130 | // tooltip text size 131 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 132 | 133 | // cursor position 134 | fgui::point cursor = fgui::input_system::mouse_position(); 135 | 136 | if (fgui::input_system::mouse_in_area(area)) { 137 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.keybinder.at(3))); 138 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 139 | } 140 | } 141 | } 142 | 143 | //--------------------------------------------------------- 144 | void fgui::keybinder::save(nlohmann::json& json_module) { 145 | 146 | json_module[m_identificator.data()]["key_code"] = m_key; 147 | } 148 | 149 | //--------------------------------------------------------- 150 | void fgui::keybinder::load(const std::string_view file_name) { 151 | 152 | nlohmann::json json_module; 153 | 154 | // open the file 155 | std::ifstream file_to_load(file_name.data(), std::ifstream::binary); 156 | 157 | if (file_to_load.fail()) // todo: make an exception handler 158 | return; 159 | 160 | // read config file 161 | json_module = nlohmann::json::parse(file_to_load); 162 | 163 | // change the element state to match the one stored on file 164 | m_key = json_module[m_identificator.data()]["key_code"]; 165 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/keybinder.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | 10 | // framework includes 11 | #include "element.hh" 12 | 13 | namespace fgui { 14 | 15 | /* 16 | * NOTE 1: If you don't want to use winapi keycodes, you will need to manually map your keys here. 17 | * 18 | * 19 | * NOTE 2: By default the framework comes with 2 "maps". One for the IInputSystem (Source Engine) and 20 | * another for the Windows Virtual Keycodes (GetAsyncKeyState). 21 | * 22 | * (If you don't plan on using anything other than "VK keys", you should be fine.) 23 | */ 24 | 25 | // win api keys (some keys might be missing) 26 | constexpr std::string_view m_winapi[] = { "", "MOUSE1", "MOUSE2", "BREAK", "MOUSE3", "MOUSE4", "MOUSE5", 27 | "", "BACKSPACE", "TAB", "", "", "", "ENTER", "", "", "SHIFT", 28 | "CTRL", "ALT", "PAUSE", "CAPSLOCK", "", "", "", "", "", "", 29 | "", "", "", "", "", "SPACE", "PG UP", "PG DOWN", "END", "HOME", "LEFT", 30 | "UP", "RIGHT", "DOWN", "", "", "", "PRT SCR", "INSERT", "DELETE", "", "0", "1", 31 | "2", "3", "4", "5", "6", "7", "8", "9", "", "", "", "", "", "", 32 | "", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", 33 | "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", 34 | "Z", "LWIN", "RWIN", "", "", "", "NUM 0", "NUM 1", "NUM 2", "NUM 3", 35 | "NUM 4", "NUM 5", "NUM 6", "NUM 7", "NUM 8", "NUM 9", "*", "+", "_", 36 | "-", ".", "/", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", 37 | "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", 38 | "F20", "F21", "F22", "F23", "F24", "", "", "", "", "", "", "", "", 39 | "NUM LOCK", "SCROLL LOCK", "", "", "", "", "", "", "", "", "", "", 40 | "", "", "", "", "LSHIFT", "RSHIFT", "LCONTROL", "RCONTROL", "LMENU", 41 | "RMENU", "", "", "", "", "", "", "", "", "", "", "NEXT TRACK", "PREVIOUS TRACK", 42 | "STOP", "PLAY/PAUSE", "", "", "", "", "", "", ";", "+", ",", "-", ".", 43 | "/?", "~", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 44 | "", "", "", "", "", "", "", "", "", "", "", "[{", "\\|", "}]", "'\"", 45 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 46 | "", "", "", "", "", "", "", "", "", "", "", "" 47 | }; 48 | 49 | // iinput system keys 50 | constexpr std::string_view m_iinput_system[] = { "'", "0", "1", "2", "3", "4", "5", "6", "7", 51 | "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", 52 | "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", 53 | "S", "T", "U", "V", "W", "X", "Y", "Z", "NUM0", 54 | "NUM1", "NUM2", "NUM3", "NUM4", "NUM5", "NUM6", "NUM7", 55 | "NUM8", "NUM9", "/", "*", "-", "+", "ENTER", ",", ".", 56 | "[", "Ç", "~", "´", ",", ".", ";", "]", "-", "=", 57 | "ENTER", "SPACE", "BACKSPACE", "TAB", "CAPSLOCK", "NUMLCK", "", 58 | "SCROLL LOCK", "INSERT", "DELETE", "HOME", "END", "PG UP", "PG DOWN", 59 | "PAUSE", "LSHIFT", "RSHIFT", "ALT", "RALT", "LCONTROL", 60 | "RCONTROL", "LWIN", "RWIN", "APP", "UP", "LEFT", "DOWN", 61 | "RIGHT", "F1", "F2", "F3", "F4", "F5", "F6", "F7", 62 | "F8", "F9", "F10", "F11", "F12", "", "", "", 63 | "MOUSE1", "MOUSE2", "MOUSE3", "MOUSE4", "MOUSE5", "", "" 64 | }; 65 | 66 | class keybinder : public fgui::element { 67 | public: 68 | keybinder(); 69 | 70 | // draw the element 71 | void draw(); 72 | 73 | // set a custom key 74 | inline void set_key(const fgui::key &key) noexcept { 75 | 76 | m_key = key; 77 | } 78 | 79 | // get the current key 80 | inline fgui::key get_key() const noexcept { 81 | 82 | return m_key; 83 | } 84 | 85 | // handle keyboard and mouse input 86 | void handle_input(); 87 | 88 | // handle the element updates 89 | void update(); 90 | 91 | // element tooltip 92 | void tooltip(); 93 | 94 | // save the element state 95 | void save(nlohmann::json& json_module); 96 | 97 | // load the element state 98 | void load(const std::string_view file_name); 99 | private: 100 | 101 | fgui::key m_key; 102 | std::string m_status; 103 | bool m_is_getting_key; 104 | }; 105 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/label.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "label.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | #include "../dependencies/aliases.hh" 10 | 11 | fgui::label::label() { 12 | 13 | fgui::element::m_height = 14; 14 | fgui::label::m_text = "sample text"; 15 | fgui::label::m_font = fgui::element::m_font; 16 | fgui::label::m_type = fgui::label_type::TEXT; 17 | fgui::element::m_type = static_cast(fgui::detail::element_type::LABEL); 18 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE); 19 | } 20 | 21 | //--------------------------------------------------------- 22 | void fgui::label::draw() { 23 | 24 | // get the current position of the window 25 | fgui::point a = fgui::element::get_absolute_position(); 26 | 27 | // get the window style 28 | auto style = handler::get_style(); 29 | 30 | // label size 31 | fgui::dimension text_size = fgui::render.get_text_size(fgui::label::get_font(), fgui::label::m_text); 32 | 33 | // label types 34 | switch (m_type) { 35 | 36 | case fgui::label_type::TEXT: { 37 | fgui::render.text(a.x, a.y, fgui::color(style.label.at(3)), fgui::label::get_font(), m_text); 38 | break; 39 | } 40 | 41 | case fgui::label_type::LINK: { 42 | fgui::render.text(a.x, a.y, fgui::color(style.label.at(5)), fgui::label::get_font(), m_text); 43 | fgui::render.rect(a.x, a.y + text_size.height, text_size.width, 1, fgui::color(style.label.at(5))); 44 | break; 45 | } 46 | 47 | case fgui::label_type::BANNER: { 48 | 49 | if (m_parent_element) 50 | m_width = m_parent_element->get_size().width - (m_x * 2); 51 | else 52 | m_width = text_size.width; 53 | 54 | // banner area 55 | fgui::rect banner_area = {a.x, a.y, m_width, 30}; 56 | 57 | // banner body 58 | fgui::render.outline(banner_area.left, banner_area.top, banner_area.right, banner_area.bottom, fgui::color(style.label.at(0))); 59 | fgui::render.outline(banner_area.left + 2, banner_area.top + 2, banner_area.right - 4, banner_area.bottom - 4, fgui::color(style.label.at(4))); 60 | fgui::render.rect(banner_area.left + 3, banner_area.top + 3, banner_area.right - 6, banner_area.bottom - 6, fgui::color(style.label.at(1))); 61 | 62 | // banner label 63 | if (m_parent_element) 64 | fgui::render.text(banner_area.left + (banner_area.right / 2) - (text_size.width / 2), banner_area.top + (banner_area.bottom / 2) - (text_size.height / 2), fgui::color(style.label.at(3)), fgui::label::get_font(), m_text); 65 | else 66 | fgui::render.text(banner_area.left + 10, banner_area.top + (banner_area.bottom / 2) - (text_size.height / 2), fgui::color(style.label.at(3)), fgui::label::get_font(), m_text); 67 | 68 | break; 69 | } 70 | 71 | case fgui::label_type::COLORED: { 72 | fgui::render.text(a.x, a.y, fgui::color(style.label.at(4)), fgui::label::get_font(), m_text); 73 | break; 74 | } 75 | 76 | } 77 | } 78 | 79 | //--------------------------------------------------------- 80 | void fgui::label::handle_input() { 81 | 82 | if (m_type == fgui::label_type::LINK) { 83 | 84 | // get the current position of the window 85 | fgui::point a = fgui::element::get_absolute_position(); 86 | 87 | // label size 88 | fgui::dimension text_size = fgui::render.get_text_size(fgui::label::get_font(), m_text); 89 | 90 | // get the label area 91 | fgui::rect area = { a.x, a.y, text_size.width, text_size.height }; 92 | 93 | if (fgui::input_system::mouse_in_area(area)) { 94 | 95 | if (fgui::input_system::key_press(fgui::external::MOUSE_LEFT)) { 96 | 97 | // TODO: figure out a way to open links. 98 | } 99 | } 100 | } 101 | } 102 | 103 | //--------------------------------------------------------- 104 | void fgui::label::update() { 105 | 106 | if (m_type == fgui::label_type::TEXT || m_type == fgui::label_type::COLORED || m_type == fgui::label_type::BANNER) 107 | fgui::label::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE); 108 | 109 | // make the element clickable if the label is a link 110 | else if (m_type == fgui::label_type::LINK) 111 | fgui::label::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE); 112 | } 113 | 114 | //--------------------------------------------------------- 115 | void fgui::label::tooltip() { 116 | 117 | // get the current position of the window 118 | fgui::point a = fgui::element::get_absolute_position(); 119 | 120 | // get the window style 121 | auto style = handler::get_style(); 122 | 123 | // get the control area 124 | fgui::rect area = { a.x, a.y, m_width, m_height }; 125 | 126 | if (m_tooltip.length() > 0) { 127 | 128 | // tooltip text size 129 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 130 | 131 | // cursor position 132 | fgui::point cursor = fgui::input_system::mouse_position(); 133 | 134 | if (fgui::input_system::mouse_in_area(area)) { 135 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.label.at(3))); 136 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 137 | } 138 | } 139 | } 140 | 141 | //--------------------------------------------------------- 142 | void fgui::label::save(nlohmann::json& json_module) {} 143 | 144 | //--------------------------------------------------------- 145 | void fgui::label::load(const std::string_view file_name) {} -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/label.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | 10 | // framework includes 11 | #include "element.hh" 12 | 13 | namespace fgui { 14 | 15 | class label : public fgui::element { 16 | public: 17 | label(); 18 | 19 | // draw the element 20 | void draw(); 21 | 22 | // sets a custom text in the label 23 | inline void set_text(const std::string_view text) noexcept { 24 | 25 | m_text = text; 26 | } 27 | 28 | // sets a custom type for the label 29 | inline void set_type(const fgui::label_type &label_type) noexcept { 30 | 31 | m_type = label_type; 32 | } 33 | 34 | // handle keyboard and mouse input 35 | void handle_input(); 36 | 37 | // handle the element updates 38 | void update(); 39 | 40 | // element tooltip 41 | void tooltip(); 42 | 43 | // save the element state 44 | void save(nlohmann::json& json_module); 45 | 46 | // load the element state 47 | void load(const std::string_view file_name); 48 | private: 49 | 50 | std::string m_text; 51 | fgui::label_type m_type; 52 | }; 53 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/listbox.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "listbox.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | #include "../dependencies/aliases.hh" 10 | 11 | fgui::listbox::listbox() { 12 | 13 | fgui::listbox::m_index = 0; 14 | fgui::listbox::m_title = "listbox"; 15 | fgui::listbox::m_slider_top = 0; 16 | fgui::listbox::m_item_height = 20; 17 | fgui::listbox::m_font = fgui::element::m_font; 18 | fgui::listbox::m_type = static_cast(fgui::detail::element_type::LISTBOX); 19 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE) | static_cast(fgui::detail::element_flags::SAVABLE); 20 | } 21 | 22 | //--------------------------------------------------------- 23 | void fgui::listbox::draw() { 24 | 25 | // get the current position of the window 26 | fgui::point a = fgui::element::get_absolute_position(); 27 | 28 | // get the window style 29 | auto style = handler::get_style(); 30 | 31 | // get the control area 32 | fgui::rect area = { a.x, a.y, m_width, m_height }; 33 | 34 | // get the number of displayed items 35 | static int item_displayed = 0; 36 | 37 | // calculate the quantity of entries that will be drawned on the listbox 38 | static int calculated_items = m_height / m_item_height; 39 | 40 | // listbox body 41 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.listbox.at(0))); 42 | 43 | if (fgui::input_system::mouse_in_area(area) || m_dragging) 44 | fgui::render.outline(area.left + 2, area.top + 2, (area.right - 14) - 4, area.bottom - 4, fgui::color(style.listbox.at(3))); 45 | else 46 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.listbox.at(1))); 47 | 48 | fgui::render.rect(area.left + 3, area.top + 3, (area.right - 14) - 6, area.bottom - 6, fgui::color(style.listbox.at(2))); 49 | 50 | // listbox label 51 | fgui::render.text(area.left, area.top - 15, fgui::color(style.text.at(0)), fgui::listbox::get_font(), m_title); 52 | 53 | if (m_info.empty()) 54 | return; 55 | 56 | for (std::size_t i = m_slider_top; (i < m_info.size() && item_displayed < calculated_items); i++) { 57 | 58 | // get the item region 59 | fgui::rect item_area = { a.x, a.y + (m_item_height * item_displayed), (m_width - 15), m_item_height }; 60 | 61 | // item text size 62 | fgui::dimension item_text_size = fgui::render.get_text_size(fgui::listbox::get_font(), m_info[i].item); 63 | 64 | // if the user is hovering an item on the list 65 | if (fgui::input_system::mouse_in_area(item_area) || m_index == i) { 66 | 67 | fgui::render.rect(item_area.left + 2, item_area.top + 2, item_area.right - 4, item_area.bottom - 4, fgui::color(style.listbox.at(3))); 68 | 69 | if (m_info[i].item.length() > 20) 70 | fgui::render.text(item_area.left + 5, item_area.top + (item_area.bottom / 2) - (item_text_size.height / 2), fgui::color(style.text.at(3)), fgui::listbox::get_font(), m_info[i].item.replace(m_info[i].item.begin() + 20, m_info[i].item.end(), "...")); 71 | else 72 | fgui::render.text(item_area.left + 5, item_area.top + (item_area.bottom / 2) - (item_text_size.height / 2), fgui::color(style.text.at(3)), fgui::listbox::get_font(), m_info[i].item); 73 | } 74 | 75 | else if (!fgui::input_system::mouse_in_area(item_area)) { 76 | 77 | if (m_info[i].item.length() > 20) 78 | fgui::render.text(item_area.left + 5, item_area.top + (item_area.bottom / 2) - (item_text_size.height / 2), fgui::color(style.text.at(0)), fgui::listbox::get_font(), m_info[i].item.replace(m_info[i].item.begin() + 20, m_info[i].item.end(), "...")); 79 | else 80 | fgui::render.text(item_area.left + 5, item_area.top + (item_area.bottom / 2) - (item_text_size.height / 2), fgui::color(style.text.at(0)), fgui::listbox::get_font(), m_info[i].item); 81 | } 82 | 83 | item_displayed++; 84 | } 85 | 86 | // calculate the slider position 87 | float calculated_position = static_cast(m_slider_top) / static_cast(m_info.size()); 88 | 89 | if (calculated_position >= 1.f) 90 | calculated_position = 1.f; 91 | 92 | calculated_position *= m_height; 93 | 94 | // calculate the slider size 95 | float calculated_size = static_cast(calculated_items) / static_cast(m_info.size()); 96 | 97 | if (calculated_size > 1.f) 98 | calculated_size = 1.f; 99 | 100 | calculated_size *= m_height; 101 | 102 | // scrollbar area 103 | fgui::rect scrollbar_area = { (area.left + 2) + (area.right - 15), area.top + 2, 15 - 4, area.bottom - 4 }; 104 | 105 | // scrollbar body 106 | fgui::render.outline(scrollbar_area.left + 1, scrollbar_area.top + 1, scrollbar_area.right - 2, scrollbar_area.bottom - 2, fgui::color(style.listbox.at(0))); 107 | fgui::render.rect(scrollbar_area.left, scrollbar_area.top, scrollbar_area.right, scrollbar_area.bottom, fgui::color(style.listbox.at(1))); 108 | fgui::render.outline(scrollbar_area.left + 1, (scrollbar_area.top + calculated_position) + 1, scrollbar_area.right - 2, (calculated_size - 2) - 4, fgui::color(style.listbox.at(3))); 109 | 110 | if (m_info.size() > 100) 111 | fgui::render.colored_gradient(scrollbar_area.left + 2, (scrollbar_area.top + calculated_position) + 2, scrollbar_area.right - 4, (calculated_size - 4) - 4, fgui::color(style.listbox.at(1)), fgui::color(style.listbox.at(2)), false); 112 | else 113 | fgui::render.colored_gradient(scrollbar_area.left + 2, (scrollbar_area.top + calculated_position) + 2, scrollbar_area.right - 4, (calculated_size - 4) - 4, fgui::color(style.listbox.at(1)), fgui::color(style.listbox.at(2)), false); 114 | 115 | // dots 116 | if (m_dragging) { 117 | 118 | fgui::render.rect(scrollbar_area.left + 5, (scrollbar_area.top + calculated_position) + 2 + (calculated_size / 2) - 1, 1, 1, fgui::color(style.listbox.at(3))); 119 | fgui::render.rect(scrollbar_area.left + 5, (scrollbar_area.top + calculated_position) + 2 + (calculated_size / 2) - 3, 1, 1, fgui::color(style.listbox.at(3))); 120 | fgui::render.rect(scrollbar_area.left + 5, (scrollbar_area.top + calculated_position) + 2 + (calculated_size / 2) - 5, 1, 1, fgui::color(style.listbox.at(3))); 121 | } 122 | 123 | else if (!m_dragging) { 124 | 125 | fgui::render.rect(scrollbar_area.left + 5, (scrollbar_area.top + calculated_position) + 2 + (calculated_size / 2) - 1, 1, 1, fgui::color(style.text.at(0))); 126 | fgui::render.rect(scrollbar_area.left + 5, (scrollbar_area.top + calculated_position) + 2 + (calculated_size / 2) - 3, 1, 1, fgui::color(style.text.at(0))); 127 | fgui::render.rect(scrollbar_area.left + 5, (scrollbar_area.top + calculated_position) + 2 + (calculated_size / 2) - 5, 1, 1, fgui::color(style.text.at(0))); 128 | } 129 | } 130 | 131 | //--------------------------------------------------------- 132 | void fgui::listbox::handle_input() { 133 | 134 | // get the current position of the window 135 | fgui::point a = fgui::element::get_absolute_position(); 136 | 137 | if (m_info.size() > 0) { 138 | 139 | // get the control area 140 | fgui::rect area = { a.x, a.y, m_width , m_height }; 141 | 142 | // scrollbar area 143 | fgui::rect scrollbar_area = { (area.left + 2) + (area.right - 15), area.top + 2, 15 - 4, area.bottom - 4 }; 144 | 145 | if (fgui::input_system::mouse_in_area(scrollbar_area)) { 146 | 147 | if (fgui::input_system::key_held(fgui::external::MOUSE_LEFT)) 148 | m_dragging = true; 149 | } 150 | 151 | // get the number of displayed items 152 | static int item_displayed = 0; 153 | 154 | // calculate the amount of items to be drawned 155 | static int calculated_items = m_height / m_item_height; 156 | 157 | for (std::size_t i = m_slider_top; (i < m_info.size() && item_displayed < calculated_items); i++) { 158 | 159 | // get the item area of the list box 160 | fgui::rect item_region = { a.x, a.y + (item_displayed * m_item_height), m_width - 15, m_item_height }; 161 | 162 | if (fgui::input_system::mouse_in_area(item_region)) { 163 | 164 | // select a item 165 | m_index = i; 166 | } 167 | 168 | item_displayed++; 169 | } 170 | } 171 | } 172 | 173 | //--------------------------------------------------------- 174 | void fgui::listbox::update() { 175 | 176 | // get the current position of the window 177 | fgui::point a = fgui::element::get_absolute_position(); 178 | 179 | // calculate the amount of items to be drawned 180 | static int calculated_items = m_height / m_item_height; 181 | 182 | if (m_dragging) { 183 | 184 | if (fgui::input_system::key_held(fgui::external::MOUSE_LEFT)) { 185 | 186 | // cursor position 187 | fgui::point cursor = fgui::input_system::mouse_position(); 188 | 189 | // move the slider vertically 190 | cursor.y -= a.y + 2; 191 | 192 | // ratio of how many visible to how many are hidden 193 | float calculated_size = static_cast(calculated_items) / static_cast(m_info.size()); 194 | calculated_size *= m_height; 195 | 196 | // height delta 197 | float height_delta = (cursor.y + calculated_size) - m_height; 198 | 199 | if (height_delta >= 0) 200 | cursor.y -= height_delta; 201 | 202 | float new_position_ratio = static_cast(cursor.y) / static_cast(m_height); 203 | m_slider_top = new_position_ratio * m_info.size(); 204 | 205 | if (m_slider_top <= 0) 206 | m_slider_top = 0; 207 | } 208 | 209 | else 210 | m_dragging = false; 211 | } 212 | } 213 | 214 | //--------------------------------------------------------- 215 | void fgui::listbox::tooltip() { 216 | 217 | // get the current position of the window 218 | fgui::point a = fgui::element::get_absolute_position(); 219 | 220 | // get the window style 221 | auto style = handler::get_style(); 222 | 223 | // get the control area 224 | fgui::rect area = { a.x, a.y, m_width, m_height }; 225 | 226 | if (m_tooltip.length() > 0) { 227 | 228 | // tooltip text size 229 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 230 | 231 | // cursor position 232 | fgui::point cursor = fgui::input_system::mouse_position(); 233 | 234 | if (fgui::input_system::mouse_in_area(area)) { 235 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.listbox.at(3))); 236 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 237 | } 238 | } 239 | } 240 | 241 | //--------------------------------------------------------- 242 | void fgui::listbox::save(nlohmann::json& json_module) { 243 | 244 | json_module[m_identificator.data()] = m_index; 245 | } 246 | 247 | //--------------------------------------------------------- 248 | void fgui::listbox::load(const std::string_view file_name) { 249 | 250 | nlohmann::json json_module; 251 | 252 | // open the file 253 | std::ifstream file_to_load(file_name.data(), std::ifstream::binary); 254 | 255 | if (file_to_load.fail()) // todo: make an exception handler 256 | return; 257 | 258 | // read config file 259 | json_module = nlohmann::json::parse(file_to_load); 260 | 261 | // change the element state to match the one stored on file 262 | m_index = json_module[m_identificator.data()]; 263 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/listbox.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | // framework includes 12 | #include "element.hh" 13 | 14 | namespace fgui { 15 | 16 | class listbox : public fgui::element { 17 | public: 18 | listbox(); 19 | 20 | // draw the element 21 | void draw(); 22 | 23 | // add a new item in the element 24 | inline void add_item(const std::string_view item, const int &value = 0) noexcept { 25 | 26 | m_info.push_back( {item, value } ); 27 | } 28 | 29 | // returns the name of the selected item 30 | inline std::string_view get_item() const noexcept { 31 | 32 | return m_info[m_index].item; 33 | } 34 | 35 | // get the index of the selected item 36 | inline int get_index() const noexcept { 37 | 38 | return m_index; 39 | } 40 | 41 | // get the value of a selected item 42 | inline int get_value() const noexcept { 43 | 44 | return m_info[m_index].value; 45 | } 46 | 47 | // set a pre-selected item for the element 48 | inline void set_index(const int &index) noexcept { 49 | 50 | m_index = index; 51 | } 52 | 53 | // handle keyboard and mouse input 54 | void handle_input(); 55 | 56 | // handle the element updates 57 | void update(); 58 | 59 | // element tooltip 60 | void tooltip(); 61 | 62 | // save the element state 63 | void save(nlohmann::json& json_module); 64 | 65 | // load the element state 66 | void load(const std::string_view file_name); 67 | private: 68 | 69 | int m_index; 70 | bool m_dragging; 71 | int m_slider_top; 72 | int m_item_height; 73 | std::vector m_info; 74 | }; 75 | } 76 | -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/multibox.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "multibox.hh" 7 | #include "container.hh" 8 | #include "../handler/handler.hh" 9 | #include "../dependencies/color.hh" 10 | #include "../dependencies/aliases.hh" 11 | 12 | fgui::multibox::multibox() { 13 | 14 | fgui::multibox::m_width = 150; 15 | fgui::multibox::m_height = 20; 16 | fgui::multibox::m_opened = false; 17 | fgui::multibox::m_item_height = 20; 18 | fgui::multibox::m_title = "multibox"; 19 | fgui::multibox::m_font = fgui::element::m_font; 20 | fgui::multibox::m_original_height = fgui::multibox::m_height; 21 | fgui::multibox::m_type = static_cast(fgui::detail::element_type::MULTIBOX); 22 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE) | static_cast(fgui::detail::element_flags::FOCUSABLE) | static_cast(fgui::detail::element_flags::SAVABLE); 23 | } 24 | 25 | void fgui::multibox::draw() { 26 | 27 | // get the current position of the window 28 | fgui::point a = fgui::element::get_absolute_position(); 29 | 30 | // get the window style 31 | auto style = handler::get_style(); 32 | 33 | // get the control area 34 | fgui::rect area = { a.x, a.y, m_width, m_original_height }; 35 | 36 | // multibox title text size 37 | fgui::dimension text_size = fgui::render.get_text_size(fgui::multibox::get_font(), m_title); 38 | 39 | // multibox body 40 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.multibox.at(0))); 41 | 42 | if (fgui::input_system::mouse_in_area(area)) 43 | fgui::render.outline(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.multibox.at(3))); 44 | else 45 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.multibox.at(2))); 46 | 47 | fgui::render.colored_gradient(area.left + 3, area.top + 3, area.right - 6, area.bottom - 6, fgui::color(style.multibox.at(1)), fgui::color(style.multibox.at(2)), false); 48 | 49 | // lines 50 | fgui::render.rect(area.left + (area.right - 20), (area.top + (area.bottom / 2) - 3) + 1, 10, 1, fgui::color(style.text.at(0))); 51 | fgui::render.rect(area.left + (area.right - 20), (area.top + (area.bottom / 2) - 3) + 3, 10, 1, fgui::color(style.text.at(0))); 52 | fgui::render.rect(area.left + (area.right - 20), (area.top + (area.bottom / 2) - 3) + 5, 10, 1, fgui::color(style.text.at(0))); 53 | 54 | // multibox label 55 | fgui::render.text(area.left, (area.top - text_size.height) - 2, fgui::color(style.text.at(0)), fgui::multibox::get_font(), m_title); 56 | 57 | // this needs to be initialized as a empty string 58 | std::string format = ""; 59 | 60 | for (std::size_t i = 0; i < m_info.size(); ++i) { 61 | 62 | bool format_length = format.length() < 20; 63 | bool first_item = format.length() <= 0; 64 | 65 | if (m_info[i].checked && format_length) { 66 | 67 | if (!m_info[i].item.empty()) { 68 | 69 | if (!first_item) 70 | format.append(", "); 71 | 72 | format.append(m_info[i].item); 73 | } 74 | } 75 | 76 | else if (!format_length) { 77 | format.append("..."); 78 | break; 79 | } 80 | } 81 | 82 | if (format.length() <= 0) 83 | format += "None"; 84 | 85 | // draw the current selected items 86 | fgui::render.text(area.left + 5, area.top + (area.bottom / 2) - (text_size.height / 2), fgui::color(style.text.at(0)), fgui::multibox::get_font(), format); 87 | 88 | // if the drop down list is opened 89 | if (m_opened) { 90 | 91 | // draw the item list 92 | fgui::render.outline(area.left - 1, (area.top + 23) - 1, area.right + 2, (m_item_height * m_info.size()) + 2, fgui::color(style.multibox.at(3))); 93 | fgui::render.rect(area.left, area.top + 23, area.right, (m_item_height * m_info.size()), fgui::color(style.multibox.at(1))); 94 | 95 | for (std::size_t i = 0; i < m_info.size(); i++) { 96 | 97 | // get the item area on the drop down list 98 | fgui::rect item_area = { a.x, a.y + 23 + (m_item_height * static_cast(i)), m_width, m_item_height }; 99 | 100 | // if the user starts hovering a item or selects one 101 | if (fgui::input_system::mouse_in_area(item_area) || m_info[i].checked) { 102 | 103 | if (m_info[i].item.length() > 20) 104 | fgui::render.text(item_area.left + 5, item_area.top + 5, fgui::color(style.multibox.at(3)), fgui::multibox::get_font(), m_info[i].item.replace(m_info[i].item.begin() + 20, m_info[i].item.end(), "...")); 105 | else 106 | fgui::render.text(item_area.left + 5, item_area.top + 5, fgui::color(style.multibox.at(3)), fgui::multibox::get_font(), m_info[i].item); 107 | } 108 | 109 | else if (!fgui::input_system::mouse_in_area(item_area) || !m_info[i].checked) { 110 | 111 | if (m_info[i].item.length() > 20) 112 | fgui::render.text(item_area.left + 5, item_area.top + 5, fgui::color(style.text.at(0)), fgui::multibox::get_font(), m_info[i].item.replace(m_info[i].item.begin() + 20, m_info[i].item.end(), "...")); 113 | else 114 | fgui::render.text(item_area.left + 5, item_area.top + 5, fgui::color(style.text.at(0)), fgui::multibox::get_font(), m_info[i].item); 115 | } 116 | } 117 | } 118 | } 119 | 120 | //--------------------------------------------------------- 121 | void fgui::multibox::handle_input() { 122 | 123 | // get the current position of the window 124 | fgui::point a = fgui::element::get_absolute_position(); 125 | 126 | // get the control area 127 | fgui::rect area = { a.x, a.y, m_width, m_original_height }; 128 | 129 | // open the drop down list 130 | if (fgui::input_system::mouse_in_area(area)) 131 | m_opened = !m_opened; 132 | 133 | // if the dropdown list is opened 134 | if (m_opened) { 135 | 136 | if (!fgui::input_system::mouse_in_area(area)) { 137 | 138 | if (m_info.size() > 0) { 139 | 140 | for (std::size_t i = 0; i < m_info.size(); i++) { 141 | 142 | // item area 143 | fgui::rect item_area = { a.x, a.y + 23 + (m_item_height * static_cast(i)), m_width, m_item_height }; 144 | 145 | // select an item 146 | if (fgui::input_system::mouse_in_area(item_area)) 147 | m_info[i].checked = !m_info[i].checked; 148 | } 149 | } 150 | } 151 | } 152 | } 153 | 154 | //--------------------------------------------------------- 155 | void fgui::multibox::update() { 156 | 157 | // get the current position of the window 158 | fgui::point a = fgui::element::get_absolute_position(); 159 | 160 | // get the control opened area 161 | fgui::rect opened_area = { a.x, (a.y + 23), m_width, m_height }; 162 | 163 | if (m_opened) { 164 | m_height = opened_area.top + (m_item_height * m_info.size()); 165 | 166 | if (!fgui::input_system::mouse_in_area(opened_area)) { 167 | 168 | if (fgui::input_system::key_press(fgui::external::MOUSE_LEFT)) 169 | m_opened = false; 170 | } 171 | } 172 | 173 | else if (!m_opened) { 174 | 175 | // restore height 176 | m_height = m_original_height; 177 | } 178 | } 179 | 180 | //--------------------------------------------------------- 181 | void fgui::multibox::tooltip() { 182 | 183 | // get the current position of the window 184 | fgui::point a = fgui::element::get_absolute_position(); 185 | 186 | // get the window style 187 | auto style = handler::get_style(); 188 | 189 | // get the control area 190 | fgui::rect area = { a.x, a.y, m_width, m_height }; 191 | 192 | if (m_tooltip.length() > 0) { 193 | 194 | // tooltip text size 195 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 196 | 197 | // cursor position 198 | fgui::point cursor = fgui::input_system::mouse_position(); 199 | 200 | if (fgui::input_system::mouse_in_area(area)) { 201 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.multibox.at(3))); 202 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 203 | } 204 | } 205 | } 206 | 207 | //--------------------------------------------------------- 208 | void fgui::multibox::save(nlohmann::json& json_module) { 209 | 210 | for (std::size_t i = 0; i < m_info.size(); i++) 211 | json_module[m_identificator.data()][m_info[i].item] = m_info[i].checked; 212 | } 213 | 214 | //--------------------------------------------------------- 215 | void fgui::multibox::load(const std::string_view file_name) { 216 | 217 | nlohmann::json json_module; 218 | 219 | // open the file 220 | std::ifstream file_to_load(file_name.data(), std::ifstream::binary); 221 | 222 | if (file_to_load.fail()) // todo: make an exception handler 223 | return; 224 | 225 | // read config file 226 | json_module = nlohmann::json::parse(file_to_load); 227 | 228 | // change the element state to match the one stored on file 229 | for (std::size_t i = 0; i < m_info.size(); i++) 230 | set_selected(i, json_module[m_identificator.data()][m_info[i].item]); 231 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/multibox.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | // framework includes 12 | #include "element.hh" 13 | 14 | namespace fgui { 15 | 16 | class multibox : public fgui::element { 17 | public: 18 | multibox(); 19 | 20 | // draw the element 21 | void draw(); 22 | 23 | // add a new item in the element 24 | inline void add_item(const std::string_view item, const fgui::state &state) noexcept { 25 | 26 | m_info.push_back( { item, state } ); 27 | } 28 | 29 | // select a specific item at a given position 30 | inline void set_selected(const int &index, const bool &onoff) noexcept { 31 | 32 | m_info[index].checked = onoff; 33 | } 34 | 35 | // get the item selected at a given position 36 | inline bool get_selected(int index) const noexcept { 37 | 38 | return m_info[index].checked; 39 | } 40 | 41 | // sets a custom state for the multibox (if the dropdown list is opened or not) 42 | inline void set_state(const fgui::state &state) noexcept { 43 | 44 | m_opened = state; 45 | } 46 | 47 | // returns the current state of the multibox (if the dropdown list is opened or not) 48 | inline fgui::state get_state() const noexcept { 49 | 50 | return m_opened; 51 | } 52 | 53 | // handle keyboard and mouse input 54 | void handle_input(); 55 | 56 | // handle the element updates 57 | void update(); 58 | 59 | // element tooltip 60 | void tooltip(); 61 | 62 | // save the element state 63 | void save(nlohmann::json& json_module); 64 | 65 | // load the element state 66 | void load(const std::string_view file_name); 67 | private: 68 | 69 | int m_item_height; 70 | fgui::state m_opened; 71 | std::vector m_info; 72 | }; 73 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/slider.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "slider.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | #include "../dependencies/aliases.hh" 10 | 11 | fgui::slider::slider() { 12 | 13 | fgui::slider::m_width = 150; 14 | fgui::slider::m_height = 10; 15 | fgui::slider::m_value = 0.f; 16 | fgui::slider::m_dragging = false; 17 | fgui::slider::m_min_text = ""; 18 | fgui::slider::m_max_text = ""; 19 | fgui::slider::m_title = "slider"; 20 | fgui::slider::m_font = fgui::element::m_font; 21 | fgui::slider::m_type = static_cast(fgui::detail::element_type::SLIDER); 22 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE) | static_cast(fgui::detail::element_flags::SAVABLE); 23 | } 24 | 25 | //--------------------------------------------------------- 26 | void fgui::slider::draw() { 27 | 28 | // get the current position of the window 29 | fgui::point a = fgui::element::get_absolute_position(); 30 | 31 | // get the window style 32 | auto style = handler::get_style(); 33 | 34 | // get the control area 35 | fgui::rect area = { a.x, a.y, m_width, m_height }; 36 | 37 | // ratio 38 | float ratio = (m_value - m_min) / (m_max - m_min); 39 | float location = ratio * m_width; 40 | 41 | // custom value 42 | static std::string_view custom_value = ""; 43 | 44 | // slider title text size 45 | fgui::dimension text_size = fgui::render.get_text_size(fgui::slider::get_font(), m_min_text); 46 | 47 | // slider body 48 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.slider.at(0))); 49 | fgui::render.colored_gradient(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.slider.at(1)), fgui::color(style.slider.at(2)), false); 50 | 51 | if (fgui::input_system::mouse_in_area(area) || m_dragging) 52 | fgui::render.outline(area.left + 1, area.top + 1, location - 2, area.bottom - 2, fgui::color(style.slider.at(3))); 53 | else 54 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.slider.at(2), 150)); 55 | 56 | fgui::render.colored_gradient(area.left + 2, area.top + 2, location - 4, area.bottom - 4, fgui::color(style.slider.at(3)), fgui::color(style.slider.at(4)), false); 57 | 58 | // slider label 59 | fgui::render.text(area.left, (area.top - text_size.height) - 2, fgui::color(style.text.at(0)), fgui::slider::get_font(), m_title); 60 | 61 | // slider value text size 62 | fgui::dimension slider_value_text_size = fgui::render.get_text_size(fgui::slider::get_font(), custom_value); 63 | 64 | // slider custom value 65 | if (!m_min_text.empty()) { 66 | 67 | if (m_value <= m_min) 68 | custom_value = m_min_text; 69 | } 70 | 71 | else 72 | custom_value = std::to_string(static_cast(m_value)); 73 | 74 | if (!m_max_text.empty()) { 75 | 76 | if (m_value >= m_max) 77 | custom_value = m_max_text; 78 | } 79 | 80 | else 81 | custom_value = std::to_string(static_cast(m_value)); 82 | 83 | if (m_value != m_min && m_value != m_max) 84 | custom_value = std::to_string(static_cast(m_value)); 85 | 86 | // slider value 87 | fgui::render.text((area.left + area.right) - slider_value_text_size.width, (area.top - text_size.height) - 2, fgui::color(style.text.at(0)), fgui::slider::get_font(), custom_value); 88 | } 89 | 90 | //--------------------------------------------------------- 91 | void fgui::slider::handle_input() { 92 | 93 | // get the current position of the window 94 | fgui::point a = fgui::element::get_absolute_position(); 95 | 96 | // get the control area 97 | fgui::rect area = { a.x, a.y, m_width, m_height }; 98 | 99 | // enable the drag state if the user is clicking inside the scrollbar area 100 | if (fgui::input_system::mouse_in_area(area)) 101 | m_dragging = true; 102 | } 103 | 104 | //--------------------------------------------------------- 105 | void fgui::slider::update() { 106 | 107 | // get the current position of the window 108 | fgui::point a = fgui::element::get_absolute_position(); 109 | 110 | // get the control area 111 | fgui::rect area = { a.x, a.y, m_width, m_height }; 112 | 113 | if (m_dragging) { 114 | 115 | if (fgui::input_system::key_held(fgui::external::MOUSE_LEFT)) { 116 | 117 | // cursor position 118 | fgui::point cursor = fgui::input_system::mouse_position(); 119 | 120 | float new_x = 0.f; 121 | float ratio = 0.f; 122 | 123 | new_x = cursor.x - a.x - 1.f; 124 | 125 | if (new_x <= m_min) 126 | new_x = m_min; 127 | 128 | else if (new_x >= m_width) 129 | new_x = m_width; 130 | 131 | ratio = new_x / float(m_width); 132 | 133 | m_value = m_min + (m_max - m_min) * ratio; 134 | } 135 | 136 | else 137 | m_dragging = false; 138 | } 139 | 140 | // check if the mouse is on the control area 141 | if (fgui::input_system::mouse_in_area(area)) { 142 | 143 | // now check if we are holding one of these keys 144 | if (fgui::input_system::key_held(fgui::external::KEY_RIGHT) || fgui::input_system::key_held(fgui::external::KEY_UP)) { 145 | m_value += 1.f; 146 | 147 | if (m_value >= m_max) { 148 | m_value = m_max; 149 | return; 150 | } 151 | 152 | else if (m_value <= m_min) { 153 | m_value = m_min; 154 | return; 155 | } 156 | } 157 | 158 | else if (fgui::input_system::key_held(fgui::external::KEY_LEFT) || fgui::input_system::key_held(fgui::external::KEY_DOWN)) { 159 | m_value -= 1.f; 160 | 161 | if (m_value >= m_max) { 162 | m_value = m_max; 163 | return; 164 | } 165 | 166 | else if (m_value <= m_min) { 167 | m_value = m_min; 168 | return; 169 | } 170 | } 171 | 172 | } 173 | } 174 | 175 | //--------------------------------------------------------- 176 | void fgui::slider::tooltip() { 177 | 178 | // get the current position of the window 179 | fgui::point a = fgui::element::get_absolute_position(); 180 | 181 | // get the window style 182 | auto style = handler::get_style(); 183 | 184 | // get the control area 185 | fgui::rect area = { a.x, a.y, m_width, m_height }; 186 | 187 | if (m_tooltip.length() > 0) { 188 | 189 | // tooltip text size 190 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 191 | 192 | // cursor position 193 | fgui::point cursor = fgui::input_system::mouse_position(); 194 | 195 | if (fgui::input_system::mouse_in_area(area)) { 196 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.slider.at(3))); 197 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 198 | } 199 | } 200 | } 201 | 202 | //--------------------------------------------------------- 203 | void fgui::slider::save(nlohmann::json& json_module) { 204 | 205 | json_module[m_identificator.data()] = m_value; 206 | } 207 | 208 | //--------------------------------------------------------- 209 | void fgui::slider::load(const std::string_view file_name) { 210 | 211 | nlohmann::json json_module; 212 | 213 | // open the file 214 | std::ifstream file_to_load(file_name.data(), std::ifstream::binary); 215 | 216 | if (file_to_load.fail()) // todo: make an exception handler 217 | return; 218 | 219 | // read config file 220 | json_module = nlohmann::json::parse(file_to_load); 221 | 222 | // change the element state to match the one stored on file 223 | m_value = json_module[m_identificator.data()]; 224 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/slider.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | // framework includes 12 | #include "element.hh" 13 | 14 | namespace fgui { 15 | 16 | class slider : public fgui::element { 17 | public: 18 | slider(); 19 | 20 | // draw the element 21 | void draw(); 22 | 23 | // set a custom value for the element 24 | inline void set_value(const float &value) noexcept { 25 | 26 | m_value = value; 27 | } 28 | 29 | // get the current value of the element 30 | inline float get_value() const noexcept { 31 | 32 | return m_value; 33 | } 34 | 35 | // set the boundaries of the element 36 | inline void set_boundaries(const float &min, const float &max) noexcept { 37 | 38 | m_min = min; 39 | m_max = max; 40 | } 41 | 42 | // set the min and max custom text 43 | inline void set_boundaries_text(const std::string_view min_text, const std::string_view max_text) noexcept { 44 | 45 | m_min_text = min_text; 46 | m_max_text = max_text; 47 | } 48 | 49 | // handle keyboard and mouse input 50 | void handle_input(); 51 | 52 | // handle the element updates 53 | void update(); 54 | 55 | // element tooltip 56 | void tooltip(); 57 | 58 | // save the element state 59 | void save(nlohmann::json& json_module); 60 | 61 | // load the element state 62 | void load(const std::string_view file_name); 63 | private: 64 | 65 | float m_value; 66 | bool m_dragging; 67 | float m_min, m_max; 68 | std::string m_min_text, m_max_text; 69 | }; 70 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/spinner.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "spinner.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | #include "../dependencies/aliases.hh" 10 | 11 | fgui::spinner::spinner() { 12 | 13 | fgui::spinner::m_width = 50; 14 | fgui::spinner::m_height = 30; 15 | fgui::spinner::m_title = "spinner"; 16 | fgui::spinner::m_value = 0; 17 | fgui::spinner::m_min = 0; 18 | fgui::spinner::m_max = 0; 19 | fgui::spinner::m_holding_ticks = 00; 20 | fgui::spinner::m_normal_click = false; 21 | fgui::spinner::m_holding_click = false; 22 | fgui::spinner::m_font = fgui::element::m_font; 23 | fgui::spinner::m_type = static_cast(fgui::detail::element_type::SPINNER); 24 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE) | static_cast(fgui::detail::element_flags::SAVABLE); 25 | } 26 | 27 | //--------------------------------------------------------- 28 | void fgui::spinner::draw() { 29 | 30 | // get the current position of the window 31 | fgui::point a = fgui::element::get_absolute_position(); 32 | 33 | // get the window style 34 | auto style = handler::get_style(); 35 | 36 | // get the control area 37 | fgui::rect area = { a.x, a.y, m_width, m_height }; 38 | 39 | // spinner title text size 40 | fgui::dimension text_size = fgui::render.get_text_size(fgui::spinner::get_font(), m_title); 41 | 42 | // spinner body 43 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.spinner.at(0))); 44 | 45 | if (fgui::input_system::mouse_in_area(area)) 46 | fgui::render.outline(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.spinner.at(3))); 47 | else 48 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.spinner.at(2))); 49 | 50 | fgui::render.rect(area.left + 3, area.top + 3, area.right - 6, area.bottom - 6, fgui::color(style.spinner.at(1))); 51 | fgui::render.rect((area.left + 3) + (area.right - 15), area.top + 3, 15 - 5, area.bottom - 6, fgui::color(style.spinner.at(2))); 52 | 53 | // keybinder label 54 | fgui::render.text(area.left, (area.top - text_size.height) - 2, fgui::color(style.text.at(0)), fgui::spinner::get_font(), m_title); 55 | 56 | // spinner value text size 57 | fgui::dimension value_text_size = fgui::render.get_text_size(fgui::spinner::get_font(), std::to_string(m_value)); 58 | 59 | // current value 60 | fgui::render.text(area.left + 10, area.top + (area.bottom / 2) - (value_text_size.height / 2), fgui::color(style.text.at(0)), fgui::spinner::get_font(), std::to_string(m_value)); 61 | 62 | // up and down button area 63 | fgui::rect up_button_area = { a.x + (m_width - 6), a.y + 5, 10, 10 }; 64 | fgui::rect down_button_area = { a.x + (m_width - 6), a.y + 15, 10, 10 }; 65 | 66 | fgui::color up_color = { 0, 0, 0 }; 67 | fgui::color down_color = { 0, 0, 0 }; 68 | 69 | if (fgui::input_system::mouse_in_area(up_button_area)) 70 | up_color = { style.spinner.at(3) }; 71 | else 72 | up_color = { style.text.at(0) }; 73 | 74 | if (fgui::input_system::mouse_in_area(down_button_area)) 75 | down_color = { style.spinner.at(3) }; 76 | else 77 | down_color = { style.text.at(0) }; 78 | 79 | // up down 80 | fgui::render.rect(up_button_area.left - 3, up_button_area.top + (up_button_area.bottom / 2), 5, 1, fgui::color(up_color)); 81 | fgui::render.rect(up_button_area.left - 2, up_button_area.top + (up_button_area.bottom / 2) - 1, 3, 1, fgui::color(up_color)); 82 | fgui::render.rect(up_button_area.left - 1, up_button_area.top + (up_button_area.bottom / 2) - 2, 1, 1, fgui::color(up_color)); 83 | 84 | // down button 85 | fgui::render.rect(down_button_area.left - 3, down_button_area.top + (down_button_area.bottom / 2), 5, 1, fgui::color(down_color)); 86 | fgui::render.rect(down_button_area.left - 2, down_button_area.top + (down_button_area.bottom / 2) + 1, 3, 1, fgui::color(down_color)); 87 | fgui::render.rect(down_button_area.left - 1, down_button_area.top + (down_button_area.bottom / 2) + 2, 1, 1, fgui::color(down_color)); 88 | } 89 | 90 | //--------------------------------------------------------- 91 | void fgui::spinner::handle_input() { 92 | 93 | // get the current position of the window 94 | fgui::point a = fgui::element::get_absolute_position(); 95 | 96 | // up and down button area 97 | fgui::rect up_button_area = { a.x + (m_width - 15), a.y, 15, 10 }; 98 | fgui::rect down_button_area = { a.x + (m_width - 15), a.y + 15, 15, 10 }; 99 | 100 | // reset click state 101 | m_normal_click = true; 102 | 103 | if (fgui::input_system::mouse_in_area(up_button_area)) { 104 | m_value += 1; 105 | 106 | // tell the spinner that this was a normal click 107 | m_normal_click = false; 108 | } 109 | 110 | else if (fgui::input_system::mouse_in_area(down_button_area)) { 111 | m_value -= 1; 112 | 113 | // tell the spinner that this was a normal click 114 | m_normal_click = false; 115 | } 116 | } 117 | 118 | //--------------------------------------------------------- 119 | void fgui::spinner::update() { 120 | 121 | // get the current position of the window 122 | fgui::point a = fgui::element::get_absolute_position(); 123 | 124 | // up and down button area 125 | fgui::rect up_button_area = { a.x + (m_width - 15), a.y, 15, 10 }; 126 | fgui::rect down_button_area = { a.x + (m_width - 15), a.y + 15, 15, 10 }; 127 | 128 | if (fgui::input_system::mouse_in_area(up_button_area)) { 129 | 130 | // check if the user is holding MOUSE 1 131 | if (fgui::input_system::key_held(fgui::external::MOUSE_LEFT) && !m_normal_click) { 132 | 133 | m_holding_ticks += 1; 134 | 135 | if (m_holding_ticks > 128) { 136 | m_value += 1; 137 | 138 | // tell the spinner that this wasn't a normal click 139 | m_holding_click = true; 140 | } 141 | } 142 | 143 | else // reset ticks 144 | m_holding_ticks = 0; 145 | } 146 | 147 | else if (fgui::input_system::mouse_in_area(down_button_area) && !m_normal_click) { 148 | 149 | // check if the user is holding MOUSE 1 150 | if (fgui::input_system::key_held(fgui::external::MOUSE_LEFT)) { 151 | 152 | m_holding_ticks += 1; 153 | 154 | if (m_holding_ticks > 128) { 155 | m_value -= 1; 156 | 157 | // tell the spinner that this wasn't a normal click 158 | m_holding_click = true; 159 | } 160 | } 161 | 162 | else // reset ticks 163 | m_holding_ticks = 0; 164 | } 165 | 166 | else // reset ticks 167 | m_holding_ticks = 0; 168 | 169 | if (m_value <= m_min) { 170 | m_value = m_min; 171 | return; 172 | } 173 | 174 | else if (m_value > m_max) 175 | m_value = m_min; 176 | 177 | // reset click state 178 | m_holding_click = false; 179 | 180 | } 181 | 182 | //--------------------------------------------------------- 183 | void fgui::spinner::tooltip() { 184 | 185 | // get the current position of the window 186 | fgui::point a = fgui::element::get_absolute_position(); 187 | 188 | // get the window style 189 | auto style = handler::get_style(); 190 | 191 | // get the control area 192 | fgui::rect area = { a.x, a.y, m_width, m_height }; 193 | 194 | if (m_tooltip.length() > 0) { 195 | 196 | // tooltip text size 197 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 198 | 199 | // cursor position 200 | fgui::point cursor = fgui::input_system::mouse_position(); 201 | 202 | if (fgui::input_system::mouse_in_area(area)) { 203 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.spinner.at(3))); 204 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 205 | } 206 | } 207 | } 208 | 209 | //--------------------------------------------------------- 210 | void fgui::spinner::save(nlohmann::json& json_module) { 211 | 212 | json_module[m_identificator.data()] = m_value; 213 | } 214 | 215 | //--------------------------------------------------------- 216 | void fgui::spinner::load(const std::string_view file_name) { 217 | 218 | nlohmann::json json_module; 219 | 220 | // open the file 221 | std::ifstream file_to_load(file_name.data(), std::ifstream::binary); 222 | 223 | if (file_to_load.fail()) // todo: make an exception handler 224 | return; 225 | 226 | // read config file 227 | json_module = nlohmann::json::parse(file_to_load); 228 | 229 | // change the element value to match the one stored on file 230 | m_value = json_module[m_identificator.data()]; 231 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/spinner.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | 10 | // framework includes 11 | #include "element.hh" 12 | 13 | namespace fgui { 14 | 15 | class spinner : public fgui::element { 16 | public: 17 | spinner(); 18 | 19 | // draw the element 20 | void draw(); 21 | 22 | // set a custom value for the element 23 | inline void set_value(const int &value) noexcept { 24 | 25 | m_value = value; 26 | } 27 | 28 | // get the current value of the element 29 | inline int get_value() const noexcept { 30 | 31 | return m_value; 32 | } 33 | 34 | // set the boundaries of the element 35 | void set_boundaries(const int &min, const int &max) noexcept { 36 | 37 | m_min = min; 38 | m_max = max; 39 | } 40 | 41 | // handle keyboard and mouse input 42 | void handle_input(); 43 | 44 | // handle the element updates 45 | void update(); 46 | 47 | // element tooltip 48 | void tooltip(); 49 | 50 | // save the element state 51 | void save(nlohmann::json& json_module); 52 | 53 | // load the element state 54 | void load(const std::string_view file_name); 55 | private: 56 | int m_value; 57 | int m_min, m_max; 58 | int m_holding_ticks; 59 | fgui::state m_normal_click; 60 | fgui::state m_holding_click; 61 | }; 62 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/tabs.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "tabs.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | #include "../dependencies/aliases.hh" 10 | 11 | fgui::tabs::tabs() { 12 | 13 | fgui::tabs::m_width = 150; 14 | fgui::tabs::m_height = 30; 15 | fgui::tabs::m_title = "tab"; 16 | fgui::tabs::m_index = 0; 17 | fgui::tabs::set_style = fgui::tabs_layout::HORIZONTAL; 18 | fgui::tabs::m_font = fgui::element::m_font; 19 | fgui::tabs::m_type = static_cast(fgui::detail::element_type::TAB); 20 | fgui::tabs::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE); 21 | } 22 | 23 | //--------------------------------------------------------- 24 | void fgui::tabs::draw() { 25 | 26 | if (m_info.empty()) 27 | return; 28 | 29 | // get the current position of the window 30 | fgui::point a = fgui::element::get_absolute_position(); 31 | 32 | // calculate the size of the tab buttons 33 | static int tab_button_size = 0; 34 | static int tab_button_height = 0; 35 | 36 | // get correct values for drawing depending on tabs_layout 37 | if (m_parent_element) 38 | { 39 | if (fgui::tabs::set_style == fgui::tabs_layout::VERTICAL) 40 | tab_button_size = (m_parent_element->get_size().width - 12) / 6; //CHANGE DENOMINATOR DEPENDING ON YOUR MENU WIDTH TO FIT ACCORDINGLY 41 | else 42 | tab_button_size = (m_parent_element->get_size().width - 12) / m_info.size(); 43 | tab_button_height = (m_parent_element->get_size().height - 32) / m_info.size(); 44 | } 45 | else 46 | tab_button_size = m_width / m_info.size(); 47 | 48 | // get the window style 49 | auto style = handler::get_style(); 50 | 51 | 52 | for (std::size_t i = 0; i < m_info.size(); i++) { 53 | 54 | // tab title text size 55 | fgui::dimension text_size = fgui::render.get_text_size(fgui::tabs::get_font(), m_info[i].item); 56 | 57 | // tab area 58 | fgui::rect area = { 0, 0, 0, 0 }; 59 | 60 | if (fgui::tabs::set_style == fgui::tabs_layout::HORIZONTAL) 61 | area = { a.x + (static_cast(i) * tab_button_size), a.y, tab_button_size, m_height }; 62 | else if (fgui::tabs::set_style == fgui::tabs_layout::VERTICAL) 63 | area = { a.x, a.y + (tab_button_height * static_cast(i)), tab_button_size, tab_button_height }; 64 | 65 | // get the window style 66 | auto style = handler::get_style(); 67 | 68 | // tab button body 69 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.tabs.at(1))); 70 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.tabs.at(0), 200)); 71 | 72 | if (m_index == i) 73 | fgui::render.colored_gradient(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.tabs.at(3)), fgui::color(style.tabs.at(4)), false); 74 | else 75 | fgui::render.colored_gradient(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.tabs.at(2)), fgui::color(style.tabs.at(1)), false); 76 | 77 | // tab button label 78 | fgui::render.text(area.left + (area.right / 2) - (text_size.width / 2), area.top + (area.bottom / 2) - (text_size.height / 2), fgui::color(style.text.at(3)), fgui::tabs::get_font(), m_info[i].item); 79 | } 80 | } 81 | 82 | //--------------------------------------------------------- 83 | void fgui::tabs::handle_input() {} 84 | 85 | //--------------------------------------------------------- 86 | void fgui::tabs::update() { 87 | 88 | // get the current position of the window 89 | fgui::point a = fgui::element::get_absolute_position(); 90 | 91 | // calculate the size of the tab buttons 92 | int tab_button_size = 0; 93 | int tab_button_height = 0; 94 | 95 | // get correct values for input depending on tabs_layout 96 | if (m_parent_element) 97 | { 98 | if (fgui::tabs::set_style == fgui::tabs_layout::VERTICAL) 99 | tab_button_size = (m_parent_element->get_size().width - 12) / 6; //CHANGE DENOMINATOR DEPENDING ON YOUR MENU WIDTH TO FIT ACCORDINGLY 100 | else 101 | tab_button_size = (m_parent_element->get_size().width - 12) / m_info.size(); 102 | tab_button_height = (m_parent_element->get_size().height - 32) / m_info.size(); 103 | } 104 | else 105 | tab_button_size = m_width / m_info.size(); 106 | 107 | for (std::size_t i = 0; i < m_info.size(); i++) { 108 | 109 | // tab area 110 | fgui::rect area = { 0, 0, 0, 0 }; 111 | 112 | if (fgui::tabs::set_style == fgui::tabs_layout::HORIZONTAL) 113 | area = { a.x + (static_cast(i)* tab_button_size), a.y, tab_button_size, m_height }; 114 | else if (fgui::tabs::set_style == fgui::tabs_layout::VERTICAL) 115 | area = { a.x, a.y + (tab_button_height * static_cast(i)), tab_button_size, tab_button_height }; 116 | 117 | // select the tab 118 | if (fgui::input_system::key_press(fgui::external::MOUSE_LEFT)) { 119 | 120 | if (fgui::input_system::mouse_in_area(area)) 121 | m_index = i; 122 | } 123 | } 124 | } 125 | 126 | //--------------------------------------------------------- 127 | void fgui::tabs::tooltip() {} 128 | 129 | //--------------------------------------------------------- 130 | void fgui::tabs::save(nlohmann::json& json_module) {} 131 | 132 | //--------------------------------------------------------- 133 | void fgui::tabs::load(const std::string_view file_name) {} -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/tabs.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | // framework includes 12 | #include "element.hh" 13 | 14 | namespace fgui { 15 | 16 | class tabs : public fgui::element { 17 | public: 18 | tabs(); 19 | 20 | // draw the element 21 | void draw(); 22 | 23 | // adds a new tab 24 | inline void add_tab(const std::string_view tab_name) noexcept { 25 | 26 | m_info.push_back( { tab_name } ); 27 | } 28 | 29 | // get the current tab selected 30 | inline int get_index() const noexcept { 31 | 32 | return m_index; 33 | } 34 | 35 | fgui::tabs_layout set_style = fgui::tabs_layout::HORIZONTAL; 36 | 37 | // handle keyboard and mouse input 38 | void handle_input(); 39 | 40 | // handle the element updates 41 | void update(); 42 | 43 | // element tooltip 44 | void tooltip(); 45 | 46 | // save the element state 47 | void save(nlohmann::json& json_module); 48 | 49 | // load the element state 50 | void load(const std::string_view file_name); 51 | private: 52 | 53 | int m_index; 54 | std::vector m_info; 55 | }; 56 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/textbox.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "textbox.hh" 7 | #include "../handler/handler.hh" 8 | #include "../dependencies/color.hh" 9 | #include "../dependencies/aliases.hh" 10 | 11 | fgui::textbox::textbox() { 12 | 13 | fgui::textbox::m_width = 150; 14 | fgui::textbox::m_height = 20; 15 | fgui::textbox::m_title = "textbox"; 16 | fgui::textbox::m_text_input_pos = 0; 17 | fgui::textbox::m_text_length = 32; 18 | fgui::textbox::m_text = "sample text"; 19 | fgui::textbox::m_is_getting_key = false; 20 | fgui::textbox::m_text_selected = false; 21 | fgui::textbox::m_holding_ticks = 0; 22 | fgui::textbox::m_font = fgui::element::m_font; 23 | fgui::textbox::m_type = static_cast(fgui::detail::element_type::TEXTBOX); 24 | fgui::textbox::m_text_flag = static_cast(fgui::text_flags::NORMAL); 25 | fgui::element::m_flags = static_cast(fgui::detail::element_flags::DRAWABLE) | static_cast(fgui::detail::element_flags::CLICKABLE) | static_cast(fgui::detail::element_flags::SAVABLE); 26 | } 27 | 28 | //--------------------------------------------------------- 29 | void fgui::textbox::draw() { 30 | 31 | // get the current position of the window 32 | fgui::point a = fgui::element::get_absolute_position(); 33 | 34 | // get the window style 35 | auto style = handler::get_style(); 36 | 37 | // get the control area 38 | fgui::rect area = { a.x, a.y, m_width, m_height }; 39 | 40 | // textbox title text size 41 | fgui::dimension text_size = fgui::render.get_text_size(fgui::textbox::get_font(), m_title); 42 | 43 | // textbox body 44 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.textbox.at(0))); 45 | 46 | if (fgui::input_system::mouse_in_area(area) || m_is_getting_key) 47 | fgui::render.outline(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.textbox.at(3))); 48 | else 49 | fgui::render.outline(area.left + 1, area.top + 1, area.right - 2, area.bottom - 2, fgui::color(style.textbox.at(2))); 50 | 51 | fgui::render.colored_gradient(area.left + 3, area.top + 3, area.right - 6, area.bottom - 6, fgui::color(style.textbox.at(1)), fgui::color(style.textbox.at(2)), false); 52 | 53 | // textbox label 54 | fgui::render.text(area.left, (area.top - text_size.height) - 2, fgui::color(style.text.at(0)), fgui::textbox::get_font(), m_title); 55 | 56 | if (m_text.empty()) 57 | return; 58 | 59 | // typed text size 60 | fgui::dimension typed_text_size = fgui::render.get_text_size(fgui::textbox::get_font(), m_text); 61 | 62 | // draw custom text 63 | if (m_text_flag & static_cast(fgui::text_flags::SECRET)) 64 | fgui::render.text(area.left + 5, area.top + (area.bottom / 2) - (typed_text_size.height / 2) - 1, fgui::color(style.text.at(0)), fgui::textbox::get_font(), std::string(m_text.length(), '*')); 65 | 66 | else if (m_text_flag & static_cast(fgui::text_flags::UPPERCASE)) { 67 | 68 | // transform the text into uppercase 69 | std::string upper_case_display = m_text; 70 | std::transform(upper_case_display.begin(), upper_case_display.end(),upper_case_display.begin(), ::toupper); 71 | 72 | fgui::render.text(area.left + 5, area.top + (area.bottom / 2) - (typed_text_size.height / 2) - 1, fgui::color(style.text.at(0)), fgui::textbox::get_font(), upper_case_display); 73 | } 74 | else 75 | fgui::render.text(area.left + 5, area.top + (area.bottom / 2) - (typed_text_size.height / 2) - 1, fgui::color(style.text.at(0)), fgui::textbox::get_font(), m_text); 76 | 77 | // if the textbox is ready to receive text 78 | if (m_is_getting_key) { 79 | 80 | // caret 81 | std::string caret = m_text; 82 | caret.erase(m_text_input_pos, caret.size()); 83 | 84 | // caret size 85 | fgui::dimension caret_text_size = fgui::render.get_text_size(fgui::textbox::get_font(), caret); 86 | 87 | // draw the caret 88 | fgui::render.line(area.left + caret_text_size.width + 7, area.top + 5, area.left + caret_text_size.width + 7, (area.top + area.bottom) - 5, fgui::color(style.text.at(0))); 89 | } 90 | 91 | // selected text rectangle 92 | if (m_text_selected) 93 | fgui::render.rect(area.left + 5, area.top + (area.bottom / 2) - (typed_text_size.height / 2) - 1, typed_text_size.width, typed_text_size.height, fgui::color(style.textbox.at(3), 100)); 94 | } 95 | 96 | //--------------------------------------------------------- 97 | void fgui::textbox::handle_input() { 98 | 99 | // get the current position of the window 100 | fgui::point a = fgui::element::get_absolute_position(); 101 | 102 | // get the control area 103 | fgui::rect area = { a.x, a.y, m_width, m_height }; 104 | 105 | if (fgui::input_system::mouse_in_area(area)) 106 | m_is_getting_key = !m_is_getting_key; 107 | } 108 | 109 | //--------------------------------------------------------- 110 | void fgui::textbox::update() { 111 | 112 | if (m_is_getting_key) { 113 | 114 | for (std::size_t i = 0; i < 256 /* KEY_MAX */; i++) { 115 | 116 | if (!fgui::input_system::key_press(i)) 117 | continue; 118 | 119 | // input 120 | // NOTE: If your keys are wrong, you might want to check this. 121 | // m_win_api_text = winapi 122 | // m_iinput_system_text = valve's inputsystem 123 | std::string input = m_iinput_system_text[i].data(); 124 | 125 | // clear text if the user types something while the text is selected 126 | if (m_text_selected) { 127 | 128 | if (fgui::input_system::key_press(i)) { 129 | m_text.clear(); 130 | m_text_input_pos = 0; 131 | m_text_selected = false; 132 | } 133 | } 134 | 135 | // if the user press ESC or ENTER, stop the control from receiving input 136 | if (i == fgui::external::KEY_ESCAPE || i == fgui::external::KEY_ENTER) 137 | m_is_getting_key = false; 138 | 139 | // make the text in upper case if shift is pressed 140 | if (fgui::input_system::key_held(fgui::external::KEY_LSHIFT) || fgui::input_system::key_held(fgui::external::KEY_RSHIFT) || m_text_flag & static_cast(fgui::text_flags::UPPERCASE)) 141 | std::transform(input.begin(), input.end(), input.begin(), ::toupper); 142 | 143 | if (input.length() == 1 && m_text.length() < m_text_length) { 144 | m_text.insert(m_text_input_pos, input); 145 | m_text_input_pos++; 146 | } 147 | } 148 | 149 | if (m_text.length() > 0) { 150 | 151 | // erase text if the user press backspace 152 | if (fgui::input_system::key_press(fgui::external::KEY_BACKSPACE) && m_text_input_pos > 0 && !m_text_selected) { 153 | 154 | m_text_input_pos--; 155 | m_text.erase(m_text_input_pos, 1); 156 | 157 | } 158 | 159 | // erase text if the user holds backspace 160 | else if (fgui::input_system::key_held(fgui::external::KEY_BACKSPACE) && m_text_input_pos > 0 && !m_text_selected) { 161 | 162 | m_holding_ticks += 1; 163 | 164 | if (m_holding_ticks > 64) { 165 | m_text_input_pos--; 166 | m_text.erase(m_text_input_pos, 1); 167 | } 168 | } 169 | 170 | else if (fgui::input_system::key_held(fgui::external::KEY_LCONTROL) && fgui::input_system::key_press(fgui::external::KEY_A)) { 171 | 172 | m_text_selected = true; 173 | 174 | if (m_text_selected) { 175 | 176 | if (fgui::input_system::key_press(fgui::external::KEY_BACKSPACE) && m_text_input_pos > 0) { 177 | m_text.clear(); 178 | m_text_input_pos = 0; 179 | m_text_selected = false; 180 | } 181 | } 182 | } 183 | 184 | else if (fgui::input_system::key_press(fgui::external::KEY_DELETE)) { 185 | m_text.clear(); 186 | m_text_input_pos = 0; 187 | } 188 | 189 | else // reset ticks 190 | m_holding_ticks = 0; 191 | 192 | // change the current input position 193 | if (fgui::input_system::key_press(fgui::external::KEY_LEFT) && m_text_input_pos > 0) 194 | m_text_input_pos--; 195 | 196 | if (fgui::input_system::key_press(fgui::external::KEY_RIGHT) && m_text_input_pos < m_text.length()) 197 | m_text_input_pos++; 198 | } 199 | } 200 | } 201 | 202 | //--------------------------------------------------------- 203 | void fgui::textbox::tooltip() { 204 | 205 | // get the current position of the window 206 | fgui::point a = fgui::element::get_absolute_position(); 207 | 208 | // get the window style 209 | auto style = handler::get_style(); 210 | 211 | // get the control area 212 | fgui::rect area = { a.x, a.y, m_width, m_height }; 213 | 214 | if (m_tooltip.length() > 0) { 215 | 216 | // tooltip text size 217 | fgui::dimension tooltip_text_size = fgui::render.get_text_size(fgui::element::get_font(), m_tooltip); 218 | 219 | // cursor position 220 | fgui::point cursor = fgui::input_system::mouse_position(); 221 | 222 | if (fgui::input_system::mouse_in_area(area)) { 223 | fgui::render.rect(cursor.x + 10, cursor.y + 20, tooltip_text_size.width + 10, 20, fgui::color(style.textbox.at(3))); 224 | fgui::render.text(cursor.x + 10 + ((tooltip_text_size.width + 10) / 2) - (tooltip_text_size.width / 2), cursor.y + 20 + (20 / 2) - (tooltip_text_size.height / 2), fgui::color(style.text.at(3)), fgui::element::get_font(), m_tooltip); 225 | } 226 | } 227 | } 228 | 229 | //--------------------------------------------------------- 230 | void fgui::textbox::save(nlohmann::json& json_module) { 231 | 232 | json_module[m_identificator.data()] = m_text; 233 | } 234 | 235 | //--------------------------------------------------------- 236 | void fgui::textbox::load(const std::string_view file_name) { 237 | 238 | nlohmann::json json_module; 239 | 240 | // open the file 241 | std::ifstream file_to_load(file_name.data(), std::ifstream::binary); 242 | 243 | if (file_to_load.fail()) // todo: make an exception handler 244 | return; 245 | 246 | // read config file 247 | json_module = nlohmann::json::parse(file_to_load); 248 | 249 | // change the element state to match the one stored on file 250 | m_text = json_module[m_identificator.data()]; 251 | } 252 | -------------------------------------------------------------------------------- /ApexLegends/FGUI/controls/textbox.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | // framework includes 12 | #include "element.hh" 13 | 14 | namespace fgui { 15 | 16 | /* 17 | * NOTE 1: If you don't want to use winapi keycodes, you will need to manually map your keys here. 18 | * 19 | * 20 | * NOTE 2: By default the framework comes with 2 "maps". One for the IInputSystem (Source Engine) and 21 | * another for the Windows Virtual Keycodes (GetAsyncKeyState). 22 | * 23 | * (If you don't plan on using anything other than "VK keys", you should be fine.) 24 | */ 25 | 26 | // win api 27 | constexpr std::string_view m_winapi_text[] = { "", "", "", "", "", "", "", 28 | "", "", "", "", "", "", "", "", "", "", 29 | "", "", "", "", "", "", "", "", "", "", 30 | "", "", "", "", "", " ", "", "", "", "", "", 31 | "", "", "", "", "", "", "", "", "", "", "0", "1", 32 | "2", "3", "4", "5", "6", "7", "8", "9", "", "", "", "", "", "", 33 | "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", 34 | "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", 35 | "z", "", "", "", "", "", "0", "1", "2", "3", 36 | "4", "5", "6", "7", "8", "9", "*", "+", "_", 37 | "-", ".", "/", "", "", "", "", "", "", "", "", "", 38 | "", "", "", "", "", "", "", "", "", "", 39 | "", "", "", "", "", "", "", "", "", "", "", "", "", 40 | "", "", "", "", "", "", "", "", "", "", "", "", 41 | "", "", "", "", "", "", "", "", "", 42 | "", "", "", "", "", "", "", "", "", "", "", "", "", 43 | "", "", "", "", "", "", "", "", ";", "+", ",", "-", ".", 44 | "/?", "~", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 45 | "", "", "", "", "", "", "", "", "", "", "", "[{", "\\|", "}]", "'\"", 46 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 47 | "", "", "", "", "", "", "", "", "", "", "", "" 48 | }; 49 | 50 | // iinput system 51 | constexpr std::string_view m_iinput_system_text[] = { "'", "0", "1", "2", "3", "4", "5", "6", "7", 52 | "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", 53 | "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", 54 | "s", "t", "u", "v", "w", "x", "y", "z", "0", 55 | "1", "2", "3", "4", "5", "6", "7", 56 | "8", "9", "/", "*", "-", "+", "", ",", ".", 57 | "[", "ç", "~", "´", ",", ".", ";", "]", "-", "=", 58 | "", " ", "", "", "", "", "", 59 | "", "", "", "", "", "", "", 60 | "", "", "", "", "", "", 61 | "", "", "", "", "", "", "", 62 | "", "", "", "", "", "", "", "", 63 | "", "", "", "", "", "", "", "", 64 | "", "", "", "", "", "", "" 65 | }; 66 | 67 | class textbox : public fgui::element { 68 | public: 69 | textbox(); 70 | 71 | // draw the element 72 | void draw(); 73 | 74 | // set a custom text 75 | inline void set_text(const std::string_view text) noexcept { 76 | 77 | m_text = text; 78 | } 79 | 80 | // get the state of the textbox (if the user is typing or not) 81 | inline fgui::state get_state() const noexcept { 82 | 83 | return m_is_getting_key; 84 | } 85 | 86 | // set the text flag (type) 87 | void set_text_flag(const fgui::text_flags &flags) noexcept { 88 | 89 | m_text_flag |= static_cast(flags); 90 | } 91 | 92 | // get text flags 93 | inline bool get_text_flag(const fgui::text_flags &flags) const noexcept { 94 | 95 | if (m_text_flag & static_cast(flags)) 96 | return true; 97 | 98 | return false; 99 | } 100 | 101 | // set the max text length 102 | inline void set_length(const int &text_length) noexcept { 103 | 104 | m_text_length = text_length; 105 | } 106 | 107 | // get the current text typed on the textbox 108 | inline std::string get_text() const noexcept { 109 | 110 | return m_text; 111 | } 112 | 113 | // handle keyboard and mouse input 114 | void handle_input(); 115 | 116 | // handle the element updates 117 | void update(); 118 | 119 | // element tooltip 120 | void tooltip(); 121 | 122 | // save the element state 123 | void save(nlohmann::json& json_module); 124 | 125 | // load the element state 126 | void load(const std::string_view file_name); 127 | private: 128 | 129 | int m_text_flag; 130 | int m_text_length; 131 | std::string m_text; 132 | int m_holding_ticks; 133 | int m_text_input_pos; 134 | bool m_text_selected; 135 | fgui::state m_is_getting_key; 136 | }; 137 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/dependencies/aliases.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | // framework includes 12 | #include "color.hh" 13 | #include "definitions.hh" 14 | 15 | namespace fgui { 16 | 17 | /* 18 | * Thanks to @zxvnme for giving me the idea to use this. 19 | * 20 | * 21 | * NOTE1: If you don't have a function to match the template, you don't have to do anything. 22 | * (Same thing goes for the input aliases.) 23 | * 24 | * 25 | * NOTE2: You can use WINAPI functions for the input system too. 26 | */ 27 | 28 | // render manager aliases 29 | using create_font_alias = std::add_pointer_t; // only call this once! 30 | using screen_size_alias = std::add_pointer_t; 31 | using text_size_alias = std::add_pointer_t; 32 | using rectangle_alias = std::add_pointer_t; 33 | using colored_gradient_alias = std::add_pointer_t; 34 | using outline_alias = std::add_pointer_t; 35 | using line_alias = std::add_pointer_t; 36 | using polygon_alias = std::add_pointer_t; 37 | using text_alias = std::add_pointer_t; 38 | using alpha_alias = std::add_pointer_t; 39 | using circle_alias = std::add_pointer_t; 40 | using texture_alias = std::add_pointer_t; 41 | using gradient_alias = std::add_pointer_t; 42 | using rounded_rectangle_alias = std::add_pointer_t; 43 | 44 | struct rendering_functions { 45 | 46 | // 47 | // Most of this stuff you will be able to do with a rectangle. 48 | // 49 | 50 | create_font_alias create_font; // * 51 | screen_size_alias get_screen_size; // * 52 | text_size_alias get_text_size; // * 53 | rectangle_alias rect; // * 54 | outline_alias outline; // * 55 | line_alias line; // * 56 | polygon_alias polygon; 57 | text_alias text; // * 58 | circle_alias circle; 59 | texture_alias texture; 60 | gradient_alias gradient; 61 | colored_gradient_alias colored_gradient; // * 62 | rounded_rectangle_alias rounded_rect; 63 | alpha_alias alpha; /**/ 64 | // ^ (The framework is using this function, but it's not necessary.) 65 | 66 | }; inline rendering_functions render; 67 | 68 | // input system aliases 69 | using mouse_position_alias = std::add_pointer_t; 70 | using key_held_alias = std::add_pointer_t; 71 | using scroll_delta_alias = std::add_pointer_t; 72 | 73 | struct input_functions { 74 | 75 | mouse_position_alias get_mouse_position; // * - GetCursorPos 76 | key_held_alias get_key_state; // * - GetAsyncKeyState 77 | 78 | scroll_delta_alias get_scroll_delta; // * - On WNDPROC hook, scroll_delta = (wParam / 120) 79 | // just make a function that returns "scroll_delta". 80 | // NOTE: This function is not necessary. If you remove it, you won't be able to scroll with your mouse wheel. 81 | 82 | }; inline input_functions input; 83 | } 84 | -------------------------------------------------------------------------------- /ApexLegends/FGUI/dependencies/color.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | #include 11 | 12 | namespace fgui { 13 | 14 | class color { 15 | public: 16 | 17 | color(int red, int green, int blue, int alpha = 255) { 18 | m_red = std::clamp(red, 0, 255); 19 | m_green = std::clamp(green, 0, 255); 20 | m_blue = std::clamp(blue, 0, 255); 21 | m_alpha = std::clamp(alpha, 0, 255); 22 | } 23 | 24 | color(fgui::color color, int alpha) { 25 | m_red = std::clamp(color.m_red, 0, 255); 26 | m_green = std::clamp(color.m_green, 0, 255); 27 | m_blue = std::clamp(color.m_blue, 0, 255); 28 | m_alpha = std::clamp(alpha, 0, 255); 29 | } 30 | 31 | static fgui::color hsb_to_rgb(float hue, float saturation, float brightness, int alpha = 255) { 32 | 33 | hue = std::clamp(hue, 0.f, 1.f); 34 | saturation = std::clamp(saturation, 0.f, 1.f); 35 | brightness = std::clamp(brightness, 0.f, 1.f); 36 | 37 | float h = (hue == 1.f) ? 0.f : (hue * 6.f); 38 | float f = h - static_cast(h); 39 | float p = brightness * (1.f - saturation); 40 | float q = brightness * (1.f - saturation * f); 41 | float t = brightness * (1.f - (saturation * (1.f - f))); 42 | 43 | if (h < 1) 44 | return fgui::color(brightness * 255, t * 255, p * 255, alpha); 45 | 46 | else if (h < 2) 47 | return fgui::color(q * 255, brightness * 255, p * 255, alpha); 48 | 49 | else if (h < 3) 50 | return fgui::color(p * 255, brightness * 255, t * 255, alpha); 51 | 52 | else if (h < 4) 53 | return fgui::color(p * 255, q * 255, brightness * 255, alpha); 54 | 55 | else if (h < 5) 56 | return fgui::color(t * 255, p * 255, brightness * 255, alpha); 57 | 58 | else 59 | return fgui::color(brightness * 255, p * 255, q * 255, alpha); 60 | 61 | } 62 | 63 | static float get_hue(fgui::color color) { 64 | 65 | float r = (std::clamp(color.m_red, 0, 255) / 255.f); 66 | float g = (std::clamp(color.m_green, 0, 255) / 255.f); 67 | float b = (std::clamp(color.m_blue, 0, 255) / 255.f); 68 | float max = std::fmaxf(std::fmaxf(r, g), b); 69 | float min = std::fminf(std::fminf(r, g), b); 70 | float delta = max - min; 71 | 72 | if (delta != 0) { 73 | 74 | float hue; 75 | 76 | if (r == max) 77 | hue = (g - b) / delta; 78 | 79 | else { 80 | 81 | if (g == max) 82 | hue = 2 + (b - r) / delta; 83 | else 84 | hue = 4 + (r - g) / delta; 85 | } 86 | 87 | hue *= 60; 88 | 89 | if (hue < 0) 90 | hue += 360; 91 | 92 | return hue / 360; 93 | } 94 | 95 | else 96 | return 0; 97 | } 98 | 99 | static fgui::color interpolate(fgui::color color1, fgui::color color2, float ttt) { 100 | 101 | float r = (std::clamp(color1.m_red, 0, 255) * (1.f - ttt) + std::clamp(color2.m_red, 0, 255)* ttt); 102 | float g = (std::clamp(color1.m_green, 0, 255) * (1.f - ttt) + std::clamp(color2.m_green, 0, 255) * ttt); 103 | float b = (std::clamp(color1.m_blue, 0, 255) * (1.f - ttt) + std::clamp(color2.m_blue, 0, 255) * ttt); 104 | float a = (std::clamp(color1.m_alpha, 0, 255) * (1.f - ttt) + std::clamp(color2.m_alpha, 0, 255) * ttt); 105 | 106 | return fgui::color(r, g, b, a); 107 | } 108 | 109 | unsigned char m_red, m_green, m_blue, m_alpha; 110 | }; 111 | } 112 | -------------------------------------------------------------------------------- /ApexLegends/FGUI/dependencies/definitions.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | #ifdef _WIN32 12 | #define NOMINMAX 13 | #include 14 | #endif 15 | 16 | namespace fgui { 17 | 18 | // handlers 19 | typedef int key; 20 | typedef int delta; 21 | typedef bool state; 22 | typedef unsigned long font; 23 | 24 | // you are not supposed to edit the contents of this namespace. but if you know what you are doing, go ahead. 25 | namespace detail { 26 | 27 | enum struct element_type : int { 28 | BUTTON = 1, 29 | CHECKBOX, 30 | COLORPICKER, 31 | COMBOBOX, 32 | KEYBINDER, 33 | LABEL, 34 | LISTBOX, 35 | MULTIBOX, 36 | SLIDER, 37 | TEXTBOX, 38 | COLORLIST, 39 | CONTAINER, 40 | TAB, 41 | SPINNER 42 | }; 43 | 44 | enum struct element_flags : int { 45 | DRAWABLE = (1 << 0), 46 | CLICKABLE = (1 << 1), 47 | FOCUSABLE = (1 << 2), 48 | SAVABLE = (1 << 3) 49 | }; 50 | 51 | struct item_info { 52 | 53 | item_info() { item = ""; checked = false; value = 0; }; 54 | item_info(const std::string_view _item, int _value) : item(_item), value(_value) {} 55 | item_info(const std::string_view _item, bool _state) : item(_item), checked(_state) {} 56 | item_info(const std::string_view _item) : item(_item) {} 57 | item_info(const std::vector &_items) : items(_items) {} 58 | 59 | int value = 0; 60 | bool checked = false; 61 | std::string item = ""; 62 | std::vector items; 63 | }; 64 | } 65 | 66 | // everything inside this namespace usually depends of an external library to work. 67 | namespace external { 68 | 69 | // this will only work if you are using IInputSystem (Source Engine) 70 | enum key_code { 71 | KEY_0 = 0x1, 72 | KEY_1 = 0x2, 73 | KEY_2 = 0x3, 74 | KEY_3 = 0x4, 75 | KEY_4 = 0x5, 76 | KEY_5 = 0x6, 77 | KEY_6 = 0x7, 78 | KEY_7 = 0x8, 79 | KEY_8 = 0x9, 80 | KEY_9 = 0xA, 81 | KEY_A = 0xB, 82 | KEY_B = 0xC, 83 | KEY_C = 0xD, 84 | KEY_D = 0xE, 85 | KEY_E = 0xF, 86 | KEY_F = 0x10, 87 | KEY_G = 0x11, 88 | KEY_H = 0x12, 89 | KEY_I = 0x13, 90 | KEY_J = 0x14, 91 | KEY_K = 0x15, 92 | KEY_L = 0x16, 93 | KEY_M = 0x17, 94 | KEY_N = 0x18, 95 | KEY_O = 0x19, 96 | KEY_P = 0x1A, 97 | KEY_Q = 0x1B, 98 | KEY_R = 0x1C, 99 | KEY_S = 0x1D, 100 | KEY_T = 0x1E, 101 | KEY_U = 0x1F, 102 | KEY_V = 0x20, 103 | KEY_W = 0x21, 104 | KEY_X = 0x22, 105 | KEY_Y = 0x23, 106 | KEY_Z = 0x24, 107 | KEY_PAD_0 = 0x25, 108 | KEY_PAD_1 = 0x26, 109 | KEY_PAD_2 = 0x27, 110 | KEY_PAD_3 = 0x28, 111 | KEY_PAD_4 = 0x29, 112 | KEY_PAD_5 = 0x2A, 113 | KEY_PAD_6 = 0x2B, 114 | KEY_PAD_7 = 0x2C, 115 | KEY_PAD_8 = 0x2D, 116 | KEY_PAD_9 = 0x2E, 117 | KEY_PAD_DIVIDE = 0x2F, 118 | KEY_PAD_MULTIPLY = 0x30, 119 | KEY_PAD_MINUS = 0x31, 120 | KEY_PAD_PLUS = 0x32, 121 | KEY_PAD_ENTER = 0x33, 122 | KEY_PAD_DECIMAL = 0x34, 123 | KEY_LBRACKET = 0x35, 124 | KEY_RBRACKET = 0x36, 125 | KEY_SEMICOLON = 0x37, 126 | KEY_APOSTROPHE = 0x38, 127 | KEY_BACKQUOTE = 0x39, 128 | KEY_COMMA = 0x3A, 129 | KEY_PERIOD = 0x3B, 130 | KEY_SLASH = 0x3C, 131 | KEY_BACKSLASH = 0x3D, 132 | KEY_MINUS = 0x3E, 133 | KEY_EQUAL = 0x3F, 134 | KEY_ENTER = 0x40, 135 | KEY_SPACE = 0x41, 136 | KEY_BACKSPACE = 0x42, 137 | KEY_TAB = 0x43, 138 | KEY_CAPSLOCK = 0x44, 139 | KEY_NUMLOCK = 0x45, 140 | KEY_ESCAPE = 0x46, 141 | KEY_SCROLLLOCK = 0x47, 142 | KEY_INSERT = 0x48, 143 | KEY_DELETE = 0x49, 144 | KEY_HOME = 0x4A, 145 | KEY_END = 0x4B, 146 | KEY_PAGEUP = 0x4C, 147 | KEY_PAGEDOWN = 0x4D, 148 | KEY_BREAK = 0x4E, 149 | KEY_LSHIFT = 0x4F, 150 | KEY_RSHIFT = 0x50, 151 | KEY_LALT = 0x51, 152 | KEY_RALT = 0x52, 153 | KEY_LCONTROL = 0x53, 154 | KEY_RCONTROL = 0x54, 155 | KEY_LWIN = 0x55, 156 | KEY_RWIN = 0x56, 157 | KEY_APP = 0x57, 158 | KEY_UP = 0x58, 159 | KEY_LEFT = 0x59, 160 | KEY_DOWN = 0x5A, 161 | KEY_RIGHT = 0x5B, 162 | KEY_F1 = 0x5C, 163 | KEY_F2 = 0x5D, 164 | KEY_F3 = 0x5E, 165 | KEY_F4 = 0x5F, 166 | KEY_F5 = 0x60, 167 | KEY_F6 = 0x61, 168 | KEY_F7 = 0x62, 169 | KEY_F8 = 0x63, 170 | KEY_F9 = 0x64, 171 | KEY_F10 = 0x65, 172 | KEY_F11 = 0x66, 173 | KEY_F12 = 0x67, 174 | KEY_CAPSLOCKTOGGLE = 0x68, 175 | KEY_NUMLOCKTOGGLE = 0x69, 176 | KEY_SCROLLLOCKTOGGLE = 0x6A, 177 | MOUSE_LEFT = 0x6B, 178 | MOUSE_RIGHT = 0x6C, 179 | MOUSE_MIDDLE = 0x6D, 180 | MOUSE_4 = 0x6E, 181 | MOUSE_5 = 0x6F, 182 | }; 183 | 184 | // this will only work if you're using ISurface (Source Engine) 185 | enum font_flags { 186 | ITALIC = 0x001, 187 | UNDERLINE = 0x002, 188 | STRIKEOUT = 0x004, 189 | SYMBOL = 0x008, 190 | ANTIALIAS = 0x010, 191 | GAUSSIANBLUR = 0x020, 192 | ROTARY = 0x040, 193 | SHADOW = 0x080, 194 | ADDITIVE = 0x100, 195 | OUTLINE = 0x200, 196 | CUSTOM = 0x400, 197 | BITMAP = 0x800, 198 | }; 199 | } 200 | 201 | // public enums 202 | enum struct cursor_type : int { 203 | NONE = 0, 204 | ARROW, 205 | IBEAM, 206 | HAND, 207 | PIPETTE, 208 | RESIZE, 209 | MOVE 210 | }; 211 | 212 | enum struct input_state : int { 213 | LOCKED = 1, 214 | UNLOCKED, 215 | }; 216 | 217 | enum struct label_type : int { 218 | TEXT = 1, 219 | LINK, 220 | BANNER, 221 | SEPARATOR, 222 | COLORED, 223 | }; 224 | 225 | enum struct text_flags : int { 226 | SECRET = (1 << 0), 227 | UPPERCASE = (1 << 1), 228 | NORMAL = (1 << 2) 229 | }; 230 | 231 | enum struct animation_type : int { 232 | LINEAR = 1, 233 | FADE 234 | }; 235 | 236 | enum struct tabs_layout : int { 237 | HORIZONTAL = 1, 238 | VERTICAL 239 | }; 240 | 241 | // public structs 242 | typedef struct element_area { 243 | int left; 244 | int top; 245 | int right; 246 | int bottom; 247 | } rect; 248 | 249 | typedef struct element_dimension { 250 | int width; 251 | int height; 252 | } dimension; 253 | 254 | typedef struct point_2d { 255 | int x = 0; 256 | int y = 0; 257 | 258 | point_2d() = default; 259 | point_2d(int _x, int _y) : x(_x), y(_y) {} 260 | 261 | // operators 262 | point_2d operator+(const point_2d& rhs) { 263 | return point_2d(x + rhs.x, y + rhs.y); 264 | } 265 | 266 | point_2d operator-(const point_2d& rhs) { 267 | return point_2d(x - rhs.x, y - rhs.y); 268 | } 269 | 270 | point_2d operator/(const int& rhs) { 271 | return point_2d(x / rhs, y / rhs); 272 | } 273 | 274 | point_2d operator*(const int& rhs) { 275 | return point_2d(x * rhs, y * rhs); 276 | } 277 | 278 | int& operator[](std::size_t index) { 279 | return *reinterpret_cast(this + index); 280 | } 281 | 282 | } point; 283 | 284 | typedef struct precision_point_2d { 285 | float x = 0.f; 286 | float y = 0.f; 287 | 288 | precision_point_2d() = default; 289 | precision_point_2d(float _x, float _y) : x(_x), y(_y) {} 290 | 291 | // operators 292 | precision_point_2d operator+(const point_2d& rhs) { 293 | return precision_point_2d(x + rhs.x, y + rhs.y); 294 | } 295 | 296 | precision_point_2d operator-(const point_2d& rhs) { 297 | return precision_point_2d(x - rhs.x, y - rhs.y); 298 | } 299 | 300 | precision_point_2d operator/(const int& rhs) { 301 | return precision_point_2d(x / rhs, y / rhs); 302 | } 303 | 304 | precision_point_2d operator*(const int& rhs) { 305 | return precision_point_2d(x * rhs, y * rhs); 306 | } 307 | 308 | float& operator[](std::size_t index) { 309 | return *reinterpret_cast(this + index); 310 | } 311 | 312 | } precision_point; 313 | 314 | typedef struct vertex_2d { 315 | 316 | fgui::precision_point position = { 0.f, 0.f }; 317 | fgui::precision_point text_coord = { 0.f, 0.f }; 318 | 319 | vertex_2d() = default; 320 | vertex_2d(const fgui::precision_point& _position, const fgui::precision_point& _text_coord = { 0.f, 0.f }) : position(_position), text_coord(_text_coord) {} 321 | 322 | } vertex; 323 | 324 | typedef struct element_font_info { 325 | std::string_view family; 326 | int size; 327 | int flags; 328 | bool bold; 329 | } element_font; 330 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/dependencies/input.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | 11 | // framework includes 12 | #include "aliases.hh" 13 | #include "definitions.hh" 14 | 15 | namespace fgui { 16 | 17 | // you are not suposed to edit the contents of this namespace, unless you know what you are doing. 18 | namespace detail { 19 | 20 | inline fgui::rect m_hovered_area; 21 | inline fgui::point m_mouse_position, m_mouse_position_delta; 22 | inline fgui::delta m_scroll_wheel_delta; 23 | inline std::array m_key_state, m_old_key_state; 24 | } 25 | 26 | namespace input_system { 27 | 28 | inline void listen() noexcept { 29 | 30 | static fgui::point last_known_position = {0, 0}; 31 | 32 | // copy new keys (current being pressed) to old keys (already pressed) 33 | std::copy(fgui::detail::m_key_state.begin(), fgui::detail::m_key_state.end(), fgui::detail::m_old_key_state.begin()); 34 | 35 | for (std::size_t i = 0; i < 256 /* KEY_MAX */; i++) 36 | fgui::detail::m_key_state.at(i) = fgui::input.get_key_state(i); 37 | 38 | // get mouse position 39 | fgui::detail::m_mouse_position = fgui::input.get_mouse_position(); 40 | 41 | // calculate the cursor delta 42 | fgui::detail::m_mouse_position_delta = {(fgui::detail::m_mouse_position.x - last_known_position.x), (fgui::detail::m_mouse_position.y - last_known_position.y)}; 43 | 44 | // get scroll message delta 45 | fgui::detail::m_scroll_wheel_delta = fgui::input.get_scroll_delta(); 46 | 47 | // get last known cursor position 48 | last_known_position = fgui::detail::m_mouse_position; 49 | } 50 | 51 | // check if a specific key is being held 52 | inline fgui::state key_held(const fgui::key &key) noexcept { 53 | 54 | return (fgui::detail::m_key_state[key]); 55 | } 56 | 57 | // check if a specific key is pressed (clicked) 58 | inline const fgui::state key_press(const fgui::key &key) noexcept { 59 | 60 | return (fgui::detail::m_key_state[key] && !fgui::detail::m_old_key_state[key]); 61 | } 62 | 63 | // check if a specific key was released 64 | inline const fgui::state key_released(const fgui::key &key) noexcept { 65 | 66 | return (!fgui::detail::m_key_state[key] && fgui::detail::m_old_key_state[key]); 67 | } 68 | 69 | // check if the mouse cursor is on a certain area 70 | inline const fgui::state mouse_in_area(const fgui::rect &area) noexcept { 71 | return (fgui::detail::m_mouse_position.x > area.left && fgui::detail::m_mouse_position.y > area.top && fgui::detail::m_mouse_position.x < area.left + area.right &&fgui::detail:: m_mouse_position.y < area.top + area.bottom); 72 | } 73 | 74 | inline const fgui::state mouse_in_area(const int &x, const int &y, const int &w, const int &h) noexcept { 75 | return (fgui::detail::m_mouse_position.x > x && fgui::detail::m_mouse_position.y > y && fgui::detail::m_mouse_position.x < x + w && fgui::detail::m_mouse_position.y < y + h); 76 | } 77 | 78 | // get scroll message delta (up, down) 79 | inline const fgui::delta scroll_delta() noexcept { 80 | 81 | return fgui::detail::m_scroll_wheel_delta; 82 | } 83 | 84 | // get cursor position 85 | inline const fgui::point mouse_position() noexcept { 86 | 87 | return fgui::detail::m_mouse_position; 88 | } 89 | 90 | // get cursor position delta 91 | inline const fgui::point mouse_position_delta() noexcept { 92 | 93 | return fgui::detail::m_mouse_position_delta; 94 | } 95 | }; 96 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/handler/handler.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "handler.hh" 7 | #include "../dependencies/aliases.hh" 8 | 9 | void fgui::handler::render_window() { 10 | 11 | if (m_input_state == fgui::input_state::UNLOCKED) { 12 | 13 | // listen for input 14 | fgui::input_system::listen(); 15 | } 16 | 17 | // bindings 18 | for (std::pair>& binded_key : m_binds) { 19 | 20 | // toggle the window on and off 21 | if (fgui::input_system::key_press(binded_key.first)) 22 | binded_key.second->set_state(!binded_key.second->get_state()); 23 | } 24 | 25 | // check if the notifications are registered first 26 | if (m_notifications) { 27 | 28 | // draw and update notifications 29 | m_notifications->update(); 30 | m_notifications->draw(); 31 | m_notifications->handle_input(); 32 | } 33 | 34 | for (std::shared_ptr window : m_windows) { 35 | 36 | if (window->get_state()) { 37 | 38 | // draw and update 39 | window->update(); 40 | window->draw(); 41 | 42 | // draw cursors 43 | draw_cursors(); 44 | } 45 | } 46 | } 47 | 48 | //--------------------------------------------------------- 49 | static void fgui::handler::draw_cursors() { 50 | 51 | static fgui::point cursor = { 0, 0 }; 52 | 53 | // get the window style 54 | fgui::style style = get_style(); 55 | 56 | if (m_input_state == fgui::input_state::UNLOCKED) { 57 | 58 | // get the cursor position 59 | cursor = fgui::input_system::mouse_position(); 60 | } 61 | 62 | // 63 | // cursor types 64 | // 65 | switch (m_cursor_type) { 66 | 67 | case fgui::cursor_type::ARROW: { 68 | 69 | fgui::render.rect(cursor.x + 1, cursor.y, 1, 17, fgui::color(style.cursor.at(1))); 70 | 71 | for (std::size_t i = 0; i < 11; i++) 72 | fgui::render.rect(cursor.x + 2 + i, cursor.y + 1 + i, 1, 1, fgui::color(style.cursor.at(1))); 73 | 74 | fgui::render.rect(cursor.x + 8, cursor.y + 12, 5, 1, fgui::color(style.cursor.at(1))); 75 | fgui::render.rect(cursor.x + 8, cursor.y + 13, 1, 1, fgui::color(style.cursor.at(1))); 76 | fgui::render.rect(cursor.x + 9, cursor.y + 14, 1, 2, fgui::color(style.cursor.at(1))); 77 | fgui::render.rect(cursor.x + 10, cursor.y + 16, 1, 2, fgui::color(style.cursor.at(1))); 78 | fgui::render.rect(cursor.x + 8, cursor.y + 18, 2, 1, fgui::color(style.cursor.at(1))); 79 | fgui::render.rect(cursor.x + 7, cursor.y + 16, 1, 2, fgui::color(style.cursor.at(1))); 80 | fgui::render.rect(cursor.x + 6, cursor.y + 14, 1, 2, fgui::color(style.cursor.at(1))); 81 | fgui::render.rect(cursor.x + 5, cursor.y + 13, 1, 1, fgui::color(style.cursor.at(1))); 82 | fgui::render.rect(cursor.x + 4, cursor.y + 14, 1, 1, fgui::color(style.cursor.at(1))); 83 | fgui::render.rect(cursor.x + 3, cursor.y + 15, 1, 1, fgui::color(style.cursor.at(1))); 84 | fgui::render.rect(cursor.x + 2, cursor.y + 16, 1, 1, fgui::color(style.cursor.at(1))); 85 | 86 | for (std::size_t i = 0; i < 4; i++) 87 | fgui::render.rect(cursor.x + 2 + i, cursor.y + 2 + i, 1, 14 - (i * 2), fgui::color(style.cursor.at(0))); 88 | 89 | fgui::render.rect(cursor.x + 6, cursor.y + 6, 1, 8, fgui::color(style.cursor.at(0))); 90 | fgui::render.rect(cursor.x + 7, cursor.y + 7, 1, 9, fgui::color(style.cursor.at(0))); 91 | 92 | for (std::size_t i = 0; i < 4; i++) 93 | fgui::render.rect(cursor.x + 8 + i, cursor.y + 8 + i, 1, 4 - i, fgui::color(style.cursor.at(0))); 94 | 95 | fgui::render.rect(cursor.x + 8, cursor.y + 14, 1, 4, fgui::color(style.cursor.at(0))); 96 | fgui::render.rect(cursor.x + 9, cursor.y + 16, 1, 2, fgui::color(style.cursor.at(0))); 97 | 98 | break; 99 | } 100 | 101 | case fgui::cursor_type::IBEAM: { 102 | 103 | fgui::render.rect(cursor.x - 1, cursor.y - 1, 6 + 2, 1 + 2, fgui::color(style.cursor.at(1))); 104 | fgui::render.rect(cursor.x, cursor.y, 7, 1, fgui::color(style.cursor.at(0))); 105 | 106 | fgui::render.rect(cursor.x - 1 + 3, cursor.y - 1 + 1, 1 + 2, 9 + 2, fgui::color(style.cursor.at(1))); 107 | fgui::render.rect(cursor.x + 3, cursor.y + 1, 1, 9, fgui::color(style.cursor.at(0))); 108 | 109 | fgui::render.rect(cursor.x - 1, cursor.y - 1 + 9, 6 + 2, 1 + 2, fgui::color(style.cursor.at(1))); 110 | fgui::render.rect(cursor.x, cursor.y + 9, 7, 1, fgui::color(style.cursor.at(0))); 111 | 112 | break; 113 | } 114 | 115 | case fgui::cursor_type::HAND: { 116 | 117 | fgui::render.rect(cursor.x - 5 + 6, cursor.y + 5 + 5 + -5, 7, 9, fgui::color(style.cursor.at(0))); 118 | fgui::render.rect(cursor.x - 5, cursor.y + 5 + 7 + -5, 1, 2, fgui::color(style.cursor.at(1))); 119 | fgui::render.rect(cursor.x - 5 + 1, cursor.y + 5 + 6 + -5, 1, 1, fgui::color(style.cursor.at(1))); 120 | 121 | for (std::size_t i = 0; i < 3; ++i) 122 | fgui::render.rect(cursor.x - 5 + 2 + i, cursor.y + 5 + 6 + i + -5, 1, 1, fgui::color(style.cursor.at(1))); 123 | 124 | for (std::size_t i = 0; i < 4; ++i) { 125 | fgui::render.rect(cursor.x - 5 + 1 + i, cursor.y + 5 + 9 + i + -5, 1, 1, fgui::color(style.cursor.at(1))); 126 | fgui::render.rect(cursor.x - 5 + 1 + i, cursor.y + 5 + 7 + i + -5, 1, 1, fgui::color(style.cursor.at(0))); 127 | fgui::render.rect(cursor.x - 5 + 2 + i, cursor.y + 5 + 7 + i + -5, 1, 1, fgui::color(style.cursor.at(0))); 128 | fgui::render.rect(cursor.x - 5 + 1 + i, cursor.y + 5 + 8 + i + -5, 1, 1, fgui::color(style.cursor.at(0))); 129 | fgui::render.rect(cursor.x - 5 + 3 + i, cursor.y + 5 + 11 + i + -5, 1, 1, fgui::color(style.cursor.at(0))); 130 | } 131 | 132 | fgui::render.rect(cursor.x - 5 + 4, cursor.y + 5 + 1 + -5, 1, 7, fgui::color(style.cursor.at(1))); 133 | fgui::render.rect(cursor.x - 5 + 5, cursor.y + 5 + 0 + -5, 2, 1, fgui::color(style.cursor.at(1))); 134 | fgui::render.rect(cursor.x - 5 + 5, cursor.y + 5 + 15 + -5, 5, 1, fgui::color(style.cursor.at(1))); 135 | fgui::render.rect(cursor.x - 5 + 7, cursor.y + 5 + 1 + -5, 1, 6, fgui::color(style.cursor.at(1))); 136 | fgui::render.rect(cursor.x - 5 + 8, cursor.y + 5 + 4 + -5, 4, 1, fgui::color(style.cursor.at(1))); 137 | fgui::render.rect(cursor.x - 5 + 10, cursor.y + 5 + 5 + -5, 1, 2, fgui::color(style.cursor.at(1))); 138 | fgui::render.rect(cursor.x - 5 + 12, cursor.y + 5 + 5 + -5, 1, 2, fgui::color(style.cursor.at(1))); 139 | fgui::render.rect(cursor.x - 5 + 13, cursor.y + 5 + 5 + -5, 1, 1, fgui::color(style.cursor.at(1))); 140 | fgui::render.rect(cursor.x - 5 + 14, cursor.y + 5 + 6 + -5, 1, 5, fgui::color(style.cursor.at(1))); 141 | fgui::render.rect(cursor.x - 5 + 13, cursor.y + 5 + 11 + -5, 1, 2, fgui::color(style.cursor.at(1))); 142 | fgui::render.rect(cursor.x - 5 + 12, cursor.y + 5 + 13 + -5, 1, 3, fgui::color(style.cursor.at(1))); 143 | 144 | fgui::render.rect(cursor.x - 5 + 5, cursor.y + 5 + 1 + -5, 2, 13, fgui::color(style.cursor.at(0))); 145 | fgui::render.rect(cursor.x - 5 + 7, cursor.y + 5 + 14 + -5, 3, 1, fgui::color(style.cursor.at(0))); 146 | fgui::render.rect(cursor.x - 5 + 13, cursor.y + 5 + 6 + -5, 1, 5, fgui::color(style.cursor.at(0))); 147 | fgui::render.rect(cursor.x - 5 + 11, cursor.y + 5 + 14 + -5, 1, 1, fgui::color(style.cursor.at(0))); 148 | 149 | for (std::size_t i = 0; i < 2; ++i) { 150 | fgui::render.rect(cursor.x - 5 + 10 + i, cursor.y + 5 + 14 + i + -5, 1, 1, fgui::color(style.cursor.at(1))); 151 | fgui::render.rect(cursor.x - 5 + 4 + i, cursor.y + 5 + 13 + i + -5, 1, 1, fgui::color(style.cursor.at(1))); 152 | } 153 | 154 | break; 155 | } 156 | 157 | case fgui::cursor_type::PIPETTE: { 158 | 159 | fgui::render.rect(cursor.x, cursor.y + 14 + -15, 1, 1, fgui::color(style.cursor.at(1))); 160 | 161 | for (std::size_t i = 0; i < 2; ++i) { 162 | 163 | fgui::render.rect(cursor.x + i, cursor.y + 13 - i + -15, 1, 1, fgui::color(style.cursor.at(1))); 164 | fgui::render.rect(cursor.x + 1 + i, cursor.y + 14 - i + -15, 1, 1, fgui::color(style.cursor.at(1))); 165 | } 166 | 167 | for (std::size_t i = 0; i < 6; ++i) { 168 | 169 | fgui::render.rect(cursor.x + 1 + i, cursor.y + 11 - i + -15, 1, 1, fgui::color(style.cursor.at(1))); 170 | fgui::render.rect(cursor.x + 3 + i, cursor.y + 13 - i + -15, 1, 1, fgui::color(style.cursor.at(1))); 171 | 172 | fgui::render.rect(cursor.x + 2 + i, cursor.y + 11 - i + -15, 1, 1, fgui::color(style.cursor.at(0))); 173 | fgui::render.rect(cursor.x + 3 + i, cursor.y + 12 - i + -15, 1, 1, fgui::color(style.cursor.at(0))); 174 | fgui::render.rect(cursor.x + 2 + i, cursor.y + 12 - i + -15, 1, 1, fgui::color(style.cursor.at(0))); 175 | } 176 | 177 | fgui::render.rect(cursor.x + 8, cursor.y + 6 + -15, 1, 1, fgui::color(style.cursor.at(1))); 178 | fgui::render.rect(cursor.x + 7, cursor.y + 3 + -15, 6, 3, fgui::color(style.cursor.at(1))); 179 | fgui::render.rect(cursor.x + 9, cursor.y + 2 + -15, 3, 6, fgui::color(style.cursor.at(1))); 180 | fgui::render.rect(cursor.x + 11, cursor.y + -15, 3, 5, fgui::color(style.cursor.at(1))); 181 | fgui::render.rect(cursor.x + 10, cursor.y + 1 + -15, 5, 3, fgui::color(style.cursor.at(1))); 182 | 183 | break; 184 | } 185 | 186 | case fgui::cursor_type::RESIZE: { 187 | 188 | // up arrow 189 | fgui::render.rect(cursor.x - 5, cursor.y - 1, 5, 1, fgui::color(style.cursor.at(0))); 190 | fgui::render.rect(cursor.x - 4, cursor.y - 2, 3, 1, fgui::color(style.cursor.at(0))); 191 | fgui::render.rect(cursor.x - 3, cursor.y - 3, 1, 1, fgui::color(style.cursor.at(0))); 192 | 193 | // middle 194 | fgui::render.rect(cursor.x - 3, cursor.y, 1, 12, fgui::color(style.cursor.at(0))); 195 | 196 | // down arrow 197 | fgui::render.rect(cursor.x - 5, cursor.y + 11, 5, 1, fgui::color(style.cursor.at(0))); 198 | fgui::render.rect(cursor.x - 4, cursor.y + 12, 3, 1, fgui::color(style.cursor.at(0))); 199 | fgui::render.rect(cursor.x - 3, cursor.y + 13, 1, 1, fgui::color(style.cursor.at(0))); 200 | 201 | break; 202 | } 203 | 204 | case fgui::cursor_type::MOVE: { 205 | 206 | // up arrow 207 | fgui::render.rect(cursor.x - 5, cursor.y - 1, 5, 1, fgui::color(style.cursor.at(0))); 208 | fgui::render.rect(cursor.x - 4, cursor.y - 2, 3, 1, fgui::color(style.cursor.at(0))); 209 | fgui::render.rect(cursor.x - 3, cursor.y - 3, 1, 1, fgui::color(style.cursor.at(0))); 210 | 211 | // left arrow 212 | fgui::render.rect(cursor.x - 3 - 7, cursor.y + 11 - 7, 1, 5, fgui::color(style.cursor.at(0))); 213 | fgui::render.rect(cursor.x - 4 - 7, cursor.y + 12 - 7, 1, 3, fgui::color(style.cursor.at(0))); 214 | fgui::render.rect(cursor.x - 5 - 7, cursor.y + 13 - 7, 1, 1, fgui::color(style.cursor.at(0))); 215 | 216 | // cross 217 | fgui::render.rect(cursor.x - 3 - (12 / 2), cursor.y + (12 / 2), 12, 1, fgui::color(style.cursor.at(0))); 218 | fgui::render.rect(cursor.x - 3, cursor.y, 1, 12, fgui::color(style.cursor.at(0))); 219 | 220 | // down arrow 221 | fgui::render.rect(cursor.x - 5, cursor.y + 12, 5, 1, fgui::color(style.cursor.at(0))); 222 | fgui::render.rect(cursor.x - 4, cursor.y + 13, 3, 1, fgui::color(style.cursor.at(0))); 223 | fgui::render.rect(cursor.x - 3, cursor.y + 14, 1, 1, fgui::color(style.cursor.at(0))); 224 | 225 | // right arrow 226 | fgui::render.rect(cursor.x - 5 + 8, cursor.y + 11 - 7, 1, 5, fgui::color(style.cursor.at(0))); 227 | fgui::render.rect(cursor.x - 4 + 8, cursor.y + 12 - 7, 1, 3, fgui::color(style.cursor.at(0))); 228 | fgui::render.rect(cursor.x - 3 + 8, cursor.y + 13 - 7, 1, 1, fgui::color(style.cursor.at(0))); 229 | 230 | break; 231 | } 232 | 233 | case fgui::cursor_type::NONE: 234 | return; 235 | 236 | } 237 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/handler/handler.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | // framework includes 14 | #include "../controls/element.hh" 15 | #include "../controls/container.hh" 16 | #include "../dependencies/color.hh" 17 | #include "../dependencies/input.hh" 18 | #include "../dependencies/definitions.hh" 19 | #include "../notifications/notifications.hh" 20 | 21 | namespace fgui { 22 | 23 | struct style { 24 | 25 | /* 26 | * You can add your own styles here. 27 | * 28 | * Just follow the template above: 29 | * 30 | * std::array button = { fgui::color(45, 45, 45), fgui::color(25, 25, 25) }; 31 | * 32 | * In case you want to remove or add a new color just increase/decrease the array size. 33 | */ 34 | 35 | /* 36 | * Usage: fgui::handler::style st = get_style(); 37 | * 38 | * to apply the style into something: 39 | * fgui::color(st.button.at(0)); 40 | * or 41 | * { st.button.at(0) } 42 | * 43 | * 44 | * to edit the color: 45 | * st.button.at(0) = fgui::color(25, 200, 75); 46 | * or 47 | * st.button.at(0) = { 25, 200, 75 }; 48 | * 49 | * NOTE: When using braces inicializations the framework will always use the default constructor from the color class. 50 | * (R, G, B, A = 255) 51 | * 52 | */ 53 | 54 | // general 55 | std::array text = { fgui::color(181, 181, 181), fgui::color(215, 215, 100), fgui::color(65, 135, 255), fgui::color(245, 245, 245), fgui::color(137, 162, 204) }; 56 | std::array cursor = { fgui::color(255, 255, 255), fgui::color(0, 0, 0) }; 57 | std::array notifications = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 58 | 59 | // elements 60 | std::array button = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 61 | std::array checkbox = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255), fgui::color(46, 119, 191) }; 62 | std::array colorlist = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 63 | std::array colorpicker = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 64 | std::array combobox = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 65 | std::array container = { fgui::color(85, 85, 85), fgui::color(25, 25, 25), fgui::color(140, 27, 166) }; 66 | std::array keybinder = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 67 | std::array label = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(140, 27, 166), fgui::color(140, 27, 166), fgui::color(140, 27, 166) }; 68 | std::array listbox = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 69 | std::array multibox = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 70 | std::array slider = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255), fgui::color(46, 119, 191) }; 71 | std::array spinner = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 72 | std::array tabs = { fgui::color(85, 85, 85), fgui::color(15, 15, 15), fgui::color(40, 40, 40), fgui::color(35, 35, 35), fgui::color(60, 60, 60) }; 73 | std::array textbox = { fgui::color(85, 85, 85), fgui::color(45, 45, 45), fgui::color(25, 25, 25), fgui::color(61, 158, 255) }; 74 | std::array window = { fgui::color(25, 25, 25), fgui::color(40, 40, 40), fgui::color(15, 7, 41), fgui::color(140, 27, 166), fgui::color(140, 27, 166) }; 75 | }; 76 | 77 | // Man that's nasty. I should probably re-do this as soon as possible. 78 | inline fgui::style m_window_style; 79 | inline fgui::input_state m_input_state; 80 | inline fgui::cursor_type m_cursor_type; 81 | inline std::shared_ptr m_focused_element; 82 | inline std::vector> m_windows; 83 | inline std::map> m_binds; 84 | inline std::shared_ptr m_notifications; 85 | 86 | namespace handler { 87 | 88 | // register a new window 89 | inline const void register_window(const std::shared_ptr &window) noexcept { 90 | 91 | m_windows.push_back(window); 92 | } 93 | 94 | // register the notifications 95 | inline const void register_notifications(const fgui::element_font ¬ification_font) noexcept { 96 | 97 | m_notifications = std::make_shared(); 98 | m_notifications->set_font(notification_font); 99 | } 100 | 101 | // render window 102 | void render_window(); 103 | 104 | // set a toggle key for the window 105 | inline const void set_key(const fgui::key &key, const std::shared_ptr &window) noexcept { 106 | 107 | if (window) 108 | m_binds[key] = window; 109 | else 110 | m_binds.erase(key); 111 | } 112 | 113 | // sets the cursor type that will be displayed on the window 114 | inline const void set_cursor(const fgui::cursor_type &cursor_type) noexcept { 115 | 116 | m_cursor_type = cursor_type; 117 | } 118 | 119 | // handle the cursors 120 | void draw_cursors(); 121 | 122 | // enable/disable the keyboard and mouse input 123 | inline const void set_input_state(const fgui::input_state &input_state) noexcept { 124 | 125 | m_input_state = input_state; 126 | } 127 | 128 | // get the window style 129 | inline const fgui::style get_style() noexcept { 130 | 131 | return m_window_style; 132 | } 133 | 134 | // call a notification 135 | inline const void call_notification(const std::string_view notification_text, const fgui::animation_type &animation_type) noexcept { 136 | 137 | fgui::m_notifications->add_notification(notification_text, animation_type); 138 | } 139 | } 140 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/notifications/notifications.cc: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | // includes 6 | #include "notifications.hh" 7 | #include "../handler/handler.hh" 8 | 9 | fgui::notification::notification() { 10 | 11 | fgui::notification::m_x = 0; 12 | fgui::notification::m_y = 50; 13 | fgui::notification::m_width = 150; 14 | fgui::notification::m_height = 45; 15 | fgui::notification::m_stay_time = 100; 16 | } 17 | 18 | //--------------------------------------------------------- 19 | void fgui::notification::draw() { 20 | 21 | // get the window style 22 | auto style = handler::get_style(); 23 | 24 | // screen size 25 | int screen_width, screen_height; 26 | fgui::render.get_screen_size(screen_width, screen_height); 27 | 28 | if (m_info.empty()) 29 | return; 30 | 31 | for (std::size_t i = 0; i < m_info.size(); i++) { 32 | 33 | // notification text size 34 | fgui::dimension text_size = fgui::render.get_text_size(fgui::notification::get_font(), m_info[i].text); 35 | 36 | // notification area 37 | fgui::rect area = { 0, 0, 0, 0 }; 38 | 39 | if (m_info[i].animation_type == fgui::animation_type::LINEAR) { 40 | 41 | area = { m_x + (screen_width - m_info[i].animation_progress), m_y + (m_height * static_cast(i)), m_width + 30, m_height }; 42 | 43 | // notification body 44 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.notifications.at(0), 235)); 45 | fgui::render.rect(area.left + 1 , area.top + 1, 1, area.bottom - 2, fgui::color(style.notifications.at(3))); 46 | fgui::render.rect(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.notifications.at(1), 235)); 47 | 48 | // notification text 49 | if (m_info[i].text.length() > 32) 50 | fgui::render.text(area.left + 10, area.top + (area.bottom / 2) - (text_size.height / 2), fgui::color(style.text.at(0), 235), fgui::notification::get_font(), m_info[i].text.replace(m_info[i].text.begin() + 32, m_info[i].text.end(), "...")); 51 | else 52 | fgui::render.text(area.left + 10, area.top + (area.bottom / 2) - (text_size.height / 2), fgui::color(style.text.at(0), 235), fgui::notification::get_font(), m_info[i].text); 53 | } 54 | 55 | else if (m_info[i].animation_type == fgui::animation_type::FADE) { 56 | 57 | area = { m_x + (screen_width - m_width), m_y + (m_height * static_cast(i)), m_width + 30, m_height }; 58 | 59 | // notification body 60 | fgui::render.outline(area.left, area.top, area.right, area.bottom, fgui::color(style.notifications.at(0), m_info[i].animation_progress)); 61 | fgui::render.rect(area.left + 1 , area.top + 1, 1, area.bottom - 2, fgui::color(style.notifications.at(3), m_info[i].animation_progress)); 62 | fgui::render.rect(area.left + 2, area.top + 2, area.right - 4, area.bottom - 4, fgui::color(style.notifications.at(1), m_info[i].animation_progress)); 63 | 64 | // notification text 65 | if (m_info[i].text.length() > 32) 66 | fgui::render.text(area.left + 10, area.top + (area.bottom / 2) - (text_size.height / 2), fgui::color(style.text.at(0), m_info[i].animation_progress), fgui::notification::get_font(), m_info[i].text.replace(m_info[i].text.begin() + 32, m_info[i].text.end(), "...")); 67 | else 68 | fgui::render.text(area.left + 10, area.top + (area.bottom / 2) - (text_size.height / 2), fgui::color(style.text.at(0), m_info[i].animation_progress), fgui::notification::get_font(), m_info[i].text); 69 | } 70 | } 71 | } 72 | 73 | //--------------------------------------------------------- 74 | void fgui::notification::update() { 75 | 76 | static const int increase_value = 1; 77 | static const int alpha_value = 200; 78 | 79 | if (m_info.empty()) 80 | return; 81 | 82 | for (std::size_t i = 0; i < m_info.size(); i++) { 83 | 84 | if (!m_info[i].state) { 85 | m_info[i].tick = 0; 86 | m_info[i].text.clear(); 87 | 88 | m_info.erase(m_info.begin() + i); 89 | m_info.shrink_to_fit(); 90 | } 91 | 92 | else if (m_info[i].state) { 93 | 94 | m_info[i].tick += increase_value; 95 | 96 | // linear animation 97 | if (m_info[i].animation_type == fgui::animation_type::LINEAR) { 98 | 99 | if (m_info[i].tick < m_width) 100 | m_info[i].animation_progress++; 101 | 102 | // close the notification if it exceeds its time 103 | if (m_info[i].tick >= m_width + m_stay_time) { 104 | 105 | m_info[i].animation_progress--; 106 | 107 | if (m_info[i].animation_progress == 0) 108 | m_info[i].state = false; 109 | } 110 | } 111 | 112 | // fade animation 113 | else if (m_info[i].animation_type == fgui::animation_type::FADE) { 114 | 115 | if (m_info[i].tick < alpha_value) 116 | m_info[i].animation_progress++; 117 | 118 | // close the notification if it exceeds its time 119 | if (m_info[i].tick >= alpha_value + m_stay_time) { 120 | 121 | m_info[i].animation_progress--; 122 | 123 | if (m_info[i].animation_progress == 0) 124 | m_info[i].state = false; 125 | } 126 | } 127 | } 128 | } 129 | } 130 | 131 | //--------------------------------------------------------- 132 | void fgui::notification::handle_input() { 133 | 134 | // screen size 135 | int screen_width, screen_height; 136 | fgui::render.get_screen_size(screen_width, screen_height); 137 | 138 | if (m_info.empty()) 139 | return; 140 | 141 | for (std::size_t i = 0; i < m_info.size(); i++) { 142 | 143 | // notification area 144 | fgui::rect area = { m_x + (screen_width - m_width), m_y + (m_height * static_cast(i)), m_width + 30, m_height }; 145 | 146 | // check if the user is hovering the notification area 147 | if (fgui::input_system::mouse_in_area(area)) { 148 | 149 | // close the notification if the user click on it 150 | if (fgui::input_system::key_held(fgui::external::MOUSE_LEFT)) 151 | m_info[i].state = false; 152 | } 153 | } 154 | } -------------------------------------------------------------------------------- /ApexLegends/FGUI/notifications/notifications.hh: -------------------------------------------------------------------------------- 1 | /* * 2 | * fgui - an extensive oop gui framework * 3 | * */ 4 | 5 | #pragma once 6 | 7 | // includes 8 | #include 9 | #include 10 | #include 11 | 12 | // framework includes 13 | #include "../dependencies/color.hh" 14 | #include "../dependencies/aliases.hh" 15 | #include "../dependencies/definitions.hh" 16 | 17 | namespace fgui { 18 | 19 | struct notification_info { 20 | 21 | notification_info(const std::string_view _text, const fgui::animation_type &_animation_type) : text(_text), animation_type(_animation_type), animation_progress(0.f), state(true), tick(0) {} 22 | 23 | int tick; 24 | int animation_progress; 25 | std::string text; 26 | fgui::state state; 27 | fgui::animation_type animation_type; 28 | }; 29 | 30 | class notification { 31 | public: 32 | notification(); 33 | 34 | // draw notifications 35 | void draw(); 36 | 37 | // creates a new notification 38 | inline void add_notification(const std::string_view _text, const fgui::animation_type &_animation_type) noexcept { 39 | 40 | m_info.push_back({_text, _animation_type}); 41 | } 42 | 43 | // allows the user to change the font of the notification 44 | inline void set_font(const std::string_view font_family, int size, int flags = 0, bool bold = false) noexcept { 45 | 46 | fgui::render.create_font(m_font, font_family, size, flags, bold); 47 | } 48 | 49 | inline void set_font(const fgui::element_font &element_font) noexcept { 50 | 51 | fgui::render.create_font(m_font, element_font.family, element_font.size, element_font.flags, element_font.bold); 52 | } 53 | 54 | // returns the font that the notification is currently using 55 | inline fgui::font get_font() const noexcept { 56 | 57 | return m_font; 58 | } 59 | 60 | // handle notification updates 61 | void update(); 62 | 63 | // handle notification mouse and keyboard input 64 | void handle_input(); 65 | 66 | private: 67 | int m_x, m_y; 68 | fgui::font m_font; 69 | int m_stay_time; 70 | int m_width, m_height; 71 | std::vector m_info; 72 | }; 73 | } -------------------------------------------------------------------------------- /ApexLegends/dd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekdms05/Seraph-APEX/54cff8d9212ea2c20925348019d11d08b1ab60f7/ApexLegends/dd.cpp -------------------------------------------------------------------------------- /ApexLegends/dd.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ekdms05/Seraph-APEX/54cff8d9212ea2c20925348019d11d08b1ab60f7/ApexLegends/dd.h -------------------------------------------------------------------------------- /ApexLegends/examples/d3d9/input.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // FGUI - WIN32 Input System 3 | // 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define FGUI_IMPLEMENTATION 10 | #include 11 | 12 | namespace FGUI_INPUT_WIN32 13 | { 14 | inline std::array m_prgpCurrentPressedKeys, m_prgpOldPressedKeys; 15 | inline FGUI::POINT m_ptCursorPosition, m_ptCursorPositionDelta; 16 | 17 | inline void PullInput() 18 | { 19 | static FGUI::POINT ptLastKnownPosition = { 0, 0 }; 20 | 21 | std::copy(m_prgpCurrentPressedKeys.begin(), m_prgpCurrentPressedKeys.end(), m_prgpOldPressedKeys.begin()); 22 | 23 | for (std::size_t i = 0; i < 256; i++) 24 | { 25 | m_prgpCurrentPressedKeys.at(i) = GetAsyncKeyState(i); 26 | } 27 | 28 | // Get current cursor position 29 | GetCursorPos(reinterpret_cast(&m_ptCursorPosition)); 30 | 31 | // Calculate the cursor position delta 32 | m_ptCursorPositionDelta = { (m_ptCursorPosition.m_iX - ptLastKnownPosition.m_iX), (m_ptCursorPosition.m_iY - ptLastKnownPosition.m_iY) }; 33 | 34 | // Get last known position of the cursor 35 | ptLastKnownPosition = m_ptCursorPosition; 36 | } 37 | 38 | inline bool IsKeyHeld(unsigned int _key_code) 39 | { 40 | return m_prgpCurrentPressedKeys.at(_key_code); 41 | } 42 | 43 | inline bool IsKeyReleased(unsigned int _key_code) 44 | { 45 | return (!m_prgpCurrentPressedKeys.at(_key_code) && m_prgpOldPressedKeys.at(_key_code)); 46 | } 47 | 48 | inline bool IsKeyPressed(unsigned int _key_code) 49 | { 50 | return (m_prgpCurrentPressedKeys.at(_key_code) && !m_prgpOldPressedKeys.at(_key_code)); 51 | } 52 | 53 | inline FGUI::POINT GetCursorPos() 54 | { 55 | return m_ptCursorPosition; 56 | } 57 | 58 | inline FGUI::POINT GetCursorPosDelta() 59 | { 60 | return m_ptCursorPositionDelta; 61 | } 62 | 63 | inline bool IsCursorInArea(FGUI::AREA area) 64 | { 65 | return (GetCursorPos().m_iX > area.m_iLeft && GetCursorPos().m_iY > area.m_iTop && 66 | GetCursorPos().m_iX < area.m_iLeft + area.m_iRight && GetCursorPos().m_iY < area.m_iTop + area.m_iBottom); 67 | } 68 | 69 | // NOTE: call this function only once (preferably when you initialize your application) 70 | inline void OnEntryPoint() 71 | { 72 | FGUI::INPUT.PullInput = FGUI_INPUT_WIN32::PullInput; 73 | FGUI::INPUT.IsKeyHeld = FGUI_INPUT_WIN32::IsKeyHeld; 74 | FGUI::INPUT.IsKeyReleased = FGUI_INPUT_WIN32::IsKeyReleased; 75 | FGUI::INPUT.IsKeyPressed = FGUI_INPUT_WIN32::IsKeyPressed; 76 | FGUI::INPUT.GetCursorPos = FGUI_INPUT_WIN32::GetCursorPos; 77 | FGUI::INPUT.GetCursorPosDelta = FGUI_INPUT_WIN32::GetCursorPosDelta; 78 | FGUI::INPUT.IsCursorInArea = FGUI_INPUT_WIN32::IsCursorInArea; 79 | 80 | // set input type 81 | FGUI::INPUT.SetInputType(FGUI::INPUT_TYPE::WIN_32); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ApexLegends/examples/d3d9/renderer.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // FGUI - DirectX 9 Renderer 3 | // 4 | 5 | #pragma once 6 | 7 | #define FGUI_IMPLEMENTATION 8 | #include 9 | 10 | // NOTE: make sure to tell FGUI to use D3D9: 11 | // go to: https://github.com/otvv/fgui/wiki/First-Steps#renderer-helpers for more info. 12 | 13 | namespace FGUI_D3D9 14 | { 15 | // NOTE: you still need to initialize the device. 16 | inline IDirect3DDevice9Ex* m_pDevice; 17 | 18 | inline void CreateFont(FGUI::FONT &_font, std::string _family, int _size, int _flags, bool _bold) // TODO: handle font flags 19 | { 20 | D3DXCreateFont(m_pDevice, _size, 0, _bold ? FW_BOLD : FW_NORMAL, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _family.c_str(), &_font); 21 | } 22 | 23 | inline FGUI::DIMENSION GetScreenSize() 24 | { 25 | static int iWidth = GetSystemMetrics(SM_CXSCREEN); 26 | static int iHeight = GetSystemMetrics(SM_CYSCREEN); 27 | 28 | return { iWidth, iHeight }; 29 | } 30 | 31 | inline FGUI::DIMENSION GetTextSize(FGUI::FONT _font, std::string _text) 32 | { 33 | RECT rectFontSize = { 0, 0 }; 34 | 35 | // there's probably a better way of getting the size of a text, this will do for the moment. 36 | _font->DrawText(0, _text.c_str(), _text.length(), &rectFontSize, DT_CALCRECT, D3DCOLOR_RGBA(0, 0, 0, 0)); 37 | 38 | return { (rectFontSize.right - rectFontSize.left), (rectFontSize.bottom - rectFontSize.top) }; 39 | } 40 | 41 | inline void Text(int _x, int _y, FGUI::FONT _font, FGUI::COLOR _color, std::string _text) 42 | { 43 | D3DCOLOR dwColor = D3DCOLOR_RGBA(_color.m_ucRed, _color.m_ucGreen, _color.m_ucBlue, _color.m_ucAlpha); 44 | 45 | RECT rectFontSize = { _x, _y }; 46 | 47 | _font->DrawText(0, _text.c_str(), _text.length(), &rectFontSize, DT_NOCLIP, dwColor); 48 | } 49 | 50 | inline void Rectangle(int _x, int _y, int _width, int _height, FGUI::COLOR _color) 51 | { 52 | D3DCOLOR dwColor = D3DCOLOR_RGBA(_color.m_ucRed, _color.m_ucGreen, _color.m_ucBlue, _color.m_ucAlpha); 53 | 54 | const FGUI::VERTEX vtxVertices[4] = 55 | { 56 | {_x, _y + _height, 0.f, 1.f, dwColor }, 57 | {_x, _y, 0.f, 1.f, dwColor}, 58 | {_x + _width, _y + _height, 0.f, 1.f, dwColor}, 59 | {_x + _width, _y, 0.f, 1.f, dwColor}, 60 | }; 61 | 62 | m_pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); 63 | m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vtxVertices, sizeof(FGUI::VERTEX)); 64 | } 65 | 66 | inline void Outline(int _x, int _y, int _width, int _height, FGUI::COLOR _color) 67 | { 68 | // WARNING: do not repeat this at home. 69 | Rectangle(_x, _y, _width, 1, _color); 70 | Rectangle(_x, _y, 1, _height, _color); 71 | Rectangle(_x + _width - 1, _y, 1, _height, _color); 72 | Rectangle(_x, _y + _height - 1, _width, 1, _color); 73 | } 74 | 75 | inline void Line(int _from_x, int _from_y, int _to_x, int _to_y, FGUI::COLOR _color) 76 | { 77 | D3DCOLOR dwColor = D3DCOLOR_RGBA(_color.m_ucRed, _color.m_ucGreen, _color.m_ucBlue, _color.m_ucAlpha); 78 | 79 | const FGUI::VERTEX vtxVertices[2] = 80 | { 81 | {_from_x, _from_y, 0.f, 0.f, dwColor }, 82 | {_from_x + _to_x, _from_y + _to_y, 0.f, 0.f, dwColor} 83 | }; 84 | 85 | m_pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); 86 | m_pDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vtxVertices, sizeof(FGUI::VERTEX)); 87 | } 88 | 89 | inline void Gradient(int _x, int _y, int _width, int _height, FGUI::COLOR _color1, FGUI::COLOR _color2, bool _horizontal) 90 | { 91 | // there's probably a better way to do this kind of gradient as well. 92 | D3DCOLOR dwColor1 = D3DCOLOR_RGBA(_color1.m_ucRed, _color1.m_ucGreen, _color1.m_ucBlue, _color1.m_ucAlpha); 93 | D3DCOLOR dwColor2 = D3DCOLOR_RGBA(_color2.m_ucRed, _color2.m_ucGreen, _color2.m_ucBlue, _color2.m_ucAlpha); 94 | 95 | const FGUI::VERTEX vtxVertices[4] = 96 | { 97 | { _x, _y, 0.0f, 1.0f, dwColor1 }, 98 | { _x + _width, _y, 0.0f, 1.0f, _horizontal ? dwColor2 : dwColor1 }, 99 | { _x, _y + _height, 0.0f, 1.0f, _horizontal ? dwColor1 : dwColor2 }, 100 | { _x + _width, _y + _height, 0.0f, 1.0f, dwColor2 } 101 | }; 102 | 103 | m_pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); 104 | m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vtxVertices, sizeof(FGUI::VERTEX)); 105 | } 106 | 107 | // NOTE: call this function only once (preferably when you initialize your application) 108 | inline void OnEntryPoint() 109 | { 110 | FGUI::RENDER.CreateFont = FGUI_D3D9::CreateFont; 111 | FGUI::RENDER.GetScreenSize = FGUI_D3D9::GetScreenSize; 112 | FGUI::RENDER.GetTextSize = FGUI_D3D9::GetTextSize; 113 | FGUI::RENDER.Rectangle = FGUI_D3D9::Rectangle; 114 | FGUI::RENDER.Outline = FGUI_D3D9::Outline; 115 | FGUI::RENDER.Line = FGUI_D3D9::Line; 116 | FGUI::RENDER.Text = FGUI_D3D9::Text; 117 | FGUI::RENDER.Gradient = FGUI_D3D9::Gradient; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /ApexLegends/examples/surface/input.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // FGUI - Valve's Input System Interface 3 | // 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #define FGUI_IMPLEMENTATION 10 | #include 11 | 12 | // NOTE: make sure to use your input system interface pointer 13 | // replace "IInputSystem" with your pointer 14 | 15 | namespace FGUI_IINPUT_SYSTEM 16 | { 17 | inline std::array m_prgpCurrentPressedKeys, m_prgpOldPressedKeys; 18 | inline FGUI::POINT m_ptCursorPosition, m_ptCursorPositionDelta; 19 | 20 | inline void PullInput() 21 | { 22 | static FGUI::POINT ptLastKnownPosition = { 0, 0 }; 23 | 24 | std::copy(m_prgpCurrentPressedKeys.begin(), m_prgpCurrentPressedKeys.end(), m_prgpOldPressedKeys.begin()); 25 | 26 | for (std::size_t i = 0; i < 256; i++) 27 | { 28 | m_prgpCurrentPressedKeys.at(i) = IInputSystem->IsButtonDown(i); 29 | } 30 | 31 | // Get current cursor position 32 | IInputSystem->GetCursorPosition(&m_ptCursorPosition.m_iX, &m_ptCursorPosition.m_iY)); 33 | 34 | // Calculate the cursor position delta 35 | m_ptCursorPositionDelta = { (m_ptCursorPosition.m_iX - ptLastKnownPosition.m_iX), (m_ptCursorPosition.m_iY - ptLastKnownPosition.m_iY) }; 36 | 37 | // Get last known position of the cursor 38 | ptLastKnownPosition = m_ptCursorPosition; 39 | } 40 | 41 | inline bool IsKeyHeld(unsigned int _key_code) 42 | { 43 | return m_prgpCurrentPressedKeys.at(_key_code); 44 | } 45 | 46 | inline bool IsKeyReleased(unsigned int _key_code) 47 | { 48 | return (!m_prgpCurrentPressedKeys.at(_key_code) && m_prgpOldPressedKeys.at(_key_code)); 49 | } 50 | 51 | inline bool IsKeyPressed(unsigned int _key_code) 52 | { 53 | return (m_prgpCurrentPressedKeys.at(_key_code) && !m_prgpOldPressedKeys.at(_key_code)); 54 | } 55 | 56 | inline FGUI::POINT GetCursorPos() 57 | { 58 | return m_ptCursorPosition; 59 | } 60 | 61 | inline FGUI::POINT GetCursorPosDelta() 62 | { 63 | return m_ptCursorPositionDelta; 64 | } 65 | 66 | inline bool IsCursorInArea(FGUI::AREA area) 67 | { 68 | return (GetCursorPos().m_iX > area.m_iLeft && GetCursorPos().m_iY > area.m_iTop && 69 | GetCursorPos().m_iX < area.m_iLeft + area.m_iRight && GetCursorPos().m_iY < area.m_iTop + area.m_iBottom); 70 | } 71 | 72 | // NOTE: call this function only once (preferably when you initialize your application) 73 | inline void OnEntryPoint() 74 | { 75 | FGUI::INPUT.PullInput = FGUI_IINPUT_SYSTEM::PullInput; 76 | FGUI::INPUT.IsKeyHeld = FGUI_IINPUT_SYSTEM::IsKeyHeld; 77 | FGUI::INPUT.IsKeyReleased = FGUI_IINPUT_SYSTEM::IsKeyReleased; 78 | FGUI::INPUT.IsKeyPressed = FGUI_IINPUT_SYSTEM::IsKeyPressed; 79 | FGUI::INPUT.GetCursorPos = FGUI_IINPUT_SYSTEM::GetCursorPos; 80 | FGUI::INPUT.GetCursorPosDelta = FGUI_IINPUT_SYSTEM::GetCursorPosDelta; 81 | FGUI::INPUT.IsCursorInArea = FGUI_IINPUT_SYSTEM::IsCursorInArea; 82 | 83 | // set input type 84 | FGUI::INPUT.SetInputType(FGUI::INPUT_TYPE::INPUT_SYSTEM); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /ApexLegends/examples/surface/renderer.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // FGUI - Surface Renderer (Source Engine) 3 | // 4 | 5 | #pragma once 6 | 7 | #define FGUI_IMPLEMENTATION 8 | #include 9 | 10 | // NOTE: make sure to use your surface interface pointer 11 | // replace "ISurface" with your pointer 12 | 13 | namespace FGUI_SURFACE 14 | { 15 | 16 | inline void CreateFont(FGUI::FONT& _font, std::string _family, int _size, int _flags, bool _bold) 17 | { 18 | _font = ISurface->CreateFont(); 19 | ISurface->SetFontGlyphSet(_font, _family.c_str(), _size, _bold ? 800 : 0, 0, 0, _flags); 20 | } 21 | 22 | inline FGUI::DIMENSION GetScreenSize() 23 | { 24 | static FGUI::DIMENSION dmTemporarySize = { 0, 0 }; 25 | 26 | ISurface->GetScreenSize(dmTemporarySize.m_iWidth, dmTemporarySize.m_iHeight); 27 | 28 | return dmTemporarySize; 29 | } 30 | 31 | inline FGUI::DIMENSION GetTextSize(FGUI::FONT _font, std::string _text) 32 | { 33 | static FGUI::DIMENSION dmTemporarySize = { 0, 0 }; 34 | 35 | ISurface->GetTextSize(_font, std::wstring(_text.begin(), _text.end()).c_str(), dmTemporarySize.m_iWidth, dmTemporarySize.m_iHeight); 36 | 37 | return dmTemporarySize; 38 | } 39 | 40 | inline void Rectangle(int _x, int _y, int _width, int _height, FGUI::COLOR _color) 41 | { 42 | ISurface->DrawSetColor(_color.m_ucRed, _color.m_ucGreen, _color.m_ucBlue, _color.m_ucAlpha); 43 | ISurface->DrawFilledRect(_x, _y, _x + _width, _y + _height); 44 | } 45 | 46 | inline void Outline(int _x, int _y, int _width, int _height, FGUI::COLOR _color) 47 | { 48 | ISurface->DrawSetColor(_color.m_ucRed, _color.m_ucGreen, _color.m_ucBlue, _color.m_ucAlpha); 49 | ISurface->DrawOutlinedRect(_x, _y, _x + _width, _y + _height); 50 | } 51 | 52 | inline void Gradient(int _x, int _y, int _width, int _height, FGUI::COLOR _color1, FGUI::COLOR _color2, bool _horizontal) 53 | { 54 | ISurface->DrawSetColor(_color1.m_ucRed, _color1.m_ucGreen, _color1.m_ucBlue, _color1.m_ucAlpha); 55 | ISurface->DrawFilledRectFade(_x, _y, _x + _width, _y +_height, 255, 255, _horizontal); 56 | 57 | ISurface->DrawSetColor(_color2.m_ucRed, _color2.m_ucGreen, _color2.m_ucBlue, _color2.m_ucAlpha); 58 | ISurface->DrawFilledRectFade(_x, _y, _x + _width, _y + _height, 0, 255, _horizontal); 59 | } 60 | 61 | inline void Line(int _from_x, int _from_y, int _to_x, int _to_y, FGUI::COLOR _color) 62 | { 63 | ISurface->DrawSetColor(_color.m_ucRed, _color.m_ucGreen, _color.m_ucBlue, _color.m_ucAlpha); 64 | ISurface->DrawLine(_from_x, _from_y, _to_x, _to_y); 65 | } 66 | 67 | inline void Text(int _x, int _y, FGUI::FONT _font, FGUI::COLOR _color, std::string _text) 68 | { 69 | ISurface->DrawColoredText(_font, _x, _y, _color.m_ucRed, _color.m_ucGreen, _color.m_ucBlue, _color.m_ucAlpha, _text.c_str()); 70 | } 71 | 72 | // NOTE: call this function only once (preferably when you initialize your application) 73 | inline void OnEntryPoint() 74 | { 75 | FGUI::RENDER.CreateFont = FGUI_SURFACE::CreateFont; 76 | FGUI::RENDER.GetScreenSize = FGUI_SURFACE::GetScreenSize; 77 | FGUI::RENDER.GetTextSize = FGUI_SURFACE::GetTextSize; 78 | FGUI::RENDER.Rectangle = FGUI_SURFACE::Rectangle; 79 | FGUI::RENDER.Outline = FGUI_SURFACE::Outline; 80 | FGUI::RENDER.Line = FGUI_SURFACE::Line; 81 | FGUI::RENDER.Text = FGUI_SURFACE::Text; 82 | FGUI::RENDER.Gradient = FGUI_SURFACE::Gradient; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /ApexLegends/globals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct globals 4 | { 5 | struct 6 | { 7 | std::string version; 8 | std::string status; 9 | 10 | std::string ip = xorstr_("haruna7777.com"); 11 | 12 | struct 13 | { 14 | std::string cipher; 15 | std::string iv; 16 | } key; 17 | } server_side; 18 | 19 | struct 20 | { 21 | std::string version = xorstr_("0.01"); 22 | 23 | struct 24 | { 25 | std::string name = utilities::get_random_string(16); 26 | float width = 440.f; 27 | float height = 280.f; 28 | } window_settings; 29 | 30 | struct 31 | { 32 | std::string key; 33 | std::string hwid = utilities::get_hwid(); 34 | 35 | std::string token; 36 | std::string structure_cheat; 37 | 38 | } data; 39 | } client_side; 40 | }; 41 | 42 | extern globals g_globals; -------------------------------------------------------------------------------- /Ark - Apex.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2010 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ApexLegends", "ApexLegends\ApexLegends.vcxproj", "{13F42F30-64C2-4405-A324-C4F4982021D8}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {13F42F30-64C2-4405-A324-C4F4982021D8}.Debug|x64.ActiveCfg = Debug|x64 17 | {13F42F30-64C2-4405-A324-C4F4982021D8}.Debug|x64.Build.0 = Debug|x64 18 | {13F42F30-64C2-4405-A324-C4F4982021D8}.Debug|x86.ActiveCfg = Debug|Win32 19 | {13F42F30-64C2-4405-A324-C4F4982021D8}.Debug|x86.Build.0 = Debug|Win32 20 | {13F42F30-64C2-4405-A324-C4F4982021D8}.Release|x64.ActiveCfg = Release|x64 21 | {13F42F30-64C2-4405-A324-C4F4982021D8}.Release|x64.Build.0 = Release|x64 22 | {13F42F30-64C2-4405-A324-C4F4982021D8}.Release|x86.ActiveCfg = Release|Win32 23 | {13F42F30-64C2-4405-A324-C4F4982021D8}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {4A38CDE7-76BB-4269-9DFE-78B6FC794213} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Seraph-APEX 2 | 3 | I JUST UPLOADED MY SHIT TRASH SOURCE BCUZ IT IS DETECTED AND I DO NOT PLAY APEX ANYMORE. 4 | 5 | ### Menus 6 | 7 | ![apex1](https://user-images.githubusercontent.com/13113619/95992809-5546f280-0e69-11eb-9b19-a144bf5b5c89.png) 8 | ![apex2](https://user-images.githubusercontent.com/13113619/95992820-5710b600-0e69-11eb-809e-399ecd778e3d.png) 9 | ![apex3](https://user-images.githubusercontent.com/13113619/95992825-58da7980-0e69-11eb-9aa9-657892062640.png) 10 | ![apex4](https://user-images.githubusercontent.com/13113619/95992834-5b3cd380-0e69-11eb-981c-3e86996263c6.png) 11 | 12 | ### Features 13 | 14 | * CHAMS 15 | * ESP 16 | * AIMBOT 17 | * NO RECOIL 18 | * 2D RADAR 19 | * SPECTATOR CHECK 20 | * AND MORE 21 | 22 | ### This is Trash 23 | * This code are trash and There's a lot of C&P codes of functions. 24 | * But Calculation and math parts and UI design are useful I think so 25 | * 4500 lines for main.cpp Imao 26 | --------------------------------------------------------------------------------