Merge branch 'master' into particles
Conflicts: src/GameWorld.cpp vs11/Returngeance/Returngeance.vcxproj vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
+18
-6
@@ -6,6 +6,9 @@
|
||||
|
||||
#include "Util/Rectangle.h"
|
||||
#include "EventBroker.h"
|
||||
#include "Events/KeyDown.h"
|
||||
#include "Events/KeyUp.h"
|
||||
#include "Events/InputCommand.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "Renderer.h"
|
||||
#include "RenderQueue.h"
|
||||
@@ -79,7 +82,13 @@ public:
|
||||
std::string Name() const { return m_Name; }
|
||||
void SetName(std::string val) { m_Name = val; }
|
||||
int Layer() const { return m_Layer; }
|
||||
bool Hidden() const { return m_Hidden; }
|
||||
bool Hidden() const
|
||||
{
|
||||
if (m_Parent)
|
||||
return m_Parent->Hidden() || m_Hidden;
|
||||
else
|
||||
return m_Hidden;
|
||||
}
|
||||
void Hide() { m_Hidden = true; }
|
||||
void Show() { m_Hidden = false; }
|
||||
|
||||
@@ -129,11 +138,6 @@ public:
|
||||
return Rectangle(left, top, width, height);
|
||||
}
|
||||
|
||||
virtual bool OnKeyDown(const Events::KeyDown &event) { return false; }
|
||||
virtual bool OnKeyUp(const Events::KeyUp &event) { return false; }
|
||||
//virtual bool OnMouseDown(const Events::KeyDown &event) { }
|
||||
//virtual bool OnMouseUp(const Events::KeyDown &event) { }
|
||||
|
||||
void UpdateLayered(double dt)
|
||||
{
|
||||
if (this->Hidden())
|
||||
@@ -196,14 +200,22 @@ protected:
|
||||
typedef std::multimap<std::string, std::shared_ptr<Frame>> Children_t; // name -> frame
|
||||
std::map<int, Children_t> m_Children; // layer -> Children_t
|
||||
|
||||
virtual bool OnKeyDown(const Events::KeyDown &event) { return false; }
|
||||
virtual bool OnKeyUp(const Events::KeyUp &event) { return false; }
|
||||
//virtual bool OnMouseDown(const Events::KeyDown &event) { }
|
||||
//virtual bool OnMouseUp(const Events::KeyDown &event) { }
|
||||
virtual bool OnCommand(const Events::InputCommand &event) { return false; }
|
||||
|
||||
private:
|
||||
EventRelay<Frame, Events::KeyDown> m_EKeyDown;
|
||||
EventRelay<Frame, Events::KeyUp> m_EKeyUp;
|
||||
EventRelay<Frame, Events::InputCommand> m_EInputCommand;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Frame::OnKeyDown);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Frame::OnKeyUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Frame::OnCommand);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+3
-3
@@ -25,13 +25,13 @@ public:
|
||||
vp1 = new Viewport(worldFrame, "Viewport1", m_World);
|
||||
vp1->X = 0;
|
||||
vp1->Width = this->Width / 2.f;
|
||||
new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||
//new VehicleSelection(vp1, "VehicleSelection", m_World, 1);
|
||||
//new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||
auto vehicleSelection = new VehicleSelection(vp1, "VehicleSelection", m_World, 1);
|
||||
|
||||
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
|
||||
vp2->X = vp1->Right();
|
||||
vp2->Width = this->Width / 2.f;
|
||||
new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
//new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
|
||||
m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World);
|
||||
m_FreeCamViewport->Hide();
|
||||
|
||||
+72
-27
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/HealthOverlay.h"
|
||||
#include "Events/SpawnVehicle.h"
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
@@ -37,35 +38,8 @@ namespace GUI
|
||||
m_Background->SetTexture("Textures/GUI/VehicleSelection/1.png");
|
||||
}
|
||||
|
||||
bool OnKeyUp(const Events::KeyUp &event) override
|
||||
{
|
||||
if (event.KeyCode == GLFW_KEY_LEFT)
|
||||
{
|
||||
m_CurrentSelection--;
|
||||
}
|
||||
else if (event.KeyCode == GLFW_KEY_RIGHT)
|
||||
{
|
||||
m_CurrentSelection++;
|
||||
}
|
||||
m_CurrentSelection = (m_CurrentSelection < 0) ? 0 : ((m_CurrentSelection > 3) ? 3 : m_CurrentSelection);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Textures/GUI/VehicleSelection/" << m_CurrentSelection + 1 << ".png";
|
||||
m_Background->FadeToTexture(ss.str(), 1.f);
|
||||
|
||||
glm::vec2 scale = Scale();
|
||||
glm::vec2 coord = -m_SelectionCoordinates[m_CurrentSelection];
|
||||
m_TargetCoordinate = coord * scale + glm::vec2(Width / 2.f, Height / 2.f);
|
||||
glm::vec2 size = m_SelectionSizes[m_CurrentSelection];
|
||||
m_TargetSize = size * scale;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Update(double dt) override
|
||||
{
|
||||
|
||||
|
||||
glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate;
|
||||
m_CurrentCoordinate += posDiff * 2.f * (float)dt;
|
||||
|
||||
@@ -94,6 +68,77 @@ namespace GUI
|
||||
float m_CurrentAlpha;
|
||||
|
||||
TextureFrame* m_Background;
|
||||
|
||||
bool OnCommand(const Events::InputCommand &event) override
|
||||
{
|
||||
if (Hidden())
|
||||
return false;
|
||||
|
||||
if (event.PlayerID != m_PlayerID)
|
||||
return false;
|
||||
|
||||
// Menu movement
|
||||
if (event.Command == "interface_horizontal" || event.Command == "interface_vertical")
|
||||
{
|
||||
// Horizontal scrolling
|
||||
if (event.Command == "interface_horizontal")
|
||||
{
|
||||
if (event.Value > 0)
|
||||
m_CurrentSelection++;
|
||||
else if (event.Value < 0)
|
||||
m_CurrentSelection--;
|
||||
}
|
||||
// Vertical scrolling to switch between "rows" in an intuitive way
|
||||
else if (event.Command == "interface_vertical")
|
||||
{
|
||||
if (event.Value > 0)
|
||||
{
|
||||
if (m_CurrentSelection == 0)
|
||||
m_CurrentSelection++;
|
||||
else if (m_CurrentSelection == 3)
|
||||
m_CurrentSelection--;
|
||||
}
|
||||
else if (event.Value < 0)
|
||||
{
|
||||
if (m_CurrentSelection == 1)
|
||||
m_CurrentSelection--;
|
||||
else if (m_CurrentSelection == 2)
|
||||
m_CurrentSelection++;
|
||||
}
|
||||
}
|
||||
|
||||
m_CurrentSelection = (m_CurrentSelection < 0) ? 0 : ((m_CurrentSelection > 3) ? 3 : m_CurrentSelection);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Textures/GUI/VehicleSelection/" << m_CurrentSelection + 1 << ".png";
|
||||
m_Background->FadeToTexture(ss.str(), 1.f);
|
||||
|
||||
glm::vec2 scale = Scale();
|
||||
glm::vec2 coord = -m_SelectionCoordinates[m_CurrentSelection];
|
||||
m_TargetCoordinate = coord * scale + glm::vec2(Width / 2.f, Height / 2.f);
|
||||
glm::vec2 size = m_SelectionSizes[m_CurrentSelection];
|
||||
m_TargetSize = size * scale;
|
||||
}
|
||||
|
||||
// Vehicle select
|
||||
if (event.Command == "interface_confirm" && event.Value > 0)
|
||||
{
|
||||
Events::SpawnVehicle e;
|
||||
e.PlayerID = m_PlayerID;
|
||||
if (m_CurrentSelection == 0)
|
||||
e.VehicleType = "Tank"; // HACK: Base on selected vehicle ID
|
||||
else if (m_CurrentSelection == 1)
|
||||
e.VehicleType = "Helicopter";
|
||||
else if (m_CurrentSelection == 2)
|
||||
e.VehicleType = "HRSV";
|
||||
else if (m_CurrentSelection == 3)
|
||||
e.VehicleType = "Jeep";
|
||||
EventBroker->Publish(e);
|
||||
Hide();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
glm::vec2 VehicleSelection::m_SelectionCoordinates[4] = {
|
||||
|
||||
Reference in New Issue
Block a user