Esempio n. 1
0
        private void Load(String filePath, Stream input)
        {
            try
            {
                foreach (Reference <TransifexEntry> item in HarmonyPatches.PrepareTexts(StructuredJson.Read(input)).Enumerate())
                {
                    EventMessageDataId id = EventMessageDataId.Parse(item.Key);
                    _dic[id] = item.Value.Text + ' '; // Avoid bug in the game engine
                }

                Log.Message($"[{nameof(StDataEventMessageListHandler)}] Loaded: {filePath}");
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[{nameof(StDataEventMessageListHandler)}] Failed to load {filePath}");
            }
        }
Esempio n. 2
0
        public void Update()
        {
            EventMessageList currentList = StDataProxy.EventMessageList;

            if (currentList == _eventMessageList)
            {
                return;
            }

            _eventMessageList = currentList;
            if (currentList is null)
            {
                Log.Message($"[{nameof(StDataEventMessageListHandler)}] Nullified");
                return;
            }

            try
            {
                Int32 language = StWorkProxy.CurrentLanguage;
                Int32 count    = 0;

                foreach (var item in currentList.messageData)
                {
                    EventMessageDataId id = new EventMessageDataId(item.category, item.scenarioNumber, item.playNumber, item.messageNumber);
                    if (_dic.TryGetValue(id, out var text))
                    {
                        count++;
                        item.message[language] = text;
                    }
                }

                Log.Message($"[{nameof(StDataEventMessageListHandler)}] Changed: {count}");
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[{nameof(StDataEventMessageListHandler)}] Error");
            }
        }