#pragma once
#include "global.h"
#include "MyStructDef.h"
#include "CPxaEditor.h"
#include "CBrushPreview.h"
class CMapEditorBrush : public CDialog
{
	DECLARE_DYNAMIC(CMapEditorBrush)
	DECLARE_MESSAGE_MAP()
public:
	CMapEditorBrush(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CMapEditorBrush();
	// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_CMAPEDITOR_BRUSH };
#endif
	void* pParentEditor = nullptr;
	MyView* pDrawView = nullptr;
	CBrushPreview* pPreviewWnd = nullptr;
	MyView* GetMyView();
	void Draw();
	void Load(CString pxaName);//载入贴图png文件
	void ResetContext();
	void RefreshImage();
	void UpdateWindowTitle();//更新窗口标题
	//其他
	//用于墙壁纹理矫正窗口
	CEdit* pWallAdjust_Edit_w = nullptr;
	CEdit* pWallAdjust_Edit_h = nullptr;
	////////////////////热键//////////////////
	HACCEL hAccel = nullptr;//热键
	BOOL PreTranslateMessage(MSG* pMsg) override;
protected:
	void DoDataExchange(CDataExchange* pDX) override;
	BOOL OnInitDialog() override;
	void OnCancel() override;
	void OnEnterKey();//空函数 阻止回车键退出
public:
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	afx_msg void OnPaint();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
private:
	//渲染器
	MyDX11Renderer pRenderer;
	MyView view;
	//载入的贴图
	MyTextureAndSRV tas;
	MyTextureAndSRV tas_pxatype;
	MyTextureAndSRV tas_nullpxa;
	CString loadedPxaName;
	CString titleBaseName;
	//载入的数据
	CPXAEDITOR_DATATYPE_PXA pxaList;
	int tileW = 16, tileH = 16;
	void UpdateGrid();//更新网格
	void DrawPxa();
};

