Example #1
0
        /// <summary>
        /// When the selection in the listbox is changed, it loads the appropriate game profile as the selected one.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StockGameList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (stockGameList.SelectedIndex < 1)
            {
                return;
            }
            e.Handled = true;
            _selected = GameProfileLoader.GameProfiles[stockGameList.SelectedIndex];
            var icon = _selected.IconName;

            string[] splitString = icon.Split('/');

            if (!File.Exists(icon))
            {
                DownloadFile(
                    "https://raw.githubusercontent.com/teknogods/TeknoParrotUIThumbnails/master/Icons/" +
                    splitString[1], icon);
            }

            try
            {
                image1.Source = LoadImage(icon);
            }
            catch
            {
                //delete icon since it's probably corrupted, then load default icons
                if (File.Exists(icon))
                {
                    File.Delete(icon);
                }
                image1.Source = new BitmapImage(new Uri("../Resources/teknoparrot_by_pooterman-db9erxd.png", UriKind.Relative));
            }
        }
Example #2
0
        private void newProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextBoxForm form    = CreateProfileTextBoxForm("New Profile", true);
            bool        success = false;

            while (!success && form.ShowDialog(this) == DialogResult.OK)
            {
                success = IsValidProfileName(-1, form.DisplayText.Trim(), out string error);

                if (success)
                {
                    GameProfile gameProfile = new GameProfile(GameFile.GameFileID.Value, form.DisplayText);

                    GameProfile.ApplyDefaultsToProfile(gameProfile, m_appConfig);
                    if (form.CheckBoxChecked)
                    {
                        UpdateGameProfile(gameProfile);
                    }

                    m_adapter.InsertGameProfile(gameProfile);

                    cmbProfiles.SelectedIndexChanged -= CmbProfiles_SelectedIndexChanged;
                    var profiles = LoadProfiles();
                    cmbProfiles.SelectedIndexChanged += CmbProfiles_SelectedIndexChanged;
                    cmbProfiles.SelectedValue         = profiles.Max(x => x.GameProfileID);
                }
                else
                {
                    MessageBox.Show(this, error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #3
0
        private void btn_Play_Click(object sender, EventArgs e)
        {
            if (handler != null)
            {
                handler.End();
                SetBtnToPlay();
                return;
            }

            btn_Play.Visible = false;
            btn_Play.Text    = "S T O P";

            handler = gameManager.MakeHandler(currentGame);
            handler.Initialize(currentGameInfo, GameProfile.CleanClone(currentProfile));
            handler.Ended += handler_Ended;

            gameManager.Play(handler);
            if (handler.TimerInterval > 0)
            {
                handlerThread = new Thread(UpdateGameManager);
                handlerThread.Start();
            }

            WindowState = FormWindowState.Minimized;
        }
Example #4
0
        private void list_Games_SelectedChanged(object arg1, Control arg2)
        {
            currentControl  = (GameControl)arg1;
            currentGameInfo = currentControl.Game;
            currentGame     = currentGameInfo.Game;

            btn_Play.Enabled = false;

            if (currentGame.Steps == null ||
                currentStepIndex == currentGame.Steps.Length)
            {
                // can play
                btn_Play.Enabled = true;

                // remove the current step if there's one
                KillCurrentStep();

                arrow_Back.Enabled = false;
                arrow_Next.Enabled = false;
            }

            currentProfile = new GameProfile();
            currentProfile.InitializeDefault(currentGame);

            this.label_GameTitle.Text = currentGame.GameName;
            this.pic_Game.Image       = currentGameInfo.Icon;

            Type[] steps = currentGame.Steps;
            if (steps != null && steps.Length > 0)
            {
                GoToStep(0);
            }
        }
        private void buttonArchive_Click(object sender, RoutedEventArgs e)
        {
            ModData md = new ModData();

            md.Creator     = tbCreator.Text;
            md.Description = StringFromRichTextBox(rtbDesc);
            GameProfile selGame = (GameProfile)dropDownGames.SelectedItem;

            md.GameXML = Path.GetFileName(selGame.FileName);
            md.ModName = tbModName.Text;
            Guid obj = Guid.NewGuid();

            md.GUID = obj.ToString();
            WriteToXmlFile(textBoxDir.Text + "\\" + md.GUID + ".xml", md);
            using (FileStream zipToOpen = new FileStream(textBoxDir.Text + "\\" + md.GUID + ".zip", FileMode.Create))
            {
                using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create))
                {
                    foreach (string ss in filesToArchive)
                    {
                        archive.CreateEntryFromFile(ss, ss.Replace(textBoxDir.Text + "\\", ""));
                    }
                }
            }
            Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage("Mod created successfully!");
            _contentControl.Content = _modmenu;
        }
Example #6
0
        public GameRunning(GameProfile gameProfile, bool isTest, ParrotData parrotData, string testMenuString, bool testMenuIsExe = false, string testMenuExe = "", bool runEmuOnly = false)
        {
            InitializeComponent();
            _runEmuOnly          = runEmuOnly;
            _gameLocation        = gameProfile.GamePath;
            InputCode.ButtonMode = gameProfile.EmulationProfile;
            _isTest            = isTest;
            _gameProfile       = gameProfile;
            _serialPortHandler = new SerialPortHandler();
            _parrotData        = parrotData;
            _testMenuString    = testMenuString;
            _testMenuIsExe     = testMenuIsExe;
            _testMenuExe       = testMenuExe;
            if (parrotData?.GunSensitivityPlayer1 > 10)
            {
                _player1GunMultiplier = 10;
            }
            if (parrotData?.GunSensitivityPlayer1 < 0)
            {
                _player1GunMultiplier = 0;
            }

            if (parrotData?.GunSensitivityPlayer2 > 10)
            {
                _player2GunMultiplier = 10;
            }
            if (parrotData?.GunSensitivityPlayer2 < 0)
            {
                _player2GunMultiplier = 0;
            }
        }
Example #7
0
        public int InsertOrUpdateGameProfile(GameProfile gameProfile)
        {
            try
            {
                SqlParameter[] sqlParameters = new SqlParameter[14];

                sqlParameters[0]  = new SqlParameter("@id", gameProfile.Id);
                sqlParameters[1]  = new SqlParameter("@name", string.IsNullOrEmpty(gameProfile.Name) ? "" : gameProfile.Name);
                sqlParameters[2]  = new SqlParameter("@normalPrice", gameProfile.NormalPrice);
                sqlParameters[3]  = new SqlParameter("@vipPrice", gameProfile.VIPPrice);
                sqlParameters[4]  = new SqlParameter("@creditAllowed", gameProfile.CreditAllowed);
                sqlParameters[5]  = new SqlParameter("@bonusAllowed", gameProfile.BonusAllowed);
                sqlParameters[6]  = new SqlParameter("@courtesyAllowed", gameProfile.CourtesyAllowed);
                sqlParameters[7]  = new SqlParameter("@timeAllowed", gameProfile.TimeAllowed);
                sqlParameters[8]  = new SqlParameter("@tiketAllowedOnCredit", gameProfile.TiketAllowedOnCredit);
                sqlParameters[9]  = new SqlParameter("@tiketAllowedOnBonus", gameProfile.TiketAllowedOnBonus);
                sqlParameters[10] = new SqlParameter("@tiketAllowedOnCourtesy", gameProfile.TiketAllowedOnCourtesy);
                sqlParameters[11] = new SqlParameter("@tiketAllowedOnTime", gameProfile.TiketAllowedOnTime);
                sqlParameters[12] = new SqlParameter("@lastUpdatedDate", DateTime.Now);
                sqlParameters[13] = new SqlParameter("@lastUpdatedBy", string.IsNullOrEmpty(gameProfile.LastUpdatedBy) ? "" : gameProfile.LastUpdatedBy);

                return(conn.executeUpdateQuery("sp_InsertOrUpdateGameProfile", sqlParameters));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public List <GameProfile> SelectAll()
        {
            List <GameProfile> gamesList = new List <GameProfile>();

            string sqlConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(sqlConnectionString))
            {
                conn.Open();

                using (SqlCommand cmd = new SqlCommand("dbo.Games_SelectAll", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    while (reader.Read())
                    {
                        GameProfile model = Mapper(reader);
                        gamesList.Add(model);
                    }
                }

                conn.Close();
            }

            return(gamesList);
        }
        public static void DeleteGameProfile(string[] args)
        {
            string      arg     = args[0];
            GameProfile profile = ProfileManager.FindProfile(arg);

            if (profile == null)
            {
                PrettyPrinter.Print("profile not found by id or title");
                return;
            }

            PrettyPrinter.Print($"are you sure you want to delete? '{profile.ProfileName}' | {profile.ProfileID}");
            Console.Write("y / n > ");
            ConsoleKeyInfo input = Console.ReadKey();

            System.Console.WriteLine();

            if (input.Key.ToString() != "Y")
            {
                PrettyPrinter.Print("deletion terminated");
                return;
            }

            PrettyPrinter.Print($"Deleted profile ({profile.ProfileID} | {profile.ProfileName})");
            ProfileManager.DeleteProfile(profile);
        }
Example #10
0
        //Returns all list of GameProfiles that are found in Spectabis config folder
        public List <GameProfile> AllGames()
        {
            List <GameProfile> allGames = new List <GameProfile>();

            if (Directory.Exists(ProfileFolder))
            {
                foreach (var folder in Directory.GetDirectories(ProfileFolder))
                {
                    if (!folder.Contains("#"))
                    {
                        GameProfile profile = new GameProfile();

                        profile.Title            = folder.ToString().Replace(ProfileFolder, String.Empty);
                        profile.ImageLink        = $"{folder}\\art.jpg";
                        profile.Image            = NewImage(profile.ImageLink);
                        profile.SpectabisIniPath = $"{folder}\\spectabis.ini";
                        profile.ProfilePath      = folder;
                        profile.Platform         = "Playstation 2";

                        allGames.Add(profile);
                    }
                }
                return(allGames);
            }
            else
            {
                Console.WriteLine("Profile Folder not found...");
                return(allGames);
            }
        }
Example #11
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     Console.WriteLine(Name_Textbox.Text);
     Console.WriteLine(BaseDirectory + @"\resources\configs\" + Name_Textbox.Text);
     GameProfile.Delete(Name_Textbox.Text);
     ((MainWindow)Application.Current.MainWindow).Open_Library();
 }
Example #12
0
        public async Task <IActionResult> GameProfiles(GameProfilesViewModel gamesViewModel)
        {
            if (!ModelState.IsValid)
            {
                ViewData["errorMessage"] = "één of meerdere waren niet correct ingevuld.";
                return(View(gamesViewModel));
            }

            var user = await _dbContext.Users
                       .Include(u => u.GameProfiles)
                       .ThenInclude(gp => gp.Game)
                       .SingleOrDefaultAsync(u => u.UserName == User.Identity.Name);

            foreach ((var gameName, var userName) in gamesViewModel.Profiles.Where(p => p.Value is not null))
            {
                var game = _dbContext.Games.FirstOrDefault(g => g.Name == gameName);
                if (game is null)
                {
                    return(BadRequest());
                }
                var existingProfile = user.GameProfiles.SingleOrDefault(gp => gp.Game.Name == game.Name);
                if (existingProfile is null)
                {
                    var profile = new GameProfile(userName, game);
                    user.GameProfiles.Add(profile);
                }
                else
                {
                    existingProfile.ProfileName = userName;
                }
                await _dbContext.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(Detail), new { id = user.UserName }));
        }
Example #13
0
        private void BrowserBtns_OnBrowse(bool previous, bool next, bool play)
        {
            if (previous)
            {
                currentStepIndex--;
                if (currentStepIndex < 0)
                {
                    currentStepIndex = 0;
                    return;
                }
                GoToStep(currentStepIndex);
            }
            else if (next)
            {
                currentStepIndex = Math.Min(++currentStepIndex, stepsList.Count - 1);
                GoToStep(currentStepIndex);
            }
            else if (play)
            {
                //this.overlay.EnableOverlay(this);

                handler = new GameHandler();
                handler.Initialize(handlerDataManager, userGame, GameProfile.CleanClone(currentProfile));
                handler.Ended += handler_Ended;

                GameManager.Instance.Play(handler);
                if (handlerData.HandlerInterval > 0)
                {
                    handlerThread = new Thread(UpdateGameManager);
                    handlerThread.Start();
                }
                //WindowState = FormWindowState.Minimized;
            }
        }
Example #14
0
        public bool Initialize(HandlerData handlerData, UserGameInfo userGameInfo, GameProfile profile)
        {
            this._handlerData = handlerData;
            this._userGame    = userGameInfo;
            this._profile     = profile;

            modules = new List <HandlerModule>();
            foreach (ModuleInfo info in GameManager.Instance.ModuleManager.Modules)
            {
                if (info.IsNeeded(handlerData))
                {
                    modules.Add((HandlerModule)Activator.CreateInstance(info.ModuleType));
                }
            }

            // order modules
            modules = modules.OrderBy(c => c.Order).ToList();

            for (int i = 0; i < modules.Count; i++)
            {
                modules[i].Initialize(this, handlerData, userGameInfo, profile);
            }

            return(true);
        }
Example #15
0
        public void Initialize(UserGameInfo game, GameProfile profile)
        {
            string documents    = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string configFolder = Path.Combine(documents, @"My Games\Borderlands 2\WillowGame\SaveData");

            DirectoryInfo[] userDirs = new DirectoryInfo(configFolder).GetDirectories();

            for (int i = 0; i < userDirs.Length; i++)
            {
                DirectoryInfo user = userDirs[i];

                FileInfo[] saves = user.GetFiles("*.sav");
                for (int j = 0; j < saves.Length; j++)
                {
                    FileInfo save = saves[j];

                    BorderlandsSaveControl con = new BorderlandsSaveControl();
                    using (Stream s = save.OpenRead())
                    {
                        con.SaveFile = SaveFile.Deserialize(s, SaveFile.DeserializeSettings.None);
                    }

                    con.UserName = user.Name;
                    //con.SaveName = con.SaveFile.SaveGame.AppliedCustomizations;
                    this.flowLayoutPanel1.Controls.Add(con);
                }
            }
        }
Example #16
0
        public override void Initialize(UserGameInfo game, GameProfile profile)
        {
            base.Initialize(game, profile);

            gamepadTimer.Enabled = true;
            UpdatePlayers();
        }
        public IEnumerator CreateGameProfile_Success()
        {
            GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles();

            Result <GameProfile> createGameProfileResult = null;

            gameProfiles.CreateGameProfile(
                new GameProfileRequest
            {
                label       = "GameProfile Test",
                profileName = "ProfileName Test",
                tags        = new string[] { "tag1", "tag2", "tag3" },
                attributes  = new Dictionary <string, string>()
                {
                    { "test", "test123" }, { "name", "testName" }
                }
            },
                result => { createGameProfileResult = result; });

            while (createGameProfileResult == null)
            {
                Thread.Sleep(100);

                yield return(null);
            }

            TestHelper.LogResult(createGameProfileResult, "Create game profile");
            Assert.That(!createGameProfileResult.IsError);
            Assert.NotNull(createGameProfileResult.Value);
            this.gameProfile = createGameProfileResult.Value;
        }
        // ---------[ EVENTS ]---------
        /// <summary>Updates the tag categories.</summary>
        public void OnGameProfileUpdated(GameProfile gameProfile)
        {
            // get length
            int categoryCount = 0;

            if (gameProfile != null &&
                gameProfile.tagCategories != null)
            {
                categoryCount = gameProfile.tagCategories.Length;
            }

            // build new map
            this.m_tagCategoryMap = new Dictionary <string, string>(categoryCount);
            for (int i = 0; i < categoryCount; ++i)
            {
                ModTagCategory category = gameProfile.tagCategories[i];
                if (category.tags != null)
                {
                    foreach (string tagName in category.tags)
                    {
                        this.m_tagCategoryMap[tagName] = category.name;
                    }
                }
            }

            // resfresh
            this.DisplayTags(this.m_tags);
        }
 public override void Initialize(List <string> arguments)
 {
     lobbyMode = arguments[0].Equals("new game") ? LobbyMode.NEW_GAME :
                 arguments[0].Equals("load game") ? LobbyMode.LOAD_GAME : LobbyMode.ONLY_SERVER;
     ServerEvents.Initialize();
     ServerEvents.singleton.StartAgrs = arguments;
     if (lobbyMode == LobbyMode.LOAD_GAME)
     {
         allProfiles = new List <List <string> >();
         for (int i = 2; i < arguments.Count; i++)
         {
             List <string> toAdd = new List <string>();
             toAdd.AddRange(arguments[i].Split(new [] { '|' }, StringSplitOptions.RemoveEmptyEntries));
             allProfiles.Add(toAdd);
         }
         loadedGameName = arguments[1];
     }
     else
     {
         profile = new GameProfile().Serialize();
         ServerEvents.singleton.NewWorldName   = "World " + GameManager.rnd.Next();
         ServerEvents.singleton.SeedToGenerate = "5";
         ServerEvents.singleton.SeedToSpawn    = "4";
         profileName = "Player " + GameManager.rnd.Next();
     }
 }
Example #20
0
 private bool FetchProfile(string profile)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(profile))
         {
             return(false);
         }
         var a = profile.Substring(10, profile.Length - 10);
         if (string.IsNullOrWhiteSpace(a))
         {
             return(false);
         }
         var b = Path.Combine("GameProfiles\\", a);
         if (!File.Exists(b))
         {
             return(false);
         }
         if (File.Exists(Path.Combine("UserProfiles\\", a)))
         {
             _profile = JoystickHelper.DeSerializeGameProfile(Path.Combine("UserProfiles\\", a));
         }
         else
         {
             _profile = JoystickHelper.DeSerializeGameProfile(b);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #21
0
        private void SetupSteps(GameHandlerMetadata metadataSelected)
        {
            KillCurrentStep();

            if (handlerDataManager != null)
            {
                // dispose
                handlerDataManager.Dispose();
                handlerDataManager = null;
            }

            selectedHandler    = metadataSelected;
            handlerDataManager = GameManager.Instance.PackageManager.ReadHandlerDataFromInstalledPackage(selectedHandler);
            handlerData        = handlerDataManager.HandlerData;

            BrowserBtns.SetPlayButtonState(false);

            stepsList = new List <UserInputControl>();
            stepsList.Add(positionsControl);
            stepsList.Add(optionsControl);
            if (handlerData.CustomSteps != null)
            {
                for (int i = 0; i < handlerData.CustomSteps.Count; i++)
                {
                    stepsList.Add(jsControl);
                }
            }

            currentProfile = new GameProfile();
            currentProfile.InitializeDefault(handlerData);

            MainForm.Instance.ChangeGameInfo(userGame);
        }
Example #22
0
        private void btn_Play_Click(object sender, EventArgs e)
        {
            if (btn_Play.Text == "S T O P")
            {
                if (handler.FakeFocus != null)
                {
                    handler.FakeFocus.Abort();
                }
                if (handler != null)
                {
                    Log("Stop button clicked, calling Handler End function");
                    handler.End();
                }
                SetBtnToPlay();
                btn_Play.Enabled = false;
                this.Controls.Clear();
                this.InitializeComponent();
                RefreshGames();

                return;
            }

            btn_Play.Text   = "S T O P";
            btnBack.Enabled = false;

            handler = gameManager.MakeHandler(currentGame);
            handler.Initialize(currentGameInfo, GameProfile.CleanClone(currentProfile));
            handler.Ended += handler_Ended;

            gameManager.Play(handler);
            if (handler.TimerInterval > 0)
            {
                handlerThread = new Thread(UpdateGameManager);
                handlerThread.Start();
            }

            if (currentGame.HideTaskbar)
            {
                User32Util.HideTaskbar();
            }

            if (currentGame.HideDesktop)
            {
                foreach (Screen screen in Screen.AllScreens)
                {
                    System.Windows.Forms.Form hform = new System.Windows.Forms.Form();
                    hform.BackColor       = Color.Black;
                    hform.Location        = new Point(0, 0);
                    hform.Size            = screen.WorkingArea.Size;
                    this.Size             = screen.WorkingArea.Size;
                    hform.FormBorderStyle = FormBorderStyle.None;
                    hform.StartPosition   = FormStartPosition.Manual;
                    //hform.TopMost = true;
                    hform.Show();
                }
            }

            WindowState = FormWindowState.Minimized;
        }
Example #23
0
        public override bool Initialize(GameHandler handler, HandlerData handlerData, UserGameInfo game, GameProfile profile)
        {
            this.userGame    = game;
            this.profile     = profile;
            this.handlerData = handlerData;

            return(true);
        }
 public void LoadNewSettings(GameProfile gameProfile, ComboBoxItem comboItem)
 {
     _gameProfile                 = gameProfile;
     _comboItem                   = comboItem;
     GamePathBox.Text             = _gameProfile.GamePath;
     GameSettingsList.ItemsSource = gameProfile.ConfigValues;
     Lazydata.GamePath            = string.Empty;
 }
Example #25
0
        public void SetGameProfile(IGameProfile gameProfile)
        {
            SetIwadInfoLabel();

            UnregisterEvents();
            m_handler = new FileLoadHandler(m_adapter, GameFile, gameProfile);

            SetDefaultSelections();
            GameProfile.ApplyDefaultsToProfile(gameProfile, m_appConfig);
            cmbProfiles.SelectedValue = gameProfile.GameProfileID;

            if (GameFile != null)
            {
                chkSaveStats.Checked      = gameProfile.SettingsStat;
                chkLoadLatestSave.Checked = gameProfile.SettingsLoadLatestSave;

                if (gameProfile.SourcePortID.HasValue)
                {
                    SelectedSourcePort = m_adapter.GetSourcePort(gameProfile.SourcePortID.Value);
                }

                // Selected GameFile is an IWAD so lock the IWAD selection
                if (IsIwad(GameFile))
                {
                    cmbIwad.Enabled = false;
                    SelectedIWad    = GameFile;
                }
                else if (gameProfile.IWadID.HasValue)
                {
                    SelectedIWad = m_adapter.GetGameFileIWads().FirstOrDefault(x => x.IWadID == gameProfile.IWadID);
                }

                if (!string.IsNullOrEmpty(gameProfile.SettingsMap))
                {
                    SelectedMap = gameProfile.SettingsMap;
                }
                if (!string.IsNullOrEmpty(gameProfile.SettingsSkill))
                {
                    SelectedSkill = gameProfile.SettingsSkill;
                }
                if (!string.IsNullOrEmpty(gameProfile.SettingsExtraParams))
                {
                    ExtraParameters = gameProfile.SettingsExtraParams;
                }
                if (!string.IsNullOrEmpty(gameProfile.SettingsSpecificFiles))
                {
                    SpecificFiles = Util.SplitString(gameProfile.SettingsSpecificFiles);
                }
            }

            bool reset = ShouldRecalculateAdditionalFiles();

            HandleSourcePortSelectionChange(reset);
            HandleIwadSelectionChanged(reset);
            SetAdditionalFiles(reset);
            HandleDemoChange();
            RegisterEvents();
        }
Example #26
0
        public async Task <bool> EditGameProfileAsync(GameProfile param)
        {
            string json = await Task.Run(() => JsonConvert.SerializeObject(param));

            HttpContent         content = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage result  = await _httpClient.PutAsync(new Uri(gameProfilesBaseUri, "GameProfiles/" + param.ID.ToString()), content);

            return(result.IsSuccessStatusCode);
        }
 public virtual List<string> GetProfile()
 {
     if (lobbyMode == LobbyMode.NEW_GAME) {
         GameProfile prf = new GameProfile();
         prf.ProfileName = profileName;
         return prf.Serialize();
     }
     else
         return profile;
 }
Example #28
0
 public void LoadNewSettings(GameProfile gameProfile, ListBoxItem comboItem, ContentControl contentControl, Library library)
 {
     _gameProfile                 = gameProfile;
     _comboItem                   = comboItem;
     GamePathBox.Text             = _gameProfile.GamePath;
     GameSettingsList.ItemsSource = gameProfile.ConfigValues;
     Lazydata.GamePath            = string.Empty;
     _contentControl              = contentControl;
     _library = library;
 }
Example #29
0
 //Game title textbox
 private void Name_Textbox_LostFocus(object sender, RoutedEventArgs e)
 {
     Console.WriteLine(title);
     if (title != Name_Textbox.Text)
     {
         title             = GameProfile.Rename(title, Name_Textbox.Text);
         Name_Textbox.Text = title;
         Console.WriteLine(title);
     }
 }
        // ---------[ EVENTS ]---------
        /// <summary>React to game profile update message.</summary>
        public void OnGameProfileUpdated(GameProfile gameProfile)
        {
            Debug.Assert(gameProfile != null);

            if (this.m_tagCategories != gameProfile.tagCategories)
            {
                this.m_tagCategories = gameProfile.tagCategories;
                this.Refresh();
            }
        }
Example #31
0
        private async Task LoadBattleNetUserDataAsync(GGCharityUser user, string accessToken)
        {
            Trace.TraceInformation("Calling GetProfileAsync for battle.net user {0}", user.UserName);
            var profile = await BattleNetApi.StarCraft.Api.GetProfileAsync(BattleNetApi.Region.US, accessToken);

            if (profile.Characters.Count > 1)
            {
                Trace.TraceEvent(TraceEventType.Critical, 0, "User {0} has {1} StarCraft characters!", user.Email, profile.Characters.Count);
                throw new NotSupportedException();
            }

            if (profile.Characters.Count == 0)
            {
                Trace.TraceInformation("User {0} has no StarCraft characters", user.Email);
                return;
            }

            await Data.PerformAsync(async () =>
            {
                GameProfile oldStarcraftProfile = user.GameProfiles.Where(p => p.GameId == GameID.StarCraft).SingleOrDefault();
                if (oldStarcraftProfile == null)
                {
                    Trace.TraceInformation("User {0} does not have a StarCraft game profile, creating one", user.UserName);

                    var gameProfile = new GameProfile
                    {
                        GameId = GameID.StarCraft,
                        ProfileData = profile.JsonString,
                        ProfileDataVersion = profile.Version,
                        UserId = user.Id,
                        AdditionalData = profile.Region.ToString()
                    };

                    user.GameProfiles.Add(gameProfile);
                    Data.GameProfiles.Add(gameProfile);
                }
                else
                {
                    Trace.TraceInformation("User {0} already has a StarCraft game profile, refreshing it", user.UserName);
                    oldStarcraftProfile.ResetData(profile.JsonString, profile.Version, profile.Region.ToString());
                }

                await Data.SaveChangesAsync();
                Trace.TraceInformation("User {0}'s StarCraft game profile was saved successfully", user.UserName);
            });
        }