From fddddfe091814bb0e2777880aa1798aee95621f2 Mon Sep 17 00:00:00 2001 From: Kuro Date: Tue, 18 Mar 2025 17:51:50 +0100 Subject: [PATCH] Add project files. --- KurosWhatToPlay.sln | 22 ++++ KurosWhatToPlay/Controller/IGDB.cs | 48 ++++++++ KurosWhatToPlay/Controller/Program.cs | 15 +++ KurosWhatToPlay/KurosWhatToPlay.csproj | 15 +++ KurosWhatToPlay/Model/GameList.cs | 10 ++ KurosWhatToPlay/View/MainForm.Designer.cs | 143 ++++++++++++++++++++++ KurosWhatToPlay/View/MainForm.cs | 13 ++ KurosWhatToPlay/View/MainForm.resx | 129 +++++++++++++++++++ 8 files changed, 395 insertions(+) create mode 100644 KurosWhatToPlay.sln create mode 100644 KurosWhatToPlay/Controller/IGDB.cs create mode 100644 KurosWhatToPlay/Controller/Program.cs create mode 100644 KurosWhatToPlay/KurosWhatToPlay.csproj create mode 100644 KurosWhatToPlay/Model/GameList.cs create mode 100644 KurosWhatToPlay/View/MainForm.Designer.cs create mode 100644 KurosWhatToPlay/View/MainForm.cs create mode 100644 KurosWhatToPlay/View/MainForm.resx diff --git a/KurosWhatToPlay.sln b/KurosWhatToPlay.sln new file mode 100644 index 0000000..56ac37b --- /dev/null +++ b/KurosWhatToPlay.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KurosWhatToPlay", "KurosWhatToPlay\KurosWhatToPlay.csproj", "{0A2485B5-EEF4-4E58-9355-CA26DCAF52B3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0A2485B5-EEF4-4E58-9355-CA26DCAF52B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A2485B5-EEF4-4E58-9355-CA26DCAF52B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A2485B5-EEF4-4E58-9355-CA26DCAF52B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A2485B5-EEF4-4E58-9355-CA26DCAF52B3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/KurosWhatToPlay/Controller/IGDB.cs b/KurosWhatToPlay/Controller/IGDB.cs new file mode 100644 index 0000000..93030a9 --- /dev/null +++ b/KurosWhatToPlay/Controller/IGDB.cs @@ -0,0 +1,48 @@ +using IGDB; +using IGDB.Models; + +namespace KurosWhatToPlay.Controller { + public class IGDB { + IGDBClient igdb; + + internal IGDB() { + igdb = new IGDBClient("ngtj0oyeb9fz4713uv0nxij7nrnh01", "fjzked4kg1d3a7u1lpw6qsp1a5823u"); + } + + internal async void getGame(string id) { + Game[] games = await igdb.QueryAsync(IGDBClient.Endpoints.Games, query: "fields *; where id = " + id + ";"); + Game game = games.First(); + Console.WriteLine(game.Name); // Thief + } + internal async void GetGameNames(long last, long amount, DataGridView gameList) { + long value = last + amount; + + string request = "("; + + for (long i = last; i <= value; i++) { + request += i + ","; + } + request = request.Remove(request.Length - 1); + request = request + ")"; + + Game[] games = await igdb.QueryAsync(IGDBClient.Endpoints.Games, query: "fields id,name; where id = " + request + "; limit " + amount + ";"); + + foreach (Game game in games) { + if (game.Id != null && game.Id.HasValue) { + gameList.Rows.Add(game.Id.Value, game.Name); + } + } + } + + internal async void GetConsoleNames(ComboBox consoleCbx) { + + Platform[] gameEngines = await igdb.QueryAsync(IGDBClient.Endpoints.Platforms, query: "fields id,name; limit 200;"); + + foreach (Platform engine in gameEngines) { + if (engine.Id != null && engine.Id.HasValue) { + consoleCbx.Items.Add(engine.Name); + } + } + } + } +} diff --git a/KurosWhatToPlay/Controller/Program.cs b/KurosWhatToPlay/Controller/Program.cs new file mode 100644 index 0000000..615e950 --- /dev/null +++ b/KurosWhatToPlay/Controller/Program.cs @@ -0,0 +1,15 @@ +namespace KurosWhatToPlay.Controller { + internal static class Program { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + IGDB igdb = new Controller.IGDB(); + ApplicationConfiguration.Initialize(); + Application.Run(new MainForm(igdb)); + } + } +} \ No newline at end of file diff --git a/KurosWhatToPlay/KurosWhatToPlay.csproj b/KurosWhatToPlay/KurosWhatToPlay.csproj new file mode 100644 index 0000000..00f23c3 --- /dev/null +++ b/KurosWhatToPlay/KurosWhatToPlay.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + \ No newline at end of file diff --git a/KurosWhatToPlay/Model/GameList.cs b/KurosWhatToPlay/Model/GameList.cs new file mode 100644 index 0000000..3a594f2 --- /dev/null +++ b/KurosWhatToPlay/Model/GameList.cs @@ -0,0 +1,10 @@ +namespace KurosWhatToPlay.Model { + internal class GameList { + + long Id { get; set; } + public string Name { get; set; } + + public GameList() { + } + } +} diff --git a/KurosWhatToPlay/View/MainForm.Designer.cs b/KurosWhatToPlay/View/MainForm.Designer.cs new file mode 100644 index 0000000..7929370 --- /dev/null +++ b/KurosWhatToPlay/View/MainForm.Designer.cs @@ -0,0 +1,143 @@ +using IGDB.Models; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace KurosWhatToPlay +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + gameList = new DataGridView(); + Id = new DataGridViewTextBoxColumn(); + gameName = new DataGridViewTextBoxColumn(); + backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); + panel1 = new Panel(); + consoleCbx = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)gameList).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // gameList + // + gameList.AllowUserToAddRows = false; + gameList.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + gameList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader; + gameList.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + gameList.Columns.AddRange(new DataGridViewColumn[] { Id, gameName }); + gameList.Location = new Point(12, 16); + gameList.Name = "gameList"; + gameList.RowHeadersWidth = 51; + gameList.Size = new Size(477, 422); + gameList.TabIndex = 4; + gameList.Scroll += GameListScroll; + // + // Id + // + Id.HeaderText = "Id"; + Id.MinimumWidth = 6; + Id.Name = "Id"; + Id.Width = 6; + // + // gameName + // + gameName.HeaderText = "gameName"; + gameName.MinimumWidth = 6; + gameName.Name = "gameName"; + gameName.Width = 6; + // + // panel1 + // + panel1.AutoSize = true; + panel1.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panel1.Controls.Add(consoleCbx); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(500, 0); + panel1.MaximumSize = new Size(300, 200); + panel1.MinimumSize = new Size(300, 200); + panel1.Name = "panel1"; + panel1.Padding = new Padding(0, 16, 0, 0); + panel1.Size = new Size(300, 200); + panel1.TabIndex = 5; + // + // consoleCbx + // + consoleCbx.FormattingEnabled = true; + consoleCbx.Location = new Point(104, 41); + consoleCbx.Name = "consoleCbx"; + consoleCbx.Size = new Size(151, 28); + consoleCbx.TabIndex = 0; + // + // MainForm + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(gameList); + Name = "MainForm"; + Text = "Kuro's What to Play"; + ((System.ComponentModel.ISupportInitialize)gameList).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); + } + + public void GameListScroll(object sender, System.EventArgs e) { + int totalHeight = 0; + foreach (DataGridViewRow row in gameList.Rows) + totalHeight += row.Height; + + if (totalHeight - gameList.Height < gameList.VerticalScrollingOffset) { + if (gameList.Rows.Count > 0) { + var id = gameList.Rows[gameList.Rows.Count - 1].Cells[0].Value; + if (id != null && id.GetType() == typeof(long)) { + currentID = long.Parse(id.ToString()); + } + } + Igdb.GetGameNames(currentID, 200, gameList); + } + } + + public void initGameList() { + Igdb.GetGameNames(0, 199, gameList); + } + + public void initConsoleCbx() { + Igdb.GetConsoleNames(consoleCbx); + } + + #endregion + + long currentID = 0; + private DataGridView gameList; + private DataGridViewTextBoxColumn Id; + private DataGridViewTextBoxColumn gameName; + private System.ComponentModel.BackgroundWorker backgroundWorker1; + private Panel panel1; + private ComboBox consoleCbx; + } +} diff --git a/KurosWhatToPlay/View/MainForm.cs b/KurosWhatToPlay/View/MainForm.cs new file mode 100644 index 0000000..2a9df4d --- /dev/null +++ b/KurosWhatToPlay/View/MainForm.cs @@ -0,0 +1,13 @@ +namespace KurosWhatToPlay { + public partial class MainForm : Form { + public MainForm(Controller.IGDB igdb) { + InitializeComponent(); + Igdb = igdb; + initGameList(); + initConsoleCbx(); + } + + + public Controller.IGDB Igdb { get; } + } +} diff --git a/KurosWhatToPlay/View/MainForm.resx b/KurosWhatToPlay/View/MainForm.resx new file mode 100644 index 0000000..208480a --- /dev/null +++ b/KurosWhatToPlay/View/MainForm.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 17, 17 + + + 25 + + \ No newline at end of file