private void CreateGameplayLabel(Transform canvasTransform, SongUILabel labelDetails) { var o = new GameObject($"Extra Song UI - {labelDetails.Name}"); var text = o.AddComponent <Text>(); o.layer = LayerMask.NameToLayer("UI"); o.transform.SetParent(canvasTransform); o.transform.SetSiblingIndex(0); o.transform.localEulerAngles = new Vector3(); o.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); text.horizontalOverflow = HorizontalWrapMode.Overflow; text.verticalOverflow = VerticalWrapMode.Overflow; text.font = BiendeoCHLib.BiendeoCHLib.Instance.CloneHeroDefaultFont; labels.Add(new Tuple <SongUILabel, GameObject, Text>(labelDetails, o, text)); }
private void UpdateGameplayLabel(SongUILabel labelSettings, GameObject textObject, Text textLabel) { if (labelSettings.Visible && config.Enabled) { textObject.transform.localPosition = new Vector3(labelSettings.X - Screen.width / 2, Screen.height / 2 - labelSettings.Y); textLabel.enabled = true; textLabel.fontSize = labelSettings.Size; textLabel.alignment = labelSettings.Alignment; textLabel.fontStyle = (labelSettings.Bold ? FontStyle.Bold : FontStyle.Normal) | (labelSettings.Italic ? FontStyle.Italic : FontStyle.Normal); textLabel.color = labelSettings.Color.Color; textLabel.text = FormatSongLabel(labelSettings.Format); } else { textLabel.enabled = false; } }
private void OnWindow(int id) { var smallLabelStyle = new GUIStyle { fontSize = 14, alignment = TextAnchor.UpperLeft, normal = new GUIStyleState { textColor = Color.white, } }; var largeLabelStyle = new GUIStyle { fontSize = 20, alignment = TextAnchor.UpperLeft, normal = new GUIStyleState { textColor = Color.white, } }; var styles = new GUIConfigurationStyles { LargeLabel = largeLabelStyle, SmallLabel = smallLabelStyle, Window = settingsWindowStyle, Toggle = settingsToggleStyle, Button = settingsButtonStyle, TextArea = settingsTextAreaStyle, TextField = settingsTextFieldStyle, Label = settingsLabelStyle, Box = settingsBoxStyle, HorizontalSlider = settingsHorizontalSliderStyle, HorizontalSliderThumb = settingsHorizontalSliderThumbStyle }; if (settingsCurrentlyEditing == null) { settingsScrollPosition = GUILayout.BeginScrollView(settingsScrollPosition); GUILayout.Label("Settings", largeLabelStyle); GUILayout.Space(25.0f); GUILayout.Label("Enable/Disable Keybind", largeLabelStyle); config.EnabledKeyBind.ConfigureGUI(styles); GUILayout.Space(25.0f); GUILayout.Label("Configuration Keybind", largeLabelStyle); config.ConfigKeyBind.ConfigureGUI(styles); GUILayout.Space(25.0f); GUILayout.Label("Debugging Tools", largeLabelStyle); config.DraggableLabelsEnabled = GUILayout.Toggle(config.DraggableLabelsEnabled, "Draggable Labels", styles.Toggle); GUILayout.Label("Allows you to drag each label with a window", new GUIStyle(styles.SmallLabel) { fontStyle = FontStyle.Italic }); GUILayout.Label("(this disables some options in this window)", new GUIStyle(styles.SmallLabel) { fontStyle = FontStyle.Italic }); foreach (var layout in config.Layout) { foreach (var label in layout) { label.DraggableWindowsEnabled = config.DraggableLabelsEnabled; } } GUILayout.Space(20.0f); config.Enabled = !GUILayout.Toggle(!config.Enabled, "Hide all extra UI", settingsToggleStyle); GUILayout.Space(20.0f); GUILayout.Label("Layout for the following players:"); GUILayout.BeginHorizontal(); for (int i = 0; i < bandIndex; ++i) { if (GUILayout.Toggle(config.LayoutIndexSelected == i, $"{i + 1}", settingsToggleStyle)) { config.LayoutIndexSelected = i; } } GUILayout.EndHorizontal(); config.Enabled = !GUILayout.Toggle(!config.Enabled, "Hide all extra UI", settingsToggleStyle); GUILayout.Space(20.0f); for (int i = 0; i < config.Layout[config.LayoutIndexSelected].Count; ++i) { GUILayout.Label($"#{i + 1}", styles.SmallLabel); var layout = config.Layout[config.LayoutIndexSelected]; var label = layout[i]; if (GUILayout.Button($"Edit: {label.Name}", styles.Button)) { settingsCurrentlyEditing = label; } GUILayout.BeginHorizontal(); if (i > 0 && GUILayout.Button("Shift up")) { layout[i] = layout[i - 1]; layout[i - 1] = label; } if (i < layout.Count - 1 && GUILayout.Button("Shift down")) { layout[i] = layout[i + 1]; layout[i + 1] = label; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Delete")) { layout.RemoveAt(i); var existingLabel = labels.FirstOrDefault(l => l.Item1 == label); if (existingLabel != default) { Destroy(existingLabel.Item2); labels.Remove(existingLabel); } } if (GUILayout.Button("Insert new")) { layout.Insert(i + 1, new SongUILabel { Name = "New Label", Format = "EDIT ME", X = Screen.width / 2, Y = Screen.height / 2, Size = 50, Alignment = TextAnchor.MiddleCenter, Bold = true, Italic = false, Visible = true, Color = new ColorARGB(Color.white) }); if (SceneManager.GetActiveScene().name == "Gameplay") { Transform canvasTransform = FadeBehaviourWrapper.Instance.FadeGraphic.canvas.transform; CreateGameplayLabel(canvasTransform, layout[i + 1]); } } GUILayout.EndHorizontal(); GUILayout.Space(15.0f); } if (config.Layout[config.LayoutIndexSelected].Count == 0) { if (GUILayout.Button("Insert")) { config.Layout[config.LayoutIndexSelected].Add(new SongUILabel { Name = "New Label", Format = "EDIT ME", X = Screen.width / 2, Y = Screen.height / 2, Size = 50, Alignment = TextAnchor.MiddleCenter, Bold = true, Italic = false, Visible = true, Color = new ColorARGB(Color.white) }); if (SceneManager.GetActiveScene().name == "Gameplay") { Transform canvasTransform = FadeBehaviourWrapper.Instance.FadeGraphic.canvas.transform; CreateGameplayLabel(canvasTransform, config.Layout[config.LayoutIndexSelected][0]); } } } GUILayout.Space(20.0f); if (GUILayout.Button("Reload Config", styles.Button)) { DestroyLabels(); config.ReloadConfig(ConfigPath); } if (GUILayout.Button("Save Config", settingsButtonStyle)) { config.SaveConfig(ConfigPath); } GUILayout.Space(50.0f); GUILayout.Label($"Extra Song UI v{versionCheck.AssemblyVersion}"); GUILayout.Label("Tweak by Biendeo"); GUILayout.Label("Thankyou for using this!"); GUILayout.EndScrollView(); } else { settingsCurrentlyEditing.ConfigureGUI(styles); if (GUILayout.Button("Back", styles.Button)) { settingsCurrentlyEditing = null; } } GUI.DragWindow(); }