Commit 70747e23 authored by Phillip Stephens's avatar Phillip Stephens

Fix font rendering and world teleporter in MPT and PAL

parent b5077994
......@@ -867,7 +867,9 @@ const boo::ObjToken<boo::ITexture>& CTexture::GetFontTexture(EFontType tp) {
CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
const urde::CVParamTransfer& vparms, CObjectReference* selfRef) {
u32 u32Owned = vparms.GetOwnedObj<u32>();
const CTextureInfo* inf = g_TextureCache->GetTextureInfo(tag.id);
const CTextureInfo* inf = nullptr;
if (g_TextureCache)
inf = g_TextureCache->GetTextureInfo(tag.id);
return TToken<CTexture>::GetIObjObjectFor(
std::make_unique<CTexture>(std::move(in), len, u32Owned == SBIG('OTEX'), inf));
}
......
......@@ -32,7 +32,7 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) {
u32 txtrId = (version == 5 ? in.readUint64Big() : in.readUint32Big());
x30_fontInfo = CFontInfo(tmp1, tmp2, tmp3, tmp4, name.c_str());
x80_texture = store.GetObj({FOURCC('TXTR'), txtrId});
x2c_mode = EColorType(in.readUint32Big());
x2c_mode = CTexture::EFontType(in.readUint32Big());
u32 glyphCount = in.readUint32Big();
xc_glyphs.reserve(glyphCount);
......@@ -79,7 +79,7 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) {
x1c_kerning.emplace_back(first, second, howMuch);
}
if (magic == SBIG('FONT') && version <= 2)
if (magic == SBIG('FONT') && version <= 4)
x0_initialized = true;
}
......
......@@ -103,7 +103,7 @@ class CRasterFont {
s32 x8_monoHeight = 16;
std::vector<std::pair<char16_t, CGlyph>> xc_glyphs;
std::vector<CKernPair> x1c_kerning;
EColorType x2c_mode = EColorType::Main;
CTexture::EFontType x2c_mode = CTexture::EFontType::OneLayer;
CFontInfo x30_fontInfo;
TLockedToken<CTexture> x80_texture;
s32 x8c_baseline;
......@@ -125,7 +125,20 @@ public:
s32 GetMonoWidth() const { return x4_monoWidth; }
s32 GetMonoHeight() const { return x8_monoHeight; }
EColorType GetMode() const { return x2c_mode; }
EColorType GetMode() const {
switch(x2c_mode) {
case CTexture::EFontType::OneLayer:
case CTexture::EFontType::TwoLayers:
case CTexture::EFontType::FourLayers:
return EColorType::Main;
case CTexture::EFontType::OneLayerOutline:
case CTexture::EFontType::TwoLayersOutlines:
case CTexture::EFontType::TwoLayersOutlines2:
return EColorType::Outline;
default:
return EColorType::Main;
}
}
s32 GetLineMargin() const { return x90_lineMargin; }
s32 GetCarriageAdvance() const { return GetLineMargin() + GetMonoHeight(); }
......@@ -148,7 +161,7 @@ public:
const CGlyph* GetGlyph(char16_t chr) const { return InternalGetGlyph(chr); }
void GetSize(const CDrawStringOptions& opts, int& width, int& height, const char16_t* str, int len) const;
const boo::ObjToken<boo::ITexture>& GetTexture() {
return x80_texture->GetFontTexture(CTexture::EFontType(x2c_mode));
return x80_texture->GetFontTexture(x2c_mode);
}
bool IsFinishedLoading() const;
......
......@@ -2352,7 +2352,7 @@ CEntity* ScriptLoader::LoadVisorFlare(CStateManager& mgr, CInputStream& in, int
CEntity* ScriptLoader::LoadWorldTeleporter(CStateManager& mgr, CInputStream& in, int propCount,
const CEntityInfo& info) {
if (propCount < 4 || propCount > 21) {
if (propCount < 4 || propCount > 26) {
Log.report(logvisor::Warning, fmt("Incorrect number of props for WorldTeleporter"));
return nullptr;
}
......@@ -2383,6 +2383,11 @@ CEntity* ScriptLoader::LoadWorldTeleporter(CStateManager& mgr, CInputStream& in,
float charFadeInTime = (propCount < 19 ? 0.1f : in.readFloatBig());
float charsPerSecond = (propCount < 20 ? 16.f : in.readFloatBig());
float showDelay = (propCount < 21 ? 0.f : in.readFloatBig());
std::string str1 = (propCount < 22 ? "" : in.readString());
std::string str2 = (propCount < 23 ? "" : in.readString());
/*float f1 =*/ (propCount < 24 ? 0.f : in.readFloatBig());
/*float f2 =*/ (propCount < 25 ? 0.f : in.readFloatBig());
/*float f3 =*/(propCount < 26 ? 0.f : in.readFloatBig());
if (showText)
return new CScriptWorldTeleporter(mgr.AllocateUniqueId(), name, info, active, worldId, areaId, elevatorSound,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment