X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fhelp.cpp;h=0b6bf2974161f2eced040cfc619920c6a2264e21;hb=7abfd4e21a8a66400a4970b83f08d7856b67832e;hp=4ab85c38d2acf76731d4991486853d9a0b907703;hpb=02a51890a3d97a0e937fbb11071cf7c41cc00aa9;p=xonotic%2Fnetradiant.git diff --git a/radiant/help.cpp b/radiant/help.cpp index 4ab85c38..0b6bf297 100644 --- a/radiant/help.cpp +++ b/radiant/help.cpp @@ -39,94 +39,95 @@ /*! the urls to fire up in the game packs help menus */ -namespace { - std::list mHelpURLs; +namespace +{ +std::list mHelpURLs; } /*! needed for hooking in Gtk+ */ -void HandleHelpCommand(CopiedString &str) -{ - OpenURL(str.c_str()); +void HandleHelpCommand( CopiedString& str ){ + OpenURL( str.c_str() ); } -void process_xlink(const char *filename, const char *menu_name, const char *base_url, ui::Menu menu) -{ - if (file_exists(filename)) { - xmlDocPtr pDoc = xmlParseFile(filename); - if (pDoc) { - globalOutputStream() << "Processing .xlink file '" << filename << "'\n"; - // create sub menu - auto 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://") || - strstr(reinterpret_cast( prop ), "https://")) { - // 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, ui::Menu menu ){ + if ( file_exists( filename ) ) { + xmlDocPtr pDoc = xmlParseFile( filename ); + if ( pDoc ) { + globalOutputStream() << "Processing .xlink file '" << filename << "'\n"; + // create sub menu + auto 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://" ) || + strstr( reinterpret_cast( prop ), "https://" ) ) { + // 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(ui::Menu menu) -{ - StringOutputStream filename(256); - filename << AppPath_get() << "global.xlink"; - process_xlink(filename.c_str(), "General", AppPath_get(), menu); +void create_game_help_menu( ui::Menu menu ){ + StringOutputStream filename( 256 ); + filename << DataPath_get() << "global.xlink"; + process_xlink(filename.c_str(), "General", DataPath_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 }