static void Postfix(SubtitleLogic __instance)
        {
            string display, csv_id, json_id;

            display = csv_id = json_id = "";

            csv_id = $"{SubtitleState.strLabel}/{SubtitleState.markerID}";

            if (__instance.timer_ > 0)
            {
                if (GeneratedDictionaries.SubtitleBindings.ContainsKey(csv_id))
                {
                    GeneratedDictionaries.SubtitleBindings.TryGetValue(csv_id, out json_id);
                    display = Language.GetLine(json_id);
                }
                else
                {
                    csv_id = csv_id.Substring(0, csv_id.Length - 2);
                    ScanForCountdownSubtitle(ref csv_id, ref display, ref json_id);
                }

                if (json_id != "" && json_id.Length > 0 && json_id != string.Empty && json_id != null)
                {
                    __instance.label_.text = display;
                }
            }
        }
Esempio n. 2
0
        static void Postfix(SubtitleLogic __instance, SubtitleEvent.Data data)
        {
            if (__instance.currentEmitter_ is null || data.emitter_ is null)
            {
                return;
            }
            __instance.CheckCameraDistance(data.emitter_);
            if (__instance.distanceToCurrentEmitter_ > data.emitter_.MaxAttenuationSq_)
            {
                return;
            }

            SubtitleState.strLabel    = data.strLabel_;
            SubtitleState.markerID    = data.markerID_;
            SubtitleState.forceString = data.forceString_;
            SubtitleState.emitter     = data.emitter_;

            if (G.Sys.GameManager_.ModeID_ != GameModeID.Adventure)
            {
                return;
            }

            AdventureMode mode      = G.Sys.GameManager_.Mode_ as AdventureMode;
            TimeSpan      countdown = TimeSpan.FromSeconds(mode.GetCountdownTime());

            SubtitleState.countdownHours   = countdown.Hours;
            SubtitleState.countdownMinutes = countdown.Minutes;
            SubtitleState.countdownSeconds = countdown.Seconds;
        }
        static void Postfix(SubtitleLogic __instance, SubtitleEvent.Data data)
        {
            __instance.CheckCameraDistance(data.emitter_);
            string event_name = $"subtitles.{Minify(data.emitter_.event_)}_{Minify(data.strLabel_)}_{data.markerID_}_{data.emitter_.currentPlayingID_}";

            if ((data.emitter_.playState_ == AmbientAudioObject.PlayState.Play || data.forceString_) && __instance.distanceToCurrentEmitter_ <= data.emitter_.maxAttenuationSq_)
            {
                Flags.subtitle_id = __instance.timer_ <= 0 ? "subtitles.empty" : event_name;
                Events.Plugins.SubtitleEvent.Broadcast(Flags.subtitle_id);
            }
        }
Esempio n. 4
0
        static bool Prefix(SubtitleLogic __instance, SubtitleEvent.Data data)
        {
            if (__instance.currentEmitter_ != null && data.emitter_ != __instance.currentEmitter_ && __instance.recentCarCam_ != null && (__instance.recentCarCam_.transform.position - data.emitter_.transform.position).sqrMagnitude > __instance.distanceToCurrentEmitter_)
            {
                return(false);
            }
            __instance.CheckCameraDistance(data.emitter_);
            if (__instance.distanceToCurrentEmitter_ > data.emitter_.MaxAttenuationSq_)
            {
                return(false);
            }

            __instance.currentEmitter_ = data.emitter_;
            __instance.timer_          = __instance.timeOut_;

            Postfix(__instance, data);
            return(false);
        }
Esempio n. 5
0
        static void Postfix(SubtitleLogic __instance)
        {
            SubtitleState.subtitlesDefaultScale = __instance.label_.defaultFontSize;

            if (Configuration["Debug"] is true && new List <string>(from argument in Environment.GetCommandLineArgs() select argument.DOWN()).Contains("-extract-subtitles"))
            {
                Settings settings = new Settings("subtitles_extracted");
                settings.Clear();
                foreach (var subtitle_entry in __instance.subtitles_)
                {
                    settings.Add(subtitle_entry.Key, subtitle_entry.Value);
                }
                settings.Save();

                try
                {
                    settings = new Settings("subtitles_defaults");
                    settings.Clear();
                    foreach (string key in __instance.subtitles_.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value).Keys)
                    {
                        foreach (uint marker in __instance.subtitles_[key].Keys)
                        {
                            string value  = __instance.subtitles_[key][marker];
                            string csv_id = $"{key}/{marker}";
                            T4.GeneratedDictionaries.SubtitleBindings.TryGetValue(csv_id, out string json_id);

                            if (!settings.ContainsKey(json_id ?? csv_id))
                            {
                                settings.Add(json_id ?? csv_id, value);
                            }
                            else
                            {
                                Console.WriteLine(json_id ?? csv_id);
                            }
                        }
                    }
                    settings.Save();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }