Half done with Scene Component Parsing
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(debug)
|
||||
add_subdirectory(display)
|
||||
add_subdirectory(example)
|
||||
add_subdirectory(physics)
|
||||
|
10
src/dawn/scene/components/debug/CMakeLists.txt
Normal file
10
src/dawn/scene/components/debug/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2023 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
FPSLabelComponent.cpp
|
||||
)
|
23
src/dawn/scene/components/debug/FPSLabelComponent.cpp
Normal file
23
src/dawn/scene/components/debug/FPSLabelComponent.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "FPSLabelComponent.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
FPSLabelComponent::FPSLabelComponent(SceneItem *item) :
|
||||
SceneItemComponent(item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FPSLabelComponent::onStart() {
|
||||
useEvent([&](float_t delta){
|
||||
if(this->label == nullptr) return;
|
||||
std::string strFps = std::to_string((int32_t)(1.0f / delta));
|
||||
std::string strTick = std::to_string((int32_t)(delta * 1000.0f));
|
||||
label->text = strFps + "FPS (" + strTick + "ms)";
|
||||
}, this->item->scene->eventSceneUnpausedUpdate);
|
||||
}
|
16
src/dawn/scene/components/debug/FPSLabelComponent.hpp
Normal file
16
src/dawn/scene/components/debug/FPSLabelComponent.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "scene/components/ui/UILabel.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class FPSLabelComponent : public SceneItemComponent {
|
||||
public:
|
||||
UILabel *label;
|
||||
FPSLabelComponent(SceneItem *item);
|
||||
void onStart() override;
|
||||
};
|
||||
}
|
@ -29,11 +29,17 @@ namespace Dawn {
|
||||
void updateMesh();
|
||||
|
||||
public:
|
||||
//@optional
|
||||
StateProperty<std::string> text;
|
||||
// @optional
|
||||
StateProperty<float_t> fontSize;
|
||||
/* @optional */
|
||||
StateProperty<Font*> font;
|
||||
/* @optional */
|
||||
StateProperty<float_t> maxWidth;
|
||||
/* @optional */
|
||||
struct Color textColor = COLOR_WHITE;
|
||||
|
||||
struct FontMeasure measure;
|
||||
int32_t startQuad = 0;
|
||||
int32_t quadCount = -1;
|
||||
|
Reference in New Issue
Block a user