Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-gtk-3.22/tileset_dlg.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
tileset_dlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <gtk/gtk.h>
19
20/* utility */
21#include "fcintl.h"
22
23/* common */
24#include "game.h"
25#include "unitlist.h"
26
27/* client */
28#include "tilespec.h"
29
30/* client/gui-gtk-3.22 */
31#include "gui_main.h"
32#include "gui_stuff.h"
33
34#include "dialogs_g.h"
35
36extern char forced_tileset_name[512];
37static void tileset_suggestion_callback(GtkWidget *dlg, gint arg);
38
39/************************************************************************/
42 static void tileset_suggestion_callback(GtkWidget *dlg, gint arg)
43{
44 if (arg == GTK_RESPONSE_YES) {
45 /* User accepted tileset loading */
46 sz_strlcpy(forced_tileset_name, game.control.preferred_tileset);
47 if (!tilespec_reread(game.control.preferred_tileset, TRUE, 1.0)) {
48 tileset_error(LOG_ERROR, game.control.preferred_tileset,
49 _("Can't load requested tileset."));
50 }
51 }
52}
53
54/************************************************************************/
58 void popup_tileset_suggestion_dialog(void)
59{
60 GtkWidget *dialog, *label;
61 char buf[1024];
62
63 dialog = gtk_dialog_new_with_buttons(_("Preferred tileset"),
64 NULL,
65 0,
66 _("_Load tileset"),
67 GTK_RESPONSE_YES,
68 _("_Keep current tileset"),
69 GTK_RESPONSE_NO,
70 NULL);
71 setup_dialog(dialog, toplevel);
72 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
73 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
74
75 fc_snprintf(buf, sizeof(buf),
76 _("Modpack suggests using %s tileset.\n"
77 "It might not work with other tilesets.\n"
78 "You are currently using tileset %s."),
79 game.control.preferred_tileset, tileset_basename(tileset));
80
81 label = gtk_label_new(buf);
82 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
83 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
84 gtk_widget_show(label);
85
86 g_signal_connect(dialog, "response",
87 G_CALLBACK(tileset_suggestion_callback), NULL);
88
89 /* In case incoming rulesets are incompatible with current tileset
90 * we need to block their receive before user has accepted loading
91 * of the correct tileset. */
92 gtk_dialog_run(GTK_DIALOG(dialog));
93
94 gtk_widget_destroy(dialog);
95}
incite_cost
char * incite_cost
Definition comments.c:74
dialogs_g.h
fcintl.h
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:62
game.h
toplevel
GtkWidget * toplevel
Definition gui_main.c:125
setup_dialog
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
forced_tileset_name
char forced_tileset_name[512]
Definition client_main.c:137
popup_tileset_suggestion_dialog
void popup_tileset_suggestion_dialog(void)
Definition tileset_dlg.c:58
tileset_suggestion_callback
static void tileset_suggestion_callback(GtkWidget *dlg, gint arg)
Definition tileset_dlg.c:42
gui_stuff.h
gui_main.h
LOG_ERROR
@ LOG_ERROR
Definition log.h:30
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
packet_ruleset_control::preferred_tileset
char preferred_tileset[MAX_LEN_NAME]
Definition packets_gen.h:1471
tileset
Definition tilespec.c:481
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:189
TRUE
#define TRUE
Definition support.h:46
tileset_basename
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:704
tileset_error
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:624
tilespec_reread
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1355
tilespec.h
unitlist.h