mousehandler.h

来自「这是整套横扫千军3D版游戏的源码」· C头文件 代码 · 共 98 行

H
98
字号
#ifndef MOUSEHANDLER_H
#define MOUSEHANDLER_H
// MouseHandler.h: interface for the CMouseHandler class.
//
//////////////////////////////////////////////////////////////////////

#include <string>
#include <vector>
#include <map>

#include "MouseCursor.h"

#define NUM_BUTTONS 5

class CInputReceiver;
class CCameraController;


class CMouseHandler  
{
public:
	void UpdateCursors();
	void HideMouse();
	void ShowMouse();
	void ToggleState();
	void WarpMouse(int x, int y);
	void Draw();
	void MouseRelease(int x,int y,int button);
	void MousePress(int x,int y,int button);
	void MouseMove(int x,int y);
	void MouseWheel(bool up);
	CMouseHandler();
	virtual ~CMouseHandler();

	int lastx;  
	int lasty;  
	bool hide;
	bool locked;
	bool invertMouse;
	float doubleClickTime;
	float scrollWheelSpeed;

	struct ButtonPress {
		bool pressed;
		bool chorded;
		int x;
		int y;
		float3 camPos;
		float3 dir;
		float time;
		float lastRelease;
		int movement;
	};

	ButtonPress buttons[NUM_BUTTONS + 1]; /* One-bottomed. */
	float3 dir;

	int activeButton;

	unsigned int cursorTex;
	std::string cursorText;
	std::string cursorTextRight;
	float cursorScale;	
	void DrawCursor(void);
	std::string GetCurrentTooltip(void);

	std::map<std::string, CMouseCursor*> cursorFileMap;
	std::map<std::string, CMouseCursor*> cursorCommandMap;
	//CMouseCursor *mc;

	int soundMultiselID;

	bool AssignMouseCursor(const std::string& cmdName,
	                       const std::string& fileName,
	                       CMouseCursor::HotSpot hotSpot,
	                       bool overwrite);
	bool ReplaceMouseCursor(const string& oldName,
	                        const string& newName,
	                        CMouseCursor::HotSpot hotSpot);
	void SafeDeleteCursor(CMouseCursor* cursor);

protected:
	void LoadCursors();

public:
	void EmptyMsgQueUpdate(void);

#ifdef DIRECT_CONTROL_ALLOWED
	/* Stores if the mouse was locked or not before going into direct control,
	   so we can restore it when we return to normal. */
	bool wasLocked;
#endif
};

extern CMouseHandler* mouse;

#endif /* MOUSEHANDLER_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?