working on texture manager
This commit is contained in:
1 parent
e04fcbb9bd
commit
be6a8cca9e
9 files changed
+92
-39
No files matched your search
@@ -63,12 +63,12 @@ bool DialogueOverlay::init(Renderer& renderer, const std::string& zipFile) {
|
||||
rendererRef = &renderer;
|
||||
zipFilename = zipFile;
|
||||
|
||||
textboxTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/dialogue/textbox_bg.png", zipFile));
|
||||
portraitFrameTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/dialogue/portrait_frame.png", zipFile));
|
||||
choiceMainTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/dialogue/choice_main.png", zipFile));
|
||||
choiceOptionalTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/dialogue/choice_optional.png", zipFile));
|
||||
choiceSelectedTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/dialogue/choice_selected.png", zipFile));
|
||||
cutsceneSubtitleTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/dialogue/cutscene_subtitle_bg.png", zipFile));
|
||||
textboxTexture = renderer.textureManager.LoadFromPng("resources/dialogue/textbox_bg.png", zipFile);
|
||||
portraitFrameTexture = renderer.textureManager.LoadFromPng("resources/dialogue/portrait_frame.png", zipFile);
|
||||
choiceMainTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_main.png", zipFile);
|
||||
choiceOptionalTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_optional.png", zipFile);
|
||||
choiceSelectedTexture = renderer.textureManager.LoadFromPng("resources/dialogue/choice_selected.png", zipFile);
|
||||
cutsceneSubtitleTexture = renderer.textureManager.LoadFromPng("resources/dialogue/cutscene_subtitle_bg.png", zipFile);
|
||||
|
||||
nameRenderer = std::make_unique<TextRenderer>();
|
||||
bodyRenderer = std::make_unique<TextRenderer>();
|
||||
@@ -648,14 +648,7 @@ std::shared_ptr<Texture> DialogueOverlay::loadTextureCached(const std::string& p
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = textureCache.find(path);
|
||||
if (it != textureCache.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
auto texture = std::make_shared<Texture>(CreateTextureDataFromPng(path, zipFilename));
|
||||
textureCache[path] = texture;
|
||||
return texture;
|
||||
return rendererRef->textureManager.LoadFromPng(path, zipFilename);
|
||||
}
|
||||
|
||||
void DialogueOverlay::drawQuad(Renderer& renderer, const TexturedQuad& quad, const std::shared_ptr<Texture>& texture) const {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "UiManager.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace ZL::Dialogue {
|
||||
@@ -90,8 +89,6 @@ private:
|
||||
TexturedQuad skipProgressFillQuad;
|
||||
mutable std::vector<TexturedQuad> choiceQuads;
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<Texture>> textureCache;
|
||||
|
||||
void drawDialogue(Renderer& renderer, const PresentationModel& model);
|
||||
void drawCutscene(Renderer& renderer, const PresentationModel& model);
|
||||
|
||||
|
||||
Reference in new issue
Block a user