Esempio n. 1
0
        public static void ShowEmoteList(TwitchChannel channel)
        {
            if (EmoteList == null)
            {
                EmoteList = new Controls.EmoteListPopup();
            }

            EmoteList.SetChannel(channel);

            EmoteList.Show();

            EmoteList.FormClosed += (s, e) =>
            {
                EmoteList = null;
            };
        }
Esempio n. 2
0
        public static void ShowEmoteList(TwitchChannel channel, bool show_only_channel_emotes)
        {
            if (EmoteList == null)
            {
                EmoteList = new Controls.EmoteListPopup();
            }

            EmoteList.setShowOnlyChannelEmotes(show_only_channel_emotes);

            EmoteList.SetChannel(channel);

            EmoteList.Show();

            EmoteList.FormClosed += (s, e) =>
            {
                EmoteList = null;
            };
        }
Esempio n. 3
0
        public static void ImportFromRedis()
        {
            Logger.Info($"Importing Emotes from Redis... (Current: {EmoteList.Count})");
            IDatabase db = DataStore.Redis.GetDatabase();

            RedisValue[] emoteArr = db.SetMembers("emotelist");
            foreach (RedisValue curEmote in emoteArr)
            {
                String decoded = DataStore.KeyDecode(curEmote);
                if (!EmoteList.Contains(decoded))
                {
                    EmoteList.Add(DataStore.KeyDecode(curEmote));
                }
            }
            EmoteArr     = EmoteList.ToArray();
            EmoteHashSet = new HashSet <String>(EmoteArr);
            GetDownloadTimes();
        }
Esempio n. 4
0
 public GetTarget(EmoteList emote)
     : base(-1, true, TargetFlags.None)
 {
     this.m_Emote = emote;
 }
Esempio n. 5
0
 public GetTarget(EmoteList emote)
     : base(-1, true, TargetFlags.None)
 {
     this.m_Emote = emote;
 }
Esempio n. 6
0
 public static void SetEmoteListChannel(TwitchChannel channel)
 {
     EmoteList?.SetChannel(channel);
 }
Esempio n. 7
0
        static void Main()
        {
            CurrentVersion = VersionNumber.Parse(
                AssemblyName.GetAssemblyName(Assembly.GetExecutingAssembly().Location).Version.ToString());

            if (!File.Exists("./removeupdatenew") && Directory.Exists("./Updater.new"))
            {
                UpdaterPath = Path.Combine(new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName,
                                           "Updater.new", "Chatterino.Updater.exe");
            }
            else
            {
                if (File.Exists("./update2"))
                {
                    UpdaterPath = Path.Combine(new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName,
                                               "Updater2", "Chatterino.Updater.exe");
                }
            }

            Directory.SetCurrentDirectory(new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName);

            GuiEngine.Initialize(new WinformsGuiEngine());

            ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;
            ServicePointManager.DefaultConnectionLimit = int.MaxValue;
            //ServicePointManager.UseNagleAlgorithm = false;
            //ServicePointManager.MaxServicePoints = 10000;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //SetProcessDpiAwareness(_Process_DPI_Awareness.Process_Per_Monitor_DPI_Aware);

            Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);

            // Fonts
            if (Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 1)
            {
                UseDirectX = true;
            }

            // Exceptions
            Application.ThreadException += (s, e) =>
            {
                e.Exception.Log("exception", "{0}\n");
            };
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                (e.ExceptionObject as Exception).Log("exception", "{0}\n");
            };
            EmoteCache.init();
            // Update gif emotes
            int offset = 0;

            new System.Windows.Forms.Timer {
                Interval = 30, Enabled = true
            }.Tick += (s, e) =>
            {
                if (AppSettings.ChatEnableGifAnimations)
                {
                    lock (GuiEngine.Current.GifEmotesLock)
                    {
                        offset += 3;
                        if (offset < 0)
                        {
                            offset = 0;
                        }
                        try {
                            if (EmoteList != null && EmoteList.GetGifEmotes() != null)
                            {
                                GuiEngine.Current.GifEmotesOnScreen.UnionWith(EmoteList.GetGifEmotes());
                            }
                            foreach (LazyLoadedImage emote in GuiEngine.Current.GifEmotesOnScreen)
                            {
                                if (emote.HandleAnimation != null)
                                {
                                    emote.HandleAnimation(offset);
                                }
                            }
                            if (ToolTip != null && ToolTip.Visible && ToolTip.Image != null && ToolTip.Image.HandleAnimation != null)
                            {
                                ToolTip.Image.HandleAnimation(offset);
                                lock (ToolTip) {
                                    ToolTip.redraw();
                                }
                            }
                        } catch (Exception err) {
                            GuiEngine.Current.log("error updating gifs " + err.ToString());
                        }
                    }
                    GifEmoteFramesUpdated?.Invoke(null, EventArgs.Empty);
                }
            };

            // Settings/Colors
            try
            {
                if (!Directory.Exists(Util.GetUserDataPath()))
                {
                    Directory.CreateDirectory(Util.GetUserDataPath());
                }

                if (!Directory.Exists(Path.Combine(Util.GetUserDataPath(), "Custom")))
                {
                    Directory.CreateDirectory(Path.Combine(Util.GetUserDataPath(), "Custom"));
                }
            }
            catch
            {
            }

            AppSettings.SavePath = Path.Combine(Util.GetUserDataPath(), "Settings.ini");

            var showWelcomeForm = false;

            try
            {
                if (!File.Exists(AppSettings.SavePath))
                {
                    CanShowChangelogs = false;

                    showWelcomeForm = true;

                    if (File.Exists("./Settings.ini") && !File.Exists(AppSettings.SavePath))
                    {
                        File.Move("./Settings.ini", AppSettings.SavePath);

                        try

                        {
                            File.Delete("./Settings.ini");
                        }
                        catch { }
                    }

                    if (File.Exists("./Custom/Commands.txt") &&
                        !File.Exists(Path.Combine(Util.GetUserDataPath(), "Custom", "Commands.txt")))
                    {
                        File.Move("./Custom/Commands.txt", Path.Combine(Util.GetUserDataPath(), "Custom", "Commands.txt"));

                        try
                        {
                            File.Delete("./Custom/Commands.txt");
                        }
                        catch { }
                    }

                    if (File.Exists("./Custom/Ping.wav") &&
                        !File.Exists(Path.Combine(Util.GetUserDataPath(), "Custom", "Ping.wav")))
                    {
                        File.Move("./Custom/Ping.wav", Path.Combine(Util.GetUserDataPath(), "Custom", "Ping.wav"));

                        try
                        {
                            File.Delete("./Custom/Ping.wav");
                        }
                        catch { }
                    }

                    if (File.Exists("./Layout.xml") &&
                        !File.Exists(Path.Combine(Util.GetUserDataPath(), "Layout.xml")))
                    {
                        File.Move("./Layout.xml", Path.Combine(Util.GetUserDataPath(), "Layout.xml"));

                        try
                        {
                            File.Delete("./Layout.xml");
                        }
                        catch { }
                    }
                }
            }
            catch
            {
            }

            AppSettings.Load();

            AccountManager.LoadFromJson(Path.Combine(Util.GetUserDataPath(), "Login.json"));

            IrcManager.Account = AccountManager.FromUsername(AppSettings.SelectedUser) ?? Account.AnonAccount;
            IrcManager.Connect();

            Commands.LoadOrDefault(Path.Combine(Util.GetUserDataPath(), "Custom", "Commands.txt"));
            Cache.Load();

            _updateTheme();

            AppSettings.ThemeChanged += (s, e) => _updateTheme();

            // Check for updates
            //try
            //{
            //    string updaterPath = "./Updater";
            //    string newUpdaterPath = "./Updater.new";

            //    if (Directory.Exists(newUpdaterPath))
            //    {
            //        if (Directory.Exists(updaterPath))
            //            Directory.Delete(updaterPath, true);

            //        Directory.Move(newUpdaterPath, updaterPath);
            //    }
            //}
            //catch { }

            Updates.UpdateFound += (s, e) =>
            {
                try
                {
                    using (var dialog = new UpdateDialog())
                    {
                        if (File.Exists(UpdaterPath))
                        {
                            var result = dialog.ShowDialog();

                            // OK -> install now
                            // Yes -> install on exit
                            if (result == DialogResult.OK || result == DialogResult.Yes)
                            {
                                using (var client = new WebClient())
                                {
                                    client.DownloadFile(e.Url, Path.Combine(Util.GetUserDataPath(), "update.zip"));
                                }

                                installUpdatesOnExit = true;

                                if (result == DialogResult.OK)
                                {
                                    restartAfterUpdates = true;
                                    MainForm?.Close();
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("An update is available but the update executable could not be found. If you want to update chatterino you will have to reinstall it.");
                        }
                    }
                }
                catch { }
            };

#if DEBUG
            Updates.CheckForUpdate("win-dev", CurrentVersion);
#else
            Updates.CheckForUpdate("win-release", CurrentVersion);
#endif

            // Start irc
            Emotes.LoadGlobalEmotes();
            Badges.LoadGlobalBadges();
            GuiEngine.Current.LoadBadges();
            Net.StartHttpServer();

            // Show form
            MainForm = new MainForm();

            MainForm.Show();

            if (showWelcomeForm)
            {
                new WelcomeForm().Show();
            }

            MainForm.FormClosed += (s, e) =>
            {
                Application.Exit();

                // Save settings
                AppSettings.Save();

                Cache.Save();

                EmoteCache.SaveEmoteList();

                Commands.Save(Path.Combine(Util.GetUserDataPath(), "Custom", "Commands.txt"));
            };

            Application.Run();
            Environment.Exit(0);
        }