Skip to content

Commit 23bec6d

Browse files
committed
moved more hardcoded values to config.ini
1 parent 346edd8 commit 23bec6d

File tree

2 files changed

+52
-26
lines changed

2 files changed

+52
-26
lines changed

config.ini

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
;ASAPCabinetFE Config file
2+
;Do not change anything between []s or before the = sign.
3+
14
[VPX]
25
;These must be absolute paths to the tables folder and vpx executable.
36
TablesPath = /home/tarso/Games/vpinball/build/tables/
@@ -41,7 +44,6 @@ SecondWidth = 1024
4144
SecondHeight = 1024
4245

4346
[Font]
44-
Path = /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
4547
Size = 28
4648

4749
[MediaDimensions]
@@ -55,3 +57,21 @@ BackglassWidth = 1024
5557
BackglassHeight = 768
5658
DmdWidth = 1024
5759
DmdHeight = 256
60+
61+
;---------------------------------------------------------------------------------------
62+
63+
[Internal]
64+
;You should probably leave these alone.
65+
SubCmd = -Play
66+
DefaultTableImage = img/default_table.png
67+
DefaultBackglassImage = img/default_backglass.png
68+
DefaultDmdImage = img/default_dmd.png
69+
DefaultWheelImage = img/default_wheel.png
70+
DefaultTableVideo = img/default_table.mp4
71+
DefaultBackglassVideo = img/default_backglass.mp4
72+
DefaultDmdVideo = img/default_dmd.mp4
73+
FadeDurationMs = 250
74+
FadeTargetAlpha = 128
75+
FontPath = /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
76+
TableChangeSound = snd/table_change.mp3
77+
TableLoadSound = snd/table_load.mp3

main.cpp

+31-25
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ std::map<std::string, std::map<std::string, std::string>> load_config(const std:
361361
return config;
362362
}
363363

364-
// ----------------- Initialization Guard Functions -------------------
364+
// ----------------- Initialization Guard Classes -------------------
365365

366366
// Guard for SDL initialization
367367
class SDLInitGuard {
@@ -426,11 +426,8 @@ class MixerGuard {
426426
}
427427
};
428428

429-
// -------------------------- Main Application --------------------------
430-
431429
enum class TransitionState { IDLE, FADING_OUT, FADING_IN };
432430

433-
// Main function for initializing and running the SDL application
434431
/**
435432
* @brief Main function for initializing and running the SDL application.
436433
*
@@ -442,15 +439,16 @@ enum class TransitionState { IDLE, FADING_OUT, FADING_IN };
442439
* @param argv The array of command-line arguments.
443440
* @return int Returns 0 on successful execution, or 1 on failure.
444441
*/
442+
// -------------------------- Main Application --------------------------
445443
int main(int argc, char* argv[]) {
446444
// --------------- Load the configuration ----------------
447445
auto config = load_config("config.ini");
448446

449447
// Assign VPX settings
450448
VPX_TABLES_PATH = get_string(config, "VPX", "TablesPath", "/home/tarso/Games/vpinball/build/tables/");
451449
VPX_EXECUTABLE_CMD = get_string(config, "VPX", "ExecutableCmd", "/home/tarso/Games/vpinball/build/VPinballX_GL");
452-
VPX_SUB_CMD = "-Play"; // Not in config, use hardcoded default
453-
VPX_START_ARGS = get_string(config, "VPX", "StartArgs", "DRI_PRIME=1 gamemoderun");
450+
VPX_SUB_CMD = get_string(config, "Internal", "SubCmd", "-Play");
451+
VPX_START_ARGS = get_string(config, "VPX", "StartArgs", "");
454452
VPX_END_ARGS = get_string(config, "VPX", "EndArgs", "");
455453

456454
// Assign CustomMedia settings
@@ -471,7 +469,7 @@ int main(int argc, char* argv[]) {
471469
SECOND_WINDOW_HEIGHT = get_int(config, "WindowSettings", "SecondHeight", 1024);
472470

473471
// Assign Font settings
474-
FONT_PATH = get_string(config, "Font", "Path", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf");
472+
FONT_PATH = get_string(config, "Internal", "FontPath", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf");
475473
FONT_SIZE = get_int(config, "Font", "Size", 28);
476474

477475
// Assign MediaDimensions
@@ -482,18 +480,18 @@ int main(int argc, char* argv[]) {
482480
DMD_MEDIA_WIDTH = get_int(config, "MediaDimensions", "DmdWidth", 1024);
483481
DMD_MEDIA_HEIGHT = get_int(config, "MediaDimensions", "DmdHeight", 256);
484482

485-
// Set defaults for variables not in config.ini
486-
DEFAULT_TABLE_IMAGE = "img/default_table.png";
487-
DEFAULT_BACKGLASS_IMAGE = "img/default_backglass.png";
488-
DEFAULT_DMD_IMAGE = "img/default_dmd.png";
489-
DEFAULT_WHEEL_IMAGE = "img/default_wheel.png";
490-
DEFAULT_TABLE_VIDEO = "img/default_table.mp4";
491-
DEFAULT_BACKGLASS_VIDEO = "img/default_backglass.mp4";
492-
DEFAULT_DMD_VIDEO = "img/default_dmd.mp4";
493-
FADE_DURATION_MS = 250;
494-
FADE_TARGET_ALPHA = 128;
495-
TABLE_CHANGE_SOUND = "snd/table_change.mp3";
496-
TABLE_LOAD_SOUND = "snd/table_load.mp3";
483+
// Set defaults for variables
484+
DEFAULT_TABLE_IMAGE = get_string(config, "Internal", "DefaultTableImage", "img/default_table.png");
485+
DEFAULT_BACKGLASS_IMAGE = get_string(config, "Internal", "DefaultBackglassImage", "img/default_backglass.png");
486+
DEFAULT_DMD_IMAGE = get_string(config, "Internal", "DefaultDmdImage", "img/default_dmd.png");
487+
DEFAULT_WHEEL_IMAGE = get_string(config, "Internal", "DefaultWheelImage", "img/default_wheel.png");
488+
DEFAULT_TABLE_VIDEO = get_string(config, "Internal", "DefaultTableVideo", "img/default_table.mp4");
489+
DEFAULT_BACKGLASS_VIDEO = get_string(config, "Internal", "DefaultBackglassVideo", "img/default_backglass.mp4");
490+
DEFAULT_DMD_VIDEO = get_string(config, "Internal", "DefaultDmdVideo", "img/default_dmd.mp4");
491+
FADE_DURATION_MS = get_int(config, "Internal", "FadeDurationMs", 250);
492+
FADE_TARGET_ALPHA = static_cast<Uint8>(get_int(config, "Internal", "FadeTargetAlpha", 128));
493+
TABLE_CHANGE_SOUND = get_string(config, "Internal", "TableChangeSound", "snd/table_change.mp3");
494+
TABLE_LOAD_SOUND = get_string(config, "Internal", "TableLoadSound", "snd/table_load.mp3");
497495

498496
// ------------------ Initialization ------------------
499497

@@ -579,18 +577,25 @@ int main(int argc, char* argv[]) {
579577

580578
// ------------------ Texture and State Variables ------------------
581579

580+
// Index of the currently selected table
582581
size_t currentIndex = 0;
583-
SDL_Texture* tableTexture = nullptr;
584-
SDL_Texture* wheelTexture = nullptr;
585-
SDL_Texture* backglassTexture = nullptr;
586-
SDL_Texture* dmdTexture = nullptr;
587-
SDL_Texture* tableNameTexture = nullptr;
582+
583+
// SDL textures for rendering images and videos
584+
SDL_Texture* tableTexture = nullptr; // Texture for the table playfield image or video
585+
SDL_Texture* wheelTexture = nullptr; // Texture for the wheel image
586+
SDL_Texture* backglassTexture = nullptr; // Texture for the backglass image or video
587+
SDL_Texture* dmdTexture = nullptr; // Texture for the DMD image or video
588+
SDL_Texture* tableNameTexture = nullptr; // Texture for rendering the table name text
589+
590+
// Rectangle to define the position and size of the table name text
588591
SDL_Rect tableNameRect = {0, 0, 0, 0};
589592

593+
// VLC media player instances for table, backglass, and DMD videos
590594
libvlc_media_player_t* tableVideoPlayer = nullptr;
591595
libvlc_media_player_t* backglassVideoPlayer = nullptr;
592596
libvlc_media_player_t* dmdVideoPlayer = nullptr;
593597

598+
// Video context structures to hold rendering data for table, backglass, and DMD videos
594599
VideoContext tableVideoCtx = {nullptr, nullptr, 0, nullptr, 0, 0, false};
595600
VideoContext backglassVideoCtx = {nullptr, nullptr, 0, nullptr, 0, 0, false};
596601
VideoContext dmdVideoCtx = {nullptr, nullptr, 0, nullptr, 0, 0, false};
@@ -607,7 +612,8 @@ int main(int argc, char* argv[]) {
607612
if (dmdTexture) { SDL_DestroyTexture(dmdTexture); dmdTexture = nullptr; }
608613
if (tableNameTexture) { SDL_DestroyTexture(tableNameTexture); tableNameTexture = nullptr; }
609614

610-
const Table &tbl = tables[currentIndex];
615+
// Start Loading
616+
const Table &tbl = tables[currentIndex]; // Structure to hold information about each pinball table
611617

612618
if (!tbl.tableVideo.empty()) {
613619
tableVideoPlayer = setupVideoPlayer(vlcInstance.get(), primaryRenderer.get(),

0 commit comments

Comments
 (0)