private void SelectDiseaseOption(int diseaseIdx) { if (diseaseIdx == 255) { diseaseButton.GetComponentInChildren <LocText>().text = "None"; } else { string name = Db.Get().Diseases[diseaseIdx].Name; diseaseButton.GetComponentInChildren <LocText>().text = name; } }
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; }
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); }
public static KButton MakeKButton(ButtonInfo info, GameObject buttonPrefab, GameObject parent, int index = 0) { KButton kbutton = Util.KInstantiateUI <KButton>(buttonPrefab, parent, true); kbutton.onClick += info.action; kbutton.transform.SetSiblingIndex(index); LocText componentInChildren = kbutton.GetComponentInChildren <LocText>(); componentInChildren.text = info.text; componentInChildren.fontSize = info.fontSize; return(kbutton); }
public void Apply(Chore.Precondition.Context context) { ChoreConsumer consumer = context.consumerState.consumer; if (targetChore != context.chore || !object.ReferenceEquals(context.chore.target, lastChoreTarget) || !(context.chore.masterPriority == lastPrioritySetting)) { targetChore = context.chore; lastChoreTarget = context.chore.target; lastPrioritySetting = context.chore.masterPriority; string choreName = GameUtil.GetChoreName(context.chore, context.data); string text = GameUtil.ChoreGroupsForChoreType(context.chore.choreType); string text2 = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.CHORE_TARGET; text2 = text2.Replace("{Target}", (!((Object)context.chore.target.gameObject == (Object)consumer.gameObject)) ? context.chore.target.gameObject.GetProperName() : UI.UISIDESCREENS.MINIONTODOSIDESCREEN.SELF_LABEL.text); if (text != null) { text2 = text2.Replace("{Groups}", text); } string text3 = (context.chore.masterPriority.priority_class != 0) ? string.Empty : context.chore.masterPriority.priority_value.ToString(); Sprite sprite = (context.chore.masterPriority.priority_class != 0) ? null : prioritySprites[context.chore.masterPriority.priority_value - 1]; ChoreGroup choreGroup = BestPriorityGroup(context, consumer); icon.sprite = ((choreGroup == null) ? null : Assets.GetSprite(choreGroup.sprite)); label.SetText(choreName); subLabel.SetText(text2); priorityLabel.SetText(text3); priorityIcon.sprite = sprite; moreLabel.text = string.Empty; GetComponent <ToolTip>().SetSimpleTooltip(TooltipForChore(context, consumer)); KButton componentInChildren = GetComponentInChildren <KButton>(); componentInChildren.ClearOnClick(); if ((Object)componentInChildren.bgImage != (Object)null) { componentInChildren.bgImage.colorStyleSetting = ((!((Object)context.chore.driver == (Object)consumer.choreDriver)) ? buttonColorSettingStandard : buttonColorSettingCurrent); componentInChildren.bgImage.ApplyColorStyleSetting(); } GameObject gameObject = context.chore.target.gameObject; componentInChildren.ClearOnPointerEvents(); componentInChildren.GetComponentInChildren <KButton>().onClick += delegate { if (context.chore != null && !context.chore.target.isNull) { Vector3 position = context.chore.target.gameObject.transform.position; float x = position.x; Vector3 position2 = context.chore.target.gameObject.transform.position; float y = position2.y + 1f; Vector3 position3 = CameraController.Instance.transform.position; Vector3 pos = new Vector3(x, y, position3.z); CameraController.Instance.SetTargetPos(pos, 10f, true); } }; } }
private void ConfigButtons() { closeButton.ClearOnClick(); closeButton.onClick += delegate { Show(false); }; viewOtherColoniesButton.ClearOnClick(); viewOtherColoniesButton.onClick += delegate { ToggleExplorer(true); }; quitToMainMenuButton.ClearOnClick(); quitToMainMenuButton.onClick += delegate { ConfirmDecision(UI.FRONTEND.MAINMENU.QUITCONFIRM, OnQuitConfirm); }; closeScreenButton.ClearOnClick(); closeScreenButton.onClick += delegate { Show(false); }; viewOtherColoniesButton.gameObject.SetActive(false); if ((UnityEngine.Object)Game.Instance != (UnityEngine.Object)null) { closeScreenButton.gameObject.SetActive(true); closeScreenButton.GetComponentInChildren <LocText>().SetText(UI.RETIRED_COLONY_INFO_SCREEN.BUTTONS.RETURN_TO_GAME); quitToMainMenuButton.gameObject.SetActive(true); } else { closeScreenButton.gameObject.SetActive(true); closeScreenButton.GetComponentInChildren <LocText>().SetText(UI.RETIRED_COLONY_INFO_SCREEN.BUTTONS.CLOSE); quitToMainMenuButton.gameObject.SetActive(false); } }
public void Open() { base.gameObject.SetActive(true); buttonPool.ClearAll(); foreach (MinionIdentity item in Components.MinionIdentities.Items) { KButton btn = buttonPool.GetFreeElement(buttonParent, true); CrewPortrait componentInChildren = btn.GetComponentInChildren <CrewPortrait>(); componentInChildren.SetIdentityObject(item, true); portraitList.Add(componentInChildren); btn.ClearOnClick(); btn.onClick += delegate { SelectDuplicant(btn); }; buttonIdentityMap.Add(btn, item); } }
private void Bind(KKeyCode kkey_code, Modifier modifier) { BindingEntry bindingEntry = new BindingEntry(screens[activeScreen], GamepadButton.NumButtons, kkey_code, modifier, actionToRebind, true, ignoreRootConflicts); int num = 0; while (true) { if (num >= GameInputMapping.KeyBindings.Length) { return; } BindingEntry bindingEntry2 = GameInputMapping.KeyBindings[num]; if (bindingEntry2.mRebindable && bindingEntry2.mAction == actionToRebind) { break; } num++; } BindingEntry duplicatedBinding = GetDuplicatedBinding(screens[activeScreen], bindingEntry); GameInputMapping.KeyBindings[num] = bindingEntry; LocText componentInChildren = activeButton.GetComponentInChildren <LocText>(); componentInChildren.text = GetBindingText(bindingEntry); if (duplicatedBinding.mAction != 0 && duplicatedBinding.mAction != actionToRebind) { confirmDialog = Util.KInstantiateUI(confirmPrefab.gameObject, base.transform.gameObject, false).GetComponent <ConfirmDialogScreen>(); string key = "STRINGS.INPUT_BINDINGS." + duplicatedBinding.mGroup.ToUpper() + "." + duplicatedBinding.mAction.ToString().ToUpper(); string arg = Strings.Get(key); string bindingText = GetBindingText(duplicatedBinding); string text = string.Format(UI.FRONTEND.INPUT_BINDINGS_SCREEN.DUPLICATE, arg, bindingText); Unbind(duplicatedBinding.mAction); confirmDialog.PopupConfirmDialog(text, null, null, null, null, null, null, null, null, true); confirmDialog.gameObject.SetActive(true); } Global.Instance.GetInputManager().RebindControls(); waitingForKeyPress = false; actionToRebind = Action.NumActions; activeButton = null; BuildDisplay(); }
private void AddExistingMod(string filename) { KButton freeElement = this.saveButtonPool.GetFreeElement(this.saveButtonRoot, true); freeElement.ClearOnClick(); LocText componentInChildren = freeElement.GetComponentInChildren <LocText>(); System.DateTime lastWriteTime = File.GetLastWriteTime(filename); componentInChildren.text = string.Format("{0}\n{1:H:mm:ss}\n" + Localization.GetFileDateFormat(1), Path.GetFileNameWithoutExtension(filename), lastWriteTime); freeElement.onClick += delegate { this.onClick(filename); }; bool flag = false; try { SaveGame.Header header; flag = (SaveLoader.LoadHeader(filename, out header).saveMajorVersion >= 7); } catch (Exception ex) { global::Debug.LogWarning("Corrupted save file: " + filename + "\n" + ex.ToString(), null); } if (flag) { freeElement.onDoubleClick += delegate { this.onClick(filename); this.DoLoad(); }; } ImageToggleState component = freeElement.GetComponent <ImageToggleState>(); component.colorStyleSetting = ((!flag) ? this.invalidSaveFileStyle : this.validSaveFileStyle); component.RefreshColorStyle(); component.SetState(ImageToggleState.State.Inactive); component.ResetColor(); freeElement.transform.SetAsLastSibling(); this.fileButtonMap.Add(filename, freeElement); }
protected override void OnSpawn() { base.OnSpawn(); title.SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.TITLE); originalSettings = CaptureSettings(); applyButton.isInteractable = false; applyButton.onClick += OnApply; applyButton.GetComponentInChildren <LocText>().SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.APPLYBUTTON); doneButton.onClick += OnDone; closeButton.onClick += OnDone; doneButton.GetComponentInChildren <LocText>().SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.DONE_BUTTON); resolutionDropdown.ClearOptions(); BuildOptions(); resolutionDropdown.options = options; resolutionDropdown.onValueChanged.AddListener(OnResolutionChanged); fullscreenToggle.ChangeState(Screen.fullScreen ? 1 : 0); MultiToggle multiToggle = fullscreenToggle; multiToggle.onClick = (System.Action)Delegate.Combine(multiToggle.onClick, new System.Action(OnFullscreenToggle)); fullscreenToggle.GetComponentInChildren <LocText>().SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.FULLSCREEN); resolutionDropdown.transform.parent.GetComponentInChildren <LocText>().SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.RESOLUTION); if (fullscreenToggle.CurrentState == 1) { int resolutionIndex = GetResolutionIndex(originalSettings.resolution); if (resolutionIndex != -1) { resolutionDropdown.value = resolutionIndex; } } CanvasScalers = UnityEngine.Object.FindObjectsOfType <KCanvasScaler>(); UpdateSliderLabel(); uiScaleSlider.onValueChanged.AddListener(delegate { sliderLabel.text = uiScaleSlider.value + "%"; }); uiScaleSlider.onReleaseHandle += delegate { UpdateUIScale(uiScaleSlider.value); }; }
public void Activate(int itemIdx, int previouslyActiveTabIdx) { int childCount = base.transform.childCount; if (itemIdx < childCount) { for (int i = 0; i < childCount; i++) { Transform child = base.transform.GetChild(i); if (child.gameObject.activeSelf) { KButton componentInChildren = child.GetComponentInChildren <KButton>(); if ((Object)componentInChildren != (Object)null) { Text componentInChildren2 = componentInChildren.GetComponentInChildren <Text>(); if ((Object)componentInChildren2 != (Object)null && i == itemIdx) { ActivateTabArtwork(itemIdx); } } KToggle component = child.GetComponent <KToggle>(); if ((Object)component != (Object)null) { ActivateTabArtwork(itemIdx); if (i == itemIdx) { component.Select(); } else { component.Deselect(); } } } } } }
private void UpdateState(object data) { requestSelectedEntityBtn.ClearOnClick(); if (!((Object)targetReceptacle == (Object)null)) { if (CheckReceptacleOccupied()) { Uprootable uprootable = targetReceptacle.Occupant.GetComponent <Uprootable>(); if ((Object)uprootable != (Object)null && uprootable.IsMarkedForUproot) { requestSelectedEntityBtn.onClick += delegate { uprootable.ForceCancelUproot(null); UpdateState(null); }; requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringCancelRemove).ToString(); requestSelectedEntityBtn.isInteractable = true; subtitleLabel.SetText(string.Format(Strings.Get(subtitleStringAwaitingRemoval).ToString(), targetReceptacle.Occupant.GetProperName())); } else { requestSelectedEntityBtn.onClick += delegate { targetReceptacle.OrderRemoveOccupant(); UpdateState(null); }; requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringRemove).ToString(); requestSelectedEntityBtn.isInteractable = true; subtitleLabel.SetText(string.Format(Strings.Get(subtitleStringEntityDeposited).ToString(), targetReceptacle.Occupant.GetProperName())); } ToggleObjectPicker(false); Tag tag = targetReceptacle.Occupant.GetComponent <KSelectable>().PrefabID(); ConfigureActiveEntity(tag); SetResultDescriptions(targetReceptacle.Occupant); } else if (targetReceptacle.GetActiveRequest != null) { requestSelectedEntityBtn.onClick += delegate { targetReceptacle.CancelActiveRequest(); ClearSelection(); UpdateAvailableAmounts(null); UpdateState(null); }; requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringCancelDeposit).ToString(); requestSelectedEntityBtn.isInteractable = true; ToggleObjectPicker(false); ConfigureActiveEntity(targetReceptacle.GetActiveRequest.tags[0]); GameObject prefab = Assets.GetPrefab(targetReceptacle.GetActiveRequest.tags[0]); if ((Object)prefab != (Object)null) { subtitleLabel.SetText(string.Format(Strings.Get(subtitleStringAwaitingDelivery).ToString(), prefab.GetProperName())); SetResultDescriptions(prefab); } } else if ((Object)selectedEntityToggle != (Object)null) { requestSelectedEntityBtn.onClick += delegate { targetReceptacle.CreateOrder(selectedDepositObjectTag); UpdateAvailableAmounts(null); UpdateState(null); }; requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringDeposit).ToString(); targetReceptacle.SetPreview(depositObjectMap[selectedEntityToggle].tag, false); bool flag = CanDepositEntity(depositObjectMap[selectedEntityToggle]); requestSelectedEntityBtn.isInteractable = flag; SetImageToggleState(selectedEntityToggle.toggle, (!flag) ? ImageToggleState.State.DisabledActive : ImageToggleState.State.Active); ToggleObjectPicker(true); GameObject prefab2 = Assets.GetPrefab(selectedDepositObjectTag); if ((Object)prefab2 != (Object)null) { subtitleLabel.SetText(string.Format(Strings.Get(subtitleStringAwaitingSelection).ToString(), prefab2.GetProperName())); SetResultDescriptions(prefab2); } } else { requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringDeposit).ToString(); requestSelectedEntityBtn.isInteractable = false; ToggleObjectPicker(true); } UpdateAvailableAmounts(null); UpdateListeners(); } }
public void OnSelect_SUBMIT() { submitButton.GetComponentInChildren <LocText>().text = UI.CRASHSCREEN.REPORTING; submitButton.GetComponent <KButton>().isInteractable = false; StartCoroutine(WaitForUIUpdateBeforeReporting()); }
public static void SetText(this KButton button, LocString text) { button.GetComponentInChildren <LocText>().SetText(text); }
private void OnSelectElement(string str, int index) { element = (SimHashes)Enum.Parse(typeof(SimHashes), options_list[index]); elementButton.GetComponentInChildren <LocText>().text = str; }