public static void Attach(KScreen screen) { if (screen == null || screen.name == "SimpleInfoScreen") { return; } DraggablePanel panel = screen.FindOrAddUnityComponent <DraggablePanel>(); if (panel == null) { return; } panel.Screen = screen; var rect = panel.GetComponentInParent <RectTransform>(); if (rect == null) { return; } panel.DefaultPosition = rect.anchoredPosition; State.Common.Logger.LogDebug("Attached to KScreen", screen.displayName); }
public KScreen PopScreen() { KScreen result = screenStack[screenStack.Count - 1]; screenStack.RemoveAt(screenStack.Count - 1); return(result); }
public void OnKeyUp(KButtonEvent e) { if (!inputDisabled) { int num = screenStack.Count - 1; KScreen kScreen; while (true) { if (num < 0) { return; } kScreen = screenStack[num]; if ((Object)kScreen != (Object)null && kScreen.isActiveAndEnabled) { kScreen.OnKeyUp(e); if (e.Consumed || kScreen.IsModal()) { break; } } num--; } lastConsumedEvent = e; lastConsumedEventScreen = kScreen; } }
public static void VerifyTranslationModSubscription(GameObject context) { if (GetSelectedLanguageType() == SelectedLanguageType.UGC && SteamManager.Initialized && !LanguageOptionsScreen.HasInstalledLanguage()) { PublishedFileId_t invalid = PublishedFileId_t.Invalid; PublishedFileId_t publishedFileId_t = new PublishedFileId_t((uint)KPlayerPrefs.GetInt("InstalledLanguage", (int)invalid.m_PublishedFileId)); Label label = default(Label); label.distribution_platform = Label.DistributionPlatform.Steam; label.id = publishedFileId_t.ToString(); Label rhs = label; string arg = UI.FRONTEND.TRANSLATIONS_SCREEN.UNKNOWN; foreach (Mod mod in Global.Instance.modManager.mods) { if (mod.label.Match(rhs)) { arg = mod.title; break; } } ClearLanguage(); GameObject gameObject = KScreenManager.AddChild(context, ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject); KScreen component = gameObject.GetComponent <KScreen>(); component.Activate(); ConfirmDialogScreen component2 = component.GetComponent <ConfirmDialogScreen>(); ConfirmDialogScreen confirmDialogScreen = component2; string title_text = UI.CONFIRMDIALOG.DIALOG_HEADER; string text = string.Format(UI.FRONTEND.TRANSLATIONS_SCREEN.MISSING_LANGUAGE_PACK, arg); string confirm_text = UI.FRONTEND.TRANSLATIONS_SCREEN.RESTART; System.Action on_confirm = App.instance.Restart; confirmDialogScreen.PopupConfirmDialog(text, on_confirm, null, null, null, title_text, confirm_text, null, null, true); } }
internal OptionsDialog(Type optionsType, KMod.Mod modSpec) { dialog = null; modImage = null; this.modSpec = modSpec ?? throw new ArgumentNullException("modSpec"); this.optionsType = optionsType ?? throw new ArgumentNullException("optionsType"); optionCategories = OptionsEntry.BuildOptions(optionsType); options = null; // Determine config location infoAttr = POptions.GetModInfoAttribute(optionsType); typeAttr = POptions.GetConfigFileAttribute(optionsType); var src = modSpec.file_source; if (src == null) { path = null; } else { path = Path.Combine(src.GetRoot(), typeAttr?.ConfigFileName ?? POptions. CONFIG_FILE_NAME); } // Find mod home page string url = infoAttr?.URL; var label = modSpec.label; if (string.IsNullOrEmpty(url) && label.distribution_platform == KMod.Label. DistributionPlatform.Steam) { // Steam mods use their workshop ID as the label url = "https://steamcommunity.com/sharedfiles/filedetails/?id=" + label.id; } modURL = url; }
/// <summary> /// Triggered when the Mod Options button is clicked. /// </summary> public void OnModOptions(GameObject _) { if (path != null) { // Close current dialog if open CloseDialog(); // Ensure that it is on top of other screens (which may be +100 modal) var pDialog = new PDialog("ModOptions") { Title = POptions.DIALOG_TITLE.text.F(modSpec.title), Size = POptions. SETTINGS_DIALOG_SIZE, SortKey = 150.0f, DialogBackColor = PUITuning.Colors. OptionsBackground, DialogClosed = OnOptionsSelected }.AddButton("ok", STRINGS.UI.CONFIRMDIALOG.OK, POptions.TOOLTIP_OK). AddButton(PDialog.DIALOG_KEY_CLOSE, STRINGS.UI.CONFIRMDIALOG.CANCEL, POptions.TOOLTIP_CANCEL); // For each option, add its UI component to panel pDialog.Body.Spacing = 3; pDialog.Body.BackColor = PUITuning.Colors.DialogDarkBackground; foreach (var entry in optionEntries) { pDialog.Body.AddChild(entry.GetUIEntry()); } options = POptions.ReadSettings(path, optionsType); if (options == null) { CreateOptions(); } // Manually build the dialog so the options can be updated after realization var obj = pDialog.Build(); UpdateOptions(); dialog = obj.GetComponent <KScreen>(); dialog.Activate(); } }
public void AddSubMenu(KScreen sub_menu) { if (sub_menu.activateOnSpawn) { sub_menu.Show(true); } subMenus.Add(sub_menu); }
public KScreen StartScreen(GameObject screenPrefab, GameObject parent) { GameObject gameObject = AddChild(parent, screenPrefab); KScreen component = gameObject.GetComponent <KScreen>(); component.Activate(); return(component); }
/// <summary> /// Closes the current dialog. /// </summary> private void CloseDialog() { if (dialog != null) { dialog.Deactivate(); dialog = null; } }
public GameObject ActivateScreen(GameObject screen, GameObject parent) { AddExistingChild(parent, screen); KScreen component = screen.GetComponent <KScreen>(); component.Activate(); return(screen); }
private ConfirmDialogScreen GetConfirmDialog() { GameObject gameObject = KScreenManager.AddChild(base.transform.parent.gameObject, ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject); KScreen component = gameObject.GetComponent <KScreen>(); component.Activate(); return(component.GetComponent <ConfirmDialogScreen>()); }
public TypeSelectControl(bool disableIcons = false) { DisableIcons = disableIcons; // Select/deselect all types var allCheckBox = new PCheckBox("SelectAll") { Text = STRINGS.UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON, CheckSize = ROW_SIZE, InitialState = PCheckBox.STATE_CHECKED, OnChecked = OnCheck, TextStyle = PUITuning.Fonts.TextDarkStyle }; allCheckBox.OnRealize += (obj) => { allItems = obj; }; var cp = new PPanel("Categories") { Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft, Spacing = ROW_SPACING }; cp.OnRealize += (obj) => { childPanel = obj; }; RootPanel = new PPanel("Border") { // 1px dark border for contrast Margin = new RectOffset(1, 1, 1, 1), Direction = PanelDirection.Vertical, Alignment = TextAnchor.MiddleCenter, Spacing = 1 }.AddChild(new PLabel("Title") { // Title bar TextAlignment = TextAnchor.MiddleCenter, Text = SweepByTypeStrings. DIALOG_TITLE, FlexSize = new Vector2(1.0f, 0.0f), DynamicSize = true, Margin = new RectOffset(1, 1, 1, 1) }.SetKleiPinkColor()).AddChild(new PPanel("TypeSelectControl") { // White background for scroll bar Direction = PanelDirection.Vertical, Margin = OUTER_MARGIN, Alignment = TextAnchor.MiddleCenter, Spacing = 0, BackColor = PUITuning.Colors.BackgroundLight, FlexSize = Vector2.one }.AddChild(new PScrollPane("Scroll") { // Scroll to select elements Child = new PPanel("SelectType") { Direction = PanelDirection.Vertical, Margin = ELEMENT_MARGIN, FlexSize = new Vector2(1.0f, 0.0f), Alignment = TextAnchor.UpperLeft }.AddChild(allCheckBox).AddChild(cp), ScrollHorizontal = false, ScrollVertical = true, AlwaysShowVertical = true, TrackSize = 8.0f, FlexSize = Vector2.one, BackColor = PUITuning.Colors.BackgroundLight, })).SetKleiBlueColor().BuildWithFixedSize(PANEL_SIZE); // Cache the vertical scroll bar var vst = RootPanel.transform.Find("TypeSelectControl/Scroll/Viewport/SelectType"); #pragma warning disable IDE0031 // Use null propagation vScroll = (vst == null) ? null : vst.gameObject; #pragma warning restore IDE0031 // Use null propagation children = new SortedList <Tag, TypeSelectCategory>(16, TagAlphabetComparer. INSTANCE); position = Vector3.zero; Screen = RootPanel.AddComponent <TypeSelectScreen>(); }
public KScreen SetSecondarySideScreen(KScreen secondaryPrefab, string title) { ClearSecondarySideScreen(); activeSideScreen2 = KScreenManager.Instance.InstantiateScreen(secondaryPrefab.gameObject, sideScreen2ContentBody); activeSideScreen2.Activate(); sideScreen2Title.text = title; sideScreen2.SetActive(true); return(activeSideScreen2); }
public int AddTab(Sprite icon, string tabName, KScreen contents, string tooltip = "") { int count = tabs.Count; header.Add(icon, tabName, ActivateTab, tabs.Count, tooltip); header.SetTabEnabled(count, true); tabs.Add(contents); return(count); }
public void ClearSecondarySideScreen() { if ((UnityEngine.Object)activeSideScreen2 != (UnityEngine.Object)null) { activeSideScreen2.Deactivate(); activeSideScreen2 = null; } sideScreen2.SetActive(false); }
// TODO: call when position is set by game public static void SetPositionFromFile(KScreen screen) { DraggablePanel panel = screen.FindOrAddUnityComponent <DraggablePanel>(); if (panel != null && panel.LoadPosition(out Vector2 newPosition)) { panel.SetPosition(newPosition); } }
public int AddTab(string tabName, KScreen contents) { int count = tabs.Count; header.Add(tabName, ActivateTab, tabs.Count); header.SetTabEnabled(count, true); tabs.Add(contents); return(count); }
public TypeSelectControl(bool disableIcons = false) { DisableIcons = disableIcons; // Select/deselect all types var allCheckBox = new PCheckBox("SelectAll") { Text = STRINGS.UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON, CheckSize = ROW_SIZE, InitialState = PCheckBox.STATE_CHECKED, OnChecked = OnCheck, TextStyle = PUITuning.Fonts.TextDarkStyle }; allCheckBox.OnRealize += (obj) => { allItems = obj; }; var cp = new PPanel("Categories") { Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft, Spacing = ROW_SPACING, Margin = ELEMENT_MARGIN, FlexSize = Vector2.right, }; cp.AddChild(allCheckBox); cp.OnRealize += (obj) => { childPanel = obj; }; // Scroll to select elements var sp = new PScrollPane("Scroll") { Child = cp, ScrollHorizontal = false, ScrollVertical = true, AlwaysShowVertical = true, TrackSize = 8.0f, FlexSize = Vector2.one }; // Title bar var title = new PLabel("Title") { TextAlignment = TextAnchor.MiddleCenter, Text = SweepByTypeStrings. DIALOG_TITLE, FlexSize = Vector2.right, Margin = TITLE_MARGIN }.SetKleiPinkColor(); // Bottom border on the title for contrast title.OnRealize += (obj) => { var img = obj.AddOrGet <Image>(); img.sprite = PUITuning.Images.BoxBorder; img.type = Image.Type.Sliced; }; // 1px black border on the rest of the dialog for contrast var panel = new PRelativePanel("Border") { BackImage = PUITuning.Images.BoxBorder, ImageMode = Image.Type.Sliced, DynamicSize = false, BackColor = PUITuning.Colors.BackgroundLight }.AddChild(sp).AddChild(title); RootPanel = panel.SetMargin(sp, OUTER_MARGIN). SetLeftEdge(title, fraction: 0.0f).SetRightEdge(title, fraction: 1.0f). SetLeftEdge(sp, fraction: 0.0f).SetRightEdge(sp, fraction: 1.0f). SetTopEdge(title, fraction: 1.0f).SetBottomEdge(sp, fraction: 0.0f). SetTopEdge(sp, below: title).Build(); RootPanel.SetMinUISize(PANEL_SIZE); children = new SortedList <Tag, TypeSelectCategory>(16, TagAlphabetComparer. INSTANCE); Screen = RootPanel.AddComponent <TypeSelectScreen>(); }
internal OptionsDialog(Type optionsType, KMod.Mod modSpec) { dialog = null; this.modSpec = modSpec ?? throw new ArgumentNullException("modSpec"); this.optionsType = optionsType ?? throw new ArgumentNullException( "optionsType"); optionEntries = BuildOptions(optionsType); options = null; path = Path.Combine(modSpec.file_source.GetRoot(), POptions.CONFIG_FILE); }
protected override void OnCmpDisable() { if (quitting) { for (int num = screenStack.Count - 1; num >= 0; num--) { KScreen kScreen = screenStack[num]; kScreen.Deactivate(); } } }
private static void ActivateScreen(LoreBearer loreBearer, KScreen screen) { var demolishable = loreBearer?.GetComponent <Demolishable>(); if (demolishable != null && isMarkedForDemolition.Get(demolishable)) { screen.Deactivate(); return; } screen.Activate(); }
public static void Attach(KScreen screen) { DraggablePanel panel = screen.FindOrAddUnityComponent <DraggablePanel>(); if (panel == null) { return; } panel.Screen = screen; }
public KScreen StartScreen(GameObject screenPrefab, GameObject parent = null, UIRenderTarget target = UIRenderTarget.ScreenSpaceOverlay) { if ((Object)parent == (Object)null) { parent = GetParent(target); } GameObject gameObject = KScreenManager.AddChild(parent, screenPrefab); KScreen component = gameObject.GetComponent <KScreen>(); component.Activate(); return(component); }
public GameObject ActivateScreen(GameObject screen, GameObject parent = null, UIRenderTarget target = UIRenderTarget.ScreenSpaceOverlay) { if ((Object)parent == (Object)null) { parent = GetParent(target); } KScreenManager.AddExistingChild(parent, screen); KScreen component = screen.GetComponent <KScreen>(); component.Activate(); return(screen); }
/// <summary> /// Closes the current dialog. /// </summary> private void CloseDialog() { if (dialog != null) { dialog.Deactivate(); // dialog's game object is destroyed by Deactivate() dialog = null; } if (modImage != null) { UnityEngine.Object.Destroy(modImage); modImage = null; } }
/// <summary> /// Triggered when the Mod Options button is clicked. /// </summary> public void OnModOptions(GameObject _) { if (path != null) { // Close current dialog if open CloseDialog(); // Ensure that it is on top of other screens (which may be +100 modal) var pDialog = new PDialog("ModOptions") { Title = POptions.DIALOG_TITLE.text.F(modSpec.title), Size = POptions. SETTINGS_DIALOG_SIZE, SortKey = 150.0f, DialogBackColor = PUITuning.Colors. OptionsBackground, DialogClosed = OnOptionsSelected }.AddButton("ok", STRINGS.UI.CONFIRMDIALOG.OK, POptions.TOOLTIP_OK); pDialog.AddButton("manual", POptions.BUTTON_MANUAL, POptions.TOOLTIP_MANUAL). AddButton(PDialog.DIALOG_KEY_CLOSE, STRINGS.UI.CONFIRMDIALOG.CANCEL, POptions.TOOLTIP_CANCEL); PPanel body = pDialog.Body, current; var margin = body.Margin; // For each option, add its UI component to panel body.Spacing = 10; body.Margin = new RectOffset(0, 0, 0, 0); // Display all categories foreach (var catEntries in optionCategories) { string category = catEntries.Key; current = new PPanel("Entries_" + category) { Alignment = TextAnchor.UpperCenter, Spacing = 5, BackColor = PUITuning.Colors.DialogDarkBackground, FlexSize = new Vector2(1.0f, 0.0f), Margin = margin }; AddCategoryHeader(current, catEntries.Key); foreach (var entry in catEntries.Value) { current.AddChild(entry.GetUIEntry()); } body.AddChild(current); } options = POptions.ReadSettings(path, optionsType); if (options == null) { CreateOptions(); } // Manually build the dialog so the options can be updated after realization var obj = pDialog.Build(); UpdateOptions(); dialog = obj.GetComponent <KScreen>(); dialog.Activate(); } }
public void AddResearchScreen(ResearchScreen researchScreen) { if (!((Object)this.researchScreen != (Object)null)) { this.researchScreen = researchScreen; this.researchScreen.gameObject.SetActive(false); ScreenInfoMatch.Add(researchInfo, new ScreenData { screen = this.researchScreen, tabIdx = 5, toggleInfo = researchInfo }); this.researchScreen.Show(false); } }
public TypeSelectControl() { var allCheckBox = new PCheckBox("SelectAll") { Text = STRINGS.UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON, CheckSize = ROW_SIZE, InitialState = PCheckBox.STATE_CHECKED, OnChecked = OnCheck, TextStyle = PUITuning.Fonts.TextDarkStyle }; allCheckBox.OnRealize += (obj) => { allItems = obj; }; var cp = new PPanel("Categories") { Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft, Spacing = ROW_SPACING }; cp.OnRealize += (obj) => { childPanel = obj; }; RootPanel = new PPanel("Border") { // 1px dark border for contrast Margin = new RectOffset(1, 1, 1, 1), Direction = PanelDirection.Vertical, Alignment = TextAnchor.MiddleCenter, Spacing = 1 }.AddChild(new PLabel("Title") { // Title bar TextAlignment = TextAnchor.MiddleCenter, Text = SweepByTypeStrings. DIALOG_TITLE, FlexSize = new Vector2(1.0f, 0.0f), DynamicSize = true, Margin = new RectOffset(1, 1, 1, 1) }.SetKleiPinkColor()).AddChild(new PPanel("TypeSelectControl") { // White background for scroll bar Direction = PanelDirection.Vertical, Margin = OUTER_MARGIN, Alignment = TextAnchor.MiddleCenter, Spacing = 0, BackColor = PUITuning.Colors.BackgroundLight, FlexSize = Vector2.one }.AddChild(new PScrollPane("Scroll") { // Scroll to select elements Child = new PPanel("SelectType") { Direction = PanelDirection.Vertical, Margin = ELEMENT_MARGIN, FlexSize = new Vector2(1.0f, 0.0f), Alignment = TextAnchor.UpperLeft }.AddChild(allCheckBox).AddChild(cp), ScrollHorizontal = false, ScrollVertical = true, AlwaysShowVertical = true, TrackSize = 8.0f, FlexSize = Vector2.one, BackColor = PUITuning.Colors.BackgroundLight })).SetKleiBlueColor().BuildWithFixedSize(PANEL_SIZE); children = new SortedList <Tag, TypeSelectCategory>(16, this); Screen = RootPanel.AddComponent <TypeSelectScreen>(); }
public KScreen PopScreen(KScreen screen) { KScreen result = null; int num = screenStack.IndexOf(screen); if (num >= 0) { result = screenStack[num]; screenStack.RemoveAt(num); } screenStack = (from x in screenStack where (Object)x != (Object)null orderby x.GetSortKey() select x).ToList(); return(result); }
internal OptionsDialog(Type optionsType, IOptionsHandler handler) { string root = handler.ConfigPath; dialog = null; modImage = null; this.handler = handler ?? throw new ArgumentNullException("handler"); this.optionsType = optionsType ?? throw new ArgumentNullException("optionsType"); optionCategories = OptionsEntry.BuildOptions(optionsType); options = null; // Determine config location infoAttr = POptions.GetModInfoAttribute(optionsType); typeAttr = POptions.GetConfigFileAttribute(optionsType); path = (root == null) ? null : Path.Combine(root, typeAttr?.ConfigFileName ?? POptions.CONFIG_FILE_NAME); }