Exemple #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            StartTimer = Stopwatch.StartNew();

            DebugHelper.Init(LogsFilePath);                    // get old settings too

            if (FModel.Properties.Settings.Default.UseEnglish) // use old settings here
            {
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }

            DebugHelper.WriteLine("{0} {1}", "[FModel]", "––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––");
            DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Version]", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Build]", Globals.Build);
            DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[OS]", Logger.Logger.GetOperatingSystemProductName(true));
            DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Runtime]", RuntimeInformation.FrameworkDescription);
            DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Culture]", Thread.CurrentThread.CurrentUICulture);

            StatusBarVm.statusBarViewModel.Set(FModel.Properties.Resources.Initializing, FModel.Properties.Resources.Loading);
            if (FModel.Properties.Settings.Default.UseDiscordRpc)
            {
                DiscordIntegration.StartClient();
            }

            base.OnStartup(e);
        }
Exemple #2
0
 private void OnClosed(object sender, EventArgs e)
 {
     output.Stop();
     ListBoxVm.soundFiles.Clear();
     DiscordIntegration.Restore();
     InputFileVm.inputFileViewModel.Reset();
 }
Exemple #3
0
        private void Startup()
        {
            DiscordIntegration.SaveCurrentPresence();
            Sound_LstBox.ItemsSource         = ListBoxVm.soundFiles;
            AudioPlayer_TabItm.DataContext   = InputFileVm.inputFileViewModel;
            AudioDevices_CmbBox.ItemsSource  = InputFileVm.inputFileViewModel.Devices;
            AudioDevices_CmbBox.SelectedItem = InputFileVm.inputFileViewModel.Devices.Where(x => x.DeviceId == Properties.Settings.Default.AudioPlayerDevice).FirstOrDefault();
            if (AudioDevices_CmbBox.SelectedIndex < 0)
            {
                AudioDevices_CmbBox.SelectedIndex = 0;
            }

            if (spectrumAnalyzer == null)
            {
                spectrumAnalyzer = new UserControls.SpectrumAnalyzer(output);
            }
            if (timeline == null)
            {
                timeline = new UserControls.Timeline(output);
            }
            if (timeclock == null)
            {
                timeclock = new UserControls.Timeclock(output);
            }

            Clock.Content    = timeclock;
            Spectrum.Content = spectrumAnalyzer;
            Time.Content     = timeline;
        }
Exemple #4
0
        private async Task SaveAndExit()
        {
            if (_useDiscordRpc && !Properties.Settings.Default.UseDiscordRpc) // previously enabled
            {
                DiscordIntegration.Deinitialize();
            }

            if (Properties.Settings.Default.AssetsLanguage != Languages_CbBox.SelectedIndex)
            {
                Properties.Settings.Default.AssetsLanguage = Languages_CbBox.SelectedIndex;
                await Localizations.SetLocalization(Properties.Settings.Default.AssetsLanguage, true).ConfigureAwait(false);
            }


            if (!_inputPath.Equals(Properties.Settings.Default.PakPath) ||
                !_outputPath.Equals(Properties.Settings.Default.OutputPath) ||
                _useEnglish != Properties.Settings.Default.UseEnglish)
            {
                DarkMessageBoxHelper.Show(Properties.Resources.PathChangedRestart, Properties.Resources.PathChanged, MessageBoxButton.OK, MessageBoxImage.Information);
                DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Restarting]", "Path(s) changed");

                Properties.Settings.Default.Save();
                Process.Start(Process.GetCurrentProcess().MainModule.FileName);
                Application.Current.Shutdown();
            }
            else
            {
                Properties.Settings.Default.Save();
                DebugHelper.WriteUserSettings();
                DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Window]", "Closing General Settings");
            }
        }
Exemple #5
0
 private async void OnClosing(object sender, CancelEventArgs e)
 {
     Globals.gNotifier.Dispose();
     Tasks.TokenSource?.Dispose();
     DiscordIntegration.Dispose();
     DebugHelper.Logger.AsyncWrite = false;
     await Properties.Settings.SaveToFile().ConfigureAwait(false);
 }
    public void SelectLevel()
    {
        audioSource.Play();
        string levelName   = "";
        string discordName = "";

        switch (activeToggle)
        {
        case -1:
            selectLevelButton.interactable = false;
            return;

        case 0:
            levelName   = "BallRoll3Menu";
            discordName = BallRoll3.TitleRandomizer.GetRandomName() + ": The Second Return";
            break;

        case 1:
            levelName   = "FalseTruthMainMenu";
            discordName = "False Truth";
            break;

        case 2:
            levelName   = "TicTacToe";
            discordName = "Tic Tac Toe";
            break;

        case 3:
            levelName   = "SportsGame";
            discordName = "Sports Game";
            break;

        case 4:
            levelName   = "ArtPark";
            discordName = "Art Park";
            break;

        case 5:
            levelName   = "Proj3ctMenu";
            discordName = "Proj3ct";
            break;

        case 6:
            levelName   = "MakiSupermarketMainMenu";
            discordName = "Maki Supermarket";
            break;

        case 7:
            levelName   = "FriendsInDreamsDummy";
            discordName = "Friends In Dreams";
            break;

        default:
            return;
        }
        StartCoroutine(LoadScene(levelName));
        DiscordIntegration.UpdateActivity(discordName);
    }
    void Start()
    {
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        audioSource = GetComponent <AudioSource>();

        SetPrefValues();

        DiscordIntegration.UpdateActivity("Main Menu");
    }
Exemple #8
0
        private async Task Init()
        {
            await PaksGrabber.PopulateMenu().ConfigureAwait(false);

            if (Properties.Settings.Default.UseDiscordRpc)
            {
                DiscordIntegration.StartClient();
            }
            await AesGrabber.Load(Properties.Settings.Default.ReloadAesKeys).ConfigureAwait(false);

            await CdnDataGrabber.DoCDNStuff().ConfigureAwait(false);
        }
Exemple #9
0
        /// <summary>
        /// Gets a list of integrations for the specified guild.
        /// <para>Requires <see cref="DiscordPermission.ManageGuild"/>.</para>
        /// </summary>
        /// <exception cref="DiscordHttpApiException"></exception>
        public async Task <IReadOnlyList <DiscordIntegration> > GetGuildIntegrations(Snowflake guildId)
        {
            DiscordApiData data = await rest.Get($"guilds/{guildId}/integrations",
                                                 $"guilds/{guildId}/integrations").ConfigureAwait(false);

            DiscordIntegration[] integrations = new DiscordIntegration[data.Values.Count];
            for (int i = 0; i < integrations.Length; i++)
            {
                integrations[i] = new DiscordIntegration(this, data.Values[i], guildId);
            }

            return(integrations);
        }
        public void LoadFile(string filepath)
        {
            Focus();

            output.Stop();
            output.Load(filepath);
            output.Play();

            string name = Path.GetFileName(filepath);

            InputFileVm.inputFileViewModel.Set(name, output);
            DiscordIntegration.Update(string.Empty, string.Format(Properties.Resources.Listening, name));
            PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/pause.png"));
        }
Exemple #11
0
        private void OnPlayPauseClick(object sender, RoutedEventArgs e)
        {
            if (output.HasMedia)
            {
                if (!output.FileName.Equals(_oldPlayedSound))
                {
                    output.Stop();
                    output.Load(_oldPlayedSound);
                    output.Play();

                    string name = Path.GetFileName(_oldPlayedSound);
                    InputFileVm.inputFileViewModel.Set(name, output);
                    DiscordIntegration.Update(string.Empty, string.Format(Properties.Resources.Listening, name));
                    PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/pause.png"));
                }
                else if (output.IsPlaying)
                {
                    output.Pause();
                    PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/play.png"));
                }
                else if (output.Paused)
                {
                    output.Resume();
                    PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/pause.png"));
                }
                else if (output.IsStopped)
                {
                    output.Play();
                    PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/pause.png"));
                }
            }
            else
            {
                if (Sound_LstBox.SelectedIndex > -1 && Sound_LstBox.SelectedItem is ListBoxViewModel2 selected)
                {
                    output.Stop();
                    output.Load(selected.FullPath);
                    output.Play();

                    InputFileVm.inputFileViewModel.Set(selected.Content, output);
                    DiscordIntegration.Update(string.Empty, string.Format(Properties.Resources.Listening, selected.Content));
                    PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/pause.png"));
                }
            }
        }
Exemple #12
0
        public void LoadFile(string filepath)
        {
            ListBoxViewModel2 item = ListBoxVm.soundFiles.Where(x => x.FullPath.Equals(filepath)).FirstOrDefault();

            if (item == null)
            {
                Focus();
                item = new ListBoxViewModel2
                {
                    Content  = Path.GetFileName(filepath),
                    Data     = null,
                    FullPath = filepath,
                    Folder   = string.Empty
                };

                ListBoxVm.soundFiles.Add(item);

                if (ListBoxVm.soundFiles.Count == 1) // auto play if one in queue
                {
                    output.Stop();
                    output.Load(filepath);
                    output.Play();
                    Sound_LstBox.SelectedIndex = 0;

                    string name = Path.GetFileName(filepath);
                    InputFileVm.inputFileViewModel.Set(name, output);
                    DiscordIntegration.Update(string.Empty, string.Format(Properties.Resources.Listening, name));
                    PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/pause.png"));
                }
                else
                {
                    Sound_LstBox.SelectedIndex = ListBoxVm.soundFiles.IndexOf(item);
                    Sound_LstBox.ScrollIntoView(item);
                }
            }
            else
            {
                Focus();
                Sound_LstBox.SelectedIndex = ListBoxVm.soundFiles.IndexOf(item);
                Sound_LstBox.ScrollIntoView(item);
            }
        }
 public void UpdateIntegrations()
 {
     if (Environment.OSVersion.Version.Major >= 10 && App.Config.IntegrateSMTC)
     {
         smtcIntegration = new SMTCIntegration(this);
     }
     else
     {
         smtcIntegration = null;
     }
     if (App.Config.IntegrateDiscordRPC)
     {
         discordIntegration = new DiscordIntegration();
     }
     else
     {
         discordIntegration?.Close();
         discordIntegration = null;
     }
 }
        private async Task LoadPakFiles(EPakLoader mode)
        {
            ListBoxVm.gameFiles.Clear();
            DataGridVm.dataGridViewModel.Clear();
            ImageBoxVm.imageBoxViewModel.Reset();
            StatusBarVm.statusBarViewModel.Reset();
            AvalonEditVm.avalonEditViewModel.Reset();
            PakPropertiesVm.pakPropertiesViewModel.Reset();
            SortedTreeviewVm.gameFilesPath.Childrens.Clear();
            AssetPropertiesVm.assetPropertiesViewModel.Reset();

            await Task.Run(async() =>
            {
                if (mode == EPakLoader.Single)
                {
                    StatusBarVm.statusBarViewModel.Set($"{Properties.Settings.Default.PakPath}\\{PakFile.FileName}", Properties.Resources.Loading);
                    DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[PakMenuItemViewModel]", "[Loader]", $"{PakFile.FileName} was selected ({mode})");
                }
                else
                {
                    StatusBarVm.statusBarViewModel.Set(Properties.Settings.Default.PakPath, Properties.Resources.Loading);
                    DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[PakMenuItemViewModel]", "[Loader]", $"All PAK files were selected ({mode})");
                }

                foreach (PakFileReader pakFile in MenuItems.pakFiles.GetPakFileReaders())
                {
                    if (pakFile.AesKey == null)
                    {
                        continue;
                    }

                    if (!Globals.CachedPakFiles.ContainsKey(pakFile.FileName))
                    {
                        pakFile.ReadIndex(pakFile.AesKey);
                        Globals.CachedPakFiles[pakFile.FileName] = pakFile;

                        if (mode != EPakLoader.Single)
                        {
                            StatusBarVm.statusBarViewModel.Set(string.Format(Properties.Resources.MountedPakTo, pakFile.FileName, pakFile.MountPoint), Properties.Resources.Loading);
                        }
                    }
                }

                if (mode == EPakLoader.Single)
                {
                    PakPropertiesVm.pakPropertiesViewModel.Set(PakFile);
                }
                await Localizations.SetLocalization(Properties.Settings.Default.AssetsLanguage, false).ConfigureAwait(false);
                PopulateTreeviewViewModel(mode);
            }).ContinueWith(t =>
            {
                DiscordIntegration.Update(
                    $"{Globals.CachedPakFiles.Count}/{MenuItems.pakFiles.GetPakCount()} {Properties.Resources.PakFiles}",
                    string.Format("{0} - {1}", Globals.Game,
                                  mode == EPakLoader.All ? Properties.Resources.AllFiles :
                                  mode == EPakLoader.New ? Properties.Resources.NewFiles :
                                  mode == EPakLoader.Modified ? Properties.Resources.ModifiedFiles :
                                  mode == EPakLoader.NewModified ? Properties.Resources.NewModifiedFiles :
                                  mode == EPakLoader.Single ? Header.Substring(0, Header.LastIndexOf("-WindowsClient.pak")) :
                                  string.Empty
                                  ));

                if (t.Exception != null)
                {
                    Tasks.TaskCompleted(t.Exception);
                }
                else
                {
                    StatusBarVm.statusBarViewModel.Set(
                        mode == EPakLoader.Single ?
                        $"{Properties.Settings.Default.PakPath}\\{PakFile.FileName}" :
                        Properties.Settings.Default.PakPath,
                        Properties.Resources.Success);
                }
            },
                            TaskScheduler.FromCurrentSynchronizationContext());

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Exemple #15
0
    public IIntegration CreateIntegration()
    {
        DiscordIntegration disco = new DiscordIntegration(System.IO.File.ReadAllText("discord_token.txt"));

        return(disco);
    }
Exemple #16
0
        private void SetupIntegrations()
        {
            string discordToken = "", slackToken = "";

            try
            {
                discordToken = System.IO.File.ReadAllText("discord_token.txt");
                slackToken   = System.IO.File.ReadAllText("slack_token.txt");
            }
            catch (System.IO.FileNotFoundException)
            {
                Console.WriteLine("Missing tokens! discord_token.txt, slack_token.txt");
                Environment.Exit(0);
            }

            IntegrationThreads.Clear();
            foreach (IntegrationType integration in Enum.GetValues(typeof(IntegrationType)))
            {
                if (integration == IntegrationType.Discord)
                {
                    IntegrationCancellations[integration] = new CancellationTokenSource();
                    IntegrationThreads[integration]       = Task.Run(() =>
                    {
                        DiscordIntegration discord = new DiscordIntegration(discordToken);
                        SetupCommands(IntegrationType.Discord, discord);

                        discord.StartIntegration();

                        discord.Connected += (sender, e) =>
                        {
                            Log(IntegrationType.Discord, $"Discord connected!");
                        };
                        discord.ConnectionClosed += (sender, e) =>
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("[Discord Error]: ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.Write($"Socket Closed. Code: {e.Code}, Reason: {e.Reason}, Clean?: {e.Clean}\n");
                        };
                        discord.MessageReceived += (sender, e) =>
                        {
                            Log(IntegrationType.Discord, string.Format("Message from {0} in #{1}: {2}", e.Member.Name, e.Channel.Name, e.Text));
                            if (e.Text.Length > 0 && e.Text[0] == '-')
                            {
                                try
                                {
                                    CommandManagers[IntegrationType.Discord].ExecuteOnMessageCommand(e.Text.Substring(1), e.Channel, e.Member);
                                }
                                catch { }
                            }
                        };
                    }, IntegrationCancellations[integration].Token);
                }
                else if (integration == IntegrationType.Slack)
                {
                    IntegrationCancellations[integration] = new CancellationTokenSource();
                    IntegrationThreads[integration]       = Task.Run(() =>
                    {
                        SlackIntegration slackClient = new SlackIntegration(slackToken);
                        SetupCommands(IntegrationType.Slack, slackClient);

                        slackClient.StartIntegration();

                        slackClient.Connected += (sender, e) =>
                        {
                            Log(integration, "Connected to Slack!");
                        };
                        slackClient.MessageReceived += (x, s) =>
                        {
                            Log(integration, string.Format("Message from {0} in {1}: {2}", s.Member.Name, s.Channel.Name, s.Text));
                            if (s.Text.Length > 0 && s.Text[0] == '-')
                            {
                                try
                                {
                                    CommandManagers[IntegrationType.Slack].ExecuteOnMessageCommand(s.Text.Substring(1), s.Channel, s.Member);
                                }
                                catch { }
                            }
                        };
                    }, IntegrationCancellations[integration].Token);
                }
            }
        }