public TestPop4() { m_popId = POP_ID.TEST_POP_4; m_layerIdx = POP_LAYER_IDX.LAYER_POP_1; ShowGameObject(); // m_btnOk = GetChildByName <KButton>("Button_Ok", true); m_btnClose = GetChildByName <KButton>("Button_Close", true); m_panel = GameObjUtil.GetParent(m_btnOk.gameObject); // m_inputName = GetChildByName <KInputField>("Input_name", true); m_labelTestInput = GetChildByName <KText>("Label_testInput", true); // m_tgl_1 = GetChildByName <KToggle>("Toggle_position1", true); m_labelTgl_1 = GetChildByName <KText>(m_tgl_1.gameObject, "Label_Text", true); m_tglGroup_1 = GetChildByName <KToggleGroup>("ToggleGroup_a1", true); // m_sliderSchedule = GetChildByName <KSlider>("Slider_Schedule1", true); m_labelSchedule = GetChildByName <KText>("Label_testSilder", true); // m_barLoading = GetChildByName <KProgressBar>("ProgressBar_loading", true); // m_icon = GetChildByName <KImage>("Image_sharedAnchor", true); // m_scrollView = GetChildByName <KScrollView>("ScrollView_GuildList", true); m_listView = ComponentUtil.EnsureComponent <KListViewScroll>(m_scrollView.gameObject); }
/// <summary> /// Shows the mod actions popup. /// </summary> /// <param name="button">The options button which invoked this popup.</param> /// <param name="index">The mod index in the list that is showing the popup.</param> private void ShowPopup(KButton button, int index) { var mods = Global.Instance.modManager?.mods; int n; if (mods != null && index >= 0 && index < (n = mods.Count)) { var mod = mods[index]; bool isSteam = mod.label.distribution_platform == Label.DistributionPlatform. Steam; RectTransform rt = actionsScreen.rectTransform(), crt = button.rectTransform(); actionsScreen.Index = index; actionsScreen.Mod = mod; // Update usability of each button if (buttonFirst != null) { buttonFirst.isInteractable = index > 0; } if (buttonUp != null) { buttonUp.isInteractable = index > 0; } if (buttonDown != null) { buttonDown.isInteractable = index < n - 1; } if (buttonLast != null) { buttonLast.isInteractable = index < n - 1; } if (buttonUnsub != null) { buttonUnsub.isInteractable = isSteam; } if (buttonManage != null) { PUIElements.SetToolTip(buttonManage, isSteam ? UI.MODSSCREEN. BUTTON_SUBSCRIPTION : UI.MODSSCREEN.BUTTON_LOCAL); PUIElements.SetToolTip(buttonManage, mod.manage_tooltip); } if (buttonModify != null) { buttonModify.isInteractable = isSteam; } actionsScreen.SetActive(true); // Resize to the proper size LayoutRebuilder.ForceRebuildLayoutImmediate(rt); float w = LayoutUtility.GetPreferredWidth(rt), h = LayoutUtility. GetPreferredHeight(rt) * 0.5f, end = crt.offsetMin.x - 1.0f; rt.SetParent(crt.parent, false); rt.SetAsLastSibling(); // Move it to the correct place rt.anchoredPosition = Vector2.zero; rt.anchorMin = DebugUtils.ANCHOR_MID_LEFT; rt.anchorMax = DebugUtils.ANCHOR_MID_LEFT; rt.offsetMin = new Vector2(end - w, -h); rt.offsetMax = new Vector2(end, h); callingButton = button; } }
private void Initialize(List <Event> events) { foreach (Event @event in events) { Event current = @event; HierarchyReferences hierarchyReferences = Util.KInstantiateUI <HierarchyReferences>(entryPrefab, entryParent.gameObject, true); LocText reference = hierarchyReferences.GetReference <LocText>("Title"); LocText reference2 = hierarchyReferences.GetReference <LocText>("Description"); KButton reference3 = hierarchyReferences.GetReference <KButton>("Details"); Event.GetUIStrings(current.event_type, out string title, out string title_tooltip); reference.text = title; reference.GetComponent <ToolTip>().toolTip = title_tooltip; reference2.text = current.mod.title; ToolTip component = reference2.GetComponent <ToolTip>(); if ((Object)component != (Object)null) { component.toolTip = current.mod.ToString(); } reference3.isInteractable = false; Mod mod = Global.Instance.modManager.FindMod(current.mod); if (mod != null) { if ((Object)component != (Object)null && !string.IsNullOrEmpty(mod.description)) { component.toolTip = mod.description; } if (mod.on_managed != null) { reference3.onClick += mod.on_managed; reference3.isInteractable = true; } } } }
public TestKUIPop3() { m_popId = POP_ID.TEST_KUI_3; m_layerIdx = POP_LAYER_IDX.LAYER_POP_1; ShowGameObject(); m_toggle1 = GetChildByName <KToggle>("Toggle_position1", true); m_toggle1.needReqChange = true; m_toggleGroup1 = GetChildByName <KToggleGroup>("ToggleGroup_1", true); //m_toggleGroup1.allowMultiple = true; //m_toggleGroup1.needReqChange = true; //m_toggleGroup1.allowSwitchOff = true; m_inputName = GetChildByName <KInputField>("Input_name", true); m_buttonAnnounce = GetChildByName <KButton>("Button_SystemAnnounce", true); m_buttonClose = GetChildByName <KButton>("Button_Close", true); m_barExp = GetChildByName <KProgressBar>("ProgressBar_EXP", true); m_sliderSchedule1 = GetChildByName <KSlider>("Slider_Schedule1", true); m_icon1 = GetChildByName <KImage>("Image_Icon1", true); m_scrollViewItemList = GetChildByName <KScrollView>("ScrollView_ItemList", true); }
private float KeyState(KButton key) { int msec = key.msec; key.msec = 0; int time = CDataModel.GameState.realTime; if (key.active) { //仍然按下 if (key.downtime == 0) { msec = time; } else { msec += time - key.downtime; } key.downtime = time; } float val = (float)msec / CDataModel.GameState.frameTime; if (val < 0) { val = 0; } else if (val > 1) { val = 1; } return(val); }
private void RebuildUGCButtons() { if (!((UnityEngine.Object)SteamUGCService.Instance == (UnityEngine.Object)null)) { foreach (Mod mod in Global.Instance.modManager.mods) { if ((mod.available_content & Content.Translation) != 0 && mod.status == Mod.Status.Installed) { GameObject gameObject = Util.KInstantiateUI(languageButtonPrefab, ugcLanguagesContainer, false); gameObject.name = mod.title + "_button"; HierarchyReferences component = gameObject.GetComponent <HierarchyReferences>(); PublishedFileId_t file_id = new PublishedFileId_t(ulong.Parse(mod.label.id)); TMP_FontAsset fontForLangage = GetFontForLangage(file_id); LocText reference = component.GetReference <LocText>("Title"); reference.SetText(string.Format(UI.FRONTEND.TRANSLATIONS_SCREEN.UGC_MOD_TITLE_FORMAT, mod.title)); reference.font = fontForLangage; Texture2D texture2D = SteamUGCService.Instance.FindMod(file_id)?.previewImage; if ((UnityEngine.Object)texture2D != (UnityEngine.Object)null) { Image reference2 = component.GetReference <Image>("Image"); reference2.sprite = Sprite.Create(texture2D, new Rect(Vector2.zero, new Vector2((float)texture2D.width, (float)texture2D.height)), Vector2.one * 0.5f); } KButton component2 = gameObject.GetComponent <KButton>(); component2.onClick += delegate { ConfirmLanguageChoiceDialog(string.Empty, file_id); }; buttons.Add(gameObject); } } } }
public StatusItemEntry(StatusItemGroup.Entry item, StatusItemCategory category, GameObject status_item_prefab, Transform parent, TextStyleSetting tooltip_style, Color color, TextStyleSetting style, bool skip_fade, Action <StatusItemEntry> onDestroy) { this.item = item; this.category = category; tooltipStyle = tooltip_style; this.onDestroy = onDestroy; this.color = color; this.style = style; widget = Util.KInstantiateUI(status_item_prefab, parent.gameObject, false); text = widget.GetComponentInChildren <LocText>(true); SetTextStyleSetting.ApplyStyle(text, style); toolTip = widget.GetComponentInChildren <ToolTip>(true); image = widget.GetComponentInChildren <Image>(true); item.SetIcon(image); widget.SetActive(true); toolTip.OnToolTip = OnToolTip; button = widget.GetComponentInChildren <KButton>(); if (item.item.statusItemClickCallback != null) { button.onClick += OnClick; } else { button.enabled = false; } fadeStage = (skip_fade ? FadeStage.WAIT : FadeStage.IN); SimAndRenderScheduler.instance.Add(this, false); Refresh(); SetColor(1f); }
private void ButtonClicked(KButton btn) { LoadingOverlay.Load(delegate { Load(buttonFileMap[btn]); }); }
private GameObject AddOrGetStorageLabel(Dictionary <string, GameObject> labels, GameObject panel, string id) { GameObject gameObject = null; if (labels.ContainsKey(id)) { gameObject = labels[id]; KButton component = gameObject.GetComponent <KButton>(); component.ClearOnClick(); Transform transform = gameObject.transform.Find("removeAttributeButton"); if ((UnityEngine.Object)transform != (UnityEngine.Object)null) { KButton kButton = transform.FindComponent <KButton>(); kButton.enabled = false; kButton.gameObject.SetActive(false); kButton.ClearOnClick(); } } else { gameObject = Util.KInstantiate(attributesLabelButtonTemplate, panel.GetComponent <CollapsibleDetailContentPanel>().Content.gameObject, null); gameObject.transform.localScale = new Vector3(1f, 1f, 1f); labels[id] = gameObject; } gameObject.SetActive(true); return(gameObject); }
private void SelectTutorial(KFlyoutMenu menu, KButton menuItem, ModelInfo menuSelection) { currentModelInfo = menuSelection; KGui.gui.GuiInputSetEditable(true); KGui.gui.GuiInputSetText(menuSelection.text); KGui.gui.GuiInputSetEditable(menuSelection.executable); }
// Use this for initialization public override void Init() { pushedEvents = new SysEvent[CConstVar.MAX_PUSHED_EVENTS]; eventQueue = new SysEvent[CConstVar.MAX_PUSHED_EVENTS]; inButtons = new KButton[16]; for (int i = 0; i < 16; i++) { inButtons[i] = new KButton(); } joystickAxis = new int[CConstVar.MAX_JOYSTICK_AXIS]; mouseDx = new int[2]; mouseDy = new int[2]; mouseIndex = 0; inSpeed = new KButton(); inRight = new KButton(); inLeft = new KButton(); inForward = new KButton(); inBack = new KButton(); inMoveRight = new KButton(); inMoveLeft = new KButton(); inUp = new KButton(); inDown = new KButton(); inLookdown = new KButton(); inLookup = new KButton(); inStrafe = new KButton(); update = Update; }
private static void Postfix(MainMenu __instance, KButton ___buttonPrefab, GameObject ___buttonParent) { KButton kButton = Util.KInstantiateUI <KButton>(___buttonPrefab.gameObject, ___buttonParent, force_active: true); kButton.onClick += () => { ConfirmDialogScreen confirmDialogScreen = (ConfirmDialogScreen)KScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject, Global.Instance.globalCanvas); var text = new StringBuilder(); text.AppendLine("Duplicants rescued:"); var state = EndpointState.Load(); foreach (var item in from x in state.times_rescued orderby - x.Value, x.Key select x) { if (item.Value == 1) { text.AppendLine(item.Key); } else { text.AppendLine(item.Key + " x" + item.Value); } } confirmDialogScreen.PopupConfirmDialog(text.ToString(), null, null, null, null, "Endpoint Population"); }; LocText loctext = kButton.GetComponentInChildren <LocText>(); loctext.text = "ENDPOINT"; loctext.fontSize = 14.0f; }
// Math menu private void MathMenu() { guiControls.menuMath.SetImage("icons8_keyboard_96_W_48x48"); guiControls.menuMath.OnClick((object s, EventArgs e) => { MenuClicked(guiControls.menuMath); }); guiControls.menuMath.autoClose = true; guiControls.menuMath.ClearMenuItems(); const int mathColumns = 5; const int mathRows = 8; var mathItems = new KButton[mathColumns, mathRows]; int im = 0; int jm = 0; foreach (string symbol in SharedAssets.symbols) { string menuSelection = symbol; KButton menuItem = guiControls.menuMath.NewMenuItemButton(); menuItem.SetText(symbol); menuItem.OnClick((object s, EventArgs e) => { ItemClicked(guiControls.menuMath, menuItem, false); // handle the selection graphical feedback SelectMath(guiControls.menuMath, menuItem, menuSelection); // handle storing the menuSelection value }); if (jm >= mathRows) { jm = 0; im++; } if (im < mathColumns) { mathItems[im, jm] = menuItem; } jm++; } guiControls.menuMath.AddMenuGrid(mathItems); guiControls.menuMath.Visible(true); guiControls.menuMath.Enabled(true); }
private void RebuildPreinstalledButtons() { foreach (string preinstalledLanguage in Localization.PreinstalledLanguages) { if (!(preinstalledLanguage != Localization.DEFAULT_LANGUAGE_CODE) || File.Exists(Localization.GetPreinstalledLocalizationFilePath(preinstalledLanguage))) { GameObject gameObject = Util.KInstantiateUI(languageButtonPrefab, preinstalledLanguagesContainer, false); gameObject.name = preinstalledLanguage + "_button"; HierarchyReferences component = gameObject.GetComponent <HierarchyReferences>(); LocText reference = component.GetReference <LocText>("Title"); reference.text = Localization.GetPreinstalledLocalizationTitle(preinstalledLanguage); reference.enabled = false; reference.enabled = true; Texture2D preinstalledLocalizationImage = Localization.GetPreinstalledLocalizationImage(preinstalledLanguage); if ((UnityEngine.Object)preinstalledLocalizationImage != (UnityEngine.Object)null) { Image reference2 = component.GetReference <Image>("Image"); reference2.sprite = Sprite.Create(preinstalledLocalizationImage, new Rect(Vector2.zero, new Vector2((float)preinstalledLocalizationImage.width, (float)preinstalledLocalizationImage.height)), Vector2.one * 0.5f); } KButton component2 = gameObject.GetComponent <KButton>(); component2.onClick += delegate { ConfirmLanguageChoiceDialog((!(preinstalledLanguage != Localization.DEFAULT_LANGUAGE_CODE)) ? string.Empty : preinstalledLanguage, PublishedFileId_t.Invalid); }; buttons.Add(gameObject); } } }
// Noise menu private void NoiseMenu() { guiControls.menuNoise.SetImage(ImageOfNoise(Noise.None)); guiControls.menuNoise.OnClick((object s, EventArgs e) => { MenuClicked(guiControls.menuNoise); }); guiControls.menuNoise.autoClose = true; guiControls.menuNoise.ClearMenuItems(); KButton headNoiseItem = guiControls.menuNoise.NewMenuSection(); headNoiseItem.SetText(" LNA"); guiControls.menuNoise.AddMenuItem(headNoiseItem); guiControls.menuNoise.AddSeparator(); foreach (Noise noise in Gui.noise) { Noise menuSelection = noise; KButton menuItem = guiControls.menuNoise.NewMenuItemButton(); if (menuSelection == Noise.None) // initialize default selection { ItemSelected(guiControls.menuNoise, menuItem); // handle the selection graphical feedback InitSelectNoise(guiControls.menuNoise, menuSelection); // handle storing the menuSelection value } menuItem.SetImage(ImageOfNoise(noise)); menuItem.OnClick((object s, EventArgs e) => { ItemClicked(guiControls.menuNoise, menuItem, true); // handle the selection graphical feedback SelectNoise(guiControls.menuNoise, menuItem, menuSelection); // handle storing the menuSelection value }); guiControls.menuNoise.AddMenuItem(menuItem); } guiControls.menuNoise.Visible(true); guiControls.menuNoise.Enabled(true); }
internal MoreModActions() { actionsScreen = null; buttonFirst = buttonUp = buttonLast = buttonDown = buttonUnsub = null; buttonManage = null; callingButton = null; callHandler = null; }
private void SelectDuplicant(KButton btn) { if (this.OnDuplicantSelected != null) { this.OnDuplicantSelected(buttonIdentityMap[btn]); } Close(); }
void OnClickBtn(KButton btn_) { m_clickCnt++; if (m_clickCnt >= m_clickCntMax) { Close(); } Log.Debug("OnClickBtn " + m_clickCnt, this); }
private void SetHeaderButtonActive(KButton headerButton, bool activeState) { ImageToggleState component = headerButton.GetComponent <ImageToggleState>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.SetActiveState(activeState); } }
public static void ItemSelected(KFlyoutMenu menu, KButton menuItem) { if (menu.selectedItem != null) { menu.selectedItem.Selected(false); } menu.selectedItem = menuItem; menuItem.Selected(true); }
protected override void OnSpawn() { base.OnSpawn(); // One long linear row var panel = new PPanel("MoreModActions") { BackColor = PUITuning.Colors.DialogDarkBackground, Spacing = 6, BackImage = PUITuning.Images.BoxBorder, ImageMode = Image.Type.Sliced, Direction = PanelDirection.Horizontal, Margin = new RectOffset(6, 6, 6, 6) }.AddChild(MakeButton("MoveToFirst", UI.TOOLTIPS.DNI_TOP, SpriteRegistry.GetTopIcon(), OnMoveFirst, (obj) => buttonFirst = obj.GetComponent <KButton>())) .AddChild(MakeButton("MoveUpTen", UI.TOOLTIPS.DNI_UP, Assets.GetSprite("icon_priority_up_2"), OnMoveUp, (obj) => buttonUp = obj.GetComponent <KButton>())) .AddChild(MakeButton("MoveDownTen", UI.TOOLTIPS.DNI_DOWN, Assets.GetSprite("icon_priority_down_2"), OnMoveDown, (obj) => buttonDown = obj.GetComponent <KButton>())) .AddChild(MakeButton("MoveToLast", UI.TOOLTIPS.DNI_BOTTOM, SpriteRegistry.GetBottomIcon(), OnMoveLast, (obj) => buttonLast = obj.GetComponent <KButton>())) .AddChild(new PButton("ManageMod") { Text = UI.MODSSCREEN.BUTTON_SUBSCRIPTION, DynamicSize = false, OnClick = OnManage, ToolTip = "Manage Mod", Margin = DebugUtils.BUTTON_MARGIN }.SetKleiBlueStyle().AddOnRealize((obj) => buttonManage = obj)) .AddChild(new PButton("UnsubMod") { Text = UI.MODSSCREEN.BUTTON_UNSUB, DynamicSize = false, OnClick = OnUnsub, ToolTip = UI.TOOLTIPS.DNI_UNSUB, Margin = DebugUtils. BUTTON_MARGIN }.SetKleiBlueStyle().AddOnRealize((obj) => buttonUnsub = obj. GetComponent <KButton>())); #if DEBUG panel.AddChild(new PButton("ModifyMod") { Text = UI.MODSSCREEN.BUTTON_MODIFY, DynamicSize = false, OnClick = OnModify, ToolTip = UI.TOOLTIPS.DNI_MODIFY, Margin = DebugUtils. BUTTON_MARGIN }.SetKleiPinkStyle().AddOnRealize((obj) => buttonModify = obj. GetComponent <KButton>())); #endif var actionsObj = panel.AddTo(gameObject); #if DEBUG PButton.SetButtonEnabled(buttonModify.gameObject, false); #endif actionsObj.SetActive(false); // Blacklist from auto layout actionsObj.AddOrGet <LayoutElement>().ignoreLayout = true; PUIElements.SetAnchors(actionsObj, PUIAnchoring.End, PUIAnchoring.Center); unsubCaller = new CallResult <RemoteStorageUnsubscribePublishedFileResult_t>( OnUnsubComplete); actionsScreen = actionsObj.AddComponent <ModActionsScreen>(); callingButton = null; }
public FilterManager(TMP_InputField search, KButton button) { if (search == null || button == null) { throw new ArgumentException("[ModsFilter] null search field or clear button!"); } _search = search; _clearSearchButton = button; }
public ButtonInfo(string text, GameObject visualizer, Action shortcutKey, UnityAction onClick, HoverCallback onHover = null, object userData = null) { this.text = text; this.shortcutKey = shortcutKey; this.onClick = onClick; this.onHover = onHover; this.visualizer = visualizer; this.userData = userData; uibutton = null; }
public void SetSelection(string name) { if (!this.namedControls.ContainsKey(name)) { return; } KButton control = this.namedControls[name]; KControls.ItemSelected(this, control); }
/// <summary> /// Applied after Refresh runs. /// </summary> internal static void Postfix(ReportManager.DailyReport ___currentReport, KButton ___prevButton) { int prevDay = ___currentReport.day - 1; if (ReportManager.Instance.FindReport(prevDay) == null) { // Do not allow previous day if it cannot be found ___prevButton.isInteractable = false; } }
void OnClickBtn(KButton btn_) { if (btn_ == m_btnOk) { Log.Debug("Click OK", this); } else if (btn_ == m_btnClose) { Close(); } }
int m_clickCntMax = 3; //关闭需要的点击次数 public PopErrorReport() { m_popId = POP_ID.ERROR_REPORT; m_layerIdx = POP_LAYER_IDX.LAYER_TOP; ShowGameObject(); m_btn = GetChildByName <KButton>("Container_ErrorReport/Container_Panel/Button_Center"); m_text = GameObjUtil.FindChlid <KText>(m_btn.gameObject, "Label_Text"); }
private void KeyDown(KButton b) { if (b.active) //一直按着 { return; } b.downtime = Milliseconds(); b.active = true; b.wasPressed = true; }
private KButton MakeButton(ButtonInfo info) { KButton kButton = Util.KInstantiateUI <KButton>(buttonPrefab.gameObject, buttonParent, true); kButton.onClick += info.action; LocText componentInChildren = kButton.GetComponentInChildren <LocText>(); componentInChildren.text = info.text; componentInChildren.fontSize = (float)info.fontSize; return(kButton); }
/// <summary> /// Hides the mod actions popup. /// </summary> internal void HidePopup() { if (actionsScreen != null) { callingButton = null; actionsScreen.SetActive(false); actionsScreen.Index = -1; actionsScreen.Mod = null; // Prevent from being destroyed too early actionsScreen.transform.SetParent(transform); } }