Skip to content

Commit ed09aef

Browse files
committed
Cleanup
1 parent c5ac22e commit ed09aef

3 files changed

Lines changed: 60 additions & 67 deletions

File tree

config/glsl/hud.cfg

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ shader 0 "hud" [
2828
}
2929
]
3030

31+
shader 0 "hudtext" [
32+
attribute vec4 vvertex, vcolor;
33+
attribute vec2 vtexcoord0;
34+
uniform mat4 hudmatrix;
35+
varying vec2 texcoord0;
36+
varying vec4 colorscale;
37+
void main(void)
38+
{
39+
gl_Position = hudmatrix * vvertex;
40+
texcoord0 = vtexcoord0;
41+
colorscale = vcolor;
42+
}
43+
] [
44+
uniform sampler2DRect tex0;
45+
varying vec2 texcoord0;
46+
varying vec4 colorscale;
47+
fragdata(0) vec4 fragcolor;
48+
void main(void)
49+
{
50+
fragcolor = colorscale * texture2DRect(tex0, texcoord0);
51+
if(fragcolor.a != 0) fragcolor.rgb /= fragcolor.a;
52+
}
53+
]
54+
3155
shader 0 "hudrgb" [
3256
attribute vec4 vvertex, vcolor;
3357
attribute vec2 vtexcoord0;
@@ -125,30 +149,6 @@ shader 0 "hudrect" [
125149
}
126150
]
127151

128-
shader 0 "hudtext" [
129-
attribute vec4 vvertex, vcolor;
130-
attribute vec2 vtexcoord0;
131-
uniform mat4 hudmatrix;
132-
varying vec2 texcoord0;
133-
varying vec4 colorscale;
134-
void main(void)
135-
{
136-
gl_Position = hudmatrix * vvertex;
137-
texcoord0 = vtexcoord0;
138-
colorscale = vcolor;
139-
}
140-
] [
141-
uniform sampler2DRect tex0;
142-
varying vec2 texcoord0;
143-
varying vec4 colorscale;
144-
fragdata(0) vec4 fragcolor;
145-
void main(void)
146-
{
147-
fragcolor = colorscale * texture2DRect(tex0, texcoord0);
148-
if(fragcolor.a != 0) fragcolor.rgb = fragcolor.rgb / fragcolor.a;
149-
}
150-
]
151-
152152
shader 0 "hud3d" [
153153
attribute vec4 vvertex, vcolor;
154154
attribute vec3 vtexcoord0;

source/engine/shader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ void setupshaders()
10341034
"void main(void)\n"
10351035
"{\n"
10361036
" gl_Position = hudmatrix * vvertex;\n"
1037-
" texcoord0 = vtexcoord0;\n"
1037+
" texcoord0 = vtexcoord0;\n"
10381038
" colorscale = vcolor;\n"
10391039
"}\n",
10401040
"uniform sampler2DRect tex0;\n"

source/engine/ui.cpp

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,7 @@ namespace UI
644644

645645
void hide()
646646
{
647-
loopchildren(o,
648-
{
649-
o->hide();
650-
});
647+
Object::hide();
651648
if(onhide) execute(onhide);
652649
}
653650

@@ -827,7 +824,7 @@ namespace UI
827824
resetstate();
828825
}
829826

830-
void hide() {};
827+
void hide() { Object::hide(); };
831828

832829
bool show(Window *w)
833830
{
@@ -2035,7 +2032,7 @@ namespace UI
20352032
pophudmatrix();
20362033
}
20372034

2038-
void hide() { cleartext(); }
2035+
void hide() { Object::hide(); cleartext(); }
20392036

20402037
void cleartext()
20412038
{
@@ -2141,82 +2138,78 @@ namespace UI
21412138

21422139
struct Font : Object
21432140
{
2144-
string font;
2141+
char *font;
21452142

2146-
Font() { font[0] = '\0'; }
2143+
Font() : font(NULL) {}
2144+
~Font() { delete[] font; }
21472145

21482146
void setup(const char *name)
21492147
{
21502148
Object::setup();
2151-
copystring(font, name, MAXSTRLEN);
2149+
SETSTR(font, name);
21522150
}
21532151

2154-
#define WITHFONT(body) do { \
2155-
pushfont(); \
2156-
setfont(font); \
2157-
body; \
2158-
popfont(); \
2159-
} while(0); \
2160-
21612152
void layout()
21622153
{
2163-
WITHFONT({
2164-
Object::layout();
2165-
});
2154+
pushfont();
2155+
setfont(font);
2156+
Object::layout();
2157+
popfont();
21662158
}
21672159

21682160
void draw(float sx, float sy)
21692161
{
2170-
WITHFONT({
2171-
Object::draw(sx, sy);
2172-
});
2162+
pushfont();
2163+
setfont(font);
2164+
Object::draw(sx, sy);
2165+
popfont();
21732166
}
21742167

21752168
void buildchildren(uint *contents)
21762169
{
2177-
WITHFONT({
2178-
Object::buildchildren(contents);
2179-
});
2170+
pushfont();
2171+
setfont(font);
2172+
Object::buildchildren(contents);
2173+
popfont();
21802174
}
21812175

21822176
#define DOSTATE(flags, func) \
21832177
void func##children(float cx, float cy, int mask, bool inside, int setflags) \
21842178
{ \
2185-
WITHFONT({ \
2186-
Object::func##children(cx, cy, mask, inside, setflags); \
2187-
}); \
2179+
pushfont(); \
2180+
setfont(font); \
2181+
Object::func##children(cx, cy, mask, inside, setflags); \
2182+
popfont(); \
21882183
} \
21892184
DOSTATES
21902185
#undef DOSTATE
21912186

21922187
bool rawkey(int code, bool isdown)
21932188
{
2194-
bool result;
2195-
WITHFONT({
2196-
result = Object::rawkey(code, isdown);
2197-
});
2189+
pushfont();
2190+
setfont(font);
2191+
bool result = Object::rawkey(code, isdown);
2192+
popfont();
21982193
return result;
21992194
}
22002195

22012196
bool key(int code, bool isdown)
22022197
{
2203-
bool result;
2204-
WITHFONT({
2205-
result = Object::key(code, isdown);
2206-
});
2198+
pushfont();
2199+
setfont(font);
2200+
bool result = Object::key(code, isdown);
2201+
popfont();
22072202
return result;
22082203
}
22092204

22102205
bool textinput(const char *str, int len)
22112206
{
2212-
bool result;
2213-
WITHFONT({
2214-
result = Object::textinput(str, len);
2215-
});
2207+
pushfont();
2208+
setfont(font);
2209+
bool result = Object::textinput(str, len);
2210+
popfont();
22162211
return result;
22172212
}
2218-
2219-
#undef WITHFONT
22202213
};
22212214

22222215
float uicontextscale = 0;

0 commit comments

Comments
 (0)