consolodate NetworkEvents
This commit is contained in:
@@ -1,49 +1,47 @@
|
|||||||
#include "Archimedes.h"
|
#ifndef NETWORKEVENTS_H
|
||||||
|
#define NETWORKEVENTS_H
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
#include <steam/steamnetworkingsockets.h>
|
#include <steam/steamnetworkingsockets.h>
|
||||||
#include <steam/isteamnetworkingutils.h>
|
#include <steam/isteamnetworkingutils.h>
|
||||||
|
|
||||||
|
namespace Archimedes {
|
||||||
|
|
||||||
|
class DataRecievedEvent : public Event {
|
||||||
namespace SMEvent {
|
|
||||||
class DataRecievedEvent : public Archimedes::Event {
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DataRecievedEvent() : msg(nullptr) {}
|
DataRecievedEvent() : msg(nullptr) {}
|
||||||
|
|
||||||
|
DataRecievedEvent(ISteamNetworkingMessage* m) : msg(m) {}
|
||||||
|
|
||||||
~DataRecievedEvent() {
|
~DataRecievedEvent() {
|
||||||
if(msg)
|
if(msg)
|
||||||
msg->Release();
|
msg->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
DataRecievedEvent(ISteamNetworkingMessage* m) : msg(m) {}
|
operator std::string() const override { return "DataRecievedEvent"; }
|
||||||
|
|
||||||
operator std::string() const { return "SMEvent::DataRecievedEvent"; }
|
|
||||||
|
|
||||||
ISteamNetworkingMessage* msg;
|
ISteamNetworkingMessage* msg;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataSentEvent : public Archimedes::Event {
|
class DataSentEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DataSentEvent() : msg(nullptr) {}
|
DataSentEvent() : msg(nullptr) {}
|
||||||
|
|
||||||
~DataSentEvent() {
|
DataSentEvent(const void* m, uint32 l) : msg(m), length(l) {}
|
||||||
if(msg)
|
|
||||||
msg->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
DataSentEvent(ISteamNetworkingMessage* m) : msg(m) {}
|
operator std::string() const override { return "DataSentEvent"; }
|
||||||
|
|
||||||
operator std::string() const { return "SMEvent::DataSentEvent"; }
|
const void* msg;
|
||||||
|
uint32 length;
|
||||||
ISteamNetworkingMessage* msg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConnectionStatusChangedEvent : public Archimedes::Event {
|
class ConnectionStatusChangedEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -51,10 +49,11 @@ namespace SMEvent {
|
|||||||
|
|
||||||
ConnectionStatusChangedEvent(SteamNetConnectionStatusChangedCallback_t* i) : info(i) {}
|
ConnectionStatusChangedEvent(SteamNetConnectionStatusChangedCallback_t* i) : info(i) {}
|
||||||
|
|
||||||
operator std::string() const { return "SMEvent::ConnectionStatusChangedEvent"; }
|
operator std::string() const override { return "ConnectionStatusChangedEvent"; }
|
||||||
|
|
||||||
SteamNetConnectionStatusChangedCallback_t* info;
|
SteamNetConnectionStatusChangedCallback_t* info;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -15,191 +15,191 @@ namespace Archimedes {
|
|||||||
std::function<void(Event*)> sendEvent;
|
std::function<void(Event*)> sendEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowResizeEvent : public Event {
|
class ResizeWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowResizeEvent() : width(0), height(0) {}
|
ResizeWindowEvent() : width(0), height(0) {}
|
||||||
|
|
||||||
WindowResizeEvent(int w, int h) : width(w), height(h) {}
|
ResizeWindowEvent(int w, int h) : width(w), height(h) {}
|
||||||
|
|
||||||
~WindowResizeEvent() {
|
~ResizeWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowResizeEvent"; }
|
operator std::string() const override { return "Archimedes::ResizeWindowEvent"; }
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowCloseEvent : public Event {
|
class CloseWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowCloseEvent() : window(nullptr) {}
|
CloseWindowEvent() : window(nullptr) {}
|
||||||
|
|
||||||
WindowCloseEvent(const Window* w) : window(w) {}
|
CloseWindowEvent(const Window* w) : window(w) {}
|
||||||
|
|
||||||
~WindowCloseEvent() {
|
~CloseWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowCloseEvent"; }
|
operator std::string() const override { return "Archimedes::CloseWindowEvent"; }
|
||||||
|
|
||||||
const Window* window;
|
const Window* window;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowKeyPressedEvent : public Event {
|
class KeyPressedWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowKeyPressedEvent() : key(0), repeat(0) {}
|
KeyPressedWindowEvent() : key(0), repeat(0) {}
|
||||||
|
|
||||||
WindowKeyPressedEvent(unsigned int k, unsigned int r) : key(k), repeat(r) {}
|
KeyPressedWindowEvent(unsigned int k, unsigned int r) : key(k), repeat(r) {}
|
||||||
|
|
||||||
~WindowKeyPressedEvent() {
|
~KeyPressedWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowKeyPressedEvent"; }
|
operator std::string() const override { return "Archimedes::KeyPressedWindowEvent"; }
|
||||||
|
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
unsigned int repeat;
|
unsigned int repeat;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowKeyReleasedEvent : public Event {
|
class KeyReleasedWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowKeyReleasedEvent() : key(0) {}
|
KeyReleasedWindowEvent() : key(0) {}
|
||||||
|
|
||||||
WindowKeyReleasedEvent(unsigned int k) : key(k) {}
|
KeyReleasedWindowEvent(unsigned int k) : key(k) {}
|
||||||
|
|
||||||
~WindowKeyReleasedEvent() {
|
~KeyReleasedWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowKeyReleasedEvent"; }
|
operator std::string() const override { return "Archimedes::KeyReleasedWindowEvent"; }
|
||||||
|
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowMouseButtonPressedEvent : public Event {
|
class MouseButtonPressedWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowMouseButtonPressedEvent() : button(0) {}
|
MouseButtonPressedWindowEvent() : button(0) {}
|
||||||
|
|
||||||
WindowMouseButtonPressedEvent(unsigned int b) : button(b) {}
|
MouseButtonPressedWindowEvent(unsigned int b) : button(b) {}
|
||||||
|
|
||||||
~WindowMouseButtonPressedEvent() {
|
~MouseButtonPressedWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowMouseButtonPressedEvent"; }
|
operator std::string() const override { return "Archimedes::MouseButtonPressedWindowEvent"; }
|
||||||
|
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowMouseButtonReleasedEvent : public Event {
|
class MouseButtonReleasedWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowMouseButtonReleasedEvent() : button(0) {}
|
MouseButtonReleasedWindowEvent() : button(0) {}
|
||||||
|
|
||||||
WindowMouseButtonReleasedEvent(unsigned int b) : button(b) {}
|
MouseButtonReleasedWindowEvent(unsigned int b) : button(b) {}
|
||||||
|
|
||||||
~WindowMouseButtonReleasedEvent() {
|
~MouseButtonReleasedWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowMouseButtonReleasedEvent"; }
|
operator std::string() const override { return "Archimedes::MouseButtonReleasedWindowEvent"; }
|
||||||
|
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowScrollEvent : public Event {
|
class ScrollWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowScrollEvent() : dx(0), dy(0) {}
|
ScrollWindowEvent() : dx(0), dy(0) {}
|
||||||
|
|
||||||
WindowScrollEvent(double x, double y) : dx(x), dy(y) {}
|
ScrollWindowEvent(double x, double y) : dx(x), dy(y) {}
|
||||||
|
|
||||||
~WindowScrollEvent() {
|
~ScrollWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowScrollEvent"; }
|
operator std::string() const override { return "Archimedes::ScrollWindowEvent"; }
|
||||||
|
|
||||||
double dx, dy;
|
double dx, dy;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowMouseMovedEvent : public Event {
|
class MouseMovedWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowMouseMovedEvent() : x(0), y(0) {}
|
MouseMovedWindowEvent() : x(0), y(0) {}
|
||||||
|
|
||||||
WindowMouseMovedEvent(double x, double y) : x(x), y(y) {}
|
MouseMovedWindowEvent(double x, double y) : x(x), y(y) {}
|
||||||
|
|
||||||
~WindowMouseMovedEvent() {
|
~MouseMovedWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowMouseMovedEvent"; }
|
operator std::string() const override { return "Archimedes::MouseMovedWindowEvent"; }
|
||||||
|
|
||||||
double x, y;
|
double x, y;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowFocusedEvent : public Event {
|
class FocusedWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowFocusedEvent() : window(nullptr) {}
|
FocusedWindowEvent() : window(nullptr) {}
|
||||||
|
|
||||||
WindowFocusedEvent(const Window* w) : window(w) {}
|
FocusedWindowEvent(const Window* w) : window(w) {}
|
||||||
|
|
||||||
~WindowFocusedEvent() {
|
~FocusedWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowFocusedEvent"; }
|
operator std::string() const override { return "Archimedes::FocusedWindowEvent"; }
|
||||||
|
|
||||||
const Window* window;
|
const Window* window;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowFocusLostEvent : public Event {
|
class FocusLostWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowFocusLostEvent() : window(nullptr) {}
|
FocusLostWindowEvent() : window(nullptr) {}
|
||||||
|
|
||||||
WindowFocusLostEvent(const Window* w) : window(w) {}
|
FocusLostWindowEvent(const Window* w) : window(w) {}
|
||||||
|
|
||||||
~WindowFocusLostEvent() {
|
~FocusLostWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowFocusLostEvent"; }
|
operator std::string() const override { return "Archimedes::FocusLostWindowEvent"; }
|
||||||
|
|
||||||
const Window* window;
|
const Window* window;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowMovedEvent : public Event {
|
class MovedWindowEvent : public Event {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowMovedEvent() : x(0), y(0) {}
|
MovedWindowEvent() : x(0), y(0) {}
|
||||||
|
|
||||||
WindowMovedEvent(int x, int y) : x(x), y(y) {}
|
MovedWindowEvent(int x, int y) : x(x), y(y) {}
|
||||||
|
|
||||||
~WindowMovedEvent() {
|
~MovedWindowEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operator std::string() const override { return "Archimedes::WindowMovedEvent"; }
|
operator std::string() const override { return "Archimedes::MovedWindowEvent"; }
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,13 +43,13 @@ namespace Archimedes {
|
|||||||
glfwSetWindowSizeCallback(w, [](GLFWwindow* window, int w, int h){
|
glfwSetWindowSizeCallback(w, [](GLFWwindow* window, int w, int h){
|
||||||
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
d.sendEvent(new WindowResizeEvent(w, h));
|
d.sendEvent(new ResizeWindowEvent(w, h));
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetWindowCloseCallback(w, [](GLFWwindow* window){
|
glfwSetWindowCloseCallback(w, [](GLFWwindow* window){
|
||||||
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
d.sendEvent(new WindowCloseEvent(d.window));
|
d.sendEvent(new CloseWindowEvent(d.window));
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetKeyCallback(w, [](GLFWwindow* window, int key, int scancode, int action, int mods){
|
glfwSetKeyCallback(w, [](GLFWwindow* window, int key, int scancode, int action, int mods){
|
||||||
@@ -57,13 +57,13 @@ namespace Archimedes {
|
|||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case GLFW_PRESS:
|
case GLFW_PRESS:
|
||||||
d.sendEvent(new WindowKeyPressedEvent(key, 0));
|
d.sendEvent(new KeyPressedWindowEvent(key, 0));
|
||||||
break;
|
break;
|
||||||
case GLFW_RELEASE:
|
case GLFW_RELEASE:
|
||||||
d.sendEvent(new WindowKeyReleasedEvent(key));
|
d.sendEvent(new KeyReleasedWindowEvent(key));
|
||||||
break;
|
break;
|
||||||
case GLFW_REPEAT:
|
case GLFW_REPEAT:
|
||||||
d.sendEvent(new WindowKeyPressedEvent(key, 1));
|
d.sendEvent(new KeyPressedWindowEvent(key, 1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -73,10 +73,10 @@ namespace Archimedes {
|
|||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case GLFW_PRESS:
|
case GLFW_PRESS:
|
||||||
d.sendEvent(new WindowMouseButtonPressedEvent(button));
|
d.sendEvent(new MouseButtonPressedWindowEvent(button));
|
||||||
break;
|
break;
|
||||||
case GLFW_RELEASE:
|
case GLFW_RELEASE:
|
||||||
d.sendEvent(new WindowMouseButtonReleasedEvent(button));
|
d.sendEvent(new MouseButtonReleasedWindowEvent(button));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -84,13 +84,13 @@ namespace Archimedes {
|
|||||||
glfwSetScrollCallback(w, [](GLFWwindow* window, double dx, double dy){
|
glfwSetScrollCallback(w, [](GLFWwindow* window, double dx, double dy){
|
||||||
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
d.sendEvent(new WindowScrollEvent(dx, dy));
|
d.sendEvent(new ScrollWindowEvent(dx, dy));
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetCursorPosCallback(w, [](GLFWwindow* window, double dx, double dy){
|
glfwSetCursorPosCallback(w, [](GLFWwindow* window, double dx, double dy){
|
||||||
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||||
|
|
||||||
d.sendEvent(new WindowMouseMovedEvent(dx, dy));
|
d.sendEvent(new MouseMovedWindowEvent(dx, dy));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
#include "Archimedes.h"
|
|
||||||
|
|
||||||
#include <steam/steamnetworkingsockets.h>
|
|
||||||
#include <steam/isteamnetworkingutils.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace CMEvent {
|
|
||||||
class DataRecievedEvent : public Archimedes::Event {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DataRecievedEvent() : msg(nullptr) {}
|
|
||||||
|
|
||||||
DataRecievedEvent(ISteamNetworkingMessage* m) : msg(m) {}
|
|
||||||
|
|
||||||
~DataRecievedEvent() {
|
|
||||||
if(msg)
|
|
||||||
msg->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
operator std::string() const override { return "CMEvent::DataRecievedEvent"; }
|
|
||||||
|
|
||||||
ISteamNetworkingMessage* msg;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DataSentEvent : public Archimedes::Event {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DataSentEvent() : msg(nullptr) {}
|
|
||||||
|
|
||||||
DataSentEvent(ISteamNetworkingMessage* m) : msg(m) {}
|
|
||||||
|
|
||||||
operator std::string() const override { return "CMEvent::DataSentEvent"; }
|
|
||||||
|
|
||||||
ISteamNetworkingMessage* msg;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ConnectionStatusChangedEvent : public Archimedes::Event {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ConnectionStatusChangedEvent() : info(nullptr) {}
|
|
||||||
|
|
||||||
ConnectionStatusChangedEvent(SteamNetConnectionStatusChangedCallback_t* i) : info(i) {}
|
|
||||||
|
|
||||||
operator std::string() const override { return "CMEvent::ConnectionStatusChangedEvent"; }
|
|
||||||
|
|
||||||
SteamNetConnectionStatusChangedCallback_t* info;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -6,9 +6,9 @@ ClientModule::ClientModule(Archimedes::App* a, void* h) : Archimedes::Module(a,
|
|||||||
|
|
||||||
ClientModule::~ClientModule() {
|
ClientModule::~ClientModule() {
|
||||||
if(app) {
|
if(app) {
|
||||||
app->unregisterEvent(CMEvent::DataRecievedEvent());
|
app->unregisterEvent(Archimedes::DataRecievedEvent());
|
||||||
app->unregisterEvent(CMEvent::DataSentEvent());
|
app->unregisterEvent(Archimedes::DataSentEvent());
|
||||||
app->unregisterEvent(CMEvent::ConnectionStatusChangedEvent());
|
app->unregisterEvent(Archimedes::ConnectionStatusChangedEvent());
|
||||||
|
|
||||||
GameNetworkingSockets_Kill();
|
GameNetworkingSockets_Kill();
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,9 @@ ClientModule::~ClientModule() {
|
|||||||
|
|
||||||
void ClientModule::onLoad() {
|
void ClientModule::onLoad() {
|
||||||
|
|
||||||
app->registerEvent(CMEvent::DataSentEvent());
|
app->registerEvent(Archimedes::DataSentEvent());
|
||||||
app->registerEvent(CMEvent::DataRecievedEvent());
|
app->registerEvent(Archimedes::DataRecievedEvent());
|
||||||
app->registerEvent(CMEvent::ConnectionStatusChangedEvent());
|
app->registerEvent(Archimedes::ConnectionStatusChangedEvent());
|
||||||
|
|
||||||
SteamDatagramErrMsg errMsg;
|
SteamDatagramErrMsg errMsg;
|
||||||
if ( !GameNetworkingSockets_Init( nullptr, errMsg ) ) {
|
if ( !GameNetworkingSockets_Init( nullptr, errMsg ) ) {
|
||||||
@@ -62,9 +62,9 @@ bool ClientModule::onEvent(const Archimedes::Event& event) {
|
|||||||
|
|
||||||
unsigned int type = app->getEventType(event);
|
unsigned int type = app->getEventType(event);
|
||||||
|
|
||||||
if(eventsToHandle & CMEventEnum::ConnectionStatusChanged && type == app->getEventType(CMEvent::ConnectionStatusChangedEvent())) {
|
if(eventsToHandle & CMEventEnum::ConnectionStatusChanged && type == app->getEventType(Archimedes::ConnectionStatusChangedEvent())) {
|
||||||
|
|
||||||
CMEvent::ConnectionStatusChangedEvent& e = (CMEvent::ConnectionStatusChangedEvent&) event;
|
Archimedes::ConnectionStatusChangedEvent& e = (Archimedes::ConnectionStatusChangedEvent&) event;
|
||||||
|
|
||||||
switch(e.info->m_info.m_eState) {
|
switch(e.info->m_info.m_eState) {
|
||||||
|
|
||||||
@@ -114,9 +114,9 @@ bool ClientModule::onEvent(const Archimedes::Event& event) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if(eventsToHandle & CMEventEnum::DataRecieved && type == app->getEventType(CMEvent::DataRecievedEvent())) {
|
} else if(eventsToHandle & CMEventEnum::DataRecieved && type == app->getEventType(Archimedes::DataRecievedEvent())) {
|
||||||
return true;
|
return true;
|
||||||
} else if(eventsToHandle & CMEventEnum::DataSent && type == app->getEventType(CMEvent::DataSentEvent())) {
|
} else if(eventsToHandle & CMEventEnum::DataSent && type == app->getEventType(Archimedes::DataSentEvent())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +135,6 @@ void ClientModule::pollIncomingData() {
|
|||||||
assert( numMsgs == 1 && pIncomingMsg );
|
assert( numMsgs == 1 && pIncomingMsg );
|
||||||
assert( pIncomingMsg->m_conn == connection );
|
assert( pIncomingMsg->m_conn == connection );
|
||||||
|
|
||||||
app->emitEvent(new CMEvent::DataRecievedEvent(pIncomingMsg));
|
app->emitEvent(new Archimedes::DataRecievedEvent(pIncomingMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <steam/steamnetworkingsockets.h>
|
#include <steam/steamnetworkingsockets.h>
|
||||||
#include <steam/isteamnetworkingutils.h>
|
#include <steam/isteamnetworkingutils.h>
|
||||||
|
|
||||||
#include "ClientEvents.h"
|
#include "utils/Events/NetworkEvents.h"
|
||||||
|
|
||||||
class ClientModule : public Archimedes::Module {
|
class ClientModule : public Archimedes::Module {
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ class ClientModule : public Archimedes::Module {
|
|||||||
|
|
||||||
void sendReliable(const void* data, uint32 byteCount) {
|
void sendReliable(const void* data, uint32 byteCount) {
|
||||||
interface->SendMessageToConnection(connection, data, byteCount, k_nSteamNetworkingSend_Reliable, nullptr);
|
interface->SendMessageToConnection(connection, data, byteCount, k_nSteamNetworkingSend_Reliable, nullptr);
|
||||||
|
app->emitEvent(new Archimedes::DataSentEvent(data, byteCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRunning() const { return running; }
|
bool isRunning() const { return running; }
|
||||||
|
|||||||
@@ -84,62 +84,5 @@ void ImguiModule::onLoad() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ImguiModule::onEvent(const Archimedes::Event &event) {
|
bool ImguiModule::onEvent(const Archimedes::Event &event) {
|
||||||
/*
|
|
||||||
unsigned int type = app->getEventType(event);
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
|
|
||||||
if(type == app->getEventType(Archimedes::WindowResizeEvent())) {
|
|
||||||
Archimedes::WindowResizeEvent& e = (Archimedes::WindowResizeEvent&) event;
|
|
||||||
io.DisplaySize = ImVec2(e.width, e.height);
|
|
||||||
return true;
|
|
||||||
} else if(type == app->getEventType(Archimedes::WindowKeyPressedEvent())) {
|
|
||||||
if(io.WantCaptureKeyboard) {
|
|
||||||
Archimedes::WindowKeyPressedEvent& e = (Archimedes::WindowKeyPressedEvent&) event;
|
|
||||||
io.KeysData[e.key].Down = true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowKeyReleasedEvent())) {
|
|
||||||
if(io.WantCaptureKeyboard) {
|
|
||||||
Archimedes::WindowKeyPressedEvent& e = (Archimedes::WindowKeyPressedEvent&) event;
|
|
||||||
io.KeysData[e.key].Down = false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else if(type == app->getEventType(Archimedes::WindowMouseButtonPressedEvent())) {
|
|
||||||
if(io.WantCaptureMouse) {
|
|
||||||
Archimedes::WindowMouseButtonPressedEvent& e = (Archimedes::WindowMouseButtonPressedEvent&) event;
|
|
||||||
io.MouseDown[e.button] = true;
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
} else if(type == app->getEventType(Archimedes::WindowMouseButtonReleasedEvent())) {
|
|
||||||
if(io.WantCaptureMouse) {
|
|
||||||
Archimedes::WindowMouseButtonReleasedEvent& e = (Archimedes::WindowMouseButtonReleasedEvent&) event;
|
|
||||||
io.MouseDown[e.button] = false;
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
} else if(type == app->getEventType(Archimedes::WindowScrollEvent())) {
|
|
||||||
if(io.WantCaptureMouse) {
|
|
||||||
Archimedes::WindowScrollEvent& e = (Archimedes::WindowScrollEvent&) event;
|
|
||||||
io.MouseWheel += e.dy;
|
|
||||||
io.MouseWheelH += e.dx;
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
} else if(type == app->getEventType(Archimedes::WindowMouseMovedEvent())) {
|
|
||||||
if(io.WantSetMousePos) {
|
|
||||||
Archimedes::WindowMouseMovedEvent& e = (Archimedes::WindowMouseMovedEvent&) event;
|
|
||||||
io.MousePos = ImVec2(e.x, e.y);
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
WindowModule::~WindowModule() {
|
WindowModule::~WindowModule() {
|
||||||
if(app) {
|
if(app) {
|
||||||
app->unregisterEvent(Archimedes::WindowResizeEvent());
|
app->unregisterEvent(Archimedes::ResizeWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowCloseEvent());
|
app->unregisterEvent(Archimedes::CloseWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowKeyPressedEvent());
|
app->unregisterEvent(Archimedes::KeyPressedWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowKeyReleasedEvent());
|
app->unregisterEvent(Archimedes::KeyReleasedWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowMouseButtonPressedEvent());
|
app->unregisterEvent(Archimedes::MouseButtonPressedWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowMouseButtonReleasedEvent());
|
app->unregisterEvent(Archimedes::MouseButtonReleasedWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowScrollEvent());
|
app->unregisterEvent(Archimedes::ScrollWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowMouseMovedEvent());
|
app->unregisterEvent(Archimedes::MouseMovedWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowFocusedEvent());
|
app->unregisterEvent(Archimedes::FocusedWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowFocusLostEvent());
|
app->unregisterEvent(Archimedes::FocusLostWindowEvent());
|
||||||
app->unregisterEvent(Archimedes::WindowMovedEvent());
|
app->unregisterEvent(Archimedes::MovedWindowEvent());
|
||||||
|
|
||||||
if(renderer) {
|
if(renderer) {
|
||||||
renderer->getCmdList().clear();
|
renderer->getCmdList().clear();
|
||||||
@@ -26,17 +26,17 @@ WindowModule::~WindowModule() {
|
|||||||
|
|
||||||
void WindowModule::onLoad() {
|
void WindowModule::onLoad() {
|
||||||
|
|
||||||
app->registerEvent(Archimedes::WindowResizeEvent());
|
app->registerEvent(Archimedes::ResizeWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowCloseEvent());
|
app->registerEvent(Archimedes::CloseWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowKeyPressedEvent());
|
app->registerEvent(Archimedes::KeyPressedWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowKeyReleasedEvent());
|
app->registerEvent(Archimedes::KeyReleasedWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowMouseButtonPressedEvent());
|
app->registerEvent(Archimedes::MouseButtonPressedWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowMouseButtonReleasedEvent());
|
app->registerEvent(Archimedes::MouseButtonReleasedWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowScrollEvent());
|
app->registerEvent(Archimedes::ScrollWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowMouseMovedEvent());
|
app->registerEvent(Archimedes::MouseMovedWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowFocusedEvent());
|
app->registerEvent(Archimedes::FocusedWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowFocusLostEvent());
|
app->registerEvent(Archimedes::FocusLostWindowEvent());
|
||||||
app->registerEvent(Archimedes::WindowMovedEvent());
|
app->registerEvent(Archimedes::MovedWindowEvent());
|
||||||
|
|
||||||
renderer = new Archimedes::Renderer();
|
renderer = new Archimedes::Renderer();
|
||||||
}
|
}
|
||||||
@@ -51,37 +51,37 @@ bool WindowModule::onEvent(const Archimedes::Event& e) {
|
|||||||
|
|
||||||
unsigned int type = app->getEventType(e);
|
unsigned int type = app->getEventType(e);
|
||||||
|
|
||||||
if(type == app->getEventType(Archimedes::WindowResizeEvent())) {
|
if(type == app->getEventType(Archimedes::ResizeWindowEvent())) {
|
||||||
window->getSize(renderer->w, renderer->h);
|
window->getSize(renderer->w, renderer->h);
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowCloseEvent())) {
|
} else if(type == app->getEventType(Archimedes::CloseWindowEvent())) {
|
||||||
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowKeyPressedEvent())) {
|
} else if(type == app->getEventType(Archimedes::KeyPressedWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowKeyReleasedEvent())) {
|
} else if(type == app->getEventType(Archimedes::KeyReleasedWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowMouseButtonPressedEvent())) {
|
} else if(type == app->getEventType(Archimedes::MouseButtonPressedWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowMouseButtonReleasedEvent())) {
|
} else if(type == app->getEventType(Archimedes::MouseButtonReleasedWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowScrollEvent())) {
|
} else if(type == app->getEventType(Archimedes::ScrollWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowMouseMovedEvent())) {
|
} else if(type == app->getEventType(Archimedes::MouseMovedWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowFocusedEvent())) {
|
} else if(type == app->getEventType(Archimedes::FocusedWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowFocusLostEvent())) {
|
} else if(type == app->getEventType(Archimedes::FocusLostWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(type == app->getEventType(Archimedes::WindowMovedEvent())) {
|
} else if(type == app->getEventType(Archimedes::MovedWindowEvent())) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user