more mode support
This commit is contained in:
parent
3ae2c9a4fb
commit
67b4ecaa93
|
@ -31,4 +31,6 @@ extern char *opt_lang;
|
|||
extern int cfg_load(void);
|
||||
extern int cfg_save(void);
|
||||
|
||||
extern int parse_mode(const char *v, void *data);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -822,6 +822,10 @@ img_t game_pict_scale(img_t img, int ww, int hh)
|
|||
img_t img2 = img;
|
||||
int w, h, www, hhh;
|
||||
float scale1, scale2, scale = 1.0f;
|
||||
|
||||
if (game_theme.scale > 1.0f)
|
||||
theme_img_scale(&img);
|
||||
|
||||
w = gfx_img_w(img);
|
||||
h = gfx_img_h(img);
|
||||
|
||||
|
@ -832,7 +836,7 @@ img_t game_pict_scale(img_t img, int ww, int hh)
|
|||
|
||||
if (w <= ww && h <= hh)
|
||||
return img;
|
||||
|
||||
|
||||
www = ww;
|
||||
hhh = hh;
|
||||
|
||||
|
|
|
@ -412,12 +412,24 @@ img_t gfx_new(int w, int h)
|
|||
{
|
||||
SDL_Surface *dst;
|
||||
if (!screen) {
|
||||
Uint32 rmask, gmask, bmask, amask;
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
rmask = 0xff000000;
|
||||
gmask = 0x00ff0000;
|
||||
bmask = 0x0000ff00;
|
||||
amask = 0x000000ff;
|
||||
#else
|
||||
rmask = 0x000000ff;
|
||||
gmask = 0x0000ff00;
|
||||
bmask = 0x00ff0000;
|
||||
amask = 0xff000000;
|
||||
#endif
|
||||
dst = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
|
||||
32,
|
||||
0xff,
|
||||
0xff00,
|
||||
0xff0000,
|
||||
0xff000000);
|
||||
32,
|
||||
rmask,
|
||||
gmask,
|
||||
bmask,
|
||||
amask);
|
||||
} else {
|
||||
dst = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
|
||||
screen->format->BitsPerPixel,
|
||||
|
@ -874,6 +886,7 @@ void gfx_video_done(void)
|
|||
{
|
||||
if (icon)
|
||||
SDL_FreeSurface(icon);
|
||||
screen = NULL;
|
||||
TTF_Quit();
|
||||
}
|
||||
|
||||
|
@ -2037,7 +2050,9 @@ img_t get_img(struct layout *layout, char *p)
|
|||
p[len] = 0;
|
||||
img = layout_lookup_image(layout, p);
|
||||
if (!img && (img = gfx_load_image(p))) {
|
||||
struct image *image = image_new(p, img);
|
||||
struct image *image;
|
||||
theme_img_scale(&img); /* bad style, no gfx layer :( */
|
||||
image = image_new(p, img);
|
||||
if (!image) {
|
||||
gfx_free_image(img);
|
||||
img = NULL;
|
||||
|
|
|
@ -12,6 +12,7 @@ char *theme_sw = NULL;
|
|||
char *themes_sw = NULL;
|
||||
char *encode_sw = NULL;
|
||||
char *encode_output = NULL;
|
||||
char *mode_sw = NULL;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
@ -24,7 +25,12 @@ int main(int argc, char **argv)
|
|||
nosound_sw = 1;
|
||||
else if (!strcmp(argv[i], "-fullscreen"))
|
||||
fullscreen_sw = 1;
|
||||
else if (!strcmp(argv[i], "-window"))
|
||||
else if (!strcmp(argv[i], "-mode")) {
|
||||
if ((i + 1) < argc)
|
||||
mode_sw = argv[++i];
|
||||
else
|
||||
mode_sw = "-1x-1";
|
||||
} else if (!strcmp(argv[i], "-window"))
|
||||
window_sw = 1;
|
||||
else if (!strcmp(argv[i], "-debug"))
|
||||
debug_sw = 1;
|
||||
|
@ -101,6 +107,8 @@ int main(int argc, char **argv)
|
|||
if (fullscreen_sw)
|
||||
opt_fs = 1;
|
||||
|
||||
if (mode_sw)
|
||||
parse_mode(mode_sw, opt_mode);
|
||||
|
||||
if (game_sw) {
|
||||
FREE(opt_game);
|
||||
|
|
|
@ -286,14 +286,14 @@ int game_menu_act(const char *a)
|
|||
game_menu_box(1, game_menu_gen());
|
||||
} else if (!strcmp(a, "/fs--")) {
|
||||
opt_fsize --;
|
||||
if (FONT_SZ(game_theme.font_size) > FONT_MIN_SZ) {
|
||||
if (FONT_SZ(game_theme.font_size) > FONT_MIN_SZ * game_theme.scale) {
|
||||
restart_needed = 1;
|
||||
} else
|
||||
opt_fsize ++;
|
||||
game_menu_box(1, game_menu_gen());
|
||||
} else if (!strcmp(a, "/fs++")) {
|
||||
opt_fsize ++;
|
||||
if (FONT_SZ(game_theme.font_size) < FONT_MAX_SZ) {
|
||||
if (FONT_SZ(game_theme.font_size) < FONT_MAX_SZ * game_theme.scale) {
|
||||
restart_needed = 1;
|
||||
} else
|
||||
opt_fsize --;
|
||||
|
|
|
@ -213,9 +213,10 @@ int game_theme_free(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int theme_img_scale(img_t *p, float v)
|
||||
int theme_img_scale(img_t *p)
|
||||
{
|
||||
img_t pic;
|
||||
float v = game_theme.scale;
|
||||
if (!p || !*p)
|
||||
return 0;
|
||||
pic = gfx_scale(*p, v, v);
|
||||
|
@ -284,17 +285,16 @@ static int game_theme_scale(int w, int h)
|
|||
static int theme_gfx_scale(void)
|
||||
{
|
||||
struct game_theme *t = &game_theme;
|
||||
float v = t->scale;
|
||||
if (v == 1.0f)
|
||||
if (t->scale == 1.0f)
|
||||
return 0;
|
||||
if (theme_img_scale(&t->a_up, v) ||
|
||||
theme_img_scale(&t->a_down, v) ||
|
||||
theme_img_scale(&t->inv_a_up, v) ||
|
||||
theme_img_scale(&t->inv_a_down, v) ||
|
||||
theme_img_scale(&t->use, v) ||
|
||||
theme_img_scale(&t->cursor, v) ||
|
||||
theme_img_scale(&t->menu_button, v) ||
|
||||
theme_img_scale(&t->bg, v))
|
||||
if (theme_img_scale(&t->a_up) ||
|
||||
theme_img_scale(&t->a_down) ||
|
||||
theme_img_scale(&t->inv_a_up) ||
|
||||
theme_img_scale(&t->inv_a_down) ||
|
||||
theme_img_scale(&t->use) ||
|
||||
theme_img_scale(&t->cursor) ||
|
||||
theme_img_scale(&t->menu_button) ||
|
||||
theme_img_scale(&t->bg))
|
||||
return -1;
|
||||
|
||||
if (t->bg) {
|
||||
|
|
|
@ -110,7 +110,7 @@ extern int game_theme_free(void);
|
|||
extern int game_theme_init(int w, int h);
|
||||
extern int theme_load(const char *name);
|
||||
extern char *game_local_themes_path(void);
|
||||
|
||||
extern int theme_img_scale(img_t *p);
|
||||
#define GFX_MODE_FLOAT 0
|
||||
#define GFX_MODE_FIXED 1
|
||||
#define GFX_MODE_EMBEDDED 2
|
||||
|
|
Reference in a new issue