JNR
Main Page
Modules
Class List
File List
uiSkin.cpp
1
/*
2
3
Jump'n'Run Engine
4
http://www.atanaslaskov.com/jnr/
5
6
BSD LICENSE
7
Copyright (c) 2007-2013, Atanas Laskov
8
All rights reserved.
9
10
Redistribution and use in source and binary forms, with or without
11
modification, are permitted provided that the following conditions are met:
12
1. Redistributions of source code must retain the above copyright notice,
13
this list of conditions and the following disclaimer.
14
2. Redistributions in binary form must reproduce the above copyright notice,
15
this list of conditions and the following disclaimer in the documentation
16
and/or other materials provided with the distribution.
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
*/
29
30
//
31
// uiSkin.cpp
32
// Dependent: -
33
//
34
// UI Skin
35
//
36
#include "stdafx.h"
37
#include "GUI.h"
38
39
//TODO: Remove all GL dependencies; Move to the laRenderer interface
40
#include <gl/gl.h>
41
//#include <laEngine/GL_TEXtures.h>
42
43
44
bool
uiSkinParameter::load(FILE* f,
char
* strPrefix)
45
{
46
char
s[128], txf[128];
47
48
//Type
49
//
50
fscanf(f,
"%s"
, s);
51
52
if
(!strcmp(s,
"tex"
))
53
{
54
bool
tileu=
false
, tilev=
false
;
55
char
s1[16], s2[16];
56
57
//simple texture with no transparency
58
fscanf(f,
"%s%s%s"
, s,s1,s2);
59
sprintf(txf,
"%s%s"
, strPrefix, s);
60
if
(!strcmp(s1,
"yes"
))tileu=
true
;
61
if
(!strcmp(s2,
"yes"
))tilev=
true
;
62
tVal.load(txf,
laTextureParams
(
M_TEX_SIMPLE
, tileu, tilev));
63
64
}
else
if
(!strcmp(s,
"atx"
))
65
{
66
bool
tileu=
false
, tilev=
false
;
67
char
s1[16], s2[16];
68
69
//texture with an alpha channel
70
fscanf(f,
"%s%s%s"
, s,s1,s2);
71
sprintf(txf,
"%s%s"
, strPrefix, s);
72
if
(!strcmp(s1,
"yes"
))tileu=
true
;
73
if
(!strcmp(s2,
"yes"
))tilev=
true
;
74
tVal.load(txf,
laTextureParams
(
M_TEX_TMAP
, tileu, tilev) );
75
}
76
else
if
(!strcmp(s,
"val"
))
77
{
78
//value
79
float
ft;
80
fscanf(f,
"%f"
, &ft);
81
dVal = (double)ft;
82
}
83
else
if
(!strcmp(s,
"str"
))
84
{
85
//string
86
UtGetStrUntil(f, s,
'*'
);
87
UtGetStrUntil(f, s,
'*'
);
88
strcpy(sVal,s);
89
}
90
else
if
(!strcmp(s,
"col"
))
91
{
92
//color
93
unsigned
r, g, b, a;
94
fscanf(f,
"%u %u %u %u"
, &r, &g, &b, &a);
95
cVal = laColor(r,g,b,a);
96
}
97
else
if
(!strcmp(s,
"fnt"
))
98
{
99
//value
100
UtGetStrUntil(f, s,
'*'
);
101
UtGetStrUntil(f, s,
'*'
);
102
103
//int id;
104
//fscanf(f, "%d", &id);
105
106
fVal = laSystemIntegrator::getRenderer()->
font
(s);
107
108
}
109
else
return
false
;
110
return
true
;
111
}
112
113
uiSkin::uiSkin(
void
)
114
{
115
}
116
117
uiSkin::~uiSkin(
void
)
118
{
119
}
120
121
void
uiSkin::load(
char
* skin)
122
{
123
FILE *f;
124
char
strFile[128], strPrefix[128], name[128];
125
126
sprintf(strFile,
"ui\\skins\\%s.uis"
, skin);
127
sprintf(strPrefix,
"ui\\%s\\"
, skin);
128
129
f = fopen(strFile,
"r"
);
130
if
(!f)
throw
laError
(
"uiSkin::Load: Can't open file (%s)"
, strFile);
131
132
while
(1)
133
{
134
//name
135
fscanf(f,
"%s"
, name);
136
if
(!strcmp(name,
"END."
))
return
;
137
138
//load
139
_mParameters[name].load(f, strPrefix);
140
}
141
142
fclose(f);
143
}
144
145
void
uiSkin::activate()
146
{
147
uiSkinUser::_pSkin =
this
;
148
}
149
150
void
uiSkin::kill()
151
{
152
}
laRenderer::font
laFont * font(char *strName)
Get a font renderer.
Definition:
laRenderer.h:192
laTextureParams
Texture creation parameters used by laTexture.
Definition:
laRenderer.h:45
M_TEX_SIMPLE
#define M_TEX_SIMPLE
Simple texture (no transparency)
Definition:
Core-Parameters.h:137
M_TEX_TMAP
#define M_TEX_TMAP
Transparent texture with an alpha channel.
Definition:
Core-Parameters.h:138
laError
Error handling class.
Definition:
laError.h:46
Source
GUI
uiSkin.cpp
Generated by
1.8.9.1