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

Freeciv-3.1

Loading...
Searching...
No Matches
soundset_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
26/* client */
27#include "audio.h"
28#include "client_main.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
36/************************************************************************/
39 static void soundset_suggestion_response(gint arg)
40{
41 if (arg == GTK_RESPONSE_YES) {
42 /* User accepted soundset loading */
43 audio_restart(game.control.preferred_soundset,
44 music_set_name);
45 }
46}
47
48/************************************************************************/
52 void popup_soundset_suggestion_dialog(void)
53{
54 GtkWidget *dialog, *label;
55 char buf[1024];
56
57 dialog = gtk_dialog_new_with_buttons(_("Preferred soundset"),
58 NULL,
59 0,
60 _("_Load soundset"),
61 GTK_RESPONSE_YES,
62 _("_Keep current soundset"),
63 GTK_RESPONSE_NO,
64 NULL);
65 setup_dialog(dialog, toplevel);
66 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
67 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
68
69 fc_snprintf(buf, sizeof(buf),
70 _("Modpack suggests using %s soundset.\n"
71 "It might not work with other soundsets.\n"
72 "You are currently using soundset %s."),
73 game.control.preferred_soundset, sound_set_name);
74
75 label = gtk_label_new(buf);
76 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
77 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
78 gtk_widget_show(label);
79
80 /* In case incoming rulesets are incompatible with current soundset
81 * we need to block their receive before user has accepted loading
82 * of the correct soundset. */
83 soundset_suggestion_response(blocking_dialog(dialog));
84
85 gtk_window_destroy(GTK_WINDOW(dialog));
86}
87
88/************************************************************************/
91 static void musicset_suggestion_response(gint arg)
92{
93 if (arg == GTK_RESPONSE_YES) {
94 /* User accepted musicset loading */
95 audio_restart(sound_set_name, game.control.preferred_musicset);
96 }
97}
98
99/************************************************************************/
103 void popup_musicset_suggestion_dialog(void)
104{
105 GtkWidget *dialog, *label;
106 char buf[1024];
107
108 dialog = gtk_dialog_new_with_buttons(_("Preferred musicset"),
109 NULL,
110 0,
111 _("_Load musicset"),
112 GTK_RESPONSE_YES,
113 _("_Keep current musicset"),
114 GTK_RESPONSE_NO,
115 NULL);
116 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
117 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
118
119 fc_snprintf(buf, sizeof(buf),
120 _("Modpack suggests using %s musicset.\n"
121 "It might not work with other musicsets.\n"
122 "You are currently using musicset %s."),
123 game.control.preferred_musicset, music_set_name);
124
125 label = gtk_label_new(buf);
126 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
127 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
128 gtk_widget_show(label);
129
130 /* In case incoming rulesets are incompatible with current musicset
131 * we need to block their receive before user has accepted loading
132 * of the correct musicset. */
133 musicset_suggestion_response(blocking_dialog(dialog));
134
135 gtk_window_destroy(GTK_WINDOW(dialog));
136}
audio_restart
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:369
audio.h
music_set_name
char music_set_name[512]
Definition client_main.c:139
sound_set_name
char sound_set_name[512]
Definition client_main.c:138
client_main.h
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
popup_musicset_suggestion_dialog
void popup_musicset_suggestion_dialog(void)
Definition soundset_dlg.c:109
popup_soundset_suggestion_dialog
void popup_soundset_suggestion_dialog(void)
Definition soundset_dlg.c:55
blocking_dialog
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1126
gui_stuff.h
soundset_suggestion_response
static void soundset_suggestion_response(gint arg)
Definition soundset_dlg.c:39
musicset_suggestion_response
static void musicset_suggestion_response(gint arg)
Definition soundset_dlg.c:91
gui_main.h
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
packet_ruleset_control::preferred_soundset
char preferred_soundset[MAX_LEN_NAME]
Definition packets_gen.h:1478
packet_ruleset_control::preferred_musicset
char preferred_musicset[MAX_LEN_NAME]
Definition packets_gen.h:1479
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
TRUE
#define TRUE
Definition support.h:46