VN Textbox can now be any size
This commit is contained in:
@ -108,7 +108,7 @@ namespace Dawn {
|
|||||||
* Sets a floating point value to the shader.
|
* Sets a floating point value to the shader.
|
||||||
*
|
*
|
||||||
* @param parameter Paramater to set the float ont o.
|
* @param parameter Paramater to set the float ont o.
|
||||||
* @param float Float to bind.
|
* @param Float to bind.
|
||||||
*/
|
*/
|
||||||
virtual void setFloat(T parameter, float_t value) = 0;
|
virtual void setFloat(T parameter, float_t value) = 0;
|
||||||
};
|
};
|
||||||
|
@ -19,20 +19,9 @@
|
|||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
class DawnHost;
|
class DawnHost;
|
||||||
|
|
||||||
class DawnGame {
|
class IDawnGame {
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Scene> scene;
|
std::shared_ptr<Scene> scene;
|
||||||
DawnHost &host;
|
|
||||||
RenderManager renderManager;
|
|
||||||
AssetManager assetManager;
|
|
||||||
InputManager inputManager;
|
|
||||||
TimeManager timeManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new instance of the DawnGame.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
DawnGame(DawnHost &host);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the game. This is performed by the host at a time that is
|
* Initialize the game. This is performed by the host at a time that is
|
||||||
@ -43,7 +32,7 @@ namespace Dawn {
|
|||||||
* @param host Pointer to the host that is running this game.
|
* @param host Pointer to the host that is running this game.
|
||||||
* @return The game initialize result.
|
* @return The game initialize result.
|
||||||
*/
|
*/
|
||||||
int32_t init();
|
virtual int32_t init() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a game update operation. This operation should occur exactly
|
* Performs a game update operation. This operation should occur exactly
|
||||||
@ -57,11 +46,13 @@ namespace Dawn {
|
|||||||
* @param delta Time delta to tick the game by.
|
* @param delta Time delta to tick the game by.
|
||||||
* @return The game update result.
|
* @return The game update result.
|
||||||
*/
|
*/
|
||||||
int32_t update(float_t delta);
|
virtual int32_t update(float_t delta) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup the memory of the DawnGame instance.
|
* Cleanup the memory of the DawnGame instance.
|
||||||
*/
|
*/
|
||||||
~DawnGame();
|
virtual ~IDawnGame() {
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -125,6 +125,10 @@ void UIBorder::setBorderSize(glm::vec2 borderSize) {
|
|||||||
this->updatePositions();
|
this->updatePositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec2 UIBorder::getInnerSize() {
|
||||||
|
return glm::vec2(this->getWidth(), this->getHeight()) - this->edgeDimensions;
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec2 UIBorder::getBorderSize() {
|
glm::vec2 UIBorder::getBorderSize() {
|
||||||
return this->edgeDimensions;
|
return this->edgeDimensions;
|
||||||
}
|
}
|
@ -17,14 +17,32 @@ namespace Dawn {
|
|||||||
glm::vec2 uv1 = glm::vec2(1.0f, 1.0f);
|
glm::vec2 uv1 = glm::vec2(1.0f, 1.0f);
|
||||||
|
|
||||||
void updatePositions() override;
|
void updatePositions() override;
|
||||||
|
void drawSelf(UIShader &shader, glm::mat4 selfTransform) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Texture *texture;
|
Texture *texture;
|
||||||
|
|
||||||
UIBorder(UICanvas &canvas);
|
UIBorder(UICanvas &canvas);
|
||||||
void drawSelf(UIShader &shader, glm::mat4 selfTransform) override;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the dimensions of the border.
|
||||||
|
*
|
||||||
|
* @param borderSize Size of the border.
|
||||||
|
*/
|
||||||
void setBorderSize(glm::vec2 borderSize);
|
void setBorderSize(glm::vec2 borderSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of the border.
|
||||||
|
*
|
||||||
|
* @return Border size of this UI border.
|
||||||
|
*/
|
||||||
glm::vec2 getBorderSize();
|
glm::vec2 getBorderSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of the area within the border.
|
||||||
|
*
|
||||||
|
* @return The inner content area size.
|
||||||
|
*/
|
||||||
|
glm::vec2 getInnerSize();
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -81,6 +81,11 @@ void UIComponent::updatePositions() {
|
|||||||
(*it)->updatePositions();
|
(*it)->updatePositions();
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fire event
|
||||||
|
eventAlignmentUpdated.invoke(
|
||||||
|
this->width, this->height, this->relativeX, this->relativeY
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
float_t UIComponent::getWidth() {
|
float_t UIComponent::getWidth() {
|
||||||
|
@ -33,6 +33,9 @@ namespace Dawn {
|
|||||||
std::vector<UIComponent*> children;
|
std::vector<UIComponent*> children;
|
||||||
UIComponent *parent = nullptr;
|
UIComponent *parent = nullptr;
|
||||||
|
|
||||||
|
// Events
|
||||||
|
Event<float_t, float_t, float_t, float_t> eventAlignmentUpdated;
|
||||||
|
|
||||||
// I currently don't support rotation or scale. Not because I can't but
|
// I currently don't support rotation or scale. Not because I can't but
|
||||||
// because it's basically un-necessary. Unity does support rotation but
|
// because it's basically un-necessary. Unity does support rotation but
|
||||||
// it doesn't affect how the alignment side of things work (similar to how
|
// it doesn't affect how the alignment side of things work (similar to how
|
||||||
@ -46,6 +49,15 @@ namespace Dawn {
|
|||||||
*/
|
*/
|
||||||
virtual void updatePositions();
|
virtual void updatePositions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intended to be overwritten by subclass. Called by the draw method to
|
||||||
|
* ask this child to draw.
|
||||||
|
*
|
||||||
|
* @param uiShader UI Shader for the child to use.
|
||||||
|
* @param selfTransform Self alignment transform.
|
||||||
|
*/
|
||||||
|
virtual void drawSelf(UIShader &uiShader, glm::mat4 selfTransform) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UICanvas &canvas;
|
UICanvas &canvas;
|
||||||
|
|
||||||
@ -57,26 +69,60 @@ namespace Dawn {
|
|||||||
* @return Width of the component.
|
* @return Width of the component.
|
||||||
*/
|
*/
|
||||||
float_t getWidth();
|
float_t getWidth();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the calculated height, based on the internal alignment values.
|
||||||
|
*
|
||||||
|
* @return Height of the component.
|
||||||
|
*/
|
||||||
float_t getHeight();
|
float_t getHeight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the X position, relative to this components' parent.
|
||||||
|
*
|
||||||
|
* @return Relative X position.
|
||||||
|
*/
|
||||||
float_t getRelativeX();
|
float_t getRelativeX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Y position, relative to this components' parent.
|
||||||
|
*
|
||||||
|
* @return Relative Y position.
|
||||||
|
*/
|
||||||
float_t getRelativeY();
|
float_t getRelativeY();
|
||||||
|
|
||||||
void setTransform(
|
/**
|
||||||
|
* Updates the transformation for this component.
|
||||||
|
*
|
||||||
|
* @param xAlign X axis alignment method.
|
||||||
|
* @param yAlign Y axis alignment method.
|
||||||
|
* @param alignment Alignment parameters, changes depending on the align.
|
||||||
|
* @param z Z position (relative to screen).
|
||||||
|
*/
|
||||||
|
virtual void setTransform(
|
||||||
UIComponentAlign xAlign,
|
UIComponentAlign xAlign,
|
||||||
UIComponentAlign yAlign,
|
UIComponentAlign yAlign,
|
||||||
glm::vec4 alignment,
|
glm::vec4 alignment,
|
||||||
float_t z
|
float_t z
|
||||||
);
|
);
|
||||||
|
|
||||||
// virtual void update() = 0;
|
|
||||||
void draw(UIShader &uiShader, glm::mat4 parentTransform);
|
void draw(UIShader &uiShader, glm::mat4 parentTransform);
|
||||||
virtual void drawSelf(UIShader &uiShader, glm::mat4 selfTransform) = 0;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a child to this UI Component.
|
||||||
|
*
|
||||||
|
* @param child Child UI Component to add.
|
||||||
|
*/
|
||||||
void addChild(UIComponent *child);
|
void addChild(UIComponent *child);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a child from this UI Component.
|
||||||
|
*
|
||||||
|
* @param child Child to remove.
|
||||||
|
*/
|
||||||
void removeChild(UIComponent *child);
|
void removeChild(UIComponent *child);
|
||||||
|
|
||||||
virtual ~UIComponent();
|
virtual ~UIComponent();
|
||||||
|
|
||||||
friend class UICanvas;
|
friend class UICanvas;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -61,3 +61,13 @@ void UILabel::drawSelf(UIShader &shader, glm::mat4 selfTransform) {
|
|||||||
|
|
||||||
this->font->draw(this->mesh, this->startQuad, this->quadCount);
|
this->font->draw(this->mesh, this->startQuad, this->quadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILabel::setTransform(
|
||||||
|
UIComponentAlign xAlign,
|
||||||
|
UIComponentAlign yAlign,
|
||||||
|
glm::vec4 alignment,
|
||||||
|
float_t z
|
||||||
|
) {
|
||||||
|
this->needsRebuffering = true;
|
||||||
|
UIComponent::setTransform(xAlign, yAlign, alignment, z);
|
||||||
|
}
|
@ -29,6 +29,12 @@ namespace Dawn {
|
|||||||
|
|
||||||
UILabel(UICanvas &canvas);
|
UILabel(UICanvas &canvas);
|
||||||
void drawSelf(UIShader &shader, glm::mat4 selfTransform) override;
|
void drawSelf(UIShader &shader, glm::mat4 selfTransform) override;
|
||||||
|
void setTransform(
|
||||||
|
UIComponentAlign xAlign,
|
||||||
|
UIComponentAlign yAlign,
|
||||||
|
glm::vec4 alignment,
|
||||||
|
float_t z
|
||||||
|
) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method to force the font mesh to be recreated.
|
* Internal method to force the font mesh to be recreated.
|
||||||
|
@ -12,6 +12,7 @@ namespace Dawn {
|
|||||||
class UISprite : public UIComponent {
|
class UISprite : public UIComponent {
|
||||||
protected:
|
protected:
|
||||||
void updatePositions() override;
|
void updatePositions() override;
|
||||||
|
void drawSelf(UIShader &uiShader, glm::mat4 selfTransform) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Mesh mesh;
|
Mesh mesh;
|
||||||
@ -23,6 +24,5 @@ namespace Dawn {
|
|||||||
* @param canvas Canvas that this sprite belongs to.
|
* @param canvas Canvas that this sprite belongs to.
|
||||||
*/
|
*/
|
||||||
UISprite(UICanvas &canvas);
|
UISprite(UICanvas &canvas);
|
||||||
void drawSelf(UIShader &uiShader, glm::mat4 selfTransform) override;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -3,6 +3,11 @@
|
|||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Sources
|
||||||
|
target_sources(${DAWN_TARGET_NAME}
|
||||||
|
PRIVATE
|
||||||
|
VisualNovelManager.cpp
|
||||||
|
)
|
||||||
|
|
||||||
# Subdirs
|
# Subdirs
|
||||||
add_subdirectory(ui)
|
add_subdirectory(ui)
|
@ -3,6 +3,10 @@
|
|||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#pragma once
|
#include "VisualNovelManager.hpp"
|
||||||
#include "game/DawnGame.hpp"
|
|
||||||
#include "scene/components/Components.hpp"
|
using namespace Dawn;
|
||||||
|
|
||||||
|
VisualNovelManager::VisualNovelManager() {
|
||||||
|
|
||||||
|
}
|
16
src/dawn/visualnovel/VisualNovelManager.hpp
Normal file
16
src/dawn/visualnovel/VisualNovelManager.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2022 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dawnlibs.hpp"
|
||||||
|
|
||||||
|
namespace Dawn {
|
||||||
|
class VisualNovelManager {
|
||||||
|
protected:
|
||||||
|
|
||||||
|
public:
|
||||||
|
VisualNovelManager();
|
||||||
|
};
|
||||||
|
}
|
@ -21,8 +21,6 @@ VisualNovelTextbox::VisualNovelTextbox(UICanvas &canvas) :
|
|||||||
this->label.startQuad = 0;
|
this->label.startQuad = 0;
|
||||||
this->label.quadCount = 0;
|
this->label.quadCount = 0;
|
||||||
|
|
||||||
this->updateSelfTransform();
|
|
||||||
|
|
||||||
this->canvas.getScene().eventSceneUnpausedUpdate.addListener(
|
this->canvas.getScene().eventSceneUnpausedUpdate.addListener(
|
||||||
this, &VisualNovelTextbox::textboxOnSceneUpdate
|
this, &VisualNovelTextbox::textboxOnSceneUpdate
|
||||||
);
|
);
|
||||||
@ -60,11 +58,11 @@ void VisualNovelTextbox::textboxOnSceneUpdate() {
|
|||||||
if(this->hasRevealedAllCurrentCharacters()) {
|
if(this->hasRevealedAllCurrentCharacters()) {
|
||||||
if(this->hasRevealedAllCharacters()) {
|
if(this->hasRevealedAllCharacters()) {
|
||||||
if(game.inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
if(game.inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
||||||
std::cout << "Bruh" << std::endl;
|
this->eventClose.invoke();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(game.inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
if(game.inputManager.isPressed(INPUT_BIND_ACCEPT)) {
|
||||||
this->lineCurrent += VISUAL_NOVEL_TEXTBOX_LINES_MAX;
|
this->lineCurrent += this->getCountOfVisibleLines();
|
||||||
this->label.startQuad = 0;
|
this->label.startQuad = 0;
|
||||||
for(int32_t i = 0; i < this->lineCurrent; i++) {
|
for(int32_t i = 0; i < this->lineCurrent; i++) {
|
||||||
this->label.startQuad += this->label.measure.getQuadsOnLine(i);
|
this->label.startQuad += this->label.measure.getQuadsOnLine(i);
|
||||||
@ -85,29 +83,35 @@ void VisualNovelTextbox::textboxOnSceneUpdate() {
|
|||||||
),
|
),
|
||||||
1.0f
|
1.0f
|
||||||
);
|
);
|
||||||
|
this->eventNewPage.invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto lastTimeCharacter = (int32_t)mathFloorFloat(this->timeCharacter);
|
||||||
if(game.inputManager.isDown(INPUT_BIND_ACCEPT)) {
|
if(game.inputManager.isDown(INPUT_BIND_ACCEPT)) {
|
||||||
this->timeCharacter += game.timeManager.delta * VISUAL_NOVEL_TEXTBOX_SPEED_FASTER;
|
this->timeCharacter += game.timeManager.delta * VISUAL_NOVEL_TEXTBOX_SPEED_FASTER;
|
||||||
} else {
|
} else {
|
||||||
this->timeCharacter += game.timeManager.delta * VISUAL_NOVEL_TEXTBOX_SPEED;
|
this->timeCharacter += game.timeManager.delta * VISUAL_NOVEL_TEXTBOX_SPEED;
|
||||||
}
|
}
|
||||||
this->label.quadCount = (int32_t)mathFloorFloat(this->timeCharacter);
|
auto newTimeCharacter = (int32_t)mathFloorFloat(this->timeCharacter);
|
||||||
|
if(newTimeCharacter == lastTimeCharacter) return;
|
||||||
|
|
||||||
|
this->label.quadCount = newTimeCharacter;
|
||||||
|
this->eventCharacterRevealed.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualNovelTextbox::updateSelfTransform() {
|
int32_t VisualNovelTextbox::getCountOfVisibleLines() {
|
||||||
float_t height;
|
int32_t i = 1;
|
||||||
|
glm::vec2 innerSize = this->border.getInnerSize() - this->labelPadding;
|
||||||
|
|
||||||
height = this->label.measure.getHeightOfLineCount(VISUAL_NOVEL_TEXTBOX_LINES_MAX);
|
for(i = this->label.measure.getLineCount(); i > 0; --i) {
|
||||||
|
if(innerSize.y >= this->label.measure.getHeightOfLineCount(i)) {
|
||||||
this->setTransform(
|
return i;
|
||||||
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_START,
|
}
|
||||||
glm::vec4(0, 0, 0, height + (this->border.getBorderSize().y * 2)),
|
}
|
||||||
0
|
return this->label.measure.getLineCount();
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualNovelTextbox::drawSelf(UIShader &shader, glm::mat4 self) {}
|
void VisualNovelTextbox::drawSelf(UIShader &shader, glm::mat4 self) {}
|
||||||
@ -121,14 +125,12 @@ void VisualNovelTextbox::setBorder(Texture *texture, glm::vec2 dimensions) {
|
|||||||
void VisualNovelTextbox::setFont(Font *font) {
|
void VisualNovelTextbox::setFont(Font *font) {
|
||||||
this->label.setFont(font);
|
this->label.setFont(font);
|
||||||
this->label.updateMesh();
|
this->label.updateMesh();
|
||||||
this->updateSelfTransform();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualNovelTextbox::setText(std::string text, float_t fontSize) {
|
void VisualNovelTextbox::setText(std::string text, float_t fontSize) {
|
||||||
this->label.setText(text);
|
this->label.setText(text);
|
||||||
this->label.setFontSize(fontSize);
|
this->label.setFontSize(fontSize);
|
||||||
this->label.updateMesh();
|
this->label.updateMesh();
|
||||||
this->updateSelfTransform();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t VisualNovelTextbox::hasRevealedAllCurrentCharacters() {
|
bool_t VisualNovelTextbox::hasRevealedAllCurrentCharacters() {
|
||||||
@ -137,7 +139,7 @@ bool_t VisualNovelTextbox::hasRevealedAllCurrentCharacters() {
|
|||||||
int32_t i = this->lineCurrent;
|
int32_t i = this->lineCurrent;
|
||||||
i < mathMin<int32_t>(
|
i < mathMin<int32_t>(
|
||||||
this->label.measure.getLineCount(),
|
this->label.measure.getLineCount(),
|
||||||
this->lineCurrent + VISUAL_NOVEL_TEXTBOX_LINES_MAX
|
this->lineCurrent + this->getCountOfVisibleLines()
|
||||||
);
|
);
|
||||||
i++
|
i++
|
||||||
) {
|
) {
|
||||||
@ -148,7 +150,7 @@ bool_t VisualNovelTextbox::hasRevealedAllCurrentCharacters() {
|
|||||||
|
|
||||||
bool_t VisualNovelTextbox::hasRevealedAllCharacters() {
|
bool_t VisualNovelTextbox::hasRevealedAllCharacters() {
|
||||||
return (
|
return (
|
||||||
this->lineCurrent + VISUAL_NOVEL_TEXTBOX_LINES_MAX >=
|
this->lineCurrent + this->getCountOfVisibleLines() >=
|
||||||
this->label.measure.getLineCount()
|
this->label.measure.getLineCount()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#define VISUAL_NOVEL_TEXTBOX_SPEED 25.0f
|
#define VISUAL_NOVEL_TEXTBOX_SPEED 25.0f
|
||||||
#define VISUAL_NOVEL_TEXTBOX_SPEED_FASTER 40.0f
|
#define VISUAL_NOVEL_TEXTBOX_SPEED_FASTER 40.0f
|
||||||
#define VISUAL_NOVEL_TEXTBOX_LINES_MAX 4
|
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
class VisualNovelTextbox : public UIComponent {
|
class VisualNovelTextbox : public UIComponent {
|
||||||
@ -23,13 +22,31 @@ namespace Dawn {
|
|||||||
float_t timeCharacter = 0.0f;
|
float_t timeCharacter = 0.0f;
|
||||||
|
|
||||||
void updatePositions() override;
|
void updatePositions() override;
|
||||||
|
void drawSelf(UIShader &shader, glm::mat4 selfTransform) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens for scene updates.
|
||||||
|
*/
|
||||||
void textboxOnSceneUpdate();
|
void textboxOnSceneUpdate();
|
||||||
void updateSelfTransform();
|
|
||||||
|
/**
|
||||||
|
* Returns the count of visible lines within the textbox. Mostly used for
|
||||||
|
* when we need to decide how to wrap.
|
||||||
|
*
|
||||||
|
* @return The count of visible lines.
|
||||||
|
*/
|
||||||
|
int32_t getCountOfVisibleLines();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Event<> eventCharacterRevealed;
|
||||||
|
Event<> eventCurrentCharactersRevealed;
|
||||||
|
Event<> eventNewPage;
|
||||||
|
Event<> eventAllCharactersRevealed;
|
||||||
|
Event<> eventClose;
|
||||||
|
|
||||||
VisualNovelTextbox(UICanvas &canvas);
|
VisualNovelTextbox(UICanvas &canvas);
|
||||||
|
|
||||||
void drawSelf(UIShader &shader, glm::mat4 selfTransform) override;
|
|
||||||
|
|
||||||
void setFont(Font *font);
|
void setFont(Font *font);
|
||||||
void setBorder(Texture *texture, glm::vec2 dimensions);
|
void setBorder(Texture *texture, glm::vec2 dimensions);
|
||||||
|
@ -17,3 +17,4 @@ target_include_directories(${DAWN_TARGET_NAME}
|
|||||||
|
|
||||||
# Subdirs
|
# Subdirs
|
||||||
add_subdirectory(game)
|
add_subdirectory(game)
|
||||||
|
add_subdirectory(ui)
|
@ -6,7 +6,7 @@
|
|||||||
# Sources
|
# Sources
|
||||||
target_sources(${DAWN_TARGET_NAME}
|
target_sources(${DAWN_TARGET_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
DawnPokerGame.cpp
|
DawnGame.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
tool_texture(texture_test texture_test.png texture_test)
|
tool_texture(texture_test texture_test.png texture_test)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#include "DawnPokerGame.hpp"
|
#include "DawnGame.hpp"
|
||||||
#include "asset/assets/TextureAsset.hpp"
|
#include "asset/assets/TextureAsset.hpp"
|
||||||
#include "asset/assets/TrueTypeAsset.hpp"
|
#include "asset/assets/TrueTypeAsset.hpp"
|
||||||
#include "visualnovel/ui/VisualNovelTextbox.hpp"
|
#include "visualnovel/ui/VisualNovelTextbox.hpp"
|
||||||
@ -41,16 +41,12 @@ int32_t DawnGame::init() {
|
|||||||
auto textbox = canvas->addElement<VisualNovelTextbox>();
|
auto textbox = canvas->addElement<VisualNovelTextbox>();
|
||||||
textbox->setBorder(assetTexture->texture.get(), glm::vec2(16, 16));
|
textbox->setBorder(assetTexture->texture.get(), glm::vec2(16, 16));
|
||||||
textbox->setFont(&assetFont->font);
|
textbox->setFont(&assetFont->font);
|
||||||
textbox->setText("1\n2\n3\n4\n5\n6\n7\n8\n9\n10", 40);
|
textbox->setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus leo odio, egestas nec imperdiet ac, placerat eget quam. Nam tellus justo, aliquam sed porta quis, ullamcorper in libero. Proin auctor eget elit nec rutrum. Vestibulum tincidunt sem vel nisi sagittis, sed imperdiet eros aliquet. Fusce a ultrices augue, at auctor lacus. Sed lobortis, ante vitae vehicula egestas, lorem turpis cursus dui, sit amet egestas mauris ligula non ipsum. Pellentesque scelerisque posuere lorem sit amet tempor. Praesent ac hendrerit mi. Nulla mollis diam vitae vestibulum aliquam. Nullam metus justo, viverra sed risus eu, tincidunt sodales lacus. Quisque efficitur accumsan posuere. Aliquam posuere volutpat diam quis lacinia. Nullam blandit nulla vestibulum mi placerat varius. Proin egestas lacus nec pellentesque iaculis. Vestibulum ex metus, congue in eleifend et, scelerisque a nulla. Pellentesque cursus lectus sed arcu efficitur tincidunt. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla a felis non velit fermentum ullamcorper.", 40);
|
||||||
|
textbox->setTransform(
|
||||||
// auto sprite = canvas->addElement<UISprite>();
|
UI_COMPONENT_ALIGN_START, UI_COMPONENT_ALIGN_START,
|
||||||
// sprite->setTransform(
|
glm::vec4(100, 100, 300, 300),
|
||||||
// UI_COMPONENT_ALIGN_START,
|
0.0f
|
||||||
// UI_COMPONENT_ALIGN_START,
|
);
|
||||||
// glm::vec4(0, 0, 200, 200),
|
|
||||||
// 0
|
|
||||||
// );
|
|
||||||
// sprite->texture = &asset->font.getTexture();
|
|
||||||
|
|
||||||
return DAWN_GAME_INIT_RESULT_SUCCESS;
|
return DAWN_GAME_INIT_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -66,7 +62,3 @@ int32_t DawnGame::update(float_t delta) {
|
|||||||
|
|
||||||
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
|
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnGame::~DawnGame() {
|
|
||||||
|
|
||||||
}
|
|
23
src/dawnpokergame/game/DawnGame.hpp
Normal file
23
src/dawnpokergame/game/DawnGame.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2022 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "game/_DawnGame.hpp"
|
||||||
|
#include "scene/components/Components.hpp"
|
||||||
|
|
||||||
|
namespace Dawn {
|
||||||
|
class DawnGame : public IDawnGame {
|
||||||
|
public:
|
||||||
|
DawnHost &host;
|
||||||
|
RenderManager renderManager;
|
||||||
|
AssetManager assetManager;
|
||||||
|
InputManager inputManager;
|
||||||
|
TimeManager timeManager;
|
||||||
|
|
||||||
|
DawnGame(DawnHost &host);
|
||||||
|
int32_t init() override;
|
||||||
|
int32_t update(float_t delta) override;
|
||||||
|
};
|
||||||
|
}
|
10
src/dawnpokergame/ui/CMakeLists.txt
Normal file
10
src/dawnpokergame/ui/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (c) 2022 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Sources
|
||||||
|
target_sources(${DAWN_TARGET_NAME}
|
||||||
|
PRIVATE
|
||||||
|
PokerGameTextbox.cpp
|
||||||
|
)
|
12
src/dawnpokergame/ui/PokerGameTextbox.cpp
Normal file
12
src/dawnpokergame/ui/PokerGameTextbox.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (c) 2022 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#include "PokerGameTextbox.hpp"
|
||||||
|
|
||||||
|
using namespace Dawn;
|
||||||
|
|
||||||
|
std::shared_ptr<VisualNovelTextbox> PokerGameTextbox::makeTextbox() {
|
||||||
|
return nullptr;
|
||||||
|
}
|
14
src/dawnpokergame/ui/PokerGameTextbox.hpp
Normal file
14
src/dawnpokergame/ui/PokerGameTextbox.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (c) 2022 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "visualnovel/ui/VisualNovelTextbox.hpp"
|
||||||
|
|
||||||
|
namespace Dawn {
|
||||||
|
class PokerGameTextbox {
|
||||||
|
public:
|
||||||
|
static std::shared_ptr<VisualNovelTextbox> makeTextbox();
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user