private void _LoadAvatars(bool keep) { int selectedAvatarID = _SelectSlides[_SelectSlideAvatars].SelectedTag; _SelectSlides[_SelectSlideAvatars].Clear(); IEnumerable <CAvatar> avatars = CProfiles.GetAvatars(); if (avatars != null) { foreach (CAvatar avatar in avatars) { _SelectSlides[_SelectSlideAvatars].AddValue(avatar.GetDisplayName(), null, avatar.ID); } } if (keep) { _SelectSlides[_SelectSlideAvatars].SelectedTag = selectedAvatarID; CProfiles.SetAvatar(_NewProfileID, selectedAvatarID); } else { _SelectSlides[_SelectSlideAvatars].SelectedTag = CProfiles.GetAvatarID(_NewProfileID); } _AvatarsChanged = false; }
private void SaveProfiles() { _EditMode = EEditMode.None; CProfiles.SaveProfiles(); LoadProfiles(); UpdateGame(); }
private void _UpdatePlayerNumber() { CConfig.Config.Game.NumPlayers = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1; CGame.NumPlayers = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1; for (int i = 1; i <= CSettings.MaxNumPlayer; i++) { if (i <= CGame.NumPlayers) { _Statics["StaticPlayer" + i].Visible = true; _Statics["StaticPlayerAvatar" + i].Visible = true; _Texts["TextPlayer" + i].Visible = true; if (_Texts["TextPlayer" + i].Text == "") { _Texts["TextPlayer" + i].Text = CProfiles.GetPlayerName(-1, i); } _Equalizers["EqualizerPlayer" + i].Visible = true; if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet) { _SelectSlides["SelectSlideDuetPlayer" + i].Visible = true; } } else { _Statics["StaticPlayer" + i].Visible = false; _Statics["StaticPlayerAvatar" + i].Visible = false; _Texts["TextPlayer" + i].Visible = false; _Equalizers["EqualizerPlayer" + i].Visible = false; _SelectSlides["SelectSlideDuetPlayer" + i].Visible = false; } } CConfig.SaveConfig(); _CheckMics(); _CheckPlayers(); }
private void OnSaveSnapshot() { string filename = "snapshot"; int i = 0; while (File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"))) { i++; } _Snapshot.Save(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"), System.Drawing.Imaging.ImageFormat.Png); CProfiles.LoadAvatars(); LoadAvatars(); _Snapshot = null; CWebcam.Stop(); CDraw.RemoveTexture(ref _WebcamTexture); for (int j = 0; j < CProfiles.Avatars.Length; j++) { if (CProfiles.Avatars[j].FileName == (filename + i + ".png")) { CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, j); break; } } Buttons[htButtons(ButtonSaveSnapshot)].Visible = false; Buttons[htButtons(ButtonDiscardSnapshot)].Visible = false; Buttons[htButtons(ButtonTakeSnapshot)].Visible = false; Buttons[htButtons(ButtonWebcam)].Visible = true; }
public static SProfileData[] GetProfileList() { List <SProfileData> result = new List <SProfileData>(CProfiles.NumProfiles); result.AddRange(CProfiles.GetProfiles().Select(profile => _CreateProfileData(profile, true))); return(result.ToArray()); }
public override void OnShow() { base.OnShow(); CProfiles.LoadProfiles(); LoadAvatars(); LoadProfiles(); UpdateGame(); }
public static SProfileData GetProfileData(Guid profileId, bool isReadonly) { CProfile profile = CProfiles.GetProfile(profileId); if (profile == null) { return(new SProfileData()); } return(_CreateProfileData(profile, isReadonly)); }
private void _ClosePopup() { string _NewProfileName = CProfiles.GetPlayerName(_NewProfileID); if (_NewProfileName.Length < 1) { _DeleteProfile(); } CGraphics.HidePopup(EPopupScreens.PopupNewPlayer); }
private void _SaveProfiles() { _EditMode = EEditMode.None; string _NewProfileName = CProfiles.GetPlayerName(_NewProfileID); if (_NewProfileName.Length > 1) { CProfiles.SaveProfiles(); } _ProfilesChanged = true; }
private void _LoadPlayerPanels() { for (int i = 0; i < CGame.NumPlayers; i++) { _NameSelections[_NameSelection].UseProfile(CGame.Players[i].ProfileID); _Statics[_PlayerStaticAvatar[i]].Texture = CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID) ? CProfiles.GetAvatarTextureFromProfile(CGame.Players[i].ProfileID) : _OriginalPlayerAvatarTextures[i]; _Texts[_PlayerText[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1); } _PopulateVoiceSelection(); }
public override void Init() { base.Init(); _BuildElementStrings(); _ChooseAvatarStatic = GetNewStatic(); _ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Aspect = EAspect.Crop; CProfiles.AddProfileChangedCallback(_OnProfileChanged); }
private void _NewProfile() { _EditMode = EEditMode.None; Guid id = CProfiles.NewProfile(); //_LoadProfiles(false); _NewProfileID = id; CProfiles.SetAvatar(_NewProfileID, _SelectSlides[_SelectSlideAvatars].SelectedTag); _SelectElement(_Buttons[_ButtonPlayerName]); //_EditMode = EEditMode.PlayerName; }
private void NewProfile() { _EditMode = EEditMode.None; CProfiles.NewProfile(); LoadProfiles(); SelectSlides[htSelectSlides(SelectSlideProfiles)].LastValue(); CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection); SetInteractionToButton(Buttons[htButtons(ButtonPlayerName)]); _EditMode = EEditMode.PlayerName; }
private void _LoadProfiles(bool keep) { string name = String.Empty; if (_EditMode == EEditMode.PlayerName) { name = CProfiles.GetPlayerName(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag)); } Guid selectedProfileID = _GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag); _SelectSlides[_SelectSlideProfiles].Clear(); _SelectSlideGuids.Clear(); CProfile[] profiles = CProfiles.GetProfiles(); int i = 0; foreach (CProfile profile in profiles) { _SelectSlides[_SelectSlideProfiles].AddValue(profile.PlayerName, null, i); _SelectSlideGuids.Add(i, profile.ID); i++; } if (CProfiles.NumProfiles > 0 && CProfiles.NumAvatars > 0) { if (selectedProfileID != Guid.Empty) { _SelectSlides[_SelectSlideProfiles].SelectedTag = _SelectSlideGuids.FirstOrDefault(x => x.Value.Equals(selectedProfileID)).Key; } else { _SelectSlides[_SelectSlideProfiles].Selection = 0; selectedProfileID = _GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag); } if (!keep) { _SelectSlides[_SelectSlideDifficulty].Selection = (int)CProfiles.GetDifficulty(selectedProfileID); _SelectSlides[_SelectSlideUserRole].Selection = (int)CProfiles.GetUserRoleProfile(selectedProfileID); _SelectSlides[_SelectSlideActive].Selection = (int)CProfiles.GetActive(selectedProfileID); _SelectSlides[_SelectSlideAvatars].SelectedTag = CProfiles.GetAvatarID(selectedProfileID); } if (_EditMode == EEditMode.PlayerName) { CProfiles.SetPlayerName(_GetIdFromTag(_SelectSlides[_SelectSlideProfiles].SelectedTag), name); } } _ProfilesChanged = false; }
public override void Init() { base.Init(); _ThemeButtons = new string[] { _ButtonPlayerName, _ButtonExit, _ButtonSave, _ButtonNew, _ButtonDelete, _ButtonWebcam, _ButtonSaveSnapshot, _ButtonDiscardSnapshot, _ButtonTakeSnapshot }; _ThemeSelectSlides = new string[] { _SelectSlideProfiles, _SelectSlideDifficulty, _SelectSlideAvatars, _SelectSlideUserRole, _SelectSlideActive }; _ThemeStatics = new string[] { _StaticAvatar }; _EditMode = EEditMode.None; _ProfilesChanged = false; _AvatarsChanged = false; CProfiles.AddProfileChangedCallback(_OnProfileChanged); }
public static int GetUserRole(Guid profileId) { CProfile profile = CProfiles.GetProfile(profileId); if (profile == null) { throw new ArgumentException("Invalid profileId"); } //Hide TR_USERROLE_GUEST and TR_USERROLE_NORMAL //const EUserRole mask = (EUserRole.TR_USERROLE_GUEST | EUserRole.TR_USERROLE_NORMAL); return((int)(profile.UserRole)); }
private void _ResetPlayerSelection(int playerNum) { _NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[playerNum].ProfileID); CGame.Players[playerNum].ProfileID = -1; //Update config for default players. CConfig.Config.Game.Players[playerNum] = String.Empty; CConfig.SaveConfig(); //Update texture and name _Statics[_StaticPlayerAvatar[playerNum]].Texture = _OriginalPlayerAvatarTextures[playerNum]; _Texts[_TextPlayer[playerNum]].Text = CProfiles.GetPlayerName(-1, playerNum + 1); //Update profile-warning _CheckPlayers(); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); }
private void _ResetPlayerSelections() { for (int i = 0; i < CGame.NumPlayers; i++) { _NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[i].ProfileID); CGame.Players[i].ProfileID = Guid.Empty; //Update config for default players. CConfig.Config.Game.Players[i] = String.Empty; //Update texture and name _Statics[_PlayerStaticAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i]; _Texts[_PlayerText[i]].Text = CProfiles.GetPlayerName(Guid.Empty, i + 1); } _NameSelections[_NameSelection].UpdateList(); CConfig.SaveConfig(); }
public static Guid GetUserIdFromUsername(string username) { IEnumerable <Guid> playerIds = (from p in CProfiles.GetProfiles() where String.Equals(p.PlayerName, username, StringComparison.OrdinalIgnoreCase) select p.ID); try { return(playerIds.First()); } catch (InvalidOperationException) { throw new ArgumentException("Invalid playername"); } }
private void _UpdatePlayerNumber() { CConfig.Config.Game.NumPlayers = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1; CGame.NumPlayers = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1; _AssignPlayerElements(); //_LoadPlayerPanels(); _ResetPlayerElements(); for (int i = 0; i < CSettings.MaxNumPlayer; i++) { if (i < CGame.NumPlayers) { _Buttons[_PlayerButton[i]].Visible = true; _Statics[_PlayerStatic[i]].Visible = true; _Statics[_PlayerStaticAvatar[i]].Visible = true; _Texts[_PlayerText[i]].Visible = true; if (CGame.Players[i].ProfileID != Guid.Empty) { _Statics[_PlayerStaticAvatar[i]].Texture = CProfiles.GetAvatarTexture(CProfiles.GetAvatarID(CGame.Players[i].ProfileID)); _Texts[_PlayerText[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1); } else { _Texts[_PlayerText[i]].Text = CProfiles.GetPlayerName(Guid.Empty, i + 1); _Statics[_PlayerStaticAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i]; } _Texts[_PlayerText[i]].Color = CBase.Themes.GetPlayerColor(i + 1); _Equalizers[_PlayerEqualizer[i]].Color.R = CBase.Themes.GetPlayerColor(i + 1).R; _Equalizers[_PlayerEqualizer[i]].Color.G = CBase.Themes.GetPlayerColor(i + 1).G; _Equalizers[_PlayerEqualizer[i]].Color.B = CBase.Themes.GetPlayerColor(i + 1).B; _Equalizers[_PlayerEqualizer[i]].MaxColor.R = CBase.Themes.GetPlayerColor(i + 1).R; _Equalizers[_PlayerEqualizer[i]].MaxColor.G = CBase.Themes.GetPlayerColor(i + 1).G; _Equalizers[_PlayerEqualizer[i]].MaxColor.B = CBase.Themes.GetPlayerColor(i + 1).B; _Equalizers[_PlayerEqualizer[i]].Visible = true; if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet) { _SelectSlides[_PlayerSelectSlideDuet[i]].Visible = true; } } else { _ResetPlayerSelection(i); } } CConfig.SaveConfig(); _CheckMics(); //_CheckPlayers(); }
private static byte[] _GetPasswordSalt(Guid profileId) { CProfile profile = CProfiles.GetProfile(profileId); if (profile == null) { throw new ArgumentException("Invalid profileId"); } if (profile.PasswordHash == null) { throw new ArgumentException("Emty password"); } return(profile.PasswordSalt); }
private void _NewProfile() { _EditMode = EEditMode.None; Guid id = CProfiles.NewProfile(); _LoadProfiles(false); int num = CProfiles.NumProfiles; _SelectSlides[_SelectSlideProfiles].SelectedTag = num; _SelectSlideGuids.Add(num, id); CProfiles.SetAvatar(id, _SelectSlides[_SelectSlideAvatars].SelectedTag); _SelectElement(_Buttons[_ButtonPlayerName]); _EditMode = EEditMode.PlayerName; }
private void _DeleteProfile() { _EditMode = EEditMode.None; CProfiles.DeleteProfile(_SelectSlides[_SelectSlideProfiles].SelectedTag); int selection = _SelectSlides[_SelectSlideProfiles].Selection; if (_SelectSlides[_SelectSlideProfiles].NumValues - 1 > selection) { _SelectSlides[_SelectSlideProfiles].Selection = selection + 1; } else { _SelectSlides[_SelectSlideProfiles].Selection = selection - 1; } }
private void _LoadProfiles(bool keep) { string name = String.Empty; if (_EditMode == EEditMode.PlayerName) { name = CProfiles.GetPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag); } int selectedProfileID = _SelectSlides[_SelectSlideProfiles].SelectedTag; _SelectSlides[_SelectSlideProfiles].Clear(); CProfile[] profiles = CProfiles.GetProfiles(); foreach (CProfile profile in profiles) { _SelectSlides[_SelectSlideProfiles].AddValue(profile.PlayerName, null, profile.ID); } if (CProfiles.NumProfiles > 0 && CProfiles.NumAvatars > 0) { if (selectedProfileID != -1) { _SelectSlides[_SelectSlideProfiles].SelectedTag = selectedProfileID; } else { _SelectSlides[_SelectSlideProfiles].Selection = 0; selectedProfileID = _SelectSlides[_SelectSlideProfiles].SelectedTag; } if (!keep) { _SelectSlides[_SelectSlideDifficulty].Selection = (int)CProfiles.GetDifficulty(selectedProfileID); _SelectSlides[_SelectSlideUserRole].Selection = (int)CProfiles.GetUserRoleProfile(selectedProfileID); _SelectSlides[_SelectSlideActive].Selection = (int)CProfiles.GetActive(selectedProfileID); _SelectSlides[_SelectSlideAvatars].SelectedTag = CProfiles.GetAvatarID(selectedProfileID); } if (_EditMode == EEditMode.PlayerName) { CProfiles.SetPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag, name); } } _ProfilesChanged = false; }
private void _UpdateSelectedProfile(int playerNum, Guid profileId) { _NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[playerNum].ProfileID); _NameSelections[_NameSelection].UseProfile(profileId); //Update Game-infos with new player CGame.Players[playerNum].ProfileID = profileId; //Update config for default players. CConfig.Config.Game.Players[playerNum] = CProfiles.GetProfileFileName(profileId); CConfig.SaveConfig(); //Update texture and name _Statics[_PlayerStaticAvatar[playerNum]].Texture = CProfiles.GetAvatarTextureFromProfile(profileId); _Texts[_PlayerText[playerNum]].Text = CProfiles.GetPlayerName(profileId); //Update profile-warning //_CheckPlayers(); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); }
public override void Init() { base.Init(); var statics = new List <string>(); statics.AddRange(_StaticPlayerAvatar); statics.AddRange(_StaticPlayer); statics.Add(_StaticWarningMics); statics.Add(_StaticWarningProfiles); _ThemeStatics = statics.ToArray(); var texts = new List <string> { _SelectSlidePlayerNumber }; texts.AddRange(_SelectSlideDuetPlayer); _ThemeSelectSlides = texts.ToArray(); texts.Clear(); texts.Add(_TextWarningMics); texts.Add(_TextWarningProfiles); texts.AddRange(_TextPlayer); _ThemeTexts = texts.ToArray(); texts.Clear(); texts.Add(_ButtonBack); texts.Add(_ButtonStart); _ThemeButtons = texts.ToArray(); texts.Clear(); texts.Add(_NameSelection); _ThemeNameSelections = texts.ToArray(); texts.Clear(); texts.AddRange(_EqualizerPlayer); _ThemeEqualizers = texts.ToArray(); _ChooseAvatarStatic = GetNewStatic(); _ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Aspect = EAspect.Crop; CProfiles.AddProfileChangedCallback(_OnProfileChanged); }
private void LoadProfiles() { _EditMode = EEditMode.None; SelectSlides[htSelectSlides(SelectSlideProfiles)].Clear(); for (int i = 0; i < CProfiles.NumProfiles; i++) { SelectSlides[htSelectSlides(SelectSlideProfiles)].AddValue(CProfiles.GetPlayerName(i)); } if (CProfiles.NumProfiles > 0 && CProfiles.NumAvatars > 0) { SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selection = (int)CProfiles.GetDifficulty(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selection = (int)CProfiles.GetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); SelectSlides[htSelectSlides(SelectSlideActive)].Selection = (int)CProfiles.GetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection = CProfiles.GetAvatarNr(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); } }
public override bool UpdateGame() { if (_AvatarsChanged) { _LoadAvatars(true); } if (_ProfilesChanged) { _LoadProfiles(true); } if (_SelectSlides[_SelectSlideProfiles].Selection > -1) { _Buttons[_ButtonPlayerName].Text.Text = CProfiles.GetPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag); if (_EditMode == EEditMode.PlayerName) { _Buttons[_ButtonPlayerName].Text.Text += "|"; } _SelectSlides[_SelectSlideDifficulty].Selection = (int)CProfiles.GetDifficulty(_SelectSlides[_SelectSlideProfiles].SelectedTag); _SelectSlides[_SelectSlideUserRole].Selection = (int)CProfiles.GetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].SelectedTag); _SelectSlides[_SelectSlideActive].Selection = (int)CProfiles.GetActive(_SelectSlides[_SelectSlideProfiles].SelectedTag); int avatarID = CProfiles.GetAvatarID(_SelectSlides[_SelectSlideProfiles].SelectedTag); _SelectSlides[_SelectSlideAvatars].SelectedTag = avatarID; if (_Snapshot == null) { if (CWebcam.IsCapturing()) { if (CWebcam.GetFrame(ref _WebcamTexture)) { _Statics[_StaticAvatar].Texture = _WebcamTexture; } } else { _Statics[_StaticAvatar].Texture = CProfiles.GetAvatarTexture(avatarID); } } } return(true); }
public override void Init() { base.Init(); _ThemeButtons = new string[] { _ButtonPlayerName, _ButtonCancel, _ButtonSave }; _ThemeSelectSlides = new string[] { _SelectSlideDifficulty, _SelectSlideAvatars }; _ThemeStatics = new string[] { _StaticAvatar }; _EditMode = EEditMode.None; _ProfilesChanged = false; _AvatarsChanged = false; _CursorBlink = false; _Timer = new Timer(); _Timer.Tick += new EventHandler(_TimerEvent); _Timer.Interval = 400; _Timer.Start(); CProfiles.AddProfileChangedCallback(_OnProfileChanged); }
private static CAvatar _AddAvatar(CBase64Image avatarData) { try { string filename = _SaveImage(avatarData, "snapshot", CConfig.ProfileFolders[0]); CAvatar avatar = CAvatar.GetAvatar(filename); if (avatar != null) { CProfiles.AddAvatar(avatar); return(avatar); } return(null); } catch { return(null); } }