1111#include < map>
1212#include < locale>
1313
14+ #include < fstream>
15+
16+ // SDL
17+ #include < SDL3/SDL_dialog.h>
18+
1419// ImGUI
1520#include < imgui.h>
1621#include < misc/cpp/imgui_stdlib.h>
1924#include " window_main.h" // Primary header for this implementation file
2025#include " amd_gpu_profilemanager_db.h"
2126#include " amd_gpu_profilemanager_utils.h"
27+ #include " amd_gpu_profilemanager_application.h"
28+ #include " amd_gpu_profilemanager_profile.h"
29+ #include " amd_gpu_profilemanager_property.h"
30+ #include " amd_gpu_profilemanager_use.h"
31+ #include < nlohmann/json.hpp>
2232
2333
2434
@@ -57,6 +67,7 @@ namespace OST::AMD::GPU::ProfileManager {
5767
5868
5969
70+
6071 //
6172 // DB
6273 //
@@ -92,6 +103,21 @@ namespace OST::AMD::GPU::ProfileManager {
92103 m_db_cache_dirty = false ;
93104 }
94105
106+ void WindowMain::dbSaveCallback (void * userdata, const char * const * files, int filte) {
107+ if (!files[0 ]) {
108+ return ;
109+ }
110+ auto * cls = reinterpret_cast <WindowMain*>(userdata);
111+ auto filepath = std::filesystem::path (files[0 ]);
112+ filepath.replace_extension (" json" );
113+ cls->m_db [cls->m_current_db_source ]->SaveJson (filepath);
114+ }
115+
116+ void WindowMain::dbSave () {
117+ SDL_Window* sdl_window = (SDL_Window*)ImGui::GetMainViewport ()->PlatformHandle ;
118+ SDL_DialogFileFilter filters[1 ] = { { " JSON" , " json" } };
119+ SDL_ShowSaveFileDialog (WindowMain::dbSaveCallback, this , sdl_window, filters, 1 , nullptr );
120+ }
95121
96122
97123 //
@@ -112,6 +138,13 @@ namespace OST::AMD::GPU::ProfileManager {
112138 }
113139
114140 ImGui::End ();
141+
142+ if (m_ui_details) {
143+ if (!m_ui_details->UiUpdate ()) {
144+ m_ui_details.reset ();
145+ }
146+ }
147+
115148 return true ;
116149 }
117150
@@ -123,6 +156,10 @@ namespace OST::AMD::GPU::ProfileManager {
123156 dbRefresh ();
124157 }
125158
159+ if (ImGui::Button (" Export" )) {
160+ dbSave ();
161+ }
162+
126163 ImGui::Separator ();
127164
128165 if (ImGui::RadioButton (" System" , m_current_db_source == ADL_AP_DATABASE__SYSTEM )) {
@@ -266,7 +303,11 @@ namespace OST::AMD::GPU::ProfileManager {
266303 ImGui::EndDisabled ();
267304
268305 ImGui::SameLine ();
306+ if (ImGui::Button (" Details" )) {
307+ m_ui_details = std::make_unique<WindowDetails>(app.app );
308+ }
269309
310+ ImGui::SameLine ();
270311 ImGui::BeginDisabled (cur_source != ADL_AP_DATABASE__USER );
271312 if (ImGui::Button (" Remove" )) {
272313 app.app ->Remove (m_adl_context);
@@ -295,15 +336,21 @@ namespace OST::AMD::GPU::ProfileManager {
295336 {
296337 static char filename[128 ] = " " ;
297338 static char title[128 ] = " " ;
339+ static char path[128 ] = " " ;
340+ static char version[128 ] = " " ;
298341
299342 ImGui::InputText (" Filename" , filename, IM_ARRAYSIZE (filename));
300343 ImGui::InputText (" Title" , title, IM_ARRAYSIZE (title));
344+ ImGui::InputText (" Path" , path, IM_ARRAYSIZE (path));
345+ ImGui::InputText (" Version" , version, IM_ARRAYSIZE (version));
301346
302347 if (ImGui::Button (" OK" , ImVec2 (120 , 0 ))) {
303348 std::wstring w_filename = Utils::ToUtf16 (filename);
304349 std::wstring w_title = Utils::ToUtf16 (title);
350+ std::wstring w_path = Utils::ToUtf16 (path);
351+ std::wstring w_version = Utils::ToUtf16 (version);
305352
306- Application app (w_filename, w_title);
353+ Application app (w_filename, w_title, w_path, w_version );
307354 app.AssignProfile (m_adl_context, L" FSROVR" , L" FsrOvrWhitelistProfile" );
308355
309356 m_db_cache_dirty = true ;
0 commit comments