-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added the documentation generated with chatgpt
- Loading branch information
Showing
951 changed files
with
1,236,302 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+27.5 KB
GFX/GFX 0.1.0.2/.vs/Genesis/FileContentIndex/383e2e0f-5703-4698-95a6-4dc798d511a2.vsidx
Binary file not shown.
Binary file added
BIN
+31.2 KB
GFX/GFX 0.1.0.2/.vs/Genesis/FileContentIndex/4dd158b4-de4b-476f-90d8-c0131aeba4e1.vsidx
Binary file not shown.
Binary file added
BIN
+33.3 KB
GFX/GFX 0.1.0.2/.vs/Genesis/FileContentIndex/7d7ef1b3-a6c3-4b2e-9072-0fb7024093be.vsidx
Binary file not shown.
Binary file added
BIN
+15.2 KB
GFX/GFX 0.1.0.2/.vs/Genesis/FileContentIndex/f4096e87-86f4-4c75-a60a-46a596cf04a8.vsidx
Binary file not shown.
Binary file added
BIN
+164 KB
GFX/GFX 0.1.0.2/.vs/Genesis/FileContentIndex/f7311488-664a-4f4c-90c4-ae9b084e9415.vsidx
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.4.33110.190 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Genesis", "Genesis\Genesis.csproj", "{D0B6089B-BA05-4535-A071-538B918C3AD4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{D0B6089B-BA05-4535-A071-538B918C3AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D0B6089B-BA05-4535-A071-538B918C3AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D0B6089B-BA05-4535-A071-538B918C3AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D0B6089B-BA05-4535-A071-538B918C3AD4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {74D82FF8-4944-4844-86B7-7802B221F611} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
using Genesis.Graphics; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
using System.Xml.Serialization; | ||
|
||
namespace Genesis.Core | ||
{ | ||
/// <summary> | ||
/// Manages game assets such as textures and fonts. | ||
/// </summary> | ||
public class AssetManager | ||
{ | ||
/// <summary> | ||
/// List of loaded textures. | ||
/// </summary> | ||
public List<Texture> Textures { get; set; } | ||
|
||
/// <summary> | ||
/// List of loaded fonts. | ||
/// </summary> | ||
public List<Graphics.Font> Fonts { get; set; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AssetManager"/> class. | ||
/// </summary> | ||
public AssetManager() | ||
{ | ||
this.Textures = new List<Texture>(); | ||
this.Fonts = new List<Graphics.Font>(); | ||
} | ||
|
||
/// <summary> | ||
/// Adds a texture to the asset manager. | ||
/// </summary> | ||
/// <param name="name">The name of the texture.</param> | ||
/// <param name="bitmap">The bitmap representing the texture.</param> | ||
/// <returns>The added texture.</returns> | ||
public Texture AddTexture(String name, Bitmap bitmap) | ||
{ | ||
Texture texture = new Texture(name, bitmap); | ||
this.Textures.Add(texture); | ||
return texture; | ||
} | ||
|
||
/// <summary> | ||
/// Gets a texture by name. | ||
/// </summary> | ||
/// <param name="name">The name of the texture.</param> | ||
/// <returns>The texture with the specified name, or null if not found.</returns> | ||
public Texture GetTexture(String name) | ||
{ | ||
foreach (var item in Textures) | ||
{ | ||
if(item.Name.Equals(name)) | ||
{ | ||
return item; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
/// <summary> | ||
/// Gets a font by name. | ||
/// </summary> | ||
/// <param name="name">The name of the font.</param> | ||
/// <returns>The font with the specified name, or null if not found.</returns> | ||
public Graphics.Font GetFont(String name) | ||
{ | ||
foreach (var item in Fonts) | ||
{ | ||
if(item.Name.Equals(name)) | ||
{ | ||
return item; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the assets in the rendering device. | ||
/// </summary> | ||
/// <param name="renderDevice">The rendering device to load the assets into.</param> | ||
public void Init(IRenderDevice renderDevice) | ||
{ | ||
foreach (var item in Textures) | ||
{ | ||
renderDevice.LoadTexture(item); | ||
} | ||
foreach (var item in Fonts) | ||
{ | ||
renderDevice.LoadFont(item); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Disposes of the loaded textures and fonts. | ||
/// </summary> | ||
/// <param name="game">The game object associated with the assets.</param> | ||
public void DisposeTextures(Game game) | ||
{ | ||
foreach (var item in Textures) | ||
{ | ||
game.RenderDevice.DisposeTexture(item); | ||
} | ||
foreach (var item in Fonts) | ||
{ | ||
game.RenderDevice.DisposeFont(item); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Loads textures from the resource folder. | ||
/// </summary> | ||
public void LoadTextures() | ||
{ | ||
String ressources = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/Resources"; | ||
foreach(var file in Directory.GetFiles(ressources)) | ||
{ | ||
FileInfo info = new FileInfo(file); | ||
if(info.Extension.Equals(".png") || info.Extension.Equals(".jpg")) | ||
{ | ||
this.Textures.Add(new Texture(info.Name, new Bitmap(file))); | ||
Console.WriteLine("Texture " + info.Name + " loaded!"); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Loads fonts from the resource folder. | ||
/// </summary> | ||
public void LoadFonts() | ||
{ | ||
String ressources = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/Resources"; | ||
foreach (var file in Directory.GetFiles(ressources)) | ||
{ | ||
FileInfo info = new FileInfo(file); | ||
if (info.Extension.Equals(".gff")) | ||
{ | ||
Graphics.Font font = new Graphics.Font(); | ||
font.FromFile(file); | ||
Fonts.Add(font); | ||
Console.WriteLine("font " + font.Name + " loaded!"); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Adds an font | ||
/// </summary> | ||
/// <param name="font">the font to add</param> | ||
public void AddFont(Genesis.Graphics.Font font) | ||
{ | ||
this.Fonts.Add(font); | ||
} | ||
|
||
/// <summary> | ||
/// Loads a system font | ||
/// </summary> | ||
/// <param name="font"></param> | ||
public void LoadSystemFont(String font) | ||
{ | ||
this.Fonts.Add(Genesis.Graphics.Font.LoadSystemFont(font)); | ||
} | ||
|
||
/// <summary> | ||
/// Packs the assets into an asset library. | ||
/// </summary> | ||
/// <param name="file">The file path to save the asset library.</param> | ||
public void PackAssets(String file) | ||
{ | ||
XmlDocument xml = new XmlDocument(); | ||
XmlDeclaration xmlDeclaration = xml.CreateXmlDeclaration("1.0", "UTF-8", null); | ||
|
||
var texturesNode = xml.CreateElement("Textures"); | ||
foreach (var texture in this.Textures) | ||
{ | ||
var textureNode = xml.CreateElement("Texture"); | ||
XmlAttribute attribute = xml.CreateAttribute("Name"); | ||
attribute.Value = texture.Name.ToString(); | ||
textureNode.Attributes.Append(attribute); | ||
|
||
var textureBitmapNode = xml.CreateElement("Bitmap"); | ||
textureBitmapNode.InnerText = Utils.ConvertBitmapToBase64(texture.Bitnmap); | ||
textureNode.AppendChild(textureBitmapNode); | ||
|
||
texturesNode.AppendChild(textureNode); | ||
} | ||
xml.AppendChild(texturesNode); | ||
xml.Save(file); | ||
} | ||
|
||
/// <summary> | ||
/// Imports assets from an asset library. | ||
/// </summary> | ||
/// <param name="file">The file path of the asset library to import.</param> | ||
public void ImportAssetLibary(String file) | ||
{ | ||
XmlDocument xml = new XmlDocument(); | ||
xml.Load(file); | ||
|
||
var texturesNode = xml.ChildNodes[0]; | ||
foreach (XmlElement textureNode in texturesNode.ChildNodes) | ||
{ | ||
var name = textureNode.Attributes["Name"].Value; | ||
var bitmap = Utils.ConvertBase64ToBitmap(textureNode.ChildNodes[0].InnerText); | ||
this.Textures.Add(new Texture(name, bitmap)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the resource directory path. | ||
/// </summary> | ||
/// <returns>The path to the resource directory.</returns> | ||
public static String GetRessourcesDirectory() | ||
{ | ||
return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/Resources"; | ||
} | ||
} | ||
} |
Oops, something went wrong.