Make fc2dconfig read existing config file

This commit is contained in:
Epicalert 2021-07-03 00:38:05 +08:00
parent b9c9cb3de4
commit 5c53e82fb7
No known key found for this signature in database
GPG key ID: CAA46F858D0979BD
2 changed files with 20 additions and 0 deletions

View file

@ -73,5 +73,8 @@ add_executable( fc2dconfig
src/fc2dconfig.cpp
src/paths.cpp
src/modellist.cpp
src/configfile.cpp
src/toml.c
src/tomlcpp.cpp
)
target_link_libraries( fc2dconfig ${wxWidgets_LIBRARIES} )

View file

@ -4,6 +4,7 @@
#include <args.hpp>
#include <paths.hpp>
#include <modellist.hpp>
#include <configfile.hpp>
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
@ -22,6 +23,7 @@ class ConfigurationFrame : public wxFrame {
std::vector<std::string> modelVec;
wxCheckBox* useHaarCheckBox;
wxChoice* modelNameChoice;
void loadExistingConfig(); // loads existing config file and populates controls
void OnApply(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
};
@ -85,6 +87,21 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure "
Bind(wxEVT_BUTTON, &ConfigurationFrame::OnApply, this, wxID_APPLY);
Bind(wxEVT_BUTTON, &ConfigurationFrame::OnExit, this, wxID_CANCEL);
loadExistingConfig();
}
void ConfigurationFrame::loadExistingConfig() {
struct optData configData;
configFileOpen(&configData);
useHaarCheckBox->SetValue(configData.useHaar);
for (int i = 0; i < modelVec.size(); i++) {
if (modelVec[i] == configData.model) {
modelNameChoice->SetSelection(i);
break;
}
}
}
void ConfigurationFrame::OnApply(wxCommandEvent& event) {