Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ logs/
**/*.exe
**/*.out*
resources/databases/*
games/*
games/
**/*.o
ArcadeMachine
**/.DS_Store
13 changes: 13 additions & 0 deletions .scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
About generate-stats.sh
This is an automated script that can automatically accomplish three things.
1. Counts lines in .cpp and .h files.

2. Counts the total number of commits and remote branches.

3. Counts contributors and generates a contributor list plus a headcount.

All of these are written to stats/

About test-menu.cpp

this is a small testing tool in the development stage. It enables testers to pull a single game repository from GitHub using the local terminal and compile it into a startup script according to the configuration command in a fixed path, making it one-click executable. At the same time, it supports viewing and modifying the config.cfg of the game.
27 changes: 14 additions & 13 deletions include/AboutScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ struct s_star {
double y;
double distance;
color c;
};
};//定义结构体星星

class AboutScreen {
private:
bool m_shouldQuit;
unsigned long long m_ticker;
std::string m_title;
double m_titleX;
double m_titleEnd;
std::vector<struct s_star> m_stars;
int m_contributorsIndex;
int m_contributorTicker;
std::vector<std::string> m_contributors;
std::vector<std::string> m_linesOfCode;
bool m_shouldQuit;//退出标识
unsigned long long m_ticker;//节拍器
std::string m_title;//标题
double m_titleX;//标题横向位置
double m_titleEnd;//标题结束横向位置
std::vector<struct s_star> m_stars;//m_stars是一个自动变长且存储着结构体s_star的数组
int m_contributorsIndex;//贡献者索引
int m_contributorTicker;//贡献者节拍器
std::vector<std::string> m_contributors;//存储着贡献者名字的m_contributors
std::vector<std::string> m_linesOfCode;//存储着贡献者代码数量的m_linesOfCode
std::vector<std::string> m_gitContributions;

void readInput();
Expand All @@ -39,10 +39,11 @@ class AboutScreen {
void renderContributor();
void onExit();
void loop();

//声明函数方法
public:
AboutScreen();
void main();
};

#endif
#endif

2 changes: 1 addition & 1 deletion include/ConfigData.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ConfigData

//Setters:
auto setId(int &i) { m_id = i; }
auto setFolder(std::string &dir) { m_folder = dir; }
void setFolder(std::string &dir);
// Getters:
auto id() const -> const int& { return m_id; }
auto repo() const -> const std::string& { return m_repo; }
Expand Down
3 changes: 3 additions & 0 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#define ARCADE_MACHINE_RES_X 1920 * ARCADE_MACHINE_SCALING_FACTOR
#define ARCADE_MACHINE_RES_Y 1080 * ARCADE_MACHINE_SCALING_FACTOR

#define ROWS 7
#define COLS 15

#ifdef _WIN32
#define ARCADE_MACHINE_PATH_SEP "\\"
#else
Expand Down
24 changes: 24 additions & 0 deletions include/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,30 @@
#include <map>
#include <tuple>

// ---------------------------------------------------------------------------
// TEMPORARY: SplashKit database API is missing on Windows builds.
// These stubs allow the project to compile on Windows. On Linux/RPi,
// SplashKit provides the real API so no stubs are needed.
// TODO: Rewrite Database.h using raw SQLite3 (-lsqlite3) to restore functionality.
// ---------------------------------------------------------------------------
#if 1
struct database {};
struct query_result {};
inline database open_database(std::string, std::string) { return {}; }
inline void free_database(database) {}
inline query_result run_sql(database, std::string) { return {}; }
inline bool query_success(query_result) { return false; }
inline bool has_row(query_result) { return false; }
inline bool get_next_row(query_result) { return false; }
inline void free_all_query_results() {}
inline int query_column_count(query_result) { return 0; }
inline std::string query_column_for_string(query_result, int) { return ""; }
inline double query_column_for_double(query_result, int) { return 0.0; }
inline int query_column_for_int(query_result, int) { return 0; }
inline std::string query_type_of_col(query_result, int) { return "NULL"; }
#endif
// ---------------------------------------------------------------------------

class Database {
private:
std::string m_databaseName;
Expand Down
11 changes: 11 additions & 0 deletions include/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Helper {
string getFolderName(string entryPath)
{
string dir = fs::path(entryPath).remove_filename().generic_string();
// Remove trailing slash to prevent double-slash when concatenating paths later
if (!dir.empty() && (dir.back() == '/' || dir.back() == '\\'))
dir.pop_back();
std::cout << "Game-Directory Path: " << dir << "\n";
return dir;
}
Expand All @@ -46,6 +49,12 @@ class Helper {
{
vector<string> files;

if (!fs::exists(dir) || !fs::is_directory(dir))
{
std::cerr << "Warning: Games directory not found: " << dir << "\n";
return files;
}

for (const auto & entry : fs::recursive_directory_iterator(dir))
{
if (entry.path().filename() == "config.txt")
Expand All @@ -55,6 +64,8 @@ class Helper {
}
}

std::cerr << "[Helper] found " << files.size() << " config files in " << dir << std::endl;

return files;
}

Expand Down
14 changes: 8 additions & 6 deletions include/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ class Menu {
PROCESS_INFORMATION m_processInfo;
// Unsigned int to store exit info
DWORD m_exitCode;
// Holds the game path of selected game
LPCSTR m_gamePath;
// Holds the executable of selected game
LPSTR m_gameExe;
// Holds the game directory of selected game
LPCSTR m_gameDir;
// m_handle for game window.
HWND m_handle;
#else
Expand Down Expand Up @@ -79,6 +73,14 @@ class Menu {

// Determines when game has started.
bool m_gameStarted = false;
// True from launch attempt until confirmed running or failed.
bool m_launching = false;
// Timestamp (ms) when m_inGame was set — used to detect crashes.
unsigned int m_launchTime = 0;
// Holds error message to display after launch failure or crash.
std::string m_launchError = "";
// Exit code of last game process (0 = normal, non-zero = crash).
int m_lastExitCode = 0;
// Starting position of button x.
const int m_posX = 700;
// Position of button y.
Expand Down
3 changes: 2 additions & 1 deletion include/Option.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#define ARCADE_MACHINE_OPTION_H

#include "AboutScreen.h"
#include "Configuration.h"
#include "splashkit.h"
#include <string>
#include "GridLayout.h"
#include "Button.h"
#include "ArcadeMachine.h"
#include "Selector.h"
#include "OptionsScreenButton.h"
#include "Audio.h"
Expand Down Expand Up @@ -34,6 +34,7 @@ class Option

public:
Option();
~Option();

void createOptionsButtons();
void drawOptionsMenu();
Expand Down
3 changes: 2 additions & 1 deletion include/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <unistd.h>

pid_t spawnProcess(std::string directory, std::string fileName);
bool processRunning(pid_t processId);
bool processRunning(pid_t processId, int &exitCode);
void killProcess(pid_t processId);

#endif
2 changes: 1 addition & 1 deletion include/Rating.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Rating
if (key_typed(LEFT_KEY))
{
--_rating;
if (_rating < 0)
if (_rating < 1)
_rating = _maxRating;
updateGrid();
}
Expand Down
123 changes: 123 additions & 0 deletions include/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
1.AboutScreen.h
The developer contribution list page will scroll through the contribution information of developers and obtain information from the data collected by the previous statistics script.

2.ArcadeMachine.h
The master control type of the entire "arcade front-end program" - organizing the startup animation, main menu, game list, option menu, button clicks, sounds and layout all together.

3.Audio.h
The music player plays the main menu music by default upon startup. It can switch songs and adjust the volume, ensuring that games/menus have a unified music management interface.

4.Button.h
The parent class of all buttons provides the basic attributes and behaviors for the buttons.

5.ButtonNode.h
Button nodes are used to form a bidirectional circular linked list of a bunch of buttons. This enables the menu cursor to move in a loop between buttons, just like in a real arcade machine. You can push in one direction without going all the way, making there no sense of boundaries.

6.cell.h
The grid cell, as the smallest drawing unit in the machine, supports storing four types: EMPTY,BMP,SPT(Animation Sprite), and BTN. It also supports functions such as center alignment, how large this cell should occupy (merging other base cells), etc. A very important drawing unit.

7.ConfigData.h
A very important header file is the "Data model manual" for each game. It is through this that the menu system knows which games are available and how to start them. Including: All metadata of each game.

Basic information: m_id

m_repo

m_language

m_folder

Display information: m_image

m_title

m_genre

m_rating

m_author

m_description

Executable file path

The executable path of Win

The executable path of Linux

The executable path of MacOS

It can open the config.txt of each game, read this information from it (here we have to mention config.txt, which is the information that every game uploader must provide), and then convert this information from text information into object attributes for the convenience of using it for config later.

8.Configuration.h
Global configuration constants, uniformly managing environment-related parameters such as "resolution, path separator, CPU architecture, operating system type, and executable file extension".

9.Database.h
The database encapsulation for arcade menu/statistics provides common operation methods such as table creation, addition, deletion, modification, query, and printing, making it convenient for direct invocation elsewhere.

10.GameData.h
To record each round encapsulation, wrote in the database a is fixed: gameData, it exists fields: gamaName, startTime, endTime, rating, highScore. It will even provide aggregated statistics: average score, total duration, highest score, etc.

11.GameScreenButton.h
The specific implementation class on the game selection menu completes the implementation of button images, drawing, click behavior, etc. In the menu interface, each game/option will be displayed with a GameScreenButton.

12.GridLayout.h
This actually forms a linkage with the previous grid header file. The two work together to achieve a very good drawing effect. It can divide the entire screen into x rows and y columns. Each cell is a grid, managing the drawing content of each cell, drawing uniformly, automatically calculating scaling, position, etc. based on the cell size, and finally drawing all of them. And it provides the functions of cleaning the screen and releasing memory.

13.Helper.h
This is a very important toolbox, involving the reading of game directories, etc.

(1) There is a function called string getFoldName(string entryPath), which uses the path of the passed game file (usually the config.txt of a certain game) to take the directory where it is located as the "game folder name" Facilitate the subsequent reading of resources by ConfigData.

(2) vector<string>getConfigFiles(string dir) recursively traverses the folder, collects all config.txt files, and returns a list of paths.

(3) vector<ConfigData> ConfigDataList()
Call getConfigFiles(string dir), specify the path for it ("./games/games"), scan it once, then read each config.txt in, convert it into a ConfigData object, and fill it in:
folder
id
The fields parsed from the configuration file
Regarding the specified path ("./games/games"), it is necessary to mention the special directory of the game repository. For the storage of games, a special format must be met. It must be written as config.txt and then uniformly placed in the "games" folder. Only in this way can vector<ConfigData> ConfigDataList() correctly find the game and load the relevant configuration. That's why it is hard-coded here.

(4)void resetScreen(GridLayout grid)
A demonstration tool for drawing grids for testing.

(5) void gridLayoutExample()
Open a 600x800 window without loading appContainer.png. Create a 5x5 grid and conduct several layout experiments.

14.Menu.h
The desktop of the arcade machine.

15.MenuButton.h
The button class of the menu interface inherits from the previous Button.

16.Option.h
The "Settings/Options Menu" of the arcade machine, the Settings interface.

17.OptionButton.h
A dedicated button for the Settings menu.

18.Process.h
Start an external process (basically a game) on Linux/ Raspberry PI and check if it is still running.
1.spawnProcess(std::string directory,std::string fileName)
Generate a new process
Parameters: The first one is placed in the directory where the running file is located, and the second one is placed in the file name of the running program.
Return value: pid_t(ID of the new process).
2.processRunning(pid_t processId)
Check if the process is alive and return T/F.

Why is this file necessary? Because the arcade machine needs to continuously listen to whether the application is still running, if the program is not running, it needs to exit and return to the main menu.

19.Rating.h
Scoring component.

20.Selector.h
Cursor selector component.

21.Splashscreen.h
The opening animation component plays the logo and provides an opening animation.

22.Table.h
The description of a table in the Database provides a blueprint for the tables in the previous database.

23.Tip.h
The screen prompts the implementation of bubbles/small pop-up Windows, which will automatically disappear after a few seconds.
27 changes: 27 additions & 0 deletions logs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[Bundle] resource bundle loaded successfully
[Bundle] all bitmaps and fonts loaded successfully
[Git] Connecting... (attempt 1/3)
[Git] pulling: https://github.com/thoth-tech/arcade-games.git → games
From https://github.com/thoth-tech/arcade-games
* branch HEAD -> FETCH_HEAD
[Git] pull succeeded: games
[Git] games loaded successfully on attempt 1
[Helper] found 9 config files in ./games/games
[Config] no builds/ directory: ./games/games/2dRacer
[Config] Below The Surface supports: Linux ARM, Linux x86, Windows
[Config] no builds/ directory: ./games/games/car-race
[Config] Homemade Pong supports: Linux ARM, Linux x86, Windows
[Config] no builds/ directory: ./games/games/Pingpong
[Config] builds/ is empty: ./games/games/Runner_Dash
[Config] no builds/ directory: ./games/games/SkySurge
[Config] no builds/ directory: ./games/games/splashkit mario
[Config] Venture Adventure supports: Linux ARM, Linux x86, Windows
[Menu] image loaded: ./games/games/2dRacer/2D-Title.jpg
[Menu] image loaded: ./games/games/BelowTheSurface/title_card.png
[Menu] image loaded: ./games/games/car-race/images/car-race-config-image.png
[Menu] image loaded: ./games/games/HomemadePong/images/pong.png
[Menu] image loaded: ./games/games/Pingpong/images/Pingpong-config-image.png
[Menu] image loaded: ./games/games/Runner_Dash/TitleImage.jpg
[Menu] image loaded: ./games/games/SkySurge/images/SkySurge-config-image.png
[Menu] image loaded: ./games/games/splashkit mario/sk-mario-config-image.png
[Menu] image loaded: ./games/games/VentureAdventure/Resources/images/VenAd.png
1 change: 1 addition & 0 deletions resources/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The resource file stored when the machine starts running. Provide resources for rendering, playback, etc. It is worth mentioning bundles, which can integrate different versions of resources to meet various needs. Among them, resources.txt is a related integration.
8 changes: 4 additions & 4 deletions resources/bundles/resources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ SOUND,intro_start,completed.wav

// Music
MUSIC,music_mainmenu,main_menu.mp3
MUSIC, 1, 1.mp3
MUSIC, 2, 2.mp3
MUSIC, 3, 3.mp3
MUSIC, music_about, insert-no-coins.ogg
MUSIC,1,1.mp3
MUSIC,2,2.mp3
MUSIC,3,3.mp3
MUSIC,music_about,insert-no-coins.ogg

// Animations
ANIM,info-script,information.txt
Expand Down
Binary file added scripts.tar.gz
Binary file not shown.
Loading