summaryrefslogtreecommitdiffstats
path: root/src/render/Font.cpp
diff options
context:
space:
mode:
authorwithmorten <morten.with@gmail.com>2020-11-15 22:08:40 +0100
committerwithmorten <morten.with@gmail.com>2020-11-15 22:08:40 +0100
commit0669df763c5e50d506ee0a57febe993d53543447 (patch)
tree7c4f7457a98dee5d6ebbc10179f4ce6d9f9e95cb /src/render/Font.cpp
parentrevert frontend changes for invertlook4pad (diff)
parentMake collision code placement more like original (+ small fixes) (diff)
downloadre3-0669df763c5e50d506ee0a57febe993d53543447.tar
re3-0669df763c5e50d506ee0a57febe993d53543447.tar.gz
re3-0669df763c5e50d506ee0a57febe993d53543447.tar.bz2
re3-0669df763c5e50d506ee0a57febe993d53543447.tar.lz
re3-0669df763c5e50d506ee0a57febe993d53543447.tar.xz
re3-0669df763c5e50d506ee0a57febe993d53543447.tar.zst
re3-0669df763c5e50d506ee0a57febe993d53543447.zip
Diffstat (limited to '')
-rw-r--r--src/render/Font.cpp75
1 files changed, 49 insertions, 26 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;