From 4e12802f4679a94a78e4038fcfcffb4a6986e85e Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 10 Jul 2019 02:42:43 +1000 Subject: [PATCH] (almost) support reading components in launcher not really complete imo because it requires modification of the components file --- data/plugins/components.ini | 1 + source/plugins/Launcher/framework.h | 52 ++++++++ source/plugins/Launcher/ui.h | 178 +++------------------------- 3 files changed, 71 insertions(+), 160 deletions(-) diff --git a/data/plugins/components.ini b/data/plugins/components.ini index beaf33b..d0d0c71 100644 --- a/data/plugins/components.ini +++ b/data/plugins/components.ini @@ -1,5 +1,6 @@ # components.ini # defines which components will be enabled +[components] # emulates game input through mouse and keyboard. # controls can be set inside the keyconfig.ini file. diff --git a/source/plugins/Launcher/framework.h b/source/plugins/Launcher/framework.h index d4f639f..2ea4789 100644 --- a/source/plugins/Launcher/framework.h +++ b/source/plugins/Launcher/framework.h @@ -32,6 +32,9 @@ LPWSTR DIVA_EXECUTABLE_LAUNCH = const_cast(DIVA_EXECUTABLE_LAUNCH_STRING wstring CONFIG_FILE_STRING = DirPath() + L"\\plugins\\config.ini"; LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); +wstring COMPONENTS_FILE_STRING = DirPath() + L"\\plugins\\components.ini"; +LPCWSTR COMPONENTS_FILE = COMPONENTS_FILE_STRING.c_str(); + int nDisplay = GetPrivateProfileIntW(L"resolution", L"display", 0, CONFIG_FILE); int nWidth = GetPrivateProfileIntW(L"resolution", L"width", 1280, CONFIG_FILE); int nHeight = GetPrivateProfileIntW(L"resolution", L"height", 720, CONFIG_FILE); @@ -58,3 +61,52 @@ int nMLAA = GetPrivateProfileIntW(L"graphics", L"MLAA", TRUE, CONFIG_FILE); int nFPSLimit = GetPrivateProfileIntW(L"graphics", L"FPS.Limit", 0, CONFIG_FILE); int nSkipLauncher = GetPrivateProfileIntW(L"launcher", L"skip", FALSE, CONFIG_FILE); + + +// Custom function. Works like GetPrivateProfileIntW but returns bool. Can detect a numeric value or string. +bool GetPrivateProfileBoolW(LPCWSTR lpAppName, LPCWSTR lpKeyName, bool default, LPCWSTR lpFileName) +{ + wchar_t buffer[8]; + GetPrivateProfileStringW(lpAppName, lpKeyName, L"", buffer, 8, lpFileName); + //MessageBoxW(NULL, buffer, NULL, 0); + + for (wchar_t& chr : buffer) + chr = towlower(chr); + + bool out; + if ((lstrcmpW(buffer, L"true") == 0) || (lstrcmpW(buffer, L"1") == 0)) + out = true; + else if ((lstrcmpW(buffer, L"false") == 0) || (lstrcmpW(buffer, L"0") == 0)) + out = false; + else + out = default; + + return out; +} + +struct componentInfo { const LPCWSTR name; LPCWSTR friendlyName; LPCWSTR description; System::IntPtr cb; }; +componentInfo componentsArray[] = { + { L"input_emulator", L"Input Emulator", L"Emulates input through keyboard and/or mouse.", System::IntPtr::Zero }, + { L"touch_slider_emulator", L"Slider Emulator", L"Emulates slider through keyboard and/or mouse.", System::IntPtr::Zero }, + { L"touch_panel_emulator", L"Touch Panel Emulator", L"Emulates touch panel through mouse.", System::IntPtr::Zero }, + + { L"sys_timer", L"Timer Freeze", L"Freezes the PV select timer at 39 seconds.", System::IntPtr::Zero }, + + { L"player_data_manager", L"Player Data Manager", L"Loads user-defined values into the PlayerData struct.\nRequired for modules and game mode modifiers.", System::IntPtr::Zero }, + + { L"frame_rate_manager", L"Frame Rate Manager", L"Adjusts animations to the correct speed at different frame rates.\nOnly needed when FPS isn't locket at 60.", System::IntPtr::Zero }, + + { L"stage_manager", L"Stage Manager", L"Allows for playing unlimited songs per session.", System::IntPtr::Zero }, + + { L"fast_loader", L"Fast Loader", L"Skip or speed up unnecessary loading steps.", System::IntPtr::Zero }, + + { L"camera_controller", L"Camera Controller", L"Enables freecam (toggled using F3).\nWASD to move, SPACE/CTRL for up/down, Q/R to rotate, R/F for zoom.\nHolding SHIFT/ALT changes control speed.", System::IntPtr::Zero }, + + { L"scale_component", L"Scale Component", L"Scales the graphics output framebuffer to fill the screen/window.", System::IntPtr::Zero }, + + { L"debug_component", L"Debug Component", L"Allows for changing game state (F4-F8 keys), using dev GUI and tests, and speeding up 2d animations/menus (hold SHIFT+TAB).", System::IntPtr::Zero }, + + { L"fps_limiter", L"FPS Limiter", L"Lets you set a framerate cap. The value of the limit is in the options tab.", System::IntPtr::Zero }, + + { L"target_inspector", L"Target Inspector", L"Enables hold transfers.", System::IntPtr::Zero }, +}; \ No newline at end of file diff --git a/source/plugins/Launcher/ui.h b/source/plugins/Launcher/ui.h index 53bcadf..6d7717d 100644 --- a/source/plugins/Launcher/ui.h +++ b/source/plugins/Launcher/ui.h @@ -27,8 +27,25 @@ namespace Launcher { this->ClientSize = Drawing::Size(444, 323); TabPadding^ tabpad = gcnew TabPadding(tabControl); + this->panel_Components->SuspendLayout(); // Beta version, components not working yet and tab disabled tabPage_Components->Enabled = false; + int componentsY = 3; + for (componentInfo& component : componentsArray) + { + CheckBox^ cb = gcnew CheckBox(); + cb->Text = gcnew String(component.friendlyName); + cb->Checked = GetPrivateProfileBoolW(L"components", component.name, false, COMPONENTS_FILE); + cb->Left = 3; + cb->Top = componentsY; + cb->AutoSize = true; + cb->FlatStyle = System::Windows::Forms::FlatStyle::Flat; + panel_Components->Controls->Add(cb); + component.cb = cb->Handle; + componentsY += 23; + } + this->panel_Components->ResumeLayout(false); + this->panel_Components->PerformLayout(); comboBox_Display->SelectedIndex = nDisplay; @@ -129,20 +146,9 @@ namespace Launcher { private: System::Windows::Forms::GroupBox^ groupBox_InternalRes; private: System::Windows::Forms::CheckBox^ checkBox_InternalRes; private: System::Windows::Forms::TabPage^ tabPage_Components; - private: System::Windows::Forms::CheckBox^ checkBox_sys_timer; - private: System::Windows::Forms::CheckBox^ checkBox_touch_panel_emulator; - private: System::Windows::Forms::CheckBox^ checkBox_touch_slider_emulator; - private: System::Windows::Forms::CheckBox^ checkBox_input_emulator; - private: System::Windows::Forms::CheckBox^ checkBox_player_data_manager; - private: System::Windows::Forms::CheckBox^ checkBox_frame_rate_manager; - private: System::Windows::Forms::CheckBox^ checkBox_stage_manager; - private: System::Windows::Forms::CheckBox^ checkBox_fast_loader; - private: System::Windows::Forms::CheckBox^ checkBox_camera_controller; private: System::Windows::Forms::Panel^ panel_Components; - private: System::Windows::Forms::CheckBox^ checkBox_scale_component; - private: System::Windows::Forms::CheckBox^ checkBox_fps_limiter; private: System::Windows::Forms::TabPage^ tabPage_Patches; private: System::Windows::Forms::Panel^ panel_Patches; @@ -192,7 +198,7 @@ private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel_Status; private: System::Windows::Forms::CheckBox^ checkBox_NoMovies; -private: System::Windows::Forms::Label^ label_Soon; + private: System::Windows::Forms::Button^ button_github; private: System::Windows::Forms::CheckBox^ checkBox_DisableErrorBanner; private: System::Windows::Forms::CheckBox^ checkBox_SkipLauncher; @@ -262,18 +268,6 @@ private: System::Windows::Forms::Label^ label_BitDepth; this->checkBox_NoPVUi = (gcnew System::Windows::Forms::CheckBox()); this->tabPage_Components = (gcnew System::Windows::Forms::TabPage()); this->panel_Components = (gcnew System::Windows::Forms::Panel()); - this->label_Soon = (gcnew System::Windows::Forms::Label()); - this->checkBox_fps_limiter = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_scale_component = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_camera_controller = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_input_emulator = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_fast_loader = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_touch_slider_emulator = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_stage_manager = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_touch_panel_emulator = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_frame_rate_manager = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_sys_timer = (gcnew System::Windows::Forms::CheckBox()); - this->checkBox_player_data_manager = (gcnew System::Windows::Forms::CheckBox()); this->button_Discord = (gcnew System::Windows::Forms::Button()); this->button_github = (gcnew System::Windows::Forms::Button()); this->groupBox_ScreenRes->SuspendLayout(); @@ -288,7 +282,6 @@ private: System::Windows::Forms::Label^ label_BitDepth; this->tableLayoutPanel_FPSLimit->SuspendLayout(); this->tableLayoutPanel_Status->SuspendLayout(); this->tabPage_Components->SuspendLayout(); - this->panel_Components->SuspendLayout(); this->SuspendLayout(); // // button_Launch @@ -783,144 +776,11 @@ private: System::Windows::Forms::Label^ label_BitDepth; // panel_Components // this->panel_Components->AutoScroll = true; - this->panel_Components->Controls->Add(this->label_Soon); - this->panel_Components->Controls->Add(this->checkBox_fps_limiter); - this->panel_Components->Controls->Add(this->checkBox_scale_component); - this->panel_Components->Controls->Add(this->checkBox_camera_controller); - this->panel_Components->Controls->Add(this->checkBox_input_emulator); - this->panel_Components->Controls->Add(this->checkBox_fast_loader); - this->panel_Components->Controls->Add(this->checkBox_touch_slider_emulator); - this->panel_Components->Controls->Add(this->checkBox_stage_manager); - this->panel_Components->Controls->Add(this->checkBox_touch_panel_emulator); - this->panel_Components->Controls->Add(this->checkBox_frame_rate_manager); - this->panel_Components->Controls->Add(this->checkBox_sys_timer); - this->panel_Components->Controls->Add(this->checkBox_player_data_manager); this->panel_Components->Location = System::Drawing::Point(0, 0); this->panel_Components->Name = L"panel_Components"; this->panel_Components->Size = System::Drawing::Size(225, 232); this->panel_Components->TabIndex = 0; // - // label_Soon - // - this->label_Soon->AutoSize = true; - this->label_Soon->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->label_Soon->Location = System::Drawing::Point(3, 3); - this->label_Soon->Name = L"label_Soon"; - this->label_Soon->Size = System::Drawing::Size(143, 52); - this->label_Soon->TabIndex = 12; - this->label_Soon->Text = L"Options not yet available\r\nthrough the launcher.\r\nPlease use \"components.ini\"\r\nin" - L"side the \"plugins\" folder."; - // - // checkBox_fps_limiter - // - this->checkBox_fps_limiter->AutoSize = true; - this->checkBox_fps_limiter->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_fps_limiter->Location = System::Drawing::Point(6, 277); - this->checkBox_fps_limiter->Name = L"checkBox_fps_limiter"; - this->checkBox_fps_limiter->Size = System::Drawing::Size(76, 17); - this->checkBox_fps_limiter->TabIndex = 10; - this->checkBox_fps_limiter->Text = L"FPS Limiter"; - // - // checkBox_scale_component - // - this->checkBox_scale_component->AutoSize = true; - this->checkBox_scale_component->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_scale_component->Location = System::Drawing::Point(6, 253); - this->checkBox_scale_component->Name = L"checkBox_scale_component"; - this->checkBox_scale_component->Size = System::Drawing::Size(107, 17); - this->checkBox_scale_component->TabIndex = 9; - this->checkBox_scale_component->Text = L"Scale Component"; - // - // checkBox_camera_controller - // - this->checkBox_camera_controller->AutoSize = true; - this->checkBox_camera_controller->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_camera_controller->Location = System::Drawing::Point(6, 230); - this->checkBox_camera_controller->Name = L"checkBox_camera_controller"; - this->checkBox_camera_controller->Size = System::Drawing::Size(106, 17); - this->checkBox_camera_controller->TabIndex = 8; - this->checkBox_camera_controller->Text = L"Camera Controller"; - // - // checkBox_input_emulator - // - this->checkBox_input_emulator->AutoSize = true; - this->checkBox_input_emulator->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_input_emulator->Location = System::Drawing::Point(6, 35); - this->checkBox_input_emulator->Name = L"checkBox_input_emulator"; - this->checkBox_input_emulator->Size = System::Drawing::Size(91, 17); - this->checkBox_input_emulator->TabIndex = 0; - this->checkBox_input_emulator->Text = L"Input Emulator"; - // - // checkBox_fast_loader - // - this->checkBox_fast_loader->AutoSize = true; - this->checkBox_fast_loader->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_fast_loader->Location = System::Drawing::Point(6, 207); - this->checkBox_fast_loader->Name = L"checkBox_fast_loader"; - this->checkBox_fast_loader->Size = System::Drawing::Size(79, 17); - this->checkBox_fast_loader->TabIndex = 7; - this->checkBox_fast_loader->Text = L"Fast Loader"; - // - // checkBox_touch_slider_emulator - // - this->checkBox_touch_slider_emulator->AutoSize = true; - this->checkBox_touch_slider_emulator->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_touch_slider_emulator->Location = System::Drawing::Point(6, 69); - this->checkBox_touch_slider_emulator->Name = L"checkBox_touch_slider_emulator"; - this->checkBox_touch_slider_emulator->Size = System::Drawing::Size(128, 17); - this->checkBox_touch_slider_emulator->TabIndex = 1; - this->checkBox_touch_slider_emulator->Text = L"Touch Panel Emulator"; - // - // checkBox_stage_manager - // - this->checkBox_stage_manager->AutoSize = true; - this->checkBox_stage_manager->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_stage_manager->Location = System::Drawing::Point(6, 184); - this->checkBox_stage_manager->Name = L"checkBox_stage_manager"; - this->checkBox_stage_manager->Size = System::Drawing::Size(96, 17); - this->checkBox_stage_manager->TabIndex = 6; - this->checkBox_stage_manager->Text = L"Stage Manager"; - // - // checkBox_touch_panel_emulator - // - this->checkBox_touch_panel_emulator->AutoSize = true; - this->checkBox_touch_panel_emulator->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_touch_panel_emulator->Location = System::Drawing::Point(6, 92); - this->checkBox_touch_panel_emulator->Name = L"checkBox_touch_panel_emulator"; - this->checkBox_touch_panel_emulator->Size = System::Drawing::Size(127, 17); - this->checkBox_touch_panel_emulator->TabIndex = 2; - this->checkBox_touch_panel_emulator->Text = L"Touch Slider Emulator"; - // - // checkBox_frame_rate_manager - // - this->checkBox_frame_rate_manager->AutoSize = true; - this->checkBox_frame_rate_manager->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_frame_rate_manager->Location = System::Drawing::Point(6, 161); - this->checkBox_frame_rate_manager->Name = L"checkBox_frame_rate_manager"; - this->checkBox_frame_rate_manager->Size = System::Drawing::Size(123, 17); - this->checkBox_frame_rate_manager->TabIndex = 5; - this->checkBox_frame_rate_manager->Text = L"Frame Rate Manager"; - // - // checkBox_sys_timer - // - this->checkBox_sys_timer->AutoSize = true; - this->checkBox_sys_timer->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_sys_timer->Location = System::Drawing::Point(6, 115); - this->checkBox_sys_timer->Name = L"checkBox_sys_timer"; - this->checkBox_sys_timer->Size = System::Drawing::Size(117, 17); - this->checkBox_sys_timer->TabIndex = 3; - this->checkBox_sys_timer->Text = L"Freeze Select Timer"; - // - // checkBox_player_data_manager - // - this->checkBox_player_data_manager->AutoSize = true; - this->checkBox_player_data_manager->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->checkBox_player_data_manager->Location = System::Drawing::Point(6, 138); - this->checkBox_player_data_manager->Name = L"checkBox_player_data_manager"; - this->checkBox_player_data_manager->Size = System::Drawing::Size(123, 17); - this->checkBox_player_data_manager->TabIndex = 4; - this->checkBox_player_data_manager->Text = L"Player Data Manager"; - // // button_Discord // this->button_Discord->BackColor = System::Drawing::Color::Transparent; @@ -997,8 +857,6 @@ private: System::Windows::Forms::Label^ label_BitDepth; this->tableLayoutPanel_Status->ResumeLayout(false); this->tableLayoutPanel_Status->PerformLayout(); this->tabPage_Components->ResumeLayout(false); - this->panel_Components->ResumeLayout(false); - this->panel_Components->PerformLayout(); this->ResumeLayout(false); }