From 3b56c51e646723d936c5c6f27d26547a37d4f126 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 22 May 2019 20:28:53 +0200 Subject: added CFont --- src/TxdStore.cpp | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'src/TxdStore.cpp') diff --git a/src/TxdStore.cpp b/src/TxdStore.cpp index ba8eecb9..a5fc1758 100644 --- a/src/TxdStore.cpp +++ b/src/TxdStore.cpp @@ -4,6 +4,9 @@ #include "Streaming.h" #include "TxdStore.h" +WRAPPER RwTexDictionary *RwTexDictionaryGtaStreamRead(RwStream *stream) { EAXJMP(0x5924A0); } + + CPool *&CTxdStore::ms_pTxdPool = *(CPool**)0x8F5FB8; RwTexDictionary *&CTxdStore::ms_pStoredTxd = *(RwTexDictionary**)0x9405BC; @@ -32,6 +35,15 @@ CTxdStore::AddTxdSlot(const char *name) return ms_pTxdPool->GetJustIndex(def); } +void +CTxdStore::RemoveTxdSlot(int slot) +{ + TxdDef *def = GetSlot(slot); + if(def->texDict) + RwTexDictionaryDestroy(def->texDict); + ms_pTxdPool->Delete(def); +} + int CTxdStore::FindTxdSlot(const char *name) { @@ -98,33 +110,34 @@ CTxdStore::RemoveRefWithoutDelete(int slot) GetSlot(slot)->refCount--; } -/* bool CTxdStore::LoadTxd(int slot, RwStream *stream) { TxdDef *def = GetSlot(slot); - if(!rw::findChunk(stream, rw::ID_TEXDICTIONARY, nil, nil)){ - return false; - }else{ - def->texDict = rw::TexDictionary::streamRead(stream); - convertTxd(def->texDict); + + if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ + def->texDict = RwTexDictionaryGtaStreamRead(stream); return def->texDict != nil; } + printf("Failed to load TXD\n"); + return false; } bool CTxdStore::LoadTxd(int slot, const char *filename) { - rw::StreamFile stream; - if(stream.open(getPath(filename), "rb")){ - LoadTxd(slot, &stream); - stream.close(); - return true; - } - printf("Failed to open TXD\n"); - return false; + RwStream *stream; + bool ret; + + ret = false; + _rwD3D8TexDictionaryEnableRasterFormatConversion(true); + do + stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, filename); + while(stream == nil); + ret = LoadTxd(slot, stream); + RwStreamClose(stream, nil); + return ret; } -*/ void CTxdStore::RemoveTxd(int slot) -- cgit v1.2.3