lemur/main.c

42 lines
832 B
C
Raw Normal View History

#include "cli.h"
#include <SDL2/SDL.h>
2024-11-01 01:21:05 +00:00
#include <stdbool.h>
2024-10-15 04:24:13 +00:00
#include <stdio.h>
#include "ui.h"
2024-10-15 04:24:13 +00:00
int main(int argc, char **argv) {
CLIArgs args;
UIContext *ui;
2024-10-15 04:24:13 +00:00
int status;
2024-11-01 01:21:05 +00:00
bool running = false;
2024-10-15 04:24:13 +00:00
if (parseCLIArgs(argc, argv, &args)) {
return 1;
}
2024-10-26 05:20:25 +00:00
SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "system");
if (SDL_Init(SDL_INIT_EVERYTHING)) {
2024-10-15 04:24:13 +00:00
fprintf(stderr, "Error initializing SDL: %s\n", SDL_GetError());
return 1;
}
ui = uiInit();
if (!ui) {
SDL_Quit();
2024-10-15 04:24:13 +00:00
return 1;
}
if (args.filename) {
2024-11-01 01:21:05 +00:00
if (uiLoadGame(ui, args.filename)) {
return 1;
}
running = true;
}
2024-11-01 01:21:05 +00:00
status = uiRun(ui, running);
uiDestroy(ui);
2024-10-15 04:24:13 +00:00
SDL_Quit();
return status;
2024-10-15 05:06:52 +00:00
}