summaryrefslogtreecommitdiffstats
path: root/client/gui/resource_provider.cpp
blob: b194ea9ebf68abd637028e483b014fe8fafda2ec (plain)
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
#include "common.h"

#include "resource_provider.h"
#include "debug.h"
#include "utils.h"

#include "CEGUIExceptions.h"

#include "taharez_look.scheme.c"
#include "taharez_look.imageset.c"
#include "taharez_look.tga.c"
#include "commonwealth-10.font.c"
#include "commonv2c.ttf.c"
#include "taharez_look.looknfeel.c"
#include "dejavu_sans-10.font.c"
#include "dejavu_sans.ttf.c"

//(echo "const unsigned char <struct name>[] =
//{"; od -txC -v <in file name> | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$d"
//| sed -e"\$s/,$/};/") > <out file name>.c

void CEGUIResourceProvider::loadRawDataContainer(const CEGUI::SpiceString &filename,
                                              CEGUI::RawDataContainer &output,
                                              const CEGUI::SpiceString &resourceGroup)
{
    DBG(0, "%s", filename.c_str());
    if (strcmp(filename.c_str(), "TaharezLook.scheme") == 0) {
        DBG(0, "size %d", sizeof(taharez_look_schem));
         output.setData((CEGUI::uint8*)taharez_look_schem);
         output.setSize(sizeof(taharez_look_schem));
         return;
    }

    if (strcmp(filename.c_str(), "TaharezLook.imageset") == 0) {
        DBG(0, "size %d", sizeof(taharez_look_imageset));
        output.setData((CEGUI::uint8*)taharez_look_imageset);
        output.setSize(sizeof(taharez_look_imageset));
        return;
    }

    if (strcmp(filename.c_str(), "TaharezLook.tga") == 0) {
        DBG(0, "size %d", sizeof(taharez_look_tga));
        output.setData((CEGUI::uint8*)taharez_look_tga);
        output.setSize(sizeof(taharez_look_tga));
        return;
    }

    if (strcmp(filename.c_str(), "Commonwealth-10.font") == 0) {
        DBG(0, "size %d", sizeof(commonwealth_10_font));
        output.setData((CEGUI::uint8*)commonwealth_10_font);
        output.setSize(sizeof(commonwealth_10_font));
        return;
    }

    if (strcmp(filename.c_str(), "Commonv2c.ttf") == 0) {
        DBG(0, "size %d", sizeof(commonv2c_ttf));
        output.setData((CEGUI::uint8*)commonv2c_ttf);
        output.setSize(sizeof(commonv2c_ttf));
        return;
    }

    if (strcmp(filename.c_str(), "TaharezLook.looknfeel") == 0) {
        DBG(0, "size %d", sizeof(taharez_look_looknfeel));
        output.setData((CEGUI::uint8*)taharez_look_looknfeel);
        output.setSize(sizeof(taharez_look_looknfeel));
        return;
    }

    if (strcmp(filename.c_str(), "DejaVuSans-10.font") == 0) {
        DBG(0, "size %d", sizeof(dejavu_sans_10_font));
        output.setData((CEGUI::uint8*)dejavu_sans_10_font);
        output.setSize(sizeof(dejavu_sans_10_font));
        return;
    }

    if (strcmp(filename.c_str(), "DejaVuSans.ttf") == 0) {
        DBG(0, "size %d", sizeof(dejavu_sans_ttf));
        output.setData((CEGUI::uint8*)dejavu_sans_ttf);
        output.setSize(sizeof(dejavu_sans_ttf));
        return;
    }

    throw CEGUI::GenericException("failed");
}

void CEGUIResourceProvider::unloadRawDataContainer(CEGUI::RawDataContainer& data)
{
    data.setData(NULL);
    data.setSize(0);
}

struct ResString{
    int id;
    const char* str;
} res_strings[] = {
    {STR_MESG_MISSING_HOST_NAME, "Missing host name"},
    {STR_MESG_INVALID_PORT, "Invalid port"},
    {STR_MESG_INVALID_SPORT, "Invalid sport"},
    {STR_MESG_MISSING_PORT, "Missing port"},
    {STR_MESG_CONNECTING, "Connecting to"},
    {STR_BUTTON_OK, "OK"},
    {STR_BUTTON_CANCEL, "Cancel"},
    {STR_BUTTON_CONNECT, "Connect"},
    {STR_BUTTON_QUIT, "Quit"},
    {STR_BUTTON_CLOSE, "Close"},
    {STR_BUTTON_DISCONNECT, "Disconnect"},
    {STR_BUTTON_OPTIONS, "Options"},
    {STR_BUTTON_BACK, "Back"},
    {STR_LABEL_HOST, "Host"},
    {STR_LABEL_PORT, "Port"},
    {STR_LABEL_SPORT, "Secore port"},
    {STR_LABEL_PASSWORD, "Password"},
    {0, NULL},
};

const char* res_get_string(int id)
{
    ResString *string;

    for (string = res_strings; string->str; string++) {
        if (string->id == id) {
            return string->str;
        }
    }

    return NULL;
}