Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluginsystem #569

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cd41c45
Fixes #563, adds the ability to open a file directly in the IDE (with…
Sep 13, 2014
eda3589
First steps to implement a plugin system: *New Plugin Resource, *Plug…
Aug 16, 2014
4497246
Further steps to implement plugin system: *Loading and saving of the …
Aug 19, 2014
8c32c3e
Rather final changes for loading plugins, props and sheets.
Aug 28, 2014
e840e75
Final changes for Sheets, added a Editor to create plugins (for now P…
Sep 1, 2014
deb6764
Some improvements with the PluginEdior for long prop names.
Sep 3, 2014
6e6f310
Made prop names clearer, little rewrite of the plugin information sav…
Sep 3, 2014
9927988
Implemented ComboProps, added removeItem funtions to UIComboBox. Enti…
Sep 5, 2014
c0558d7
Added ability to remove props from a plugin in the Plugin Editor
Sep 6, 2014
efe3819
Got rid of the arrayVal in EntityProps.
Sep 11, 2014
e5396d8
(Re-)adding pluginEditor icons, Fixing problems with more than one pl…
Sep 13, 2014
ef6149e
(Re-)adding pluginEditor icons, Fixing problems with more than one pl…
Sep 12, 2014
6691834
Cleaned up a bit, added correct implementation of slider props (min a…
Sep 13, 2014
5845081
Added Plugin folder to IDE Resources, including PhysicsModul.plugin, …
Sep 15, 2014
ac31c12
Fix last commit: forgot to add PhysicsModul.plugin.
Sep 15, 2014
0c011ae
Fixed some issues, added addPhysicsChildEntity and addCollisionChildE…
Sep 23, 2014
39d0ad1
Hopefully (not tested) add the function to Linux IDE to open files di…
Sep 13, 2014
f6fad7e
Fix PolycodeIDEApp::openFilePicker() to be able to use PolycodeUI fil…
Sep 15, 2014
6da87cd
Fix rebase issue.
Sep 23, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Core/Contents/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SET(polycore_SRCS
Source/PolyEventHandler.cpp
Source/PolyFixedShader.cpp
Source/PolyFont.cpp
Source/PolyFontGlyphSheet.cpp
Source/PolyFontGlyphSheet.cpp
Source/PolyFontManager.cpp
Source/PolyGLCubemap.cpp
Source/PolyGLRenderer.cpp
Expand All @@ -40,6 +40,8 @@ SET(polycore_SRCS
Source/PolyObject.cpp
Source/PolyParticleEmitter.cpp
Source/PolyPerlin.cpp
Source/PolyPlugin.cpp
Source/PolyPluginManager.cpp
Source/PolyQuaternion.cpp
Source/PolyQuaternionCurve.cpp
Source/PolyRectangle.cpp
Expand All @@ -62,8 +64,8 @@ SET(polycore_SRCS
Source/PolySound.cpp
Source/PolySoundManager.cpp
Source/PolyString.cpp
Source/PolyTextMesh.cpp
Source/PolyTexture.cpp
Source/PolyTextMesh.cpp
Source/PolyTexture.cpp
Source/PolyThreaded.cpp
Source/PolyTimer.cpp
Source/PolyTimerManager.cpp
Expand Down Expand Up @@ -105,7 +107,7 @@ SET(polycore_HDRS
Include/PolyEventHandler.h
Include/PolyFixedShader.h
Include/PolyFont.h
Include/PolyFontGlyphSheet.h
Include/PolyFontGlyphSheet.h
Include/PolyFontManager.h
Include/PolyGLCubemap.h
Include/PolyGLHeaders.h
Expand All @@ -129,6 +131,8 @@ SET(polycore_HDRS
Include/PolyObject.h
Include/PolyParticleEmitter.h
Include/PolyPerlin.h
Include/PolyPlugin.h
Include/PolyPluginManager.h
Include/PolyQuaternionCurve.h
Include/PolyQuaternion.h
Include/PolyRectangle.h
Expand Down
11 changes: 10 additions & 1 deletion Core/Contents/Include/PolyCoreServices.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ namespace Polycode {
class TweenManager;
class ResourceManager;
class SoundManager;
class PluginManager;
class Core;
class CoreMutex;
class Logger;

/**
* Global services singleton. CoreServices instantiates and provides global Singleton access to all of the main manager classes in Polycode as well as the Renderer and Config classes.
*/
Expand Down Expand Up @@ -141,6 +142,13 @@ namespace Polycode {
*/
FontManager *getFontManager();

/**
* Returns the plugin manager. The plugin manager is responsible for loading and managing plugins.
* @return Plugin Manager
* @see PluginManager
*/
PluginManager *getPluginManager();

/**
* Returns the logger. It can log messages and broadcast them to listeners.
*/
Expand Down Expand Up @@ -181,6 +189,7 @@ namespace Polycode {
ResourceManager *resourceManager;
SoundManager *soundManager;
FontManager *fontManager;
PluginManager *pluginManager;
Renderer *renderer;
};

Expand Down
105 changes: 91 additions & 14 deletions Core/Contents/Include/PolyEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,37 @@
#include "PolyRectangle.h"
#include "PolyRay.h"
#include "PolyEventDispatcher.h"
#include "PolyPlugin.h"
#include <vector>

namespace Polycode {

class Renderer;
class ResourcePool;

class _PolyExport MouseEventResult {
public:
bool hit;
bool blocked;
};

class _PolyExport EntityProp {
public:
String propName;
String propValue;
class _PolyExport EntityProp : public PolyBase { public:
EntityProp(const String& name, const unsigned int& type = EntityProp::PROP_STRING);

int type;
String name;

String stringVal;
Number numberVal;
int intVal;
bool boolVal;
//std::vector<EntityProp*> arrayVal;

static const unsigned int PROP_NUMBER = 0;
static const unsigned int PROP_INT = 1;
static const unsigned int PROP_BOOL = 2;
static const unsigned int PROP_STRING = 3;
static const unsigned int PROP_ARRAY = 4;
};

class _PolyExport AABB {
Expand Down Expand Up @@ -718,19 +733,81 @@ namespace Polycode {
std::vector<Entity*> getEntitiesByLayerID(unsigned char layerID, bool recursive) const;

/**
* Returns custom string dictionary property of the entity based on the property name.
* Returns int property of the entity based on the property name.
* @param Property name to look up.
* @return String property for specified property name or "null" if this property doesn't exist.
* @return int property for specified property name or false if this property doesn't exist.
*/
String getEntityProp(const String& propName);

/**
* Sets the entity property for a specified property name in the entity's custom property dictionary.
int getEntityPropIntByName (const String& propName) const;

/**
* Returns Number property of the entity based on the property name.
* @param Property name to look up.
* @return Number property for specified property name or 0 if this property doesn't exist.
*/
Number getEntityPropNumberByName (const String& propName) const;

/**
* Returns Bool property of the entity based on the property name.
* @param Property name to look up.
* @return Bool property for specified property name or -1 if this property doesn't exist.
*/
bool getEntityPropBoolByName (const String& propName) const;

/**
* Returns String property of the entity based on the property name.
* @param Property name to look up.
* @return String property for specified property name or "null" if this property doesn't exist.
*/
String getEntityPropStringByName (const String& propName) const;

/**
* Returns vector of EntityProp property of the entity based on the property name.
* @param Property name to look up.
* @return vector of EntityProp property for specified property name - is empty if this property doesn't exist.
*/
//std::vector<EntityProp*> getEntityPropArrayByName(const String& propName) const;

/**
* Sets the entity property for a specified property name.
* @param propName Property name to set.
* @param propValue Value to set for the specified property name.
* @param propVal String to set for the specified property name.
*/
void setEntityProp(const String& propName, const String& propValue);
void setEntityProp(const String& propName, const String& propVal);

/**
* Sets the entity property for a specified property name.
* @param propName Property name to set.
* @param propVal int to set for the specified property name.
*/
void setEntityProp(const String& propName, const int& propVal);

/**
* Sets the entity property for a specified property name.
* @param propName Property name to set.
* @param propVal Number to set for the specified property name.
*/
void setEntityProp(const String& propName, const Number& propVal);

/**
* Sets the entity property for a specified property name.
* @param propName Property name to set.
* @param propVal bool to set for the specified property name.
*/
void setEntityProp(const String& propName, const bool& propVal);

/**
* Sets the entity property for a specified property name.
* @param propName Property name to set.
* @param propVal vector of EntityProp* to set for the specified property name.
*/
//void setEntityProp(const String& propName, std::vector<EntityProp*> propVal);

void setEntityProp(EntityProp* prop);

bool isRequiredPlugin(const String& pluginName) const;
void addPluginByName(const String& name, ResourcePool *resourcePool = NULL);
void removePluginByName(const String& name);

/**
* If set to true, the y position of the entity matrix will be multiplied by -1.0, inverting its Y-axis coordinate system.
*/
Expand Down Expand Up @@ -895,8 +972,8 @@ namespace Polycode {
*/
unsigned char layerID;

std::vector <EntityProp> entityProps;
std::vector <EntityProp*> entityProps;
std::vector<Plugin*> requiredPlugins;
protected:


Expand Down
95 changes: 95 additions & 0 deletions Core/Contents/Include/PolyPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
Copyright (C) 2014 by Joachim Meyer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#pragma once
#include "PolyGlobals.h"
#include "PolyString.h"
#include "PolyResource.h"

namespace Polycode {
class ObjectEntry;

class _PolyExport Prop : public PolyBase {
public:
Prop(const String& name, const int type = Prop::PROP_STRING);
Prop(ObjectEntry *entry);
~Prop();

Prop *loadPropFromEntry(ObjectEntry* entry);

int type;
String name;
int value;

std::vector<Prop*> children;

static const int PROP_VECTOR3 = 0;
static const int PROP_VECTOR2 = 1;
static const int PROP_SLIDER = 2;
static const int PROP_BUTTON = 3;
static const int PROP_NUMBER = 4;
static const int PROP_TARGET_BINDING = 5;
static const int PROP_RENDER_TARGET = 6;
static const int PROP_SHADER_PASS = 7;
static const int PROP_REMOVABLE_STRING = 8;
static const int PROP_LAYER = 9;
static const int PROP_CUSTOM = 10;
static const int PROP_STRING = 11;
static const int PROP_COLOR = 12;
static const int PROP_COMBO = 13;
static const int PROP_BOOL = 14;
static const int PROP_SOUND = 15;
static const int PROP_BEZIER_RGBA_CURVE = 16;
static const int PROP_BEZIER_CURVE = 17;
static const int PROP_MATERIAL = 18;
static const int PROP_MATERIAL_PREVIEW = 19;
static const int PROP_TEXTURE = 20;
static const int PROP_SCENE_SPRITE = 21;
static const int PROP_SCENE_ENTITY_INSTANCE = 22; };

class _PolyExport Plugin : public Resource {
public:
Plugin(const String& name);
Plugin(ObjectEntry *entry);
~Plugin();

Plugin* loadPluginFromEntry(ObjectEntry *entry);

void setProp(Prop* prop);

void removeProp(Prop* prop);
void removeProp(const String& propName);

std::vector<Prop*> getProps() const;
unsigned int getNumProps() const;

unsigned int pluginType;

static const unsigned int PLUGIN_ENTITY = 0;

String ext;
String author;

protected:
std::vector<Prop*> props;
};
}
47 changes: 47 additions & 0 deletions Core/Contents/Include/PolyPluginManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright (C) 2014 by Joachim Meyer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#pragma once
#include "PolyGlobals.h"
#include "PolyPlugin.h"

namespace Polycode {

class ResourcePool;
class String;

class PluginManager : public PolyBase {
public:
PluginManager();
~PluginManager();

std::vector<Plugin*> loadPluginsFromFile(ResourcePool* pool, const String &fileName);
void loadPluginLibraryIntoPool(ResourcePool *pool, const String &pluginFile);

void addPlugin(Plugin* plugin);

protected:
Number version;
std::vector<Plugin*> plugins;
};

}
7 changes: 2 additions & 5 deletions Core/Contents/Include/PolyResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ namespace Polycode {
static const int RESOURCE_CUBEMAP = 6;
static const int RESOURCE_SPRITE = 7;
static const int RESOURCE_ENTITY_INSTANCE = 8;

static const int RESOURCE_PLUGIN = 9;

bool reloadOnFileModify;

static bool defaultReloadOnFileModify;
Expand All @@ -69,12 +70,8 @@ namespace Polycode {
//@}

protected:


int type;
String resourcePath;
String name;


};
}
Loading