3
3
4
4
#include < fstream>
5
5
#include < string>
6
- #include < common/version.h>
7
6
#include < fmt/core.h>
8
7
#include < fmt/xchar.h> // for wstring support
9
8
#include < toml.hpp>
10
- # include " common/logging/formatter.h "
9
+
11
10
#include " common/path_util.h"
12
11
#include " config.h"
12
+ #include " logging/formatter.h"
13
+ #include " version.h"
13
14
14
15
namespace toml {
15
16
template <typename TC, typename K>
@@ -81,7 +82,8 @@ std::vector<std::string> m_pkg_viewer;
81
82
std::vector<std::string> m_elf_viewer;
82
83
std::vector<std::string> m_recent_files;
83
84
std::string emulator_language = " en" ;
84
- // Settings
85
+
86
+ // Language
85
87
u32 m_language = 1 ; // english
86
88
87
89
bool isNeoMode () {
@@ -334,6 +336,7 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
334
336
main_window_geometry_w = w;
335
337
main_window_geometry_h = h;
336
338
}
339
+
337
340
bool addGameInstallDir (const std::filesystem::path& dir) {
338
341
if (std::find (settings_install_dirs.begin (), settings_install_dirs.end (), dir) ==
339
342
settings_install_dirs.end ()) {
@@ -342,47 +345,60 @@ bool addGameInstallDir(const std::filesystem::path& dir) {
342
345
}
343
346
return false ;
344
347
}
348
+
345
349
void removeGameInstallDir (const std::filesystem::path& dir) {
346
350
auto iterator = std::find (settings_install_dirs.begin (), settings_install_dirs.end (), dir);
347
351
if (iterator != settings_install_dirs.end ()) {
348
352
settings_install_dirs.erase (iterator);
349
353
}
350
354
}
355
+
351
356
void setAddonInstallDir (const std::filesystem::path& dir) {
352
357
settings_addon_install_dir = dir;
353
358
}
359
+
354
360
void setMainWindowTheme (u32 theme) {
355
361
mw_themes = theme;
356
362
}
363
+
357
364
void setIconSize (u32 size) {
358
365
m_icon_size = size;
359
366
}
367
+
360
368
void setIconSizeGrid (u32 size) {
361
369
m_icon_size_grid = size;
362
370
}
371
+
363
372
void setSliderPosition (u32 pos) {
364
373
m_slider_pos = pos;
365
374
}
375
+
366
376
void setSliderPositionGrid (u32 pos) {
367
377
m_slider_pos_grid = pos;
368
378
}
379
+
369
380
void setTableMode (u32 mode) {
370
381
m_table_mode = mode;
371
382
}
383
+
372
384
void setMainWindowWidth (u32 width) {
373
385
m_window_size_W = width;
374
386
}
387
+
375
388
void setMainWindowHeight (u32 height) {
376
389
m_window_size_H = height;
377
390
}
391
+
378
392
void setPkgViewer (const std::vector<std::string>& pkgList) {
379
393
m_pkg_viewer.resize (pkgList.size ());
380
394
m_pkg_viewer = pkgList;
381
395
}
396
+
382
397
void setElfViewer (const std::vector<std::string>& elfList) {
383
398
m_elf_viewer.resize (elfList.size ());
384
399
m_elf_viewer = elfList;
385
400
}
401
+
386
402
void setRecentFiles (const std::vector<std::string>& recentFiles) {
387
403
m_recent_files.resize (recentFiles.size ());
388
404
m_recent_files = recentFiles;
@@ -395,55 +411,71 @@ void setEmulatorLanguage(std::string language) {
395
411
u32 getMainWindowGeometryX () {
396
412
return main_window_geometry_x;
397
413
}
414
+
398
415
u32 getMainWindowGeometryY () {
399
416
return main_window_geometry_y;
400
417
}
418
+
401
419
u32 getMainWindowGeometryW () {
402
420
return main_window_geometry_w;
403
421
}
422
+
404
423
u32 getMainWindowGeometryH () {
405
424
return main_window_geometry_h;
406
425
}
426
+
407
427
const std::vector<std::filesystem::path>& getGameInstallDirs () {
408
428
return settings_install_dirs;
409
429
}
430
+
410
431
std::filesystem::path getAddonInstallDir () {
411
432
if (settings_addon_install_dir.empty ()) {
412
433
// Default for users without a config file or a config file from before this option existed
413
434
return Common::FS::GetUserPath (Common::FS::PathType::UserDir) / " addcont" ;
414
435
}
415
436
return settings_addon_install_dir;
416
437
}
438
+
417
439
u32 getMainWindowTheme () {
418
440
return mw_themes;
419
441
}
442
+
420
443
u32 getIconSize () {
421
444
return m_icon_size;
422
445
}
446
+
423
447
u32 getIconSizeGrid () {
424
448
return m_icon_size_grid;
425
449
}
450
+
426
451
u32 getSliderPosition () {
427
452
return m_slider_pos;
428
453
}
454
+
429
455
u32 getSliderPositionGrid () {
430
456
return m_slider_pos_grid;
431
457
}
458
+
432
459
u32 getTableMode () {
433
460
return m_table_mode;
434
461
}
462
+
435
463
u32 getMainWindowWidth () {
436
464
return m_window_size_W;
437
465
}
466
+
438
467
u32 getMainWindowHeight () {
439
468
return m_window_size_H;
440
469
}
470
+
441
471
std::vector<std::string> getPkgViewer () {
442
472
return m_pkg_viewer;
443
473
}
474
+
444
475
std::vector<std::string> getElfViewer () {
445
476
return m_elf_viewer;
446
477
}
478
+
447
479
std::vector<std::string> getRecentFiles () {
448
480
return m_recent_files;
449
481
}
@@ -455,6 +487,7 @@ std::string getEmulatorLanguage() {
455
487
u32 GetLanguage () {
456
488
return m_language;
457
489
}
490
+
458
491
void load (const std::filesystem::path& path) {
459
492
// If the configuration file does not exist, create it and return
460
493
std::error_code error;
@@ -545,18 +578,6 @@ void load(const std::filesystem::path& path) {
545
578
m_window_size_W = toml::find_or<int >(gui, " mw_width" , 0 );
546
579
m_window_size_H = toml::find_or<int >(gui, " mw_height" , 0 );
547
580
548
- // TODO Migration code, after a major release this should be removed.
549
- auto old_game_install_dir = toml::find_fs_path_or (gui, " installDir" , {});
550
- if (!old_game_install_dir.empty ()) {
551
- addGameInstallDir (std::filesystem::path{old_game_install_dir});
552
- } else {
553
- const auto install_dir_array =
554
- toml::find_or<std::vector<std::string>>(gui, " installDirs" , {});
555
- for (const auto & dir : install_dir_array) {
556
- addGameInstallDir (std::filesystem::path{dir});
557
- }
558
- }
559
-
560
581
settings_addon_install_dir = toml::find_fs_path_or (gui, " addonInstallDir" , {});
561
582
main_window_geometry_x = toml::find_or<int >(gui, " geometry_x" , 0 );
562
583
main_window_geometry_y = toml::find_or<int >(gui, " geometry_y" , 0 );
@@ -575,6 +596,7 @@ void load(const std::filesystem::path& path) {
575
596
m_language = toml::find_or<int >(settings, " consoleLanguage" , 1 );
576
597
}
577
598
}
599
+
578
600
void save (const std::filesystem::path& path) {
579
601
toml::value data;
580
602
@@ -655,9 +677,6 @@ void save(const std::filesystem::path& path) {
655
677
656
678
data[" Settings" ][" consoleLanguage" ] = m_language;
657
679
658
- // TODO Migration code, after a major release this should be removed.
659
- data.at (" GUI" ).as_table ().erase (" installDir" );
660
-
661
680
std::ofstream file (path, std::ios::binary);
662
681
file << data;
663
682
file.close ();
0 commit comments