private void LoadAchievements() { fireAchievements = new List <FireExtinctAchievement>(); distanceAchievements = new List <DistanceAchievement>(); ICollection keys = LocalizationSystem.GetKeys(); foreach (string key in keys) { if (key.StartsWith("_ach_t_f-")) //fire achievements { string[] countText = key.Split('-')[1].Split('_'); int count = int.Parse(countText[0]); int index = int.Parse(countText[1]); string title = "_ach_t_f-" + count + "_" + index; string description = "_ach_d_f-" + count + "_" + index;; FireExtinctAchievement achievement = new FireExtinctAchievement(); achievement.achievementTitle = title; achievement.achievmentDescription = description; achievement.targetCount = count; fireAchievements.Add(achievement); } if (key.StartsWith("_ach_t_d-")) //distance achievements { string[] countText = key.Split('-')[1].Split('_'); int count = int.Parse(countText[0]); int index = int.Parse(countText[1]); string title = "_ach_t_d-" + count + "_" + index; string description = "_ach_d_d-" + count + "_" + index;; DistanceAchievement achievement = new DistanceAchievement(); achievement.achievementTitle = title; achievement.achievmentDescription = description; achievement.targetCount = count; distanceAchievements.Add(achievement); } } fireAchievementIndex = dataHandler.fireAchievementIndex; distanceAchievementIndex = dataHandler.distanceAchievementIndex; //Debug.Log("Achievements loaded"); }
public static void Draw(Rect position, SerializedProperty property, GUIContent label) { /*if (Application.isPlaying == false) { * * LocalizationSystem.TryToLoadCache(); * * }*/ //property.serializedObject.Update(); var keyProperty = property.FindPropertyRelative("key"); var parametersCountProperty = property.FindPropertyRelative("parameters"); var formatWithDeclensionProperty = property.FindPropertyRelative("formatWithDeclension"); if (keyProperty != null && parametersCountProperty != null && formatWithDeclensionProperty != null) { //GUILayout.BeginHorizontal(); { var labelWidth = EditorGUIUtility.labelWidth; var offset = new Vector2(-23f - 100f - labelWidth, -7f - 16f); var indent = EditorGUI.indentLevel * 16f; GUI.Label(new Rect(position.x + indent, position.y, labelWidth - indent, position.height), label); var buttonRect = new Rect(position.x + labelWidth, position.y, position.width - labelWidth, position.height); var keyValue = keyProperty.stringValue; var keyFull = (string.IsNullOrEmpty(keyValue) == true ? string.Empty : string.Format("[{0}] {1} ({2})", parametersCountProperty.intValue, keyValue, LocalizationSystem.Get(keyValue, LocalizationSystem.DEFAULT_EDITOR_LANGUAGE))); if (GUI.Button(buttonRect, keyFull, EditorStyles.textField) == true) { var rect = position; Vector2 vector = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y)); rect.x = vector.x; rect.y = vector.y; var popup = new Popup() { title = "Localization Keys", screenRect = new Rect(rect.x + labelWidth + offset.x, rect.y + rect.height + offset.y, rect.width - labelWidth - offset.x, 200f), searchText = keyProperty.stringValue, separator = '|' }; popup.Item("None", () => { keyProperty.serializedObject.Update(); parametersCountProperty.serializedObject.Update(); formatWithDeclensionProperty.serializedObject.Update(); keyProperty.stringValue = string.Empty; parametersCountProperty.intValue = 0; formatWithDeclensionProperty.boolValue = false; formatWithDeclensionProperty.serializedObject.ApplyModifiedProperties(); parametersCountProperty.serializedObject.ApplyModifiedProperties(); keyProperty.serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(keyProperty.serializedObject.targetObject); }); foreach (var key in LocalizationSystem.GetKeys()) { var finalKey = key; var finalKeyFull = string.Format("{0} <color=grey>({1})</color>", finalKey, LocalizationSystem.Get(finalKey, LocalizationSystem.DEFAULT_EDITOR_LANGUAGE)); popup.Item(finalKeyFull, () => { formatWithDeclensionProperty.serializedObject.Update(); parametersCountProperty.serializedObject.Update(); keyProperty.serializedObject.Update(); keyProperty.stringValue = finalKey; parametersCountProperty.intValue = LocalizationSystem.GetParametersCount(finalKey, LocalizationSystem.DEFAULT_EDITOR_LANGUAGE); formatWithDeclensionProperty.boolValue = LocalizationSystem.IsNeedToFormatWithDeclension(finalKey, LocalizationSystem.DEFAULT_EDITOR_LANGUAGE); formatWithDeclensionProperty.serializedObject.ApplyModifiedProperties(); parametersCountProperty.serializedObject.ApplyModifiedProperties(); keyProperty.serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(keyProperty.serializedObject.targetObject); }); } popup.Show(); } var textFieldRect = buttonRect; //GUILayoutUtility.GetLastRect(); EditorGUIUtility.AddCursorRect(textFieldRect, MouseCursor.Text); const float sizeX = 32f; const float sizeY = 16f; HierarchyEditor.DrawLabel(new Rect(textFieldRect.x + textFieldRect.width - sizeX, textFieldRect.y, sizeX, sizeY), HierarchyEditor.colors.screens, "LOC"); if (LocalizationSystem.ContainsKey(keyProperty.stringValue) == false) { HierarchyEditor.DrawLabel(new Rect(textFieldRect.x + textFieldRect.width - sizeX - 54f, textFieldRect.y, 54f, sizeY), HierarchyEditor.colors.error, "NO KEY"); } } //GUILayout.EndHorizontal(); } //property.serializedObject.ApplyModifiedProperties(); }