| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 | using System;using System.Collections.Generic;using UnityEngine;using wf;public class ColorPaletteUIManager : MonoBehaviour{	public int hue	{		get		{			return (int)System.Math.Round((double)(this.sliderHue.value * 255f), MidpointRounding.AwayFromZero);		}		set		{			List<EventDelegate> onChange = this.sliderHue.onChange;			this.sliderHue.onChange = null;			value = wf.Math.RoundMinMax(value, 0, 255);			this.sliderHue.value = (float)System.Math.Round((double)((float)value / 255f), 2, MidpointRounding.AwayFromZero);			this.sliderHue.onChange = onChange;			UTY.ConvertColorHue(this.hue, this.byteArrayPickerGray, ref this.tmpTxt2dColoField);		}	}	public int chroma	{		get		{			return (int)System.Math.Round((double)(this.sliderChroma.value * 255f), MidpointRounding.AwayFromZero);		}		set		{			List<EventDelegate> onChange = this.sliderChroma.onChange;			this.sliderChroma.onChange = null;			value = wf.Math.RoundMinMax(value, 0, 255);			this.sliderChroma.value = (float)System.Math.Round((double)((float)value / 255f), 2, MidpointRounding.AwayFromZero);			this.sliderChroma.onChange = onChange;			this.labelChroma.text = this.chroma.ToString();			this.UpdatePickerPosition();		}	}	public int brightness	{		get		{			return (int)System.Math.Round((double)(this.sliderBrightness.value * 510f), MidpointRounding.AwayFromZero);		}		set		{			List<EventDelegate> onChange = this.sliderBrightness.onChange;			this.sliderBrightness.onChange = null;			value = wf.Math.RoundMinMax(value, 0, 510);			this.sliderBrightness.value = (float)System.Math.Round((double)((float)value / 510f), 2, MidpointRounding.AwayFromZero);			this.sliderBrightness.onChange = onChange;			this.labelBrightness.text = this.brightness.ToString();			this.UpdatePickerPosition();		}	}	public int contrast	{		get		{			return (int)System.Math.Round((double)(this.sliderContrast.value * 200f), MidpointRounding.AwayFromZero);		}		set		{			List<EventDelegate> onChange = this.sliderContrast.onChange;			this.sliderContrast.onChange = null;			value = wf.Math.RoundMinMax(value, 0, 200);			this.sliderContrast.value = (float)System.Math.Round((double)((float)value / 200f), 2, MidpointRounding.AwayFromZero);			this.sliderContrast.onChange = onChange;			this.labelContrast.text = this.contrast.ToString();		}	}	public int shadowRate	{		get		{			return (int)System.Math.Round((double)(this.sliderShadowRate.value * 255f), MidpointRounding.AwayFromZero);		}		set		{			List<EventDelegate> onChange = this.sliderShadowRate.onChange;			this.sliderShadowRate.onChange = null;			value = wf.Math.RoundMinMax(value, 0, 255);			this.sliderShadowRate.value = (float)System.Math.Round((double)((float)value / 255f), 2, MidpointRounding.AwayFromZero);			this.sliderShadowRate.onChange = onChange;			this.labelShadowRate.text = this.shadowRate.ToString();		}	}	public bool visibleShadowRate	{		get		{			return this.shadowRateObject.activeSelf;		}		set		{			this.shadowRateObject.SetActive(value);		}	}	public bool visible	{		get		{			return base.gameObject.activeSelf;		}		set		{			base.gameObject.SetActive(value);		}	}	private void Awake()	{		this.shadowRateObject = UTY.GetChildObject(base.gameObject, "ColorAdjustment/ShadowRate", false);		this.sliderHue = UTY.GetChildObject(base.gameObject, "PickerPalette/HueSlider", false).GetComponent<UISlider>();		EventDelegate.Add(this.sliderHue.onChange, new EventDelegate.Callback(this.OnChangeValueSlider));		this.sliderChroma = UTY.GetChildObject(base.gameObject, "ColorAdjustment/Saturation/SatSlider", false).GetComponent<UISlider>();		EventDelegate.Add(this.sliderChroma.onChange, new EventDelegate.Callback(this.OnChangeValueSlider));		this.sliderBrightness = UTY.GetChildObject(base.gameObject, "ColorAdjustment/Brightness/BriSlider", false).GetComponent<UISlider>();		EventDelegate.Add(this.sliderBrightness.onChange, new EventDelegate.Callback(this.OnChangeValueSlider));		this.sliderContrast = UTY.GetChildObject(base.gameObject, "ColorAdjustment/Contrast/ContrastSlider", false).GetComponent<UISlider>();		EventDelegate.Add(this.sliderContrast.onChange, new EventDelegate.Callback(this.OnChangeValueSlider));		this.sliderShadowRate = UTY.GetChildObject(base.gameObject, "ColorAdjustment/ShadowRate/ShadowRateSlider", false).GetComponent<UISlider>();		EventDelegate.Add(this.sliderShadowRate.onChange, new EventDelegate.Callback(this.OnChangeValueSlider));		this.labelChroma = UTY.GetChildObject(base.gameObject, "ColorAdjustment/Saturation/Number", false).GetComponent<UILabel>();		this.labelBrightness = UTY.GetChildObject(base.gameObject, "ColorAdjustment/Brightness/Number", false).GetComponent<UILabel>();		this.labelContrast = UTY.GetChildObject(base.gameObject, "ColorAdjustment/Contrast/Number", false).GetComponent<UILabel>();		this.labelShadowRate = UTY.GetChildObject(base.gameObject, "ColorAdjustment/ShadowRate/Number", false).GetComponent<UILabel>();		this.m_palettePanel = UTY.GetChildObject(base.gameObject, "PickerPalette/PalettePanel", false).GetComponent<UIPanel>();		this.m_spSelector = UTY.GetChildObject(this.m_palettePanel.gameObject, "Palette/Selecter", false).GetComponent<UISprite>();		this.uiMainCamera = this.m_palettePanel.root.transform.Find("Camera").GetComponent<Camera>();		this.txtColorField = UTY.GetChildObject(this.m_palettePanel.gameObject, "Palette", false).GetComponent<UITexture>();		Texture2D texture2D = Resources.Load("SceneEdit/ColorPalette/Texture/cm3d2_ColorPalette_PickerGray 1") as Texture2D;		this.byteArrayPickerGray = UTY.GetPixelArray(texture2D);		this.tmpTxt2dColoField = new Texture2D(texture2D.width, texture2D.height, TextureFormat.RGBA32, false, true);		this.txtColorField.mainTexture = this.tmpTxt2dColoField;		UIEventTrigger component = this.m_palettePanel.GetComponent<UIEventTrigger>();		EventDelegate.Add(component.onPress, new EventDelegate.Callback(this.OnMouseDownPalettePanel));		EventDelegate.Add(component.onRelease, new EventDelegate.Callback(this.OnMouseUpPalettePanel));	}	private void Update()	{		if (this.ispickerDrag)		{			this.MovePalettePanelClickPos(UICamera.lastTouchPosition);		}	}	public void UpdatePickerPosition()	{		this.m_spSelector.transform.localPosition = new Vector3((float)this.txtColorField.width * this.sliderChroma.value, -((float)this.txtColorField.height * (1f - this.sliderBrightness.value)));	}	public void MovePalettePanelClickPos(Vector3 clickPos)	{		Vector3 position = this.uiMainCamera.ScreenToWorldPoint(clickPos);		Vector3 vector = this.m_palettePanel.transform.InverseTransformPoint(position);		Vector3 size = this.m_palettePanel.GetComponent<BoxCollider>().size;		Vector2 vector2 = new Vector2((float)this.m_spSelector.width, (float)this.m_spSelector.height);		int num = (int)(this.m_palettePanel.width / 2f + vector.x - vector2.x / 2f);		int num2 = (int)(this.m_palettePanel.height / 2f - vector.y - vector2.y / 2f);		num = wf.Math.RoundMinMax(num, 0, (int)size.x);		num2 = wf.Math.RoundMinMax(num2, 0, (int)size.y);		int num3 = this.SelectorPosToMainChromaNum(num);		int num4 = this.SelectorPosToMainBrightness(num2);		this.sliderChroma.value = (float)num3 / 255f;		this.sliderBrightness.value = (float)num4 / 510f;		this.labelChroma.text = num3.ToString();		this.labelBrightness.text = num4.ToString();		if (this.onChangeValue != null)		{			this.onChangeValue(this);		}	}	private void OnMouseDownPalettePanel()	{		int num = -1;		if (UICamera.currentTouchID == num)		{			if (!GameMain.Instance.VRMode)			{				this.MovePalettePanelClickPos(Input.mousePosition);			}			else			{				this.MovePalettePanelClickPos(GameMain.Instance.OvrMgr.SystemUICamera.GetOvrVirtualMouseCurrentSidePos());			}			this.ispickerDrag = true;		}	}	private void OnMouseUpPalettePanel()	{		this.ispickerDrag = false;	}	private void OnChangeValueSlider()	{		if (UIProgressBar.current == this.sliderHue)		{			UTY.ConvertColorHue(this.hue, this.byteArrayPickerGray, ref this.tmpTxt2dColoField);		}		else if (UIProgressBar.current == this.sliderChroma)		{			this.labelChroma.text = this.chroma.ToString();		}		else if (UIProgressBar.current == this.sliderBrightness)		{			this.labelBrightness.text = this.brightness.ToString();		}		else if (UIProgressBar.current == this.sliderContrast)		{			this.labelContrast.text = this.contrast.ToString();		}		else if (UIProgressBar.current == this.sliderShadowRate)		{			this.labelShadowRate.text = this.shadowRate.ToString();		}		this.UpdatePickerPosition();		if (this.onChangeValue != null)		{			this.onChangeValue(this);		}	}	private int SelectorPosToMainChromaNum(int texturePosX)	{		int num = texturePosX * 255 / this.txtColorField.width;		return wf.Math.RoundMinMax(num, 0, 255);	}	private int SelectorPosToMainBrightness(int texturePosY)	{		int num = (this.txtColorField.height - System.Math.Abs(texturePosY)) * 510 / this.txtColorField.height;		return wf.Math.RoundMinMax(num, 0, 510);	}	public Action<ColorPaletteUIManager> onChangeValue;	private GameObject shadowRateObject;	private UISlider sliderHue;	private UISlider sliderChroma;	private UISlider sliderBrightness;	private UISlider sliderContrast;	private UISlider sliderShadowRate;	private UILabel labelChroma;	private UILabel labelBrightness;	private UILabel labelContrast;	private UILabel labelShadowRate;	private UIPanel m_palettePanel;	private UISprite m_spSelector;	private Camera uiMainCamera;	private UITexture txtColorField;	private Texture2D tmpTxt2dColoField;	private byte[] byteArrayPickerGray;	private bool ispickerDrag;}
 |