1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
#include <iostream>
#include <iostream>
#include "engine/display/display.hpp"
#include "engine/display/screenshot.hpp"
#include "engine/display/surface.hpp"
#include "math/color.hpp"
#include "math/size.hpp"
#include "math/vector3f.hpp"
#include "pingus/globals.hpp"
#include "pingus/levelset.hpp"
#include "pingus/path_manager.hpp"
#include "pingus/pingus_level.hpp"
#include "pingus/res_descriptor.hpp"
#include "pingus/resource.hpp"
#include "pingus/savegame_manager.hpp"
#include "pingus/stat_manager.hpp"
#include "util/command_line.hpp"
#include "util/pathname.hpp"
#include "util/system.hpp"
int main(int argc, char** argv)
{
std::vector<Pathname> files;
enum {
kTitle = (1<<0),
kDescription = (1<<1),
kLevels = (1<<2),
kFilename = (1<<3)
};
unsigned int mode = 0;
CommandLine argp;
argp.add_usage("[OPTIONS]... [FILE]...");
argp.add_option('h', "help", "", "Displays this help");
argp.add_option('t', "title", "", "Display title of the levelset");
argp.add_option('d', "description", "", "Display description of the levelset");
argp.add_option('l', "levels", "", "Display levels in this levelset");
argp.add_option('f', "filename", "", "Display filename of the level");
argp.parse_args(argc, argv);
argp.set_help_indent(20);
while (argp.next())
{
switch (argp.get_key())
{
case 'h':
argp.print_help();
exit(EXIT_SUCCESS);
break;
case 't':
mode |= kTitle;
break;
case 'd':
mode |= kDescription;
break;
case 'l':
mode |= kLevels;
break;
case 'f':
mode |= kFilename;
break;
case CommandLine::REST_ARG:
files.push_back(Pathname(argp.get_argument(), Pathname::SYSTEM_PATH));
break;
}
}
if (files.empty())
{
argp.print_help();
exit(EXIT_SUCCESS);
}
else
{
// FIXME: a little ugly that levelset loads sprites and savegames
System::init_directories();
g_path_manager.set_path("data/");
SavegameManager savegame_manager("savegames/savegames.scm");
StatManager stat_manager("savegames/variables.scm");
Resource::init();
Display::create_window(NULL_FRAMEBUFFER, Size(), false, false);
for(auto it = files.begin(); it != files.end(); ++it)
{
const Pathname& path = *it;
std::unique_ptr<Levelset> levelset = Levelset::from_file(path);
if (mode == 0)
{
std::cout << "filename : " << path << std::endl;
std::cout << "title : " << levelset->get_title() << std::endl;
std::cout << "description : " << levelset->get_description() << std::endl;
std::cout << "levels : " << std::endl;
for(int i = 0; i < levelset->get_level_count(); ++i)
{
std::cout << " " << levelset->get_level(i)->resname << std::endl;
}
std::cout << std::endl;
}
else
{
if (mode & kFilename)
{
std::cout << path << ": ";
}
if (mode & kTitle)
{
std::cout << levelset->get_title() << std::endl;
}
if (mode & kDescription)
{
std::cout << levelset->get_description() << std::endl;
}
if (mode & kLevels)
{
for(int i = 0; i < levelset->get_level_count(); ++i)
{
std::cout << " " << levelset->get_level(i)->resname << std::endl;
}
std::cout << std::endl;
}
}
}
Resource::deinit();
}
return 0;
}
/* EOF */
|