mirror of
https://github.com/glest/glest-source.git
synced 2025-08-15 12:54:01 +02:00
Updates related to win32 camera zoom compile fixes
This commit is contained in:
@@ -59,7 +59,8 @@ class Chrono{
|
|||||||
private:
|
private:
|
||||||
int64 startCount;
|
int64 startCount;
|
||||||
int64 accumCount;
|
int64 accumCount;
|
||||||
int64 freq;
|
static int64 freq;
|
||||||
|
|
||||||
bool stopped;
|
bool stopped;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@@ -8,18 +8,20 @@
|
|||||||
// by the Free Software Foundation; either version 2 of the
|
// by the Free Software Foundation; either version 2 of the
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#ifndef _SHARED_PLATFORM_WINDOW_H_
|
#ifndef _SHARED_PLATFORM_WINDOW_H_
|
||||||
#define _SHARED_PLATFORM_WINDOW_H_
|
#define _SHARED_PLATFORM_WINDOW_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "vec.h"
|
||||||
#include "platform_menu.h"
|
#include "platform_menu.h"
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
using Shared::Graphics::Vec2i;
|
||||||
|
|
||||||
namespace Shared{ namespace Platform{
|
namespace Shared{ namespace Platform{
|
||||||
|
|
||||||
@@ -27,9 +29,16 @@ class Timer;
|
|||||||
class PlatformContextGl;
|
class PlatformContextGl;
|
||||||
|
|
||||||
enum MouseButton{
|
enum MouseButton{
|
||||||
|
mbUnknown,
|
||||||
mbLeft,
|
mbLeft,
|
||||||
|
mbCenter,
|
||||||
mbRight,
|
mbRight,
|
||||||
mbCenter
|
mbWheelUp,
|
||||||
|
mbWheelDown,
|
||||||
|
mbButtonX1,
|
||||||
|
mbButtonX2,
|
||||||
|
|
||||||
|
mbCount
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SizeState{
|
enum SizeState{
|
||||||
@@ -53,10 +62,28 @@ const int vkBack= VK_BACK;
|
|||||||
const int vkDelete= VK_DELETE;
|
const int vkDelete= VK_DELETE;
|
||||||
const int vkF1= VK_F1;
|
const int vkF1= VK_F1;
|
||||||
|
|
||||||
struct MouseState{
|
class MouseState {
|
||||||
bool leftMouse;
|
private:
|
||||||
bool rightMouse;
|
bool states[mbCount];
|
||||||
bool centerMouse;
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
MouseState() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
//MouseState(const MouseState &);
|
||||||
|
//MouseState &operator=(const MouseState &);
|
||||||
|
void clear() { memset(this, 0, sizeof(MouseState)); }
|
||||||
|
|
||||||
|
bool get(MouseButton b) const {
|
||||||
|
assert(b > 0 && b < mbCount);
|
||||||
|
return states[b];
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(MouseButton b, bool state) {
|
||||||
|
assert(b > 0 && b < mbCount);
|
||||||
|
states[b] = state;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum WindowStyle{
|
enum WindowStyle{
|
||||||
@@ -81,6 +108,19 @@ private:
|
|||||||
static int nextClassName;
|
static int nextClassName;
|
||||||
static WindowMap createdWindows;
|
static WindowMap createdWindows;
|
||||||
|
|
||||||
|
static unsigned int lastMouseEvent; /** for use in mouse hover calculations */
|
||||||
|
static MouseState mouseState;
|
||||||
|
static Vec2i mousePos;
|
||||||
|
|
||||||
|
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
||||||
|
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
|
||||||
|
|
||||||
|
static const MouseState &getMouseState() {return Window::mouseState;}
|
||||||
|
static void setMouseState(MouseButton b, bool state) {Window::mouseState.set(b, state);}
|
||||||
|
|
||||||
|
static const Vec2i &getMousePos() {return Window::mousePos;}
|
||||||
|
static void setMousePos(const Vec2i &mousePos) {Window::mousePos = mousePos;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WindowHandle handle;
|
WindowHandle handle;
|
||||||
WindowStyle windowStyle;
|
WindowStyle windowStyle;
|
||||||
@@ -152,6 +192,23 @@ private:
|
|||||||
static int getNextClassName();
|
static int getNextClassName();
|
||||||
void registerWindow(WNDPROC wndProc= NULL);
|
void registerWindow(WNDPROC wndProc= NULL);
|
||||||
void createWindow(LPVOID creationData= NULL);
|
void createWindow(LPVOID creationData= NULL);
|
||||||
|
void mouseyVent(int asdf, MouseButton mouseButton) {
|
||||||
|
const Vec2i &mousePos = getMousePos();
|
||||||
|
switch(asdf) {
|
||||||
|
case 0:
|
||||||
|
setMouseState(mouseButton, true);
|
||||||
|
eventMouseDown(mousePos.x, mousePos.y, mouseButton);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
setMouseState(mouseButton, false);
|
||||||
|
eventMouseUp(mousePos.x, mousePos.y, mouseButton);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
eventMouseDoubleClick(mousePos.x, mousePos.y, mouseButton);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -73,6 +73,8 @@ void PerformanceTimer::reset(){
|
|||||||
// class Chrono
|
// class Chrono
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
int64 Chrono::freq;
|
||||||
|
|
||||||
Chrono::Chrono(){
|
Chrono::Chrono(){
|
||||||
if(!QueryPerformanceFrequency((LARGE_INTEGER*) &freq)){
|
if(!QueryPerformanceFrequency((LARGE_INTEGER*) &freq)){
|
||||||
throw runtime_error("Performance counters not supported");
|
throw runtime_error("Performance counters not supported");
|
||||||
|
@@ -34,6 +34,10 @@ const DWORD Window::windowedResizeableStyle= WS_SIZEBOX | WS_CAPTION | WS_MINIMI
|
|||||||
int Window::nextClassName= 0;
|
int Window::nextClassName= 0;
|
||||||
Window::WindowMap Window::createdWindows;
|
Window::WindowMap Window::createdWindows;
|
||||||
|
|
||||||
|
unsigned int Window::lastMouseEvent = 0; /** for use in mouse hover calculations */
|
||||||
|
Vec2i Window::mousePos;
|
||||||
|
MouseState Window::mouseState;
|
||||||
|
|
||||||
// ===================== PUBLIC ========================
|
// ===================== PUBLIC ========================
|
||||||
|
|
||||||
Window::Window(){
|
Window::Window(){
|
||||||
@@ -45,6 +49,11 @@ Window::Window(){
|
|||||||
y= 0;
|
y= 0;
|
||||||
w= 100;
|
w= 100;
|
||||||
h= 100;
|
h= 100;
|
||||||
|
|
||||||
|
lastMouseEvent = 0;
|
||||||
|
mousePos = Vec2i(0);
|
||||||
|
mouseState.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window(){
|
Window::~Window(){
|
||||||
@@ -229,6 +238,230 @@ LRESULT CALLBACK Window::eventRouter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
|||||||
}
|
}
|
||||||
eventWindow = it->second;
|
eventWindow = it->second;
|
||||||
|
|
||||||
|
switch (msg) {
|
||||||
|
case WM_CREATE:
|
||||||
|
eventWindow->eventCreate();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
case WM_LBUTTONDBLCLK:
|
||||||
|
case WM_RBUTTONDOWN:
|
||||||
|
case WM_RBUTTONUP:
|
||||||
|
case WM_RBUTTONDBLCLK:
|
||||||
|
case WM_MBUTTONDOWN:
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
case WM_MBUTTONDBLCLK:
|
||||||
|
case WM_XBUTTONDOWN:
|
||||||
|
case WM_XBUTTONUP:
|
||||||
|
case WM_XBUTTONDBLCLK:
|
||||||
|
case WM_MOUSEWHEEL:
|
||||||
|
case WM_MOUSEHWHEEL:
|
||||||
|
case WM_MOUSEMOVE: {
|
||||||
|
RECT windowRect;
|
||||||
|
POINT mousePos;
|
||||||
|
|
||||||
|
GetWindowRect(eventWindow->getHandle(), &windowRect);
|
||||||
|
mousePos.x = LOWORD(lParam) - windowRect.left;
|
||||||
|
mousePos.y = HIWORD(lParam) - windowRect.top;
|
||||||
|
ClientToScreen(eventWindow->getHandle(), &mousePos);
|
||||||
|
|
||||||
|
eventWindow->setLastMouseEvent(Chrono::getCurMillis());
|
||||||
|
eventWindow->setMousePos(Vec2i(mousePos.x, mousePos.y));
|
||||||
|
switch(msg) {
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
eventWindow->mouseyVent(0, mbLeft);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
eventWindow->mouseyVent(1, mbLeft);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_LBUTTONDBLCLK:
|
||||||
|
eventWindow->mouseyVent(2, mbLeft);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_RBUTTONDOWN:
|
||||||
|
eventWindow->mouseyVent(0, mbRight);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_RBUTTONUP:
|
||||||
|
eventWindow->mouseyVent(1, mbRight);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_RBUTTONDBLCLK:
|
||||||
|
eventWindow->mouseyVent(2, mbRight);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_MBUTTONDOWN:
|
||||||
|
eventWindow->mouseyVent(0, mbCenter);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
eventWindow->mouseyVent(1, mbCenter);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_MBUTTONDBLCLK:
|
||||||
|
eventWindow->mouseyVent(2, mbCenter);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_XBUTTONDOWN:
|
||||||
|
// we only know about XBUTTON1 and XBUTTON2, but there may be more later, let
|
||||||
|
// DefWindowProc take these.
|
||||||
|
switch(HIWORD(wParam)) {
|
||||||
|
case XBUTTON1:
|
||||||
|
eventWindow->mouseyVent(0, mbButtonX1);
|
||||||
|
return TRUE;// don't ask me why it wants TRUE instead of zero like
|
||||||
|
// everything else
|
||||||
|
case XBUTTON2:
|
||||||
|
eventWindow->mouseyVent(0, mbButtonX2);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_XBUTTONUP:
|
||||||
|
switch(HIWORD(wParam)) {
|
||||||
|
case XBUTTON1:
|
||||||
|
eventWindow->mouseyVent(1, mbButtonX1);
|
||||||
|
return TRUE;// don't ask me why it wants TRUE instead of zero like
|
||||||
|
// everything else
|
||||||
|
case XBUTTON2:
|
||||||
|
eventWindow->mouseyVent(1, mbButtonX2);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_XBUTTONDBLCLK:
|
||||||
|
switch(HIWORD(wParam)) {
|
||||||
|
case XBUTTON1:
|
||||||
|
eventWindow->mouseyVent(2, mbButtonX1);
|
||||||
|
return TRUE;// don't ask me why it wants TRUE instead of zero like
|
||||||
|
// everything else
|
||||||
|
case XBUTTON2:
|
||||||
|
eventWindow->mouseyVent(2, mbButtonX2);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_MOUSEWHEEL:
|
||||||
|
eventWindow->eventMouseWheel(mousePos.x, mousePos.y, GET_WHEEL_DELTA_WPARAM(wParam));
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_MOUSEHWHEEL:
|
||||||
|
//eventWindow->eventMouseHWheel(mousePos.x, mousePos.y, GET_WHEEL_DELTA_WPARAM(wParam));
|
||||||
|
break; // not handled, send to DefWindowProc
|
||||||
|
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
eventWindow->setMouseState(mbLeft, wParam & MK_LBUTTON);
|
||||||
|
eventWindow->setMouseState(mbRight, wParam & MK_RBUTTON);
|
||||||
|
eventWindow->setMouseState(mbCenter, wParam & MK_MBUTTON);
|
||||||
|
eventWindow->setMouseState(mbButtonX1, wParam & MK_XBUTTON1);
|
||||||
|
eventWindow->setMouseState(mbButtonX2, wParam & MK_XBUTTON2);
|
||||||
|
eventWindow->eventMouseMove(mousePos.x, mousePos.y, &eventWindow->getMouseState());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_KEYDOWN: {
|
||||||
|
|
||||||
|
eventWindow->eventKeyDown(static_cast<char>(wParam));
|
||||||
|
break;
|
||||||
|
/*
|
||||||
|
Key key(Input::getKeyCode(wParam), static_cast<char>(wParam));
|
||||||
|
// bottom 16 bits is repeat acount, and I only care if it's zero or non-zero
|
||||||
|
bool isRepeat = (lParam << 16);
|
||||||
|
// I don't want repeats of modifier keys posting
|
||||||
|
if(!isRepeat || !key.isModifier()) {
|
||||||
|
eventWindow->input.updateKeyModifiers(key.getCode(), true);
|
||||||
|
eventWindow->eventKeyDown(key);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_KEYUP: {
|
||||||
|
|
||||||
|
eventWindow->eventKeyUp(static_cast<char>(wParam));
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Key key(Input::getKeyCode(wParam), static_cast<char>(wParam));
|
||||||
|
eventWindow->input.updateKeyModifiers(key.getCode(), false);
|
||||||
|
eventWindow->eventKeyUp(key);
|
||||||
|
break;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_CHAR:
|
||||||
|
eventWindow->eventKeyPress(static_cast<char>(wParam));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
if (HIWORD(wParam) == 0) {
|
||||||
|
eventWindow->eventMenu(LOWORD(wParam));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_ACTIVATE:
|
||||||
|
eventWindow->eventActivate(wParam != WA_INACTIVE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_MOVE: {
|
||||||
|
RECT rect;
|
||||||
|
|
||||||
|
GetWindowRect(eventWindow->getHandle(), &rect);
|
||||||
|
eventWindow->x = rect.left;
|
||||||
|
eventWindow->y = rect.top;
|
||||||
|
eventWindow->w = rect.right - rect.left;
|
||||||
|
eventWindow->h = rect.bottom - rect.top;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_SIZE: {
|
||||||
|
RECT rect;
|
||||||
|
|
||||||
|
GetWindowRect(eventWindow->getHandle(), &rect);
|
||||||
|
eventWindow->x = rect.left;
|
||||||
|
eventWindow->y = rect.top;
|
||||||
|
eventWindow->w = rect.right - rect.left;
|
||||||
|
eventWindow->h = rect.bottom - rect.top;
|
||||||
|
|
||||||
|
eventWindow->eventResize(static_cast<SizeState>(wParam));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_SIZING:
|
||||||
|
eventWindow->eventResize();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_PAINT:
|
||||||
|
eventWindow->eventPaint();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
eventWindow->eventClose();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
eventWindow->eventDestroy();
|
||||||
|
PostQuitMessage(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Window *eventWindow;
|
||||||
|
WindowMap::iterator it;
|
||||||
|
|
||||||
|
it= createdWindows.find(hwnd);
|
||||||
|
if(it==createdWindows.end()){
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
eventWindow= it->second;
|
||||||
|
|
||||||
POINT mousePos;
|
POINT mousePos;
|
||||||
RECT windowRect;
|
RECT windowRect;
|
||||||
|
|
||||||
@@ -353,6 +586,7 @@ LRESULT CALLBACK Window::eventRouter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
|||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int Window::getNextClassName(){
|
int Window::getNextClassName(){
|
||||||
|
Reference in New Issue
Block a user