Changed GuestProfile-option on profiles to UserRole. UserRole could now be set from Vocaluxe.
This commit is contained in:
1 parent
d9a2ea8ce0
commit
352b0181fa
10 files changed
+49
-40
No files matched your search
@@ -5,7 +5,8 @@ namespace ServerLib
|
||||
[Flags]
|
||||
internal enum EUserRoles
|
||||
{
|
||||
AuthenticatedUser = 0,
|
||||
Administrator = 1
|
||||
GuestUser = 0,
|
||||
AuthenticatedUser = 1,
|
||||
Administrator = 2
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,9 @@
|
||||
<string name="TR_RATING_WANNABE">Wannabe</string>
|
||||
<string name="TR_RATING_AMATEUR">Amateur</string>
|
||||
<string name="TR_RATING_TONE_DEAF">Tone Deaf</string>
|
||||
<string name="TR_USERROLE_GUEST">Guest</string>
|
||||
<string name="TR_USERROLE_NORMAL">Normal User</string>
|
||||
<string name="TR_USERROLE_ADMIN">Administrator</string>
|
||||
<string name="TR_CONFIG_SOFTWARE">Software</string>
|
||||
<string name="TR_CONFIG_OPENGL">OpenGL</string>
|
||||
<string name="TR_CONFIG_DIRECT3D">Direct3D</string>
|
||||
@@ -147,7 +150,7 @@
|
||||
<string name="TR_SCREENPROFILES_PLAYERNAME">Player Name</string>
|
||||
<string name="TR_SCREENPROFILES_GAMEDIFFICULTY">Game Difficulty</string>
|
||||
<string name="TR_SCREENPROFILES_AVATAR">Avatar</string>
|
||||
<string name="TR_SCREENPROFILES_GUESTPROFILE">Guest Profile</string>
|
||||
<string name="TR_SCREENPROFILES_USERROLE">User Role</string>
|
||||
<string name="TR_SCREENPROFILES_ACTIVE">Active</string>
|
||||
<string name="TR_SCREENPROFILES_BUTTON_NEW">New</string>
|
||||
<string name="TR_SCREENPROFILES_BUTTON_DELETE">Delete</string>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<ScreenProfiles>
|
||||
<ScreenVersion>2</ScreenVersion>
|
||||
<ScreenVersion>3</ScreenVersion>
|
||||
<Background1>
|
||||
<!--<Type>: Background type: None, Color, Texture, Video-->
|
||||
<Type>Video</Type>
|
||||
@@ -265,7 +265,7 @@
|
||||
<!--<Font>: Text font name-->
|
||||
<Font>Outline</Font>
|
||||
<!--<Text>: Nothing or translation tag-->
|
||||
<Text>TR_SCREENPROFILES_GUESTPROFILE</Text>
|
||||
<Text>TR_SCREENPROFILES_USERROLE</Text>
|
||||
<!--<Reflection> If exists:-->
|
||||
<!-- <Space>: Reflection Space-->
|
||||
<!-- <Height>: Reflection Height-->
|
||||
@@ -989,7 +989,7 @@
|
||||
<!--<NumVisible>: Number of visible elements in the slide-->
|
||||
<NumVisible>3</NumVisible>
|
||||
</SelectSlideAvatars>
|
||||
<SelectSlideGuestProfile>
|
||||
<SelectSlideUserRole>
|
||||
<!--<Skin>: Texture name-->
|
||||
<Skin>Invisible</Skin>
|
||||
<!--<SkinArrowLeft>: Texture name of left arrow-->
|
||||
@@ -1055,7 +1055,7 @@
|
||||
<TextStyle>Bold</TextStyle>
|
||||
<!--<NumVisible>: Number of visible elements in the slide-->
|
||||
<NumVisible>2</NumVisible>
|
||||
</SelectSlideGuestProfile>
|
||||
</SelectSlideUserRole>
|
||||
<SelectSlideActive>
|
||||
<!--<Skin>: Texture name-->
|
||||
<Skin>Invisible</Skin>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
ScreenProfiles
|
||||
++++++++++
|
||||
Version 3:
|
||||
Rename: <SelectSlideGuestProfile> to <SelectSlideUserRole>
|
||||
|
||||
++++++++++
|
||||
Version 2:
|
||||
|
||||
@@ -433,17 +433,17 @@ namespace Vocaluxe.Base
|
||||
_Profiles[profileID].Difficulty = difficulty;
|
||||
}
|
||||
|
||||
public static EOffOn GetGuestProfile(int profileID)
|
||||
public static EUserRole GetUserRoleProfile(int profileID)
|
||||
{
|
||||
return IsProfileIDValid(profileID) ? _Profiles[profileID].GuestProfile : EOffOn.TR_CONFIG_OFF;
|
||||
return IsProfileIDValid(profileID) ? _Profiles[profileID].UserRole : EUserRole.TR_USERROLE_GUEST;
|
||||
}
|
||||
|
||||
public static void SetGuestProfile(int profileID, EOffOn option)
|
||||
public static void SetUserRoleProfile(int profileID, EUserRole option)
|
||||
{
|
||||
if (!IsProfileIDValid(profileID))
|
||||
return;
|
||||
|
||||
_Profiles[profileID].GuestProfile = option;
|
||||
_Profiles[profileID].UserRole = option;
|
||||
}
|
||||
|
||||
public static EOffOn GetActive(int profileID)
|
||||
@@ -464,7 +464,7 @@ namespace Vocaluxe.Base
|
||||
if (!IsProfileIDValid(profileID))
|
||||
return true; // this will prevent from saving dummy profiles to highscore db
|
||||
|
||||
return _Profiles[profileID].GuestProfile == EOffOn.TR_CONFIG_ON;
|
||||
return _Profiles[profileID].UserRole == EUserRole.TR_USERROLE_GUEST;
|
||||
}
|
||||
|
||||
public static bool IsActive(int profileID)
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace Vocaluxe.Base.Server
|
||||
AvatarFileName = existingProfile.AvatarFileName,
|
||||
Avatar = existingProfile.Avatar,
|
||||
Difficulty = existingProfile.Difficulty,
|
||||
GuestProfile = existingProfile.GuestProfile,
|
||||
UserRole = existingProfile.UserRole,
|
||||
PlayerName = existingProfile.PlayerName
|
||||
};
|
||||
}
|
||||
@@ -193,7 +193,7 @@ namespace Vocaluxe.Base.Server
|
||||
newProfile = new CProfile
|
||||
{
|
||||
Active = EOffOn.TR_CONFIG_ON,
|
||||
GuestProfile = EOffOn.TR_CONFIG_OFF
|
||||
UserRole = EUserRole.TR_USERROLE_NORMAL
|
||||
};
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace Vocaluxe.Base.Server
|
||||
|
||||
if (profile.Type >= 0 && profile.Type <= 1)
|
||||
{
|
||||
newProfile.GuestProfile = (EOffOn)profile.Type;
|
||||
newProfile.UserRole = (EUserRole)profile.Type;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(profile.Password))
|
||||
@@ -281,7 +281,7 @@ namespace Vocaluxe.Base.Server
|
||||
IsEditable = !isReadonly,
|
||||
ProfileId = profile.ID,
|
||||
PlayerName = profile.PlayerName,
|
||||
Type = (int)profile.GuestProfile,
|
||||
Type = (int)profile.UserRole,
|
||||
Difficulty = (int)profile.Difficulty
|
||||
};
|
||||
|
||||
@@ -673,7 +673,7 @@ namespace Vocaluxe.Base.Server
|
||||
throw new ArgumentException("Invalid profileId");
|
||||
}
|
||||
|
||||
return profile.UserRoles;
|
||||
return (int)profile.UserRole;
|
||||
}
|
||||
|
||||
private static void _SetUserRole(int profileId, int userRole)
|
||||
@@ -684,7 +684,7 @@ namespace Vocaluxe.Base.Server
|
||||
throw new ArgumentException("Invalid profileId");
|
||||
}
|
||||
|
||||
profile.UserRoles = userRole;
|
||||
profile.UserRole = (EUserRole)userRole;
|
||||
|
||||
CProfiles.EditProfile(profile);
|
||||
CProfiles.Update();
|
||||
|
||||
@@ -40,13 +40,13 @@ namespace Vocaluxe.Screens
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
{
|
||||
get { return 2; }
|
||||
get { return 3; }
|
||||
}
|
||||
|
||||
private const string _SelectSlideProfiles = "SelectSlideProfiles";
|
||||
private const string _SelectSlideDifficulty = "SelectSlideDifficulty";
|
||||
private const string _SelectSlideAvatars = "SelectSlideAvatars";
|
||||
private const string _SelectSlideGuestProfile = "SelectSlideGuestProfile";
|
||||
private const string _SelectSlideUserRole = "SelectSlideUserRole";
|
||||
private const string _SelectSlideActive = "SelectSlideActive";
|
||||
private const string _ButtonPlayerName = "ButtonPlayerName";
|
||||
private const string _ButtonExit = "ButtonExit";
|
||||
@@ -73,7 +73,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
_ThemeButtons = new string[]
|
||||
{_ButtonPlayerName, _ButtonExit, _ButtonSave, _ButtonNew, _ButtonDelete, _ButtonWebcam, _ButtonSaveSnapshot, _ButtonDiscardSnapshot, _ButtonTakeSnapshot};
|
||||
_ThemeSelectSlides = new string[] {_SelectSlideProfiles, _SelectSlideDifficulty, _SelectSlideAvatars, _SelectSlideGuestProfile, _SelectSlideActive};
|
||||
_ThemeSelectSlides = new string[] {_SelectSlideProfiles, _SelectSlideDifficulty, _SelectSlideAvatars, _SelectSlideUserRole, _SelectSlideActive};
|
||||
_ThemeStatics = new string[] {_StaticAvatar};
|
||||
|
||||
_EditMode = EEditMode.None;
|
||||
@@ -91,7 +91,7 @@ namespace Vocaluxe.Screens
|
||||
_Buttons[_ButtonTakeSnapshot].Visible = false;
|
||||
_Buttons[_ButtonWebcam].Visible = CWebcam.IsDeviceAvailable();
|
||||
_SelectSlides[_SelectSlideDifficulty].SetValues<EGameDifficulty>(0);
|
||||
_SelectSlides[_SelectSlideGuestProfile].SetValues<EOffOn>(0);
|
||||
_SelectSlides[_SelectSlideUserRole].SetValues<EUserRole>(0);
|
||||
_SelectSlides[_SelectSlideActive].SetValues<EOffOn>(0);
|
||||
_Statics[_StaticAvatar].Aspect = EAspect.Crop;
|
||||
}
|
||||
@@ -176,10 +176,10 @@ namespace Vocaluxe.Screens
|
||||
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
||||
_SelectSlides[_SelectSlideAvatars].ValueIndex);
|
||||
}
|
||||
else if (_SelectSlides[_SelectSlideGuestProfile].Selected)
|
||||
else if (_SelectSlides[_SelectSlideUserRole].Selected)
|
||||
{
|
||||
CProfiles.SetGuestProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
||||
(EOffOn)_SelectSlides[_SelectSlideGuestProfile].Selection);
|
||||
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
||||
(EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
|
||||
}
|
||||
else if (_SelectSlides[_SelectSlideActive].Selected)
|
||||
{
|
||||
@@ -225,10 +225,10 @@ namespace Vocaluxe.Screens
|
||||
if (CWebcam.IsDeviceAvailable() && _WebcamTexture != null)
|
||||
_OnDiscardSnapshot();
|
||||
}
|
||||
else if (_SelectSlides[_SelectSlideGuestProfile].Selected)
|
||||
else if (_SelectSlides[_SelectSlideUserRole].Selected)
|
||||
{
|
||||
CProfiles.SetGuestProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
||||
(EOffOn)_SelectSlides[_SelectSlideGuestProfile].Selection);
|
||||
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
||||
(EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
|
||||
}
|
||||
else if (_SelectSlides[_SelectSlideActive].Selected)
|
||||
{
|
||||
@@ -265,7 +265,7 @@ namespace Vocaluxe.Screens
|
||||
_Buttons[_ButtonPlayerName].Text.Text += "|";
|
||||
|
||||
_SelectSlides[_SelectSlideDifficulty].Selection = (int)CProfiles.GetDifficulty(_SelectSlides[_SelectSlideProfiles].ValueIndex);
|
||||
_SelectSlides[_SelectSlideGuestProfile].Selection = (int)CProfiles.GetGuestProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex);
|
||||
_SelectSlides[_SelectSlideUserRole].Selection = (int)CProfiles.GetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex);
|
||||
_SelectSlides[_SelectSlideActive].Selection = (int)CProfiles.GetActive(_SelectSlides[_SelectSlideProfiles].ValueIndex);
|
||||
|
||||
int avatarID = CProfiles.GetAvatarID(_SelectSlides[_SelectSlideProfiles].ValueIndex);
|
||||
@@ -428,7 +428,7 @@ namespace Vocaluxe.Screens
|
||||
if (!keep)
|
||||
{
|
||||
_SelectSlides[_SelectSlideDifficulty].Selection = (int)CProfiles.GetDifficulty(selectedProfileID);
|
||||
_SelectSlides[_SelectSlideGuestProfile].Selection = (int)CProfiles.GetGuestProfile(selectedProfileID);
|
||||
_SelectSlides[_SelectSlideUserRole].Selection = (int)CProfiles.GetUserRoleProfile(selectedProfileID);
|
||||
_SelectSlides[_SelectSlideActive].Selection = (int)CProfiles.GetActive(selectedProfileID);
|
||||
_SelectSlides[_SelectSlideAvatars].SetSelectionByValueIndex(CProfiles.GetAvatarID(selectedProfileID));
|
||||
}
|
||||
|
||||
@@ -349,4 +349,11 @@ namespace VocaluxeLib
|
||||
|
||||
NoPopup = -1
|
||||
}
|
||||
|
||||
public enum EUserRole
|
||||
{
|
||||
TR_USERROLE_GUEST = 0,
|
||||
TR_USERROLE_NORMAL = 1,
|
||||
TR_USERROLE_ADMIN = 2
|
||||
}
|
||||
}
|
||||
@@ -508,7 +508,7 @@ namespace VocaluxeLib.Menu
|
||||
for (int p = 0; p < CBase.Game.GetNumPlayer(); p++)
|
||||
{
|
||||
//Don't show profile if is selected, but if selected and guest
|
||||
if (CBase.Game.GetPlayers()[p].ProfileID == profile.ID && profile.GuestProfile == EOffOn.TR_CONFIG_OFF)
|
||||
if (CBase.Game.GetPlayers()[p].ProfileID == profile.ID && profile.UserRole == EUserRole.TR_USERROLE_GUEST)
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ namespace VocaluxeLib.Profile
|
||||
public string AvatarFileName;
|
||||
public byte[] PasswordHash;
|
||||
public byte[] PasswordSalt;
|
||||
public int UserRoles;
|
||||
|
||||
public EGameDifficulty Difficulty;
|
||||
|
||||
@@ -47,7 +46,7 @@ namespace VocaluxeLib.Profile
|
||||
}
|
||||
}
|
||||
|
||||
public EOffOn GuestProfile;
|
||||
public EUserRole UserRole;
|
||||
public EOffOn Active;
|
||||
|
||||
public CProfile()
|
||||
@@ -55,7 +54,7 @@ namespace VocaluxeLib.Profile
|
||||
PlayerName = String.Empty;
|
||||
Difficulty = EGameDifficulty.TR_CONFIG_EASY;
|
||||
Avatar = new CAvatar(-1);
|
||||
GuestProfile = EOffOn.TR_CONFIG_OFF;
|
||||
UserRole = EUserRole.TR_USERROLE_NORMAL;
|
||||
Active = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
AvatarFileName = String.Empty;
|
||||
@@ -88,7 +87,7 @@ namespace VocaluxeLib.Profile
|
||||
|
||||
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref Difficulty);
|
||||
xmlReader.GetValue("//root/Info/Avatar", out AvatarFileName, String.Empty);
|
||||
xmlReader.TryGetEnumValue("//root/Info/GuestProfile", ref GuestProfile);
|
||||
xmlReader.TryGetEnumValue("//root/Info/UserRole", ref UserRole);
|
||||
xmlReader.TryGetEnumValue("//root/Info/Active", ref Active);
|
||||
string passwordHash;
|
||||
xmlReader.GetValue("//root/Info/PasswordHash", out passwordHash, "");
|
||||
@@ -96,9 +95,6 @@ namespace VocaluxeLib.Profile
|
||||
string passwordSalt;
|
||||
xmlReader.GetValue("//root/Info/PasswordSalt", out passwordSalt, "");
|
||||
PasswordSalt = !string.IsNullOrEmpty(passwordSalt) ? Convert.FromBase64String(passwordSalt) : null;
|
||||
string userRoles;
|
||||
xmlReader.GetValue("//root/Info/UserRoles", out userRoles, "0");
|
||||
Int32.TryParse(userRoles, out UserRoles);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -157,7 +153,7 @@ namespace VocaluxeLib.Profile
|
||||
writer.WriteElementString("PlayerName", PlayerName);
|
||||
writer.WriteElementString("Difficulty", Enum.GetName(typeof(EGameDifficulty), Difficulty));
|
||||
writer.WriteElementString("Avatar", Path.GetFileName(Avatar.FileName));
|
||||
writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), GuestProfile));
|
||||
writer.WriteElementString("UserRole", Enum.GetName(typeof(EUserRole), UserRole));
|
||||
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), Active));
|
||||
if (PasswordHash != null)
|
||||
{
|
||||
@@ -167,7 +163,6 @@ namespace VocaluxeLib.Profile
|
||||
{
|
||||
writer.WriteElementString("PasswordSalt", Convert.ToBase64String(PasswordSalt));
|
||||
}
|
||||
writer.WriteElementString("UserRoles", UserRoles.ToString());
|
||||
writer.WriteEndElement();
|
||||
|
||||
writer.WriteEndElement(); //end of root
|
||||
|
||||
Reference in new issue
Block a user