Add DMv3 stubs, add reflection warning

This commit is contained in:
Vulpovile
2023-11-04 20:15:07 -07:00
parent 53427dd385
commit e8eef916b0
23 changed files with 982 additions and 1491 deletions

View File

@@ -0,0 +1,64 @@
#include "Instance.h"
using namespace B3D;
#pragma once
// Instances
//#include "WorkspaceInstance.h"
#include "LevelInstance.h"
//#include "PartInstance.h"
//#include "SelectionService.h"
//#include "GuiRootInstance.h"
//#include "ThumbnailGeneratorInstance.h"
//#include "XplicitNgine/XplicitNgine.h"
//#include "SoundService.h"
//#include "LightingInstance.h"
// Libraries
//#include "rapidxml/rapidxml.hpp"
namespace B3D {
class DataModelInstance : public Instance
{
public:
DataModelInstance(void);
~DataModelInstance(void);
void setMessage(std::string);
void setMessageBrickCount();
void clearMessage();
void drawMessage(RenderDevice*);
// Instance getters
// WorkspaceInstance* getWorkspace();
LevelInstance* getLevel();
// XplicitNgine* getEngine();
// ThumbnailGeneratorInstance* getThumbnailGenerator();
// SoundService* getSoundService();
// LightingInstance* getLighting();
std::string message;
bool showMessage;
//Should probably not be here???
G3D::GFontRef font;
// GuiRootInstance* getGuiRoot();
// SelectionService* getSelectionService();
// PartInstance* makePart();
void clearLevel();
void toggleRun();
bool isRunning();
// void resetEngine();
private:
bool isBrickCount;
Color3 DataModelInstance::bcToRGB(short bc);
// Instances
// WorkspaceInstance* workspace;
LevelInstance* level;
// GuiRootInstance* guiRoot;
// SelectionService* selectionService;
// ThumbnailGeneratorInstance* thumbnailGenerator;
// XplicitNgine* xplicitNgine;
// SoundService* soundService;
// LightingInstance* lightingInstance;
bool running;
};
}

View File

View File

@@ -5,8 +5,11 @@
#include "Reflection/ReflectionProperty.h"
#include <G3DAll.h>
namespace B3D
{
class DataModelInstance;
class Instance
{
public:
@@ -33,9 +36,13 @@ namespace B3D
void removeChild(Instance*);
void clearChildren();
Instance* getParent();
DataModelInstance * getParentDataModel(void);
//Variables
Reflection::ReflectionProperty<std::string> name;
bool canDelete;
protected:
//Constructor
//Used specifically to identify an instance class by an instance class,
@@ -45,5 +52,6 @@ namespace B3D
//Variables
Reflection::ReflectionDataTable * dataTable;
Instance * parent;
DataModelInstance * parentDataModel;
};
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include "Instance.h"
namespace B3D{
class LevelInstance : public Instance
{
public:
//Constructors
LevelInstance(void);
~LevelInstance(void);
//Functions
void winCondition();
void loseCondition();
void pauseCondition();
void drawCondition();
void Step(SimTime sdt);
//Values
Reflection::ReflectionProperty<bool> highScoreIsGood;
Reflection::ReflectionProperty<int> timerUpAction;
Reflection::ReflectionProperty<int> timerAffectsScore;
Reflection::ReflectionProperty<bool> runOnOpen;
Reflection::ReflectionProperty<float> timer;
Reflection::ReflectionProperty<int> score;
Reflection::ReflectionProperty<std::string> winMessage;
Reflection::ReflectionProperty<std::string> loseMessage;
};
}

View File

View File

View File

@@ -4,40 +4,64 @@ namespace Enum
{
namespace SurfaceType
{
enum Value {
Smooth = 0, Bumps = 1, Hinge = 2, Motor = 3, StepperMotor = 4, Spawn = 5
static const char* STR_TABLE[] = {
"Smooth", "Bumps", "Hinge",
"Motor", "StepperMotor", "Spawn"
};
enum Value {
Smooth = 0, Bumps = 1, Hinge = 2, Motor = 3, StepperMotor = 4, Spawn = 5, LENGTH = 6
};
}
namespace Shape
{
static const char* STR_TABLE[] = {
"Ball", "Block", "Cylinder"
};
enum Value {
Ball = 0, Block = 1, Cylinder = 2
Ball = 0, Block = 1, Cylinder = 2, LENGTH = 3
};
}
namespace Controller
{
static const char* STR_TABLE[] = {
"None", "KeyboardRight", "KeyboardLeft", "Joypad1",
"Joypad2", "Chase", "Flee"
};
enum Value {
Player = 7, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, None = 0
None = 0, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, LENGTH=7
};
}
namespace ActionType
{
static const char* STR_TABLE[] = {
"Nothing", "Pause", "Lose", "Draw", "Win"
};
enum Value {
Nothing = 0, Pause = 1, Lose = 2, Draw = 3, Win = 4
Nothing = 0, Pause = 1, Lose = 2, Draw = 3, Win = 4, LENGTH = 5
};
}
namespace AffectType
{
static const char* STR_TABLE[] = {
"NoChange", "Increase", "Decrease"
};
enum Value {
NoChange = 0, Increase = 1, Decrease = 2
NoChange = 0, Increase = 1, Decrease = 2, LENGTH = 3
};
}
namespace Sound
{
static const char* STR_TABLE[] = {
"NoSound", "Victory", "Boing", "Bomb",
"Ping", "Break", "Splat", "Swoosh",
"Snap", "Page", "Click", "Clock", "Step", "StepOn"
};
enum Value {
NoSound = 0, Victory = 1, Boing = 2, Bomb = 3,
Ping = 4, Break = 5, Splat = 6, Swoosh = 7,
Snap = 8, Page = 9, Click = 10, Clock = 11, Step = 12, StepOn = 13,
LENGTH = 14
};
}
}

View File

@@ -1,8 +1,21 @@
#pragma once
#include "ErrorFunctions.h"
//BE WARNED, IF YOU TOUCH REFLECTION YOUR BUILD WILL TAKE AGES
namespace B3D{
namespace Reflection{
//I do not like this... Structs?
class EnumMeta {
public:
EnumMeta(int maxLength, const char ** nameValues)
{
this->maxLength = maxLength;
this->nameValues = nameValues;
}
int maxLength;
const char ** nameValues;
};
enum ReflectionType {
TYPE_INT = 0,
TYPE_FLOAT = 1,

View File

@@ -16,19 +16,22 @@ namespace B3D{
std::string key;
T * value;
ReflectionType type;
ReflectionProperty(std::string key, T * value, ReflectionType type, ReflectionDataTable * containerTable);
ReflectionProperty(std::string key, T * valuePtr, ReflectionType type, ReflectionDataTable * containerTable, void* extData = NULL, bool archivable = true, bool locked = false, bool propertyHidden = false);
ReflectionProperty(std::string key, T defaultValue, ReflectionType type, ReflectionDataTable * containerTable, void* extData = NULL, bool archivable = true, bool locked = false, bool propertyHidden = false);
ReflectionProperty(void);
~ReflectionProperty(void);
void dispose();
private:
std::string propertyName;
bool archivable;
bool locked;
bool propertyHidden;
void* extData;
ReflectionDataTable * containerTable;
};
}
}
//***really*** wanted to avoid implementing this inside of the header
#include "ReflectionProperty_imp.h"
#include "ReflectionProperty_impl.h"

View File

@@ -0,0 +1,44 @@
using namespace B3D::Reflection;
template<class T>
ReflectionProperty<T>::ReflectionProperty(std::string key, T * value, ReflectionType type, ReflectionDataTable * containerTable, void* extData = NULL, bool archivable = true, bool locked = false, bool propertyHidden = false)
{
this->value = value;
this->type = type;
this->containerTable = containerTable;
this->locked = locked;
this->archivable = archivable;
this->propertyHidden = propertyHidden;
this->extData = extData;
containerTable->mapProperty(key, (ReflectionProperty<void*>*)this);
}
template<class T>
ReflectionProperty<T>::ReflectionProperty(std::string key, T value, ReflectionType type, ReflectionDataTable * containerTable, void* extData = NULL, bool archivable = true, bool locked = false, bool propertyHidden = false)
{
this->value = new T(value);
this->type = type;
this->containerTable = containerTable;
this->locked = locked;
this->archivable = archivable;
this->propertyHidden = propertyHidden;
this->extData = extData;
containerTable->mapProperty(key, (ReflectionProperty<void*>*)this);
}
template<class T>
ReflectionProperty<T>::ReflectionProperty(void)
{
}
template<class T>
ReflectionProperty<T>::~ReflectionProperty(void)
{
}
template<class T>
void ReflectionProperty<T>::dispose()
{
delete value;
value = NULL;
}

View File

@@ -1,30 +0,0 @@
using namespace B3D::Reflection;
template<class T>
ReflectionProperty<T>::ReflectionProperty(std::string key, T * value, ReflectionType type, ReflectionDataTable * containerTable)
{
this->value = value;
this->type = type;
this->containerTable = containerTable;
this->locked = locked;
this->archivable = archivable;
this->propertyHidden = propertyHidden;
containerTable->mapProperty(key, (ReflectionProperty<void*>*)this);
}
template<class T>
ReflectionProperty<T>::ReflectionProperty(void)
{
}
template<class T>
ReflectionProperty<T>::~ReflectionProperty(void)
{
}
template<class T>
void ReflectionProperty<T>::dispose()
{
delete value;
value = NULL;
}