1
0
Fork 0

Add content Edit

This commit is contained in:
sheychen 2016-12-08 11:14:44 +01:00
parent 2a56db6546
commit 84f2310204
3 changed files with 45 additions and 5 deletions

View File

@ -17,6 +17,8 @@ namespace MyMonoGame.GUI
public Texture2D bottomCenter;
public Texture2D bottomRight;
public bool correct { get { return (topLeft != null && topCenter != null && topRight != null && centerLeft != null && centerCenter != null && centerRight != null && bottomLeft != null && bottomCenter != null && bottomRight != null); } }
public boxSprites(Texture2D TopLeft,
Texture2D TopCenter,
Texture2D TopRight,

View File

@ -74,6 +74,15 @@ namespace MyMonoGame.Utilities
textures.Add(key, texture);
}
public void EditTexture(string key, Texture2D texture)
{
if (!textures.ContainsKey(key))
throw new System.Exception("No found");
if (texture != null)
textures[key] = texture;
}
public Texture2D GetTexture(string key)
{
if (!textures.ContainsKey(key))
@ -116,6 +125,15 @@ namespace MyMonoGame.Utilities
boxs.Add(key, box);
}
public void EditBox(string key, boxSprites box)
{
if (!boxs.ContainsKey(key))
throw new System.Exception("No found");
if (!box.correct)
boxs[key] = box;
}
public boxSprites GetBox(string key)
{
if (!boxs.ContainsKey(key))
@ -142,12 +160,21 @@ namespace MyMonoGame.Utilities
public void AddSound(string key, SoundEffect sound)
{
if (textures.ContainsKey(key))
if (sounds.ContainsKey(key))
throw new System.Exception("Allready in dictonary");
sounds.Add(key, sound);
}
public void EditSound(string key, SoundEffect sound)
{
if (!sounds.ContainsKey(key))
throw new System.Exception("No found");
if (sound != null)
sounds[key] = sound;
}
public SoundEffect GetSound(string key)
{
if (!sounds.ContainsKey(key))
@ -180,6 +207,15 @@ namespace MyMonoGame.Utilities
fonts.Add(key, font);
}
public void EditFont(string key, SpriteFont font)
{
if (!fonts.ContainsKey(key))
throw new System.Exception("No found");
if (font != null)
fonts[key] = font;
}
public SpriteFont GetFont(string key)
{
if (!fonts.ContainsKey(key))

View File

@ -14,15 +14,16 @@ namespace MyMonoGame.Utilities
/// </summary>
/// <param name="path">File .png path</param>
/// <param name="sprite">Result sprite</param>
static public void SpriteFromPng(string path, ref Texture2D sprite, GraphicsDevice graphics)
static public Texture2D SpriteFromPng(string path, GraphicsDevice graphics)
{
if (File.Exists(path))
{
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
sprite = Texture2D.FromStream(graphics, fileStream);
return Texture2D.FromStream(graphics, fileStream);
}
}
return null;
}
/// <summary>
@ -30,15 +31,16 @@ namespace MyMonoGame.Utilities
/// </summary>
/// <param name="path">File .mp3 path</param>
/// <param name="sound">Result sound</param>
static public void SoundFromMp3(string path, ref SoundEffect sound)
static public SoundEffect SoundFromMp3(string path)
{
if (File.Exists(path))
{
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
sound = SoundEffect.FromStream(fileStream);
return SoundEffect.FromStream(fileStream);
}
}
return null;
}
}
}