Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Fix various things in the User Interface (QMBtns)
Browse files Browse the repository at this point in the history
- Fixed Language not updating the button's text/tooltip properly
- Fixed to update RiskyFunc status on ReMenuCategory Title Header

Updated ReMod.Core references
  • Loading branch information
MintLily committed Jun 26, 2022
1 parent 09fa9d4 commit bd0a43a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 21 deletions.
108 changes: 88 additions & 20 deletions NewUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,39 @@ private static void BuildUi() {
ReTabButton.Create("TPVRTab", "Open the TeleporterVR Menu", "TeleporterVR", ResourceManager.Tab);

_mainCat = _teleportVr.AddCategory("TPVR Actions", false);
_tpKeyboard = _mainCat.AddButton(Language.TPtoName_Text, $"Open keyboard to {Language.TPtoName_Text}", OpenKeyboardForPlayerTP, ResourceManager.keyboard);
_tpCoord = _mainCat.AddButton(Language.TPtoCoord_Text, $"Open keyboard to {Language.TPtoCoord_Text}", OpenKeyboardForCoordTP, ResourceManager.mapmarker);
_handChange = _mainCat.AddToggle(Language.preferedHanded_Text_ON, $"Toggle {Language.preferedHanded_Text_ON} or {Language.preferedHanded_Text_OFF}", b => {
MelonPreferences.GetEntry<bool>(Main.melon.Identifier, Main.PreferRightHand.Identifier).Value = b;
});

_tpKeyboard = _mainCat.AddButton(Language.TpToNameText, Language.TpToNameTooltip, OpenKeyboardForPlayerTP, ResourceManager.keyboard);

_tpCoord = _mainCat.AddButton(Language.TpToCoordText, Language.TpToCoordTooltip, OpenKeyboardForCoordTP, ResourceManager.mapmarker);

_handChange = _mainCat.AddToggle(Language.PreferedHandedTextOn, Language.PerferedHandTooltip, b =>
MelonPreferences.GetEntry<bool>(Main.Melon.Identifier, Main.PreferRightHand.Identifier).Value = b);
_handChange.Toggle(Main.PreferRightHand.Value);
_tpAction = _mainCat.AddToggle(Language.theWord_Teleport, $"Activate {Language.theWord_Teleport}", b => {

_tpAction = _mainCat.AddToggle(Language.TheWordTeleport, $"Activate {Language.TheWordTeleport}", b => {
if (!CheckWorldAllowed.RiskyFunctionAllowed) return;
VRUtils.active = !VRUtils.active;
TPLocationIndicator.Toggle();
});
//TPAction.Toggle(VRUtils.active);

_waypointsCat = _teleportVr.AddCategory("Waypoints");
_wp1 = _waypointsCat.AddButton(Language.SavePos, $"{Language.SavePos} 1", () => { SaveAction(1); },
_wp1 = _waypointsCat.AddButton(Language.SavePos, Language.SavePosToolTip, () => SaveAction(1),
ResourceManager.one);
_wp2 = _waypointsCat.AddButton(Language.SavePos, $"{Language.SavePos} 2", () => { SaveAction(2); },
_wp2 = _waypointsCat.AddButton(Language.SavePos, Language.SavePosToolTip, () => SaveAction(2),
ResourceManager.two);
_wp3 = _waypointsCat.AddButton(Language.SavePos, $"{Language.SavePos} 3", () => { SaveAction(3); },
_wp3 = _waypointsCat.AddButton(Language.SavePos, Language.SavePosToolTip, () => SaveAction(3),
ResourceManager.three);
_wp4 = _waypointsCat.AddButton(Language.SavePos, $"{Language.SavePos} 4", () => { SaveAction(4); },
_wp4 = _waypointsCat.AddButton(Language.SavePos, Language.SavePosToolTip, () => SaveAction(4),
ResourceManager.four);

_wpl1 = _waypointsCat.AddButton(Language.LoadPos, $"{Language.LoadPos} 1", () => { LoadAction(1); },
_wpl1 = _waypointsCat.AddButton(Language.LoadPos, Language.LoadPosTooltip, () => LoadAction(1),
ResourceManager.one);
_wpl2 = _waypointsCat.AddButton(Language.LoadPos, $"{Language.LoadPos} 2", () => { LoadAction(2); },
_wpl2 = _waypointsCat.AddButton(Language.LoadPos, Language.LoadPosTooltip, () => LoadAction(2),
ResourceManager.two);
_wpl3 = _waypointsCat.AddButton(Language.LoadPos, $"{Language.LoadPos} 3", () => { LoadAction(3); },
_wpl3 = _waypointsCat.AddButton(Language.LoadPos, Language.LoadPosTooltip, () => LoadAction(3),
ResourceManager.three);
_wpl4 = _waypointsCat.AddButton(Language.LoadPos, $"{Language.LoadPos} 4", () => { LoadAction(4); },
_wpl4 = _waypointsCat.AddButton(Language.LoadPos, Language.LoadPosTooltip, () => LoadAction(4),
ResourceManager.four);

var t = _teleportVr.AddCategory("Information");
Expand All @@ -77,7 +80,7 @@ private static void BuildUserSelectMenu() {
var theSelectedUserMenu = menuSelectedUserLocal.Find("ScrollRect/Viewport/VerticalLayoutGroup");
_userSelectCategory = new ReMenuCategory("TPVR", theSelectedUserMenu);

_userSelTp = _userSelectCategory.AddButton(Language.theWord_Teleport, $"{Language.theWord_Teleport} to Selected User", () => {
_userSelTp = _userSelectCategory.AddButton(Language.TheWordTeleport, $"{Language.TheWordTeleport} to Selected User", () => {
if (CheckWorldAllowed.RiskyFunctionAllowed)
PlayerActions.Teleport(PlayerActions.SelVRCPlayer());
}, ResourceManager.mapmarker);
Expand All @@ -88,14 +91,17 @@ internal static void OnPrefSave() {
if (!_built) return;
if (_teleportVr != null && _handChange != null)
_handChange.Toggle(Main.PreferRightHand.Value);
if (_userSelectCategory != null && _userSelTp != null) {
_userSelectCategory.Active = Main.VRTeleportVisible.Value;
_userSelTp.Active = Main.VRTeleportVisible.Value;
}

if (_userSelectCategory == null || _userSelTp == null) return;
_userSelectCategory.Active = Main.VRTeleportVisible.Value;
_userSelTp.Active = Main.VRTeleportVisible.Value;
UpdateButtonLanguage();
}

internal static void UpdateWorldActions(bool status) {
if (_mainCat != null)
_mainCat.Title = $"TPVR Actions ({(status ? "<color=#00ff00>Allowed</color>" : "<color=#ff0000>Disallowed</color>")})";

if (_tpAction != null)
_tpAction.Interactable = status;
if (_tpKeyboard != null)
Expand All @@ -121,5 +127,67 @@ internal static void UpdateWorldActions(bool status) {
if (_wpl4 != null)
_wpl4.Interactable = status;
}

private static void UpdateButtonLanguage() {
if (_tpKeyboard != null) {
_tpKeyboard.Text = Language.TpToNameText;
_tpKeyboard.Tooltip = Language.TpToNameTooltip;
}

if (_tpCoord != null) {
_tpCoord.Text = Language.TpToCoordText;
_tpCoord.Tooltip = Language.TpToCoordTooltip;
}

if (_tpAction != null) {
_tpAction.Text = Language.TheWordTeleport;
_tpAction.Tooltip = $"Activate {Language.TheWordTeleport}";
}

if (_handChange != null) {
_handChange.Text = Language.PreferedHandedTextOn;
_handChange.Tooltip = Language.PerferedHandTooltip;
}

if (_wp1 != null) {
_wp1.Text = Language.SavePos;
_wp1.Tooltip = Language.SavePosToolTip;
}

if (_wp2 != null) {
_wp2.Text = Language.SavePos;
_wp2.Tooltip = Language.SavePosToolTip;
}

if (_wp3 != null) {
_wp3.Text = Language.SavePos;
_wp3.Tooltip = Language.SavePosToolTip;
}

if (_wp4 != null) {
_wp4.Text = Language.SavePos;
_wp4.Tooltip = Language.SavePosToolTip;
}

if (_wpl1 != null) {
_wpl1.Text = Language.LoadPos;
_wpl1.Tooltip = Language.LoadPosTooltip;
}

if (_wpl2 != null) {
_wpl2.Text = Language.LoadPos;
_wpl2.Tooltip = Language.LoadPosTooltip;
}

if (_wpl3 != null) {
_wpl3.Text = Language.LoadPos;
_wpl3.Tooltip = Language.LoadPosTooltip;
}

if (_wpl4 != null) {
_wpl4.Text = Language.LoadPos;
_wpl4.Tooltip = Language.LoadPosTooltip;
}
}
}
}

0 comments on commit bd0a43a

Please sign in to comment.