#ifndef __ASSIST__
#define __ASSIST__

#pragma once

#include <map>
#include <string>
#include "ImgAssist.h"

namespace GameGlobal {
	enum {
		GW_SMALL,
		GW_LARGE,
		GW_FULL,
	}GAME_WND;
	extern int titleBarHeight;
	extern int frameWidth;

	extern TCHAR g_szCurModuleFileName[MAX_PATH];
	extern TCHAR g_szCurModuleDir[MAX_PATH];
	extern TCHAR g_szCurModulePath[MAX_PATH];
	extern TCHAR g_szFna[_MAX_FNAME];
	extern TCHAR g_szExt[_MAX_EXT];
	extern TCHAR g_szAssistConfig[MAX_PATH];
	extern std::string g_strAppdir;
	extern std::string g_strGameDir;
	extern TCHAR g_szGameApp[MAX_PATH];
	extern TCHAR g_szTempDir[MAX_PATH];
	extern int nGameWndType;
	extern int nAttackCount;

	void Init();
	std::string BuildImgPath(HWND hWnd, LPCTSTR lpName = NULL);
	VOID DebugLog(CHAR* pszStr, ...);
};

// 所有坐标,都是基于游戏窗口的相对坐标值;
// 游戏窗口:802*627
namespace GameAssist{
	// 控件信息;
	typedef struct __CTRL_INFO__ {
		DWORD			dwId;				// 控件id;
		std::string		strWinText;			// 控件文本;
		std::string		strClassName;		// 控件类名;
		HWND			hwnd;				// 控件句柄;
	}CtrlInfo, * pCtrlInfo;
	extern std::vector<CtrlInfo> g_vtCtrlInfo;

	typedef struct __GAMEWNDINFO__
	{
		unsigned long       lProcId;				// 进程ID;
		HWND                hWnd;					// 进程窗口句柄;
		std::string			strGameRoleName;		// 角色名称;
		std::string			strGameZoon;			// 区域;
		std::string			strGameServer;			// 服务站
		LPVOID				pAction;				// CAction类对象;
	}GameWndInfo, * pGameWndInfo;
	extern std::vector<GameWndInfo> g_vtGameWndInfo;
	void ClearGameInfo(std::vector<GameWndInfo> &vtGWnd);

	extern RECT g_rcRoleIdleHP ;
	extern RECT g_rcRoleIdleSP ;
	extern RECT g_rcSummonerIdleHP;
	extern RECT g_rcSummonerIdleSP;
	extern RECT g_rcRoleFightingHP;
	extern RECT g_rcRoleFightingSP;
	extern RECT g_rcSummonerFightingHP;
	extern RECT g_rcSummonerFightingSP;

	// 设置游戏窗口前置;
	void SetGameForeground(HWND hWnd);
	// 判断游戏窗口是否前置;
	bool IsGameForeground(HWND hWnd);
	// 将窗口坐标转化为屏幕坐标;
	BOOL GamePos2Screen(HWND hWnd, POINT &pt, bool bOffset = false);
	// 将屏幕坐标转化为游戏坐标;
	BOOL ScreenPos2Game(HWND hWnd, POINT& pt);
	// 鼠标移动;
	void MouseMove(POINT pt, bool bSetCurPos = true);
	// 鼠标单击;
	void MouseClick();
	void MouseClick(POINT pt);
	// 鼠标双击;
	void MouseDbClick();
	void MouseDbClick(POINT pt);
	// 鼠标右击;
	void MouseRClick();
	void MouseRClick(POINT pt);
	// 鼠标拖动;
	void MouseDrag(POINT pt);

	// 发送按键;
	void SendKey(DWORD key, BOOL bCtrl = FALSE, BOOL bAtl = FALSE, BOOL bShift = FALSE);

	// 获取剪切板字符串;
	CString GetClipboradString();
	// 设置剪切板字符串;
	BOOL SetClipboardString(LPCTSTR lpString);

	// 根据进程名获取进程pid;
	DWORD GetProcessId(LPCTSTR lpProcessName = _T("Game.exe"));
	// 获取所有指定进程名的进程pid;
	void GetAllProcessId(std::vector<DWORD>& vtPid, LPCTSTR lpProcessName = _T("Game.exe"));
	// 根据进程pid获取进程对应程序的窗口句柄;
	HWND GetProcessMainWnd(const DWORD& dwTagetProcessId, LPCTSTR lpTagetWndName = _T("大话水浒"));
	// 获取指定进程名的进程主窗口;
	HWND GetProcessMainWnd(LPCTSTR lpProcessName = _T("Game.exe"), LPCTSTR lpTagetWndName = _T("大话水浒"));
	// 获取所有指定进程名的进程主窗口;
	void GetAllProcessMainWnd(const std::vector<DWORD>& vtPid, std::vector<GameWndInfo>& vtGWnd, LPCTSTR lpTagetWndName = _T("大话水浒"));
	// 枚举指定进程的窗口;
	extern BOOL CALLBACK EnumChildWindowCallBack(HWND hWnd, LPARAM lParam);
};

#endif // __ASSIST__