#include "gui_utils.h" #include "gui_common.h" #include "config.h" #include "utils/strings.h" #include #include #include #include void load_config_file(const std::wstring &path) { g_config_path_w = path; g_config_path = utils::wstr_to_str(path); std::string err; if (parse_config(path, g_cfg, &err)) { g_log_lines.push_back(std::format("[INFO] Config loaded: {}", g_config_path)); } else { g_log_lines.push_back(std::format("[ERROR] {}", err)); } } std::string open_file_dialog(const char *filter_desc, const char *filter_ext) { wchar_t buf[MAX_PATH] = {}; OPENFILENAMEW ofn = {}; ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = buf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; std::wstring wfilter = utils::to_wstring(std::string(filter_desc) + '\0' + filter_ext + '\0'); ofn.lpstrFilter = wfilter.c_str(); if (GetOpenFileNameW(&ofn)) return utils::wstr_to_str(buf); return {}; } std::string open_folder_dialog() { BROWSEINFOW bi = {}; bi.hwndOwner = nullptr; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; LPITEMIDLIST pidl = SHBrowseForFolderW(&bi); if (!pidl) return {}; wchar_t buf[MAX_PATH] = {}; if (!SHGetPathFromIDListW(pidl, buf)) return {}; CoTaskMemFree(pidl); return utils::wstr_to_str(buf); }