Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

main.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2002 Xavier Trochu
00003 
00004 This software is provided 'as-is', without any express or implied warranty. In no event
00005 will the authors be held liable for any damages arising from the use of this software.
00006 
00007 Permission is granted to anyone to use this software for any purpose, including commercial
00008 applications, and to alter it and redistribute it freely, subject to the following
00009 restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you
00012    wrote the original software. If you use this software in a product, an acknowledgment
00013    in the product documentation would be appreciated but is not required.
00014 
00015 2. Altered source versions must be plainly marked as such, and must not be misrepresented 
00016    as being the original software.
00017 
00018 3. This notice may not be removed or altered from any source distribution.
00019 */
00020 #include <iostream>
00021 #include <string>
00022 #include <vector>
00023 
00024 #include "player.h"
00025 #include "win32.h"
00026 
00027 using namespace std;
00028 
00029 int main(int argc, char * argv[]) {
00030     renderer * render = 0;
00031     bool wait = true;
00032     bool sound = true;
00033     string anim;
00034     vector<string> show_opt, hide_opt;
00035     for(int i = 1; i < argc; i++)
00036     {
00037         string arg = argv[i];
00038         if(arg == "-wnd") {
00039             if(render) {
00040                 cerr << "only one of -wnd | -bmp supported" << endl;
00041                 return 1;
00042             }
00043             render = new window_renderer;
00044         } else if(arg == "-nosound") {
00045             sound = false;
00046         } else if(arg == "-show") {
00047             if(i >= argc-1) { cerr << "-show need an option" << endl; return 1; }
00048             show_opt.push_back(argv[++i]);
00049         } else if(arg == "-hide") {
00050             if(i >= argc-1) { cerr << "-show need an option" << endl; return 1; }
00051             hide_opt.push_back(argv[++i]);
00052         } else if(arg == "-nowait") {
00053             sound = false;
00054             wait = false;
00055         } else if(arg == "-bmp") {
00056             string param = i < argc-1 ? argv[++i] : "frame";
00057             if(render) {
00058                 cerr << "only one of -wnd | -bmp supported" << endl;
00059                 return 1;
00060             }
00061             render = new bitmap_file_renderer(param);
00062         } else {
00063             if(anim.size()) {
00064                 cerr << "only one SMUSH file at a time, please" << endl;
00065                 return 1;
00066             }
00067             anim = arg;
00068         }
00069     }
00070     if(!anim.size()) {
00071         cout << "Usage : " << argv[0] << " [<options> ...] <file>" << endl;
00072         return 1;
00073     }
00074     if(!render)
00075         render = new null_renderer;
00076     player p(render, wait, sound);
00077     for(vector<string>::iterator i = show_opt.begin(); i != show_opt.end(); i++)
00078         p.show(*i);
00079     for(vector<string>::iterator i = hide_opt.begin(); i != hide_opt.end(); i++)
00080         p.hide(*i);
00081     set_terminate(__gnu_cxx::__verbose_terminate_handler);
00082     try {
00083         p.play(anim);
00084     } catch(const exception & e) {
00085         cerr << "Exception caught : " << e.what() << endl;
00086     }
00087     delete render;
00088     return 0;
00089 }
00090 

Generated on Fri Aug 9 22:54:29 2002 for san_player by doxygen1.2.16