Fixed text rendering bug. Organized UI stuff.
This commit is contained in:
@@ -61,7 +61,7 @@ void FarmlandsGame::onRender()
|
||||
{
|
||||
m_gameState.sdlRenderer.renderBegin();
|
||||
m_gameState.gameRenderer.render();
|
||||
m_gameState.guiRenderer.render();
|
||||
// m_gameState.guiRenderer.render();
|
||||
m_guiController.render();
|
||||
m_gameState.sdlRenderer.renderEnd();
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@
|
||||
|
||||
#include <GameState.h>
|
||||
#include <controller/GuiController.h>
|
||||
#include <gui/primitives/RenderContext.h>
|
||||
#include <gui/primitives/TextArea.h>
|
||||
#include <gui/RenderContext.h>
|
||||
#include <gui/widgets/TextArea.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -37,14 +37,16 @@ void GuiController::initialize(GameState* gameState)
|
||||
m_canvas.setSize(m_gameState->viewport.width, m_gameState->viewport.height);
|
||||
|
||||
// Add a text element
|
||||
auto text = new gui::primitives::TextArea();
|
||||
text->setText("Hello world!\nMy name is Tibi!\nThis is a really really long long long, even the longest ever, line.");
|
||||
text->setSize(200, 100);
|
||||
auto text = new gui::widgets::TextArea();
|
||||
text->setText("Hello world!\nMy name is Tibi!\nThis is a really really long long long, even the longest ever, line.\nThis is a very loooooooooooooooooong word.");
|
||||
text->setSize(200, 200);
|
||||
text->setPosition(100, 10);
|
||||
text->setColor(0, 1, 0);
|
||||
text->setBackColor(0.5f, 0, 0, 0.5f);
|
||||
text->setTextSize(11);
|
||||
text->setHorizontalWrap(gui::primitives::TextHorizontalWrapping::Ellipsis);
|
||||
text->setHorizontalWrap(gui::widgets::TextHorizontalWrapping::Wrap);
|
||||
text->setVerticalWrap(gui::widgets::TextVerticalWrapping::Trim);
|
||||
text->setAlignment(gui::widgets::TextAlign::BottomRight);
|
||||
m_canvas.addChild(text);
|
||||
}
|
||||
|
||||
@@ -57,11 +59,11 @@ bool GuiController::processEvent(SDL_Event& event)
|
||||
|
||||
if (event.type == SDL_EventType::SDL_KEYDOWN && event.key.keysym.scancode == SDL_SCANCODE_HOME)
|
||||
{
|
||||
m_canvas.child(0)->setSize(currentW + 50, currentH);
|
||||
m_canvas.child(0)->setSize(currentW + 5, currentH);
|
||||
}
|
||||
if (event.type == SDL_EventType::SDL_KEYDOWN && event.key.keysym.scancode == SDL_SCANCODE_END)
|
||||
{
|
||||
m_canvas.child(0)->setSize(currentW - 50, currentH);
|
||||
m_canvas.child(0)->setSize(currentW - 5, currentH);
|
||||
}
|
||||
|
||||
return handled;
|
||||
@@ -70,7 +72,7 @@ bool GuiController::processEvent(SDL_Event& event)
|
||||
void GuiController::render()
|
||||
{
|
||||
// Compute render context
|
||||
gui::primitives::RenderContext renderContext =
|
||||
gui::RenderContext renderContext =
|
||||
{
|
||||
.sdlRenderer = &m_gameState->sdlRenderer,
|
||||
.resManager = &m_gameState->resManager,
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#ifndef CONTROLLER_GUICONTROLLER_H_
|
||||
#define CONTROLLER_GUICONTROLLER_H_
|
||||
|
||||
#include <gui/Canvas.h>
|
||||
#include <gui/layout/Canvas.h>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace controller {
|
||||
|
||||
private:
|
||||
GameState* m_gameState;
|
||||
gui::Canvas m_canvas;
|
||||
gui::layout::Canvas m_canvas;
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
Reference in New Issue
Block a user