Created a FileDropped event for when a file is dropped onto the client by the OS

This commit is contained in:
2015-12-17 13:26:12 +01:00
parent 8000654005
commit c1b9404e52
3 changed files with 37 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
#ifndef EFileDropped_h__
#define EFileDropped_h__
#include "EventBroker.h"
namespace Events
{
struct FileDropped : Event
{
std::string Path;
};
}
#endif
+3
View File
@@ -16,6 +16,7 @@
#include "ELockMouse.h"
#include "EGamepadAxis.h"
#include "EGamepadButton.h"
#include "EFileDropped.h"
class InputManager
{
@@ -71,6 +72,8 @@ private:
static void GLFWCharCallback(GLFWwindow* window, unsigned int c);
static std::vector<std::pair<double, double>> GLFWScrollCallbackQueue;
static void GLFWScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
static std::vector<std::string> GLFWDropCallbackQueue;
static void GLFWDropCallback(GLFWwindow* window, int count, const char* paths[]);
};
#endif
+18
View File
@@ -2,6 +2,7 @@
std::vector<unsigned int> InputManager::GLFWCharCallbackQueue;
std::vector<std::pair<double, double>> InputManager::GLFWScrollCallbackQueue;
std::vector<std::string> InputManager::GLFWDropCallbackQueue;
void InputManager::Initialize()
{
@@ -10,6 +11,7 @@ void InputManager::Initialize()
//m_LastGamepadButtonState = std::array<GamepadButtonState, XUSER_MAX_COUNT>();
glfwSetCharCallback(m_GLFWWindow, &InputManager::GLFWCharCallback);
glfwSetScrollCallback(m_GLFWWindow, &InputManager::GLFWScrollCallback);
glfwSetDropCallback(m_GLFWWindow, &InputManager::GLFWDropCallback);
EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &InputManager::OnLockMouse);
EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &InputManager::OnUnlockMouse);
@@ -95,6 +97,14 @@ void InputManager::Update(double dt)
}
GLFWScrollCallbackQueue.clear();
// File drop
for (auto& path : GLFWDropCallbackQueue) {
Events::FileDropped e;
e.Path = path;
m_EventBroker->Publish(e);
}
GLFWDropCallbackQueue.clear();
// // Lock mouse while holding LMB
// if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
// {
@@ -229,6 +239,14 @@ void InputManager::GLFWScrollCallback(GLFWwindow* window, double xoffset, double
GLFWScrollCallbackQueue.push_back(std::make_pair(xoffset, yoffset));
}
void InputManager::GLFWDropCallback(GLFWwindow* window, int count, const char* paths[])
{
for (int i = 0; i < count; i++) {
GLFWDropCallbackQueue.push_back(std::string(paths[i]));
}
}
bool InputManager::OnLockMouse(const Events::LockMouse &event)
{
m_MouseLocked = true;