Runtime() noexcept;
- void ReadArgs(int argc, const char *const *argv);
+ void Initialize(int argc, const char *const *argv);
int Execute();
private:
+ void ReadArgs(int argc, const char *const *argv);
+ void ReadPreferences();
+
void RunStandalone();
void RunServer();
void RunClient();
out << "player.name = \"" << player.name << "\";" << std::endl;
out << "video.dblbuf = " << (video.dblbuf ? "on" : "off") << ';' << std::endl;
out << "video.vsync = " << (video.vsync ? "on" : "off") << ';' << std::endl;
- out << "video.msaa = " << net.port << ';' << std::endl;
+ out << "video.msaa = " << video.msaa << ';' << std::endl;
out << "video.hud = " << (video.hud ? "on" : "off") << ';' << std::endl;
out << "video.world = " << (video.world ? "on" : "off") << ';' << std::endl;
- out << "video.debug = " << (video.world ? "on" : "off") << ';' << std::endl;
+ out << "video.debug = " << (video.debug ? "on" : "off") << ';' << std::endl;
}
}
+void Runtime::Initialize(int argc, const char *const *argv) {
+ ReadArgs(argc, argv);
+ if (mode == ERROR) return;
+ ReadPreferences();
+ ReadArgs(argc, argv);
+}
+
void Runtime::ReadArgs(int argc, const char *const *argv) {
if (argc <= 0) return;
name = argv[0];
if (error) {
mode = ERROR;
- return;
+ } else if (n > 0) {
+ if (t > 0) {
+ mode = FIXED_FRAME_LIMIT;
+ } else {
+ mode = FRAME_LIMIT;
+ }
+ } else if (t > 0) {
+ mode = TIME_LIMIT;
+ } else {
+ mode = NORMAL;
}
+}
+void Runtime::ReadPreferences() {
if (config.env.asset_path.empty()) {
config.env.asset_path = default_asset_path();
} else if (
config.env.save_path += '/';
}
- if (n > 0) {
- if (t > 0) {
- mode = FIXED_FRAME_LIMIT;
- } else {
- mode = FRAME_LIMIT;
- }
- } else if (t > 0) {
- mode = TIME_LIMIT;
+ string prefs_path = config.env.save_path + "prefs.conf";
+ if (is_file(prefs_path)) {
+ ifstream file(prefs_path);
+ config.game.Load(file);
} else {
- mode = NORMAL;
+ make_dirs(config.env.save_path);
+ ofstream file(prefs_path);
+ config.game.Save(file);
}
}