Finish color changing UIS
This commit is contained in:
@@ -96,5 +96,6 @@ public class AccountHandler : MonoBehaviour
|
||||
accountRefreshLogin.gameObject.SetActive(true);
|
||||
break;
|
||||
}
|
||||
foreach (CustomColorObject customColorObject in FindObjectsByType<CustomColorObject>(FindObjectsSortMode.None)) customColorObject.SetColor();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ public class ChatroomMenuEntry : MonoBehaviour, IPointerEnterHandler, IPointerEx
|
||||
{
|
||||
bgImg = bgImgArg;
|
||||
optionsButton = optionsButtonArg;
|
||||
bgImg.color = new Color(50f / 255f, 50f / 255f, 50f / 255f);
|
||||
var color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
bgImg.color = new Color((((float)color[0]) + 26f) / 255f, (((float)color[1]) + 26f) / 255f, (((float)color[2]) + 26f) / 255f);
|
||||
optionsButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
@@ -72,13 +73,15 @@ public class ChatroomMenuEntry : MonoBehaviour, IPointerEnterHandler, IPointerEx
|
||||
private void Activate()
|
||||
{
|
||||
activeEntry = this;
|
||||
bgImg.color = new Color(60f / 255f, 60f / 255f, 60f / 255f);
|
||||
var color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
bgImg.color = new Color((((float)color[0]) + 36f) / 255f, (((float)color[1]) + 36f) / 255f, (((float)color[2]) + 36f) / 255f);
|
||||
optionsButton.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void Deactivate()
|
||||
{
|
||||
bgImg.color = new Color(50f / 255f, 50f / 255f, 50f / 255f);
|
||||
var color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
bgImg.color = new Color((((float)color[0]) + 26f) / 255f, (((float)color[1]) + 26f) / 255f, (((float)color[2]) + 26f) / 255f);
|
||||
optionsButton.gameObject.SetActive(false);
|
||||
if (activeEntry == this) activeEntry = null;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ public class ColorPanel : MonoBehaviour
|
||||
public Button resetButton;
|
||||
public Button switchModeButton;
|
||||
public event Action<JArray> OnColorChanged;
|
||||
public Color defaultColor;
|
||||
|
||||
public void Init(Color color, Color defaultColor)
|
||||
public void Init(Color color, Color defaultColorArg)
|
||||
{
|
||||
defaultColor = defaultColorArg;
|
||||
rSlider.value = color.r * 255f;
|
||||
gSlider.value = color.g * 255f;
|
||||
bSlider.value = color.b * 255f;
|
||||
@@ -64,10 +66,10 @@ public class ColorPanel : MonoBehaviour
|
||||
};
|
||||
}
|
||||
|
||||
public void Init(JArray color, Color defaultColor)
|
||||
public void Init(JArray color, Color defaultColorArg)
|
||||
{
|
||||
|
||||
Init(new Color((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f), defaultColor);
|
||||
Init(new Color((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f), defaultColorArg);
|
||||
}
|
||||
|
||||
void SyncAll(bool fromPicker = false)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -8,35 +7,78 @@ public class CustomColorObject : MonoBehaviour
|
||||
{
|
||||
public ColorObjectType type;
|
||||
public bool invert;
|
||||
public Color addMore;
|
||||
public bool reverseAdd;
|
||||
|
||||
Color ApplyModifiers(Color baseColor)
|
||||
{
|
||||
if (invert) baseColor = new(1f - baseColor.r, 1f - baseColor.g, 1f - baseColor.b);
|
||||
|
||||
if (reverseAdd)
|
||||
{
|
||||
baseColor.r = Mathf.Clamp01(baseColor.r - addMore.r);
|
||||
baseColor.g = Mathf.Clamp01(baseColor.g - addMore.g);
|
||||
baseColor.b = Mathf.Clamp01(baseColor.b - addMore.b);
|
||||
}
|
||||
else
|
||||
{
|
||||
baseColor.r = Mathf.Clamp01(baseColor.r + addMore.r);
|
||||
baseColor.g = Mathf.Clamp01(baseColor.g + addMore.g);
|
||||
baseColor.b = Mathf.Clamp01(baseColor.b + addMore.b);
|
||||
}
|
||||
|
||||
return baseColor;
|
||||
}
|
||||
|
||||
public void SetColor()
|
||||
{
|
||||
JArray color = null;
|
||||
Color colorType = Color.white;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ColorObjectType.InGameBackgroundColor:
|
||||
JArray color = BazookaManager.Instance.GetColorSettingBackground();
|
||||
Color colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
if (invert) colorType = new(1f - colorType.r, 1f - colorType.g, 1f - colorType.b);
|
||||
color = BazookaManager.Instance.GetColorSettingBackground();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
gameObject.GetComponent<Camera>().backgroundColor = colorType;
|
||||
break;
|
||||
case ColorObjectType.MenuBackgroundColor:
|
||||
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
if (invert) colorType = new(1f - colorType.r, 1f - colorType.g, 1f - colorType.b);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
gameObject.GetComponent<Camera>().backgroundColor = colorType;
|
||||
break;
|
||||
case ColorObjectType.MenuBackgroundColorImage:
|
||||
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
gameObject.GetComponent<Image>().color = colorType;
|
||||
break;
|
||||
case ColorObjectType.ButtonColor:
|
||||
color = BazookaManager.Instance.GetColorSettingButton();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
if (invert) colorType = new(1f - colorType.r, 1f - colorType.g, 1f - colorType.b);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
gameObject.GetComponent<Image>().color = colorType;
|
||||
break;
|
||||
case ColorObjectType.ButtonColorText:
|
||||
color = BazookaManager.Instance.GetColorSettingButton();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
gameObject.GetComponent<TMP_Text>().color = colorType;
|
||||
break;
|
||||
case ColorObjectType.TextColor:
|
||||
color = BazookaManager.Instance.GetColorSettingText();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
if (invert) colorType = new(1f - colorType.r, 1f - colorType.g, 1f - colorType.b);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
gameObject.GetComponent<TMP_Text>().color = colorType;
|
||||
break;
|
||||
case ColorObjectType.TextColorImage:
|
||||
color = BazookaManager.Instance.GetColorSettingText();
|
||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
colorType = ApplyModifiers(colorType);
|
||||
gameObject.GetComponent<Image>().color = colorType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ public class SettingsMenu : MonoBehaviour
|
||||
settingsMenu.SetActive(!settingsMenu.activeSelf);
|
||||
colorMenu.gameObject.SetActive(!colorMenu.gameObject.activeSelf);
|
||||
toggleButton.transform.GetChild(0).GetComponent<TMP_Text>().text = settingsMenu.activeSelf ? "Colors" : "Settings";
|
||||
SwitchColorType(0);
|
||||
SwitchColorType(3);
|
||||
foreach (CustomColorObject customColorObject in FindObjectsByType<CustomColorObject>(FindObjectsSortMode.None)) customColorObject.SetColor();
|
||||
});
|
||||
switchColorTypeButton.onClick.AddListener(() => SwitchColorType());
|
||||
|
||||
@@ -100,21 +101,25 @@ public class SettingsMenu : MonoBehaviour
|
||||
text.text = "Menu background color";
|
||||
colorType = 1;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
colorMenu.defaultColor = new(24f / 255f, 24f / 255f, 24f / 255f);
|
||||
break;
|
||||
case 1: //MBGColor
|
||||
text.text = "Button color";
|
||||
colorType = 2;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingButton();
|
||||
colorMenu.defaultColor = new(1f, 1f, 1f);
|
||||
break;
|
||||
case 2: //BColor
|
||||
text.text = "Text color";
|
||||
colorType = 3;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingText();
|
||||
colorMenu.defaultColor = new(1f, 1f, 1f);
|
||||
break;
|
||||
case 3: //TColor
|
||||
text.text = "In game background color";
|
||||
colorType = 0;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingBackground();
|
||||
colorMenu.defaultColor = new(58f / 255f, 58f / 255f, 58f / 255f);
|
||||
break;
|
||||
}
|
||||
colorCanSave = false;
|
||||
|
||||
@@ -2,6 +2,9 @@ public enum ColorObjectType
|
||||
{
|
||||
InGameBackgroundColor,
|
||||
MenuBackgroundColor,
|
||||
ButtonColor,
|
||||
ButtonColorText,
|
||||
TextColor,
|
||||
ButtonColor
|
||||
TextColorImage,
|
||||
MenuBackgroundColorImage,
|
||||
}
|
||||
Reference in New Issue
Block a user