Add igbg, mbg, bc, tc color options in settings menu
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsMenu : MonoBehaviour
|
||||
{
|
||||
public GameObject settingsMenu;
|
||||
public ColorPanel colorMenu;
|
||||
public Button toggleButton;
|
||||
|
||||
public Toggle setting1toggle;
|
||||
public Toggle setting2toggle;
|
||||
public Toggle setting3toggle;
|
||||
@@ -11,25 +16,34 @@ public class SettingsMenu : MonoBehaviour
|
||||
public Toggle setting5toggle;
|
||||
public Slider musicSlider;
|
||||
public Slider sfxSlider;
|
||||
public ColorPanel bgColorPanel;
|
||||
public Button bgPreviewModePanel;
|
||||
public GameObject settingsUI;
|
||||
|
||||
public Button switchColorTypeButton;
|
||||
public int colorType = 0;
|
||||
public bool colorCanSave = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
bgColorPanel.Init(BazookaManager.Instance.GetColorSettingBackground(), new Color(58 / 255f, 58 / 255f, 58 / 255f));
|
||||
bgColorPanel.OnColorChanged += color =>
|
||||
colorMenu.Init(Color.white, Color.white);
|
||||
colorMenu.OnColorChanged += color =>
|
||||
{
|
||||
BazookaManager.Instance.SetColorSettingBackground(color);
|
||||
if (!settingsUI.activeSelf) Camera.main.backgroundColor = new Color((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||
if (!colorCanSave) return;
|
||||
|
||||
if (colorType == 0) BazookaManager.Instance.SetColorSettingBackground(color);
|
||||
else if (colorType == 1) BazookaManager.Instance.SetColorSettingMenuBackground(color);
|
||||
else if (colorType == 2) BazookaManager.Instance.SetColorSettingButton(color);
|
||||
else if (colorType == 3) BazookaManager.Instance.SetColorSettingText(color);
|
||||
|
||||
foreach (CustomColorObject customColorObject in FindObjectsByType<CustomColorObject>(FindObjectsSortMode.None)) customColorObject.SetColor();
|
||||
};
|
||||
bgPreviewModePanel.onClick.AddListener(() =>
|
||||
toggleButton.onClick.AddListener(() =>
|
||||
{
|
||||
settingsUI.SetActive(!settingsUI.activeSelf);
|
||||
var value = BazookaManager.Instance.GetColorSettingBackground();
|
||||
Camera.main.backgroundColor = !settingsUI.activeSelf ? new Color((int)value[0] / 255f, (int)value[1] / 255f, (int)value[2] / 255f) : new Color(24 / 255f, 24 / 255f, 24 / 255f);
|
||||
bgPreviewModePanel.transform.GetChild(0).GetComponent<TMP_Text>().text = settingsUI.activeSelf ? "Preview On" : "Preview Off";
|
||||
settingsMenu.SetActive(!settingsMenu.activeSelf);
|
||||
colorMenu.gameObject.SetActive(!colorMenu.gameObject.activeSelf);
|
||||
toggleButton.transform.GetChild(0).GetComponent<TMP_Text>().text = settingsMenu.activeSelf ? "Colors" : "Settings";
|
||||
SwitchColorType(0);
|
||||
});
|
||||
switchColorTypeButton.onClick.AddListener(() => SwitchColorType());
|
||||
|
||||
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
||||
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
||||
@@ -74,4 +88,37 @@ public class SettingsMenu : MonoBehaviour
|
||||
});
|
||||
sfxSlider.onValueChanged.AddListener(value => BazookaManager.Instance.SetSettingSFXVolume(value));
|
||||
}
|
||||
|
||||
void SwitchColorType(int color = -1)
|
||||
{
|
||||
var type = color == -1 ? colorType : color;
|
||||
var text = colorMenu.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||
var colorToSet = new JArray(255, 255, 255);;
|
||||
switch (type)
|
||||
{
|
||||
case 0: //IGBGColor
|
||||
text.text = "Menu background color";
|
||||
colorType = 1;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||
break;
|
||||
case 1: //MBGColor
|
||||
text.text = "Button color";
|
||||
colorType = 2;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingButton();
|
||||
break;
|
||||
case 2: //BColor
|
||||
text.text = "Text color";
|
||||
colorType = 3;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingText();
|
||||
break;
|
||||
case 3: //TColor
|
||||
text.text = "In game background color";
|
||||
colorType = 0;
|
||||
colorToSet = BazookaManager.Instance.GetColorSettingBackground();
|
||||
break;
|
||||
}
|
||||
colorCanSave = false;
|
||||
colorMenu.SetColor(new Color((int)colorToSet[0] / 255f, (int)colorToSet[1] / 255f, (int)colorToSet[2] / 255f));
|
||||
colorCanSave = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user