Skip to content

Commit

Permalink
Clean up theme switching code, still could use some work
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowberryHN committed Oct 15, 2024
1 parent 5080fe0 commit 8a7fa81
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 24 deletions.
8 changes: 6 additions & 2 deletions Assembly-CSharp/PhoneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ private void CreateExtraSettings()
phoneButton = Instantiate(PhoneTextController.buttonprefab) as PhoneButton;
phoneButton.transform.position = position;
phoneButton.transform.parent = menu.transform;
phoneButton.textmesh.text = "Phone Theme";
phoneButton.textmesh.text = "Theme";
phoneButton.textmesh.characterSize = 0.7f;
phoneButton.button_name = "PhoneTheme";
phoneButton.text = string.Format("Phone Theme ({0})", PlayerPrefs.GetString("phone_theme", "white"));
phoneButton.text = string.Format("Theme ({0})", PlayerPrefs.GetString("phone_theme", "white"));
phoneButton.command = ".cycle_phone_theme";
phoneButton.screen = menu;
phoneButton.textmesh.alignment = TextAlignment.Right;
Expand Down Expand Up @@ -609,6 +609,10 @@ public void SetPhoneButtonHighlight(Color color)
public void SetPhoneTheme(string theme)
{
phonememory.SetTheme(theme);
foreach (var screen in bgscreens)
{
screen.OnThemeChange();
}
curscreen.OnThemeChange();
phoneviewcontroller.phoneviewbordertop.Find("Catco").GetComponent<PhoneLabel>().OnThemeChange();
PhoneOverlayMenu.instance.OnThemeChange();
Expand Down
9 changes: 9 additions & 0 deletions Assembly-CSharp/PhoneMailMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -865,4 +865,13 @@ protected override void UpdateButtonSelected()
}
}
}

public override void OnThemeChange()
{
base.OnThemeChange();
foreach (var button in mailbuttons)
{
button.OnThemeChange();
}
}
}
2 changes: 1 addition & 1 deletion Assembly-CSharp/PhoneMainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ public override bool ButtonMessage(PhoneButton button, string message)
PhoneMemory.CycleSelectedTheme();
PhoneController.instance.SetPhoneTheme(PhoneMemory.current_theme);
PlayerPrefs.SetString("phone_theme", PhoneMemory.current_theme);
button.text = string.Format("Phone Theme ({0})", PlayerPrefs.GetString("phone_theme", "white"));
button.text = string.Format("Theme ({0})", PlayerPrefs.GetString("phone_theme", "white"));
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Assembly-CSharp/PhoneMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ private void SetupColors()
text = new Color32(255, 255, 255),
selectable = new Color32(231, 80, 80),
selected = new Color32(255, 20, 20),
mail = Color.gray,
mail = new Color32(80, 80, 80),
dark = true
};
phoneColorPalette.particles = phoneColorPalette.selected;
Expand Down
6 changes: 6 additions & 0 deletions Assembly-CSharp/PhoneMissionsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,10 @@ private void HideFocusMarker()
focus_marker.renderer.enabled = false;
}
}

public override void OnLoad()
{
base.OnLoad();
OnThemeChange();
}
}
3 changes: 2 additions & 1 deletion Assembly-CSharp/PhoneScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public float deltatime

public virtual void Init()
{
OnThemeChange();
}

public virtual void OnLoad()
Expand Down Expand Up @@ -62,7 +63,7 @@ public virtual void UpdateScreen()

public virtual void OnThemeChange()
{
PhoneElement[] componentsInChildren = GetComponentsInChildren<PhoneElement>();
PhoneElement[] componentsInChildren = GetComponentsInChildren<PhoneElement>(true);
foreach (PhoneElement phoneElement in componentsInChildren)
{
phoneElement.OnThemeChange();
Expand Down
42 changes: 23 additions & 19 deletions Assembly-CSharp/PhoneTweetButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void Awake()
public override void OnLoad()
{
base.OnLoad();
OnThemeChange();
OnThemeChange(); // stupid hack
if (my_mail != null)
{
if (my_mail.color != Color.clear)
Expand Down Expand Up @@ -216,35 +216,39 @@ public override void OnUnSelected()
public override void OnThemeChange()
{
base.OnThemeChange();

if (name == "PhoneMissionButton(Clone)")
{
use_own_color = username_label.overrideColor = true;
username_label.color = username_label.textmesh.renderer.material.color = Color.black;
return;
}

back_normal_color = PhoneMemory.settings.mailColor;
back_selected_color = Color.Lerp(back_normal_color, Color.white, 0.6f);

if ((bool)background_box) background_box.renderer.material.color = back_normal_color;

if ((bool)username_label) username_label.OnThemeChange();
if ((bool)sender_label)
{
sender_label.overrideColor = false;
sender_label.OnThemeChange();
}
if ((bool)bodytext_label) bodytext_label.OnThemeChange();

if (name == "PhoneMailButton(Clone)")
{
back_normal_color = PhoneMemory.settings.mailColor;
back_selected_color = Color.Lerp(back_normal_color, Color.white, 0.6f);

if ((bool)background_box) background_box.renderer.material.color = back_normal_color;

if ((bool)sender_label) sender_label.OnThemeChange(); // TODO: this doesn't change, probably set to override
if ((bool)bodytext_label) bodytext_label.OnThemeChange();
}
if (name == "SingleTweet")
{
back_normal_color = PhoneMemory.settings.mailColor;
back_selected_color = Color.Lerp(back_normal_color, Color.white, 0.6f);

var titleBack = gameObject.transform.FindChild("TitleBack");
titleBack.gameObject.renderer.material.color = Color.Lerp(back_normal_color, back_normal_color * 2f, 0.2f);

var bodyBack = gameObject.transform.FindChild("BodyBack");
bodyBack.gameObject.renderer.material.color = Color.Lerp(back_normal_color, back_normal_color * 2f, 0.2f);

if ((bool)background_box) background_box.renderer.material.color = back_normal_color;

// subject line
if ((bool)username_label) username_label.OnThemeChange();
// sender line
if ((bool)sender_label) sender_label.OnThemeChange(); // TODO: this doesn't change, probably set to override
// mail body
if ((bool)bodytext_label) bodytext_label.OnThemeChange();
}
}
}
Binary file modified dist/zinethCE_Data/Managed/Assembly-CSharp.dll
Binary file not shown.

0 comments on commit 8a7fa81

Please sign in to comment.