neki
This commit is contained in:
@@ -17,7 +17,6 @@ namespace Game {
|
|||||||
using clock = std::chrono::steady_clock;
|
using clock = std::chrono::steady_clock;
|
||||||
|
|
||||||
enum class GameStateEnum {
|
enum class GameStateEnum {
|
||||||
MENU,
|
|
||||||
RUNNING,
|
RUNNING,
|
||||||
PAUSED,
|
PAUSED,
|
||||||
STOPPED
|
STOPPED
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace Game {
|
namespace Game {
|
||||||
GameStateEnum GameManager::mCurrentGameState = GameStateEnum::MENU;
|
GameStateEnum GameManager::mCurrentGameState = GameStateEnum::RUNNING;
|
||||||
|
|
||||||
void GameManager::run(std::stop_token stopToken) {
|
void GameManager::run(std::stop_token stopToken) {
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|||||||
@@ -9,15 +9,17 @@ namespace Game::Object {
|
|||||||
: Entity(name, font, transform), mX(x), mY(y), mConfig(config) { }
|
: Entity(name, font, transform), mX(x), mY(y), mConfig(config) { }
|
||||||
|
|
||||||
void UITextBox::start() {
|
void UITextBox::start() {
|
||||||
mTransform.x = mX - mTex->getWidth() * mTransform.adjustedScaleX() / 2.f;
|
// Compute visual box size first (respecting min sizes and scale), then center the box
|
||||||
mTransform.y = mY - mTex->getHeight() * mTransform.adjustedScaleY() / 2.f;
|
mBoxWidth = static_cast<float>(mTex ? mTex->getWidth() : 0.f) * mTransform.adjustedScaleX();
|
||||||
|
mBoxHeight = static_cast<float>(mTex ? mTex->getHeight() : 0.f) * mTransform.adjustedScaleY();
|
||||||
mBoxWidth = static_cast<float>(mTex->getWidth()) * mTransform.adjustedScaleX();
|
|
||||||
mBoxHeight = static_cast<float>(mTex->getHeight()) * mTransform.adjustedScaleY();
|
|
||||||
|
|
||||||
if (mBoxWidth < mConfig.minWidth) mBoxWidth = mConfig.minWidth;
|
if (mBoxWidth < mConfig.minWidth) mBoxWidth = mConfig.minWidth;
|
||||||
if (mBoxHeight < mConfig.minHeight) mBoxHeight = mConfig.minHeight;
|
if (mBoxHeight < mConfig.minHeight) mBoxHeight = mConfig.minHeight;
|
||||||
|
|
||||||
|
// Center using the computed box dimensions rather than raw texture size so padding/min sizes are respected
|
||||||
|
mTransform.x = mX - mBoxWidth / 2.f;
|
||||||
|
mTransform.y = mY - mBoxHeight / 2.f;
|
||||||
|
|
||||||
refreshVisualText();
|
refreshVisualText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user