mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Add gd::HelpFileAccess::OpenPage to open a page without passing its whole URL.
The webpage is assumed to be stored on the wiki and the language is automatically added to the URL if needed
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
#include "GDCore/Tools/HelpFileAccess.h"
|
||||
#include "GDCore/Tools/Locale/LocaleManager.h"
|
||||
#include <wx/mimetype.h> // mimetype support
|
||||
|
||||
namespace gd
|
||||
@@ -13,5 +14,24 @@ namespace gd
|
||||
|
||||
HelpFileAccess * HelpFileAccess::_singleton = NULL;
|
||||
|
||||
wxString HelpFileAccess::GetHelpURL(wxString page) const
|
||||
{
|
||||
wxString pageURL = "http://wiki.compilgames.net/doku.php/";
|
||||
|
||||
//Get the language name from the current language of GDevelop
|
||||
wxString languageName = wxLocale::GetLanguageInfo(gd::LocaleManager::Get()->GetLanguage())->CanonicalName.substr(0, 2);
|
||||
|
||||
//Add the language two letter code if the language is supported by the wiki.
|
||||
//Note: for "en", we don't need to add "en" to the URL.
|
||||
if(languageName == "fr" || languageName == "de" || languageName == "es" || languageName == "pt"
|
||||
|| languageName == "ru" || languageName == "zh")
|
||||
pageURL += languageName + (!page.StartsWith("/") ? "/" : "" );
|
||||
|
||||
//Add the page location to the URL
|
||||
pageURL += page;
|
||||
|
||||
return pageURL;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#ifndef HELPFILEACCESS_H
|
||||
#define HELPFILEACCESS_H
|
||||
#include "GDCore/Tools/Locale/LocaleManager.h"
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include <wx/string.h>
|
||||
|
||||
namespace gd
|
||||
@@ -58,11 +59,24 @@ public:
|
||||
/**
|
||||
* Ask the IDE to display the specified URL as help.
|
||||
*/
|
||||
inline void OpenURL(wxString url)
|
||||
inline void OpenURL(wxString url) GD_DEPRECATED
|
||||
{
|
||||
helpProvider->OpenURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the IDE to display the specified page as help.
|
||||
* This assumes that the page is hosted on the GDevelop's wiki : http://wiki.compilgames.net/doku.php/language/the_page_name
|
||||
* The "language" from the URL is deduced from the user language. For the languages that are not available on the wiki,
|
||||
* the user is redirected to the english page.
|
||||
*
|
||||
* \param page the address to the page relative to the wiki (http://wiki.compilgames.net/doku.php/language/)
|
||||
*/
|
||||
inline void OpenPage(wxString page)
|
||||
{
|
||||
helpProvider->OpenURL(GetHelpURL(page));
|
||||
}
|
||||
|
||||
static HelpFileAccess *Get()
|
||||
{
|
||||
if (NULL == _singleton)
|
||||
@@ -84,6 +98,8 @@ private:
|
||||
HelpFileAccess() : helpProvider(NULL) {};
|
||||
virtual ~HelpFileAccess() { };
|
||||
|
||||
wxString GetHelpURL(wxString page) const;
|
||||
|
||||
static HelpFileAccess *_singleton;
|
||||
HelpProvider * helpProvider;
|
||||
};
|
||||
|
Reference in New Issue
Block a user