imrpoved UI system structure and added a basic text module for testing; Untested.
This commit is contained in:
parent
b0ecc4f457
commit
3779f220ff
@ -42,16 +42,19 @@
|
|||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Zer01HD\Game\MainScreen\MainPage.cs" />
|
<Compile Include="Zer01HD\UI\Modular\Module.cs" />
|
||||||
<Compile Include="Zer01HD\UI\Page\Page.cs" />
|
<Compile Include="Zer01HD\UI\Modular\ModuleGroup.cs" />
|
||||||
<Compile Include="RhythmBulletGame.cs" />
|
<Compile Include="RhythmBulletGame.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Zer01HD\UI\Page\PageManager.cs" />
|
<Compile Include="Zer01HD\UI\Book\Page.cs" />
|
||||||
<Compile Include="Zer01HD\UI\Screen\Screen.cs" />
|
<Compile Include="Zer01HD\UI\Book\Book.cs" />
|
||||||
|
<Compile Include="Zer01HD\UI\Modular\Text.cs" />
|
||||||
|
<Compile Include="Zer01HD\UI\Screen.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\ContentSystem\ContentLoad.cs" />
|
<Compile Include="Zer01HD\Utilities\ContentSystem\ContentLoad.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\ContentSystem\ContentSystem.cs" />
|
<Compile Include="Zer01HD\Utilities\ContentSystem\ContentSystem.cs" />
|
||||||
<Compile Include="Zer01HD\Utilities\ContentSystem\IContentResolver.cs" />
|
<Compile Include="Zer01HD\Utilities\ContentSystem\IContentResolver.cs" />
|
||||||
|
<Compile Include="Zer01HD\Utilities\ParticleSystem\Particle.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="MonoGame.Framework">
|
<Reference Include="MonoGame.Framework">
|
||||||
@ -112,7 +115,9 @@
|
|||||||
</None>
|
</None>
|
||||||
<None Include="app.manifest" />
|
<None Include="app.manifest" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Folder Include="Zer01HD\Game\MainScreen\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using RhythmBullet.Zer01HD.UI.Screen;
|
using RhythmBullet.Zer01HD.UI;
|
||||||
|
|
||||||
namespace RhythmBullet
|
namespace RhythmBullet
|
||||||
{
|
{
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
using RhythmBullet.Zer01HD.UI.Page;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace RhythmBullet.Zer01HD.Game.MainScreen
|
|
||||||
{
|
|
||||||
class MainPage : Page
|
|
||||||
{
|
|
||||||
public MainPage(int pageX, int pageY) : base(pageX, pageY)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
45
RhythmBullet/Zer01HD/UI/Book/Book.cs
Normal file
45
RhythmBullet/Zer01HD/UI/Book/Book.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RhythmBullet.Zer01HD.UI.Book
|
||||||
|
{
|
||||||
|
class Book
|
||||||
|
{
|
||||||
|
Viewport viewport;
|
||||||
|
Dictionary<string, Page> pages = new Dictionary<string, Page>();
|
||||||
|
public Book(Viewport viewport)
|
||||||
|
{
|
||||||
|
this.viewport = viewport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddPage(Page page)
|
||||||
|
{
|
||||||
|
pages.Add(page.Name, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemovePage(Page page)
|
||||||
|
{
|
||||||
|
RemovePage(page.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemovePage(string name)
|
||||||
|
{
|
||||||
|
pages.Remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resize(int width, int height)
|
||||||
|
{
|
||||||
|
viewport.Width = width;
|
||||||
|
viewport.Height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayPage(string name)
|
||||||
|
{
|
||||||
|
pages[name].DisplayWithViewport(viewport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
RhythmBullet/Zer01HD/UI/Book/Page.cs
Normal file
36
RhythmBullet/Zer01HD/UI/Book/Page.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using RhythmBullet.Zer01HD.UI.Modular;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RhythmBullet.Zer01HD.UI.Book
|
||||||
|
{
|
||||||
|
class Page : ModuleGroup
|
||||||
|
{
|
||||||
|
private readonly int pageX, pageY;
|
||||||
|
|
||||||
|
public Page(int pageX, int pageY, int width, int height)
|
||||||
|
{
|
||||||
|
this.pageX = pageX;
|
||||||
|
this.pageY = pageY;
|
||||||
|
ApplySize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void ApplySize(int width, int height)
|
||||||
|
{
|
||||||
|
X = pageX * width;
|
||||||
|
Y = pageY * height;
|
||||||
|
this.Width = width;
|
||||||
|
this.Height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayWithViewport(Viewport viewport)
|
||||||
|
{
|
||||||
|
viewport.X = X;
|
||||||
|
viewport.Y = Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
RhythmBullet/Zer01HD/UI/Modular/Module.cs
Normal file
38
RhythmBullet/Zer01HD/UI/Modular/Module.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RhythmBullet.Zer01HD.UI.Modular
|
||||||
|
{
|
||||||
|
public class Module
|
||||||
|
{
|
||||||
|
public Vector2 Position = new Vector2();
|
||||||
|
public float Width, Height;
|
||||||
|
public ModuleGroup Parent;
|
||||||
|
public string Name;
|
||||||
|
public Color Color;
|
||||||
|
|
||||||
|
public virtual void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Draw(SpriteBatch batch)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveFromParent()
|
||||||
|
{
|
||||||
|
if (Parent == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Parent is null.");
|
||||||
|
}
|
||||||
|
Parent.RemoveModule(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
85
RhythmBullet/Zer01HD/UI/Modular/ModuleGroup.cs
Normal file
85
RhythmBullet/Zer01HD/UI/Modular/ModuleGroup.cs
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
|
namespace RhythmBullet.Zer01HD.UI.Modular
|
||||||
|
{
|
||||||
|
public class ModuleGroup : Module
|
||||||
|
{
|
||||||
|
List<Module> modules = new List<Module>();
|
||||||
|
Rectangle scissorBounds;
|
||||||
|
RasterizerState scissorRasterizer = new RasterizerState();
|
||||||
|
public ModuleGroup(bool crop = false)
|
||||||
|
{
|
||||||
|
if (crop)
|
||||||
|
{
|
||||||
|
scissorRasterizer.ScissorTestEnable = true;
|
||||||
|
scissorBounds = new Rectangle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Draw(SpriteBatch batch)
|
||||||
|
{
|
||||||
|
if (scissorBounds != null)
|
||||||
|
{
|
||||||
|
batch.End();
|
||||||
|
batch.Begin(SpriteSortMode.Deferred, null, null, null, scissorRasterizer);
|
||||||
|
scissorBounds.Width = (int) Width;
|
||||||
|
scissorBounds.Height = (int) Height;
|
||||||
|
scissorBounds.X = (int) Position.X;
|
||||||
|
scissorBounds.Y = (int) Position.Y;
|
||||||
|
Rectangle scissor = scissorBounds;
|
||||||
|
scissorBounds = batch.GraphicsDevice.ScissorRectangle;
|
||||||
|
batch.GraphicsDevice.ScissorRectangle = scissor;
|
||||||
|
}
|
||||||
|
foreach (Module module in modules)
|
||||||
|
{
|
||||||
|
float offsetX = module.Position.X;
|
||||||
|
float offsetY = module.Position.Y;
|
||||||
|
module.Position.X = Position.X + offsetX;
|
||||||
|
module.Position.Y = Position.Y + offsetY;
|
||||||
|
module.Draw(batch);
|
||||||
|
module.Position.X = offsetX;
|
||||||
|
module.Position.Y = offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scissorBounds != null)
|
||||||
|
{
|
||||||
|
batch.GraphicsDevice.ScissorRectangle = scissorBounds;
|
||||||
|
batch.End();
|
||||||
|
batch.Begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
foreach (Module module in modules)
|
||||||
|
{
|
||||||
|
module.Update(gameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddModule(params Module[] addModules)
|
||||||
|
{
|
||||||
|
foreach (Module module in addModules)
|
||||||
|
{
|
||||||
|
if (modules.Contains(module))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(module.ToString() + " already exists in " + this.ToString());
|
||||||
|
}
|
||||||
|
module.Parent = this;
|
||||||
|
modules.Add(module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveModule(Module module)
|
||||||
|
{
|
||||||
|
module.Parent = null;
|
||||||
|
modules.Remove(module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
40
RhythmBullet/Zer01HD/UI/Modular/Text.cs
Normal file
40
RhythmBullet/Zer01HD/UI/Modular/Text.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RhythmBullet.Zer01HD.UI.Modular
|
||||||
|
{
|
||||||
|
class Text : Module
|
||||||
|
{
|
||||||
|
private SpriteFont font;
|
||||||
|
private float scale;
|
||||||
|
public string DisplayedText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DisplayedText;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Vector2 size = font.MeasureString(value);
|
||||||
|
Width = size.X;
|
||||||
|
scale = Height / size.Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Text(string displayedText, SpriteFont font, int height)
|
||||||
|
{
|
||||||
|
this.font = font;
|
||||||
|
Height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Draw(SpriteBatch batch)
|
||||||
|
{
|
||||||
|
batch.DrawString(font, DisplayedText, Position, Color);
|
||||||
|
base.Draw(batch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
using Microsoft.Xna.Framework;
|
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace RhythmBullet.Zer01HD.UI.Page
|
|
||||||
{
|
|
||||||
class Page
|
|
||||||
{
|
|
||||||
private readonly int pageX, pageY;
|
|
||||||
public readonly int xPos, yPos;
|
|
||||||
public Page(int pageX, int pageY)
|
|
||||||
{
|
|
||||||
this.pageX = pageX;
|
|
||||||
this.pageY = pageY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(GameTime gameTime)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
using Microsoft.Xna.Framework;
|
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace RhythmBullet.Zer01HD.UI.Page
|
|
||||||
{
|
|
||||||
class PageManager
|
|
||||||
{
|
|
||||||
private readonly List<Page> pages = new List<Page>();
|
|
||||||
|
|
||||||
public void Act(GameTime gameTime)
|
|
||||||
{
|
|
||||||
foreach (Page page in pages)
|
|
||||||
{
|
|
||||||
page.Update(gameTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch)
|
|
||||||
{
|
|
||||||
foreach (Page page in pages)
|
|
||||||
{
|
|
||||||
page.Draw(spriteBatch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,31 +6,31 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace RhythmBullet.Zer01HD.UI.Screen
|
namespace RhythmBullet.Zer01HD.UI
|
||||||
{
|
{
|
||||||
class Screen
|
public class Screen
|
||||||
{
|
{
|
||||||
public void Update(GameTime gameTime)
|
public virtual void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch)
|
public virtual void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Show()
|
public virtual void Show()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Hide()
|
public virtual void Hide()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resize()
|
public virtual void Resize()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||||
{
|
{
|
||||||
class ContentSystem
|
public class ContentSystem
|
||||||
{
|
{
|
||||||
volatile bool queued;
|
volatile bool queued;
|
||||||
Thread thread;
|
Thread thread;
|
||||||
@ -46,7 +46,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T get<T>(string assetName)
|
public T Get<T>(string assetName)
|
||||||
{
|
{
|
||||||
lock(queue)
|
lock(queue)
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Queue(string assetName, Type type)
|
public void Queue(string assetName, Type type)
|
||||||
{
|
{
|
||||||
queued = true;
|
queued = true;
|
||||||
lock (queue)
|
lock (queue)
|
||||||
|
12
RhythmBullet/Zer01HD/Utilities/ParticleSystem/Particle.cs
Normal file
12
RhythmBullet/Zer01HD/Utilities/ParticleSystem/Particle.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RhythmBullet.Zer01HD.Utilities.ParticleSystem
|
||||||
|
{
|
||||||
|
class Particle
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user