123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System.Collections.Generic;
- using UnityEngine;
- namespace COM3D2.MeidoPhotoStudio.Plugin
- {
- internal class GravityControlPane : BasePane
- {
- private MeidoManager meidoManager;
- private Toggle hairToggle;
- private Toggle skirtToggle;
- private Toggle globalToggle;
- public GravityControlPane(MeidoManager meidoManager)
- {
- this.meidoManager = meidoManager;
- hairToggle = new Toggle(Translation.Get("gravityControlPane", "hairToggle"));
- hairToggle.ControlEvent += (s, a) => ToggleGravity(hairToggle.Value, skirt: false);
- skirtToggle = new Toggle(Translation.Get("gravityControlPane", "skirtToggle"));
- skirtToggle.ControlEvent += (s, a) => ToggleGravity(skirtToggle.Value, skirt: true);
- globalToggle = new Toggle(Translation.Get("gravityControlPane", "globalToggle"));
- globalToggle.ControlEvent += (s, a) => SetGlobalGravity(globalToggle.Value);
- }
- public override void Draw()
- {
- bool enabled = this.meidoManager.HasActiveMeido;
- GUI.enabled = enabled;
- Meido meido = this.meidoManager.ActiveMeido;
- GUILayout.BeginHorizontal();
- GUI.enabled = enabled && meido.HairGravityValid;
- hairToggle.Draw();
- GUI.enabled = enabled && meido.SkirtGravityValid;
- skirtToggle.Draw();
- GUI.enabled = true;
- GUILayout.EndHorizontal();
- globalToggle.Draw();
- GUI.enabled = true;
- }
- public override void UpdatePane()
- {
- if (!this.meidoManager.HasActiveMeido) return;
- Meido meido = meidoManager.ActiveMeido;
- this.updating = true;
- hairToggle.Value = meido.HairGravityActive;
- skirtToggle.Value = meido.SkirtGravityActive;
- this.updating = false;
- }
- private void ToggleGravity(bool value, bool skirt = false)
- {
- if (updating) return;
- if (this.meidoManager.GlobalGravity)
- {
- foreach (Meido meido in this.meidoManager.ActiveMeidoList)
- {
- if (skirt) meido.SkirtGravityActive = value;
- else meido.HairGravityActive = value;
- }
- }
- else
- {
- if (skirt) this.meidoManager.ActiveMeido.SkirtGravityActive = value;
- else this.meidoManager.ActiveMeido.HairGravityActive = value;
- }
- }
- private void SetGlobalGravity(bool value) => this.meidoManager.GlobalGravity = value;
- }
- }
|