mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-22 22:04:24 -04:00
moved pmem setting restore before top bar is loaded (#1105)
* moved pmem setting restore before top bar is loaded * added a check pmem from sdcard function, replaced occurences, added a save to file on back button * Added defines for flag file and dump file, changed test func name to should_use_sdcard_for_pmem, used file_exists, removed save and load pmem parameter * changed a text to a more comprehesible one
This commit is contained in:
parent
e3e179e380
commit
7e8a139732
5 changed files with 31 additions and 30 deletions
|
@ -446,27 +446,16 @@ SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
|
|||
add_children({&text_pmem_about,
|
||||
&text_pmem_informations,
|
||||
&text_pmem_status,
|
||||
&check_load_mem_at_startup,
|
||||
&check_use_sdcard_for_pmem,
|
||||
&button_save_mem_to_file,
|
||||
&button_load_mem_from_file,
|
||||
&button_load_mem_defaults,
|
||||
&button_return});
|
||||
|
||||
bool load_mem_at_startup = false;
|
||||
File pmem_flag_file_handle;
|
||||
|
||||
std::string folder = "SETTINGS";
|
||||
make_new_directory(folder);
|
||||
|
||||
std::string pmem_flag_file = "/SETTINGS/PMEM_FILEFLAG";
|
||||
auto result = pmem_flag_file_handle.open(pmem_flag_file);
|
||||
if (!result.is_valid()) {
|
||||
load_mem_at_startup = true;
|
||||
}
|
||||
check_load_mem_at_startup.set_value(load_mem_at_startup);
|
||||
check_load_mem_at_startup.on_select = [this](Checkbox&, bool v) {
|
||||
check_use_sdcard_for_pmem.set_value(portapack::persistent_memory::should_use_sdcard_for_pmem());
|
||||
check_use_sdcard_for_pmem.on_select = [this](Checkbox&, bool v) {
|
||||
File pmem_flag_file_handle;
|
||||
std::string pmem_flag_file = "/SETTINGS/PMEM_FILEFLAG";
|
||||
std::string pmem_flag_file = PMEM_FILEFLAG;
|
||||
if (v) {
|
||||
auto result = pmem_flag_file_handle.open(pmem_flag_file);
|
||||
if (result.is_valid()) {
|
||||
|
@ -490,7 +479,7 @@ SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
|
|||
};
|
||||
|
||||
button_save_mem_to_file.on_select = [&nav, this](Button&) {
|
||||
if (!portapack::persistent_memory::save_persistent_settings_to_file("SETTINGS/pmem_settings")) {
|
||||
if (!portapack::persistent_memory::save_persistent_settings_to_file()) {
|
||||
text_pmem_status.set("!problem saving settings!");
|
||||
} else {
|
||||
text_pmem_status.set("settings saved");
|
||||
|
@ -498,7 +487,7 @@ SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
|
|||
};
|
||||
|
||||
button_load_mem_from_file.on_select = [&nav, this](Button&) {
|
||||
if (!portapack::persistent_memory::load_persistent_settings_from_file("SETTINGS/pmem_settings")) {
|
||||
if (!portapack::persistent_memory::load_persistent_settings_from_file()) {
|
||||
text_pmem_status.set("!problem loading settings!");
|
||||
} else {
|
||||
text_pmem_status.set("settings loaded");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue