The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
exploder.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004 - 2016 by Philippe Plantier <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "game_config.hpp"
16 #include "exploder_composer.hpp"
17 
18 #include <iostream>
19 
20 namespace {
21 
23  {
24  std::cerr << "usage: " << name << " [source] [destination]\n";
25  }
26 }
27 
28 int main(int argc, char* argv[])
29 {
31  std::string dest;
32  composer comp;
33 
34  //parse arguments that shouldn't require a display device
35  int arg;
36  for(arg = 1; arg != argc; ++arg) {
37  const std::string val(argv[arg]);
38  if(val.empty()) {
39  continue;
40  }
41 
42  if(val == "--help" || val == "-h") {
43  print_usage(argv[0]);
44  return 0;
45  } else if(val == "--interactive" || val == "-i") {
46  comp.set_interactive(true);
47  } else if(val == "--verbose" || val == "-v") {
48  comp.set_verbose(true);
49  } else if(val == "--directory" || val == "-d" ) {
50  game_config::path = argv[++arg];
51  } else {
52  if(src.empty()) {
53  src = val;
54  } else if(dest.empty()) {
55  dest = val;
56  } else {
57  print_usage(argv[0]);
58  return 1;
59  }
60  }
61  }
62 
63  if(src.empty() || dest.empty()) {
64  print_usage(argv[0]);
65  return 1;
66  }
67 
68  try {
69  surface image = comp.compose(src, dest);
70  save_image(image, dest);
71  } catch(exploder_failure& err) {
72  std::cerr << "Failed: " << err.message << "\n";
73  return 1;
74  }
75 
76  return 0;
77 }
78 
79 
80 
surface compose(const std::string &src, const std::string &dest)
static void print_usage(const char *badoption)
Definition: lua.cpp:107
std::string message
GLuint const GLfloat * val
Definition: glew.h:2614
GLenum src
Definition: glew.h:2392
bool save_image(const locator &i_locator, const std::string &filename)
Definition: image.cpp:1249
void set_interactive(bool value)
void set_verbose(bool value)
std::string path
int main(int argc, char *argv[])
Definition: exploder.cpp:28
logger & err()
Definition: log.cpp:79
GLuint const GLchar * name
Definition: glew.h:1782
this module manages the cache of images.
Definition: image.cpp:75
GLsizei const GLcharARB ** string
Definition: glew.h:4503