Fixed bug with VN scrolling
This commit is contained in:
@ -12,7 +12,38 @@ TrueTypeAsset::TrueTypeAsset(AssetManager *assMan, std::string name) :
|
||||
Asset(assMan, name),
|
||||
loader(name + ".truetype")
|
||||
{
|
||||
this->locks.onLockRemoved = [&](usagelockid_t id){
|
||||
auto texture = this->textureByLock[id];
|
||||
|
||||
assertNotNull(texture);
|
||||
|
||||
std::vector<usagelockid_t> &lbt = this->locksByTexture[texture];
|
||||
auto it0 = std::find(lbt.begin(), lbt.end(), id);
|
||||
assertTrue(it0 != lbt.end());
|
||||
lbt.erase(it0);
|
||||
|
||||
auto it1 = this->textureByLock.find(id);
|
||||
assertTrue(it1 != this->textureByLock.end());
|
||||
this->textureByLock.erase(it1);
|
||||
|
||||
if(lbt.empty()) {
|
||||
auto it2 = locksByTexture.find(texture);
|
||||
assertTrue(it2 != locksByTexture.end());
|
||||
locksByTexture.erase(it2);
|
||||
|
||||
auto it3 = textureByStyle.begin();
|
||||
while(it3 != textureByStyle.end()) {
|
||||
if(it3->second == texture) it3 = textureByStyle.erase(it3);
|
||||
++it3;
|
||||
}
|
||||
|
||||
auto it4 = std::find(textures.begin(), textures.end(), texture);
|
||||
assertTrue(it4 != textures.end());
|
||||
textures.erase(it4);
|
||||
|
||||
delete texture;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void TrueTypeAsset::updateSync() {
|
||||
@ -161,8 +192,9 @@ usagelockid_t TrueTypeAsset::lock(struct TrueTypeFaceTextureStyle style) {
|
||||
texture = it->second;
|
||||
}
|
||||
|
||||
auto lock = texture->locks.createLock();
|
||||
auto lock = this->locks.createLock();
|
||||
this->textureByLock[lock] = texture;
|
||||
this->locksByTexture[texture].push_back(lock);
|
||||
return lock;
|
||||
}
|
||||
|
||||
@ -173,10 +205,7 @@ TrueTypeFaceTexture * TrueTypeAsset::getTexture(usagelockid_t id) {
|
||||
}
|
||||
|
||||
void TrueTypeAsset::unlock(usagelockid_t id) {
|
||||
auto it = this->textureByLock.find(id);
|
||||
assertTrue(it != this->textureByLock.end());
|
||||
it->second->locks.removeLock(id);
|
||||
this->textureByLock.erase(it);
|
||||
this->locks.removeLock(id);
|
||||
}
|
||||
|
||||
TrueTypeAsset::~TrueTypeAsset() {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "../AssetLoader.hpp"
|
||||
#include "util/flag.hpp"
|
||||
#include "display/font/truetype/TrueTypeFaceTexture.hpp"
|
||||
#include "util/UsageLock.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
enum TrueTypeAssetState {
|
||||
@ -30,6 +31,7 @@ namespace Dawn {
|
||||
|
||||
class TrueTypeAsset : public Asset {
|
||||
protected:
|
||||
UsageLock locks;
|
||||
AssetLoader loader;
|
||||
FT_Library fontLibrary;
|
||||
enum TrueTypeAssetState state = TRUE_TYPE_ASSET_STATE_INITIAL;
|
||||
@ -37,6 +39,7 @@ namespace Dawn {
|
||||
std::vector<TrueTypeFaceTexture*> textures;
|
||||
std::map<usagelockid_t, TrueTypeFaceTexture*> textureByLock;
|
||||
std::map<struct TrueTypeFaceTextureStyle, TrueTypeFaceTexture*> textureByStyle;
|
||||
std::map<TrueTypeFaceTexture*, std::vector<usagelockid_t>> locksByTexture;
|
||||
|
||||
public:
|
||||
TrueTypeAsset(AssetManager *assMan, std::string name);
|
||||
|
@ -15,10 +15,6 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
|
||||
|
||||
this->face = face;
|
||||
this->style = style;
|
||||
|
||||
this->locks.onEmpty = [&]() {
|
||||
assertUnreachable();
|
||||
};
|
||||
|
||||
// Set freetype font size prior to baking.
|
||||
if(FT_Set_Pixel_Sizes(face, 0, style.fontSize)) {
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "display/font/truetype/TrueTypeShared.hpp"
|
||||
#include "util/mathutils.hpp"
|
||||
#include "display/Texture.hpp"
|
||||
#include "util/UsageLock.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class TrueTypeAsset;
|
||||
@ -34,7 +33,6 @@ namespace Dawn {
|
||||
FT_Face face;
|
||||
std::map<FT_ULong, struct TrueTypeCharacter> characterData;
|
||||
struct TrueTypeFaceTextureStyle style;
|
||||
UsageLock locks;
|
||||
Texture texture;
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,7 @@ void VNTextboxScroller::onStart() {
|
||||
this->timeCharacter = 0;
|
||||
this->label->quadStart = 0;
|
||||
this->label->quadCount = 0;
|
||||
this->label->textOffset = glm::vec2();
|
||||
this->readyToClose = false;
|
||||
};
|
||||
x();
|
||||
|
Reference in New Issue
Block a user