123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- public class WindowPartsInputSliderSet : MonoBehaviour
- {
- public void Awake()
- {
- for (int i = 0; i < this.SliderAndInput.Length; i++)
- {
- WindowPartsInputSliderSet.SliderAndInputSet target_obj = this.SliderAndInput[i];
- this.SliderAndInput[i].Object.onChangeValue.Add(delegate(float val)
- {
- WindowPartsInputSliderSet.SliderAndInputSet target_obj = target_obj;
- for (int k = 0; k < this.onChangeValue.Count; k++)
- {
- this.onChangeValue[k](target_obj, val);
- }
- });
- }
- this.btn_list_.Clear();
- if (this.ResetBtn != null)
- {
- this.btn_list_.Add(this.ResetBtn);
- EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnReset));
- EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
- eventDelegate.parameters[0].value = "リセット";
- this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
- }
- if (this.CopyBtn != null)
- {
- this.btn_list_.Add(this.CopyBtn);
- EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnCopy));
- EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
- eventDelegate.parameters[0].value = "コピー";
- this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
- }
- if (this.PasteBtn != null)
- {
- this.btn_list_.Add(this.PasteBtn);
- EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnPaste));
- EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
- eventDelegate.parameters[0].value = "ペースト";
- this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
- }
- for (int j = 0; j < this.btn_list_.Count; j++)
- {
- EventDelegate.Add(this.btn_list_[j].gameObject.GetComponent<UIEventTrigger>().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
- EventDelegate.Add(this.btn_list_[j].gameObject.GetComponent<UIEventTrigger>().onRelease, new EventDelegate.Callback(this.OnMouseHoverOut));
- }
- this.OnReset();
- }
- public void SetValue(string name, float value)
- {
- for (int i = 0; i < this.SliderAndInput.Length; i++)
- {
- if (!(this.SliderAndInput[i].Name != name))
- {
- this.SliderAndInput[i].Object.value = value;
- break;
- }
- }
- }
- public float GetValue(string name)
- {
- float result = 0f;
- for (int i = 0; i < this.SliderAndInput.Length; i++)
- {
- if (!(this.SliderAndInput[i].Name != name))
- {
- result = this.SliderAndInput[i].Object.value;
- break;
- }
- }
- return result;
- }
- public PhotoSliderAndInput GetSliderAndInput(string name)
- {
- for (int i = 0; i < this.SliderAndInput.Length; i++)
- {
- if (!(this.SliderAndInput[i].Name != name))
- {
- return this.SliderAndInput[i].Object;
- }
- }
- return null;
- }
- public void OnReset()
- {
- for (int i = 0; i < this.SliderAndInput.Length; i++)
- {
- this.SliderAndInput[i].Object.ResetValue();
- }
- }
- public void OnCopy()
- {
- StringWriter stringWriter = new StringWriter();
- for (int i = 0; i < this.SliderAndInput.Length; i++)
- {
- stringWriter.WriteLine(this.SliderAndInput[i].Object.value);
- }
- for (int j = 0; j < this.onCopyEvent.Count; j++)
- {
- this.onCopyEvent[j](stringWriter);
- }
- BasePhotoWindowManager.SetCopyData(this.copy_data_title, stringWriter.ToString());
- }
- public void OnPaste()
- {
- string copyData = BasePhotoWindowManager.GetCopyData(this.copy_data_title);
- if (string.IsNullOrEmpty(copyData))
- {
- return;
- }
- StringReader stringReader = new StringReader(copyData);
- for (int i = 0; i < this.SliderAndInput.Length; i++)
- {
- this.SliderAndInput[i].Object.value = float.Parse(stringReader.ReadLine());
- }
- for (int j = 0; j < this.onPasteEvent.Count; j++)
- {
- this.onPasteEvent[j](stringReader);
- }
- }
- public void OnMouseHoverIn(string text)
- {
- MouseExposition @object = MouseExposition.GetObject();
- @object.text = text;
- }
- public void OnMouseHoverOut()
- {
- MouseExposition @object = MouseExposition.GetObject();
- @object.text = string.Empty;
- }
- public new bool enabled
- {
- get
- {
- return this.SliderAndInput[0].Object.enabled;
- }
- set
- {
- for (int i = 0; i < this.SliderAndInput.Length; i++)
- {
- this.SliderAndInput[i].Object.enabled = value;
- }
- if (this.ResetBtn != null)
- {
- this.ResetBtn.isEnabled = value;
- }
- if (this.CopyBtn != null)
- {
- this.CopyBtn.isEnabled = value;
- }
- if (this.PasteBtn != null)
- {
- this.PasteBtn.isEnabled = value;
- }
- }
- }
- public bool visible
- {
- get
- {
- return base.gameObject.activeSelf;
- }
- set
- {
- base.gameObject.SetActive(value);
- }
- }
- public string copy_data_title
- {
- get
- {
- return this.CopyDataTitle;
- }
- }
- public WindowPartsInputSliderSet.SliderAndInputSet[] SliderAndInput;
- public UIButton ResetBtn;
- public UIButton CopyBtn;
- public UIButton PasteBtn;
- public string CopyDataTitle = "WindowPartsInputSliderSet";
- public List<Action<WindowPartsInputSliderSet.SliderAndInputSet, float>> onChangeValue = new List<Action<WindowPartsInputSliderSet.SliderAndInputSet, float>>();
- public List<Action<StringWriter>> onCopyEvent = new List<Action<StringWriter>>();
- public List<Action<StringReader>> onPasteEvent = new List<Action<StringReader>>();
- private List<UIButton> btn_list_ = new List<UIButton>();
- [Serializable]
- public class SliderAndInputSet
- {
- public string Name;
- public PhotoSliderAndInput Object;
- }
- }
|