Esempio n. 1
0
 public static void RegisterLabel(Transform target, string translationKey, Color textColor, Color backgroundColor, NGUIText.Alignment alignment, UiTranslationOverlaySystem.CurrentViewOptions currentViewOption = UiTranslationOverlaySystem.CurrentViewOptions.AllowInWorld)
 {
     if (UiTranslationOverlaySystem.Instance && !UiTranslationOverlaySystem.Instance._activeLabels.ContainsKey(target) && UiTranslationDatabase.HasKey(translationKey))
     {
         string text = UiTranslationDatabase.TranslateKey(translationKey, string.Empty, false);
         if (!string.IsNullOrEmpty(text))
         {
             UiTranslationOverlayLabel uiTranslationOverlayLabel;
             if (UiTranslationOverlaySystem.Instance._labelPool.Count > 0)
             {
                 uiTranslationOverlayLabel = UiTranslationOverlaySystem.Instance._labelPool.Dequeue();
                 uiTranslationOverlayLabel.gameObject.SetActive(true);
                 UiTranslationOverlaySystem.Instance.SetIconHolderTr(uiTranslationOverlayLabel.transform, currentViewOption);
             }
             else
             {
                 uiTranslationOverlayLabel = UnityEngine.Object.Instantiate <UiTranslationOverlayLabel>(UiTranslationOverlaySystem.Instance._overlayLabelPrefab);
                 UiTranslationOverlaySystem.Instance.SetIconHolderTr(uiTranslationOverlayLabel.transform, currentViewOption);
                 uiTranslationOverlayLabel.transform.localScale = UiTranslationOverlaySystem.Instance._overlayLabelPrefab.transform.localScale;
             }
             uiTranslationOverlayLabel._label.text = text;
             bool flag = alignment != NGUIText.Alignment.Left;
             if (flag)
             {
                 if (uiTranslationOverlayLabel._label.pivot != UIWidget.Pivot.Center)
                 {
                     uiTranslationOverlayLabel._label.pivot = UIWidget.Pivot.Center;
                     uiTranslationOverlayLabel._label.transform.localPosition = Vector3.zero;
                     uiTranslationOverlayLabel._background.pivot = UIWidget.Pivot.Center;
                     uiTranslationOverlayLabel._background.transform.localPosition = new Vector3(0f, uiTranslationOverlayLabel._background.transform.localPosition.y, 0f);
                 }
             }
             else if (uiTranslationOverlayLabel._label.pivot != UIWidget.Pivot.Left)
             {
                 uiTranslationOverlayLabel._label.pivot = UIWidget.Pivot.Left;
                 uiTranslationOverlayLabel._label.transform.localPosition = Vector3.zero;
                 uiTranslationOverlayLabel._background.pivot = UIWidget.Pivot.Left;
                 uiTranslationOverlayLabel._background.transform.localPosition = new Vector3(-10f, uiTranslationOverlayLabel._background.transform.localPosition.y, 0f);
             }
             uiTranslationOverlayLabel._label.color         = textColor;
             uiTranslationOverlayLabel._background.color    = backgroundColor;
             uiTranslationOverlayLabel._follow._target      = target;
             uiTranslationOverlayLabel._follow._inBook      = (currentViewOption == UiTranslationOverlaySystem.CurrentViewOptions.AllowInBook);
             uiTranslationOverlayLabel._follow._inInventory = (currentViewOption == UiTranslationOverlaySystem.CurrentViewOptions.AllowInInventory);
             UiTranslationOverlaySystem.Instance._activeLabels.Add(target, uiTranslationOverlayLabel);
         }
     }
 }
Esempio n. 2
0
        public static string GetMappingFor(InputMappingIcons.Actions action)
        {
            if (TheForest.Utils.Input.IsGamePad)
            {
                return(InputMappingIcons.GamepadMappings[(int)action]);
            }
            string text = InputMappingIcons.KeyboardMappings[(int)action];

            if (text != null)
            {
                if (text == "Space")
                {
                    return(UiTranslationDatabase.TranslateKey("SPACE", "SPACE", true));
                }
            }
            return(InputMappingIcons.KeyboardMappings[(int)action]);
        }
Esempio n. 3
0
 public void RefreshName(List <Action <MpGameRow> > sortOptions)
 {
     if (this._previousPlayed)
     {
         this._continueButtonLabel.text = UiTranslationDatabase.TranslateKey("CONTINUE", "CONTINUE", false);
         if (!this._continueButtonLabel.transform.parent.gameObject.activeSelf)
         {
             this._continueButtonLabel.transform.parent.gameObject.SetActive(true);
         }
     }
     else if (this._continueButtonLabel.transform.parent.gameObject.activeSelf)
     {
         this._continueButtonLabel.transform.parent.gameObject.SetActive(false);
     }
     base.name = string.Empty;
     for (int i = 0; i < sortOptions.Count; i++)
     {
         sortOptions[i](this);
     }
     base.name += this._gameName.text;
 }
Esempio n. 4
0
		private void LoadStats()
		{
			string localSlotPath = SaveSlotUtils.GetLocalSlotPath(this._slot);
			string path = localSlotPath + "info";
			if (!File.Exists(localSlotPath + "__RESUME__"))
			{
				this._labelSlot.text = UiTranslationDatabase.TranslateKey("SLOT_" + this._slotNum, "Slot " + this._slotNum, false);
				if (this._labelStat)
				{
					this._labelStat.gameObject.SetActive(false);
				}
				if (this._labelDateTime)
				{
					this._labelDateTime.gameObject.SetActive(false);
				}
				if (Application.loadedLevelName.Equals("TitleScene"))
				{
					base.transform.parent.GetComponent<Collider>().enabled = false;
				}
			}
			else
			{
				base.transform.parent.GetComponent<Collider>().enabled = true;
				try
				{
					if (File.Exists(path))
					{
						GameStats.Stats gameStats = GameStats.Stats.LoadFromBytes(File.ReadAllBytes(path));
						this._labelSlot.text = UiTranslationDatabase.TranslateKey("SLOT_" + this._slotNum, "Slot " + this._slotNum, false) + UiTranslationDatabase.TranslateKey("_DAY_", ": day ", false) + gameStats._day;
						if (this._labelStat)
						{
							FieldInfo[] array = (from f in gameStats.GetType().GetFields()
							where (int)f.GetValue(gameStats) > 0
							select f).ToArray<FieldInfo>();
							if (array != null && array.Length > 0)
							{
								int num = UnityEngine.Random.Range(0, array.Length);
								string name = array[num].Name;
								string text;
								switch (name)
								{
								case "_treeCutDown":
									text = "Trees Cut Down: ";
									goto IL_4BC;
								case "_enemiesKilled":
									text = "Enemies Killed: ";
									goto IL_4BC;
								case "_rabbitKilled":
									text = "Rabbits Killed: ";
									goto IL_4BC;
								case "_lizardKilled":
									text = "Lizards Killed: ";
									goto IL_4BC;
								case "_raccoonKilled":
									text = "Raccoons Killed: ";
									goto IL_4BC;
								case "_deerKilled":
									text = "Deer Killed: ";
									goto IL_4BC;
								case "_turtleKilled":
									text = "Turtles Killed: ";
									goto IL_4BC;
								case "_birdKilled":
									text = "Birds Killed: ";
									goto IL_4BC;
								case "_cookedFood":
									text = "Cooked Food: ";
									goto IL_4BC;
								case "_burntFood":
									text = "Burnt Food: ";
									goto IL_4BC;
								case "_cancelledStructures":
									text = "Cancelled Structures: ";
									goto IL_4BC;
								case "_builtStructures":
									text = "Built Structures: ";
									goto IL_4BC;
								case "_destroyedStructures":
									text = "Destroyed Structures: ";
									goto IL_4BC;
								case "_repairedStructures":
									text = "Repaired Structures: ";
									goto IL_4BC;
								case "_edibleItemsUsed":
									text = "Edible Items Used: ";
									goto IL_4BC;
								case "_itemsCrafted":
									text = "Items Crafted: ";
									goto IL_4BC;
								case "_upgradesAdded":
									text = "Upgrades Added: ";
									goto IL_4BC;
								case "_arrowsFired":
									text = "Arrows Fired: ";
									goto IL_4BC;
								case "_litArrows":
									text = "Lit Arrows: ";
									goto IL_4BC;
								case "_litWeapons":
									text = "Lit Weapons: ";
									goto IL_4BC;
								case "_burntEnemies":
									text = "Burnt Enemies: ";
									goto IL_4BC;
								case "_explodedEnemies":
									text = "Exploded Enemies: ";
									goto IL_4BC;
								}
								text = string.Empty;
								IL_4BC:
								if (string.IsNullOrEmpty(text))
								{
									this._labelStat.gameObject.SetActive(false);
								}
								else
								{
									this._labelStat.gameObject.SetActive(true);
									this._labelStat.text = text + array[num].GetValue(gameStats);
								}
							}
							else
							{
								this._labelStat.gameObject.SetActive(false);
							}
						}
					}
					else
					{
						this._labelSlot.text = "Slot " + this._slotNum;
					}
				}
				catch (Exception exception)
				{
					Debug.LogException(exception);
				}
				UILabel labelSlot = this._labelSlot;
				labelSlot.text += "\n";
				try
				{
					string path2 = localSlotPath + "difficulty";
					if (File.Exists(path2))
					{
						string text2 = File.ReadAllText(path2);
						if (text2 != null)
						{
							if (text2 == "Peaceful" || text2 == "Hard" || text2 == "HardSurvival" || text2 == "Creative" || text2 == "Normal")
							{
								string text3 = text2.ToUpper();
								UILabel labelSlot2 = this._labelSlot;
								labelSlot2.text += UiTranslationDatabase.TranslateKey(text3, text3, false);
							}
						}
					}
				}
				catch (Exception ex)
				{
				}
				if (this._labelDateTime)
				{
					this._labelDateTime.text = File.GetLastWriteTime(localSlotPath + "__RESUME__").ToString(CultureInfo.CurrentCulture.DateTimeFormat);
					this._labelDateTime.gameObject.SetActive(true);
				}
			}
		}