Entity is now sent with the click events.

Fixed small things
This commit is contained in:
Tleety
2016-02-19 12:49:07 +01:00
parent a6c30100af
commit fc5d054cb2
6 changed files with 19 additions and 10 deletions
+2 -1
View File
@@ -7,7 +7,8 @@ namespace Events
{ {
struct ButtonClicked : public Event { struct ButtonClicked : public Event {
std::string EntityName = "DEFAULT STRING USED"; std::string EntityName;
EntityWrapper Entity;
}; };
} }
+2 -1
View File
@@ -7,7 +7,8 @@ namespace Events
{ {
struct ButtonPressed : public Event { struct ButtonPressed : public Event {
std::string EntityName = "DEFAULT STRING USED"; std::string EntityName;
EntityWrapper Entity;
}; };
} }
+3 -1
View File
@@ -6,7 +6,9 @@
namespace Events namespace Events
{ {
struct ButtonReleased : public Event { }; struct ButtonReleased : public Event {
EntityWrapper Entity;
};
} }
+2 -2
View File
@@ -108,7 +108,7 @@ struct ModelJob : RenderJob
EndIndex = matGroup->EndIndex; EndIndex = matGroup->EndIndex;
Matrix = matrix; Matrix = matrix;
Color = modelComponent["Color"]; Color = modelComponent["Color"];
GlowIntencity = ((double)modelComponent["GlowIntensity"]); GlowIntensity = ((double)modelComponent["GlowIntensity"]);
Entity = modelComponent.EntityID; Entity = modelComponent.EntityID;
glm::vec3 abspos = Transform::AbsolutePosition(world, modelComponent.EntityID); glm::vec3 abspos = Transform::AbsolutePosition(world, modelComponent.EntityID);
glm::vec3 worldpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1)); glm::vec3 worldpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1));
@@ -171,7 +171,7 @@ struct ModelJob : RenderJob
::Skeleton::AnimationOffset AnimationOffset; ::Skeleton::AnimationOffset AnimationOffset;
float GlowIntencity = 8.0; float GlowIntensity = 8.0;
glm::vec4 DiffuseColor; glm::vec4 DiffuseColor;
glm::vec4 SpecularColor; glm::vec4 SpecularColor;
glm::vec4 IncandescenceColor; glm::vec4 IncandescenceColor;
+8 -3
View File
@@ -38,6 +38,7 @@ bool ButtonSystem::OnMousePress(const Events::MousePress& e)
//You have clicked on a button entity, send pressed event. //You have clicked on a button entity, send pressed event.
Events::ButtonPressed ePressed; Events::ButtonPressed ePressed;
ePressed.Entity = m_PickEntity;
ePressed.EntityName = m_PickEntity.Name(); ePressed.EntityName = m_PickEntity.Name();
m_EventBroker->Publish(ePressed); m_EventBroker->Publish(ePressed);
} }
@@ -50,15 +51,19 @@ bool ButtonSystem::OnMouseRelease(const Events::MouseRelease& e)
{ {
if(!m_MouseIsLocked) { if(!m_MouseIsLocked) {
//Mouse is not locked, send release event. //Mouse is not locked, send release event.
Events::ButtonReleased eReleased;
m_EventBroker->Publish(eReleased);
m_PickData = m_Renderer->Pick(glm::vec2(e.X, e.Y)); m_PickData = m_Renderer->Pick(glm::vec2(e.X, e.Y));
if(m_PickData.Entity != EntityID_Invalid && m_PickData.World == m_World) { if(m_PickData.Entity != EntityID_Invalid && m_PickData.World == m_World) {
EntityWrapper ent = EntityWrapper(m_World, m_PickData.Entity);
Events::ButtonReleased eReleased;
eReleased.Entity = ent;
m_EventBroker->Publish(eReleased);
if(m_World->HasComponent(m_PickData.Entity, "Button")) { if(m_World->HasComponent(m_PickData.Entity, "Button")) {
EntityWrapper ent = EntityWrapper(m_World, m_PickData.Entity);
if (ent == m_PickEntity) { if (ent == m_PickEntity) {
//The entity you released the mouse button on is the same as you pressed it on. "Clicked" //The entity you released the mouse button on is the same as you pressed it on. "Clicked"
Events::ButtonClicked eClicked; Events::ButtonClicked eClicked;
eClicked.Entity = m_PickEntity;
eClicked.EntityName = m_PickEntity.Name(); eClicked.EntityName = m_PickEntity.Name();
m_EventBroker->Publish(eClicked); m_EventBroker->Publish(eClicked);
} }
+2 -2
View File
@@ -736,7 +736,7 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
GLERROR("Bind 19 uniform"); GLERROR("Bind 19 uniform");
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
GLERROR("Bind 20 uniform"); GLERROR("Bind 20 uniform");
glUniform1f(glGetUniformLocation(shaderHandle, "GlowIntensity"), job->GlowIntencity); glUniform1f(glGetUniformLocation(shaderHandle, "GlowIntensity"), job->GlowIntensity);
GLERROR("END"); GLERROR("END");
} }
@@ -775,7 +775,7 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<Model
GLERROR("Bind 10 uniform"); GLERROR("Bind 10 uniform");
GLint Location_GlowIntensity = glGetUniformLocation(shaderHandle, "GlowIntensity"); GLint Location_GlowIntensity = glGetUniformLocation(shaderHandle, "GlowIntensity");
glUniform1f(Location_GlowIntensity, job->GlowIntencity); glUniform1f(Location_GlowIntensity, job->GlowIntensity);
GLERROR("END"); GLERROR("END");
} }