diff options
| -rw-r--r-- | all.h | 2 | ||||
| -rw-r--r-- | main.c | 16 | ||||
| -rwxr-xr-x | tbrun.sh | 21 | ||||
| -rw-r--r-- | trenchbroom/stalag/GameEngineProfiles.cfg | 16 |
4 files changed, 44 insertions, 11 deletions
| @@ -131,6 +131,8 @@ typedef struct { | |||
| 131 | bool cursor_captured; | 131 | bool cursor_captured; |
| 132 | bool vsync; | 132 | bool vsync; |
| 133 | int target_fps; | 133 | int target_fps; |
| 134 | int screen_width; | ||
| 135 | int screen_height; | ||
| 134 | Font font_ui; | 136 | Font font_ui; |
| 135 | 137 | ||
| 136 | PlayerState player; | 138 | PlayerState player; |
| @@ -11,16 +11,20 @@ int main(int argc, char *argv[]) { | |||
| 11 | 11 | ||
| 12 | bool skip_title = false; | 12 | bool skip_title = false; |
| 13 | int target_fps = -1; | 13 | int target_fps = -1; |
| 14 | int width = WINDOW_WIDTH; | ||
| 15 | int height = WINDOW_HEIGHT; | ||
| 14 | 16 | ||
| 15 | static struct option long_options[] = { | 17 | static struct option long_options[] = { |
| 16 | {"map", required_argument, 0, 'm'}, | 18 | {"map", required_argument, 0, 'm'}, |
| 17 | {"fps", required_argument, 0, 'f'}, | 19 | {"fps", required_argument, 0, 'f'}, |
| 20 | {"width", required_argument, 0, 'w'}, | ||
| 21 | {"height", required_argument, 0, 'h'}, | ||
| 18 | {0, 0, 0, 0} | 22 | {0, 0, 0, 0} |
| 19 | }; | 23 | }; |
| 20 | 24 | ||
| 21 | int opt; | 25 | int opt; |
| 22 | int option_index = 0; | 26 | int option_index = 0; |
| 23 | while ((opt = getopt_long_only(argc, argv, "m:f:", long_options, &option_index)) != -1) { | 27 | while ((opt = getopt_long_only(argc, argv, "m:f:w:h:", long_options, &option_index)) != -1) { |
| 24 | switch (opt) { | 28 | switch (opt) { |
| 25 | case 'm': | 29 | case 'm': |
| 26 | sb_free(&map_path); | 30 | sb_free(&map_path); |
| @@ -31,6 +35,12 @@ int main(int argc, char *argv[]) { | |||
| 31 | case 'f': | 35 | case 'f': |
| 32 | target_fps = atoi(optarg); | 36 | target_fps = atoi(optarg); |
| 33 | break; | 37 | break; |
| 38 | case 'w': | ||
| 39 | width = atoi(optarg); | ||
| 40 | break; | ||
| 41 | case 'h': | ||
| 42 | height = atoi(optarg); | ||
| 43 | break; | ||
| 34 | } | 44 | } |
| 35 | } | 45 | } |
| 36 | 46 | ||
| @@ -38,13 +48,15 @@ int main(int argc, char *argv[]) { | |||
| 38 | if (target_fps < 0) flags |= FLAG_VSYNC_HINT; | 48 | if (target_fps < 0) flags |= FLAG_VSYNC_HINT; |
| 39 | 49 | ||
| 40 | SetConfigFlags(flags); | 50 | SetConfigFlags(flags); |
| 41 | InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE); | 51 | InitWindow(width, height, WINDOW_TITLE); |
| 42 | 52 | ||
| 43 | int monitor = GetCurrentMonitor(); | 53 | int monitor = GetCurrentMonitor(); |
| 44 | SetWindowPosition((GetMonitorWidth(monitor) - GetScreenWidth()) / 2, (GetMonitorHeight(monitor) - GetScreenHeight()) / 2); | 54 | SetWindowPosition((GetMonitorWidth(monitor) - GetScreenWidth()) / 2, (GetMonitorHeight(monitor) - GetScreenHeight()) / 2); |
| 45 | 55 | ||
| 46 | vfs_init(VFS_DATA_PAK); | 56 | vfs_init(VFS_DATA_PAK); |
| 47 | InitGame(); | 57 | InitGame(); |
| 58 | game.screen_width = width; | ||
| 59 | game.screen_height = height; | ||
| 48 | SetMap(map_path.data); | 60 | SetMap(map_path.data); |
| 49 | 61 | ||
| 50 | if (target_fps >= 0) { | 62 | if (target_fps >= 0) { |
| @@ -20,6 +20,8 @@ echo "$SCRIPT_DIR" | |||
| 20 | 20 | ||
| 21 | MAP="" | 21 | MAP="" |
| 22 | FPS="" | 22 | FPS="" |
| 23 | WIDTH="" | ||
| 24 | HEIGHT="" | ||
| 23 | while [ $# -gt 0 ]; do | 25 | while [ $# -gt 0 ]; do |
| 24 | case "$1" in | 26 | case "$1" in |
| 25 | --map) | 27 | --map) |
| @@ -36,6 +38,20 @@ while [ $# -gt 0 ]; do | |||
| 36 | --fps=*) | 38 | --fps=*) |
| 37 | FPS="${1#--fps=}" | 39 | FPS="${1#--fps=}" |
| 38 | ;; | 40 | ;; |
| 41 | --width) | ||
| 42 | shift | ||
| 43 | WIDTH="$1" | ||
| 44 | ;; | ||
| 45 | --width=*) | ||
| 46 | WIDTH="${1#--width=}" | ||
| 47 | ;; | ||
| 48 | --height) | ||
| 49 | shift | ||
| 50 | HEIGHT="$1" | ||
| 51 | ;; | ||
| 52 | --height=*) | ||
| 53 | HEIGHT="${1#--height=}" | ||
| 54 | ;; | ||
| 39 | --) shift; break;; | 55 | --) shift; break;; |
| 40 | *) ;; | 56 | *) ;; |
| 41 | esac | 57 | esac |
| @@ -43,4 +59,7 @@ while [ $# -gt 0 ]; do | |||
| 43 | done | 59 | done |
| 44 | 60 | ||
| 45 | cd "$SCRIPT_DIR" | 61 | cd "$SCRIPT_DIR" |
| 46 | ./bin/stalag --map "$MAP" --fps "$FPS" | 62 | ./bin/stalag --map "$MAP" \ |
| 63 | ${FPS:+--fps "$FPS"} \ | ||
| 64 | ${WIDTH:+--width "$WIDTH"} \ | ||
| 65 | ${HEIGHT:+--height "$HEIGHT"} | ||
diff --git a/trenchbroom/stalag/GameEngineProfiles.cfg b/trenchbroom/stalag/GameEngineProfiles.cfg index fb04830..81eda2f 100644 --- a/trenchbroom/stalag/GameEngineProfiles.cfg +++ b/trenchbroom/stalag/GameEngineProfiles.cfg | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | { | 1 | { |
| 2 | "profiles": [ | 2 | "profiles": [ |
| 3 | { | 3 | { |
| 4 | "name": "Stalag", | 4 | "name": "Stalag", |
| 5 | "parameters": "--fps 120 --map maps/${MAP_BASE_NAME}.map", | 5 | "parameters": "--fps 120 --width 1920 --height 1080 --map maps/${MAP_BASE_NAME}.map", |
| 6 | "path": "/home/m/Projects/stalag/tbrun.sh" | 6 | "path": "/home/m/Projects/stalag/tbrun.sh" |
| 7 | } | 7 | } |
| 8 | ], | 8 | ], |
| 9 | "version": 1 | 9 | "version": 1 |
| 10 | } | 10 | } |
