summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/Font.cpp75
-rw-r--r--src/render/Font.h1
-rw-r--r--src/render/Hud.cpp20
-rw-r--r--src/render/SpecialFX.cpp2
4 files changed, 61 insertions, 37 deletions
diff --git a/src/render/Font.cpp b/src/render/Font.cpp
index 6aceaf4b..fbcc38e4 100644
--- a/src/render/Font.cpp
+++ b/src/render/Font.cpp
@@ -3,6 +3,9 @@
#include "Sprite2d.h"
#include "TxdStore.h"
#include "Font.h"
+#ifdef BUTTON_ICONS
+#include "FileMgr.h"
+#endif
void
AsciiToUnicode(const char *src, wchar *dst)
@@ -227,6 +230,7 @@ wchar foreign_table[128] = {
#ifdef BUTTON_ICONS
CSprite2d CFont::ButtonSprite[MAX_BUTTON_ICONS];
int CFont::PS2Symbol = BUTTON_NONE;
+int CFont::ButtonsSlot = -1;
#endif // BUTTON_ICONS
void
@@ -275,8 +279,8 @@ CFont::Initialise(void)
SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0));
SetJustifyOff();
SetCentreOff();
- SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
- SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
+ SetWrapx(SCREEN_WIDTH);
+ SetCentreSize(SCREEN_WIDTH);
SetBackgroundOff();
SetBackgroundColor(CRGBA(0x80, 0x80, 0x80, 0x80));
SetBackGroundOnlyTextOff();
@@ -288,28 +292,31 @@ CFont::Initialise(void)
CTxdStore::PopCurrentTxd();
#ifdef BUTTON_ICONS
- slot = CTxdStore::AddTxdSlot("buttons");
- CTxdStore::LoadTxd(slot, "MODELS/X360BTNS.TXD");
- CTxdStore::AddRef(slot);
- CTxdStore::PushCurrentTxd();
- CTxdStore::SetCurrentTxd(slot);
+ if (int file = CFileMgr::OpenFile("MODELS/X360BTNS.TXD")) {
+ CFileMgr::CloseFile(file);
+ ButtonsSlot = CTxdStore::AddTxdSlot("buttons");
+ CTxdStore::LoadTxd(ButtonsSlot, "MODELS/X360BTNS.TXD");
+ CTxdStore::AddRef(ButtonsSlot);
+ CTxdStore::PushCurrentTxd();
+ CTxdStore::SetCurrentTxd(ButtonsSlot);
#if 0 // unused
- ButtonSprite[BUTTON_UP].SetTexture("up");
- ButtonSprite[BUTTON_DOWN].SetTexture("down");
- ButtonSprite[BUTTON_LEFT].SetTexture("left");
- ButtonSprite[BUTTON_RIGHT].SetTexture("right");
+ ButtonSprite[BUTTON_UP].SetTexture("up");
+ ButtonSprite[BUTTON_DOWN].SetTexture("down");
+ ButtonSprite[BUTTON_LEFT].SetTexture("left");
+ ButtonSprite[BUTTON_RIGHT].SetTexture("right");
#endif
- ButtonSprite[BUTTON_CROSS].SetTexture("cross");
- ButtonSprite[BUTTON_CIRCLE].SetTexture("circle");
- ButtonSprite[BUTTON_SQUARE].SetTexture("square");
- ButtonSprite[BUTTON_TRIANGLE].SetTexture("triangle");
- ButtonSprite[BUTTON_L1].SetTexture("l1");
- ButtonSprite[BUTTON_L2].SetTexture("l2");
- ButtonSprite[BUTTON_L3].SetTexture("l3");
- ButtonSprite[BUTTON_R1].SetTexture("r1");
- ButtonSprite[BUTTON_R2].SetTexture("r2");
- ButtonSprite[BUTTON_R3].SetTexture("r3");
- CTxdStore::PopCurrentTxd();
+ ButtonSprite[BUTTON_CROSS].SetTexture("cross");
+ ButtonSprite[BUTTON_CIRCLE].SetTexture("circle");
+ ButtonSprite[BUTTON_SQUARE].SetTexture("square");
+ ButtonSprite[BUTTON_TRIANGLE].SetTexture("triangle");
+ ButtonSprite[BUTTON_L1].SetTexture("l1");
+ ButtonSprite[BUTTON_L2].SetTexture("l2");
+ ButtonSprite[BUTTON_L3].SetTexture("l3");
+ ButtonSprite[BUTTON_R1].SetTexture("r1");
+ ButtonSprite[BUTTON_R2].SetTexture("r2");
+ ButtonSprite[BUTTON_R3].SetTexture("r3");
+ CTxdStore::PopCurrentTxd();
+ }
#endif // BUTTON_ICONS
}
@@ -360,9 +367,11 @@ void
CFont::Shutdown(void)
{
#ifdef BUTTON_ICONS
- for (int i = 0; i < MAX_BUTTON_ICONS; i++)
- ButtonSprite[i].Delete();
- CTxdStore::RemoveTxdSlot(CTxdStore::FindTxdSlot("buttons"));
+ if (ButtonsSlot != -1) {
+ for (int i = 0; i < MAX_BUTTON_ICONS; i++)
+ ButtonSprite[i].Delete();
+ CTxdStore::RemoveTxdSlot(ButtonsSlot);
+ }
#endif
Sprite[0].Delete();
Sprite[1].Delete();
@@ -692,7 +701,14 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
y = ystart;
while(*s){
+#ifdef FIX_BUGS
+ float f = Details.centre ? Details.centreSize :
+ Details.rightJustify ? xstart - Details.rightJustifyWrap :
+ Details.wrapX;
+#else
float f = (Details.centre ? Details.centreSize : Details.wrapX);
+#endif
+
#ifdef MORE_LANGUAGES
if (IsJapaneseFont())
f -= SCREEN_SCALE_X(21.0f * 2.0f);
@@ -772,8 +788,15 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s)
x = xstart;
y = ystart;
+#ifdef FIX_BUGS
+ float xEnd = Details.centre ? Details.centreSize :
+ Details.rightJustify ? xstart - Details.rightJustifyWrap :
+ Details.wrapX;
+#else
+ float xEnd = (Details.centre ? Details.centreSize : Details.wrapX);
+#endif
while(*s){
- if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
+ if(x + GetStringWidth(s) > xEnd){
// reached end of line
if(x > maxlength)
maxlength = x;
diff --git a/src/render/Font.h b/src/render/Font.h
index be1eabed..bf747859 100644
--- a/src/render/Font.h
+++ b/src/render/Font.h
@@ -103,6 +103,7 @@ public:
static CFontDetails Details;
#ifdef BUTTON_ICONS
+ static int32 ButtonsSlot;
static CSprite2d ButtonSprite[MAX_BUTTON_ICONS];
static int PS2Symbol;
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index 3d6e59f6..de3128ce 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -336,7 +336,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f));
CFont::SetJustifyOff();
CFont::SetCentreOn();
- CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH));
+ CFont::SetCentreSize(SCREEN_WIDTH);
CFont::SetPropOn();
CFont::SetFontStyle(FONT_BANK);
@@ -740,7 +740,7 @@ void CHud::Draw()
CFont::SetRightJustifyWrap(0.0f);
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetColor(CRGBA(244, 20, 20, 255));
- CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH));
+ CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn();
@@ -869,7 +869,7 @@ void CHud::Draw()
else
CFont::SetCentreOff();
- CFont::SetWrapx(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fWrapX));
+ CFont::SetWrapx(SCALE_AND_CENTER_X(CTheScripts::IntroTextLines[i].m_fWrapX));
CFont::SetCentreSize(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fCenterSize));
if (CTheScripts::IntroTextLines[i].m_bBackground)
@@ -931,9 +931,9 @@ void CHud::Draw()
CFont::SetPropOn();
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
- float offsetX = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f);
- float center = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - offsetX;
- CFont::SetCentreSize(center);
+ float radarBulge = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f);
+ float rectWidth = SCREEN_WIDTH - SCREEN_SCALE_X(50.0f) - SCREEN_SCALE_X(8.0f) - radarBulge;
+ CFont::SetCentreSize(rectWidth);
const int16 shadow = 1;
CFont::SetDropShadowPosition(shadow);
@@ -941,7 +941,7 @@ void CHud::Draw()
CFont::SetColor(CRGBA(235, 235, 235, 255));
// I'm not sure shadow substaction was intentional here, might be a leftover if CFont::PrintString was used for a shadow draw call
- CFont::PrintString(center / 2.0f + offsetX - SCREEN_SCALE_X(shadow), SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(68.0f) - SCREEN_SCALE_Y(shadow), m_Message);
+ CFont::PrintString(rectWidth / 2.0f + radarBulge - SCREEN_SCALE_X(shadow), SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(68.0f) - SCREEN_SCALE_Y(shadow), m_Message);
CFont::SetDropShadowPosition(0);
}
@@ -957,7 +957,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(1.8f), SCREEN_SCALE_Y(1.8f));
CFont::SetPropOn();
CFont::SetCentreOn();
- CFont::SetCentreSize(SCREEN_SCALE_X(590.0f));
+ CFont::SetCentreSize(SCREEN_SCALE_X(615.0f));
CFont::SetFontStyle(FONT_HEADING);
// Appearently sliding text in here was abandoned very early, since this text is centered now.
@@ -1166,7 +1166,7 @@ void CHud::DrawAfterFade()
else
CFont::SetCentreOff();
- CFont::SetWrapx(SCREEN_SCALE_X(line.m_fWrapX));
+ CFont::SetWrapx(SCALE_AND_CENTER_X(line.m_fWrapX));
CFont::SetCentreSize(SCREEN_SCALE_X(line.m_fCenterSize));
if (line.m_bBackground)
CFont::SetBackgroundOn();
@@ -1318,7 +1318,7 @@ void CHud::DrawAfterFade()
CFont::SetScale(SCREEN_SCALE_X(1.04f), SCREEN_SCALE_Y(1.6f));
CFont::SetPropOn();
- CFont::SetRightJustifyWrap(SCREEN_SCALE_X(-500.0f));
+ CFont::SetRightJustifyWrap(SCREEN_SCALE_FROM_RIGHT(DEFAULT_SCREEN_WIDTH + 500.0f));
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
if (BigMessageX[1] >= SCREEN_SCALE_FROM_RIGHT(20.0f)) {
diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp
index 89043752..34423d83 100644
--- a/src/render/SpecialFX.cpp
+++ b/src/render/SpecialFX.cpp
@@ -1058,7 +1058,7 @@ CMoneyMessage::Render()
CFont::SetScale(fScaleX, fScaleY); // maybe use SCREEN_SCALE_X and SCREEN_SCALE_Y here?
CFont::SetCentreOn();
- CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH));
+ CFont::SetCentreSize(SCREEN_WIDTH);
CFont::SetJustifyOff();
CFont::SetColor(CRGBA(m_Colour.r, m_Colour.g, m_Colour.b, (255.0f - 255.0f * fLifeTime) * m_fOpacity));
CFont::SetBackGroundOnlyTextOff();