X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=radiant%2Fhelp.cpp;h=d5319f30c0469575d9091c8baa81e483b56c7914;hp=d2e5fbbb9b498cebef50bb552fe130ba577253c4;hb=92b301a7f2ac5fdb8eabd87a919552231e8c1f77;hpb=12b372f89ce109a4db9d510884fbe7d05af79870 diff --git a/radiant/help.cpp b/radiant/help.cpp index d2e5fbbb..d5319f30 100644 --- a/radiant/help.cpp +++ b/radiant/help.cpp @@ -1,23 +1,23 @@ /* -Copyright (C) 1999-2006 Id Software, Inc. and contributors. -For a list of contributors, see the accompanying CONTRIBUTORS file. + Copyright (C) 1999-2006 Id Software, Inc. and contributors. + For a list of contributors, see the accompanying CONTRIBUTORS file. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "help.h" @@ -37,102 +37,96 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "mainframe.h" /*! -the urls to fire up in the game packs help menus -*/ + the urls to fire up in the game packs help menus + */ namespace { - std::list mHelpURLs; +std::list mHelpURLs; } /*! -needed for hooking in Gtk+ -*/ -void HandleHelpCommand(CopiedString& str) -{ - OpenURL(str.c_str()); + needed for hooking in Gtk+ + */ +void HandleHelpCommand( CopiedString& str ){ + OpenURL( str.c_str() ); } -void process_xlink(const char* filename, const char *menu_name, const char *base_url, GtkMenu *menu) -{ - if(file_exists(filename)) - { - xmlDocPtr pDoc = xmlParseFile(filename); - if (pDoc) - { - globalOutputStream() << "Processing .xlink file '" << filename << "'\n"; - // create sub menu - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic(menu, menu_name); - // start walking the nodes, find the 'links' one - xmlNodePtr pNode = pDoc->children; - while (pNode && strcmp((const char*)pNode->name, "links")) - pNode=pNode->next; - if (pNode) - { - pNode = pNode->children; - while(pNode) - { - if(!strcmp((const char*)pNode->name, "item")) - { - // process the URL - CopiedString url; - - xmlChar* prop = xmlGetProp(pNode, reinterpret_cast("url")); - ASSERT_NOTNULL(prop); - if(strstr(reinterpret_cast(prop), "http://")) - { - // complete URL - url = reinterpret_cast(prop); - } - else - { - // relative URL - StringOutputStream full(256); - full << base_url << reinterpret_cast(prop); - url = full.c_str(); - } - - mHelpURLs.push_back(url); - - xmlFree(prop); - - prop = xmlGetProp(pNode, reinterpret_cast("name")); - ASSERT_NOTNULL(prop); - create_menu_item_with_mnemonic(menu_in_menu, reinterpret_cast(prop), ReferenceCaller(mHelpURLs.back())); - xmlFree(prop); - } - pNode=pNode->next; - } - } - xmlFreeDoc(pDoc); - } - else - { - globalOutputStream() << "'" << filename << "' parse failed\n"; - } - } - else - { - globalOutputStream() << "'" << filename << "' not found\n"; - } +void process_xlink( const char* filename, const char *menu_name, const char *base_url, GtkMenu *menu ){ + if ( file_exists( filename ) ) { + xmlDocPtr pDoc = xmlParseFile( filename ); + if ( pDoc ) { + globalOutputStream() << "Processing .xlink file '" << filename << "'\n"; + // create sub menu + GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, menu_name ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + // start walking the nodes, find the 'links' one + xmlNodePtr pNode = pDoc->children; + while ( pNode && strcmp( (const char*)pNode->name, "links" ) ) + pNode = pNode->next; + if ( pNode ) { + pNode = pNode->children; + while ( pNode ) + { + if ( !strcmp( (const char*)pNode->name, "item" ) ) { + // process the URL + CopiedString url; + + xmlChar* prop = xmlGetProp( pNode, reinterpret_cast( "url" ) ); + ASSERT_NOTNULL( prop ); + if ( strstr( reinterpret_cast( prop ), "http://" ) ) { + // complete URL + url = reinterpret_cast( prop ); + } + else + { + // relative URL + StringOutputStream full( 256 ); + full << base_url << reinterpret_cast( prop ); + url = full.c_str(); + } + + mHelpURLs.push_back( url ); + + xmlFree( prop ); + + prop = xmlGetProp( pNode, reinterpret_cast( "name" ) ); + ASSERT_NOTNULL( prop ); + create_menu_item_with_mnemonic( menu_in_menu, reinterpret_cast( prop ), ReferenceCaller( mHelpURLs.back() ) ); + xmlFree( prop ); + } + pNode = pNode->next; + } + } + xmlFreeDoc( pDoc ); + } + else + { + globalOutputStream() << "'" << filename << "' parse failed\n"; + } + } + else + { + globalOutputStream() << "'" << filename << "' not found\n"; + } } -void create_game_help_menu(GtkMenu *menu) -{ - StringOutputStream filename(256); - filename << AppPath_get() << "global.xlink"; - process_xlink(filename.c_str(), "General", AppPath_get(), menu); +void create_game_help_menu( GtkMenu *menu ){ + StringOutputStream filename( 256 ); + filename << AppPath_get() << "global.xlink"; + process_xlink( filename.c_str(), "General", AppPath_get(), menu ); #if 1 - filename.clear(); - filename << g_pGameDescription->mGameToolsPath.c_str() << "game.xlink"; - process_xlink(filename.c_str(), g_pGameDescription->getRequiredKeyValue("name"), g_pGameDescription->mGameToolsPath.c_str(), menu); + filename.clear(); + filename << g_pGameDescription->mGameToolsPath.c_str() << "game.xlink"; + process_xlink( filename.c_str(), g_pGameDescription->getRequiredKeyValue( "name" ), g_pGameDescription->mGameToolsPath.c_str(), menu ); #else - for(std::list::iterator iGame = g_GamesDialog.mGames.begin(); iGame != g_GamesDialog.mGames.end(); ++iGame) - { - filename.clear(); - filename << (*iGame)->mGameToolsPath.c_str() << "game.xlink"; - process_xlink(filename.c_str(), (*iGame)->getRequiredKeyValue("name"), (*iGame)->mGameToolsPath.c_str(), menu); - } + for ( std::list::iterator iGame = g_GamesDialog.mGames.begin(); iGame != g_GamesDialog.mGames.end(); ++iGame ) + { + filename.clear(); + filename << ( *iGame )->mGameToolsPath.c_str() << "game.xlink"; + process_xlink( filename.c_str(), ( *iGame )->getRequiredKeyValue( "name" ), ( *iGame )->mGameToolsPath.c_str(), menu ); + } #endif } -