From 008bd6d3df469f69eaf667bc3ae357a03894bddb Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Sun, 25 Jun 2023 01:16:40 +1000 Subject: [PATCH] more!! more!!!! --- source/core/StarAssetPath.cpp | 22 +++++++- source/core/StarAssetPath.hpp | 5 ++ source/core/StarDirectives.cpp | 69 +++++++++++++++++-------- source/core/StarDirectives.hpp | 8 +-- source/core/StarLexicalCast.hpp | 2 +- source/frontend/StarMainInterface.cpp | 5 +- source/game/StarAnimation.cpp | 9 +--- source/game/StarAnimation.hpp | 5 +- source/game/StarDrawable.cpp | 2 +- source/game/StarParticle.cpp | 20 ++++--- source/game/StarParticle.hpp | 6 ++- source/game/items/StarArmors.cpp | 2 +- source/windowing/StarGuiContext.cpp | 14 ++--- source/windowing/StarGuiContext.hpp | 14 ++--- source/windowing/StarItemSlotWidget.cpp | 7 ++- source/windowing/StarPortraitWidget.cpp | 2 +- source/windowing/StarPortraitWidget.hpp | 6 +-- 17 files changed, 125 insertions(+), 73 deletions(-) diff --git a/source/core/StarAssetPath.cpp b/source/core/StarAssetPath.cpp index b49f24d..82eca93 100644 --- a/source/core/StarAssetPath.cpp +++ b/source/core/StarAssetPath.cpp @@ -147,8 +147,13 @@ bool AssetPath::operator==(AssetPath const& rhs) const { return tie(basePath, subPath, directives) == tie(rhs.basePath, rhs.subPath, rhs.directives); } +AssetPath::AssetPath(const char* path) { + *this = move(AssetPath::split(path)); +} + + AssetPath::AssetPath(String const& path) { - *this = move(AssetPath::split(path)); // split code should probably be in here, but whatever + *this = move(AssetPath::split(path)); } AssetPath::AssetPath(String&& basePath, Maybe&& subPath, DirectivesGroup&& directives) { @@ -182,4 +187,19 @@ size_t hash::operator()(AssetPath const& s) const { return hashOf(s.basePath, s.subPath, s.directives); } +DataStream& operator>>(DataStream& ds, AssetPath& path) { + String string; + ds.read(string); + + path = move(string); + + return ds; +} + +DataStream& operator<<(DataStream& ds, AssetPath const& path) { + ds.write(AssetPath::join(path)); + + return ds; +} + } diff --git a/source/core/StarAssetPath.hpp b/source/core/StarAssetPath.hpp index fd77005..93fa8eb 100644 --- a/source/core/StarAssetPath.hpp +++ b/source/core/StarAssetPath.hpp @@ -3,6 +3,7 @@ #include "StarDirectives.hpp" #include "StarHash.hpp" +#include "StarDataStream.hpp" namespace Star { @@ -53,6 +54,7 @@ struct AssetPath { static String relativeTo(String const& sourcePath, String const& givenPath); AssetPath() = default; + AssetPath(const char* path); AssetPath(String const& path); AssetPath(String&& basePath, Maybe&& subPath, DirectivesGroup&& directives); AssetPath(const String& basePath, const Maybe& subPath, const DirectivesGroup& directives); @@ -63,6 +65,9 @@ struct AssetPath { bool operator==(AssetPath const& rhs) const; }; +DataStream& operator>>(DataStream& ds, AssetPath& path); +DataStream& operator<<(DataStream& ds, AssetPath const& path); + std::ostream& operator<<(std::ostream& os, AssetPath const& rhs); template <> diff --git a/source/core/StarDirectives.cpp b/source/core/StarDirectives.cpp index 4a2ca4c..9214abf 100644 --- a/source/core/StarDirectives.cpp +++ b/source/core/StarDirectives.cpp @@ -23,23 +23,24 @@ Directives::Entry::Entry(Entry const& other) { Directives::Directives() : hash(0) {} Directives::Directives(String const& directives) : hash(0) { - parse(directives); + string = directives; + parse(string); } Directives::Directives(String&& directives) : hash(0) { - String mine = move(directives); - parse(mine); + string = move(directives); + parse(string); } -Directives::Directives(const char* directives) : hash(0) { - String string(directives); +Directives::Directives(const char* directives) : hash(0), string(directives) { parse(string); } Directives::Directives(List&& newEntries) { entries = std::make_shared const>(move(newEntries)); - String directives = toString(); // This needs to be better - hash = XXH3_64bits(directives.utf8Ptr(), directives.utf8Size()); + String newString; + string = move(buildString(newString)); + hash = XXH3_64bits(string.utf8Ptr(), string.utf8Size()); } void Directives::parse(String const& directives) { @@ -51,8 +52,12 @@ void Directives::parse(String const& directives) { newList.reserve(split.size()); for (String& str : split) { if (!str.empty()) { - ImageOperation operation = imageOperationFromString(str); - newList.emplace_back(move(operation), move(str)); + try { + ImageOperation operation = imageOperationFromString(str); + newList.emplace_back(move(operation), move(str)); + } catch (StarException const& e) { + Logger::logf(LogLevel::Error, "Error parsing image operation: %s", e.what()); + } } } @@ -65,27 +70,29 @@ void Directives::parse(String const& directives) { // Logger::logf(LogLevel::Debug, "Directives: Parsed %u character long string", directives.utf8Size()); } -void Directives::buildString(String& out) const { +String& Directives::buildString(String& out) const { if (entries) { for (auto& entry : *entries) { out += "?"; out += entry.string; } } + + return out; } String Directives::toString() const { - String result; - buildString(result); - //if (result.utf8Size() > 1000) - // Logger::logf(LogLevel::Debug, "Directives: Rebuilt %u character long string", result.utf8Size()); - return result; + return string; } inline bool Directives::empty() const { return !entries || entries->empty(); } +inline Directives::operator bool() const { + return !empty(); +} + DataStream& operator>>(DataStream& ds, Directives& directives) { String string; @@ -103,19 +110,37 @@ DataStream& operator<<(DataStream& ds, Directives const& directives) { } DirectivesGroup::DirectivesGroup() : m_count(0) {} -DirectivesGroup::DirectivesGroup(String const& directives) { - m_directives.emplace_back(directives); - m_count = m_directives.back().entries->size(); +DirectivesGroup::DirectivesGroup(String const& directives) : m_count(0) { + if (directives.empty()) + return; + + Directives parsed(directives); + if (parsed) { + m_directives.emplace_back(move(parsed)); + m_count = m_directives.back().entries->size(); + } } -DirectivesGroup::DirectivesGroup(String&& directives) { - m_directives.emplace_back(move(directives)); - m_count = m_directives.back().entries->size(); +DirectivesGroup::DirectivesGroup(String&& directives) : m_count(0) { + if (directives.empty()) { + directives.clear(); + return; + } + + Directives parsed(move(directives)); + if (parsed) { + m_directives.emplace_back(move(parsed)); + m_count = m_directives.back().entries->size(); + } } inline bool DirectivesGroup::empty() const { return m_count == 0; } +inline DirectivesGroup::operator bool() const { + return empty(); +} + inline bool DirectivesGroup::compare(DirectivesGroup const& other) const { if (m_count != other.m_count) return false; @@ -156,7 +181,7 @@ inline String DirectivesGroup::toString() const { void DirectivesGroup::addToString(String& string) const { for (auto& directives : m_directives) - directives.buildString(string); + string += directives.string; } void DirectivesGroup::forEach(DirectivesCallback callback) const { diff --git a/source/core/StarDirectives.hpp b/source/core/StarDirectives.hpp index ca4364c..440b33a 100644 --- a/source/core/StarDirectives.hpp +++ b/source/core/StarDirectives.hpp @@ -12,12 +12,11 @@ STAR_CLASS(DirectivesGroup); STAR_EXCEPTION(DirectivesException, StarException); // Kae: My attempt at reducing memory allocation and per-frame string parsing for extremely long directives -// entries must never be a null ptr! class Directives { public: struct Entry { ImageOperation operation; - String string; + String string; // One day, we can make this a string_view pointing to Entry::string. Entry(ImageOperation&& newOperation, String&& newString); Entry(ImageOperation const& newOperation, String const& newString); @@ -31,15 +30,17 @@ public: Directives(List&& entries); void parse(String const& directives); - void buildString(String& out) const; + String& buildString(String& out) const; String toString() const; inline bool empty() const; + inline operator bool() const; friend DataStream& operator>>(DataStream& ds, Directives& directives); friend DataStream& operator<<(DataStream& ds, Directives const& directives); std::shared_ptr const> entries; size_t hash = 0; + String string; }; class DirectivesGroup { @@ -51,6 +52,7 @@ public: void parseDirectivesIntoLeaf(String const& directives); inline bool empty() const; + inline operator bool() const; bool compare(DirectivesGroup const& other) const; void append(Directives const& other); void append(List&& entries); diff --git a/source/core/StarLexicalCast.hpp b/source/core/StarLexicalCast.hpp index bee2692..6e6c66e 100644 --- a/source/core/StarLexicalCast.hpp +++ b/source/core/StarLexicalCast.hpp @@ -47,7 +47,7 @@ Type lexicalCast(std::string const& s, std::ios_base::fmtflags flags = std::ios_ if (m) return m.take(); else - throw BadLexicalCast(); + throw BadLexicalCast(strf("Lexical cast failed on '%s'", s)); } template diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index 18a3b70..1dcb6c4 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -965,9 +965,8 @@ void MainInterface::renderBreath() { size_t blocks = round((10 * breath) / breathMax); if (blocks < 10) { - String path = "/interface/breath/breath.png"; - m_guiContext->drawQuad(path, - RectF::withCenter(breathBackgroundCenterPos, Vec2F(imgMetadata->imageSize(path)) * interfaceScale())); + String breathPath = "/interface/breath/breath.png"; + m_guiContext->drawQuad(breathPath, RectF::withCenter(breathBackgroundCenterPos, Vec2F(imgMetadata->imageSize(breathPath)) * interfaceScale())); for (size_t i = 0; i < 10; i++) { if (i >= blocks) { if (blocks == 0 && Time::monotonicMilliseconds() % 500 > 250) diff --git a/source/game/StarAnimation.cpp b/source/game/StarAnimation.cpp index be13975..7f3847c 100644 --- a/source/game/StarAnimation.cpp +++ b/source/game/StarAnimation.cpp @@ -43,14 +43,10 @@ void Animation::setAngle(float angle) { m_angle = angle; } -void Animation::setProcessing(String processing) { +void Animation::setProcessing(Directives processing) { m_processing = move(processing); } -void Animation::addProcessing(String const& processing) { - m_processing = String::joinWith("?", m_processing, processing); -} - void Animation::setColor(Color color) { m_color = color; } @@ -73,9 +69,8 @@ Drawable Animation::drawable(float pixelSize) const { if (m_appendFrame) baseFrame += ":" + toString(m_frame); - baseFrame = String::joinWith("?", baseFrame, m_processing); - Drawable drawable = Drawable::makeImage(move(baseFrame), pixelSize, m_centered, m_offset); + drawable.imagePart().addDirectives(m_processing); drawable.rotate(m_angle); drawable.color = m_color; return drawable; diff --git a/source/game/StarAnimation.hpp b/source/game/StarAnimation.hpp index 1294fd0..e4a2ece 100644 --- a/source/game/StarAnimation.hpp +++ b/source/game/StarAnimation.hpp @@ -15,8 +15,7 @@ public: void setAngle(float angle); - void setProcessing(String processing); - void addProcessing(String const& processing); + void setProcessing(Directives processing); void setColor(Color color); @@ -44,7 +43,7 @@ private: float m_angle; Vec2F m_offset; bool m_centered; - String m_processing; + Directives m_processing; Color m_color; int m_variantOffset; diff --git a/source/game/StarDrawable.cpp b/source/game/StarDrawable.cpp index e259aa2..aeb8cb6 100644 --- a/source/game/StarDrawable.cpp +++ b/source/game/StarDrawable.cpp @@ -10,7 +10,7 @@ namespace Star { Drawable::ImagePart& Drawable::ImagePart::addDirectives(Directives const& directives, bool keepImageCenterPosition) { - if (!directives.entries || directives.entries->empty()) + if (!directives) return *this; if (keepImageCenterPosition) { diff --git a/source/game/StarParticle.cpp b/source/game/StarParticle.cpp index 250b2a4..ad0c168 100644 --- a/source/game/StarParticle.cpp +++ b/source/game/StarParticle.cpp @@ -45,7 +45,6 @@ Particle::Particle() { trail = false; flippable = true; flip = false; - directives = ""; } Particle::Particle(Json const& config, String const& path) { @@ -69,6 +68,12 @@ Particle::Particle(Json const& config, String const& path) { if (type == Type::Animated) initializeAnimation(); + auto pathEnd = string.find('?'); + if (pathEnd == NPos) + directives = ""; + else + directives.parse(string.substr(pathEnd)); + if (config.contains("color")) color = jsonToColor(config.get("color")); @@ -96,9 +101,11 @@ Particle::Particle(Json const& config, String const& path) { length = config.getFloat("length", 10.0f); destructionAction = DestructionActionNames.getLeft(config.getString("destructionAction", "None")); - destructionImage = config.getString("destructionImage", ""); + String destructionImagePath = config.getString("destructionImage", ""); if (destructionAction == DestructionAction::Image) - destructionImage = AssetPath::relativeTo(path, destructionImage); + destructionImagePath = AssetPath::relativeTo(path, destructionImagePath); + destructionImage = destructionImagePath; + destructionTime = config.getFloat("destructionTime", 0.0f); timeToLive = config.getFloat("timeToLive", 0.0f); @@ -113,7 +120,6 @@ Particle::Particle(Json const& config, String const& path) { ignoreWind = config.getBool("ignoreWind", true); trail = config.getBool("trail", false); - directives = ""; } Json Particle::toJson() const { @@ -134,7 +140,7 @@ Json Particle::toJson() const { {"angularVelocity", angularVelocity * 180.0f / Constants::pi}, {"length", length}, {"destructionAction", DestructionActionNames.getRight(destructionAction)}, - {"destructionImage", destructionImage}, + {"destructionImage", AssetPath::join(destructionImage)}, {"destructionTime", destructionTime}, {"timeToLive", timeToLive}, {"layer", LayerNames.getRight(layer)}, @@ -221,7 +227,7 @@ void Particle::destructionUpdate() { size = 1.0f; color = Color::White; type = Particle::Type::Textured; - string = destructionImage; + image = destructionImage; angularVelocity = 0.0f; length = 0.0f; rotation = 0.0f; @@ -232,7 +238,7 @@ void Particle::destructionUpdate() { void Particle::initializeAnimation() { if (!animation) { animation = Animation(AssetPath::removeDirectives(string)); - animation->addProcessing(AssetPath::getDirectives(string)); + animation->setProcessing(directives); } } diff --git a/source/game/StarParticle.hpp b/source/game/StarParticle.hpp index 5dba0fa..b35cb0a 100644 --- a/source/game/StarParticle.hpp +++ b/source/game/StarParticle.hpp @@ -5,6 +5,7 @@ #include "StarColor.hpp" #include "StarBiMap.hpp" #include "StarAnimation.hpp" +#include "StarAssetPath.hpp" namespace Star { @@ -75,6 +76,8 @@ struct Particle { // Used differently depending on the type of the particle. String string; + AssetPath image; + Directives directives; Color color; Color light; @@ -95,7 +98,7 @@ struct Particle { float length; DestructionAction destructionAction; - String destructionImage; + AssetPath destructionImage; float destructionTime; float timeToLive; @@ -110,7 +113,6 @@ struct Particle { bool trail; Maybe animation; - String directives; }; DataStream& operator<<(DataStream& ds, Particle const& particle); diff --git a/source/game/items/StarArmors.cpp b/source/game/items/StarArmors.cpp index 883f3b2..71f95a2 100644 --- a/source/game/items/StarArmors.cpp +++ b/source/game/items/StarArmors.cpp @@ -21,7 +21,7 @@ ArmorItem::ArmorItem(Json const& config, String const& directory, Json const& da m_directives = instanceValue("directives", "").toString(); m_colorOptions = colorDirectivesFromConfig(config.getArray("colorOptions", JsonArray{""})); - if (!m_directives.entries || m_directives.entries->empty()) + if (!m_directives) m_directives = "?" + m_colorOptions.wrap(instanceValue("colorIndex", 0).toUInt()); refreshIconDrawables(); diff --git a/source/windowing/StarGuiContext.cpp b/source/windowing/StarGuiContext.cpp index 70ef67b..a19d684 100644 --- a/source/windowing/StarGuiContext.cpp +++ b/source/windowing/StarGuiContext.cpp @@ -135,7 +135,7 @@ void GuiContext::resetInterfaceScissorRect() { renderer()->setScissorRect({}); } -Vec2U GuiContext::textureSize(String const& texName) { +Vec2U GuiContext::textureSize(AssetPath const& texName) { return assetTextureGroup()->loadTexture(texName)->size(); } @@ -143,15 +143,15 @@ void GuiContext::drawQuad(RectF const& screenCoords, Vec4B const& color) { renderer()->render(renderFlatRect(screenCoords, color, 0.0f)); } -void GuiContext::drawQuad(String const& texName, RectF const& screenCoords, Vec4B const& color) { +void GuiContext::drawQuad(AssetPath const& texName, RectF const& screenCoords, Vec4B const& color) { renderer()->render(renderTexturedRect(assetTextureGroup()->loadTexture(texName), screenCoords, color, 0.0f)); } -void GuiContext::drawQuad(String const& texName, Vec2F const& screenPos, int pixelRatio, Vec4B const& color) { +void GuiContext::drawQuad(AssetPath const& texName, Vec2F const& screenPos, int pixelRatio, Vec4B const& color) { renderer()->render(renderTexturedRect(assetTextureGroup()->loadTexture(texName), screenPos, pixelRatio, color, 0.0f)); } -void GuiContext::drawQuad(String const& texName, RectF const& texCoords, RectF const& screenCoords, Vec4B const& color) { +void GuiContext::drawQuad(AssetPath const& texName, RectF const& texCoords, RectF const& screenCoords, Vec4B const& color) { renderer()->render(RenderQuad{assetTextureGroup()->loadTexture(texName), RenderVertex{Vec2F(screenCoords.xMin(), screenCoords.yMin()), Vec2F(texCoords.xMin(), texCoords.yMin()), color, 0.0f}, RenderVertex{Vec2F(screenCoords.xMax(), screenCoords.yMin()), Vec2F(texCoords.xMax(), texCoords.yMin()), color, 0.0f}, @@ -209,15 +209,15 @@ void GuiContext::drawInterfaceQuad(RectF const& screenCoords, Vec4B const& color drawQuad(screenCoords.scaled(interfaceScale()), color); } -void GuiContext::drawInterfaceQuad(String const& texName, Vec2F const& screenCoords, Vec4B const& color) { +void GuiContext::drawInterfaceQuad(AssetPath const& texName, Vec2F const& screenCoords, Vec4B const& color) { drawQuad(texName, screenCoords * interfaceScale(), interfaceScale(), color); } -void GuiContext::drawInterfaceQuad(String const& texName, Vec2F const& screenCoords, float scale, Vec4B const& color) { +void GuiContext::drawInterfaceQuad(AssetPath const& texName, Vec2F const& screenCoords, float scale, Vec4B const& color) { drawQuad(texName, screenCoords * interfaceScale(), interfaceScale() * scale, color); } -void GuiContext::drawInterfaceQuad(String const& texName, RectF const& texCoords, RectF const& screenCoords, Vec4B const& color) { +void GuiContext::drawInterfaceQuad(AssetPath const& texName, RectF const& texCoords, RectF const& screenCoords, Vec4B const& color) { drawQuad(texName, texCoords, screenCoords.scaled(interfaceScale()), color); } diff --git a/source/windowing/StarGuiContext.hpp b/source/windowing/StarGuiContext.hpp index 2f08394..bd46f65 100644 --- a/source/windowing/StarGuiContext.hpp +++ b/source/windowing/StarGuiContext.hpp @@ -62,12 +62,12 @@ public: void setInterfaceScissorRect(RectI const& scissor); void resetInterfaceScissorRect(); - Vec2U textureSize(String const& texName); + Vec2U textureSize(AssetPath const& texName); void drawQuad(RectF const& screenCoords, Vec4B const& color = Vec4B::filled(255)); - void drawQuad(String const& texName, RectF const& screenCoords, Vec4B const& color = Vec4B::filled(255)); - void drawQuad(String const& texName, Vec2F const& screenPos, int pixelRatio, Vec4B const& color = Vec4B::filled(255)); - void drawQuad(String const& texName, RectF const& texCoords, RectF const& screenCoords, Vec4B const& color = Vec4B::filled(255)); + void drawQuad(AssetPath const& texName, RectF const& screenCoords, Vec4B const& color = Vec4B::filled(255)); + void drawQuad(AssetPath const& texName, Vec2F const& screenPos, int pixelRatio, Vec4B const& color = Vec4B::filled(255)); + void drawQuad(AssetPath const& texName, RectF const& texCoords, RectF const& screenCoords, Vec4B const& color = Vec4B::filled(255)); void drawDrawable(Drawable drawable, Vec2F const& screenPos, int pixelRatio, Vec4B const& color = Vec4B::filled(255)); @@ -84,9 +84,9 @@ public: void drawInterfaceTriangles(List> const& triangles, Vec4B const& color); void drawInterfaceQuad(RectF const& screenCoords, Vec4B const& color = Vec4B::filled(255)); - void drawInterfaceQuad(String const& texName, Vec2F const& screenPos, Vec4B const& color = Vec4B::filled(255)); - void drawInterfaceQuad(String const& texName, Vec2F const& screenPos, float scale, Vec4B const& color = Vec4B::filled(255)); - void drawInterfaceQuad(String const& texName, RectF const& texCoords, RectF const& screenCoords, Vec4B const& color = Vec4B::filled(255)); + void drawInterfaceQuad(AssetPath const& texName, Vec2F const& screenPos, Vec4B const& color = Vec4B::filled(255)); + void drawInterfaceQuad(AssetPath const& texName, Vec2F const& screenPos, float scale, Vec4B const& color = Vec4B::filled(255)); + void drawInterfaceQuad(AssetPath const& texName, RectF const& texCoords, RectF const& screenCoords, Vec4B const& color = Vec4B::filled(255)); void drawImageStretchSet(ImageStretchSet const& imageSet, RectF const& screenPos, GuiDirection direction = GuiDirection::Horizontal, Vec4B const& color = Vec4B::filled(255)); diff --git a/source/windowing/StarItemSlotWidget.cpp b/source/windowing/StarItemSlotWidget.cpp index b317c8a..a828838 100644 --- a/source/windowing/StarItemSlotWidget.cpp +++ b/source/windowing/StarItemSlotWidget.cpp @@ -153,8 +153,7 @@ void ItemSlotWidget::renderImpl() { if (m_showLinkIndicator) { // TODO: Hardcoded - context()->drawInterfaceQuad("/interface/inventory/itemlinkindicator.png", - Vec2F(screenPosition() - Vec2I(1, 1))); + context()->drawInterfaceQuad(String("/interface/inventory/itemlinkindicator.png"), Vec2F(screenPosition() - Vec2I(1, 1))); } for (auto i : iconDrawables) @@ -179,7 +178,7 @@ void ItemSlotWidget::renderImpl() { } int frame = (int)roundf(m_progress * 18); // TODO: Hardcoded lol - context()->drawInterfaceQuad(strf("/interface/cooldown.png:%d", frame), Vec2F(screenPosition())); + context()->drawInterfaceQuad(String(strf("/interface/cooldown.png:%d", frame)), Vec2F(screenPosition())); if (m_item->count() > 1 && m_showCount) { // we don't need to tell people that there's only 1 of something context()->setFont(m_font); @@ -192,7 +191,7 @@ void ItemSlotWidget::renderImpl() { } else if (m_drawBackingImageWhenEmpty && m_backingImage != "") { context()->drawInterfaceQuad(m_backingImage, Vec2F(screenPosition())); int frame = (int)roundf(m_progress * 18); // TODO: Hardcoded lol - context()->drawInterfaceQuad(strf("/interface/cooldown.png:%d", frame), Vec2F(screenPosition())); + context()->drawInterfaceQuad(String(strf("/interface/cooldown.png:%d", frame)), Vec2F(screenPosition())); } if (m_highlightEnabled) { diff --git a/source/windowing/StarPortraitWidget.cpp b/source/windowing/StarPortraitWidget.cpp index 0966919..9341d55 100644 --- a/source/windowing/StarPortraitWidget.cpp +++ b/source/windowing/StarPortraitWidget.cpp @@ -38,7 +38,7 @@ void PortraitWidget::renderImpl() { } if (m_entity) { List portrait = m_entity->portrait(m_portraitMode); - for (auto i : portrait) { + for (auto& i : portrait) { i.scale(m_scale); context()->drawInterfaceDrawable(i, Vec2F(screenPosition() + offset)); } diff --git a/source/windowing/StarPortraitWidget.hpp b/source/windowing/StarPortraitWidget.hpp index a51aa20..c56f003 100644 --- a/source/windowing/StarPortraitWidget.hpp +++ b/source/windowing/StarPortraitWidget.hpp @@ -31,12 +31,12 @@ private: PortraitEntityPtr m_entity; PortraitMode m_portraitMode; - String m_noEntityImageFull; - String m_noEntityImagePart; + AssetPath m_noEntityImageFull; + AssetPath m_noEntityImagePart; float m_scale; bool m_iconMode; - String m_iconImage; + AssetPath m_iconImage; Vec2I m_iconOffset; };