browse beta complete

This commit is contained in:
p.kosyh 2010-06-02 12:41:36 +00:00
parent b65386681d
commit e7f451da17
11 changed files with 47 additions and 13 deletions

View file

@ -21,7 +21,7 @@ LUA_LFLAGS=-llua5.1 -L../windows/
SDL_CFLAGS=-I../windows/SDL
SDL_LFLAGS=-lSDL -lSDLmain -lSDL_ttf -lSDL_mixer -lSDL_image -L../windows/SDL
CFLAGS += -Wall -mwindows -D_HAVE_ICONV -D_USE_UNPACK
CFLAGS += -Wall -mwindows -D_HAVE_ICONV -D_USE_UNPACK -D_USE_BROWSE
LDFLAGS += -liconv
CC=i486-mingw32-gcc

View file

@ -19,7 +19,7 @@ LUA_LFLAGS=-llua5.1
SDL_CFLAGS=-IC:\MinGW\include\SDL
SDL_LFLAGS=-lSDL -lSDLmain -lSDL_ttf -lSDL_mixer -lSDL_image
CFLAGS += -Wall -mwindows -D_HAVE_ICONV -D_USE_UNPACK
CFLAGS += -Wall -mwindows -D_HAVE_ICONV -D_USE_UNPACK -D_USE_BROWSE
LDFLAGS += -liconv
CC=gcc

View file

@ -109,7 +109,7 @@ fi
echo -n "Generating config.make..."
echo "# autamatically generated by configure.sh" >config.make
if [[ ! -z "$gtk_cflags" ]]; then
echo "EXTRA_CFLAGS+=-D_USE_GTK" >> config.make
echo "EXTRA_CFLAGS+=-D_USE_GTK -D_USE_BROWSE" >> config.make
echo "EXTRA_CFLAGS+=\$(shell $gtk_cflags)" >> config.make
echo "EXTRA_LDFLAGS+=\$(shell $gtk_libs)" >> config.make
fi

View file

@ -119,3 +119,5 @@ CANCEL_MENU = <a:/resume>Cancel</a>
DISABLED_SAVE_MENU = \
Saving is disabled by game.\n
BROWSE_MENU = \
...

View file

@ -119,3 +119,5 @@ CANCEL_MENU = <a:/resume>Cancelar</a>
DISABLED_SAVE_MENU = \
Guardar está deshabilitado desde el juego.\n
BROWSE_MENU = \
...

View file

@ -120,3 +120,5 @@ CANCEL_MENU = <a:/resume>Отмена</a>
DISABLED_SAVE_MENU = \
Сохранение запрещено игрой.\n
BROWSE_MENU = \
...

View file

@ -2352,11 +2352,15 @@ int game_from_disk(void)
d = dirname(d);
b = basename(b);
/* fprintf(stderr,"%s:%s\n", d, b); */
#ifdef _USE_UNPACK
p = game_tmp_path();
fprintf(stderr,"Trying to install: %s\n", g);
if (!unpack(g, p) && zip_game_dirname[0]) {
games_replace(p, zip_game_dirname);
p = zip_game_dirname;
#else
if (0) {
#endif
} else if (games_replace(d, b)) {
return -1;
} else

View file

@ -63,6 +63,8 @@ extern int game_paused(void);
extern char *open_file_dialog(void);
extern int game_from_disk(void);
#define CURSOR_CLEAR -1
#define CURSOR_OFF 0
#define CURSOR_ON 1

View file

@ -194,6 +194,9 @@ int main(int argc, char **argv)
out:
if (debug_sw)
debug_done();
#ifdef _USE_GTK
gtk_main_quit ();
#endif
return err;
}

View file

@ -29,6 +29,7 @@ char *SELECT_THEME_MENU = NULL;
char *SAVED_MENU = NULL;
char *NOGAMES_MENU = NULL;
char *NOTHEMES_MENU = NULL;
char *BROWSE_MENU = NULL;
char *QUIT_MENU = NULL;
char *ON = NULL;
char *OFF = NULL;
@ -141,7 +142,7 @@ static void save_menu(void)
strcat(menu_buff, CANCEL_MENU);
}
static int pages_menu(char *res, int nr, int max, const char *menu)
static int pages_menu(char *res, int nr, int max, const char *menu, const char *append)
{
static char buff[256];
int k = MENU_PER_PAGER;
@ -170,18 +171,26 @@ static int pages_menu(char *res, int nr, int max, const char *menu)
else
sprintf(buff, ">>");
strcat(res, buff);
strcat(res, "\n");
strcat(res, append);
return 0;
}
static void games_menu(void)
{
int i, n;
int i, n, append_browse = 0;
char tmp[PATH_MAX];
#ifdef _USE_BROWSE
snprintf(tmp, sizeof(tmp), " <u><a:/browse>%s</a></u>\n", BROWSE_MENU);
#else
snprintf(tmp, sizeof(tmp), "\n");
#endif
sprintf(menu_buff, SELECT_GAME_MENU);
if ((games_nr - 1) / MENU_GAMES_MAX)
pages_menu(menu_buff, games_menu_from / MENU_GAMES_MAX, (games_nr - 1) / MENU_GAMES_MAX + 1, "games");
pages_menu(menu_buff, games_menu_from / MENU_GAMES_MAX, (games_nr - 1) / MENU_GAMES_MAX + 1, "games", tmp);
else
append_browse = 1;
for (i = games_menu_from, n = 0; i < games_nr && n < MENU_GAMES_MAX; i ++) {
char tmp[PATH_MAX];
if (!games[i].name[0]) /* empty */
continue;
if (curgame_dir && !strcmp(games[i].dir, curgame_dir))
@ -191,9 +200,14 @@ static void games_menu(void)
strcat(menu_buff, tmp);
n ++;
}
for(;n < MENU_GAMES_MAX && games_nr > MENU_GAMES_MAX; n++) /* align h */
strcat(menu_buff, "\n");
#ifdef _USE_BROWSE
if (append_browse) {
snprintf(tmp, sizeof(tmp), "<u><a:/browse>%s</a></u>\n", BROWSE_MENU);
strcat(menu_buff, tmp);
}
#endif
if (!games_nr)
sprintf(menu_buff, NOGAMES_MENU, GAMES_PATH);
strcat(menu_buff,"\n");
@ -205,7 +219,7 @@ static void themes_menu(void)
int i, n;
sprintf(menu_buff, SELECT_THEME_MENU);
if ((themes_nr - 1) / MENU_THEMES_MAX)
pages_menu(menu_buff, themes_menu_from / MENU_THEMES_MAX, (themes_nr - 1) / MENU_THEMES_MAX + 1, "themes");
pages_menu(menu_buff, themes_menu_from / MENU_THEMES_MAX, (themes_nr - 1) / MENU_THEMES_MAX + 1, "themes", "\n");
for (i = themes_menu_from, n = 0; i < themes_nr && n < MENU_THEMES_MAX; i ++) {
char tmp[PATH_MAX];
if (!themes[i].name[0]) /* empty */
@ -489,6 +503,9 @@ int game_menu_act(const char *a)
game_menu_box(1, game_menu_gen());
} else if (!strcmp(a,"/quit")) {
return -1;
} else if (!strcmp(a,"/browse")) {
game_from_disk();
return 0;
} else if (cur_menu == menu_games) {
char *p;
p = strdup(a);
@ -562,6 +579,7 @@ static void lang_free(void)
FREE(CANCEL_MENU);
FREE(FROM_THEME);
FREE(DISABLED_SAVE_MENU);
FREE(BROWSE_MENU);
}
static int lang_ok(void)
@ -572,7 +590,7 @@ static int lang_ok(void)
CUSTOM_THEME_MENU && OWN_THEME_MENU && SELECT_GAME_MENU && SELECT_THEME_MENU &&
SAVED_MENU && NOGAMES_MENU && NOTHEMES_MENU && QUIT_MENU &&
ON && OFF && KBD_MODE_LINKS && KBD_MODE_SMART && KBD_MODE_SCROLL && CANCEL_MENU &&
FROM_THEME && DISABLED_SAVE_MENU)
FROM_THEME && DISABLED_SAVE_MENU && BROWSE_MENU)
return 0;
return -1;
}
@ -606,6 +624,7 @@ struct parser lang_parser[] = {
{ "CANCEL_MENU", parse_esc_string, &CANCEL_MENU },
{ "FROM_THEME", parse_esc_string, &FROM_THEME },
{ "DISABLED_SAVE_MENU", parse_esc_string, &DISABLED_SAVE_MENU },
{ "BROWSE_MENU", parse_esc_string, &BROWSE_MENU },
{ NULL, },
};

View file

@ -130,8 +130,8 @@ char *open_file_dialog(void)
g_free (filename);
}
}
g_signal_handler_disconnect (file_dialog, response_handler);
gtk_widget_destroy(file_dialog);
g_signal_handler_disconnect (GTK_WIDGET(file_dialog), response_handler);
gtk_widget_destroy(GTK_WIDGET(file_dialog));
while(gtk_events_pending())
gtk_main_iteration();
return (file[0])?file:NULL;