Prefab Progress
This commit is contained in:
@ -11,14 +11,23 @@ namespace Dawn {
|
||||
template<class T>
|
||||
class Prefab {
|
||||
public:
|
||||
/**
|
||||
* Returns the list of assets required for this prefab.
|
||||
*
|
||||
* @return List of required assets this prefab.
|
||||
*/
|
||||
static std::vector<Asset*> getRequiredAssets() {
|
||||
return T::prefabAssets();
|
||||
}
|
||||
|
||||
static T * create(Scene *scene) {
|
||||
T *item = scene->createSceneItemOfType<T>();
|
||||
item->prefabInit();
|
||||
return item;
|
||||
/**
|
||||
* Creates a new instance of this asset.
|
||||
*
|
||||
* @param scene Scene this item belongs to.
|
||||
* @return The instance of the created prefab.
|
||||
*/
|
||||
static T * create(Scene *scene, UICanvas *canvas) {
|
||||
return T::prefabCreate(scene, canvas);
|
||||
}
|
||||
};
|
||||
}
|
@ -16,12 +16,22 @@ namespace Dawn {
|
||||
protected:
|
||||
|
||||
public:
|
||||
static T * prefabCreate(Scene *scene, UICanvas *canvas) {
|
||||
T *item = scene->createSceneItemOfType<T>();
|
||||
item->prefabInit();
|
||||
return item;
|
||||
}
|
||||
|
||||
SceneItemPrefab(Scene *scene, sceneitemid_t id) :
|
||||
SceneItem(scene, id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual method called by the subclass for initialization after the
|
||||
* prefab has been created.
|
||||
*/
|
||||
virtual void prefabInit() = 0;
|
||||
};
|
||||
}
|
23
src/dawn/prefab/UIPrefab.hpp
Normal file
23
src/dawn/prefab/UIPrefab.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "Prefab.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
template<class T>
|
||||
class UIPrefab :
|
||||
public Prefab<T>
|
||||
{
|
||||
public:
|
||||
static T * prefabCreate(Scene *scene) {
|
||||
|
||||
}
|
||||
|
||||
static void apply(T *item) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user