Beispiel #1
0
        public static ObsModuleSettings Load()
        {
            if (_settings != null)
            {
                return(_settings);
            }

            try
            {
                if (File.Exists(m_fileName))
                {
                    var s = new DataContractSerializer(typeof(ObsModuleSettings));
                    using (var fs = File.Open(m_fileName, FileMode.Open))
                    {
                        using (var reader = XmlReader.Create(fs))
                        {
                            _settings = (ObsModuleSettings)s.ReadObject(reader);
                            return(_settings);
                        }
                    }
                }
            }
            catch
            {
                Console.WriteLine($"Unable to load {m_fileName}. Using default config.");
            }

            Save(Default);
            return(_settings);
        }
Beispiel #2
0
        public void AdEnded()
        {
            var settings = ObsModuleSettings.Load();

            string toSend   = String.Empty;
            bool   modifier = false;

            if (settings.GameSceneCtrl)
            {
                toSend  += "^";
                modifier = true;
            }
            if (settings.GameSceneAlt)
            {
                toSend  += "%";
                modifier = true;
            }
            if (settings.GameSceneShift)
            {
                toSend  += "+";
                modifier = true;
            }

            if (modifier)
            {
                toSend += "{";
                toSend += settings.GameSceneChar;
                toSend += "}";
            }
            else
            {
                toSend += settings.GameSceneChar;
            }


            if (!String.IsNullOrEmpty(toSend))
            {
                IntPtr?obs  = hookOBS();
                IntPtr?curr = GetForegroundWindow();
                if (obs != null)
                {
                    Console.WriteLine("OBS: Changing to Game Scene");
                    SetForegroundWindow((IntPtr)obs);
                    SendKeys.SendWait(toSend);
                    SetForegroundWindow((IntPtr)curr);
                }
                else
                {
                    Console.WriteLine("Error: OBS was not located");
                }
            }
        }
Beispiel #3
0
        private void LoadSettings()
        {
            m_settings = ObsModuleSettings.Load();

            m_gameSceneChar  = m_settings.GameSceneChar;
            m_gameSceneCtrl  = m_settings.GameSceneCtrl;
            m_gameSceneAlt   = m_settings.GameSceneAlt;
            m_gameSceneShift = m_settings.GameSceneShift;

            m_adSceneChar  = m_settings.AdSceneChar;
            m_adSceneCtrl  = m_settings.AdSceneCtrl;
            m_adSceneAlt   = m_settings.AdSceneAlt;
            m_adSceneShift = m_settings.AdSceneShift;
        }
Beispiel #4
0
        private void OnConfigChanged()
        {
            m_settings.GameSceneChar  = GameSceneChar;
            m_settings.GameSceneCtrl  = GameSceneCtrl;
            m_settings.GameSceneAlt   = GameSceneAlt;
            m_settings.GameSceneShift = GameSceneShift;

            m_settings.AdSceneChar  = AdSceneChar;
            m_settings.AdSceneCtrl  = AdSceneCtrl;
            m_settings.AdSceneAlt   = AdSceneAlt;
            m_settings.AdSceneShift = AdSceneShift;

            ObsModuleSettings.Save(m_settings);
        }
Beispiel #5
0
 public static void Save(ObsModuleSettings settings)
 {
     try
     {
         var s = new DataContractSerializer(typeof(ObsModuleSettings));
         using (var fs = File.Open(m_fileName, FileMode.Create))
         {
             s.WriteObject(fs, settings);
             _settings = settings;
         }
     }
     catch
     {
         Console.WriteLine($"Unable to save {m_fileName}");
     }
 }