Cleanup:
* Rename class CKeyHandler to KeyHandler (I don't want freaking MFC style classnames being prefixed with 'C') * Modify class KeyHandler to use std::bitset instead of an array of bools * Use forward declarations for pointers instead of including the entire header git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2200 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
6634aa66fa
commit
20d790a4fa
|
@ -350,7 +350,7 @@ SOURCE=.\initiallimitsdlg.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\keyhandler.h
|
||||
SOURCE=.\keyhandler.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
//#include "statsview.h"
|
||||
#include "tiletypes.h"
|
||||
#include "objectproperties.h"
|
||||
#include "keyhandler.hpp"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
|
@ -121,7 +122,7 @@ CBTEditView::CBTEditView()
|
|||
m_Selected = -1;
|
||||
m_DragMode = DM3D_NODRAG;
|
||||
// m_DirectMaths = NULL;
|
||||
m_KeyHandler = new CKeyHandler();
|
||||
m_KeyHandler = new KeyHandler();
|
||||
m_HeightsChanged = FALSE;
|
||||
|
||||
// m_InfoDialog = new CInfoDialog(this);
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "ddimage.h"
|
||||
#include "heightmap.h"
|
||||
#include "pcxhandler.h"
|
||||
#include "keyhandler.h"
|
||||
|
||||
//#include "InfoDialog.h"
|
||||
|
||||
|
@ -47,8 +46,9 @@ enum {
|
|||
DM3D_DRAGOBJECT,
|
||||
};
|
||||
|
||||
// Forward declaration for pointer
|
||||
// Forward declarations for pointers
|
||||
class CBTEditDoc;
|
||||
class KeyHandler;
|
||||
|
||||
class CBTEditView : public CScrollView
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ protected:
|
|||
DWORD m_MouseX;
|
||||
DWORD m_MouseY;
|
||||
DWORD m_DragMode;
|
||||
CKeyHandler *m_KeyHandler;
|
||||
KeyHandler *m_KeyHandler;
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CBTEditView)
|
||||
|
|
|
@ -28,32 +28,26 @@
|
|||
#include "typedefs.h"
|
||||
#include "debugprint.hpp"
|
||||
|
||||
#include "keyhandler.h"
|
||||
#include "keyhandler.hpp"
|
||||
|
||||
CKeyHandler::CKeyHandler(void)
|
||||
KeyHandler::KeyHandler()
|
||||
{
|
||||
InitKeyTable();
|
||||
}
|
||||
|
||||
void CKeyHandler::InitKeyTable(void)
|
||||
void KeyHandler::HandleKeyDown(unsigned int VKey)
|
||||
{
|
||||
for(int i = 0; i<KEYTABSIZE; i++) {
|
||||
m_KeyTable[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CKeyHandler::HandleKeyDown(UINT VKey)
|
||||
{
|
||||
if(VKey < KEYTABSIZE) {
|
||||
if(VKey < _KeyTable.size())
|
||||
{
|
||||
// DebugPrint("KeyDown %d\n",VKey);
|
||||
m_KeyTable[VKey] = 1;
|
||||
_KeyTable.set(VKey);
|
||||
}
|
||||
}
|
||||
|
||||
void CKeyHandler::HandleKeyUp(UINT VKey)
|
||||
void KeyHandler::HandleKeyUp(unsigned int VKey)
|
||||
{
|
||||
if(VKey < KEYTABSIZE) {
|
||||
m_KeyTable[VKey] = 0;
|
||||
if(VKey < _KeyTable.size())
|
||||
{
|
||||
_KeyTable.reset(VKey);
|
||||
// DebugPrint("KeyUp %d\n",VKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,27 @@
|
|||
$HeadURL$
|
||||
*/
|
||||
|
||||
#ifndef __INCLUDED_KEYHANDLER__
|
||||
#define __INCLUDED_KEYHANDLER__
|
||||
#ifndef __INCLUDE_KEYHANDLER_HPP__
|
||||
#define __INCLUDE_KEYHANDLER_HPP__
|
||||
|
||||
#define KEYTABSIZE 256
|
||||
#include <bitset>
|
||||
|
||||
class CKeyHandler {
|
||||
public:
|
||||
CKeyHandler(void);
|
||||
void InitKeyTable(void);
|
||||
void HandleKeyDown(UINT VKey);
|
||||
void HandleKeyUp(UINT VKey);
|
||||
BOOL GetKeyState(UINT VKey) { return m_KeyTable[VKey]; }
|
||||
protected:
|
||||
BOOL m_KeyTable[KEYTABSIZE];
|
||||
class KeyHandler
|
||||
{
|
||||
public:
|
||||
KeyHandler();
|
||||
|
||||
void HandleKeyDown(unsigned int VKey);
|
||||
void HandleKeyUp(unsigned int VKey);
|
||||
|
||||
inline bool GetKeyState(unsigned int VKey)
|
||||
{
|
||||
return _KeyTable.test(VKey);
|
||||
}
|
||||
|
||||
private:
|
||||
std::bitset<256> _KeyTable;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // __INCLUDE_KEYHANDLER_HPP__
|
|
@ -34,6 +34,7 @@
|
|||
#include "debugprint.hpp"
|
||||
//#include "DebugWin.h"
|
||||
#include "objectproperties.h"
|
||||
#include "keyhandler.hpp"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
|
@ -76,7 +77,7 @@ CWFView::CWFView()
|
|||
WFView = this;
|
||||
m_ViewIsInitialised=FALSE;
|
||||
m_DragMode=DM_NODRAG;
|
||||
m_KeyHandler = new CKeyHandler();
|
||||
m_KeyHandler = new KeyHandler();
|
||||
m_HeightsChanged = FALSE;
|
||||
// m_BrushDialog = new CBrushProp(this);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "ddimage.h"
|
||||
#include "heightmap.h"
|
||||
#include "pcxhandler.h"
|
||||
#include "keyhandler.h"
|
||||
//#include "brushprop.h"
|
||||
|
||||
#define SCREEN_XRES 640
|
||||
|
@ -46,6 +45,9 @@ enum {
|
|||
DM_DRAGOBJECT,
|
||||
};
|
||||
|
||||
// Forward declarations for pointers
|
||||
class KeyHandler;
|
||||
|
||||
class CWFView : public CScrollView
|
||||
{
|
||||
protected:
|
||||
|
@ -121,7 +123,7 @@ protected:
|
|||
DWORD m_DragMode;
|
||||
// CBrushProp *m_BrushDialog;
|
||||
|
||||
CKeyHandler *m_KeyHandler;
|
||||
KeyHandler *m_KeyHandler;
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CWFView)
|
||||
|
|
Loading…
Reference in New Issue