emptied textcomponent for rewriting
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -60,7 +60,7 @@
|
|||||||
"RelativeDocumentMoniker": "src\\game\\components\\TextComponent.cpp",
|
"RelativeDocumentMoniker": "src\\game\\components\\TextComponent.cpp",
|
||||||
"ToolTip": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TextComponent.cpp",
|
"ToolTip": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TextComponent.cpp",
|
||||||
"RelativeToolTip": "src\\game\\components\\TextComponent.cpp",
|
"RelativeToolTip": "src\\game\\components\\TextComponent.cpp",
|
||||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABAAAAAPAAAAAAAAAA==",
|
"ViewState": "AgIAAAAAAAAAAAAAAAAAABkAAAAAAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||||
"WhenOpened": "2025-07-13T20:09:50.139Z",
|
"WhenOpened": "2025-07-13T20:09:50.139Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TextComponent.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TextComponent.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||||
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\game\\components\\TextComponent.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\game\\components\\TextComponent.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\core\\Engine.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||||
|
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\core\\Engine.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\core\\Engine.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\core\\Engine.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||||
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\core\\Engine.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\core\\Engine.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||||
@ -18,10 +22,6 @@
|
|||||||
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\Component.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\Component.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||||
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\game\\components\\Component.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\game\\components\\Component.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\core\\Engine.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
|
||||||
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\core\\Engine.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TransformComponent.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
"AbsoluteMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TransformComponent.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||||
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\game\\components\\TransformComponent.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
"RelativeMoniker": "D:0:0:{5653811A-38D1-4D9D-9446-A417E8557584}|ShadowCrestGameEngine.vcxproj|solutionrelative:src\\game\\components\\TransformComponent.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||||
@ -60,7 +60,7 @@
|
|||||||
"RelativeDocumentMoniker": "src\\game\\components\\TextComponent.cpp",
|
"RelativeDocumentMoniker": "src\\game\\components\\TextComponent.cpp",
|
||||||
"ToolTip": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TextComponent.cpp",
|
"ToolTip": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TextComponent.cpp",
|
||||||
"RelativeToolTip": "src\\game\\components\\TextComponent.cpp",
|
"RelativeToolTip": "src\\game\\components\\TextComponent.cpp",
|
||||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABkAAAAAAAAAAAAAAA==",
|
"ViewState": "AgIAAAAAAAAAAAAAAAAAABIAAAA5AAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||||
"WhenOpened": "2025-07-13T20:09:50.139Z",
|
"WhenOpened": "2025-07-13T20:09:50.139Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
@ -79,7 +79,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 3,
|
"DocumentIndex": 4,
|
||||||
"Title": "Component.hpp",
|
"Title": "Component.hpp",
|
||||||
"DocumentMoniker": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\Component.hpp",
|
"DocumentMoniker": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\Component.hpp",
|
||||||
"RelativeDocumentMoniker": "src\\game\\components\\Component.hpp",
|
"RelativeDocumentMoniker": "src\\game\\components\\Component.hpp",
|
||||||
@ -87,12 +87,11 @@
|
|||||||
"RelativeToolTip": "src\\game\\components\\Component.hpp",
|
"RelativeToolTip": "src\\game\\components\\Component.hpp",
|
||||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAgAAAAZAAAAAAAAAA==",
|
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAgAAAAZAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
|
||||||
"WhenOpened": "2025-07-13T19:24:03.306Z",
|
"WhenOpened": "2025-07-13T19:24:03.306Z"
|
||||||
"EditorCaption": ""
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 2,
|
"DocumentIndex": 3,
|
||||||
"Title": "TextComponent.hpp",
|
"Title": "TextComponent.hpp",
|
||||||
"DocumentMoniker": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TextComponent.hpp",
|
"DocumentMoniker": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\game\\components\\TextComponent.hpp",
|
||||||
"RelativeDocumentMoniker": "src\\game\\components\\TextComponent.hpp",
|
"RelativeDocumentMoniker": "src\\game\\components\\TextComponent.hpp",
|
||||||
@ -100,12 +99,11 @@
|
|||||||
"RelativeToolTip": "src\\game\\components\\TextComponent.hpp",
|
"RelativeToolTip": "src\\game\\components\\TextComponent.hpp",
|
||||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAwAAAAZAAAAAAAAAA==",
|
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAwAAAAZAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
|
||||||
"WhenOpened": "2025-07-13T19:18:06.662Z",
|
"WhenOpened": "2025-07-13T19:18:06.662Z"
|
||||||
"EditorCaption": ""
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 1,
|
"DocumentIndex": 2,
|
||||||
"Title": "Engine.cpp",
|
"Title": "Engine.cpp",
|
||||||
"DocumentMoniker": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\core\\Engine.cpp",
|
"DocumentMoniker": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\core\\Engine.cpp",
|
||||||
"RelativeDocumentMoniker": "src\\core\\Engine.cpp",
|
"RelativeDocumentMoniker": "src\\core\\Engine.cpp",
|
||||||
@ -113,8 +111,7 @@
|
|||||||
"RelativeToolTip": "src\\core\\Engine.cpp",
|
"RelativeToolTip": "src\\core\\Engine.cpp",
|
||||||
"ViewState": "AgIAAEsAAAAAAAAAAAAAAFkAAAAAAAAAAAAAAA==",
|
"ViewState": "AgIAAEsAAAAAAAAAAAAAAFkAAAAAAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||||
"WhenOpened": "2025-07-13T18:23:56.384Z",
|
"WhenOpened": "2025-07-13T18:23:56.384Z"
|
||||||
"EditorCaption": ""
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -139,7 +136,7 @@
|
|||||||
"Children": [
|
"Children": [
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 4,
|
"DocumentIndex": 1,
|
||||||
"Title": "Engine.hpp",
|
"Title": "Engine.hpp",
|
||||||
"DocumentMoniker": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\core\\Engine.hpp",
|
"DocumentMoniker": "C:\\Users\\steev\\Desktop\\ShadowCrestGameEngine\\src\\core\\Engine.hpp",
|
||||||
"RelativeDocumentMoniker": "src\\core\\Engine.hpp",
|
"RelativeDocumentMoniker": "src\\core\\Engine.hpp",
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1,48 +1,20 @@
|
|||||||
#include "TextComponent.hpp"
|
#include "TextComponent.hpp"
|
||||||
#include <SDL3_ttf/SDL_ttf.h>
|
#include <SDL3_ttf/SDL_ttf.h>
|
||||||
|
|
||||||
TextComponent::TextComponent(const std::string& text, const std::string& fontPath, int fontSize, SDL_Color color)
|
TextComponent::TextComponent(const std::string& text, const std::string& fontPath, int fontSize, SDL_Color color) : text(text), fontPath(fontPath), fontSize(fontSize), color(color) {
|
||||||
: text(text), fontPath(fontPath), fontSize(fontSize), color(color) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextComponent::~TextComponent() {
|
TextComponent::~TextComponent() {
|
||||||
if (texture) SDL_DestroyTexture(texture);
|
|
||||||
if (font) TTF_CloseFont(font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextComponent::Init(SDL_Renderer* renderer) {
|
void TextComponent::Init(SDL_Renderer* renderer) {
|
||||||
font = TTF_OpenFont(fontPath.c_str(), fontSize);
|
|
||||||
if (!font) {
|
|
||||||
SDL_Log("Failed to load font: %s", SDL_GetError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: implement a way to resize
|
|
||||||
SDL_Surface* surface = TTF_RenderText_Blended(font, text.c_str(), 10, color);
|
|
||||||
if (!surface) {
|
|
||||||
SDL_Log("Failed to render text surface: %s", SDL_GetError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
texture = SDL_CreateTextureFromSurface(renderer, surface);
|
|
||||||
destRect = { 0, 0, (float)surface->w, (float)surface->h };
|
|
||||||
|
|
||||||
SDL_DestroySurface(surface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextComponent::Update(float dt) {
|
void TextComponent::Update(float dt) {
|
||||||
// nothing dynamic for now
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextComponent::Render(SDL_Renderer* renderer) {
|
void TextComponent::Render(SDL_Renderer* renderer) {
|
||||||
if (texture) {
|
|
||||||
SDL_RenderTexture(renderer, texture, nullptr, &destRect);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextComponent::SetText(const std::string& newText) {
|
void TextComponent::SetText(const std::string& newText) {
|
||||||
if (newText != text) {
|
|
||||||
text = newText;
|
|
||||||
// Re-render in Init() or a helper function you could create
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user