Ejemplo n.º 1
0
        private async Task <bool> CloseGameJoltSessionAsync()
        {
            if (string.IsNullOrEmpty(Settings.GameJoltUsername))
            {
                Log($"Can't open Session! Credentials not set!");
                return(false);
            }

            if (await GameJolt.IsConnectedAsync())
            {
                Log("Closing GameJolt Session...");
                var resp = await GameJolt.SessionCloseAsync();

                if (!resp.Success)
                {
                    Log($"GameJolt Error: {resp.ErrorMessage}");
                }
                if (!await GameJolt.IsConnectedAsync())
                {
                    Log("GameJolt Session was closed!");
                    PictureBox_GameJolt.Visible         = false;
                    PictureBox_GameJolt_Offline.Visible = true;
                }
                else
                {
                    Log("GameJolt Session was not opened! Can't close the Session!");
                }
            }

            return(!await GameJolt.IsConnectedAsync());
        }
Ejemplo n.º 2
0
		public void Init(GameJolt.API.Objects.Score score)
		{
			username.text = score.PlayerName;
			value.text = score.Text;

			bool isUserScore = score.UserID != 0 && GameJolt.API.Manager.Instance.CurrentUser != null && GameJolt.API.Manager.Instance.CurrentUser.ID == score.UserID;
			username.color = isUserScore ? highlightColour : defaultColour;
			value.color = isUserScore ? highlightColour : defaultColour;
		}
Ejemplo n.º 3
0
		public void Init(GameJolt.API.Objects.Table table, int index, LeaderboardsWindow controller, bool active = false)
		{
			title.text = table.Name;
			tabIndex = index;
			windowController = controller;
			SetActive(active);


			button.onClick.RemoveAllListeners();
			button.onClick.AddListener(Clicked);
		}
Ejemplo n.º 4
0
        private async void PictureBox_GameJolt_Offline_Click(object sender, EventArgs e)
        {
            PictureBox_GameJolt_Offline.BorderStyle = BorderStyle.Fixed3D;
            await Task.Delay(100);

            PictureBox_GameJolt_Offline.BorderStyle = BorderStyle.None;

            if (!await GameJolt.IsConnectedAsync())
            {
                await OpenGameJoltSessionAsync();
            }
        }
Ejemplo n.º 5
0
        private async void ReloadSettings()
        {
            await Settings.ReloadAsync();

            if (Controls.Count == 0)
            {
                return;
            }

            Check_Updates.Checked = Settings.GameUpdates;
            CheckBox_CheckServerOnStart.Checked = Settings.GameCheckServer;

            ComboBox_Language.Items.Clear();
            var localizations = LocalizationUI.Localizations;

            foreach (var localizationInfo in LocalizationUI.Localizations)
            {
                var cultureInfo         = localizationInfo.CultureInfo;
                var nativeNameTitleCase = cultureInfo.TextInfo.ToTitleCase(cultureInfo.NativeName);

                var locaizationName = !string.IsNullOrEmpty(localizationInfo.SubLanguage)
                    ? $"{nativeNameTitleCase} [{localizationInfo.SubLanguage}]"
                    : nativeNameTitleCase;
                ComboBox_Language.Items.Add(locaizationName);
            }
            ComboBox_Language.SelectedIndex = localizations.IndexOf(localizationInfo => Equals(localizationInfo.CultureInfo, Settings.LocalizationInfo.CultureInfo) && Equals(localizationInfo.SubLanguage, Settings.LocalizationInfo.SubLanguage));

            GameJolt = new GameJolt(Settings.GameJoltUsername, Settings.GameJoltToken);
            TextBox_Username.Text            = Settings.GameJoltUsername;
            TextBox_Token.Text               = Settings.GameJoltToken;
            CheckBox_AutoLogIn.Checked       = Settings.AutoLogIn;
            CheckBox_SaveCredentials.Checked = Settings.SaveCredentials;

            ComboBox_SelectedDL.Items.Clear();
            if (SettingsFile.DLList.Any())
            {
                foreach (var dlUri in SettingsFile.DLList)
                {
                    ComboBox_SelectedDL.Items.Add(dlUri);
                }
                ComboBox_SelectedDL.SelectedIndex = Settings.SelectedDLIndex;
            }

            await OpenGameJoltSessionAsync();
        }
Ejemplo n.º 6
0
        private async Task <bool> OpenGameJoltSessionAsync()
        {
            if (string.IsNullOrEmpty(Settings.GameJoltUsername))
            {
                Log("Can't open Session! credentials not set!");
                return(false);
            }

            if (!await GameJolt.IsConnectedAsync())
            {
                Log("Opening GameJolt Session...");
                var resp = await GameJolt.SessionOpenAsync();

                if (!resp.Success)
                {
                    Log($"GameJolt Error: {resp.ErrorMessage}");
                    PictureBox_GameJolt.Visible         = false;
                    PictureBox_GameJolt_Offline.Visible = false;
                }
                if (await GameJolt.IsConnectedAsync())
                {
                    Log("GameJolt Session was opened!");
                    BackgroundWorker_GameJolt.CancelAsync();
                    while (BackgroundWorker_GameJolt.IsBusy)
                    {
                        await Task.Delay(50);
                    }
                    BackgroundWorker_GameJolt.RunWorkerAsync();
                    PictureBox_GameJolt.Visible         = true;
                    PictureBox_GameJolt_Offline.Visible = false;
                }
                else
                {
                    Log("GameJolt Session could not be opened!");
                }
            }

            //if (!await GameJolt.IsMigratedAsync())
            //    Log($"GameJolt User {Settings.GameJoltUsername} has not migrated!");

            return(await GameJolt.IsConnectedAsync());
        }
Ejemplo n.º 7
0
		public void Init(GameJolt.API.Objects.Trophy trophy)
		{
			group.alpha = trophy.Unlocked ? 1f : .6f;
			title.text = trophy.Title;
			description.text = trophy.Description;

			if (trophy.Image != null)
			{
				image.sprite = trophy.Image;
			}
			else
			{
				trophy.DownloadImage((success) => {
					if (success)
					{
						image.sprite = trophy.Image;
					}
				});
			}
		}
Ejemplo n.º 8
0
        private async void BackgroundWorker_GameJolt_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!BackgroundWorker_GameJolt.CancellationPending)
            {
                var stopwatch = Stopwatch.StartNew();

                if (!(await GameJolt.IsSessionActiveAsync()).Success)
                {
                    break;
                }

                stopwatch.Stop();

                if (stopwatch.ElapsedMilliseconds < 30000)
                {
                    await Task.Delay((int)(30000 - stopwatch.ElapsedMilliseconds));
                }
            }

            e.Cancel = true;
        }
Ejemplo n.º 9
0
        private async void FormInitialize()
        {
            Log($"System Language: {CultureInfo.InstalledUICulture.EnglishName}");

            PictureBox_GameJolt.Visible = GameJolt != null && await GameJolt?.IsConnectedAsync();

            Label_Version.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            TabPage_Settings.VisibleChanged += TabPage_Settings_VisibleChanged;

            CheckBox_SaveCredentials.Checked = !CheckBox_SaveCredentials.Checked;
            CheckBox_SaveCredentials.Checked = !CheckBox_SaveCredentials.Checked;

            await ReloadProfileListAsync();

            ReloadSettings();
            await Settings.SaveAsync();

            // TODO: better string.format use
            Label_Credits.Text = string.Format(Label_Credits.Text, "Aragas", string.Join(", ", LocalizationUI.Authors.Distinct().Where(author => !string.IsNullOrEmpty(author))));

#pragma warning disable 4014
            BrowserLoadAsync();

            CheckLauncherForUpdateAsync();

            if (Settings.GameUpdates)
            {
                CheckProfileForUpdateAsync(true);
            }

            if (CheckBox_AutoLogIn.Checked)
            {
                OpenGameJoltSessionAsync();
            }
#pragma warning restore 4014
        }
Ejemplo n.º 10
0
        private async void Button_Start_Click(object sender, EventArgs e)
        {
            bool IsOpenALInstalled()
            {
                if (OSInfo.OperatingSystemType == OperatingSystemType.Windows)
                {
                    return(Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall").GetSubKeyNames()
                           .Select(item => (string)Registry.LocalMachine.OpenSubKey($@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{item}").GetValue("DisplayName"))
                           .Any(programName => programName == "OpenAL"));
                }
                if (OSInfo.OperatingSystemType == OperatingSystemType.Unix)
                {
                    return(true);
                }

                if (OSInfo.OperatingSystemType == OperatingSystemType.MacOSX)
                {
                    return(true);
                }

                return(false);
            }

            const string OpenALLink = "https://www.openal.org/downloads/";
            const string DotNetLink = "https://www.microsoft.com/ru-RU/download/details.aspx?id=42643";

            if (OSInfo.FrameworkVersion >= new Version(4, 0, 30319, 34000)) // 4.5.2
            {
                if (!IsOpenALInstalled())
                {
                    if (MessageBox.Show(LocalizationUI.GetString("SomethingNotFoundError", "OpenAL 1.1", OpenALLink), LocalizationUI.GetString("SomethingNotFoundErrorTitle"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process.Start(OpenALLink);
                        this.SafeInvoke(Close);
                        return;
                    }
                }
            }
            else
            {
                if (MessageBox.Show(LocalizationUI.GetString("SomethingNotFoundError", "Microsoft .NET Framework 4.5.2", DotNetLink), LocalizationUI.GetString("SomethingNotFoundErrorTitle"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Process.Start(DotNetLink);
                    this.SafeInvoke(Close);
                    return;
                }
            }


            if (CurrentProfile.IsSupportingGameJolt && !(await GameJolt.IsSessionActiveAsync()).Success)
            {
                using (var gameJoltMessageBox = new GameJoltForm(Settings))
                {
                    switch (gameJoltMessageBox.ShowDialog())
                    {
                    case DialogResult.Yes:
                        ReloadSettings();
                        if (!await OpenGameJoltSessionAsync())
                        {
                            return;
                        }
                        break;

                    case DialogResult.Cancel:
                        return;
                    }
                }
            }


            if (Settings.GameCheckServer && CurrentProfile.ProfileType == ProfileType.Game)
            {
                new ProfileGameServerListFile(new ProfileGameSaveFolder(CurrentProfile.Folder)).CheckServers();
            }

            if (CurrentProfile.ExecutionFile != null)
            {
                var gameJoltArgs = CurrentProfile.IsSupportingGameJolt ? LaunchArgsHandler.CreateArgs(GameJolt.GameJoltYaml, false) : "";
                CurrentProfile.ExecutionFile.Start($"{gameJoltArgs} {CurrentProfile.LaunchArgs}");
                this.SafeInvoke(Close);
                return;
            }
            else
            {
                Button_StartGame.Enabled = false;

                if (await DownloadCurrentProfileAsync())
                {
                    Button_Start_Click(sender, e);
                }
                else
                {
                    Button_StartGame.Enabled = true;
                }
            }
        }
Ejemplo n.º 11
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            Profiles.Save();

            Program.ActionsBeforeExit.Add(() => Task.Run(() => GameJolt.SessionCloseAsync()).Wait(2000));
        }
Ejemplo n.º 12
0
 private void GenerateCustomMenuFinalPhase(GameJolt.API.Objects.Score[] lstScores)
 {
     if (lstScores != null && lstScores.Length > 0)
     {
         for (int i = 0; i < lstScores.Length; i++)
         {
             //Debug.Log("User Data: " + lstScores[i].Value + " time:" + lstScores[i].Time);
             if (lstScores[i].Time.Contains("seconds"))
             {
                 lstTopScores[lstTopScores.Length - 1] = lstScores[i];
                 break;
             }
         }
     }
     PopulateLeaderBoard();
 }
Ejemplo n.º 13
0
 //Function to generate custom scoreboard using GameJolt API
 private void GenerateCustomMenu(GameJolt.API.Objects.Score[] lstScores)
 {
     if(lstScores != null && lstScores.Length > 0)
     {
         for (int i = 0; i<lstScores.Length; i++)
         {
             Debug.Log((lstScores[i].UserName!=string.Empty? lstScores[i].UserName:lstScores[i].GuestName) + " " + lstScores[i].Text);
         }
         lstTopScores = lstScores;
     }
     if (LoginManager.isLoggedIn())
     {
         GameJolt.API.Scores.Get(GenerateCustomMenuFinalPhase, tableID, 100, true);
     }
     else
     {
     //                PopulateLeaderBoard();
     }
 }
Ejemplo n.º 14
0
 public void getTrophy(GameJolt.API.Objects.Trophy trophy)
 {
     Debug.Log ("Got trophy: " + trophy.ID + " unlocked: " + trophy.Unlocked);
     if (!trophy.Unlocked)	// Unlock trophy if we don't already have it
         actuallyUnlockTrophy(trophy.ID);
 }