Add Text rendering and Hull / Fuel Meters

This commit is contained in:
Bram Verhulst
2024-05-16 02:04:36 +02:00
parent 600050c198
commit 8866f33c09
18 changed files with 286 additions and 118 deletions

View File

@@ -1,8 +1,23 @@
#include "pch.h"
#include "MainScreen.h"
#include "colors.h"
#include "utils.h"
#include "Gui/GuiText.h"
MainScreen::MainScreen(TextureManager* manager) : Screen("", Vector2f{0, 0}, Vector2f{900.f, 500.f}, manager) {
m_FuelMeter = new GuiMeter("gui/main/fuel/fuel.png", Vector2f{20, 500.f - 146 / 1.5 - 20}, Vector2f{336, 146},Vector2f{336 / 2, 146 / 1.5}, 21, manager);
Vector2f ScreenSize = utils::GetViewport();
Vector2f FuelFrameSize{ 336, 77 };
Vector2f HullFrameSize{ 61, 76 };
m_FuelMeter = new GuiMeter("gui/main/fuel/fuel.png", Vector2f{HullFrameSize.x + 10, ScreenSize.y - FuelFrameSize.y }, FuelFrameSize,FuelFrameSize / 1.3, 21, manager);
this->AddElement(m_FuelMeter);
m_HullMeter = new GuiMeter("gui/main/hull/hull.png", Vector2f{5, ScreenSize.y - HullFrameSize.y - 10 }, HullFrameSize, HullFrameSize, 50, manager);
this->AddElement(m_HullMeter);
Vector2f DepthMeterPosition{10, ScreenSize.y - 120};
m_DepthText = new GuiText(DepthMeterPosition, "Depth: 20", "fonts/Arial.ttf", 20, Colors::YELLOW);
this->AddElement(m_DepthText);
}
MainScreen::~MainScreen() = default;
void MainScreen::Draw() const {
@@ -14,3 +29,10 @@ void MainScreen::Update(float elapsedSecs) {
void MainScreen::SetFuelMeterValue(float value) const {
m_FuelMeter->SetValue(value);
}
void MainScreen::SetHullMeterValue(float value) const {
m_HullMeter->SetValue(value);
}
void MainScreen::SetDepth(const std::string& text) const {
m_DepthText->ChangeText(text);
}