implemented basics of skin system.

This commit is contained in:
Harrison Deng 2019-01-26 23:57:00 -06:00
parent 261b79c7b4
commit 1ae37bb219
4 changed files with 70 additions and 17 deletions

Binary file not shown.

View File

@ -637,6 +637,13 @@
RGBA data of this color. RGBA data of this color.
</summary> </summary>
</member> </member>
<member name="M:RecrownedAthenaeum.Data.SkinData.ColorData.#ctor(System.String,Microsoft.Xna.Framework.Color)">
<summary>
Sets values for data.
</summary>
<param name="name">the name to be referenced by.</param>
<param name="color">The color value <paramref name="name"/> represents.</param>
</member>
<member name="T:RecrownedAthenaeum.Data.SkinData.DefinitionData"> <member name="T:RecrownedAthenaeum.Data.SkinData.DefinitionData">
<summary> <summary>
Definition data for data transfer. Definition data for data transfer.
@ -652,6 +659,13 @@
The skin definition data. The skin definition data.
</summary> </summary>
</member> </member>
<member name="M:RecrownedAthenaeum.Data.SkinData.DefinitionData.#ctor(System.String,RecrownedAthenaeum.UI.Skin.Definitions.ISkinDefinitionData)">
<summary>
Sets values for data.
</summary>
<param name="name">The name to be referenced by.</param>
<param name="skinDefinitionData">The skin data.</param>
</member>
<member name="M:RecrownedAthenaeum.ContentReaders.TextureAtlasDataReader.GenerateAtlasRegionsFromData(RecrownedAthenaeum.Data.TextureAtlasData,Microsoft.Xna.Framework.Graphics.Texture2D)"> <member name="M:RecrownedAthenaeum.ContentReaders.TextureAtlasDataReader.GenerateAtlasRegionsFromData(RecrownedAthenaeum.Data.TextureAtlasData,Microsoft.Xna.Framework.Graphics.Texture2D)">
<summary> <summary>
Generates region given <see cref="T:RecrownedAthenaeum.Data.TextureAtlasData"/>. Generates region given <see cref="T:RecrownedAthenaeum.Data.TextureAtlasData"/>.
@ -1736,11 +1750,16 @@
Manages reference to default and loading of custom skins. Manages reference to default and loading of custom skins.
</summary> </summary>
</member> </member>
<member name="P:RecrownedAthenaeum.UI.Skin.SkinManager.ReadyForUse"> <member name="P:RecrownedAthenaeum.UI.Skin.SkinManager.MergingSkins">
<summary> <summary>
Whether or not the skin manager is set up with a <see cref="P:RecrownedAthenaeum.UI.Skin.SkinManager.BaseSkin"/> and <see cref="P:RecrownedAthenaeum.UI.Skin.SkinManager.loadedSkin"/>. Whether or not the skin manager is set up with a <see cref="P:RecrownedAthenaeum.UI.Skin.SkinManager.BaseSkin"/> and <see cref="P:RecrownedAthenaeum.UI.Skin.SkinManager.loadedSkin"/>.
</summary> </summary>
</member> </member>
<member name="P:RecrownedAthenaeum.UI.Skin.SkinManager.SkinUseable">
<summary>
Whether or not this manager has been set up with at least a base skin.
</summary>
</member>
<member name="F:RecrownedAthenaeum.UI.Skin.SkinManager.skinPaths"> <member name="F:RecrownedAthenaeum.UI.Skin.SkinManager.skinPaths">
<summary> <summary>
The list of paths for all found skins by <see cref="M:RecrownedAthenaeum.UI.Skin.SkinManager.SearchSkinDirectory"/>. May be null. The list of paths for all found skins by <see cref="M:RecrownedAthenaeum.UI.Skin.SkinManager.SearchSkinDirectory"/>. May be null.
@ -1778,7 +1797,7 @@
</member> </member>
<member name="P:RecrownedAthenaeum.UI.Skin.SkinManager.BaseSkin"> <member name="P:RecrownedAthenaeum.UI.Skin.SkinManager.BaseSkin">
<summary> <summary>
The fallback skin in case the selected skin doesn't cover a specific definition or color. The default skin in case the selected skin doesn't cover a specific definition or color.
</summary> </summary>
</member> </member>
<member name="F:RecrownedAthenaeum.UI.Skin.SkinManager.skinsDirectory"> <member name="F:RecrownedAthenaeum.UI.Skin.SkinManager.skinsDirectory">
@ -1800,7 +1819,7 @@
</member> </member>
<member name="M:RecrownedAthenaeum.UI.Skin.SkinManager.LoadSkin(RecrownedAthenaeum.Data.SkinData,System.String,Microsoft.Xna.Framework.Graphics.GraphicsDevice)"> <member name="M:RecrownedAthenaeum.UI.Skin.SkinManager.LoadSkin(RecrownedAthenaeum.Data.SkinData,System.String,Microsoft.Xna.Framework.Graphics.GraphicsDevice)">
<summary> <summary>
loads a skin asynchronously. loads a skin asynchronously to the <see cref="P:RecrownedAthenaeum.UI.Skin.SkinManager.loadedSkin"/>.
</summary> </summary>
<param name="graphicsDevice">Graphics device to use for texture creation. Uses graphics device from <see cref="T:RecrownedAthenaeum.Configuration"/>by default.</param> <param name="graphicsDevice">Graphics device to use for texture creation. Uses graphics device from <see cref="T:RecrownedAthenaeum.Configuration"/>by default.</param>
<param name="skinData">The data to generate from.</param> <param name="skinData">The data to generate from.</param>

View File

@ -10,5 +10,7 @@ namespace RhythmBullet.Preferences
public float MusicVolume = 1f; public float MusicVolume = 1f;
public float FXVolume = 1f; public float FXVolume = 1f;
public string MusicDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic); public string MusicDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
public string skinName;
public string skinDirectory;
} }
} }

View File

@ -4,11 +4,13 @@ using Microsoft.Xna.Framework.Input;
using RecrownedAthenaeum.Camera; using RecrownedAthenaeum.Camera;
using RecrownedAthenaeum.ContentSystem; using RecrownedAthenaeum.ContentSystem;
using RecrownedAthenaeum.ContentSystem.ContentResolvers; using RecrownedAthenaeum.ContentSystem.ContentResolvers;
using RecrownedAthenaeum.Data;
using RecrownedAthenaeum.Input; using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.Persistence; using RecrownedAthenaeum.Persistence;
using RecrownedAthenaeum.ScreenSystem; using RecrownedAthenaeum.ScreenSystem;
using RecrownedAthenaeum.SpecialTypes; using RecrownedAthenaeum.SpecialTypes;
using RecrownedAthenaeum.UI.Skin; using RecrownedAthenaeum.UI.Skin;
using RecrownedAthenaeum.UI.Skin.Definitions;
using RhythmBullet.Audio; using RhythmBullet.Audio;
using RhythmBullet.Preferences; using RhythmBullet.Preferences;
using RhythmBullet.Screens.MainMenu; using RhythmBullet.Screens.MainMenu;
@ -40,7 +42,7 @@ namespace RhythmBullet
private Texture2D currentCursorTexture; private Texture2D currentCursorTexture;
internal readonly MusicController musicController; internal readonly MusicController musicController;
private SkinManager skinManager = new SkinManager(); private SkinManager skinManager = new SkinManager();
private readonly ISkin skin; private ISkin Skin { get { return skinManager.Skin; } }
public RhythmBulletGame() public RhythmBulletGame()
{ {
@ -49,7 +51,6 @@ namespace RhythmBullet
assets = new ContentManagerController(Content); assets = new ContentManagerController(Content);
musicController = new MusicController(); musicController = new MusicController();
skin = skinManager.Skin;
resolutionContentResolver = new ResolutionContentResolver(); resolutionContentResolver = new ResolutionContentResolver();
FontContentResolver fcr = new FontContentResolver(resolutionContentResolver); FontContentResolver fcr = new FontContentResolver(resolutionContentResolver);
assets.contentPathModifier.Add(typeof(Texture2D), resolutionContentResolver); assets.contentPathModifier.Add(typeof(Texture2D), resolutionContentResolver);
@ -73,11 +74,16 @@ namespace RhythmBullet
/// </summary> /// </summary>
protected override void Initialize() protected override void Initialize()
{ {
Resolution resolution = preferencesManager.GetPreferences<General>().Resolution; General general = preferencesManager.GetPreferences<General>();
Resolution resolution = general.Resolution;
resolutionContentResolver.Width = resolution.Width; resolutionContentResolver.Width = resolution.Width;
resolutionContentResolver.Height = resolution.Height; resolutionContentResolver.Height = resolution.Height;
musicController.musicList.path = preferencesManager.GetPreferences<General>().MusicDirectory; musicController.musicList.path = general.MusicDirectory;
musicController.musicList.StartSearch(); musicController.musicList.StartSearch();
if ((general.skinName ) != null)
{
skinManager.LoadSkin(skinManager.ReadSkinData(general.skinDirectory + general.skinName), general.skinDirectory + general.skinName);
}
Debug.WriteLine("Initial setup complete."); Debug.WriteLine("Initial setup complete.");
base.Initialize(); base.Initialize();
} }
@ -123,7 +129,7 @@ namespace RhythmBullet
} }
else if (!initialLoadComplete && CheckReadyForInitiate()) else if (!initialLoadComplete && CheckReadyForInitiate())
{ {
Initiate(); PostLoad();
} }
} }
else else
@ -167,6 +173,27 @@ namespace RhythmBullet
screenManager.PostResize(); screenManager.PostResize();
} }
private bool CheckReadyForInitiate()
{
bool ready = true;
if (!assets.Done ||
!musicController.musicList.Searched)
{
ready = false;
}
if (preferencesManager.GetPreferences<General>().skinName != null && !skinManager.MergingSkins)
{
ready = false;
}
return ready;
}
private void ShowFirstScreen(Screen Screen)
{
Screen.NextScreen = mainScreen;
}
private void QueueContent() private void QueueContent()
{ {
assets.Queue<Texture2D>("cursor", false); assets.Queue<Texture2D>("cursor", false);
@ -176,16 +203,18 @@ namespace RhythmBullet
assets.Queue<TextureAtlas>("UI"); assets.Queue<TextureAtlas>("UI");
} }
private void Initiate() private void PostLoad()
{ {
initialLoadComplete = true; Debug.WriteLine("Initial setup and loading complete.");
SetUpDefaultSkin();
UpdateCursor(); UpdateCursor();
mainScreen = new MainScreen(assets); mainScreen = new MainScreen(assets);
initialLoadComplete = true;
} }
private void UpdateCursor() private void UpdateCursor()
{ {
Texture2D texture = skin.CursorTexture; Texture2D texture = skinManager.Skin.CursorTexture;
int cursorSize = (int)(0.08f * graphics.PreferredBackBufferHeight); int cursorSize = (int)(0.08f * graphics.PreferredBackBufferHeight);
Debug.WriteLine("Cursor size length: " + cursorSize); Debug.WriteLine("Cursor size length: " + cursorSize);
RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, cursorSize, cursorSize); RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, cursorSize, cursorSize);
@ -201,14 +230,17 @@ namespace RhythmBullet
Mouse.SetCursor(MouseCursor.FromTexture2D(currentCursorTexture, currentCursorTexture.Width / 2, currentCursorTexture.Height / 2)); Mouse.SetCursor(MouseCursor.FromTexture2D(currentCursorTexture, currentCursorTexture.Width / 2, currentCursorTexture.Height / 2));
} }
private bool CheckReadyForInitiate() private void SetUpDefaultSkin()
{ {
return assets.Done && musicController.musicList.Searched && skinManager.ReadyForUse; Skin skin = new Skin(assets.Get<TextureAtlas>("UI"), assets.Get<Texture2D>("cursor"));
} skin.AddColor("default", Color.White);
private void ShowFirstScreen(Screen Screen) TextButtonSkinDefinition textButtonSkinDefinition = new TextButtonSkinDefinition("Rounded9pButton-down", "Rounded9pButton");
{ textButtonSkinDefinition.disabledRegion = "Rounded9pButton-disabled";
Screen.NextScreen = mainScreen; skin.AddDefinition("default", textButtonSkinDefinition);
skin.Laminate();
skinManager.BaseSkin = skin;
} }
} }
} }