Fixing Linux SCons build.
[xonotic/netradiant.git] / plugins / surface_ufoai / surfaceflagsdialog_ufoai.cpp
index d8febe482b983cba74bb497a0be1d60a33ad1b97..47b18975a104deb1a9f3855c700d0c98b98c2e1c 100644 (file)
@@ -20,7 +20,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 #include <gtk/gtk.h>
+#include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
+#include <glib/gi18n.h>
 
 #include "surfdlg_plugin.h"
 
@@ -31,6 +33,11 @@ GtkWidget *notebook1;
 // 32 bit is the max
 #define MAX_BUTTONS 32
 
+#ifdef _WIN32
+  // TTimo: THIS IS UGLY
+#define snprintf _snprintf
+#endif
+
 GtkWidget *surface_buttons[MAX_BUTTONS];
 GtkWidget *content_buttons[MAX_BUTTONS];
 
@@ -212,14 +219,14 @@ inline void change_contentflag (GtkWidget *togglebutton, int content_flag, gbool
 // Surface Flags Callbacks
 void on_surface_button_toggled (GtkToggleButton *togglebutton, gpointer user_data)
 {
-       int flag = *(int*)user_data;
+       int flag = GPOINTER_TO_INT(user_data);
        change_surfaceflag(GTK_WIDGET (togglebutton), flag, (GTK_TOGGLE_BUTTON (togglebutton)->active));
 }
 
 // Content Flags Callbacks
 void on_content_button_toggled (GtkToggleButton *togglebutton, gpointer user_data)
 {
-       int flag = *(int*)user_data;
+       int flag = GPOINTER_TO_INT(user_data);
        change_contentflag(GTK_WIDGET (togglebutton), flag, (GTK_TOGGLE_BUTTON (togglebutton)->active));
 }
 
@@ -269,77 +276,6 @@ void on_contentbutton_clicked (GtkButton *button, gpointer user_data)
        gtk_notebook_set_page (GTK_NOTEBOOK(notebook1), 1);
 }
 
-// FIXME: This should be in the ufoai.game
-static const char *surfaceFlags[] = {
-       "light",
-       "slick",
-       "",
-       "warp",
-       "trans33",
-       "trans66",
-       "flow",
-       "nodraw",
-       "hint",
-       "skip",
-       "phong",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "alphatest",
-       "",
-       "",
-       "",
-       "",
-       "",
-       ""
-};
-
-static const char *contentFlags[] = {
-       "solid",
-       "window",
-       "",
-       "fireaffected",
-       "",
-       "water",
-       "",
-       "",
-       "level1",
-       "level2",
-       "level3",
-       "level4",
-       "level5",
-       "level6",
-       "level7",
-       "level8",
-       "actorclip",
-       "passable",
-       "footstep",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "origin",
-       "weaponclip",
-       "",
-       "detail",
-       "",
-       "",
-       "stepon",
-       ""
-};
-
 #define UFOAI_FLAG_BUTTON_BORDER 3
 
 GtkWidget* Create_UFOAIFlagsDialog (GtkWidget* surfacedialog_widget)
@@ -357,10 +293,11 @@ GtkWidget* Create_UFOAIFlagsDialog (GtkWidget* surfacedialog_widget)
        GtkWidget *label5;
        GtkWidget *table3;
        GtkWidget *label6;
-       int flag = 0;
        int i, x, y;
+       const char *buttonLabel;
+       char buffer[8];
 
-       frame1 = gtk_frame_new ("Flags");
+       frame1 = gtk_frame_new (_("Flags"));
        gtk_widget_show (frame1);
        gtk_container_add (GTK_CONTAINER (surfacedialog_widget), frame1);
 
@@ -387,9 +324,11 @@ GtkWidget* Create_UFOAIFlagsDialog (GtkWidget* surfacedialog_widget)
                if (!(i % 4))
                        y++;
                x = i % 4;
-               flag = (1 << i);
-               surface_buttons[i] = gtk_toggle_button_new_with_label (surfaceFlags[i]);
-               gtk_signal_connect(GTK_OBJECT (surface_buttons[i]), "toggled", GTK_SIGNAL_FUNC(on_surface_button_toggled), &flag);
+               snprintf(buffer, sizeof(buffer) - 1, "surf%i", i + 1);
+               buttonLabel = g_FuncTable.m_pfnReadProjectKey(buffer);
+               Sys_Printf("%s: %s\n", buffer, buttonLabel);
+               surface_buttons[i] = gtk_toggle_button_new_with_label (buttonLabel);
+               gtk_signal_connect(GTK_OBJECT (surface_buttons[i]), "toggled", GTK_SIGNAL_FUNC(on_surface_button_toggled), GINT_TO_POINTER(1 << i));
                gtk_widget_show(surface_buttons[i]);
                gtk_table_attach(GTK_TABLE (table4), surface_buttons[i], 0 + x, 1 + x, (0 + y), (1 + y),
                                                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
@@ -446,9 +385,10 @@ GtkWidget* Create_UFOAIFlagsDialog (GtkWidget* surfacedialog_widget)
                if (!(i % 4))
                        y++;
                x = i % 4;
-               flag = (1 << i);
-               content_buttons[i] = gtk_toggle_button_new_with_label(contentFlags[i]);
-               gtk_signal_connect(GTK_OBJECT (content_buttons[i]), "toggled", GTK_SIGNAL_FUNC (on_content_button_toggled), &flag);
+               snprintf(buffer, sizeof(buffer) - 1, "cont%i", i + 1);
+               buttonLabel = g_FuncTable.m_pfnReadProjectKey(buffer);
+               content_buttons[i] = gtk_toggle_button_new_with_label(buttonLabel);
+               gtk_signal_connect(GTK_OBJECT (content_buttons[i]), "toggled", GTK_SIGNAL_FUNC (on_content_button_toggled), GINT_TO_POINTER(1 << i));
                gtk_widget_show(content_buttons[i]);
                gtk_table_attach(GTK_TABLE (table3), content_buttons[i], 0 + x, 1 + x, (0 + y), (1 + y),
                                                (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),