]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/sunplug/sunplug.cpp
Merge commit 'c5a6237a2b002c9811719172931b0c9cc5a725f4' into master-merge
[xonotic/netradiant.git] / contrib / sunplug / sunplug.cpp
index ac8233d1fd87f29d2986fd21d8134c1fece223fa..11aca066381717c90fa67ebc983945af20120824 100644 (file)
@@ -37,7 +37,8 @@
 
 #include <gtk/gtk.h>     // to display something with gtk (windows, buttons etc.), the whole package might not be necessary
 
-void about_plugin_window();
+#define CMD_ABOUT "About..."
+
 void MapCoordinator();
 
 #if !GDEF_OS_WINDOWS
@@ -190,13 +191,13 @@ char MenuList[100] = "";
 
 const char* init( void* hApp, void* pMainWidget ){
        main_window = ui::Window::from(pMainWidget);
-       return "Initializing SunPlug for GTKRadiant";
+       return "Initializing " PLUGIN_NAME " for " RADIANT_NAME;
 }
 const char* getName(){
-       return "SunPlug"; // name that is shown in the menue
+       return PLUGIN_NAME; // name that is shown in the menue
 }
 const char* getCommandList(){
-       const char about[] = "About...";
+       const char about[] = CMD_ABOUT;
        const char etMapCoordinator[] = ";ET-MapCoordinator";
 
        strcat( MenuList, about );
@@ -209,8 +210,19 @@ const char* getCommandTitleList(){
        return "";
 }
 void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ // message processing
-       if ( string_equal( command, "About..." ) ) {
-               about_plugin_window();
+       if ( string_equal( command, CMD_ABOUT ) ) {
+               char const *label_text = 
+                       PLUGIN_NAME " " PLUGIN_VERSION " for "
+                       RADIANT_NAME " " RADIANT_VERSION "\n\n"
+                       "Written by Topsun\n\n"
+                       "Built against "
+                       RADIANT_NAME " " RADIANT_VERSION_STRING "\n"
+                       __DATE__;
+
+               GlobalRadiant().m_pfnMessageBox( main_window, label_text,
+                                                                               "About " PLUGIN_NAME,
+                                                                               eMB_OK,
+                                                                               eMB_ICONDEFAULT );
        }
        if ( string_equal( command, "ET-MapCoordinator" ) ) {
                MapCoordinator();
@@ -223,7 +235,7 @@ class SunPlugModule : public TypeSystemRef
 _QERPluginTable m_plugin;
 public:
 typedef _QERPluginTable Type;
-STRING_CONSTANT( Name, "SunPlug" );
+STRING_CONSTANT( Name, PLUGIN_NAME );
 
 SunPlugModule(){
        m_plugin.m_pfnQERPlug_Init = &SunPlug::init;
@@ -252,33 +264,6 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server
 // ** my stuff **
 //  ************
 
-// About dialog
-void about_plugin_window(){
-       auto window = ui::Window( ui::window_type::TOP ); // create a window
-       gtk_window_set_transient_for( window, SunPlug::main_window ); // make the window to stay in front of the main window
-       window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event
-       window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
-       gtk_window_set_title( window, "About SunPlug" ); // set the title of the window for the window
-       gtk_window_set_resizable( window, FALSE ); // don't let the user resize the window
-       gtk_window_set_modal( window, TRUE ); // force the user not to do something with the other windows
-       gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window
-
-       auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
-       window.add(vbox);
-
-       auto label = ui::Label( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label
-       gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left
-       vbox.pack_start( label, FALSE, FALSE, 2 ); // insert the label in the box
-
-       auto button = ui::Button( "OK" ); // create a button with text
-       g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), (void *) window ); // connect the click event to close the window
-       vbox.pack_start( button, FALSE, FALSE, 2 ); // insert the button in the box
-
-       gtk_window_set_position( window, GTK_WIN_POS_CENTER ); // center the window on screen
-
-       gtk_widget_show_all( window ); // show the window and all subelements
-}
-
 // get the current bounding box and return the optimal coordinates
 void GetOptimalCoordinates( AABB *levelBoundingBox ){
        int half_width, half_heigth, center_x, center_y;