~ubuntu-branches/ubuntu/trusty/manaplus/trusty

« back to all changes in this revision

Viewing changes to src/dyetool/dyemain.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-11-18 15:19:44 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20131118151944-iyd93ut2rmxzp8gg
Tags: 1.3.11.10-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  The ManaPlus Client
 
3
 *  Copyright (C) 2013  The ManaPlus Developers
 
4
 *
 
5
 *  This file is part of The ManaPlus Client.
 
6
 *
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU General Public License as published by
 
9
 *  the Free Software Foundation; either version 2 of the License, or
 
10
 *  any later version.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU General Public License
 
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
#include "logger.h"
 
22
 
 
23
#include "graphicsmanager.h"
 
24
#include "sdlshared.h"
 
25
 
 
26
#include "resources/image.h"
 
27
#include "resources/imagehelper.h"
 
28
#include "resources/imagewriter.h"
 
29
#include "resources/resourcemanager.h"
 
30
#include "resources/sdlimagehelper.h"
 
31
 
 
32
#ifdef USE_SDL2
 
33
#include "resources/surfaceimagehelper.h"
 
34
#endif
 
35
 
 
36
#include "utils/gettext.h"
 
37
#include "utils/physfstools.h"
 
38
 
 
39
#include <iostream>
 
40
 
 
41
#include <SDL.h>
 
42
 
 
43
#include "debug.h"
 
44
 
 
45
int serverVersion = 0;
 
46
 
 
47
static void printHelp()
 
48
{
 
49
    std::cout << _("dyecmd srcfile dyestring dstfile") << std::endl;
 
50
    std::cout << _("or") << std::endl;
 
51
    std::cout << _("dyecmd srcdyestring dstfile") << std::endl;
 
52
}
 
53
 
 
54
int main(int argc, char **argv)
 
55
{
 
56
    if (argc < 3 || argc > 4)
 
57
    {
 
58
        printHelp();
 
59
        return 1;
 
60
    }
 
61
 
 
62
    logger = new Logger;
 
63
    logger->setLogToStandardOut(false);
 
64
 
 
65
    PhysFs::init(argv[0]);
 
66
    SDL_Init(SDL_INIT_VIDEO);
 
67
 
 
68
    graphicsManager.createWindow(10, 10, 0, SDL_ANYFORMAT);
 
69
 
 
70
#ifdef USE_SDL2
 
71
    imageHelper = new SurfaceImageHelper;
 
72
#else
 
73
    imageHelper = new SDLImageHelper;
 
74
#endif
 
75
 
 
76
    ResourceManager *resman = new ResourceManager;
 
77
    resman->setWriteDir(".");
 
78
    resman->addToSearchPath(".", false);
 
79
    resman->addToSearchPath("/", false);
 
80
    std::string src = argv[1];
 
81
    std::string dst;
 
82
    if (argc == 4)
 
83
    {
 
84
        src.append("|").append(argv[2]);
 
85
        dst = argv[3];
 
86
    }
 
87
    else
 
88
    {
 
89
        dst = argv[2];
 
90
    }
 
91
 
 
92
    Image *image = resman->getImage(src);
 
93
    if (!image)
 
94
    {
 
95
        printf("Error loading image\n");
 
96
        return 1;
 
97
    }
 
98
    ImageWriter::writePNG(image->getSDLSurface(), dst);
 
99
    return 0;
 
100
}