// Use this for initialization void Start() { BuildModeController bmc = GameObject.FindObjectOfType <BuildModeController>(); // For each furniture prototype in our world, create one instance // of the button to be clicked foreach (string s in World.Current.furniturePrototypes.Keys) { GameObject go = (GameObject)Instantiate(buildFurnitureButtonPrefab); go.transform.SetParent(this.transform); string objectId = s; string objectName = World.Current.furniturePrototypes[s].Name; go.name = "Button - Build " + objectId; go.transform.GetComponentInChildren <TextLocalizer>().formatValues = new string[] { LocalizationTable.GetLocalization(World.Current.furniturePrototypes[s].LocalizationCode) }; Button b = go.GetComponent <Button>(); b.onClick.AddListener(delegate { bmc.SetMode_BuildFurniture(objectId); }); } lastLanguage = LocalizationTable.currentLanguage; }
/** * <summary> * Updates the text with the given text and formatValues. * * This method is called differently due to params in the UpdateText(..) method * that might confuse the compiler. * </summary> * * <para> * string text: The *new* defaultText. * </para> * <para> * params string[] formatValues: The values that should be inserted into {0}, {1}, etc. * </para> */ public void UpdateTextCustom(string text, params string[] formatValues) { lastLanguage = LocalizationTable.currentLanguage; this.formatValues = formatValues; defaultText = text; this.text.text = LocalizationTable.GetLocalization(text, formatValues); }
public override GameObject InitializeElement() { // Note this is just from playing around and finding a nice value GameObject element = GetVerticalBaseElement("Slider", 200, 20, TextAnchor.MiddleLeft, 0, 40); textElement = CreateText(string.Format(format, getValue()) + LocalizationTable.GetLocalization(option.name), true, TextAnchor.MiddleCenter, false); textElement.transform.SetParent(element.transform); float minValue = this.parameterData.ContainsKey("MinimumValue") ? this.parameterData["MinimumValue"].ToFloat() : 0; float maxValue = this.parameterData.ContainsKey("MaximumValue") ? this.parameterData["MaximumValue"].ToFloat() : 1; bool wholeNumbers = this.parameterData.ContainsKey("WholeNumbers") ? this.parameterData["WholeNumbers"].ToBool() : false; sliderElement = CreateSlider(getValue(), new Vector2(minValue, maxValue), wholeNumbers); sliderElement.transform.SetParent(element.transform); sliderElement.onValueChanged.AddListener( (float v) => { if (v != value) { valueChanged = true; textElement.text = string.Format(format, v) + LocalizationTable.GetLocalization(option.name); value = v; } }); sliderElement.onValueChanged.Invoke(sliderElement.value); return(element); }
public IEnumerable <ContextMenuAction> GetContextMenuActions(ContextMenu contextMenu) { if (PendingBuildJobs != null) { foreach (Job pendingJob in PendingBuildJobs) { yield return(new ContextMenuAction { LocalizationKey = LocalizationTable.GetLocalization("cancel_job", pendingJob.GetName()), RequireCharacterSelected = false, Action = (cm, c) => { pendingJob.CancelJob(); } }); if (!pendingJob.IsBeingWorked) { yield return(new ContextMenuAction { LocalizationKey = LocalizationTable.GetLocalization("prioritize", pendingJob.GetName()), RequireCharacterSelected = true, Action = (cm, c) => { c.PrioritizeJob(pendingJob); } }); } } } }
public virtual IEnumerable <string> GetAdditionalInfo() { foreach (string stat in Stats.Keys) { yield return(LocalizationTable.GetLocalization("stat_" + stat.ToLower(), Stats[stat].Value)); } }
protected override void Start() { base.Start(); Text title = GetComponentInChildren <Text>(); title.text = LocalizationTable.GetLocalization("menu_construction"); menuLeft = this.transform.GetComponentInParent <MenuLeft>(); this.transform.Find("Close Button").GetComponent <Button>().onClick.AddListener(delegate { menuLeft.CloseCurrentMenu(); }); RenderRoomBehaviorButtons(); RenderTileButtons(); RenderFurnitureButtons(); RenderUtilityButtons(); InputField filterField = GetComponentInChildren <InputField>(); filterField.onValueChanged.AddListener(delegate { FilterTextChanged(filterField.text); }); KeyboardManager.Instance.RegisterModalInputField(filterField); }
private void Update() { if (currentWait == 5) { currentWait = 0; while (JobList.childCount > 0) { Transform c = JobList.GetChild(0); c.SetParent(null); Destroy(c.gameObject); } // Localization string[] formatValues; formatValues = new string[0]; foreach (Character c in World.Current.characters) { GameObject go = (GameObject)Instantiate(JobListItemPrefab, JobList); go.GetComponentInChildren <Text>().text = c.GetName() + " - " + LocalizationTable.GetLocalization(c.GetJobDescription(), formatValues); } JobList.GetComponentInParent <ScrollRect>().scrollSensitivity = JobList.childCount / 2; } else { currentWait += 1; } }
// Update is called once per frame void Update() { if (mc.mySelection == null) { canvasGroup.alpha = 0; canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; return; } canvasGroup.alpha = 1; canvasGroup.interactable = true; canvasGroup.blocksRaycasts = true; ISelectable actualSelection = mc.mySelection.GetSelectedStuff(); if (actualSelection.GetType() == typeof(Character)) { txt.text = actualSelection.GetName() + "\n" + actualSelection.GetDescription() + "\n" + actualSelection.GetHitPointString() + "\n" + LocalizationTable.GetLocalization(actualSelection.GetJobDescription()); //TODO: Change the hitpoint stuff. } else { txt.text = LocalizationTable.GetLocalization(actualSelection.GetName()) + "\n" + LocalizationTable.GetLocalization(actualSelection.GetDescription()) + "\n" + actualSelection.GetHitPointString(); //TODO: Change the hitpoint stuff. } }
public override void ShowDialog() { base.ShowDialog(); // Localization string[] formatValues; formatValues = new string[0]; int i = 0; foreach (Character character in World.Current.CharacterManager) { GameObject go = Instantiate(JobListItemPrefab, JobList); string jobDescription = LocalizationTable.GetLocalization(character.GetJobDescription(), formatValues); go.GetComponentInChildren <Text>().text = string.Format("<b>{0}</b> - {1}", character.GetName(), jobDescription); JobListItem listItem = go.GetComponent <JobListItem>(); listItem.character = character; listItem.currentColor = i % 2 == 0 ? ListPrimaryColor : ListSecondaryColor; go.GetComponent <Image>().color = listItem.currentColor; i++; } JobList.GetComponentInParent <ScrollRect>().scrollSensitivity = JobList.childCount / 2; JobList.GetComponent <AutomaticVerticalSize>().AdjustSize(); }
public override IEnumerable <string> GetDescription() { string powerColor = IsRunning ? "lime" : "red"; string status = IsRunning ? "online" : "offline"; yield return(LocalizationTable.GetLocalization("fluid_grid_status_" + status, powerColor)); // Debugging info, should be removed yield return("Fluid Type: " + SubType); if (IsConsumer && Requires != null) { yield return(LocalizationTable.GetLocalization("fluid_input_status", powerColor, Requires.Rate)); } if (IsProducer && Requires != null) { yield return(LocalizationTable.GetLocalization("fluid_output_status", powerColor, Requires.Rate)); } if (IsStorage && Provides != null) { yield return(LocalizationTable.GetLocalization("fluid_accumulated_fraction", StoredAmount, Provides.Capacity)); } }
public override IEnumerable <string> GetDescription() { string powerColor = IsConnected ? "lime" : "red"; string status = IsConnected ? "connected" : "not connected"; yield return(string.Format("Power grid: <color={0}>{1}</color>", powerColor, status)); // TODO: localization if (IsConsumer) { yield return(LocalizationTable.GetLocalization("power_input_status", powerColor, Requires.Rate)); if (Requires.CanUseVariableEfficiency && IsRunning) { yield return(string.Format("Electricity: {0:0}%", Efficiency * 100)); // TODO: localization } } if (IsProducer) { if (OutputCanVary) { status = OutputIsNeeded ? "demand" : "idle"; yield return(string.Format("Status: {0}", status)); // TODO: localization } else { yield return(LocalizationTable.GetLocalization("power_output_status", powerColor, Provides.Rate)); } } if (IsStorage) { yield return(LocalizationTable.GetLocalization("power_accumulated_fraction", StoredAmount, Provides.Capacity)); } }
/// <summary> /// Gets the Context Menu Actions. /// </summary> /// <param name="contextMenu">The context menu to check for actions.</param> /// <returns>Context menu actions.</returns> public IEnumerable <ContextMenuAction> GetContextMenuActions(ContextMenu contextMenu) { yield return(new ContextMenuAction { LocalizationKey = LocalizationTable.GetLocalization("deconstruct", LocalizationCode), RequireCharacterSelected = false, Action = (contextMenuAction, character) => Deconstruct(this) }); foreach (ContextMenuLuaAction contextMenuLuaAction in contextMenuLuaActions) { if (!contextMenuLuaAction.DevModeOnly || SettingsKeyHolder.DeveloperMode) { // TODO The Action could be done via a lambda, but it always uses the same space of memory, thus if 2 actions are performed, the same action will be produced for each. yield return(new ContextMenuAction { LocalizationKey = contextMenuLuaAction.LocalizationKey, RequireCharacterSelected = contextMenuLuaAction.RequireCharacterSelected, Action = InvokeContextMenuLuaAction, Parameter = contextMenuLuaAction.LuaFunction // Note that this is only in place because of the problem with the previous statement. }); } } }
protected Text CreateText(string withText, bool autoFit = false, TextAnchor alignment = TextAnchor.MiddleLeft, bool localize = true) { if (loadedResources.ContainsKey("Text") == false) { loadedResources["Text"] = Resources.Load <GameObject>("UI/Elements/Text"); } Text text = GameObject.Instantiate(loadedResources["Text"]).GetComponent <Text>(); if (localize) { text.text = LocalizationTable.GetLocalization(withText); } else { text.text = withText; } text.alignment = alignment; if (autoFit == true) { text.gameObject.AddComponent <TextScaling>(); } return(text); }
public override GameObject InitializeElement() { // Note this is just from playing around and finding a nice value GameObject element = GetVerticalBaseElement("Slider", 200, 20, TextAnchor.MiddleLeft, 0, 40); format = "({0:00}) "; textElement = CreateText(string.Format(format, getValue()) + LocalizationTable.GetLocalization(option.name), true, TextAnchor.MiddleCenter); textElement.transform.SetParent(element.transform); sliderElement = CreateSlider(getValue(), new Vector2(0, 1), false); sliderElement.transform.SetParent(element.transform); sliderElement.onValueChanged.AddListener( (float v) => { if (v != value) { valueChanged = true; textElement.text = string.Format(format, v) + LocalizationTable.GetLocalization(option.name); value = v; } }); sliderElement.onValueChanged.Invoke(sliderElement.value); return(element); }
public string GetDescription() { string needText = ""; foreach (Need n in needs) { needText += "\n" + LocalizationTable.GetLocalization(n.localisationID, n.DisplayAmount); } return("A human astronaut." + needText); }
/// <summary> /// Gets the Context Menu Actions. /// </summary> /// <param name="contextMenu">The context menu to check for actions.</param> /// <returns>Context menu actions.</returns> public IEnumerable <ContextMenuAction> GetContextMenuActions(ContextMenu contextMenu) { if (CommandSettings.DeveloperModeToggle == true || HasTypeTag("Non-deconstructible") == false) { yield return(new ContextMenuAction { LocalizationKey = LocalizationTable.GetLocalization("deconstruct_furniture", LocalizationCode), RequireCharacterSelected = false, Action = (ca, c) => SetDeconstructJob() }); } for (int i = 0; i < Jobs.Count; i++) { if (!Jobs[i].IsBeingWorked) { yield return(new ContextMenuAction { LocalizationKey = LocalizationTable.GetLocalization("prioritize_furniture", LocalizationCode), RequireCharacterSelected = true, Action = (ca, c) => c.PrioritizeJob(Jobs[0]) }); } } // check for context menus of components foreach (BuildableComponent component in components) { List <ContextMenuAction> componentContextMenu = component.GetContextMenu(); if (componentContextMenu != null) { foreach (ContextMenuAction compContextMenuAction in componentContextMenu) { yield return(compContextMenuAction); } } } foreach (ContextMenuLuaAction contextMenuLuaAction in contextMenuLuaActions) { if (!contextMenuLuaAction.DevModeOnly || CommandSettings.DeveloperModeToggle) { // TODO The Action could be done via a lambda, but it always uses the same space of memory, thus if 2 actions are performed, the same action will be produced for each. yield return(new ContextMenuAction { LocalizationKey = contextMenuLuaAction.LocalizationKey, RequireCharacterSelected = contextMenuLuaAction.RequireCharacterSelected, Action = InvokeContextMenuLuaAction, Parameter = contextMenuLuaAction.LuaFunction // Note that this is only in place because of the problem with the previous statement. }); } } }
/// <summary> /// Builds the interface. /// </summary> public void BuildInterface() { if (Action.LocalizationParameter == null) { text.text = LocalizationTable.GetLocalization(Action.LocalizationKey); } else { text.text = LocalizationTable.GetLocalization(Action.LocalizationKey, Action.LocalizationParameter); } }
public string GetName() { try { return(LocalizationTable.GetLocalization(PrototypeManager.Furniture.Get(Type.ToString()).GetName())); } catch { return(LocalizationTable.GetLocalization(Type)); } }
protected override string GetMouseOverString(Tile tile) { if (tile != null && tile.Furniture != null) { return(LocalizationTable.GetLocalization("furniture", tile.Furniture.Name)); } else { return(string.Empty); } }
protected override string GetMouseOverString(Tile tile) { string roomID = "N/A"; if (tile != null && tile.Room != null) { roomID = tile.Room.ID.ToString(); } return(LocalizationTable.GetLocalization("room_index", roomID)); }
/// <summary> /// Formats the text for health to be displayed by the Selection Panel. /// </summary> /// <returns>The newly formatted text.</returns> public string TextForSelectionPanel() { if (MaxHealth > 0) { return(LocalizationTable.GetLocalization("hit_points_fraction", currentHealth, MaxHealth)); } else { return(LocalizationTable.GetLocalization("hit_points", "not_applicable_shorthand")); } }
protected override string GetMouseOverString(Tile tile) { string tileType = "N/A"; if (tile != null) { tileType = tile.Type.ToString(); } string tileInfo = LocalizationTable.GetLocalization("tile_type", tileType); return(tileInfo); }
private GameObject CreateButtonGO(UnityEngine.Object buttonPrefab, string name, string localizationCode) { GameObject buttonGameObject = (GameObject)Instantiate(buttonPrefab); buttonGameObject.transform.SetParent(this.transform, false); buttonGameObject.name = "Button " + name; TextLocalizer textLocalizer = buttonGameObject.transform.GetComponentInChildren <TextLocalizer>(); textLocalizer.formatValues = new string[] { LocalizationTable.GetLocalization(localizationCode) }; textLocalizer.defaultText = localizationCode; return(buttonGameObject); }
// Update is called once per frame. private void Update() { if (lastLanguage != LocalizationTable.currentLanguage) { lastLanguage = LocalizationTable.currentLanguage; TextLocalizer[] localizers = GetComponentsInChildren <TextLocalizer>(); for (int i = 0; i < localizers.Length; i++) { localizers[i].UpdateText(LocalizationTable.GetLocalization(tileTypes[i].LocalizationCode)); } } }
public IEnumerable <string> GetAdditionalInfo() { yield return(health.TextForSelectionPanel()); foreach (Need n in Needs) { yield return(LocalizationTable.GetLocalization(n.LocalisationID, n.DisplayAmount)); } foreach (Stat stat in stats.Values) { yield return(LocalizationTable.GetLocalization("stat_" + stat.Type.ToLower(), stat.Value)); } }
public IEnumerable <string> GetAdditionalInfo() { yield return(health.TextForSelectionPanel()); foreach (Need n in Needs) { yield return(LocalizationTable.GetLocalization(n.LocalizationName, n.DisplayAmount)); } foreach (string stat in Stats.Keys) { yield return(LocalizationTable.GetLocalization("stat_" + stat.ToLower(), Stats[stat].Value)); } }
public string GetDescription() { string description = "Requirements:\n"; foreach (RequestedItem item in RequestedItems.Values) { description += string.Format("\t{0} {1}..{2}\n", item.Type, item.MinAmountRequested, item.MaxAmountRequested); // TODO: Not sure if this works or not. description = LocalizationTable.GetLocalization(description); } return(description); }
private void Update() { if (lastLanguage != LocalizationTable.currentLanguage) { lastLanguage = LocalizationTable.currentLanguage; TextLocalizer[] localizers = GetComponentsInChildren <TextLocalizer>(); for (int i = 0; i < localizers.Length; i++) { localizers[i].UpdateText(LocalizationTable.GetLocalization(World.current.furniturePrototypes.ElementAt(i).Value.GetName())); } } }
private void Update() { if (lastLanguage != LocalizationTable.currentLanguage) { lastLanguage = LocalizationTable.currentLanguage; TextLocalizer[] localizers = GetComponentsInChildren <TextLocalizer>(); for (int i = 0; i < localizers.Length; i++) { localizers[i].UpdateText(LocalizationTable.GetLocalization(PrototypeManager.Furniture.GetPrototype(i).GetName())); } } }
protected Text CreateText(string withText, bool autoFit = false, TextAnchor alignment = TextAnchor.MiddleLeft) { Text text = GameObject.Instantiate(Resources.Load <GameObject>("UI/SettingsMenu/SettingsText")).GetComponent <Text>(); text.text = LocalizationTable.GetLocalization(withText); text.alignment = alignment; if (autoFit == true) { text.gameObject.AddComponent <TextScaling>(); } return(text); }