2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 //-----------------------------------------------------------------------------
26 // custom Gtk dialog for brush primitives load/save
29 #include <glib/gi18n.h>
31 void BP_dialog_button_callback (GtkWidget *widget, gpointer data)
36 parent = gtk_widget_get_toplevel (widget);
37 loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
38 ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
41 *ret = GPOINTER_TO_INT (data);
44 gint BP_dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
48 gtk_widget_hide (widget);
49 loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
55 // ret: 0 = abort, 1 = load and convert, 2 = changed project settings, load and don't convert
56 // the user might decide to switch the BP mode in project settings
57 // status: 0 = loading regular, got conflict 1 = loading BP, got conflict
58 // int WINAPI gtk_MessageBox (GtkWidget *parent, const char* lpText, const char* lpCaption, guint32 uType)
59 int BP_MessageBox (int status)
61 GtkWidget *window, *w, *vbox, *hbox;
65 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
66 gtk_signal_connect (GTK_OBJECT (window), "delete_event",
67 GTK_SIGNAL_FUNC (BP_dialog_delete_callback), NULL);
68 gtk_signal_connect (GTK_OBJECT (window), "destroy",
69 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
71 gtk_window_set_title (GTK_WINDOW (window), _("Current map format is incompatible"));
73 gtk_container_border_width (GTK_CONTAINER (window), 10);
74 g_object_set_data (G_OBJECT (window), "loop", &loop);
75 g_object_set_data (G_OBJECT (window), "ret", &ret);
76 gtk_widget_realize (window);
78 gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (g_pParentWnd->m_pWidget));
80 accel = gtk_accel_group_new ();
81 gtk_window_add_accel_group (GTK_WINDOW (window), accel);
83 vbox = gtk_vbox_new (FALSE, 10);
84 gtk_container_add (GTK_CONTAINER (window), vbox);
85 gtk_widget_show (vbox);
89 w = gtk_label_new (_("This map was saved using brush primitives format\n"
90 "and your project settings use the standard format.\n"
91 "Do you want to convert the map, change default format or abort?\n"
92 "NOTE: due to limitations of the standard format, "
93 "some texture alignments may be lost after conversion."));
97 w = gtk_label_new (_("This map was saved using standard format\n"
98 "and your project settings use the new \"brush primitives\" format.\n"
99 "Do you want to convert the map, change default format or abort?\n"
100 "NOTE: Next versions of Radiant will allow mixing the two formats"
101 "in the same maps for a smooth transition."));
103 gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
104 gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
107 w = gtk_hseparator_new ();
108 gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
111 hbox = gtk_hbox_new (FALSE, 10);
112 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2);
113 gtk_widget_show (hbox);
115 w = gtk_button_new_with_label (_("Convert"));
116 gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
117 gtk_signal_connect (GTK_OBJECT (w), "clicked",
118 GTK_SIGNAL_FUNC (BP_dialog_button_callback), GINT_TO_POINTER (1));
119 GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
120 gtk_widget_grab_default (w);
123 w = gtk_button_new_with_label (_("Change default"));
124 gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
125 gtk_signal_connect (GTK_OBJECT (w), "clicked",
126 GTK_SIGNAL_FUNC (BP_dialog_button_callback), GINT_TO_POINTER (2));
129 w = gtk_button_new_with_label (_("Abort load"));
130 gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
131 gtk_signal_connect (GTK_OBJECT (w), "clicked",
132 GTK_SIGNAL_FUNC (BP_dialog_button_callback), GINT_TO_POINTER (0));
136 gtk_widget_show (window);
137 gtk_grab_add (window);
140 gtk_main_iteration ();
144 // change project settings
146 g_qeglobals.m_bBrushPrimitMode = TRUE;
148 g_qeglobals.m_bBrushPrimitMode = FALSE;
149 SetKeyValue(g_qeglobals.d_project_entity, "brush_primit", (g_qeglobals.m_bBrushPrimitMode ? "1" : "0" ));
152 gtk_grab_remove (window);
153 gtk_widget_destroy (window);