├── update_makefile.bat ├── fix_build_system.bat ├── .gitmodules ├── winapi_interop.hpp ├── README.md ├── LICENSE ├── process_info.hpp ├── process_manager.hpp ├── application_profile.hpp ├── game_window_manager.cbp ├── winapi_interop.cpp ├── main.cpp ├── makefile.mac ├── makefile.unix ├── makefile.windows └── process_manager.cpp /update_makefile.bat: -------------------------------------------------------------------------------- 1 | cbp2make -in game_window_manager.cbp -out makefile --all-os -------------------------------------------------------------------------------- /fix_build_system.bat: -------------------------------------------------------------------------------- 1 | copy "deps\\imgui-sfml\\imconfig-SFML.h" "deps\\imgui" 2 | del "deps\\imgui\\imconfig.h" 3 | rename "deps\\imgui\\imconfig-SFML.h" "imconfig.h" -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/funserialisation"] 2 | path = deps/funserialisation 3 | url = https://github.com/20k/funserialisation 4 | [submodule "deps/imgui-sfml"] 5 | path = deps/imgui-sfml 6 | url = https://github.com/eliasdaler/imgui-sfml 7 | [submodule "deps/imgui"] 8 | path = deps/imgui 9 | url = https://github.com/ocornut/imgui 10 | -------------------------------------------------------------------------------- /winapi_interop.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WINAPI_INTEROP_HPP_INCLUDED 2 | #define WINAPI_INTEROP_HPP_INCLUDED 3 | 4 | #include 5 | #include "process_info.hpp" 6 | 7 | process_info window_handle_to_process_info(HWND window_handle); 8 | process_info process_id_to_process_info(DWORD processID); 9 | std::vector get_process_infos(); 10 | 11 | #endif // WINAPI_INTEROP_HPP_INCLUDED 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # game_window_manager 2 | 3 | Start up a game in windowed mode. Either start up game_window_manager.exe or click refresh, then select the name of the game from the dropdown list 4 | 5 | If you wish to move it to the top left of your screen and make it borderless, click make borderless, set to top left 6 | 7 | If you wish to simply make it borderless, click make borderless 8 | 9 | Demonstration: 10 | 11 | https://i.imgur.com/8nu6uCm.gifv -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 James 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /process_info.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROCESS_INFO_HPP_INCLUDED 2 | #define PROCESS_INFO_HPP_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct process_info 10 | { 11 | std::string process_name = "Error"; 12 | HWND handle = 0; 13 | HANDLE hProcess = 0; 14 | WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) }; 15 | DWORD processID = 0; 16 | 17 | int w = 0; 18 | int h = 0; 19 | 20 | bool valid() const 21 | { 22 | return handle != 0; 23 | } 24 | 25 | LONG_PTR get_style() const 26 | { 27 | return GetWindowLongPtr(handle, GWL_STYLE); 28 | } 29 | 30 | LONG_PTR get_ex_style() const 31 | { 32 | return GetWindowLongPtr(handle, GWL_EXSTYLE); 33 | } 34 | 35 | void set_style(LONG_PTR dat) const 36 | { 37 | SetWindowLongPtr(handle, GWL_STYLE, dat); 38 | } 39 | 40 | void set_ex_style(LONG_PTR dat) const 41 | { 42 | SetWindowLongPtr(handle, GWL_EXSTYLE, dat); 43 | } 44 | 45 | void refresh(bool should_move = false, int move_x = 0, int move_y = 0) const 46 | { 47 | if(!should_move) 48 | SetWindowPos(handle, NULL, 0,0,0,0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); 49 | else 50 | SetWindowPos(handle, NULL, move_x, move_y, 0,0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); 51 | } 52 | 53 | void dump_styles() const 54 | { 55 | std::bitset<64> b1(get_style()); 56 | std::bitset<64> b2(get_ex_style()); 57 | 58 | std::cout << "b1 " << b1 << std::endl; 59 | std::cout << "b2 " << b2 << std::endl; 60 | } 61 | 62 | void lock_mouse_to() 63 | { 64 | RECT wrect; 65 | GetWindowRect(handle, &wrect); 66 | ClipCursor(&wrect); 67 | } 68 | }; 69 | 70 | #endif // PROCESS_INFO_HPP_INCLUDED 71 | -------------------------------------------------------------------------------- /process_manager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROCESS_MANAGER_HPP_INCLUDED 2 | #define PROCESS_MANAGER_HPP_INCLUDED 3 | 4 | #include 5 | #include 6 | #include "application_profile.hpp" 7 | #include 8 | 9 | struct process_info; 10 | 11 | struct process_manager : serialisable 12 | { 13 | std::string last_managed_window = ""; 14 | 15 | std::vector profiles; 16 | 17 | std::vector processes; 18 | int imgui_current_item = 0; 19 | 20 | bool should_quit = false; 21 | bool only_show_windowed = true; 22 | bool use_mouse_lock = true; 23 | bool use_f9_refresh = true; 24 | 25 | bool lock_mouse_to_window = false; 26 | 27 | bool locking_success = false; 28 | 29 | int dwidth = 0; 30 | int dheight = 0; 31 | 32 | virtual void do_serialise(serialise& s, bool ser) override 33 | { 34 | s.handle_serialise(only_show_windowed, ser); 35 | s.handle_serialise(use_mouse_lock, ser); 36 | s.handle_serialise(profiles, ser); 37 | } 38 | 39 | process_manager(); 40 | 41 | std::optional> fetch_profile_by_name(const std::string& name); 42 | 43 | void toggle_mouse_lock(); 44 | 45 | void apply_profile(application_profile& prof, process_info& proc, bool force = false); 46 | 47 | void refresh(); 48 | void check_apply_profile_to_foreground_window(double dt_s); 49 | 50 | process_info fetch_by_name(const std::string& name); 51 | 52 | void dump(); 53 | 54 | void set_borderless(const process_info& info, bool should_move = false, int move_w = 0, int move_h = 0); 55 | void set_bordered(const process_info& info); 56 | bool is_windowed(const process_info& info); 57 | 58 | void handle_mouse_lock(); 59 | 60 | void draw_window(int& found_w); 61 | 62 | void cleanup(); 63 | ~process_manager(); 64 | }; 65 | 66 | 67 | #endif // PROCESS_MANAGER_HPP_INCLUDED 68 | -------------------------------------------------------------------------------- /application_profile.hpp: -------------------------------------------------------------------------------- 1 | #ifndef APPLICATION_PROFILE_HPP_INCLUDED 2 | #define APPLICATION_PROFILE_HPP_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | struct application_profile : serialisable 8 | { 9 | ///not persisted. purely for bookkeeping 10 | bool applied = false; 11 | bool should_apply_immediately = false; 12 | float time_since_detected = 0.f; 13 | 14 | std::string name; 15 | 16 | bool auto_lock_mouse = false; 17 | bool auto_borderless = false; 18 | float init_delay_s = 1.f; 19 | 20 | bool should_move_application = true; 21 | int application_x = 0; 22 | int application_y = 0; 23 | 24 | bool enabled = true; 25 | 26 | virtual void do_serialise(serialise& s, bool ser) override 27 | { 28 | s.handle_serialise(name, ser); 29 | 30 | s.handle_serialise(auto_lock_mouse, ser); 31 | s.handle_serialise(auto_borderless, ser); 32 | s.handle_serialise(init_delay_s, ser); 33 | 34 | s.handle_serialise(should_move_application, ser); 35 | s.handle_serialise(application_x, ser); 36 | s.handle_serialise(application_y, ser); 37 | 38 | s.handle_serialise(enabled, ser); 39 | } 40 | 41 | void draw_window_internals() 42 | { 43 | ImGui::Text(name.c_str()); 44 | 45 | //ImGui::InputFloat("Init Delay (s)", &init_delay_s); 46 | 47 | ImGui::DragFloat("Init Delay (s)", &init_delay_s, 0.1f, 0.001f, 0.f, "%.1f"); 48 | 49 | if(init_delay_s < 0) 50 | init_delay_s = 0; 51 | 52 | if(ImGui::IsItemHovered()) 53 | ImGui::SetTooltip("Delays profile application by this amount after detection. Click and drag to change"); 54 | 55 | ImGui::Checkbox("Auto Confine Mouse", &auto_lock_mouse); 56 | 57 | if(ImGui::IsItemHovered()) 58 | ImGui::SetTooltip("Locks the mouse cursor to the game"); 59 | 60 | ImGui::Checkbox("Auto Borderless", &auto_borderless); 61 | 62 | if(ImGui::IsItemHovered()) 63 | ImGui::SetTooltip("Sets a windowed game to be borderless windowed"); 64 | 65 | ImGui::Checkbox("Move Window?", &should_move_application); 66 | 67 | if(ImGui::IsItemHovered()) 68 | ImGui::SetTooltip("If enabled, moves the game's window to Start x and Start y"); 69 | 70 | if(should_move_application) 71 | { 72 | ImGui::InputInt("Start x", &application_x, 1, 100); 73 | ImGui::InputInt("Start y", &application_y, 1, 100); 74 | } 75 | 76 | ImGui::Checkbox("Enabled", &enabled); 77 | 78 | if(ImGui::IsItemHovered()) 79 | ImGui::SetTooltip("Enable the profile?"); 80 | 81 | should_apply_immediately = ImGui::Button("Force Apply"); 82 | } 83 | 84 | void set_unset() 85 | { 86 | applied = false; 87 | time_since_detected = 0; 88 | } 89 | }; 90 | 91 | #endif // APPLICATION_PROFILE_HPP_INCLUDED 92 | -------------------------------------------------------------------------------- /game_window_manager.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 99 | 100 | -------------------------------------------------------------------------------- /winapi_interop.cpp: -------------------------------------------------------------------------------- 1 | #include "winapi_interop.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct handle_data 10 | { 11 | unsigned long process_id; 12 | HWND best_handle; 13 | }; 14 | 15 | BOOL CALLBACK enum_windows_callback(HWND handle, LPARAM lParam); 16 | BOOL is_main_window(HWND handle); 17 | 18 | HWND find_main_window(unsigned long process_id) 19 | { 20 | handle_data data; 21 | data.process_id = process_id; 22 | data.best_handle = 0; 23 | EnumWindows(enum_windows_callback, (LPARAM)&data); 24 | return data.best_handle; 25 | } 26 | 27 | BOOL CALLBACK enum_windows_callback(HWND handle, LPARAM lParam) 28 | { 29 | handle_data& data = *(handle_data*)lParam; 30 | unsigned long process_id = 0; 31 | GetWindowThreadProcessId(handle, &process_id); 32 | 33 | if (data.process_id != process_id || !is_main_window(handle)) 34 | { 35 | return TRUE; 36 | } 37 | 38 | data.best_handle = handle; 39 | return FALSE; 40 | } 41 | 42 | BOOL is_main_window(HWND handle) 43 | { 44 | return GetWindow(handle, GW_OWNER) == (HWND)0 && IsWindowVisible(handle); 45 | } 46 | 47 | process_info window_handle_to_process_info(HWND window_handle) 48 | { 49 | if(window_handle == NULL) 50 | return process_info(); 51 | 52 | TCHAR szProcessName[MAX_PATH] = TEXT(""); 53 | 54 | DWORD processID; 55 | 56 | GetWindowThreadProcessId(window_handle, &processID); 57 | 58 | HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | 59 | PROCESS_VM_READ, 60 | FALSE, processID ); 61 | 62 | 63 | if (NULL != hProcess ) 64 | { 65 | HMODULE hMod; 66 | DWORD cbNeeded; 67 | 68 | if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), 69 | &cbNeeded) ) 70 | { 71 | GetModuleBaseName( hProcess, hMod, szProcessName, 72 | sizeof(szProcessName)/sizeof(TCHAR) ); 73 | } 74 | } 75 | 76 | process_info info; 77 | info.process_name = szProcessName; 78 | info.handle = window_handle; 79 | info.hProcess = hProcess; 80 | info.processID = processID; 81 | 82 | RECT rect; 83 | GetWindowRect(window_handle, &rect); 84 | 85 | info.w = rect.right - rect.left; 86 | info.h = abs(rect.bottom - rect.top); 87 | 88 | return info; 89 | } 90 | 91 | process_info process_id_to_process_info(DWORD processID) 92 | { 93 | TCHAR szProcessName[MAX_PATH] = TEXT(""); 94 | 95 | HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | 96 | PROCESS_VM_READ, 97 | FALSE, processID ); 98 | 99 | 100 | if (NULL != hProcess ) 101 | { 102 | HMODULE hMod; 103 | DWORD cbNeeded; 104 | 105 | if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), 106 | &cbNeeded) ) 107 | { 108 | GetModuleBaseName( hProcess, hMod, szProcessName, 109 | sizeof(szProcessName)/sizeof(TCHAR) ); 110 | } 111 | } 112 | 113 | HWND handle = find_main_window(processID); 114 | 115 | if(handle == 0) 116 | { 117 | CloseHandle(hProcess); 118 | return process_info(); 119 | } 120 | 121 | process_info info; 122 | info.process_name = szProcessName; 123 | info.handle = handle; 124 | info.hProcess = hProcess; 125 | info.processID = processID; 126 | 127 | RECT rect; 128 | GetWindowRect(handle, &rect); 129 | 130 | info.w = rect.right - rect.left; 131 | info.h = abs(rect.bottom - rect.top); 132 | 133 | return info; 134 | } 135 | 136 | std::vector get_process_infos() 137 | { 138 | DWORD aProcesses[1024], cbNeeded, cProcesses; 139 | unsigned int i; 140 | 141 | if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) 142 | { 143 | return std::vector(); 144 | } 145 | 146 | cProcesses = cbNeeded / sizeof(DWORD); 147 | 148 | std::vector processes; 149 | 150 | for ( i = 0; i < cProcesses; i++ ) 151 | { 152 | if( aProcesses[i] != 0 ) 153 | { 154 | process_info inf = process_id_to_process_info(aProcesses[i]); 155 | 156 | if(!inf.valid()) 157 | continue; 158 | 159 | processes.push_back(inf); 160 | } 161 | } 162 | 163 | return processes; 164 | } 165 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include "application_profile.hpp" 17 | #include "winapi_interop.hpp" 18 | #include "process_manager.hpp" 19 | 20 | int main() 21 | { 22 | sf::RenderWindow window; 23 | sf::ContextSettings settings; 24 | settings.antialiasingLevel = 8; 25 | 26 | window.create(sf::VideoMode(600, 400),"Wowee", sf::Style::Default, settings); 27 | window.setVerticalSyncEnabled(true); 28 | window.setFramerateLimit(60); 29 | 30 | ImGui::SFML::Init(window); 31 | 32 | //ImGui::NewFrame(); 33 | 34 | ImGuiStyle& style = ImGui::GetStyle(); 35 | 36 | style.FrameRounding = 2; 37 | style.WindowRounding = 2; 38 | style.ChildRounding = 2; 39 | style.ChildBorderSize = 0; 40 | style.FrameBorderSize = 0; 41 | style.PopupBorderSize = 0; 42 | style.WindowBorderSize = 0; 43 | 44 | process_manager process_manage; 45 | 46 | sf::Keyboard key; 47 | bool toggled_end_key = false; 48 | bool toggled_f9_key = false; 49 | 50 | sf::Clock ui_clock; 51 | sf::Clock refresh_clock; 52 | sf::Clock save_clock; 53 | sf::Clock apply_clock; 54 | sf::Clock frametime_clock; 55 | 56 | std::ifstream test_file("save_data.bin"); 57 | 58 | if(test_file.good()) 59 | { 60 | serialise ser; 61 | ser.load("save_data.bin"); 62 | 63 | ser.handle_serialise_no_clear(process_manage, false); 64 | } 65 | 66 | bool focused = true; 67 | bool going = true; 68 | 69 | double frametime_s = 0; 70 | 71 | int last_desired_w = window.getSize().x; 72 | 73 | while(going) 74 | { 75 | sf::Event event; 76 | 77 | while(window.pollEvent(event)) 78 | { 79 | ImGui::SFML::ProcessEvent(event); 80 | 81 | if(event.type == sf::Event::Closed) 82 | going = false; 83 | 84 | if(event.type == sf::Event::Resized) 85 | { 86 | window.setSize({event.size.width, event.size.height}); 87 | window.setView(sf::View(sf::FloatRect(0, 0, event.size.width, event.size.height))); 88 | } 89 | 90 | if(event.type == sf::Event::GainedFocus) 91 | { 92 | focused = true; 93 | window.setFramerateLimit(60); 94 | } 95 | 96 | if(event.type == sf::Event::LostFocus) 97 | { 98 | focused = false; 99 | window.setFramerateLimit(5); 100 | } 101 | } 102 | 103 | if(last_desired_w > 100 && abs(last_desired_w - (int)window.getSize().x) > 10) 104 | { 105 | int dx = last_desired_w; 106 | int dy = window.getSize().y; 107 | 108 | window.setSize({(unsigned int)dx, (unsigned int)dy}); 109 | window.setView(sf::View(sf::FloatRect(0, 0, dx, dy))); 110 | } 111 | 112 | ImGui::SFML::Update(window, ui_clock.restart()); 113 | 114 | frametime_s = frametime_clock.restart().asMicroseconds() / 1000. / 1000.; 115 | 116 | if(refresh_clock.getElapsedTime().asSeconds() > 1) 117 | { 118 | refresh_clock.restart(); 119 | 120 | //process_manage.refresh(); 121 | } 122 | 123 | if(save_clock.getElapsedTime().asSeconds() > 1) 124 | { 125 | save_clock.restart(); 126 | 127 | serialise ser; 128 | ser.handle_serialise(process_manage, true); 129 | 130 | ser.save("save_data.bin"); 131 | } 132 | 133 | if(apply_clock.getElapsedTime().asSeconds() > 1) 134 | { 135 | double time_elapsed_s = apply_clock.getElapsedTime().asMicroseconds() / 1000. / 1000.; 136 | 137 | apply_clock.restart(); 138 | 139 | process_manage.check_apply_profile_to_foreground_window(time_elapsed_s); 140 | } 141 | 142 | if(!key.isKeyPressed(sf::Keyboard::End)) 143 | toggled_end_key = false; 144 | 145 | if(key.isKeyPressed(sf::Keyboard::End) && !toggled_end_key && process_manage.use_mouse_lock) 146 | { 147 | toggled_end_key = true; 148 | 149 | process_manage.refresh(); 150 | process_manage.toggle_mouse_lock(); 151 | process_manage.handle_mouse_lock(); 152 | } 153 | 154 | ///TODO: Use a better system for this 155 | if(!key.isKeyPressed(sf::Keyboard::F9)) 156 | toggled_f9_key = false; 157 | 158 | if(key.isKeyPressed(sf::Keyboard::F9) && !toggled_f9_key && process_manage.use_f9_refresh) 159 | { 160 | toggled_f9_key = true; 161 | 162 | process_manage.refresh(); 163 | } 164 | 165 | int desired_w = 0; 166 | process_manage.draw_window(desired_w); 167 | last_desired_w = desired_w; 168 | 169 | if(process_manage.should_quit) 170 | going = false; 171 | 172 | ImGui::SFML::Render(window); 173 | 174 | window.display(); 175 | window.clear(); 176 | 177 | sf::sleep(sf::milliseconds(4)); 178 | } 179 | 180 | serialise ssave; 181 | ssave.handle_serialise(process_manage, true); 182 | ssave.save("save_data.bin"); 183 | 184 | return 0; 185 | } 186 | -------------------------------------------------------------------------------- /makefile.mac: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # This makefile was generated by 'cbp2make' tool rev.147 # 3 | #------------------------------------------------------------------------------# 4 | 5 | 6 | WORKDIR = `pwd` 7 | 8 | CC = gcc 9 | CXX = g++ 10 | AR = ar 11 | LD = g++ 12 | WINDRES = windres 13 | 14 | INC = -Ideps 15 | CFLAGS = -Wall -std=c++1z -fexceptions -DNO_VEC_SUPPORT -DNO_COMPRESSION -DNET_CLIENT -DNO_SFML 16 | RESINC = 17 | LIBDIR = 18 | LIB = 19 | LDFLAGS = -lpsapi -limgui -lsfml-graphics -lsfml-window -lsfml-system -lfreetype -lopengl32 20 | 21 | INC_DEBUG = $(INC) 22 | CFLAGS_DEBUG = $(CFLAGS) -g 23 | RESINC_DEBUG = $(RESINC) 24 | RCFLAGS_DEBUG = $(RCFLAGS) 25 | LIBDIR_DEBUG = $(LIBDIR) 26 | LIB_DEBUG = $(LIB) 27 | LDFLAGS_DEBUG = $(LDFLAGS) 28 | OBJDIR_DEBUG = obj/Debug 29 | DEP_DEBUG = 30 | OUT_DEBUG = bin/Debug/game_window_manager 31 | 32 | INC_RELEASE = $(INC) 33 | CFLAGS_RELEASE = $(CFLAGS) -O2 34 | RESINC_RELEASE = $(RESINC) 35 | RCFLAGS_RELEASE = $(RCFLAGS) 36 | LIBDIR_RELEASE = $(LIBDIR) 37 | LIB_RELEASE = $(LIB) 38 | LDFLAGS_RELEASE = $(LDFLAGS) -s 39 | OBJDIR_RELEASE = obj/Release 40 | DEP_RELEASE = 41 | OUT_RELEASE = bin/Release/game_window_manager 42 | 43 | INC_DEPLOY = $(INC) 44 | CFLAGS_DEPLOY = $(CFLAGS) -O2 45 | RESINC_DEPLOY = $(RESINC) 46 | RCFLAGS_DEPLOY = $(RCFLAGS) 47 | LIBDIR_DEPLOY = $(LIBDIR) 48 | LIB_DEPLOY = $(LIB) 49 | LDFLAGS_DEPLOY = $(LDFLAGS) -s 50 | OBJDIR_DEPLOY = obj/Deploy 51 | DEP_DEPLOY = 52 | OUT_DEPLOY = bin/Deploy/game_window_manager 53 | 54 | OBJ_DEBUG = $(OBJDIR_DEBUG)/deps/funserialisation/serialise.o $(OBJDIR_DEBUG)/main.o $(OBJDIR_DEBUG)/process_manager.o $(OBJDIR_DEBUG)/winapi_interop.o 55 | 56 | OBJ_RELEASE = $(OBJDIR_RELEASE)/deps/funserialisation/serialise.o $(OBJDIR_RELEASE)/main.o $(OBJDIR_RELEASE)/process_manager.o $(OBJDIR_RELEASE)/winapi_interop.o 57 | 58 | OBJ_DEPLOY = $(OBJDIR_DEPLOY)/deps/funserialisation/serialise.o $(OBJDIR_DEPLOY)/main.o $(OBJDIR_DEPLOY)/process_manager.o $(OBJDIR_DEPLOY)/winapi_interop.o 59 | 60 | all: debug release deploy 61 | 62 | clean: clean_debug clean_release clean_deploy 63 | 64 | before_debug: 65 | test -d bin/Debug || mkdir -p bin/Debug 66 | test -d $(OBJDIR_DEBUG)/deps/funserialisation || mkdir -p $(OBJDIR_DEBUG)/deps/funserialisation 67 | test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG) 68 | 69 | after_debug: 70 | 71 | debug: before_debug out_debug after_debug 72 | 73 | out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG) 74 | $(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG) 75 | 76 | $(OBJDIR_DEBUG)/deps/funserialisation/serialise.o: deps/funserialisation/serialise.cpp 77 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c deps/funserialisation/serialise.cpp -o $(OBJDIR_DEBUG)/deps/funserialisation/serialise.o 78 | 79 | $(OBJDIR_DEBUG)/main.o: main.cpp 80 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c main.cpp -o $(OBJDIR_DEBUG)/main.o 81 | 82 | $(OBJDIR_DEBUG)/process_manager.o: process_manager.cpp 83 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c process_manager.cpp -o $(OBJDIR_DEBUG)/process_manager.o 84 | 85 | $(OBJDIR_DEBUG)/winapi_interop.o: winapi_interop.cpp 86 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c winapi_interop.cpp -o $(OBJDIR_DEBUG)/winapi_interop.o 87 | 88 | clean_debug: 89 | rm -f $(OBJ_DEBUG) $(OUT_DEBUG) 90 | rm -rf bin/Debug 91 | rm -rf $(OBJDIR_DEBUG)/deps/funserialisation 92 | rm -rf $(OBJDIR_DEBUG) 93 | 94 | before_release: 95 | test -d bin/Release || mkdir -p bin/Release 96 | test -d $(OBJDIR_RELEASE)/deps/funserialisation || mkdir -p $(OBJDIR_RELEASE)/deps/funserialisation 97 | test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE) 98 | 99 | after_release: 100 | 101 | release: before_release out_release after_release 102 | 103 | out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE) 104 | $(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE) $(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE) 105 | 106 | $(OBJDIR_RELEASE)/deps/funserialisation/serialise.o: deps/funserialisation/serialise.cpp 107 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c deps/funserialisation/serialise.cpp -o $(OBJDIR_RELEASE)/deps/funserialisation/serialise.o 108 | 109 | $(OBJDIR_RELEASE)/main.o: main.cpp 110 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c main.cpp -o $(OBJDIR_RELEASE)/main.o 111 | 112 | $(OBJDIR_RELEASE)/process_manager.o: process_manager.cpp 113 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c process_manager.cpp -o $(OBJDIR_RELEASE)/process_manager.o 114 | 115 | $(OBJDIR_RELEASE)/winapi_interop.o: winapi_interop.cpp 116 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c winapi_interop.cpp -o $(OBJDIR_RELEASE)/winapi_interop.o 117 | 118 | clean_release: 119 | rm -f $(OBJ_RELEASE) $(OUT_RELEASE) 120 | rm -rf bin/Release 121 | rm -rf $(OBJDIR_RELEASE)/deps/funserialisation 122 | rm -rf $(OBJDIR_RELEASE) 123 | 124 | before_deploy: 125 | test -d bin/Deploy || mkdir -p bin/Deploy 126 | test -d $(OBJDIR_DEPLOY)/deps/funserialisation || mkdir -p $(OBJDIR_DEPLOY)/deps/funserialisation 127 | test -d $(OBJDIR_DEPLOY) || mkdir -p $(OBJDIR_DEPLOY) 128 | 129 | after_deploy: 130 | 131 | deploy: before_deploy out_deploy after_deploy 132 | 133 | out_deploy: before_deploy $(OBJ_DEPLOY) $(DEP_DEPLOY) 134 | $(LD) $(LIBDIR_DEPLOY) -o $(OUT_DEPLOY) $(OBJ_DEPLOY) $(LDFLAGS_DEPLOY) $(LIB_DEPLOY) 135 | 136 | $(OBJDIR_DEPLOY)/deps/funserialisation/serialise.o: deps/funserialisation/serialise.cpp 137 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c deps/funserialisation/serialise.cpp -o $(OBJDIR_DEPLOY)/deps/funserialisation/serialise.o 138 | 139 | $(OBJDIR_DEPLOY)/main.o: main.cpp 140 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c main.cpp -o $(OBJDIR_DEPLOY)/main.o 141 | 142 | $(OBJDIR_DEPLOY)/process_manager.o: process_manager.cpp 143 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c process_manager.cpp -o $(OBJDIR_DEPLOY)/process_manager.o 144 | 145 | $(OBJDIR_DEPLOY)/winapi_interop.o: winapi_interop.cpp 146 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c winapi_interop.cpp -o $(OBJDIR_DEPLOY)/winapi_interop.o 147 | 148 | clean_deploy: 149 | rm -f $(OBJ_DEPLOY) $(OUT_DEPLOY) 150 | rm -rf bin/Deploy 151 | rm -rf $(OBJDIR_DEPLOY)/deps/funserialisation 152 | rm -rf $(OBJDIR_DEPLOY) 153 | 154 | .PHONY: before_debug after_debug clean_debug before_release after_release clean_release before_deploy after_deploy clean_deploy 155 | 156 | -------------------------------------------------------------------------------- /makefile.unix: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # This makefile was generated by 'cbp2make' tool rev.147 # 3 | #------------------------------------------------------------------------------# 4 | 5 | 6 | WORKDIR = `pwd` 7 | 8 | CC = gcc 9 | CXX = g++ 10 | AR = ar 11 | LD = g++ 12 | WINDRES = windres 13 | 14 | INC = -Ideps 15 | CFLAGS = -Wall -std=c++1z -fexceptions -DNO_VEC_SUPPORT -DNO_COMPRESSION -DNET_CLIENT -DNO_SFML 16 | RESINC = 17 | LIBDIR = 18 | LIB = 19 | LDFLAGS = -lpsapi -limgui -lsfml-graphics -lsfml-window -lsfml-system -lfreetype -lopengl32 20 | 21 | INC_DEBUG = $(INC) 22 | CFLAGS_DEBUG = $(CFLAGS) -g 23 | RESINC_DEBUG = $(RESINC) 24 | RCFLAGS_DEBUG = $(RCFLAGS) 25 | LIBDIR_DEBUG = $(LIBDIR) 26 | LIB_DEBUG = $(LIB) 27 | LDFLAGS_DEBUG = $(LDFLAGS) 28 | OBJDIR_DEBUG = obj/Debug 29 | DEP_DEBUG = 30 | OUT_DEBUG = bin/Debug/game_window_manager 31 | 32 | INC_RELEASE = $(INC) 33 | CFLAGS_RELEASE = $(CFLAGS) -O2 34 | RESINC_RELEASE = $(RESINC) 35 | RCFLAGS_RELEASE = $(RCFLAGS) 36 | LIBDIR_RELEASE = $(LIBDIR) 37 | LIB_RELEASE = $(LIB) 38 | LDFLAGS_RELEASE = $(LDFLAGS) -s 39 | OBJDIR_RELEASE = obj/Release 40 | DEP_RELEASE = 41 | OUT_RELEASE = bin/Release/game_window_manager 42 | 43 | INC_DEPLOY = $(INC) 44 | CFLAGS_DEPLOY = $(CFLAGS) -O2 45 | RESINC_DEPLOY = $(RESINC) 46 | RCFLAGS_DEPLOY = $(RCFLAGS) 47 | LIBDIR_DEPLOY = $(LIBDIR) 48 | LIB_DEPLOY = $(LIB) 49 | LDFLAGS_DEPLOY = $(LDFLAGS) -s 50 | OBJDIR_DEPLOY = obj/Deploy 51 | DEP_DEPLOY = 52 | OUT_DEPLOY = bin/Deploy/game_window_manager 53 | 54 | OBJ_DEBUG = $(OBJDIR_DEBUG)/deps/funserialisation/serialise.o $(OBJDIR_DEBUG)/main.o $(OBJDIR_DEBUG)/process_manager.o $(OBJDIR_DEBUG)/winapi_interop.o 55 | 56 | OBJ_RELEASE = $(OBJDIR_RELEASE)/deps/funserialisation/serialise.o $(OBJDIR_RELEASE)/main.o $(OBJDIR_RELEASE)/process_manager.o $(OBJDIR_RELEASE)/winapi_interop.o 57 | 58 | OBJ_DEPLOY = $(OBJDIR_DEPLOY)/deps/funserialisation/serialise.o $(OBJDIR_DEPLOY)/main.o $(OBJDIR_DEPLOY)/process_manager.o $(OBJDIR_DEPLOY)/winapi_interop.o 59 | 60 | all: debug release deploy 61 | 62 | clean: clean_debug clean_release clean_deploy 63 | 64 | before_debug: 65 | test -d bin/Debug || mkdir -p bin/Debug 66 | test -d $(OBJDIR_DEBUG)/deps/funserialisation || mkdir -p $(OBJDIR_DEBUG)/deps/funserialisation 67 | test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG) 68 | 69 | after_debug: 70 | 71 | debug: before_debug out_debug after_debug 72 | 73 | out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG) 74 | $(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG) 75 | 76 | $(OBJDIR_DEBUG)/deps/funserialisation/serialise.o: deps/funserialisation/serialise.cpp 77 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c deps/funserialisation/serialise.cpp -o $(OBJDIR_DEBUG)/deps/funserialisation/serialise.o 78 | 79 | $(OBJDIR_DEBUG)/main.o: main.cpp 80 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c main.cpp -o $(OBJDIR_DEBUG)/main.o 81 | 82 | $(OBJDIR_DEBUG)/process_manager.o: process_manager.cpp 83 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c process_manager.cpp -o $(OBJDIR_DEBUG)/process_manager.o 84 | 85 | $(OBJDIR_DEBUG)/winapi_interop.o: winapi_interop.cpp 86 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c winapi_interop.cpp -o $(OBJDIR_DEBUG)/winapi_interop.o 87 | 88 | clean_debug: 89 | rm -f $(OBJ_DEBUG) $(OUT_DEBUG) 90 | rm -rf bin/Debug 91 | rm -rf $(OBJDIR_DEBUG)/deps/funserialisation 92 | rm -rf $(OBJDIR_DEBUG) 93 | 94 | before_release: 95 | test -d bin/Release || mkdir -p bin/Release 96 | test -d $(OBJDIR_RELEASE)/deps/funserialisation || mkdir -p $(OBJDIR_RELEASE)/deps/funserialisation 97 | test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE) 98 | 99 | after_release: 100 | 101 | release: before_release out_release after_release 102 | 103 | out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE) 104 | $(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE) $(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE) 105 | 106 | $(OBJDIR_RELEASE)/deps/funserialisation/serialise.o: deps/funserialisation/serialise.cpp 107 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c deps/funserialisation/serialise.cpp -o $(OBJDIR_RELEASE)/deps/funserialisation/serialise.o 108 | 109 | $(OBJDIR_RELEASE)/main.o: main.cpp 110 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c main.cpp -o $(OBJDIR_RELEASE)/main.o 111 | 112 | $(OBJDIR_RELEASE)/process_manager.o: process_manager.cpp 113 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c process_manager.cpp -o $(OBJDIR_RELEASE)/process_manager.o 114 | 115 | $(OBJDIR_RELEASE)/winapi_interop.o: winapi_interop.cpp 116 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c winapi_interop.cpp -o $(OBJDIR_RELEASE)/winapi_interop.o 117 | 118 | clean_release: 119 | rm -f $(OBJ_RELEASE) $(OUT_RELEASE) 120 | rm -rf bin/Release 121 | rm -rf $(OBJDIR_RELEASE)/deps/funserialisation 122 | rm -rf $(OBJDIR_RELEASE) 123 | 124 | before_deploy: 125 | test -d bin/Deploy || mkdir -p bin/Deploy 126 | test -d $(OBJDIR_DEPLOY)/deps/funserialisation || mkdir -p $(OBJDIR_DEPLOY)/deps/funserialisation 127 | test -d $(OBJDIR_DEPLOY) || mkdir -p $(OBJDIR_DEPLOY) 128 | 129 | after_deploy: 130 | 131 | deploy: before_deploy out_deploy after_deploy 132 | 133 | out_deploy: before_deploy $(OBJ_DEPLOY) $(DEP_DEPLOY) 134 | $(LD) $(LIBDIR_DEPLOY) -o $(OUT_DEPLOY) $(OBJ_DEPLOY) $(LDFLAGS_DEPLOY) $(LIB_DEPLOY) 135 | 136 | $(OBJDIR_DEPLOY)/deps/funserialisation/serialise.o: deps/funserialisation/serialise.cpp 137 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c deps/funserialisation/serialise.cpp -o $(OBJDIR_DEPLOY)/deps/funserialisation/serialise.o 138 | 139 | $(OBJDIR_DEPLOY)/main.o: main.cpp 140 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c main.cpp -o $(OBJDIR_DEPLOY)/main.o 141 | 142 | $(OBJDIR_DEPLOY)/process_manager.o: process_manager.cpp 143 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c process_manager.cpp -o $(OBJDIR_DEPLOY)/process_manager.o 144 | 145 | $(OBJDIR_DEPLOY)/winapi_interop.o: winapi_interop.cpp 146 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c winapi_interop.cpp -o $(OBJDIR_DEPLOY)/winapi_interop.o 147 | 148 | clean_deploy: 149 | rm -f $(OBJ_DEPLOY) $(OUT_DEPLOY) 150 | rm -rf bin/Deploy 151 | rm -rf $(OBJDIR_DEPLOY)/deps/funserialisation 152 | rm -rf $(OBJDIR_DEPLOY) 153 | 154 | .PHONY: before_debug after_debug clean_debug before_release after_release clean_release before_deploy after_deploy clean_deploy 155 | 156 | -------------------------------------------------------------------------------- /makefile.windows: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # This makefile was generated by 'cbp2make' tool rev.147 # 3 | #------------------------------------------------------------------------------# 4 | 5 | 6 | WORKDIR = %cd% 7 | 8 | CC = gcc.exe 9 | CXX = g++.exe 10 | AR = ar.exe 11 | LD = g++.exe 12 | WINDRES = windres.exe 13 | 14 | INC = -Ideps 15 | CFLAGS = -Wall -std=c++1z -fexceptions -DNO_VEC_SUPPORT -DNO_COMPRESSION -DNET_CLIENT -DNO_SFML 16 | RESINC = 17 | LIBDIR = 18 | LIB = 19 | LDFLAGS = -lpsapi -limgui -lsfml-graphics -lsfml-window -lsfml-system -lfreetype -lopengl32 20 | 21 | INC_DEBUG = $(INC) 22 | CFLAGS_DEBUG = $(CFLAGS) -g 23 | RESINC_DEBUG = $(RESINC) 24 | RCFLAGS_DEBUG = $(RCFLAGS) 25 | LIBDIR_DEBUG = $(LIBDIR) 26 | LIB_DEBUG = $(LIB) 27 | LDFLAGS_DEBUG = $(LDFLAGS) 28 | OBJDIR_DEBUG = obj\\Debug 29 | DEP_DEBUG = 30 | OUT_DEBUG = bin\\Debug\\game_window_manager.exe 31 | 32 | INC_RELEASE = $(INC) 33 | CFLAGS_RELEASE = $(CFLAGS) -O2 34 | RESINC_RELEASE = $(RESINC) 35 | RCFLAGS_RELEASE = $(RCFLAGS) 36 | LIBDIR_RELEASE = $(LIBDIR) 37 | LIB_RELEASE = $(LIB) 38 | LDFLAGS_RELEASE = $(LDFLAGS) -s 39 | OBJDIR_RELEASE = obj\\Release 40 | DEP_RELEASE = 41 | OUT_RELEASE = bin\\Release\\game_window_manager.exe 42 | 43 | INC_DEPLOY = $(INC) 44 | CFLAGS_DEPLOY = $(CFLAGS) -O2 45 | RESINC_DEPLOY = $(RESINC) 46 | RCFLAGS_DEPLOY = $(RCFLAGS) 47 | LIBDIR_DEPLOY = $(LIBDIR) 48 | LIB_DEPLOY = $(LIB) 49 | LDFLAGS_DEPLOY = $(LDFLAGS) -s 50 | OBJDIR_DEPLOY = obj\\Deploy 51 | DEP_DEPLOY = 52 | OUT_DEPLOY = bin\\Deploy\\game_window_manager.exe 53 | 54 | OBJ_DEBUG = $(OBJDIR_DEBUG)\\deps\\funserialisation\\serialise.o $(OBJDIR_DEBUG)\\main.o $(OBJDIR_DEBUG)\\process_manager.o $(OBJDIR_DEBUG)\\winapi_interop.o 55 | 56 | OBJ_RELEASE = $(OBJDIR_RELEASE)\\deps\\funserialisation\\serialise.o $(OBJDIR_RELEASE)\\main.o $(OBJDIR_RELEASE)\\process_manager.o $(OBJDIR_RELEASE)\\winapi_interop.o 57 | 58 | OBJ_DEPLOY = $(OBJDIR_DEPLOY)\\deps\\funserialisation\\serialise.o $(OBJDIR_DEPLOY)\\main.o $(OBJDIR_DEPLOY)\\process_manager.o $(OBJDIR_DEPLOY)\\winapi_interop.o 59 | 60 | all: debug release deploy 61 | 62 | clean: clean_debug clean_release clean_deploy 63 | 64 | before_debug: 65 | cmd /c if not exist bin\\Debug md bin\\Debug 66 | cmd /c if not exist $(OBJDIR_DEBUG)\\deps\\funserialisation md $(OBJDIR_DEBUG)\\deps\\funserialisation 67 | cmd /c if not exist $(OBJDIR_DEBUG) md $(OBJDIR_DEBUG) 68 | 69 | after_debug: 70 | 71 | debug: before_debug out_debug after_debug 72 | 73 | out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG) 74 | $(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG) 75 | 76 | $(OBJDIR_DEBUG)\\deps\\funserialisation\\serialise.o: deps\\funserialisation\\serialise.cpp 77 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c deps\\funserialisation\\serialise.cpp -o $(OBJDIR_DEBUG)\\deps\\funserialisation\\serialise.o 78 | 79 | $(OBJDIR_DEBUG)\\main.o: main.cpp 80 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c main.cpp -o $(OBJDIR_DEBUG)\\main.o 81 | 82 | $(OBJDIR_DEBUG)\\process_manager.o: process_manager.cpp 83 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c process_manager.cpp -o $(OBJDIR_DEBUG)\\process_manager.o 84 | 85 | $(OBJDIR_DEBUG)\\winapi_interop.o: winapi_interop.cpp 86 | $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c winapi_interop.cpp -o $(OBJDIR_DEBUG)\\winapi_interop.o 87 | 88 | clean_debug: 89 | cmd /c del /f $(OBJ_DEBUG) $(OUT_DEBUG) 90 | cmd /c rd bin\\Debug 91 | cmd /c rd $(OBJDIR_DEBUG)\\deps\\funserialisation 92 | cmd /c rd $(OBJDIR_DEBUG) 93 | 94 | before_release: 95 | cmd /c if not exist bin\\Release md bin\\Release 96 | cmd /c if not exist $(OBJDIR_RELEASE)\\deps\\funserialisation md $(OBJDIR_RELEASE)\\deps\\funserialisation 97 | cmd /c if not exist $(OBJDIR_RELEASE) md $(OBJDIR_RELEASE) 98 | 99 | after_release: 100 | 101 | release: before_release out_release after_release 102 | 103 | out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE) 104 | $(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE) $(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE) 105 | 106 | $(OBJDIR_RELEASE)\\deps\\funserialisation\\serialise.o: deps\\funserialisation\\serialise.cpp 107 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c deps\\funserialisation\\serialise.cpp -o $(OBJDIR_RELEASE)\\deps\\funserialisation\\serialise.o 108 | 109 | $(OBJDIR_RELEASE)\\main.o: main.cpp 110 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c main.cpp -o $(OBJDIR_RELEASE)\\main.o 111 | 112 | $(OBJDIR_RELEASE)\\process_manager.o: process_manager.cpp 113 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c process_manager.cpp -o $(OBJDIR_RELEASE)\\process_manager.o 114 | 115 | $(OBJDIR_RELEASE)\\winapi_interop.o: winapi_interop.cpp 116 | $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c winapi_interop.cpp -o $(OBJDIR_RELEASE)\\winapi_interop.o 117 | 118 | clean_release: 119 | cmd /c del /f $(OBJ_RELEASE) $(OUT_RELEASE) 120 | cmd /c rd bin\\Release 121 | cmd /c rd $(OBJDIR_RELEASE)\\deps\\funserialisation 122 | cmd /c rd $(OBJDIR_RELEASE) 123 | 124 | before_deploy: 125 | cmd /c if not exist bin\\Deploy md bin\\Deploy 126 | cmd /c if not exist $(OBJDIR_DEPLOY)\\deps\\funserialisation md $(OBJDIR_DEPLOY)\\deps\\funserialisation 127 | cmd /c if not exist $(OBJDIR_DEPLOY) md $(OBJDIR_DEPLOY) 128 | 129 | after_deploy: 130 | 131 | deploy: before_deploy out_deploy after_deploy 132 | 133 | out_deploy: before_deploy $(OBJ_DEPLOY) $(DEP_DEPLOY) 134 | $(LD) $(LIBDIR_DEPLOY) -o $(OUT_DEPLOY) $(OBJ_DEPLOY) $(LDFLAGS_DEPLOY) -mwindows $(LIB_DEPLOY) 135 | 136 | $(OBJDIR_DEPLOY)\\deps\\funserialisation\\serialise.o: deps\\funserialisation\\serialise.cpp 137 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c deps\\funserialisation\\serialise.cpp -o $(OBJDIR_DEPLOY)\\deps\\funserialisation\\serialise.o 138 | 139 | $(OBJDIR_DEPLOY)\\main.o: main.cpp 140 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c main.cpp -o $(OBJDIR_DEPLOY)\\main.o 141 | 142 | $(OBJDIR_DEPLOY)\\process_manager.o: process_manager.cpp 143 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c process_manager.cpp -o $(OBJDIR_DEPLOY)\\process_manager.o 144 | 145 | $(OBJDIR_DEPLOY)\\winapi_interop.o: winapi_interop.cpp 146 | $(CXX) $(CFLAGS_DEPLOY) $(INC_DEPLOY) -c winapi_interop.cpp -o $(OBJDIR_DEPLOY)\\winapi_interop.o 147 | 148 | clean_deploy: 149 | cmd /c del /f $(OBJ_DEPLOY) $(OUT_DEPLOY) 150 | cmd /c rd bin\\Deploy 151 | cmd /c rd $(OBJDIR_DEPLOY)\\deps\\funserialisation 152 | cmd /c rd $(OBJDIR_DEPLOY) 153 | 154 | .PHONY: before_debug after_debug clean_debug before_release after_release clean_release before_deploy after_deploy clean_deploy 155 | 156 | -------------------------------------------------------------------------------- /process_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "process_manager.hpp" 2 | #include "process_info.hpp" 3 | #include "winapi_interop.hpp" 4 | #include 5 | 6 | process_manager::process_manager() 7 | { 8 | refresh(); 9 | } 10 | 11 | std::optional> process_manager::fetch_profile_by_name(const std::string& name) 12 | { 13 | for(auto& i :profiles) 14 | { 15 | if(i.name == name) 16 | return i; 17 | } 18 | 19 | return std::nullopt; 20 | } 21 | 22 | void process_manager::toggle_mouse_lock() 23 | { 24 | lock_mouse_to_window = !lock_mouse_to_window; 25 | } 26 | 27 | void process_manager::apply_profile(application_profile& prof, process_info& proc, bool force) 28 | { 29 | if(prof.applied && !force) 30 | return; 31 | 32 | if(!prof.enabled && !force) 33 | return; 34 | 35 | prof.applied = true; 36 | 37 | if(prof.auto_borderless) 38 | { 39 | set_borderless(proc, prof.should_move_application, prof.application_x, prof.application_y); 40 | } 41 | 42 | if(!prof.auto_borderless && prof.should_move_application) 43 | { 44 | proc.refresh(true, prof.application_x, prof.application_y); 45 | } 46 | 47 | Sleep(100); 48 | 49 | ///this doesn't work when we also set the window borderless 50 | ///why not? 51 | ///might be because i'm testing on my own window, and it doesn't redraw 52 | if(prof.auto_lock_mouse) 53 | { 54 | proc.lock_mouse_to(); 55 | 56 | lock_mouse_to_window = true; 57 | 58 | printf("Confine Mouse\n"); 59 | } 60 | 61 | printf("applied profile\n"); 62 | } 63 | 64 | void process_manager::refresh() 65 | { 66 | cleanup(); 67 | 68 | processes = get_process_infos(); 69 | 70 | auto desk_dim = sf::VideoMode::getDesktopMode(); 71 | 72 | dwidth = desk_dim.width; 73 | dheight = desk_dim.height; 74 | 75 | ///we need to go through all the profiles afterwards and set applied to false for any 76 | ///processes that don't exist, so that we'll apply this to a process on a relaunch 77 | for(process_info& proc : processes) 78 | { 79 | std::optional opt_profile = fetch_profile_by_name(proc.process_name); 80 | 81 | if(!opt_profile.has_value()) 82 | continue; 83 | 84 | std::cout << "hello prof " << proc.process_name << std::endl; 85 | 86 | auto ref_profile = *opt_profile; 87 | 88 | apply_profile(ref_profile.get(), proc); 89 | } 90 | } 91 | 92 | void process_manager::check_apply_profile_to_foreground_window(double dt_s) 93 | { 94 | HWND handle = GetForegroundWindow(); 95 | 96 | process_info proc = window_handle_to_process_info(handle); 97 | 98 | if(!proc.valid()) 99 | { 100 | for(application_profile& prof : profiles) 101 | { 102 | prof.set_unset(); 103 | } 104 | 105 | return; 106 | } 107 | 108 | printf("checking\n"); 109 | 110 | for(application_profile& prof : profiles) 111 | { 112 | if(prof.name == proc.process_name) 113 | { 114 | if(prof.applied) 115 | continue; 116 | 117 | std::cout << "Not applied to " << prof.name << std::endl; 118 | 119 | prof.time_since_detected += dt_s; 120 | 121 | if(prof.time_since_detected < prof.init_delay_s) 122 | continue; 123 | 124 | std::cout << "applying" << std::endl; 125 | 126 | apply_profile(prof, proc); 127 | } 128 | 129 | if(prof.name != proc.process_name) 130 | { 131 | prof.set_unset(); 132 | } 133 | } 134 | } 135 | 136 | process_info process_manager::fetch_by_name(const std::string& name) 137 | { 138 | for(auto& i : processes) 139 | { 140 | if(i.process_name == name) 141 | return i; 142 | } 143 | 144 | return process_info(); 145 | } 146 | 147 | void process_manager::dump() 148 | { 149 | for(process_info& inf : processes) 150 | { 151 | printf("%s %lu %li\n", inf.process_name.c_str(), inf.handle, inf.hProcess); 152 | } 153 | } 154 | 155 | void process_manager::set_borderless(const process_info& info, bool should_move, int move_w, int move_h) 156 | { 157 | if(!info.valid()) 158 | { 159 | printf("Invalid window borderless\n"); 160 | return; 161 | } 162 | 163 | info.dump_styles(); 164 | 165 | auto original_style = info.get_style(); 166 | original_style &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU); 167 | 168 | info.set_style(original_style); 169 | 170 | auto original_ex_style = info.get_ex_style(); 171 | original_ex_style &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE); 172 | 173 | info.set_ex_style(original_ex_style); 174 | 175 | info.refresh(should_move, move_w, move_h); 176 | 177 | info.dump_styles(); 178 | } 179 | 180 | void process_manager::set_bordered(const process_info& info) 181 | { 182 | if(!info.valid()) 183 | { 184 | printf("Invalid window bordered\n"); 185 | return; 186 | } 187 | 188 | info.dump_styles(); 189 | 190 | auto original_style = info.get_style(); 191 | original_style |= (WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU); 192 | 193 | info.set_style(original_style); 194 | 195 | auto original_ex_style = info.get_ex_style(); 196 | original_ex_style |= (WS_EX_DLGMODALFRAME);// | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE); 197 | 198 | info.set_ex_style(original_ex_style); 199 | 200 | info.refresh(); 201 | 202 | info.dump_styles(); 203 | } 204 | 205 | bool process_manager::is_windowed(const process_info& info) 206 | { 207 | if(!info.valid()) 208 | { 209 | printf("Invalid window windowed\n"); 210 | return false; 211 | } 212 | 213 | ///hack in lieu of something better 214 | if(info.process_name == "explorer.exe" || info.process_name == "explorer.EXE") 215 | return false; 216 | 217 | auto style = info.get_style(); 218 | 219 | return ((style & WS_CAPTION) > 0); 220 | } 221 | 222 | void process_manager::handle_mouse_lock() 223 | { 224 | ///below logic can be used to lock the mouse to a specific application 225 | ///currently using global locking until we have profiles 226 | /*process_info info = fetch_by_name(last_managed_window); 227 | 228 | if(!lock_mouse_to_window || last_managed_window == "" || !info.valid()) 229 | { 230 | ClipCursor(nullptr); 231 | return; 232 | } 233 | 234 | RECT wrect; 235 | 236 | GetWindowRect(info.handle, &wrect); 237 | 238 | ClipCursor(&wrect);*/ 239 | 240 | if(!lock_mouse_to_window) 241 | { 242 | ClipCursor(nullptr); 243 | return; 244 | } 245 | 246 | HWND hwnd = GetForegroundWindow(); 247 | 248 | RECT wrect; 249 | 250 | GetWindowRect(hwnd, &wrect); 251 | 252 | ClipCursor(&wrect); 253 | } 254 | 255 | void process_manager::draw_window(int& found_w) 256 | { 257 | ImGui::SetNextWindowPos(ImVec2(0, 0)); 258 | 259 | ImGui::Begin("Applications", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar); 260 | 261 | std::vector process_names; 262 | std::vector display_names; 263 | std::vector is_profiles_list; 264 | 265 | for(auto& i : processes) 266 | { 267 | if(!is_windowed(fetch_by_name(i.process_name)) && only_show_windowed && !fetch_profile_by_name(i.process_name).has_value()) 268 | continue; 269 | 270 | process_names.push_back(i.process_name); 271 | display_names.push_back(i.process_name); 272 | is_profiles_list.push_back(0); 273 | } 274 | 275 | for(application_profile& i : profiles) 276 | { 277 | process_names.push_back(i.name); 278 | display_names.push_back(i.name + " (saved)"); 279 | is_profiles_list.push_back(1); 280 | } 281 | 282 | if(imgui_current_item >= (int)process_names.size()) 283 | imgui_current_item = ((int)process_names.size())-1; 284 | 285 | if(imgui_current_item < 0) 286 | imgui_current_item = 0; 287 | 288 | std::vector names; 289 | 290 | for(auto& i : display_names) 291 | { 292 | names.push_back(i.c_str()); 293 | } 294 | 295 | std::string current_process_name; 296 | bool is_profile = false; 297 | 298 | if(process_names.size() > 0) 299 | { 300 | 301 | ImGui::PushItemWidth(300); 302 | ImGui::ListBox("###Window", &imgui_current_item, &names[0], names.size()); 303 | 304 | current_process_name = process_names[imgui_current_item]; 305 | is_profile = is_profiles_list[imgui_current_item]; 306 | } 307 | 308 | ImGui::Checkbox("Only Show Windowed Applications", &only_show_windowed); 309 | 310 | ImGui::Checkbox("Use End to lock mouse to window", &use_mouse_lock); 311 | 312 | ImGui::Checkbox("Refresh on f9", &use_f9_refresh); 313 | 314 | if(process_names.size() > 0) 315 | { 316 | if(!is_profile) 317 | { 318 | if(ImGui::Button("Make Windowed")) 319 | { 320 | set_bordered(fetch_by_name(current_process_name)); 321 | 322 | last_managed_window = current_process_name; 323 | } 324 | 325 | if(ImGui::Button("Make Borderless")) 326 | { 327 | set_borderless(fetch_by_name(current_process_name), false); 328 | 329 | last_managed_window = current_process_name; 330 | } 331 | 332 | if(ImGui::Button("Make Borderless, set to top left")) 333 | { 334 | set_borderless(fetch_by_name(current_process_name), true); 335 | 336 | last_managed_window = current_process_name; 337 | } 338 | 339 | if(!fetch_profile_by_name(current_process_name).has_value() && ImGui::Button("Create Profile")) 340 | { 341 | application_profile prof; 342 | prof.name = current_process_name; 343 | 344 | profiles.push_back(prof); 345 | } 346 | } 347 | 348 | if(fetch_profile_by_name(current_process_name).has_value() && ImGui::Button("Delete Profile")) 349 | { 350 | for(int i=0; i < (int)profiles.size(); i++) 351 | { 352 | if(profiles[i].name == current_process_name) 353 | { 354 | profiles.erase(profiles.begin() + i); 355 | break; 356 | } 357 | } 358 | } 359 | } 360 | 361 | if(ImGui::Button("Refresh")) 362 | { 363 | refresh(); 364 | } 365 | 366 | if(ImGui::Button("Quit")) 367 | { 368 | should_quit = true; 369 | } 370 | 371 | int window_w = ImGui::GetWindowWidth(); 372 | 373 | found_w += window_w; 374 | 375 | ImGui::End(); 376 | 377 | ImGui::SetNextWindowPos(ImVec2(window_w, 0)); 378 | ImGui::Begin("Profiles", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar); 379 | 380 | bool success = false; 381 | 382 | if(process_names.size() > 0) 383 | { 384 | std::optional opt_profile = fetch_profile_by_name(current_process_name); 385 | 386 | if(opt_profile.has_value()) 387 | { 388 | auto ref_profile = *opt_profile; 389 | 390 | ref_profile.get().draw_window_internals(); 391 | 392 | if(ref_profile.get().should_apply_immediately) 393 | { 394 | auto proc_info = fetch_by_name(ref_profile.get().name); 395 | 396 | apply_profile(ref_profile.get(), proc_info, true); 397 | } 398 | 399 | success = true; 400 | } 401 | } 402 | 403 | if(!success) 404 | { 405 | ///yup 406 | ImGui::Text(" "); 407 | } 408 | 409 | found_w += ImGui::GetWindowWidth(); 410 | 411 | ImGui::End(); 412 | } 413 | 414 | void process_manager::cleanup() 415 | { 416 | for(process_info& info : processes) 417 | { 418 | CloseHandle(info.handle); 419 | CloseHandle(info.hProcess); 420 | } 421 | } 422 | 423 | process_manager::~process_manager() 424 | { 425 | cleanup(); 426 | } 427 | --------------------------------------------------------------------------------