implemented basics of skin system.

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

View File

@@ -10,5 +10,7 @@ namespace RhythmBullet.Preferences
public float MusicVolume = 1f;
public float FXVolume = 1f;
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.ContentSystem;
using RecrownedAthenaeum.ContentSystem.ContentResolvers;
using RecrownedAthenaeum.Data;
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.Persistence;
using RecrownedAthenaeum.ScreenSystem;
using RecrownedAthenaeum.SpecialTypes;
using RecrownedAthenaeum.UI.Skin;
using RecrownedAthenaeum.UI.Skin.Definitions;
using RhythmBullet.Audio;
using RhythmBullet.Preferences;
using RhythmBullet.Screens.MainMenu;
@@ -40,7 +42,7 @@ namespace RhythmBullet
private Texture2D currentCursorTexture;
internal readonly MusicController musicController;
private SkinManager skinManager = new SkinManager();
private readonly ISkin skin;
private ISkin Skin { get { return skinManager.Skin; } }
public RhythmBulletGame()
{
@@ -49,7 +51,6 @@ namespace RhythmBullet
assets = new ContentManagerController(Content);
musicController = new MusicController();
skin = skinManager.Skin;
resolutionContentResolver = new ResolutionContentResolver();
FontContentResolver fcr = new FontContentResolver(resolutionContentResolver);
assets.contentPathModifier.Add(typeof(Texture2D), resolutionContentResolver);
@@ -73,11 +74,16 @@ namespace RhythmBullet
/// </summary>
protected override void Initialize()
{
Resolution resolution = preferencesManager.GetPreferences<General>().Resolution;
General general = preferencesManager.GetPreferences<General>();
Resolution resolution = general.Resolution;
resolutionContentResolver.Width = resolution.Width;
resolutionContentResolver.Height = resolution.Height;
musicController.musicList.path = preferencesManager.GetPreferences<General>().MusicDirectory;
musicController.musicList.path = general.MusicDirectory;
musicController.musicList.StartSearch();
if ((general.skinName ) != null)
{
skinManager.LoadSkin(skinManager.ReadSkinData(general.skinDirectory + general.skinName), general.skinDirectory + general.skinName);
}
Debug.WriteLine("Initial setup complete.");
base.Initialize();
}
@@ -123,7 +129,7 @@ namespace RhythmBullet
}
else if (!initialLoadComplete && CheckReadyForInitiate())
{
Initiate();
PostLoad();
}
}
else
@@ -167,6 +173,27 @@ namespace RhythmBullet
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()
{
assets.Queue<Texture2D>("cursor", false);
@@ -176,16 +203,18 @@ namespace RhythmBullet
assets.Queue<TextureAtlas>("UI");
}
private void Initiate()
private void PostLoad()
{
initialLoadComplete = true;
Debug.WriteLine("Initial setup and loading complete.");
SetUpDefaultSkin();
UpdateCursor();
mainScreen = new MainScreen(assets);
initialLoadComplete = true;
}
private void UpdateCursor()
{
Texture2D texture = skin.CursorTexture;
Texture2D texture = skinManager.Skin.CursorTexture;
int cursorSize = (int)(0.08f * graphics.PreferredBackBufferHeight);
Debug.WriteLine("Cursor size length: " + 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));
}
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)
{
Screen.NextScreen = mainScreen;
TextButtonSkinDefinition textButtonSkinDefinition = new TextButtonSkinDefinition("Rounded9pButton-down", "Rounded9pButton");
textButtonSkinDefinition.disabledRegion = "Rounded9pButton-disabled";
skin.AddDefinition("default", textButtonSkinDefinition);
skin.Laminate();
skinManager.BaseSkin = skin;
}
}
}