diff options
-rw-r--r-- | anim-crop-tool/main.cpp | 28 | ||||
-rw-r--r-- | blender/npc/.gitignore | 4 | ||||
-rw-r--r-- | wall-tileset-tool/main.cpp | 14 |
3 files changed, 37 insertions, 9 deletions
diff --git a/anim-crop-tool/main.cpp b/anim-crop-tool/main.cpp index 33011be5..9e8fb2a1 100644 --- a/anim-crop-tool/main.cpp +++ b/anim-crop-tool/main.cpp @@ -33,6 +33,8 @@ using Corrade::Utility::Error; using Corrade::Utility::Debug; using floormat::Serialize::anim_atlas_; +namespace { + struct options { String input_dir, input_file, output_dir; @@ -41,7 +43,7 @@ struct options }; [[nodiscard]] -static std::tuple<cv::Vec2i, cv::Vec2i, bool> find_image_bounds(const cv::Mat4b& mat) noexcept +std::tuple<cv::Vec2i, cv::Vec2i, bool> find_image_bounds(const cv::Mat4b& mat) noexcept { cv::Vec2i start{mat.cols, mat.rows}, end{0, 0}; for (int y = 0; y < mat.rows; y++) @@ -66,7 +68,7 @@ static std::tuple<cv::Vec2i, cv::Vec2i, bool> find_image_bounds(const cv::Mat4b& } [[nodiscard]] -static bool load_file(anim_group& group, options& opts, anim_atlas_& atlas, StringView filename) +bool load_file(anim_group& group, options& opts, anim_atlas_& atlas, StringView filename) { auto mat = fm_begin( cv::Mat mat = cv::imread(filename, cv::IMREAD_UNCHANGED); @@ -126,7 +128,7 @@ static bool load_file(anim_group& group, options& opts, anim_atlas_& atlas, Stri } [[nodiscard]] -static bool load_directory(anim_group& group, options& opts, anim_atlas_& atlas) +bool load_directory(anim_group& group, options& opts, anim_atlas_& atlas) { if (!group.mirror_from.isEmpty()) return true; @@ -181,9 +183,19 @@ static bool load_directory(anim_group& group, options& opts, anim_atlas_& atlas) return true; } +inline String fixsep(String str) +{ +#ifdef _WIN32 + for (char& c : str) + if (c == '\\') + c = '/'; +#endif + return str; +} + using Corrade::Utility::Arguments; -static std::tuple<options, Arguments, bool> parse_cmdline(int argc, const char* const* argv) noexcept +std::tuple<options, Arguments, bool> parse_cmdline(int argc, const char* const* argv) noexcept { Corrade::Utility::Arguments args{}; args.addOption('o', "output").setHelp("output", "", "DIR") @@ -202,8 +214,8 @@ static std::tuple<options, Arguments, bool> parse_cmdline(int argc, const char* else if (!args.value<StringView>("scale").isEmpty()) opts.scale = anim_scale::ratio{args.value<float>("scale")}; - opts.output_dir = Path::join(loader.startup_directory(), args.value<StringView>("output")); - opts.input_file = Path::join(loader.startup_directory(), args.value<StringView>("input.json")); + opts.output_dir = Path::join(loader.startup_directory(), fixsep(args.value<StringView>("output"))); + opts.input_file = Path::join(loader.startup_directory(), fixsep(args.value<StringView>("input.json"))); opts.input_dir = Path::split(opts.input_file).first(); if (opts.output_dir.isEmpty()) @@ -212,12 +224,14 @@ static std::tuple<options, Arguments, bool> parse_cmdline(int argc, const char* return { Utility::move(opts), Utility::move(args), true }; } -[[nodiscard]] static int usage(const Arguments& args) noexcept +[[nodiscard]] int usage(const Arguments& args) noexcept { Error{Error::Flag::NoNewlineAtTheEnd} << args.usage(); return EX_USAGE; } +} // namespace + int main(int argc, char** argv) { argv[0] = fix_argv0(argv[0]); diff --git a/blender/npc/.gitignore b/blender/npc/.gitignore new file mode 100644 index 00000000..89c147b0 --- /dev/null +++ b/blender/npc/.gitignore @@ -0,0 +1,4 @@ +/[nesw]/ +/[ns][ew]/ +/tmp/ +/*.blend[0-9]* diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp index 29a7b3d4..c04d4988 100644 --- a/wall-tileset-tool/main.cpp +++ b/wall-tileset-tool/main.cpp @@ -42,6 +42,16 @@ std::shared_ptr<wall_atlas> read_from_file(StringView filename) return {}; } +inline String fixsep(String str) +{ +#ifdef _WIN32 + for (char& c : str) + if (c == '\\') + c = '/'; +#endif + return str; +} + Triple<options, Arguments, bool> parse_cmdline(int argc, const char* const* argv) noexcept { Corrade::Utility::Arguments args{}; @@ -50,8 +60,8 @@ Triple<options, Arguments, bool> parse_cmdline(int argc, const char* const* argv args.parse(argc, argv); options opts; - opts.output_dir = Path::join(loader.startup_directory(), args.value<StringView>("output")); - opts.input_file = Path::join(loader.startup_directory(), args.value<StringView>("input.json")); + opts.output_dir = Path::join(loader.startup_directory(), fixsep(args.value<StringView>("output"))); + opts.input_file = Path::join(loader.startup_directory(), fixsep(args.value<StringView>("input.json"))); opts.input_dir = Path::split(opts.input_file).first(); if (opts.output_dir.isEmpty()) |