exploder.cpp

Go to the documentation of this file.
00001 /* $Id: exploder.cpp 23842 2008-02-16 08:47:16Z mordante $ */
00002 /*
00003    Copyright (C) 2004 - 2008 by Philippe Plantier <ayin@anathas.org>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 
00015 #include "../sdl_utils.hpp"
00016 #include "../game_config.hpp"
00017 #include "exploder_utils.hpp"
00018 #include "exploder_composer.hpp"
00019 
00020 namespace {
00021 
00022     void print_usage(std::string name)
00023     {
00024         std::cerr << "usage: " << name << " [source] [destination]\n";
00025     }
00026 }
00027 
00028 int main(int argc, char* argv[])
00029 {
00030     std::string src;
00031     std::string dest;
00032     composer comp;
00033 
00034     //parse arguments that shouldn't require a display device
00035     int arg;
00036     for(arg = 1; arg != argc; ++arg) {
00037         const std::string val(argv[arg]);
00038         if(val.empty()) {
00039             continue;
00040         }
00041 
00042         if(val == "--help" || val == "-h") {
00043             print_usage(argv[0]);
00044             return 0;
00045         } else if(val == "--interactive" || val == "-i") {
00046             comp.set_interactive(true);
00047         } else if(val == "--verbose" || val == "-v") {
00048             comp.set_verbose(true);
00049         } else if(val == "--directory" || val == "-d" ) {
00050             game_config::path = argv[++arg];
00051         } else {
00052             if(src.empty()) {
00053                 src = val;
00054             } else if(dest.empty()) {
00055                 dest = val;
00056             } else {
00057                 print_usage(argv[0]);
00058                 return 1;
00059             }
00060         }
00061     }
00062 
00063     if(src.empty() || dest.empty()) {
00064         print_usage(argv[0]);
00065         return 1;
00066     }
00067 
00068     try {
00069         surface image = comp.compose(src, dest);
00070         save_image(image, dest);
00071     } catch(exploder_failure err) {
00072         std::cerr << "Failed: " << err.message << "\n";
00073     }
00074 }
00075 
00076 
00077 

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs