Example #1
0
        public static void LoadPreview(int languageIndex)
        {
            // Validate language index and get language name
            var settings = Resources.Load <LocSettings>(LocManager.SettingsName);

            languageIndex = Mathf.Clamp(languageIndex, 0, settings.Languages.Length - 1);
            var languageName = settings.Languages[languageIndex];

            if (Selection.activeObject != settings)
            {
                Resources.UnloadAsset(settings);
            }

            var keysPath     = GetAssetPath(LocManager.KeysName);
            var keys         = AssetDatabase.LoadAssetAtPath <LocKeys>(keysPath).Strings;
            var languagePath = GetAssetPath(languageName);
            var values       = AssetDatabase.LoadAssetAtPath <LocLanguage>(languagePath).Strings;

            var strings = LocManager.CreateDictionary(keys, values);

            LocManager.SetEditorPreview(languageIndex, strings);

            // Refresh each component
            var components = Resources.FindObjectsOfTypeAll <LocComponent>();

            foreach (var component in components)
            {
                component.RefreshLocalization();
                EditorUtility.SetDirty(component);
            }

            // Force repaint
            SceneView.RepaintAll();
        }
Example #2
0
        public override void RefreshLocalization()
        {
            string value;

            if (_target == null || string.IsNullOrEmpty(Key) || !LocManager.TryGetString(Key, out value))
            {
                return;
            }

            // Apply case
            switch (_changeCase)
            {
            case TextCase.ToUpper:
                value = value.ToUpper();
                break;

            case TextCase.ToLower:
                value = value.ToLower();
                break;
            }

            // Set new text value
            _target.text = value;

            // Update to preferred size setting
            ResizeToPreferredSize(_usePreferredSize);
        }
Example #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            ProcessService.HandleProcessInstance(this, e.Args);

            base.OnStartup(e);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(_logUnhandledExceptions);

            // assign instance into Xaml
            Resources["ViewModelLocator"] = Resolver.Kernel.Get <IViewModelSource>();

            // Old code
            _SetupDirectories();
            _SetupLoggers(ZApi.Instance, Logger);

            SettingsService.LoadLauncherSettings();
            SettingsService.LoadGameSettings();

            var settings = SettingsService.GetLauncherSettings();

            LocManager.Initialize(this);
            LocManager.SetLocale(settings.Localization);

            XamlThemes.Theming.ThemeManager.Initialize(this);
            XamlThemes.Theming.ThemeManager.ApplyAccent(settings.Accent);
            XamlThemes.Theming.ThemeManager.ApplyTheme(settings.Theme);
            XamlThemes.Theming.ThemeManager.ApplyBackgroundImage();

            ProcessService.HandleUpdate(settings, e.Args);
        }
Example #4
0
        public void TryQuit()
        {
            DialogueBox dialogue = HUD.Instance.FindMenu <DialogueBox>();

            dialogue.Show(LocManager.GetTranslation("/Menu/Quit_Header"), LocManager.GetTranslation("/Menu/Quit_Body"), LocManager.GetTranslation("/Menu/Ok"), LocManager.GetTranslation("/Menu/Cancel"),
                          () => App.Quit());
        }
Example #5
0
 public string GetLocalized()
 {
     if (DesignMode)
     {
         return(_UnlocalizedText);
     }
     return(LocManager.GetLocaleFor("Labels", LocManager.Locale.INT).GetLocalizedString(_UnlocalizedText));
 }
Example #6
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
         getLocAsset();
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #7
0
        private void OnEnable()
        {
            var languages = LocManager.GetLanguages();

            if (languages == null)
            {
                return;
            }

            // Get properties
            _targets = serializedObject.FindProperty("_targets");
            var enable = serializedObject.FindProperty("_enable");

            // Get language labels
            var count = languages.Length;

            _labels = new GUIContent[count];
            const string tooltip = "Enable for this localization?";

            for (var i = 0; i < count; ++i)
            {
                _labels[i] = new GUIContent(languages[i], tooltip);
            }

            // Ensure enable list length
            if (enable.arraySize != count)
            {
                if (enable.arraySize > count)
                {
                    enable.arraySize = count;
                }
                else if (enable.arraySize < count)
                {
                    for (var i = enable.arraySize; i < count; ++i)
                    {
                        enable.InsertArrayElementAtIndex(i);
                    }
                }

                this.Save(false);
            }

            // Get switch properties
            _enable = new SerializedProperty[count];
            for (var i = 0; i < count; ++i)
            {
                _enable[i] = enable.GetArrayElementAtIndex(i);
            }
        }
Example #8
0
        private IEnumerator ShowPlayerSpeech(string option1, string option2)
        {
            if (string.IsNullOrEmpty(option2))
            {
                yield return(ShowSpeech(option1, true));
            }
            else
            {
                _dialogueClosed = false;

                _currentDialogue = HUD.Instance.FindMenu <DialogueBox>();
                _currentDialogue.Show("", "", LocManager.GetTranslation(option1), LocManager.GetTranslation(option2), Option1Selected, Option2Selected);

                yield return(new WaitUntil(() => _dialogueClosed));
            }
        }
Example #9
0
        private IEnumerator ShowSpeech(string locstring, bool isPlayer)
        {
            _optionSelected = 0;

            Transform toTrack = isPlayer ? App.AIBlackboard.Player.transform : _owner.transform;

            _dialogueClosed = false;

            _currentBubble          = HUD.Instance.CreateMenu <SpeechBubble>();
            _currentBubble.OnClose += OnDialogueClosed;
            _currentBubble.Show(toTrack, LocManager.GetTranslation(locstring), PlayerPressedSkip);

            yield return(new WaitUntil(() => _dialogueClosed));

            if (_currentBubble != null)
            {
                _currentBubble.OnClose -= OnDialogueClosed;
            }
        }
Example #10
0
        private void OnTakeDamage(DamageSource source)
        {
            if (source.Owner == null)
            {
                //means it's debug stuff (or falling to our death) and can be ignored
                return;
            }

            if (source.Owner.Config.Faction == CharacterFaction.Player && !App.AIBlackboard.IsHostileToPlayer(this))
            {
                App.AIBlackboard.MarkAsHostileToPlayer(this);
                HUD.Instance.CreateMenu <SpeechBubble>().Show(transform, LocManager.GetTranslation("/Dialogue/Agent/Hostile/Attack"),
                                                              () => App.AIBlackboard.Player.Health.IsDead);
            }

            if (AvailableBehaviours.HasFlag(SpecialistStates.Flee))
            {
                PushState(new FleeState.FleeConfig(this, source.Owner));
            }
            else if (!IsInState <AttackState>(false))           //We're not already attacking something
            {
                PushState(new AttackState.AttackConfig(this, source.Owner));
            }
        }
Example #11
0
 void Start()
 {
     StartCoroutine(LocManager.getTranslation(translationKey, GetComponent <TextMeshProUGUI>()));
 }
Example #12
0
 private void Awake()
 {
     // Initialize the LocManager at the start
     StartCoroutine(LocManager.LoadLocalizationAsync());
 }
Example #13
0
 public LocList()
 {
     this.InitializeComponent();
     Locs = LocManager.GetLocList();
 }