diff --git a/dropship/assets/icons/icon-block.png b/dropship/assets/icons/icon-block.png index ec7998c..1de1a18 100644 Binary files a/dropship/assets/icons/icon-block.png and b/dropship/assets/icons/icon-block.png differ diff --git a/dropship/assets/icons/icon-x.png b/dropship/assets/icons/icon-x.png new file mode 100644 index 0000000..ec7998c Binary files /dev/null and b/dropship/assets/icons/icon-x.png differ diff --git a/dropship/main.cpp b/dropship/main.cpp index 2369b67..0346b1f 100644 --- a/dropship/main.cpp +++ b/dropship/main.cpp @@ -11,6 +11,7 @@ #include #include +#include // common #include "util.hpp" @@ -59,6 +60,9 @@ OPTIONS options #else .auto_update = true, #endif + + // TODO implement + ._save_settings = true, }; AppStore __default__appStore @@ -253,8 +257,27 @@ int main(int, char**) // https://github.com/ocornut/imgui/issues/5169 // TODO /tmp - io.IniFilename = NULL; - io.LogFilename = NULL; + // io.IniFilename = NULL; + //{ + std::filesystem::path path = std::filesystem::temp_directory_path().append("dropship"); + if (!std::filesystem::is_directory(path) || !std::filesystem::exists(path)) { + std::filesystem::create_directory(path); + } + + path.append("dropship.ini"); + + std::string path_name = path.string(); + + io.IniFilename = path_name.c_str(); + //} + + io.UserData = &options; + + ImGui::SaveIniSettingsToDisk(io.IniFilename); + + printf("file path: %s\n", io.IniFilename); + + //io.LogFilename = NULL; // store my own data :D //io.UserData = NULL diff --git a/dropship/src/DashboardManager.cpp b/dropship/src/DashboardManager.cpp index b4d7694..83ac38c 100644 --- a/dropship/src/DashboardManager.cpp +++ b/dropship/src/DashboardManager.cpp @@ -318,9 +318,9 @@ DashboardManager::DashboardManager() : if (__previous__application_open && !appStore.application_open) { - // std::thread([&]() { + std::thread([&]() { firewallManager.sync(&(this->endpoints)); - // }).detach(); + }).detach(); appStore.dashboard.heading = __default__appStore.dashboard.heading; @@ -790,7 +790,7 @@ void DashboardManager::RenderInline() // action if (action) { - // std::thread([&]() { + std::thread([&]() { firewallManager.sync(&(this->endpoints), appStore.application_open); bool pending_actions = false; @@ -799,7 +799,7 @@ void DashboardManager::RenderInline() pending_actions = true; this->game_restart_required = pending_actions; - // }).detach(); + }).detach(); // fill missing frame w_list->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), color, 5, NULL); diff --git a/dropship/src/_WindowsFirewallUtil.h b/dropship/src/_WindowsFirewallUtil.h index e484b62..dcf0825 100644 --- a/dropship/src/_WindowsFirewallUtil.h +++ b/dropship/src/_WindowsFirewallUtil.h @@ -1330,8 +1330,6 @@ class _WindowsFirewallUtil : public failable if (!e.active_desired_state != ruleEnabled && (!only_unblocks || (only_unblocks && (!e.active && e.active_desired_state)))) { - printf("\n\nhere\n\n"); - // if endpointDominant, set firewall to mirror endpoint state if (endpointDominant) { diff --git a/dropship/src/_windows_download.hpp b/dropship/src/_windows_download.hpp index 7a206a1..cdcf257 100644 --- a/dropship/src/_windows_download.hpp +++ b/dropship/src/_windows_download.hpp @@ -127,23 +127,25 @@ class _downloading : public IBindStatusCallback static void download_file(std::string uri, std::string filename, float* progress, std::string* data = nullptr, std::filesystem::path* path = nullptr) { - std::string directory = std::filesystem::temp_directory_path().string() + "/dropship"; + std::filesystem::path _path = std::filesystem::temp_directory_path().append("dropship"); - if (!std::filesystem::is_directory(directory) || !std::filesystem::exists("src")) { - std::filesystem::create_directory(directory); + if (!std::filesystem::is_directory(_path) || !std::filesystem::exists(_path)) { + std::filesystem::create_directory(_path); } - std::filesystem::path filePath = directory + "/" + filename; + _path.append(filename); - if (std::filesystem::exists(filePath)) - std::filesystem::remove(filePath); + if (std::filesystem::exists(_path)) + std::filesystem::remove(_path); - DeleteUrlCacheEntry(filePath.string().c_str()); + std::string _path_name = _path.string(); - wprintf(filePath.c_str()); + DeleteUrlCacheEntry(_path_name.c_str()); + + printf("downloading: %s\n", _path_name.c_str()); _downloading _progress(progress); - if (URLDownloadToFile(NULL, uri.c_str(), filePath.string().c_str(), 0, &_progress) != S_OK) + if (URLDownloadToFile(NULL, uri.c_str(), _path_name.c_str(), 0, &_progress) != S_OK) { printf("download failed\n"); } @@ -154,12 +156,12 @@ static void download_file(std::string uri, std::string filename, float* progress if (data != nullptr) { - *data = get_file_contents(filePath.string().c_str()); + *data = get_file_contents(_path_name.c_str()); } if (path != nullptr) { - *path = filePath; + *path = _path; } // std::filesystem::hash_value diff --git a/dropship/src/util.hpp b/dropship/src/util.hpp index 95d3727..3c49431 100644 --- a/dropship/src/util.hpp +++ b/dropship/src/util.hpp @@ -48,14 +48,15 @@ struct Endpoint //std::shared_ptr ping = std::make_shared(-9); int display_ping = 0; - bool active; - bool active_desired_state; + bool active = true; // if no rules have been defined, default to selected + bool active_desired_state = true; }; struct OPTIONS { bool auto_update; + bool _save_settings; };