Half done with Scene Component Parsing
This commit is contained in:
@ -1,32 +0,0 @@
|
||||
// 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 "scene/components/ui/UILabel.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class FPSLabel : public SceneItemPrefab<FPSLabel>, public StateOwner {
|
||||
public:
|
||||
static std::vector<Asset*> prefabAssets(AssetManager *man) {
|
||||
return {};
|
||||
}
|
||||
|
||||
UILabel *label;
|
||||
|
||||
FPSLabel(Scene *s, sceneitemid_t i) : SceneItemPrefab(s, i) {}
|
||||
|
||||
void prefabInit(AssetManager *man) override {
|
||||
label = this->addComponent<UILabel>();
|
||||
label->text = "No Frame";
|
||||
|
||||
useEvent([&](float_t delta){
|
||||
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)";
|
||||
}, scene->eventSceneUnpausedUpdate);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user