game: Migrate from GLFW to SDL2 & attempt to rewrite / simplify display and input code (#2397)

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
This commit is contained in:
Tyler Wilding
2023-06-04 14:34:37 -05:00
committed by GitHub
parent 08741f0a42
commit bdaf088d4b
1973 changed files with 903017 additions and 118529 deletions
+17
View File
@@ -16,6 +16,7 @@
#include "common/common_types.h"
#include "common/util/BinaryReader.h"
#include "common/util/string_util.h"
#include "common/util/unicode_util.h"
// This disables the use of PCLMULQDQ which is probably ok, but let's just be safe and disable it
@@ -201,10 +202,12 @@ bool create_dir_if_needed(const fs::path& path) {
return false;
}
// TODO - explodes if the file path is invalid
bool create_dir_if_needed_for_file(const std::string& path) {
return create_dir_if_needed_for_file(fs::path(path));
}
// TODO - explodes if the file path is invalid
bool create_dir_if_needed_for_file(const fs::path& path) {
return fs::create_directories(path.parent_path());
}
@@ -636,4 +639,18 @@ void copy_file(const fs::path& src, const fs::path& dst) {
fs::copy_file(src, dst, fs::copy_options::overwrite_existing);
}
std::string make_screenshot_filepath(const GameVersion game_version, const std::string& name) {
std::string file_name;
if (name.empty()) {
file_name = fmt::format("{}_{}.png", version_to_game_name(game_version),
str_util::current_local_timestamp_no_colons());
} else {
file_name = fmt::format("{}_{}_{}.png", version_to_game_name(game_version), name,
str_util::current_local_timestamp_no_colons());
}
const auto file_path = file_util::get_file_path({"screenshots", file_name});
file_util::create_dir_if_needed_for_file(file_path);
return file_path;
}
} // namespace file_util