Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "../game_config.hpp"
00017 #include "exploder_composer.hpp"
00018
00019 #include <iostream>
00020
00021 namespace {
00022
00023 void print_usage(std::string name)
00024 {
00025 std::cerr << "usage: " << name << " [source] [destination]\n";
00026 }
00027 }
00028
00029 int main(int argc, char* argv[])
00030 {
00031 std::string src;
00032 std::string dest;
00033 composer comp;
00034
00035
00036 int arg;
00037 for(arg = 1; arg != argc; ++arg) {
00038 const std::string val(argv[arg]);
00039 if(val.empty()) {
00040 continue;
00041 }
00042
00043 if(val == "--help" || val == "-h") {
00044 print_usage(argv[0]);
00045 return 0;
00046 } else if(val == "--interactive" || val == "-i") {
00047 comp.set_interactive(true);
00048 } else if(val == "--verbose" || val == "-v") {
00049 comp.set_verbose(true);
00050 } else if(val == "--directory" || val == "-d" ) {
00051 game_config::path = argv[++arg];
00052 } else {
00053 if(src.empty()) {
00054 src = val;
00055 } else if(dest.empty()) {
00056 dest = val;
00057 } else {
00058 print_usage(argv[0]);
00059 return 1;
00060 }
00061 }
00062 }
00063
00064 if(src.empty() || dest.empty()) {
00065 print_usage(argv[0]);
00066 return 1;
00067 }
00068
00069 try {
00070 surface image = comp.compose(src, dest);
00071 save_image(image, dest);
00072 } catch(exploder_failure& err) {
00073 std::cerr << "Failed: " << err.message << "\n";
00074 return 1;
00075 }
00076
00077 return 0;
00078 }
00079
00080
00081