Compare commits
1 Commits
feat-audio
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cac7577ba9 |
14
README.md
14
README.md
@@ -51,7 +51,7 @@ DESTDIR=/some/staging/path make install
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
gsplash <image_or_video_path> <game_executable> [game_arguments...]
|
||||
gsplash [options] <image_or_video_path> <game_executable> [game_arguments...]
|
||||
```
|
||||
|
||||
Example:
|
||||
@@ -72,9 +72,17 @@ Gsplash allows you to configure how the image or video is displayed with 3 modes
|
||||
You can set these by using the `-m` or `--mode` flag:
|
||||
|
||||
```bash
|
||||
build/gsplash [--mode=stretch|center|crop] <background> <executable> [args...]
|
||||
gsplash [--mode=stretch|center|crop] <background> <executable> [args...]
|
||||
|
||||
build/gsplash -m stretch|center|crop <background> <executable> [args...]
|
||||
gsplash -m stretch|center|crop <background> <executable> [args...]
|
||||
```
|
||||
|
||||
You can optionally protect the splash screen from dismissing on focus changes for a given number of seconds using `-i` or `--ignore-focus=SEC`. This is useful if the game process itself brings up a short-lived focus window before the main game window opens:
|
||||
|
||||
```bash
|
||||
gsplash --ignore-focus=2.5 <background> <executable> [args...]
|
||||
|
||||
gsplash -i 2.5 <background> <executable> [args...]
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ static void compute_dest_rect(int src_w, int src_h, int out_w, int out_h,
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
RenderMode render_mode = RENDER_CENTER;
|
||||
float focus_ignore_seconds = 0.0f;
|
||||
int arg_index = 1;
|
||||
|
||||
#ifndef GSPLASH_VERSION
|
||||
@@ -114,6 +115,16 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
render_mode = parse_render_mode(argv[arg_index + 1]);
|
||||
arg_index += 2;
|
||||
} else if (strncmp(argv[arg_index], "--ignore-focus=", 15) == 0) {
|
||||
focus_ignore_seconds = atof(argv[arg_index] + 15);
|
||||
arg_index++;
|
||||
} else if (strcmp(argv[arg_index], "-i") == 0) {
|
||||
if (arg_index + 1 >= argc) {
|
||||
log_error("Missing value for option -i");
|
||||
return 1;
|
||||
}
|
||||
focus_ignore_seconds = atof(argv[arg_index + 1]);
|
||||
arg_index += 2;
|
||||
} else if (strcmp(argv[arg_index], "--version") == 0 ||
|
||||
strcmp(argv[arg_index], "-v") == 0) {
|
||||
printf("gsplash version %s\n", GSPLASH_VERSION);
|
||||
@@ -123,11 +134,15 @@ int main(int argc, char* argv[]) {
|
||||
printf("Usage: %s [options] <image_path> <game_executable> [args...]\n",
|
||||
argv[0]);
|
||||
printf("Options:\n");
|
||||
printf(" -v, --version Show version information\n");
|
||||
printf(" -v, --version Show version information\n");
|
||||
printf(
|
||||
" -m, --mode=MODE Set render mode: stretch, center (default), "
|
||||
" -m, --mode=MODE Set render mode: stretch, center "
|
||||
"(default), "
|
||||
"crop\n");
|
||||
printf(" -h, --help Show this help message\n");
|
||||
printf(
|
||||
" -i, --ignore-focus=SEC Ignore focus changes for a given amount "
|
||||
"of seconds\n");
|
||||
printf(" -h, --help Show this help message\n");
|
||||
return 0;
|
||||
} else {
|
||||
log_error("Unknown option: %s", argv[arg_index]);
|
||||
@@ -261,6 +276,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// Fork the process to run the game
|
||||
log_info("Launching game executable");
|
||||
Uint32 launch_time = SDL_GetTicks();
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
// Inside Child Process: Hand over execution directly to the game binary
|
||||
@@ -328,10 +344,16 @@ int main(int argc, char* argv[]) {
|
||||
// THE MOMENT THE GAME WINDOW STEALS FOCUS:
|
||||
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST &&
|
||||
!hide_scheduled) {
|
||||
log_info("Splash window hidden (focus lost), scheduling hide");
|
||||
hide_scheduled = true;
|
||||
hide_time =
|
||||
SDL_GetTicks() + 100; // 100ms delay to prevent desktop flash
|
||||
Uint32 current_time = SDL_GetTicks();
|
||||
if (current_time - launch_time <
|
||||
(Uint32)(focus_ignore_seconds * 1000.0f)) {
|
||||
log_info("Ignoring focus loss due to ignore limit");
|
||||
} else {
|
||||
log_info("Splash window hidden (focus lost), scheduling hide");
|
||||
hide_scheduled = true;
|
||||
hide_time =
|
||||
SDL_GetTicks() + 100; // 100ms delay to prevent desktop flash
|
||||
}
|
||||
}
|
||||
// Re-render static image when compositor requests a redraw
|
||||
if (event.window.event == SDL_WINDOWEVENT_EXPOSED && texture &&
|
||||
|
||||
Reference in New Issue
Block a user