-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
second-pass at modularizing GUI - done?
I'm pretty happy with how SDL_GUI cleaned up. It's now pretty thin, with just a bit of nontrivial, ANESE related behavior, namely: 1) Loading a rom passed as an arg 2) The main run loop is not fully generic (queries modules) Neither of those are that bad though, so i'm calling it for now. I think that after this, i'll just have 2 more tasks left until I tag this as ANESE release 1.0. 1) Comment the codebase some more. It's pretty good as it stands, but I want to give it a once-over. 2) See if I can't just figure out how to use SDL_QueueAudio Yes, Blargg's Sound_Queue works _fine_, but I'd feel better if I could say that _all_ of ANESE's sound code is hand-written.
- Loading branch information
1 parent
82be50b
commit 52c8ea0
Showing
11 changed files
with
236 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SDL GUI | ||
|
||
It's not the cleanest code, but it works, and is pretty modular. | ||
|
||
- `SDL_GUI` - `gui.h/cc` - Core SDL functionality | ||
- Set up + teardown main Renderer, Window, Controllers, etc... | ||
- Contains main Loop | ||
- Initializes and routes events / output to and from `GUIModules` | ||
- `gui_modules` - Individual components of the UI | ||
- Implement simple interface (accept input, update self, render output) | ||
- `EmuModule` - ANESE core | ||
- Owns, updates, and presents the output of ANESE core | ||
- Handles loading / unloading ROMs, Movies, and savs | ||
- `MenuModule` - Menu system | ||
- Runs the menu system | ||
- Has reference to `EmuModule` (to load ROMs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,80 @@ | ||
#include "config.h" | ||
|
||
#include <iostream> | ||
|
||
#include <cfgpath.h> | ||
#include <clara.hpp> | ||
|
||
Config::Config() { this->ini.SetUnicode(); } | ||
|
||
void Config::load(const char* filename) { | ||
void Config::load(int argc, char* argv[]) { | ||
// --------------------------- Argument Parsing --------------------------- // | ||
|
||
bool show_help = false; | ||
auto cli | ||
= clara::Help(show_help) | ||
| clara::Opt(this->cli.log_cpu) | ||
["--log-cpu"] | ||
("Output CPU execution over STDOUT") | ||
| clara::Opt(this->cli.no_sav) | ||
["--no-sav"] | ||
("Don't load/create sav files") | ||
| clara::Opt(this->cli.ppu_timing_hack) | ||
["--alt-nmi-timing"] | ||
("Enable NMI timing fix \n" | ||
"(fixes some games, eg: Bad Dudes, Solomon's Key)") | ||
| clara::Opt(this->cli.record_fm2_path, "path") | ||
["--record-fm2"] | ||
("Record a movie in the fm2 format") | ||
| clara::Opt(this->cli.replay_fm2_path, "path") | ||
["--replay-fm2"] | ||
("Replay a movie in the fm2 format") | ||
| clara::Opt(this->cli.config_file, "path") | ||
["--config"] | ||
("Use custom config file") | ||
| clara::Arg(this->cli.rom, "rom") | ||
("an iNES rom"); | ||
|
||
auto result = cli.parse(clara::Args(argc, argv)); | ||
if(!result) { | ||
std::cerr << "Error: " << result.errorMessage() << "\n"; | ||
std::cerr << cli; | ||
exit(1); | ||
} | ||
|
||
if (show_help) { | ||
std::cout << cli; | ||
exit(1); | ||
} | ||
|
||
// ------------------------- Config File Parsing ------------------------- -// | ||
|
||
// Get cross-platform config path (if no custom path specified) | ||
if (this->cli.config_file.empty()) { | ||
cfgpath::get_user_config_file(this->filename, 260, "anese"); | ||
} else { | ||
strcpy(this->filename, this->cli.config_file.c_str()); | ||
} | ||
|
||
// Try to load config, setting up a new one if none exists | ||
if (SI_Error err = this->ini.LoadFile(filename)) { | ||
if (SI_Error err = this->ini.LoadFile(this->filename)) { | ||
(void)err; // TODO: handle me? | ||
fprintf(stderr, "[Config] Could not open config file %s!\n", filename); | ||
fprintf(stderr, "[Config] Could not open config file %s!\n", this->filename); | ||
fprintf(stderr, "[Config] Will generate a new one.\n"); | ||
this->save(filename); | ||
this->save(); | ||
} | ||
|
||
// Load config vals | ||
this->window_scale = this->ini.GetLongValue("ui", "window_scale"); | ||
strcpy(this->roms_dir, this->ini.GetValue("paths", "roms_dir")); | ||
} | ||
|
||
void Config::save(const char* filename) { | ||
void Config::save() { | ||
this->ini.SetLongValue("ui", "window_scale", this->window_scale); | ||
this->ini.SetValue ("paths", "roms_dir", this->roms_dir); | ||
|
||
if (SI_Error err = this->ini.SaveFile(filename)) { | ||
if (SI_Error err = this->ini.SaveFile(this->filename)) { | ||
(void)err; // TODO: handle me? | ||
fprintf(stderr, "[Config] Could not save config file %s!\n", filename); | ||
fprintf(stderr, "[Config] Could not save config file %s!\n", this->filename); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.