- Es pot canviar la resolució des del programa abm res(w,h)

- La finestra es resizable
- Es permet arrancar des d'un arxiu .lua passat com a paràmetre.
This commit is contained in:
2023-11-28 19:03:13 +01:00
parent 7569c24d04
commit 63eaaa857e
5 changed files with 44 additions and 14 deletions

View File

@@ -41,6 +41,8 @@ FILE *file = NULL;
//uint8_t file_mode = 0;
bool file_ignore_comma=true;
char main_lua_file[200] = "main.lua";
bool override_ini = false;
//char lua_files[1024];
#define DEST(x, y) dest_surface->p[x+y*dest_surface->w]
@@ -229,7 +231,7 @@ void createDisplay() {
if (screen_zoom <= 0) screen_zoom = 1;
while (screen_width*screen_zoom > desktop_width || screen_height*screen_zoom > desktop_height) screen_zoom--;
mini_win = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width*screen_zoom, screen_height*screen_zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:SDL_WINDOW_SHOWN);
mini_win = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width*screen_zoom, screen_height*screen_zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:SDL_WINDOW_RESIZABLE);
windowID = SDL_GetWindowID(mini_win);
mini_ren = SDL_CreateRenderer(mini_win, -1, 0);
//SDL_CreateWindowAndRenderer(512,512,0,&mini_win,&mini_ren);
@@ -262,6 +264,15 @@ void initGamePad() {
int main(int argc,char*argv[]){
if (argc>1)
{
file_setresourcefolder("./");
file_setsource(SOURCE_FOLDER);
strcpy(main_lua_file, argv[1]);
strcpy(window_title, argv[1]);
override_ini = true;
}
while (!should_quit) {
should_exit=false;
@@ -279,14 +290,17 @@ int main(int argc,char*argv[]){
strcat(res_file, "/../Resources/data.jrf");
file_setresourcefilename(res_file);
#endif
read_ini();
file_setconfigfolder(config_folder);
const char *zoom = file_getconfigvalue("zoom");
if (zoom) screen_zoom=atoi(zoom);
const char *fullscreen = file_getconfigvalue("fullscreen");
if (fullscreen) screen_fullscreen=strcmp(fullscreen, "true")==0?true:false;
const char *cursor = file_getconfigvalue("cursor");
if (cursor) screen_cursor=strcmp(cursor, "true")?true:false;
if (!override_ini)
{
read_ini();
file_setconfigfolder(config_folder);
const char *zoom = file_getconfigvalue("zoom");
if (zoom) screen_zoom=atoi(zoom);
const char *fullscreen = file_getconfigvalue("fullscreen");
if (fullscreen) screen_fullscreen=strcmp(fullscreen, "true")==0?true:false;
const char *cursor = file_getconfigvalue("cursor");
if (cursor) screen_cursor=strcmp(cursor, "true")?true:false;
}
setdest(newsurf(screen_width, screen_height));
@@ -314,7 +328,7 @@ int main(int argc,char*argv[]){
#ifdef DEBUG
debug("MINI v%s\n",MINI_VERSION);
#endif
lua_init();
lua_init(main_lua_file);
lua_call_init();
Uint32 dt=SDL_GetTicks();
@@ -1270,6 +1284,13 @@ void setzoom(const int value) {
file_setconfigvalue("zoom", SDL_itoa(screen_zoom, strzoom, 10));
}
void setres(const int w, const int h) {
screen_width = w;
screen_height = h;
destroyDisplay();
createDisplay();
}
bool getfullscreen() {
return screen_fullscreen;
}