Skip to content

Commit

Permalink
Reused cached label, added one for dropdown. Fixed issue with setting…
Browse files Browse the repository at this point in the history
… Speed limits theme in main menu
  • Loading branch information
krzychu124 committed Jun 2, 2022
1 parent b6c17ac commit c6042f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion TLM/TLM/State/OptionsTabs/GeneralTab_LocalisationGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ public static class GeneralTab_LocalisationGroup {
}

private static void OnRoadSignsThemeChanged(int newThemeIndex) {
if (!Options.IsGameLoaded()) {
if (!Options.IsGameLoaded(false)) {
// update global config only, skip reloading theme
var selectedTheme = RoadSignThemeManager.Instance.ThemeNames[newThemeIndex];
Main config = GlobalConfig.Instance.Main;
config.RoadSignTheme = selectedTheme;
GlobalConfig.WriteConfig();
return;
}

Expand Down
4 changes: 3 additions & 1 deletion TLM/TLM/UI/Helpers/DropDownOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace TrafficManager.UI.Helpers {

public class DropDownOption<TEnum> : SerializableUIOptionBase<TEnum, UIDropDown, DropDownOption<TEnum>>
where TEnum : struct, Enum, IConvertible {
private UILabel _dropdownLabel;

public DropDownOption(string fieldName, Options.PersistTo scope = Options.PersistTo.Savegame)
: base(fieldName, scope) { }
Expand Down Expand Up @@ -66,6 +67,7 @@ public DropDownOption(string fieldName, Options.PersistTo scope = Options.Persis
eventCallback: InvokeOnValueChanged) as UIDropDown;

_ui.width = 350;
_dropdownLabel = _ui.parent.Find<UILabel>("Label");

UpdateTooltip();
UpdateReadOnly();
Expand Down Expand Up @@ -97,7 +99,7 @@ public DropDownOption(string fieldName, Options.PersistTo scope = Options.Persis
_ui.isInteractive = !readOnly;
_ui.opacity = readOnly ? 0.3f : 1f;
// parent is UIPanel containing text label and dropdown
_ui.parent.Find<UILabel>("Label").opacity = readOnly ? 0.3f : 1f;
_dropdownLabel.opacity = readOnly ? 0.3f : 1f;
}
}
}
2 changes: 1 addition & 1 deletion TLM/TLM/UI/Helpers/SliderOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public byte FloatToByte(float val)
_ui.thumbObject.isInteractive = !readOnly;
_ui.thumbObject.opacity = readOnly ? 0.3f : 1f;
// parent is UIPanel containing text label and slider
_ui.parent.Find<UILabel>("Label").opacity = readOnly ? 0.3f : 1f;
_sliderLabel.opacity = readOnly ? 0.3f : 1f;
}
}
}

0 comments on commit c6042f2

Please sign in to comment.