summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/Font.cpp51
-rw-r--r--src/render/Font.h3
-rw-r--r--src/render/Sprite2d.cpp41
-rw-r--r--src/render/Sprite2d.h4
4 files changed, 45 insertions, 54 deletions
diff --git a/src/render/Font.cpp b/src/render/Font.cpp
index 99d63ea4..961dc20d 100644
--- a/src/render/Font.cpp
+++ b/src/render/Font.cpp
@@ -394,7 +394,7 @@ CFont::PrintChar(float x, float y, wchar c)
CSprite2d::AddToBuffer(
CRect(x, y,
x + 32.0f * RenderState.scaleX * w,
- y + 32.0f * RenderState.scaleX * 0.5f),
+ y + 32.0f * RenderState.scaleY * 0.5f),
RenderState.color,
xoff / 16.0f, yoff / 16.0f,
(xoff + w) / 16.0f, yoff / 16.0f,
@@ -811,8 +811,8 @@ CFont::PrintString(float x, float y, uint32, wchar *start, wchar *end, float spw
RenderState.style = Details.style;
}
- float dropShadowPosition = CFont::Details.dropShadowPosition;
- if (dropShadowPosition != 0.0f && (CFont::Details.style == FONT_BANK || CFont::Details.style == FONT_STANDARD)) {
+ float dropShadowPosition = Details.dropShadowPosition;
+ if (dropShadowPosition != 0.0f && (Details.style == FONT_BANK || Details.style == FONT_STANDARD)) {
CRGBA color = Details.color;
Details.color = Details.dropColor;
Details.dropShadowPosition = 0;
@@ -828,11 +828,11 @@ CFont::PrintString(float x, float y, uint32, wchar *start, wchar *end, float spw
}
Details.color = color;
Details.dropShadowPosition = dropShadowPosition;
- Details.bIsShadow = 0;
+ Details.bIsShadow = false;
}
- if (FontRenderStatePointer.pStr >= (wchar*)&FontRenderStateBuf[1024] - (end - start + 26)) // why 26?
- CFont::RenderFontBuffer();
- CFontRenderState* pRenderState = FontRenderStatePointer.pRenderState;
+ if (FontRenderStatePointer.pStr >= (wchar*)&FontRenderStateBuf[ARRAY_SIZE(FontRenderStateBuf)] - (end - start + 26)) // why 26?
+ RenderFontBuffer();
+ CFontRenderState *pRenderState = FontRenderStatePointer.pRenderState;
pRenderState->fTextPosX = x;
pRenderState->fTextPosY = y;
pRenderState->scaleX = Details.scaleX;
@@ -994,15 +994,28 @@ CFont::GetStringWidth(wchar *s, bool spaces)
} else
#endif
{
- for (; (*s != ' ' || spaces) && *s != '\0'; s++) {
- if (*s == '~') {
- s++;
- while (*s != '~') s++;
+ for (wchar c = *s; (c != ' ' || spaces) && c != '\0'; c = *(++s)) {
+ if (c == '~') {
+
+ // This is original code
+#if 0
s++;
- if (*s == ' ' && !spaces)
- break;
+ while (*s != '~') {
+ s++;
+ }
+#else
+ // TODO(Miami): This is my code to prevent fuck up until InsertPlayerControlKeysInString is done
+ if (*(s + 1) != '~') {
+ s++;
+ while (*s != '~') {
+ s++;
+ }
+ }
+#endif
+ }
+ else {
+ w += GetCharacterSize(c - ' ');
}
- w += GetCharacterSize(*s - ' ');
}
}
return w;
@@ -1136,7 +1149,7 @@ CFont::ParseToken(wchar *s)
wchar*
CFont::ParseToken(wchar* str, CRGBA &color, bool &flash, bool &bold)
{
- Details.anonymous_23 = 0;
+ Details.anonymous_23 = false;
wchar *s = str + 1;
if (Details.color.r || Details.color.g || Details.color.b)
{
@@ -1215,7 +1228,7 @@ CFont::ParseToken(wchar* str, CRGBA &color, bool &flash, bool &bold)
while (*s != '~')
++s;
if (*(++s) == '~')
- s = CFont::ParseToken(s, color, flash, bold);
+ s = ParseToken(s, color, flash, bold);
return s;
}
@@ -1260,7 +1273,7 @@ CFont::RenderFontBuffer()
color = RenderState.color;
}
if (*pRenderStateBufPointer.pStr == '~') {
- pRenderStateBufPointer.pStr = CFont::ParseToken(pRenderStateBufPointer.pStr, color, bFlash, bBold);
+ pRenderStateBufPointer.pStr = ParseToken(pRenderStateBufPointer.pStr, color, bFlash, bBold);
if (bFlash) {
if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) {
Details.bFlashState = !Details.bFlashState;
@@ -1286,9 +1299,9 @@ CFont::RenderFontBuffer()
PrintChar(textPosX + 2.0f, textPosY, c);
textPosX += 2.0f;
}
- textPosX += CFont::RenderState.scaleX * (RenderState.proportional ? Size[RenderState.style][c] : Size[RenderState.style][209]);
+ textPosX += RenderState.scaleX * (RenderState.proportional ? Size[RenderState.style][c] : Size[RenderState.style][209]);
if (c == '\0')
- textPosX += CFont::RenderState.fExtraSpace;
+ textPosX += RenderState.fExtraSpace;
}
CSprite2d::RenderVertexBuffer();
FontRenderStatePointer.pRenderState = (CFontRenderState*)FontRenderStateBuf;
diff --git a/src/render/Font.h b/src/render/Font.h
index e30caed6..ca0ed7d0 100644
--- a/src/render/Font.h
+++ b/src/render/Font.h
@@ -27,8 +27,7 @@ struct CFontDetails
uint32 bank;
int16 dropShadowPosition;
CRGBA dropColor;
- char bFlashState;
- char anonymous_21;
+ bool bFlashState;
int nFlashTimer;
bool anonymous_23;
uint32 anonymous_25;
diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp
index 3f7cea44..bf39d15e 100644
--- a/src/render/Sprite2d.cpp
+++ b/src/render/Sprite2d.cpp
@@ -430,43 +430,26 @@ void CSprite2d::Draw2DPolygon(float x1, float y1, float x2, float y2, float x3,
}
void
-CSprite2d::AddToBuffer(const CRect &r, const CRGBA &c, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10)
+CSprite2d::AddToBuffer(const CRect &r, const CRGBA &c, float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2)
{
- RwIm2DVertex* v = TempVertexBuffer;
- SetVertices(
- &v[nextBufferVertex],
- r,
- c,
- c,
- c,
- c,
- a3,
- a4,
- a5,
- a6,
- a7,
- a8,
- a9,
- a10);
- RwImVertexIndex *v12 = &TempBufferRenderIndexList[nextBufferIndex];
- v12[0] = nextBufferVertex;
- v12[1] = nextBufferVertex + 1;
- v12[2] = nextBufferVertex + 2;
- v12[3] = nextBufferVertex + 3;
- v12[4] = nextBufferVertex;
- v12[5] = nextBufferVertex + 2;
+ SetVertices(&TempVertexBuffer[nextBufferVertex], r, c, c, c, c, u0, v0, u1, v1, u3, v3, u2, v2);
+ RwImVertexIndex *pIndexList = &TempBufferRenderIndexList[nextBufferIndex];
+ pIndexList[0] = nextBufferVertex;
+ pIndexList[1] = nextBufferVertex + 1;
+ pIndexList[2] = nextBufferVertex + 2;
+ pIndexList[3] = nextBufferVertex + 3;
+ pIndexList[4] = nextBufferVertex;
+ pIndexList[5] = nextBufferVertex + 2;
nextBufferIndex += 6;
nextBufferVertex += 4;
if (IsVertexBufferFull())
RenderVertexBuffer();
}
-bool CSprite2d::IsVertexBufferFull()
+bool
+CSprite2d::IsVertexBufferFull()
{
- bool result = true;
- if (nextBufferVertex <= 380 && nextBufferIndex <= 1018)
- result = false;
- return result;
+ return (nextBufferVertex > ARRAY_SIZE(TempVertexBuffer)-128-4 || nextBufferIndex > ARRAY_SIZE(TempBufferRenderIndexList)-6);
}
void
diff --git a/src/render/Sprite2d.h b/src/render/Sprite2d.h
index 679ac496..1adb5d49 100644
--- a/src/render/Sprite2d.h
+++ b/src/render/Sprite2d.h
@@ -12,10 +12,6 @@ public:
static void SetRecipNearClip(void);
static void InitPerFrame(void);
- //static int32 GetBank(int32 n, RwTexture *tex);
- //static void AddSpriteToBank(int32 bank, const CRect &rect, const CRGBA &col,
- // float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2);
- //static void DrawBank(int32 bank);
CSprite2d(void) : m_pTexture(nil) {};
~CSprite2d(void) { Delete(); };