|
@@ -7,18 +7,18 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
|
using static DragPointLight;
|
|
|
internal class LightsPane : BasePane
|
|
|
{
|
|
|
- private LightManager lightManager;
|
|
|
private static readonly string[] lightTypes = { "normal", "spot", "point" };
|
|
|
- private Dictionary<LightProp, Slider> LightSlider;
|
|
|
- private Dropdown lightDropdown;
|
|
|
- private Button addLightButton;
|
|
|
- private Button deleteLightButton;
|
|
|
- private Button clearLightsButton;
|
|
|
- private Button resetPropsButton;
|
|
|
- private Button resetPositionButton;
|
|
|
- private SelectionGrid lightTypeGrid;
|
|
|
- private Toggle colorToggle;
|
|
|
- private Toggle disableToggle;
|
|
|
+ private readonly LightManager lightManager;
|
|
|
+ private readonly Dictionary<LightProp, Slider> LightSlider;
|
|
|
+ private readonly Dropdown lightDropdown;
|
|
|
+ private readonly Button addLightButton;
|
|
|
+ private readonly Button deleteLightButton;
|
|
|
+ private readonly Button clearLightsButton;
|
|
|
+ private readonly Button resetPropsButton;
|
|
|
+ private readonly Button resetPositionButton;
|
|
|
+ private readonly SelectionGrid lightTypeGrid;
|
|
|
+ private readonly Toggle colorToggle;
|
|
|
+ private readonly Toggle disableToggle;
|
|
|
private MPSLightType currentLightType = MPSLightType.Normal;
|
|
|
private string lightHeader;
|
|
|
private static readonly Dictionary<LightProp, SliderProp> LightSliderProp =
|
|
@@ -34,7 +34,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
|
[LightProp.Green] = new SliderProp(0f, 1f, 1f),
|
|
|
[LightProp.Blue] = new SliderProp(0f, 1f, 1f),
|
|
|
};
|
|
|
- private static string[,] sliderNames = {
|
|
|
+ private static readonly string[,] sliderNames = {
|
|
|
{ "lights", "x" }, { "lights", "y" }, { "lights", "intensity" }, { "lights", "shadow" },
|
|
|
{ "lights", "spot" }, { "lights", "range" }, { "backgroundWindow", "red" }, { "backgroundWindow", "green" },
|
|
|
{ "backgroundWindow", "blue" }
|
|
@@ -42,7 +42,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
|
|
|
|
public LightsPane(LightManager lightManager)
|
|
|
{
|
|
|
- this.lightHeader = Translation.Get("lightsPane", "header");
|
|
|
+ lightHeader = Translation.Get("lightsPane", "header");
|
|
|
|
|
|
this.lightManager = lightManager;
|
|
|
this.lightManager.Rotate += (s, a) => UpdateRotation();
|
|
@@ -50,26 +50,26 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
|
this.lightManager.Select += (s, a) => UpdateCurrentLight();
|
|
|
this.lightManager.ListModified += (s, a) => UpdateList();
|
|
|
|
|
|
- this.lightTypeGrid = new SelectionGrid(Translation.GetArray("lightType", lightTypes));
|
|
|
- this.lightTypeGrid.ControlEvent += (s, a) => SetCurrentLightType();
|
|
|
+ lightTypeGrid = new SelectionGrid(Translation.GetArray("lightType", lightTypes));
|
|
|
+ lightTypeGrid.ControlEvent += (s, a) => SetCurrentLightType();
|
|
|
|
|
|
- this.lightDropdown = new Dropdown(new[] { "Main" });
|
|
|
- this.lightDropdown.SelectionChange += (s, a) => SetCurrentLight();
|
|
|
+ lightDropdown = new Dropdown(new[] { "Main" });
|
|
|
+ lightDropdown.SelectionChange += (s, a) => SetCurrentLight();
|
|
|
|
|
|
- this.addLightButton = new Button("+");
|
|
|
- this.addLightButton.ControlEvent += (s, a) => AddLight();
|
|
|
+ addLightButton = new Button("+");
|
|
|
+ addLightButton.ControlEvent += (s, a) => AddLight();
|
|
|
|
|
|
- this.deleteLightButton = new Button(Translation.Get("lightsPane", "delete"));
|
|
|
- this.deleteLightButton.ControlEvent += (s, a) => DeleteCurrentLight();
|
|
|
+ deleteLightButton = new Button(Translation.Get("lightsPane", "delete"));
|
|
|
+ deleteLightButton.ControlEvent += (s, a) => DeleteCurrentLight();
|
|
|
|
|
|
- this.disableToggle = new Toggle(Translation.Get("lightsPane", "disable"));
|
|
|
- this.disableToggle.ControlEvent += (s, a) => SetCurrentLightActive();
|
|
|
+ disableToggle = new Toggle(Translation.Get("lightsPane", "disable"));
|
|
|
+ disableToggle.ControlEvent += (s, a) => SetCurrentLightActive();
|
|
|
|
|
|
- this.clearLightsButton = new Button(Translation.Get("lightsPane", "clear"));
|
|
|
- this.clearLightsButton.ControlEvent += (s, a) => ClearLights();
|
|
|
+ clearLightsButton = new Button(Translation.Get("lightsPane", "clear"));
|
|
|
+ clearLightsButton.ControlEvent += (s, a) => ClearLights();
|
|
|
|
|
|
int numberOfLightProps = Enum.GetNames(typeof(LightProp)).Length;
|
|
|
- this.LightSlider = new Dictionary<LightProp, Slider>(numberOfLightProps);
|
|
|
+ LightSlider = new Dictionary<LightProp, Slider>(numberOfLightProps);
|
|
|
|
|
|
for (int i = 0; i < numberOfLightProps; i++)
|
|
|
{
|
|
@@ -87,93 +87,81 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
|
LightSlider[lightProp] = slider;
|
|
|
}
|
|
|
|
|
|
- this.colorToggle = new Toggle(Translation.Get("lightsPane", "colour"));
|
|
|
- this.colorToggle.ControlEvent += (s, a) => SetColourMode();
|
|
|
+ colorToggle = new Toggle(Translation.Get("lightsPane", "colour"));
|
|
|
+ colorToggle.ControlEvent += (s, a) => SetColourMode();
|
|
|
|
|
|
- this.resetPropsButton = new Button(Translation.Get("lightsPane", "resetProperties"));
|
|
|
- this.resetPropsButton.ControlEvent += (s, a) => ResetLightProps();
|
|
|
+ resetPropsButton = new Button(Translation.Get("lightsPane", "resetProperties"));
|
|
|
+ resetPropsButton.ControlEvent += (s, a) => ResetLightProps();
|
|
|
|
|
|
- this.resetPositionButton = new Button(Translation.Get("lightsPane", "resetPosition"));
|
|
|
- this.resetPositionButton.ControlEvent += (s, a) => ResetLightPosition();
|
|
|
+ resetPositionButton = new Button(Translation.Get("lightsPane", "resetPosition"));
|
|
|
+ resetPositionButton.ControlEvent += (s, a) => ResetLightPosition();
|
|
|
}
|
|
|
|
|
|
protected override void ReloadTranslation()
|
|
|
{
|
|
|
- this.updating = true;
|
|
|
- this.lightHeader = Translation.Get("lightsPane", "header");
|
|
|
- this.lightTypeGrid.SetItems(Translation.GetArray("lightType", lightTypes));
|
|
|
- this.lightDropdown.SetDropdownItems(this.lightManager.LightNameList);
|
|
|
- this.deleteLightButton.Label = Translation.Get("lightsPane", "delete");
|
|
|
- this.disableToggle.Label = Translation.Get("lightsPane", "disable");
|
|
|
- this.clearLightsButton.Label = Translation.Get("lightsPane", "clear");
|
|
|
+ updating = true;
|
|
|
+ lightHeader = Translation.Get("lightsPane", "header");
|
|
|
+ lightTypeGrid.SetItems(Translation.GetArray("lightType", lightTypes));
|
|
|
+ lightDropdown.SetDropdownItems(lightManager.LightNameList);
|
|
|
+ deleteLightButton.Label = Translation.Get("lightsPane", "delete");
|
|
|
+ disableToggle.Label = Translation.Get("lightsPane", "disable");
|
|
|
+ clearLightsButton.Label = Translation.Get("lightsPane", "clear");
|
|
|
for (LightProp lightProp = LightProp.LightRotX; lightProp <= LightProp.Blue; lightProp++)
|
|
|
{
|
|
|
LightSlider[lightProp].Label =
|
|
|
Translation.Get(sliderNames[(int)lightProp, 0], sliderNames[(int)lightProp, 1]);
|
|
|
}
|
|
|
- this.colorToggle.Label = Translation.Get("lightsPane", "colour");
|
|
|
- this.resetPropsButton.Label = Translation.Get("lightsPane", "resetProperties");
|
|
|
- this.resetPositionButton.Label = Translation.Get("lightsPane", "resetPosition");
|
|
|
- this.updating = false;
|
|
|
+ colorToggle.Label = Translation.Get("lightsPane", "colour");
|
|
|
+ resetPropsButton.Label = Translation.Get("lightsPane", "resetProperties");
|
|
|
+ resetPositionButton.Label = Translation.Get("lightsPane", "resetPosition");
|
|
|
+ updating = false;
|
|
|
}
|
|
|
|
|
|
private void SetColourMode()
|
|
|
{
|
|
|
- this.lightManager.SetColourModeActive(this.colorToggle.Value);
|
|
|
- this.UpdatePane();
|
|
|
+ lightManager.SetColourModeActive(colorToggle.Value);
|
|
|
+ UpdatePane();
|
|
|
}
|
|
|
|
|
|
private void ClearLights()
|
|
|
{
|
|
|
- this.lightManager.ClearLights();
|
|
|
- this.UpdatePane();
|
|
|
+ lightManager.ClearLights();
|
|
|
+ UpdatePane();
|
|
|
}
|
|
|
|
|
|
private void SetCurrentLight()
|
|
|
{
|
|
|
if (updating) return;
|
|
|
- this.lightManager.SelectedLightIndex = this.lightDropdown.SelectedItemIndex;
|
|
|
- this.UpdatePane();
|
|
|
+ lightManager.SelectedLightIndex = lightDropdown.SelectedItemIndex;
|
|
|
+ UpdatePane();
|
|
|
}
|
|
|
|
|
|
private void ResetLightProps()
|
|
|
{
|
|
|
- this.lightManager.CurrentLight.ResetLightProps();
|
|
|
- this.UpdatePane();
|
|
|
+ lightManager.CurrentLight.ResetLightProps();
|
|
|
+ UpdatePane();
|
|
|
}
|
|
|
|
|
|
- private void ResetLightPosition()
|
|
|
- {
|
|
|
- this.lightManager.CurrentLight.ResetLightPosition();
|
|
|
- }
|
|
|
+ private void ResetLightPosition() => lightManager.CurrentLight.ResetLightPosition();
|
|
|
|
|
|
- private void AddLight()
|
|
|
- {
|
|
|
- this.lightManager.AddLight();
|
|
|
- }
|
|
|
+ private void AddLight() => lightManager.AddLight();
|
|
|
|
|
|
- private void DeleteCurrentLight()
|
|
|
- {
|
|
|
- this.lightManager.DeleteActiveLight();
|
|
|
- }
|
|
|
+ private void DeleteCurrentLight() => lightManager.DeleteActiveLight();
|
|
|
|
|
|
- private void SetCurrentLightActive()
|
|
|
- {
|
|
|
- this.lightManager.CurrentLight.IsDisabled = this.disableToggle.Value;
|
|
|
- }
|
|
|
+ private void SetCurrentLightActive() => lightManager.CurrentLight.IsDisabled = disableToggle.Value;
|
|
|
|
|
|
private void SetCurrentLightType()
|
|
|
{
|
|
|
if (updating) return;
|
|
|
|
|
|
- currentLightType = (MPSLightType)this.lightTypeGrid.SelectedItemIndex;
|
|
|
+ currentLightType = (MPSLightType)lightTypeGrid.SelectedItemIndex;
|
|
|
|
|
|
DragPointLight currentLight = lightManager.CurrentLight;
|
|
|
|
|
|
currentLight.SetLightType(currentLightType);
|
|
|
|
|
|
- this.lightDropdown.SetDropdownItem(lightManager.ActiveLightName);
|
|
|
- this.UpdatePane();
|
|
|
+ lightDropdown.SetDropdownItem(lightManager.ActiveLightName);
|
|
|
+ UpdatePane();
|
|
|
}
|
|
|
|
|
|
private void SetLightProp(LightProp prop, float value)
|
|
@@ -192,81 +180,81 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
|
|
|
|
private void UpdateList()
|
|
|
{
|
|
|
- string[] newList = this.lightManager.LightNameList;
|
|
|
- this.lightDropdown.SetDropdownItems(newList, this.lightManager.SelectedLightIndex);
|
|
|
- this.UpdatePane();
|
|
|
+ string[] newList = lightManager.LightNameList;
|
|
|
+ lightDropdown.SetDropdownItems(newList, lightManager.SelectedLightIndex);
|
|
|
+ UpdatePane();
|
|
|
}
|
|
|
|
|
|
private void UpdateRotation()
|
|
|
{
|
|
|
- this.updating = true;
|
|
|
- LightProperty prop = this.lightManager.CurrentLight.CurrentLightProperty;
|
|
|
+ updating = true;
|
|
|
+ LightProperty prop = lightManager.CurrentLight.CurrentLightProperty;
|
|
|
LightSlider[LightProp.LightRotX].Value = prop.Rotation.eulerAngles.x;
|
|
|
LightSlider[LightProp.LightRotY].Value = prop.Rotation.eulerAngles.y;
|
|
|
- this.updating = false;
|
|
|
+ updating = false;
|
|
|
}
|
|
|
|
|
|
private void UpdateScale()
|
|
|
{
|
|
|
- this.updating = true;
|
|
|
- LightSlider[LightProp.SpotAngle].Value = this.lightManager.CurrentLight.CurrentLightProperty.SpotAngle;
|
|
|
- LightSlider[LightProp.Range].Value = this.lightManager.CurrentLight.CurrentLightProperty.Range;
|
|
|
- this.updating = false;
|
|
|
+ updating = true;
|
|
|
+ LightSlider[LightProp.SpotAngle].Value = lightManager.CurrentLight.CurrentLightProperty.SpotAngle;
|
|
|
+ LightSlider[LightProp.Range].Value = lightManager.CurrentLight.CurrentLightProperty.Range;
|
|
|
+ updating = false;
|
|
|
}
|
|
|
|
|
|
private void UpdateCurrentLight()
|
|
|
{
|
|
|
- this.updating = true;
|
|
|
- this.lightDropdown.SelectedItemIndex = this.lightManager.SelectedLightIndex;
|
|
|
- this.updating = false;
|
|
|
- this.UpdatePane();
|
|
|
+ updating = true;
|
|
|
+ lightDropdown.SelectedItemIndex = lightManager.SelectedLightIndex;
|
|
|
+ updating = false;
|
|
|
+ UpdatePane();
|
|
|
}
|
|
|
|
|
|
public override void UpdatePane()
|
|
|
{
|
|
|
- this.updating = true;
|
|
|
- DragPointLight currentLight = this.lightManager.CurrentLight;
|
|
|
- this.currentLightType = currentLight.SelectedLightType;
|
|
|
- this.lightTypeGrid.SelectedItemIndex = (int)this.currentLightType;
|
|
|
- this.disableToggle.Value = currentLight.IsDisabled;
|
|
|
- this.LightSlider[LightProp.LightRotX].Value = currentLight.Rotation.eulerAngles.x;
|
|
|
- this.LightSlider[LightProp.LightRotY].Value = currentLight.Rotation.eulerAngles.y;
|
|
|
- this.LightSlider[LightProp.Intensity].Value = currentLight.Intensity;
|
|
|
- this.LightSlider[LightProp.ShadowStrength].Value = currentLight.ShadowStrength;
|
|
|
- this.LightSlider[LightProp.Range].Value = currentLight.Range;
|
|
|
- this.LightSlider[LightProp.SpotAngle].Value = currentLight.SpotAngle;
|
|
|
- this.LightSlider[LightProp.Red].Value = currentLight.LightColour.r;
|
|
|
- this.LightSlider[LightProp.Green].Value = currentLight.LightColour.g;
|
|
|
- this.LightSlider[LightProp.Blue].Value = currentLight.LightColour.b;
|
|
|
- this.updating = false;
|
|
|
+ updating = true;
|
|
|
+ DragPointLight currentLight = lightManager.CurrentLight;
|
|
|
+ currentLightType = currentLight.SelectedLightType;
|
|
|
+ lightTypeGrid.SelectedItemIndex = (int)currentLightType;
|
|
|
+ disableToggle.Value = currentLight.IsDisabled;
|
|
|
+ LightSlider[LightProp.LightRotX].Value = currentLight.Rotation.eulerAngles.x;
|
|
|
+ LightSlider[LightProp.LightRotY].Value = currentLight.Rotation.eulerAngles.y;
|
|
|
+ LightSlider[LightProp.Intensity].Value = currentLight.Intensity;
|
|
|
+ LightSlider[LightProp.ShadowStrength].Value = currentLight.ShadowStrength;
|
|
|
+ LightSlider[LightProp.Range].Value = currentLight.Range;
|
|
|
+ LightSlider[LightProp.SpotAngle].Value = currentLight.SpotAngle;
|
|
|
+ LightSlider[LightProp.Red].Value = currentLight.LightColour.r;
|
|
|
+ LightSlider[LightProp.Green].Value = currentLight.LightColour.g;
|
|
|
+ LightSlider[LightProp.Blue].Value = currentLight.LightColour.b;
|
|
|
+ updating = false;
|
|
|
}
|
|
|
|
|
|
public override void Draw()
|
|
|
{
|
|
|
- bool isMain = this.lightManager.SelectedLightIndex == 0;
|
|
|
+ bool isMain = lightManager.SelectedLightIndex == 0;
|
|
|
|
|
|
MiscGUI.Header(lightHeader);
|
|
|
MiscGUI.WhiteLine();
|
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
- this.lightDropdown.Draw(GUILayout.Width(84));
|
|
|
- this.addLightButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
+ lightDropdown.Draw(GUILayout.Width(84));
|
|
|
+ addLightButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
|
|
|
GUILayout.FlexibleSpace();
|
|
|
GUI.enabled = !isMain;
|
|
|
- this.deleteLightButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
+ deleteLightButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
GUI.enabled = true;
|
|
|
- this.clearLightsButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
+ clearLightsButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
|
- bool isDisabled = !isMain && this.lightManager.CurrentLight.IsDisabled;
|
|
|
+ bool isDisabled = !isMain && lightManager.CurrentLight.IsDisabled;
|
|
|
GUILayout.BeginHorizontal();
|
|
|
GUI.enabled = !isDisabled;
|
|
|
- this.lightTypeGrid.Draw(GUILayout.ExpandWidth(false));
|
|
|
+ lightTypeGrid.Draw(GUILayout.ExpandWidth(false));
|
|
|
if (!isMain)
|
|
|
{
|
|
|
GUI.enabled = true;
|
|
|
- this.disableToggle.Draw();
|
|
|
+ disableToggle.Draw();
|
|
|
}
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
@@ -274,43 +262,43 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
|
|
|
|
if (currentLightType != MPSLightType.Point)
|
|
|
{
|
|
|
- this.LightSlider[LightProp.LightRotX].Draw();
|
|
|
- this.LightSlider[LightProp.LightRotY].Draw();
|
|
|
+ LightSlider[LightProp.LightRotX].Draw();
|
|
|
+ LightSlider[LightProp.LightRotY].Draw();
|
|
|
}
|
|
|
|
|
|
- this.LightSlider[LightProp.Intensity].Draw();
|
|
|
+ LightSlider[LightProp.Intensity].Draw();
|
|
|
|
|
|
if (currentLightType == MPSLightType.Normal)
|
|
|
{
|
|
|
- this.LightSlider[LightProp.ShadowStrength].Draw();
|
|
|
+ LightSlider[LightProp.ShadowStrength].Draw();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- this.LightSlider[LightProp.Range].Draw();
|
|
|
+ LightSlider[LightProp.Range].Draw();
|
|
|
}
|
|
|
|
|
|
if (currentLightType == MPSLightType.Spot)
|
|
|
{
|
|
|
- this.LightSlider[LightProp.SpotAngle].Draw();
|
|
|
+ LightSlider[LightProp.SpotAngle].Draw();
|
|
|
}
|
|
|
|
|
|
GUILayoutOption sliderWidth = MiscGUI.HalfSlider;
|
|
|
GUILayout.BeginHorizontal();
|
|
|
- this.LightSlider[LightProp.Red].Draw(sliderWidth);
|
|
|
- this.LightSlider[LightProp.Green].Draw(sliderWidth);
|
|
|
+ LightSlider[LightProp.Red].Draw(sliderWidth);
|
|
|
+ LightSlider[LightProp.Green].Draw(sliderWidth);
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
- this.LightSlider[LightProp.Blue].Draw(sliderWidth);
|
|
|
+ LightSlider[LightProp.Blue].Draw(sliderWidth);
|
|
|
if ((lightManager.SelectedLightIndex == 0) && (currentLightType == MPSLightType.Normal))
|
|
|
{
|
|
|
- this.colorToggle.Draw();
|
|
|
+ colorToggle.Draw();
|
|
|
}
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
- this.resetPropsButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
- this.resetPositionButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
+ resetPropsButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
+ resetPositionButton.Draw(GUILayout.ExpandWidth(false));
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
|
GUI.enabled = true;
|