consolodate NetworkEvents
This commit is contained in:
@@ -15,191 +15,191 @@ namespace Archimedes {
|
||||
std::function<void(Event*)> sendEvent;
|
||||
};
|
||||
|
||||
class WindowResizeEvent : public Event {
|
||||
class ResizeWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
class WindowCloseEvent : public Event {
|
||||
class CloseWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class WindowKeyPressedEvent : public Event {
|
||||
class KeyPressedWindowEvent : public Event {
|
||||
|
||||
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 repeat;
|
||||
};
|
||||
|
||||
class WindowKeyReleasedEvent : public Event {
|
||||
class KeyReleasedWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class WindowMouseButtonPressedEvent : public Event {
|
||||
class MouseButtonPressedWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class WindowMouseButtonReleasedEvent : public Event {
|
||||
class MouseButtonReleasedWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class WindowScrollEvent : public Event {
|
||||
class ScrollWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class WindowMouseMovedEvent : public Event {
|
||||
class MouseMovedWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class WindowFocusedEvent : public Event {
|
||||
class FocusedWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class WindowFocusLostEvent : public Event {
|
||||
class FocusLostWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class WindowMovedEvent : public Event {
|
||||
class MovedWindowEvent : public Event {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -43,13 +43,13 @@ namespace Archimedes {
|
||||
glfwSetWindowSizeCallback(w, [](GLFWwindow* window, int w, int h){
|
||||
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||
|
||||
d.sendEvent(new WindowResizeEvent(w, h));
|
||||
d.sendEvent(new ResizeWindowEvent(w, h));
|
||||
});
|
||||
|
||||
glfwSetWindowCloseCallback(w, [](GLFWwindow* 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){
|
||||
@@ -57,13 +57,13 @@ namespace Archimedes {
|
||||
|
||||
switch(action) {
|
||||
case GLFW_PRESS:
|
||||
d.sendEvent(new WindowKeyPressedEvent(key, 0));
|
||||
d.sendEvent(new KeyPressedWindowEvent(key, 0));
|
||||
break;
|
||||
case GLFW_RELEASE:
|
||||
d.sendEvent(new WindowKeyReleasedEvent(key));
|
||||
d.sendEvent(new KeyReleasedWindowEvent(key));
|
||||
break;
|
||||
case GLFW_REPEAT:
|
||||
d.sendEvent(new WindowKeyPressedEvent(key, 1));
|
||||
d.sendEvent(new KeyPressedWindowEvent(key, 1));
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -73,10 +73,10 @@ namespace Archimedes {
|
||||
|
||||
switch(action) {
|
||||
case GLFW_PRESS:
|
||||
d.sendEvent(new WindowMouseButtonPressedEvent(button));
|
||||
d.sendEvent(new MouseButtonPressedWindowEvent(button));
|
||||
break;
|
||||
case GLFW_RELEASE:
|
||||
d.sendEvent(new WindowMouseButtonReleasedEvent(button));
|
||||
d.sendEvent(new MouseButtonReleasedWindowEvent(button));
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -84,13 +84,13 @@ namespace Archimedes {
|
||||
glfwSetScrollCallback(w, [](GLFWwindow* window, double dx, double dy){
|
||||
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){
|
||||
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
|
||||
|
||||
d.sendEvent(new WindowMouseMovedEvent(dx, dy));
|
||||
d.sendEvent(new MouseMovedWindowEvent(dx, dy));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user