summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/help/header.txt2
-rw-r--r--data/help/support.txt2
-rw-r--r--data/help/tips/10.txt2
-rw-r--r--data/help/tips/16.txt2
-rw-r--r--data/help/tips/8.txt2
-rw-r--r--src/gui/helpwindow.cpp12
-rw-r--r--src/test/testmain.cpp8
-rw-r--r--src/utils/process.cpp97
-rw-r--r--src/utils/process.h9
9 files changed, 115 insertions, 21 deletions
diff --git a/data/help/header.txt b/data/help/header.txt
index 5d5604b77..dbc11a75d 100644
--- a/data/help/header.txt
+++ b/data/help/header.txt
@@ -4,6 +4,6 @@
<<##2Version:##6%VER%>>
-##2 <<Website: http://manaplus.evolonline.org/>>
+##2 <<Website: @@http://manaplus.evolonline.org/|http://manaplus.evolonline.org/@@>>
diff --git a/data/help/support.txt b/data/help/support.txt
index bd50b471c..a29b38882 100644
--- a/data/help/support.txt
+++ b/data/help/support.txt
@@ -20,7 +20,7 @@
<< For TMW support:
-<<##2 http://forums.themanaworld.org/viewforum.php?f=3
+<<##2 @@http://forums.themanaworld.org/viewforum.php?f=3|http://forums.themanaworld.org@@
or visit IRC channel:>>
##2 #themanaworld ##P@##2 irc.freenode.net
diff --git a/data/help/tips/10.txt b/data/help/tips/10.txt
index 3eec89728..88c25f907 100644
--- a/data/help/tips/10.txt
+++ b/data/help/tips/10.txt
@@ -1,2 +1,2 @@
<<If client working very slow, you can improve speed
-by reading this: http://manaplus.evolonline.org/slowpc>>
+by reading this: @@http://manaplus.evolonline.org/slowpc|http://manaplus.evolonline.org/slowpc@@>>
diff --git a/data/help/tips/16.txt b/data/help/tips/16.txt
index 92b8d9450..95d891dbd 100644
--- a/data/help/tips/16.txt
+++ b/data/help/tips/16.txt
@@ -1,2 +1,2 @@
<<Look this page for help and downloads:>>
-http://manaplus.evolonline.org/
+@@http://manaplus.evolonline.org/|http://manaplus.evolonline.org/@@
diff --git a/data/help/tips/8.txt b/data/help/tips/8.txt
index fd405ab1a..bd47560cb 100644
--- a/data/help/tips/8.txt
+++ b/data/help/tips/8.txt
@@ -1,2 +1,2 @@
<<About yellow bar you can read here:
-http://manaplus.evolonline.org/yellowbar>>
+@@http://manaplus.evolonline.org/yellowbar|http://manaplus.evolonline.org/yellowbar@@>>
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index c2b0d873f..f88394f82 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -38,6 +38,7 @@
#include "utils/gettext.h"
#include "utils/langs.h"
+#include "utils/process.h"
#include "utils/translation/podict.h"
#include "utils/translation/translationmanager.h"
@@ -92,8 +93,15 @@ void HelpWindow::action(const gcn::ActionEvent &event)
void HelpWindow::handleLink(const std::string &link,
gcn::MouseEvent *event A_UNUSED)
{
- std::string helpFile = link;
- loadHelp(helpFile);
+ if (!strStartWith(link, "http://"))
+ {
+ std::string helpFile = link;
+ loadHelp(helpFile);
+ }
+ else
+ {
+ openBrowser(link);
+ }
}
void HelpWindow::loadHelp(const std::string &helpFile)
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
index bdf071394..07e7a8f01 100644
--- a/src/test/testmain.cpp
+++ b/src/test/testmain.cpp
@@ -260,7 +260,7 @@ int TestMain::invokeTest(std::string test)
mConfig.setValue("opengl", 0);
mConfig.write();
- int ret = execFile(fileName, fileName, "-t", test);
+ int ret = execFileWait(fileName, fileName, "-t", test);
return ret;
}
@@ -277,7 +277,7 @@ int TestMain::invokeSoftwareRenderTest(std::string test)
{
mConfig.setValue("opengl", 0);
mConfig.write();
- int ret = execFile(fileName, fileName, "-t", test, 30);
+ int ret = execFileWait(fileName, fileName, "-t", test, 30);
log->log("%s: %d", test.c_str(), ret);
return ret;
}
@@ -287,7 +287,7 @@ int TestMain::invokeFastOpenGLRenderTest(std::string test)
#if defined USE_OPENGL
mConfig.setValue("opengl", 1);
mConfig.write();
- int ret = execFile(fileName, fileName, "-t", test, 30);
+ int ret = execFileWait(fileName, fileName, "-t", test, 30);
log->log("%s: %d", test.c_str(), ret);
return ret;
#else
@@ -300,7 +300,7 @@ int TestMain::invokeSafeOpenGLRenderTest(std::string test)
#if defined USE_OPENGL
mConfig.setValue("opengl", 2);
mConfig.write();
- int ret = execFile(fileName, fileName, "-t", test, 30);
+ int ret = execFileWait(fileName, fileName, "-t", test, 30);
log->log("%s: %d", test.c_str(), ret);
return ret;
#else
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index 2d64f3a37..54f85b066 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -37,8 +37,8 @@ const int timeOut = 10;
#include <windows.h>
-int execFile(std::string pathName, std::string name A_UNUSED,
- std::string arg1, std::string arg2, int waitTime)
+int execFileWait(std::string pathName, std::string name A_UNUSED,
+ std::string arg1, std::string arg2, int waitTime)
{
if (!waitTime)
waitTime = timeOut;
@@ -74,21 +74,59 @@ int execFile(std::string pathName, std::string name A_UNUSED,
return -1;
}
+bool execFile(std::string pathName, std::string name A_UNUSED,
+ std::string arg1, std::string arg2)
+{
+ STARTUPINFO siStartupInfo;
+ PROCESS_INFORMATION piProcessInfo;
+ memset(&siStartupInfo, 0, sizeof(siStartupInfo));
+ memset(&piProcessInfo, 0, sizeof(piProcessInfo));
+ siStartupInfo.cb = sizeof(siStartupInfo);
+ std::string args(pathName + " " + arg1);
+ if (!arg2.empty())
+ args += " " + arg2;
+
+ bool res = CreateProcess(pathName.c_str(), (char*)args.c_str(), nullptr,
+ nullptr, false, CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr,
+ &siStartupInfo, &piProcessInfo);
+
+ CloseHandle(piProcessInfo.hProcess);
+ CloseHandle(piProcessInfo.hThread);
+ return res;
+}
+
+bool openBrowser(std::string url)
+{
+ return (int)ShellExecute(nullptr, "open", url.c_str(), nullptr,
+ nullptr, SW_SHOWNORMAL) > 32;
+}
+
#elif defined(__APPLE__)
-int execFile(std::string pathName, std::string name,
- std::string arg1, std::string arg2, int waitTime)
+int execFileWait(std::string pathName, std::string name,
+ std::string arg1, std::string arg2, int waitTime)
{
return -1;
}
+bool execFile(std::string pathName, std::string name,
+ std::string arg1, std::string arg2)
+{
+ return false;
+}
+
+bool openBrowser(std::string url)
+{
+ return false;
+}
+
#elif defined __linux__ || defined __linux
#include <sys/types.h>
#include <sys/wait.h>
-int execFile(std::string pathName, std::string name,
- std::string arg1, std::string arg2, int waitTime)
+int execFileWait(std::string pathName, std::string name,
+ std::string arg1, std::string arg2, int waitTime)
{
pid_t mon_pid;
int status;
@@ -161,12 +199,55 @@ int execFile(std::string pathName, std::string name,
return -1;
}
+bool execFile(std::string pathName, std::string name,
+ std::string arg1, std::string arg2)
+{
+ int status;
+
+ pid_t pid;
+ if ((pid = fork()) == -1)
+ { // fork error
+ return false;
+ }
+ else if (!pid)
+ { // work child
+ if (arg2.empty())
+ {
+ execl(pathName.c_str(), name.c_str(),
+ arg1.c_str(), static_cast<char *>(nullptr));
+ }
+ else
+ {
+ execl(pathName.c_str(), name.c_str(), arg1.c_str(),
+ arg2.c_str(), static_cast<char *>(nullptr));
+ }
+ return false;
+ }
+ return true;
+}
+
+bool openBrowser(std::string url)
+{
+ return execFile("/usr/bin/xdg-open", "/usr/bin/xdg-open", url, "") == 0;
+}
+
#else
-int execFile(std::string pathName, std::string name,
- std::string arg1, std::string arg2, int waitTime)
+int execFileWait(std::string pathName, std::string name,
+ std::string arg1, std::string arg2, int waitTime)
{
return -1;
}
+bool execFile(std::string pathName, std::string name,
+ std::string arg1, std::string arg2)
+{
+ return false;
+}
+
+bool openBrowser(std::string url)
+{
+ return false;
+}
+
#endif
diff --git a/src/utils/process.h b/src/utils/process.h
index 12421729f..1895ed880 100644
--- a/src/utils/process.h
+++ b/src/utils/process.h
@@ -23,7 +23,12 @@
#include <string>
-int execFile(std::string pathName, std::string name,
- std::string arg1, std::string arg2, int waitTime = 0);
+int execFileWait(std::string pathName, std::string name,
+ std::string arg1, std::string arg2, int waitTime = 0);
+
+bool execFile(std::string pathName, std::string name,
+ std::string arg1, std::string arg2);
+
+bool openBrowser(std::string url);
#endif // UTILS_PROCESS_H