Default config
This commit is contained in:
parent
c5a0ec15e9
commit
1ccab9d518
BIN
default.cfg
Normal file
BIN
default.cfg
Normal file
Binary file not shown.
@ -58,6 +58,7 @@ void settings_init(void);
|
|||||||
void settings_reset(void);
|
void settings_reset(void);
|
||||||
bool settings_save_to_file(const char* filename);
|
bool settings_save_to_file(const char* filename);
|
||||||
bool settings_load_from_file(const char* filename);
|
bool settings_load_from_file(const char* filename);
|
||||||
|
bool settings_set_as_default(void);
|
||||||
const char* get_config_dir(void);
|
const char* get_config_dir(void);
|
||||||
|
|
||||||
inline void init_default_settings(void) {
|
inline void init_default_settings(void) {
|
||||||
|
19
src/menu.c
19
src/menu.c
@ -400,6 +400,16 @@ extern "C" void menu_render(void) {
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::Button("Set as Default", ImVec2(120, 30))) {
|
||||||
|
if (settings_set_as_default()) {
|
||||||
|
ImGui::OpenPopup("DefaultSaved");
|
||||||
|
} else {
|
||||||
|
ImGui::OpenPopup("ConfigError");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::Button("Delete Config", ImVec2(120, 30))) {
|
if (ImGui::Button("Delete Config", ImVec2(120, 30))) {
|
||||||
ImGui::OpenPopup("ConfirmDelete");
|
ImGui::OpenPopup("ConfirmDelete");
|
||||||
}
|
}
|
||||||
@ -470,6 +480,15 @@ extern "C" void menu_render(void) {
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginPopupModal("DefaultSaved", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
ImGui::Text("Current settings saved as default configuration!");
|
||||||
|
ImGui::Text("These settings will load automatically on startup.");
|
||||||
|
if (ImGui::Button("OK", ImVec2(120, 0))) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::BeginPopupModal("ConfigError", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
|
if (ImGui::BeginPopupModal("ConfigError", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::Text("Error with configuration operation!");
|
ImGui::Text("Error with configuration operation!");
|
||||||
ImGui::Text("Check console for details.");
|
ImGui::Text("Check console for details.");
|
||||||
|
@ -19,9 +19,21 @@ void settings_init(void) {
|
|||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
snprintf(filepath, sizeof(filepath), "%s/default.cfg", config_dir);
|
snprintf(filepath, sizeof(filepath), "%s/default.cfg", config_dir);
|
||||||
|
|
||||||
|
if (access(filepath, F_OK) != 0) {
|
||||||
|
char cmd[2048];
|
||||||
|
snprintf(cmd, sizeof(cmd), "cp -f default.cfg %s/ 2>/dev/null", config_dir);
|
||||||
|
if (system(cmd) == 0) {
|
||||||
|
i_engine->Con_Printf("Copied default config from project root to %s\n", config_dir);
|
||||||
|
} else {
|
||||||
|
i_engine->Con_Printf("No default config found in project root or couldn't copy\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (access(filepath, F_OK) == 0) {
|
if (access(filepath, F_OK) == 0) {
|
||||||
i_engine->Con_Printf("Loading default configuration...\n");
|
i_engine->Con_Printf("Loading default configuration...\n");
|
||||||
settings_load_from_file("default");
|
settings_load_from_file("default");
|
||||||
|
} else {
|
||||||
|
i_engine->Con_Printf("No default config found, using built-in defaults\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,4 +160,8 @@ bool settings_load_from_file(const char* filename) {
|
|||||||
|
|
||||||
i_engine->Con_Printf("Settings loaded from %s\n", filepath);
|
i_engine->Con_Printf("Settings loaded from %s\n", filepath);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool settings_set_as_default(void) {
|
||||||
|
return settings_save_to_file("default");
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user