Keep on improving fonts.

This commit is contained in:
2023-01-24 14:49:31 -08:00
parent 45a0a2c158
commit 4d6cffbcfe
10 changed files with 148 additions and 9 deletions

View File

@ -14,9 +14,23 @@ scene.9.1,"Immediately Post Orc Battle"
scene.10.1,"Morning after orc battle and some foreshadowing"
scene.11.1,"Pre battle with theif"
scene.12.1,"Battle with theif"
unknown1,"There needs to be the big bad here."
scene.13.1,"After battle with theif, things cool off a bit."
scene.14.1,"Harem times maybe"
scene.15.1,"Harem times interrupted by some chaos"
scene.16.1,"I'm putting chaos here but this scene is probably redundant."
scene.17.1,"Chaos battle"
scene.18.1,"Post Chaos Battle, things are still gloomy"
scene.18.1,"Post Chaos Battle, things are still gloomy"
unknown2,"Another big bad here probably."
scene.19.1,"Pre King Arrival, rumours"
scene.20.1,"King Arrival, Everyone's annoyed"
scene.21.1,"King in the bar, running his mouth"
scene.22.1,"King Fight"
scene.23.1,"Post King Fight, angry he leaves, town rallies around you"
scene.24.1,"Go to one of the kingsmen who's working with the big bad, he's worried that the townspeople know more than they let on."
unknown3,"Something here has to bring the big bad to town."
test.1,"Test 1
Test 2
Test 3
Test 4
"
1 undefined UNDEFINED
14 scene.10.1 Morning after orc battle and some foreshadowing
15 scene.11.1 Pre battle with theif
16 scene.12.1 Battle with theif
17 unknown1 There needs to be the big bad here.
18 scene.13.1 After battle with theif, things cool off a bit.
19 scene.14.1 Harem times maybe
20 scene.15.1 Harem times interrupted by some chaos
21 scene.16.1 I'm putting chaos here but this scene is probably redundant.
22 scene.17.1 Chaos battle
23 scene.18.1 Post Chaos Battle, things are still gloomy
24 unknown2 Another big bad here probably.
25 scene.19.1 Pre King Arrival, rumours
26 scene.20.1 King Arrival, Everyone's annoyed
27 scene.21.1 King in the bar, running his mouth
28 scene.22.1 King Fight
29 scene.23.1 Post King Fight, angry he leaves, town rallies around you
30 scene.24.1 Go to one of the kingsmen who's working with the big bad, he's worried that the townspeople know more than they let on.
31 unknown3 Something here has to bring the big bad to town.
32 test.1 Test 1 Test 2 Test 3 Test 4
33
34
35
36

Submodule lib/SDL updated: 7b8f0ba8b7...9670f233cc

View File

@ -37,17 +37,17 @@ float_t TrueTypeFont::getScale(float_t scale) {
float_t TrueTypeFont::getSpaceSize(float_t fontSize) {
assertTrue(fontSize > 0);
return mathRound<float_t>(this->getScale(fontSize) * 18);
return this->getScale(fontSize) * 18;
}
float_t TrueTypeFont::getInitialLineHeight(float_t fontSize) {
assertTrue(fontSize > 0);
return mathRound<float_t>(42.0f * this->getScale(fontSize));
return 42.0f * this->getScale(fontSize);
}
float_t TrueTypeFont::getLineHeight(float_t fontSize) {
assertTrue(fontSize > 0);
return mathRound<float_t>(58.0f * this->getScale(fontSize));
return 96.0f * this->getScale(fontSize);
}
void TrueTypeFont::buffer(
@ -105,7 +105,14 @@ void TrueTypeFont::buffer(
// Setup the initial loop state, and X/Y coords for the quad.
int32_t i = 0;
float_t x = 0;
float_t y = this->getInitialLineHeight(fontSize) / scale;
float_t y = 0;
// Bake the first quad.
this->bakeQuad(quads, &x, &y, 'D');
y = -(quads->y0);
x = 0;
// y = this->getInitialLineHeight(fontSize) / scale;
float_t wordX = 0;
char c;
while(c = text[i++]) {

View File

@ -0,0 +1,38 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "prefab/SceneItemPrefab.hpp"
#include "display/mesh/CubeMesh.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/MeshHost.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
#include "scene/components/example/ExampleSpin.hpp"
namespace Dawn {
class SimpleSpinningCubePrefab :
public SceneItemPrefab<SimpleSpinningCubePrefab>
{
public:
std::vector<Asset*> prefabAssets(AssetManager *man) {
return std::vector<Asset*>();
}
SimpleSpinningCubePrefab(Scene *s, sceneitemid_t i) :
SceneItemPrefab(s, i)
{
}
void prefabInit(AssetManager *man) override {
auto meshRenderer = this->addComponent<MeshRenderer>();
auto meshHost = this->addComponent<MeshHost>();
auto spinning = this->addComponent<ExampleSpin>();
auto material = this->addComponent<SimpleTexturedMaterial>();
meshHost->mesh.createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
CubeMesh::buffer(&meshHost->mesh, glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(1, 1, 1), 0, 0);
}
};
}

View File

@ -91,7 +91,7 @@ std::vector<struct ShaderPassItem> UILabel::getSelfPassItems(
this->z
);
item.start = this->startQuad * QUAD_INDICE_COUNT;
item.count = this->quadCount * QUAD_INDICE_COUNT;
item.count = this->quadCount == -1 ? -1 : this->quadCount * QUAD_INDICE_COUNT;
items.push_back(item);
return items;
}

View File

@ -135,7 +135,6 @@ void VisualNovelTextbox::textboxOnSceneUpdate() {
}
}
if(this->talkSound != nullptr) {
auto vnManager = this->getVisualNovelManager();
assertNotNull(vnManager);

View File

@ -6,6 +6,7 @@
#include "DawnGame.hpp"
#include "scenes/SubSceneRendererScene.hpp"
#include "scenes/Scene_1.hpp"
#include "scenes/TestUIScene.hpp"
using namespace Dawn;
@ -25,7 +26,7 @@ int32_t DawnGame::init() {
this->renderManager.init();
this->audioManager.init();
this->scene = new Scene_1(this);
this->scene = new TestUIScene(this);
return DAWN_GAME_INIT_RESULT_SUCCESS;
}

View File

@ -8,4 +8,5 @@ target_sources(${DAWN_TARGET_NAME}
PRIVATE
PixelVNScene.cpp
PokerVNScene.cpp
TestUIScene.cpp
)

View File

@ -0,0 +1,54 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "TestUIScene.hpp"
using namespace Dawn;
TestUIScene::TestUIScene(DawnGame *game) : Scene(game) {
}
std::vector<Asset*> TestUIScene::getRequiredAssets() {
std::vector<Asset*> assets;
AssetManager *man = &this->game->assetManager;
assets.push_back(man->get<TrueTypeAsset>("truetype_alice"));
assets.push_back(man->get<TextureAsset>("texture_test"));
return assets;
}
void TestUIScene::stage() {
AssetManager *man = &this->game->assetManager;
// Camera
this->camera = Camera::create(this);
this->camera->transform->lookAt(glm::vec3(3, 3, 3), glm::vec3(0, 0, 0));
auto testCube = SimpleSpinningCubePrefab::create(this);
// UI
this->canvas = UICanvas::create(this);
// auto text = man->get<TextureAsset>("texture_test");
// auto border = this->canvas->addElement<UIBorder>();
// border->texture = &text->texture;
// border->setBorderSize(glm::vec2(4, 4));
// border->setTransform(
// UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
// glm::vec4(0, 0, 0, 0),
// 0.0f
// );
auto assetFont = man->get<TrueTypeAsset>("truetype_alice");
auto label = this->canvas->addElement<UILabel>();
label->setFont(&assetFont->font);
label->setText("test.1");
label->setFontSize(24);
label->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
glm::vec4(0, 0, 0, 0),
0.0f
);
}

View File

@ -0,0 +1,25 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/Scene.hpp"
#include "game/DawnGame.hpp"
#include "scene/components/ui/UICanvas.hpp"
#include "ui/UILabel.hpp"
#include "ui/UIBorder.hpp"
#include "prefabs/SimpleSpinningCubePrefab.hpp"
namespace Dawn {
class TestUIScene : public Scene {
private:
Camera *camera = nullptr;
UICanvas *canvas = nullptr;
public:
TestUIScene(DawnGame *game);
std::vector<Asset*> getRequiredAssets() override;
void stage() override;
};
}