@@ -361,7 +361,7 @@ std::map<std::string, std::map<std::string, std::string>> load_config(const std:
361
361
return config;
362
362
}
363
363
364
- // ----------------- Initialization Guard Functions -------------------
364
+ // ----------------- Initialization Guard Classes -------------------
365
365
366
366
// Guard for SDL initialization
367
367
class SDLInitGuard {
@@ -426,11 +426,8 @@ class MixerGuard {
426
426
}
427
427
};
428
428
429
- // -------------------------- Main Application --------------------------
430
-
431
429
enum class TransitionState { IDLE, FADING_OUT, FADING_IN };
432
430
433
- // Main function for initializing and running the SDL application
434
431
/* *
435
432
* @brief Main function for initializing and running the SDL application.
436
433
*
@@ -442,15 +439,16 @@ enum class TransitionState { IDLE, FADING_OUT, FADING_IN };
442
439
* @param argv The array of command-line arguments.
443
440
* @return int Returns 0 on successful execution, or 1 on failure.
444
441
*/
442
+ // -------------------------- Main Application --------------------------
445
443
int main (int argc, char * argv[]) {
446
444
// --------------- Load the configuration ----------------
447
445
auto config = load_config (" config.ini" );
448
446
449
447
// Assign VPX settings
450
448
VPX_TABLES_PATH = get_string (config, " VPX" , " TablesPath" , " /home/tarso/Games/vpinball/build/tables/" );
451
449
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" , " " );
454
452
VPX_END_ARGS = get_string (config, " VPX" , " EndArgs" , " " );
455
453
456
454
// Assign CustomMedia settings
@@ -471,7 +469,7 @@ int main(int argc, char* argv[]) {
471
469
SECOND_WINDOW_HEIGHT = get_int (config, " WindowSettings" , " SecondHeight" , 1024 );
472
470
473
471
// 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" );
475
473
FONT_SIZE = get_int (config, " Font" , " Size" , 28 );
476
474
477
475
// Assign MediaDimensions
@@ -482,18 +480,18 @@ int main(int argc, char* argv[]) {
482
480
DMD_MEDIA_WIDTH = get_int (config, " MediaDimensions" , " DmdWidth" , 1024 );
483
481
DMD_MEDIA_HEIGHT = get_int (config, " MediaDimensions" , " DmdHeight" , 256 );
484
482
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" ) ;
497
495
498
496
// ------------------ Initialization ------------------
499
497
@@ -579,18 +577,25 @@ int main(int argc, char* argv[]) {
579
577
580
578
// ------------------ Texture and State Variables ------------------
581
579
580
+ // Index of the currently selected table
582
581
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
588
591
SDL_Rect tableNameRect = {0 , 0 , 0 , 0 };
589
592
593
+ // VLC media player instances for table, backglass, and DMD videos
590
594
libvlc_media_player_t * tableVideoPlayer = nullptr ;
591
595
libvlc_media_player_t * backglassVideoPlayer = nullptr ;
592
596
libvlc_media_player_t * dmdVideoPlayer = nullptr ;
593
597
598
+ // Video context structures to hold rendering data for table, backglass, and DMD videos
594
599
VideoContext tableVideoCtx = {nullptr , nullptr , 0 , nullptr , 0 , 0 , false };
595
600
VideoContext backglassVideoCtx = {nullptr , nullptr , 0 , nullptr , 0 , 0 , false };
596
601
VideoContext dmdVideoCtx = {nullptr , nullptr , 0 , nullptr , 0 , 0 , false };
@@ -607,7 +612,8 @@ int main(int argc, char* argv[]) {
607
612
if (dmdTexture) { SDL_DestroyTexture (dmdTexture); dmdTexture = nullptr ; }
608
613
if (tableNameTexture) { SDL_DestroyTexture (tableNameTexture); tableNameTexture = nullptr ; }
609
614
610
- const Table &tbl = tables[currentIndex];
615
+ // Start Loading
616
+ const Table &tbl = tables[currentIndex]; // Structure to hold information about each pinball table
611
617
612
618
if (!tbl.tableVideo .empty ()) {
613
619
tableVideoPlayer = setupVideoPlayer (vlcInstance.get (), primaryRenderer.get (),
0 commit comments