#pragma once
#include "global.h"
#include "MyStructDef.h"
#include "CMyPicBox.h"
#include <afxcmn.h>
class CNewLayer : public CDialog
{
	DECLARE_DYNAMIC(CNewLayer)
	DECLARE_MESSAGE_MAP()
public:
	CNewLayer(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CNewLayer();
	// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_CMAPEDITOR_NEWLAYER };
#endif
	bool load = false;
	//地形组
	CString outLayerName;
	CString outPxa;
	//图层类型
	int outLayerType = 0;//0主层 1背景层 2循环背景层
	//图层属性
	float outOffx = 0.0f;
	float outOffy = 0.0f;
	float outMyFar = 0.0f;
	//循环背景层属性
	bool outLoopH = false;
	bool outLoopV = false;
	float outSpeedH = 0;
	float outSpeedV = 0;
	//主层属性
	int outMapW;
	int outMapH;
	//通用
	float outOrder = 100.0f;
	int outJumpFrame = 0;//帧数跳跃
	//颜色调整
	DWORD outColor = RGBA(0xff, 0xff, 0xff, 0xff);
	//光线
	float outDayLight = 1.0f;
	float outHSV[3] = { 0 };
	float outLightConst = 1.0f;
	//绘制剪切区域
	bool outEnableClipZone = false;
	MyRect outClipZone;
	//检查图层重名
	MyMapSet* pMapSet;
	//主窗口
	MyMapLayer* pLayer = nullptr;
	void* pDrawWnd = nullptr;
	void UpdateRGBACEdit();
	DWORD ColorString(const wchar_t* colorStr);
protected:
	void DoDataExchange(CDataExchange* pDX) override;
	BOOL OnInitDialog() override;
public:
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedRadioMainlayer();
	afx_msg void OnBnClickedRadioBklayer();
	afx_msg void OnBnClickedRadioLoopbklayer();
	afx_msg void OnCbnSelchangeComboPxa();
	afx_msg void OnEnChangeEditColorR();
	afx_msg void OnNMCustomdrawSliderColorR(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEnChangeEditColorG();
	afx_msg void OnNMCustomdrawSliderColorG(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEnChangeEditColorB();
	afx_msg void OnNMCustomdrawSliderColorB(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEnChangeEditColorA();
	afx_msg void OnNMCustomdrawSliderColorA(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEnChangeEditColorRgba();
	afx_msg void OnEnChangeEditDaylight();
	afx_msg void OnNMCustomdrawSliderDaylight(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEnChangeEditLightH();
	afx_msg void OnNMCustomdrawSliderLightH(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEnChangeEditLightS();
	afx_msg void OnNMCustomdrawSliderLightS(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEnChangeEditLightV();
	afx_msg void OnNMCustomdrawSliderLightV(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEnChangeEditLightConst();
	afx_msg void OnNMCustomdrawSliderLightConst(NMHDR* pNMHDR, LRESULT* pResult);
private:
	//控件
	//地形组
	CEdit edit_layerName;//图层名
	CComboBox combo_pxa;//地形组名
	//图层类型
	CButton radio_mainLayer;//主层
	CButton radio_bkLayer;//背景层
	CButton radio_loopBkLayer;//循环背景层
	//图层属性
	CStatic* static_offx;
	CStatic* static_offy;
	CEdit edit_offx;
	CEdit edit_offy;
	CStatic* static_far;
	CEdit edit_far;
	//循环背景层属性
	CButton check_loopH;
	CButton check_loopV;
	CStatic* static_speed;
	CStatic* static_speedX;
	CEdit edit_speedH;
	CEdit edit_speedV;
	//主层属性
	CStatic* static_mapSize;
	CStatic* static_mapSizeX;
	CEdit edit_mapW;
	CEdit edit_mapH;
	//通用
	CEdit edit_order;
	CEdit edit_jumpFrame;
	//颜色调整
	CEdit edit_color_r;
	CSliderCtrl slider_color_r;
	CEdit edit_color_g;
	CSliderCtrl slider_color_g;
	CEdit edit_color_b;
	CSliderCtrl slider_color_b;
	CEdit edit_color_a;
	CSliderCtrl slider_color_a;
	CEdit edit_color_rgba;
	//光线
	CEdit edit_dayLight;
	CSliderCtrl slider_dayLight;
	CEdit edit_light_h;
	CSliderCtrl slider_light_h;
	CEdit edit_light_s;
	CSliderCtrl slider_light_s;
	CEdit edit_light_v;
	CSliderCtrl slider_light_v;
	CEdit edit_light_const;
	CSliderCtrl slider_light_const;
	//其他
	CStatic* static_png;
	//绘制剪切区域
	CButton chech_clipZone;
	CEdit edit_clipUp;
	CEdit edit_clipDown;
	CEdit edit_clipLeft;
	CEdit edit_clipRight;
	//子窗口
	CMyPicBox picbox;
	bool inSingleRGBAEdit = false;
	bool inRGBAEdit = false;
};

