X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=contrib%2Fshaderplug%2Fshaderplug.cpp;h=06c378a5ec956bc2cffd0e7a2268ed2b421f18e4;hb=1def25e964edbf47c1e62cea13a17b9628e3608e;hp=9d7bc4c52c78eca92c1e9d80095534675e5dc5d0;hpb=a78b39f38a98bef33e988ff35d37d15c7e2819a8;p=xonotic%2Fnetradiant.git diff --git a/contrib/shaderplug/shaderplug.cpp b/contrib/shaderplug/shaderplug.cpp index 9d7bc4c5..06c378a5 100644 --- a/contrib/shaderplug/shaderplug.cpp +++ b/contrib/shaderplug/shaderplug.cpp @@ -41,6 +41,8 @@ #include "generic/callback.h" +#define CMD_ABOUT "About..." + namespace { const char SHADERTAG_FILE[] = "shadertags.xml"; } @@ -57,7 +59,7 @@ ShaderPlugPluginDependencies() : namespace Shaderplug { -ui::Window g_window{ui::null}; +ui::Window main_window{ui::null}; std::vector archives; std::set shaders; @@ -67,26 +69,38 @@ XmlTagBuilder TagBuilder; void CreateTagFile(); const char* init( void* hApp, void* pMainWidget ){ - g_window = ui::Window::from(pMainWidget); + main_window = ui::Window::from(pMainWidget); return ""; } + const char* getName(){ - return "ShaderPlug"; + return PLUGIN_NAME; } + const char* getCommandList(){ - return "About;Create tag file"; + return CMD_ABOUT ";-;Create tag file"; } + const char* getCommandTitleList(){ return ""; } + void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ - if ( string_equal( command, "About" ) ) { - GlobalRadiant().m_pfnMessageBox( g_window, "Shaderplug (1.0)\n\n" - "by Shaderman (shaderman@gmx.net)", - "About", + if ( string_equal( command, CMD_ABOUT ) ) { + const char *label_text = + PLUGIN_NAME " " PLUGIN_VERSION " for " + RADIANT_NAME " " RADIANT_VERSION "\n\n" + "Written by Shaderman \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, "Create tag file" ) ) { CreateTagFile(); } @@ -130,25 +144,25 @@ void GetAllShaders(){ void GetArchiveList(){ GlobalFileSystem().forEachArchive(makeCallbackF(loadArchiveFile)); - globalOutputStream() << "Shaderplug: " << (const Unsigned)Shaderplug::archives.size() << " archives found.\n"; + globalOutputStream() << PLUGIN_NAME ": " << (const Unsigned)Shaderplug::archives.size() << " archives found.\n"; } void CreateTagFile(){ const char* shader_type = GlobalRadiant().getGameDescriptionKeyValue( "shaders" ); GetAllShaders(); - globalOutputStream() << "Shaderplug: " << (const Unsigned)shaders.size() << " shaders found.\n"; + globalOutputStream() << PLUGIN_NAME ": " << (const Unsigned)shaders.size() << " shaders found.\n"; if ( string_equal( shader_type, "quake3" ) ) { GetTextures( "jpg" ); GetTextures( "tga" ); GetTextures( "png" ); - globalOutputStream() << "Shaderplug: " << (const Unsigned)textures.size() << " textures found.\n"; + globalOutputStream() << PLUGIN_NAME ":" << (const Unsigned)textures.size() << " textures found.\n"; } if ( shaders.size() || textures.size() != 0 ) { - globalOutputStream() << "Shaderplug: Creating XML tag file.\n"; + globalOutputStream() << PLUGIN_NAME ":Creating XML tag file.\n"; TagBuilder.CreateXmlDocument(); @@ -172,26 +186,26 @@ void CreateTagFile(){ char message[256]; strcpy( message, "Tag file saved to\n" ); strcat( message, tagFile ); - strcat( message, "\nPlease restart Radiant now.\n" ); + strcat( message, "\nPlease restart " RADIANT_NAME " now.\n" ); if ( file_exists( tagFile ) ) { - EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( g_window , + EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( main_window , "WARNING! A tag file already exists! Overwrite it?", "Overwrite tag file?", eMB_NOYES, eMB_ICONWARNING ); if ( result == eIDYES ) { TagBuilder.SaveXmlDoc( tagFile ); - GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); + GlobalRadiant().m_pfnMessageBox( main_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); } } else { TagBuilder.SaveXmlDoc( tagFile ); - GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); + GlobalRadiant().m_pfnMessageBox( main_window, message, "INFO", eMB_OK, eMB_ICONASTERISK ); } } else { - GlobalRadiant().m_pfnMessageBox( g_window, + GlobalRadiant().m_pfnMessageBox( main_window, "No shaders or textures found. No XML tag file created!\n" "", "ERROR", @@ -206,7 +220,7 @@ class ShaderPluginModule _QERPluginTable m_plugin; public: typedef _QERPluginTable Type; -STRING_CONSTANT( Name, "ShaderPlug" ); +STRING_CONSTANT( Name, PLUGIN_NAME ); ShaderPluginModule(){ m_plugin.m_pfnQERPlug_Init = &Shaderplug::init;