Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-4.0/tileset_dlg.c Source File

Freeciv-3.1

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-4.0 */
31#include "gui_main.h"
32#include "gui_stuff.h"
33
34#include "dialogs_g.h"
35
36extern char forced_tileset_name[512];
37
38/************************************************************************/
41 static void tileset_suggestion_response(gint arg)
42{
43 if (arg == GTK_RESPONSE_YES) {
44 /* User accepted tileset loading */
45 sz_strlcpy(forced_tileset_name, game.control.preferred_tileset);
46 if (!tilespec_reread(game.control.preferred_tileset, TRUE, 1.0)) {
47 tileset_error(LOG_ERROR, game.control.preferred_tileset,
48 _("Can't load requested tileset."));
49 }
50 }
51}
52
53/************************************************************************/
57 void popup_tileset_suggestion_dialog(void)
58{
59 GtkWidget *dialog, *label;
60 char buf[1024];
61
62 dialog = gtk_dialog_new_with_buttons(_("Preferred tileset"),
63 NULL,
64 0,
65 _("_Load tileset"),
66 GTK_RESPONSE_YES,
67 _("_Keep current tileset"),
68 GTK_RESPONSE_NO,
69 NULL);
70 setup_dialog(dialog, toplevel);
71 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
72 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
73
74 fc_snprintf(buf, sizeof(buf),
75 _("Modpack suggests using %s tileset.\n"
76 "It might not work with other tilesets.\n"
77 "You are currently using tileset %s."),
78 game.control.preferred_tileset, tileset_basename(tileset));
79
80 label = gtk_label_new(buf);
81 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
82 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
83 gtk_widget_show(label);
84
85 /* In case incoming rulesets are incompatible with current tileset
86 * we need to block their receive before user has accepted loading
87 * of the correct tileset. */
88 tileset_suggestion_response(blocking_dialog(dialog));
89
90 gtk_window_destroy(GTK_WINDOW(dialog));
91}
dialogs_g.h
fcintl.h
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:57
game.h
toplevel
GtkWidget * toplevel
Definition gui_main.c:124
setup_dialog
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:281
forced_tileset_name
char forced_tileset_name[512]
Definition client_main.c:136
popup_tileset_suggestion_dialog
void popup_tileset_suggestion_dialog(void)
Definition tileset_dlg.c:57
blocking_dialog
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1126
gui_stuff.h
tileset_suggestion_response
static void tileset_suggestion_response(gint arg)
Definition tileset_dlg.c:41
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:1477
tileset
Definition tilespec.c:459
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:161
TRUE
#define TRUE
Definition support.h:46
tileset_basename
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:667
tileset_error
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:587
tilespec_reread
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1299
tilespec.h
unitlist.h