]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/prtview/prtview.cpp
macos: add ssasc to deps, it's required to build the GTK theme
[xonotic/netradiant.git] / contrib / prtview / prtview.cpp
index 301ac9ea154a8835682c9b22a6a89d3a285ea359..14aeec1325bb80feec981cda000f8170d6c21bb0 100644 (file)
 #include "stream/stringstream.h"
 
 #include "portals.h"
-#include "AboutDialog.h"
 #include "ConfigDialog.h"
 #include "LoadPortalFileDialog.h"
 
 #define Q3R_CMD_SPLITTER "-"
-#define Q3R_CMD_ABOUT "About Portal Viewer"
+#define Q3R_CMD_ABOUT "About..."
 #define Q3R_CMD_LOAD "Load .prt file"
 #define Q3R_CMD_RELEASE "Unload .prt file"
 #define Q3R_CMD_SHOW_3D "Toggle portals (3D)"
 #define Q3R_CMD_SHOW_2D "Toggle portals (2D)"
-#define Q3R_CMD_OPTIONS "Configure Portal Viewer"
+#define Q3R_CMD_OPTIONS "Configure..."
 
 CopiedString INIfn;
 
 /////////////////////////////////////////////////////////////////////////////
 // CPrtViewApp construction
 
-#define RENDER_2D "Render2D"
-#define WIDTH_2D "Width2D"
-#define AA_2D "AntiAlias2D"
-#define COLOR_2D "Color2D"
-
-#define RENDER_3D "Render3D"
-#define WIDTH_3D "Width3D"
-#define AA_3D "AntiAlias3D"
-#define COLOR_3D "Color3D"
-#define COLOR_FOG "ColorFog"
-#define FOG "Fog"
-#define ZBUFFER "ZBuffer"
-#define POLYGON "Polygons"
-#define LINE "Lines"
-#define TRANS_3D "Transparency"
-#define CLIP_RANGE "ClipRange"
-#define CLIP "Clip"
-
+const char *RENDER_2D = "Render2D";
+const char *WIDTH_2D = "Width2D";
+const char *AA_2D = "AntiAlias2D";
+const char *COLOR_2D = "Color2D";
+
+const char *RENDER_3D = "Render3D";
+const char *WIDTH_3D = "Width3D";
+const char *AA_3D = "AntiAlias3D";
+const char *COLOR_3D = "Color3D";
+const char *COLOR_FOG = "ColorFog";
+const char *FOG = "Fog";
+const char *ZBUFFER = "ZBuffer";
+const char *POLYGON = "Polygons";
+const char *LINE = "Lines";
+const char *TRANS_3D = "Transparency";
+const char *CLIP_RANGE = "ClipRange";
+const char *CLIP = "Clip";
+
+static ui::Window main_window{ui::null};
 
 void PrtView_construct(){
        StringOutputStream tmp( 64 );
@@ -160,9 +160,9 @@ void SaveConfig(){
 }
 
 
-#define CONFIG_SECTION "Configuration"
+const char *CONFIG_SECTION = "Configuration";
 
-int INIGetInt( char *key, int def ){
+int INIGetInt( const char *key, int def ){
        char value[1024];
 
        if ( read_var( INIfn.c_str(), CONFIG_SECTION, key, value ) ) {
@@ -173,7 +173,7 @@ int INIGetInt( char *key, int def ){
        }
 }
 
-void INISetInt( char *key, int val, char *comment /* = NULL */ ){
+void INISetInt( const char *key, int val, const char *comment /* = NULL */ ){
        char s[1000];
 
        if ( comment ) {
@@ -185,9 +185,6 @@ void INISetInt( char *key, int val, char *comment /* = NULL */ ){
        save_var( INIfn.c_str(), CONFIG_SECTION, key, s );
 }
 
-
-// plugin name
-static const char *PLUGIN_NAME = "Portal Viewer";
 // commands in the menu
 static const char *PLUGIN_COMMANDS =
        Q3R_CMD_ABOUT ";"
@@ -203,7 +200,10 @@ static const char *PLUGIN_COMMANDS =
 
 
 const char* QERPlug_Init( void *hApp, void* pMainWidget ){
-       return "Portal Viewer for Q3Radiant";
+       main_window = ui::Window::from(pMainWidget);
+       ASSERT_TRUE( main_window );
+
+       return PLUGIN_NAME " for " RADIANT_NAME;
 }
 
 const char* QERPlug_GetName(){
@@ -224,7 +224,19 @@ void QERPlug_Dispatch( const char* p, float* vMin, float* vMax, bool bSingleBrus
        globalOutputStream() << MSG_PREFIX "Command \"" << p << "\"\n";
 
        if ( !strcmp( p,Q3R_CMD_ABOUT ) ) {
-               DoAboutDlg();
+               const char *label_text =
+                               PLUGIN_NAME " " PLUGIN_VERSION " for "
+                               RADIANT_NAME " " RADIANT_VERSION "\n\n"
+                               "Gtk port by Leonardo Zide <leo@lokigames.com>\n"
+                               "Written by Geoffrey DeWan <gdewan@prairienet.org>\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 );
        }
        else if ( !strcmp( p,Q3R_CMD_LOAD ) ) {
                if ( DoLoadPortalFileDialog() == IDOK ) {
@@ -270,7 +282,7 @@ void QERPlug_Dispatch( const char* p, float* vMin, float* vMax, bool bSingleBrus
                }
        }
        else if ( !strcmp( p,Q3R_CMD_OPTIONS ) ) {
-               DoConfigDialog();
+               DoConfigDialog( main_window );
                SaveConfig();
 
                SceneChangeNotify();
@@ -294,7 +306,7 @@ class PrtViewPluginModule
 _QERPluginTable m_plugin;
 public:
 typedef _QERPluginTable Type;
-STRING_CONSTANT( Name, "prtview" );
+STRING_CONSTANT( Name, PLUGIN_NAME );
 
 PrtViewPluginModule(){
        m_plugin.m_pfnQERPlug_Init = QERPlug_Init;