Skip to content

Commit 2fb4a5d

Browse files
committed
- Support right-aligned text.
1 parent 18faee1 commit 2fb4a5d

File tree

9 files changed

+182
-181
lines changed

9 files changed

+182
-181
lines changed

cube/swiss/source/devices/wiikeyfusion/wkf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ void wkfCheckSwitches() {
281281
{
282282
uiDrawObj_t* warning = DrawContainer();
283283
print_debug("Invalid Switch config detected: [0x%08X]\n", wkfReadSpecial3());
284-
DrawAddChild(warning, DrawStyledLabel(640/2, 200, "*** WKF / WASP WARNING ***", 1.5f, true, defaultColor));
284+
DrawAddChild(warning, DrawStyledLabel(640/2, 200, "*** WKF / WASP WARNING ***", 1.5f, ALIGN_CENTER, defaultColor));
285285
sprintf(txtbuffer,"Invalid WKF/WASP Switch config detected: [0x%08X]", wkfReadSpecial3());
286-
DrawAddChild(warning, DrawStyledLabel(640/2, 250, txtbuffer, 0.75f, true, defaultColor));
287-
DrawAddChild(warning, DrawStyledLabel(640/2, 280, "This will cause slowdown in games!", 0.8f, true, defaultColor));
288-
DrawAddChild(warning, DrawStyledLabel(640/2, 310, "Please set SW3 & SW4 to ON to fix this", 0.8f, true, defaultColor));
286+
DrawAddChild(warning, DrawStyledLabel(640/2, 250, txtbuffer, 0.75f, ALIGN_CENTER, defaultColor));
287+
DrawAddChild(warning, DrawStyledLabel(640/2, 280, "This will cause slowdown in games!", 0.8f, ALIGN_CENTER, defaultColor));
288+
DrawAddChild(warning, DrawStyledLabel(640/2, 310, "Please set SW3 & SW4 to ON to fix this", 0.8f, ALIGN_CENTER, defaultColor));
289289
DrawPublish(warning);
290290
sleep(5);
291291
DrawDispose(warning);

cube/swiss/source/gui/FrameBufferMagic.c

Lines changed: 52 additions & 54 deletions
Large diffs are not rendered by default.

cube/swiss/source/gui/FrameBufferMagic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ uiDrawObj_t* DrawSelectableButton(int x1, int y1, int x2, int y2, const char *me
113113
uiDrawObj_t* DrawEmptyBox(int x1, int y1, int x2, int y2);
114114
uiDrawObj_t* DrawEmptyColouredBox(int x1, int y1, int x2, int y2, GXColor colour);
115115
uiDrawObj_t* DrawTransparentBox(int x1, int y1, int x2, int y2);
116-
uiDrawObj_t* DrawStyledLabel(int x, int y, const char *string, float size, bool centered, GXColor color);
117-
uiDrawObj_t* DrawStyledLabelWithCaret(int x, int y, const char *string, float size, bool centered, GXColor color, int caretPosition);
116+
uiDrawObj_t* DrawStyledLabel(int x, int y, const char *string, float size, int align, GXColor color);
117+
uiDrawObj_t* DrawStyledLabelWithCaret(int x, int y, const char *string, float size, int align, GXColor color, int caretPosition);
118118
uiDrawObj_t* DrawLabel(int x, int y, const char *string);
119119
uiDrawObj_t* DrawFadingLabel(int x, int y, const char *string, float size);
120120
uiDrawObj_t* DrawMenuButtons(int selection);

cube/swiss/source/gui/IPLFontWrite.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void drawFontInit(void)
9191
GX_SetCullMode (GX_CULL_NONE);
9292
}
9393

94-
void drawString(int x, int y, char *string, float scale, bool centered, GXColor fontColor)
94+
void drawString(int x, int y, char *string, float scale, int align, GXColor fontColor)
9595
{
9696
if(string == NULL) {
9797
return;
@@ -100,7 +100,7 @@ void drawString(int x, int y, char *string, float scale, bool centered, GXColor
100100
Mtx GXmodelView2D;
101101
int strWidth = 0;
102102
int strHeight = font->cell_height;
103-
if(centered)
103+
if(align)
104104
{
105105
char* string_work = string;
106106
while(*string_work)
@@ -110,7 +110,7 @@ void drawString(int x, int y, char *string, float scale, bool centered, GXColor
110110
string_work++;
111111
}
112112
}
113-
guMtxTrans(GXmodelView2D, -strWidth/2, -strHeight/2, 0);
113+
guMtxTrans(GXmodelView2D, -(align*strWidth)/2, -strHeight/2, 0);
114114
guMtxScaleApply(GXmodelView2D, GXmodelView2D, scale, scale, 1);
115115
guMtxTransApply(GXmodelView2D, GXmodelView2D, x, y, 0);
116116
GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);
@@ -143,7 +143,7 @@ void drawString(int x, int y, char *string, float scale, bool centered, GXColor
143143
}
144144
}
145145

146-
void drawStringWithCaret(int x, int y, char *string, float scale, bool centered, GXColor fontColor, int caretPosition, GXColor caretColor)
146+
void drawStringWithCaret(int x, int y, char *string, float scale, int align, GXColor fontColor, int caretPosition, GXColor caretColor)
147147
{
148148
if(string == NULL) {
149149
string = "";
@@ -152,7 +152,7 @@ void drawStringWithCaret(int x, int y, char *string, float scale, bool centered,
152152
Mtx GXmodelView2D;
153153
int strWidth = 0;
154154
int strHeight = font->cell_height;
155-
if(centered)
155+
if(align)
156156
{
157157
char* string_work = string;
158158
while(*string_work)
@@ -162,7 +162,7 @@ void drawStringWithCaret(int x, int y, char *string, float scale, bool centered,
162162
string_work++;
163163
}
164164
}
165-
guMtxTrans(GXmodelView2D, -strWidth/2, -strHeight/2, 0);
165+
guMtxTrans(GXmodelView2D, -(align*strWidth)/2, -strHeight/2, 0);
166166
guMtxScaleApply(GXmodelView2D, GXmodelView2D, scale, scale, 1);
167167
guMtxTransApply(GXmodelView2D, GXmodelView2D, x, y, 0);
168168
GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);
@@ -225,7 +225,7 @@ int GetCharsThatFitInWidth(char *string, int max, float scale)
225225
}
226226

227227
// maxSize is how far we can draw, abbreviate with "..." if we're going to exceed it.
228-
void drawStringEllipsis(int x, int y, char *string, float scale, bool centered, GXColor fontColor, bool rotateVertical, int maxSize)
228+
void drawStringEllipsis(int x, int y, char *string, float scale, int align, GXColor fontColor, bool rotateVertical, int maxSize)
229229
{
230230
if(string == NULL) {
231231
return;
@@ -239,7 +239,7 @@ void drawStringEllipsis(int x, int y, char *string, float scale, bool centered,
239239
}
240240
int strWidth = 0;
241241
int strHeight = font->cell_height;
242-
if(centered)
242+
if(align)
243243
{
244244
char* string_work = string;
245245
while(*string_work)
@@ -249,7 +249,7 @@ void drawStringEllipsis(int x, int y, char *string, float scale, bool centered,
249249
string_work++;
250250
}
251251
}
252-
guMtxApplyTrans(GXmodelView2D, GXmodelView2D, -strWidth/2, -strHeight/2, 0);
252+
guMtxApplyTrans(GXmodelView2D, GXmodelView2D, -(align*strWidth)/2, -strHeight/2, 0);
253253
guMtxScaleApply(GXmodelView2D, GXmodelView2D, scale, scale, 1);
254254
guMtxTransApply(GXmodelView2D, GXmodelView2D, x, y, 0);
255255
GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);

cube/swiss/source/gui/IPLFontWrite.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414

1515
#define wait_press_A() ({while((padsButtonsHeld() & PAD_BUTTON_A)){VIDEO_WaitVSync();} while(!(padsButtonsHeld() & PAD_BUTTON_A)){VIDEO_WaitVSync();}})
1616

17+
#define ALIGN_LEFT 0
18+
#define ALIGN_CENTER 1
19+
#define ALIGN_RIGHT 2
20+
1721
extern GXColor defaultColor;
1822
extern GXColor disabledColor;
1923
extern GXColor deSelectedColor;
2024
extern char txtbuffer[2048];
2125

2226
void init_font(void);
23-
void drawString(int x, int y, char *string, float scale, bool centered, GXColor fontColor);
24-
void drawStringWithCaret(int x, int y, char *string, float scale, bool centered, GXColor fontColor, int caretPosition, GXColor caretColor);
25-
void drawStringEllipsis(int x, int y, char *string, float scale, bool centered, GXColor fontColor, bool rotateVertical, int maxSize);
27+
void drawString(int x, int y, char *string, float scale, int align, GXColor fontColor);
28+
void drawStringWithCaret(int x, int y, char *string, float scale, int align, GXColor fontColor, int caretPosition, GXColor caretColor);
29+
void drawStringEllipsis(int x, int y, char *string, float scale, int align, GXColor fontColor, bool rotateVertical, int maxSize);
2630
int GetFontHeight(float scale);
2731
int GetTextSizeInPixels(char *string);
2832
float GetTextScaleToFitInWidth(char *string, int width);

0 commit comments

Comments
 (0)