-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
609 additions
and
232 deletions.
There are no files selected for viewing
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
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,60 @@ | ||
using System.Collections; | ||
using System.Reflection; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Qkmaxware.Emulators.Gameboy; | ||
|
||
public class GameInfo { | ||
[JsonPropertyName("title")] | ||
public string? CartTitle {get; set;} | ||
[JsonPropertyName("name")] | ||
public string? Name {get; set;} | ||
[JsonPropertyName("boxart")] | ||
public string? BoxArtUrl {get; set;} | ||
[JsonPropertyName("description")] | ||
public string? Description {get; set;} | ||
[JsonPropertyName("genres")] | ||
public string[]? Genres {get; set;} | ||
[JsonPropertyName("released")] | ||
public int ReleaseYear {get; set;} | ||
[JsonPropertyName("developer")] | ||
public string? DeveloperName {get; set;} | ||
[JsonPropertyName("publisher")] | ||
public string? PublisherName {get; set;} | ||
} | ||
|
||
public class GameDatabase : IEnumerable<GameInfo> { | ||
|
||
private List<GameInfo> all = new List<GameInfo>(); | ||
|
||
private GameDatabase() { | ||
var assembly = typeof(GameDatabase).GetTypeInfo().Assembly; | ||
foreach (var name in assembly.GetManifestResourceNames()) { | ||
if (name == ("Gameboy.Database.database.json")) { | ||
Stream? resource = assembly.GetManifestResourceStream(name); | ||
if (resource is null) | ||
continue; | ||
|
||
var records = System.Text.Json.JsonSerializer.Deserialize<List<GameInfo>>(resource); | ||
if (records is null) | ||
break; | ||
this.all = records; | ||
} | ||
} | ||
} | ||
|
||
private static GameDatabase? instance; | ||
public static GameDatabase Instance() { | ||
if (instance is null) | ||
instance = new GameDatabase(); | ||
return instance; | ||
} | ||
|
||
public IEnumerator<GameInfo> GetEnumerator() { | ||
return all.GetEnumerator(); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() { | ||
return all.GetEnumerator(); | ||
} | ||
} |
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="database.json" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,28 @@ | ||
[ | ||
{ | ||
"title": "TETRIS", | ||
"name": "Tetris", | ||
"boxart": "https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Tetris_Boxshot.jpg/220px-Tetris_Boxshot.jpg", | ||
"description": "A portable version of Alexey Pajitnov's original tetris for the Nintendo Game Boy.", | ||
"genres": [ | ||
"Puzzle" | ||
], | ||
"released": 1989, | ||
"developer": "Nintendo R&D1", | ||
"publisher": "Nintendo" | ||
}, | ||
{ | ||
"title": "POKEMON BLUE", | ||
"name": "Pokémon Blue", | ||
"boxart": "https://archives.bulbagarden.net/media/upload/thumb/5/5a/Blue_EN_boxart.png/250px-Blue_EN_boxart.png", | ||
"description": "Along with Pokémon Red, Pokémon Blue was one of the first installments of the Pokémon series.", | ||
"genres": [ | ||
"Role-playing", | ||
"Adventure", | ||
"Turn-based strategy" | ||
], | ||
"released": 1996, | ||
"developer": "Game Freak", | ||
"publisher": "Nintendo" | ||
} | ||
] |
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
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
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 |
---|---|---|
@@ -1,11 +1,20 @@ | ||
table { | ||
div { | ||
background-color: rgba(0, 0, 0, 0.5); | ||
color: white; | ||
padding: 12px; | ||
border-radius: 12px; | ||
width: 100%; | ||
} | ||
table { | ||
width: 100%; | ||
} | ||
|
||
table th { | ||
text-align: left; | ||
} | ||
|
||
img { | ||
width: 100%; | ||
max-height: 240px; | ||
object-fit: contain; | ||
} |
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,23 @@ | ||
using Godot; | ||
using System; | ||
|
||
namespace Qkmaxware.Emulators.Gameboy.Player; | ||
|
||
public partial class FpsCounter : Label { | ||
[Export] public TextureRenderer Renderer {get; set;} | ||
private int fps; | ||
|
||
// Called every frame. 'delta' is the elapsed time since the previous frame. | ||
public override void _Process(double delta) { | ||
if (Renderer is not null && Renderer.IsPlaying) { | ||
var fps = (int)Math.Round(Godot.Engine.GetFramesPerSecond()); | ||
if (this.fps != fps) { | ||
// New string only if the FPS changed | ||
this.Text = "FPS: " + fps; | ||
this.fps = fps; | ||
} | ||
} else { | ||
this.Text = string.Empty; | ||
} | ||
} | ||
} |
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
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
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
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
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,12 @@ | ||
using System.Reflection; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Qkmaxware.Emulators.Gameboy.Test; | ||
|
||
[TestClass] | ||
public class GameDatabaseTest { | ||
[TestMethod] | ||
public void TestGameDatabaseNonEmpty() { | ||
Assert.AreEqual(true, GameDatabase.Instance().Any()); | ||
} | ||
} |
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
Oops, something went wrong.