diff --git a/binaries/data/mods/public/gui/msgbox/msgbox.xml b/binaries/data/mods/public/gui/msgbox/msgbox.xml
index c08e956be7..241da60828 100644
--- a/binaries/data/mods/public/gui/msgbox/msgbox.xml
+++ b/binaries/data/mods/public/gui/msgbox/msgbox.xml
@@ -1,16 +1,16 @@
-
+ ]]>
diff --git a/source/gui/GUIManager.cpp b/source/gui/GUIManager.cpp
index fcdbf02d23..459e940ebb 100644
--- a/source/gui/GUIManager.cpp
+++ b/source/gui/GUIManager.cpp
@@ -100,6 +100,21 @@ void CGUIManager::PopPage()
m_PageStack.pop_back();
}
+void CGUIManager::DisplayMessageBox(int width, int height, const CStrW& title, const CStrW& message)
+{
+ // Set up scripted init data for the standard message box window
+ CScriptValRooted data;
+ m_ScriptInterface.Eval("({})", data);
+ m_ScriptInterface.SetProperty(data.get(), "width", width, false);
+ m_ScriptInterface.SetProperty(data.get(), "height", height, false);
+ m_ScriptInterface.SetProperty(data.get(), "mode", 2, false);
+ m_ScriptInterface.SetProperty(data.get(), "font", std::string("verdana16"), false);
+ m_ScriptInterface.SetProperty(data.get(), "title", std::wstring(title), false);
+ m_ScriptInterface.SetProperty(data.get(), "message", std::wstring(message), false);
+
+ // Display the message box
+ PushPage(L"page_msgbox.xml", data.get());
+}
void CGUIManager::LoadPage(SGUIPage& page)
{
diff --git a/source/gui/GUIManager.h b/source/gui/GUIManager.h
index d31b1279fc..1f8137984c 100644
--- a/source/gui/GUIManager.h
+++ b/source/gui/GUIManager.h
@@ -61,6 +61,11 @@ public:
// (There must be at least two pages when you call this.)
void PopPage();
+ /**
+ * Display a modal message box with an "OK" button.
+ */
+ void DisplayMessageBox(int width, int height, const CStrW& title, const CStrW& message);
+
// Hotload pages when their .xml files have changed
LibError ReloadChangedFiles(const VfsPath& path);
diff --git a/source/lib/res/graphics/ogl_tex.cpp b/source/lib/res/graphics/ogl_tex.cpp
index 497758f818..da358a6114 100644
--- a/source/lib/res/graphics/ogl_tex.cpp
+++ b/source/lib/res/graphics/ogl_tex.cpp
@@ -704,8 +704,10 @@ static void detect_gl_upload_caps()
}
// warn if more-or-less essential features are missing
+ // (but don't use DEBUG_DISPLAY_ERROR; the app should check ogl_tex_has_s3tc
+ // and give friendlier error messages, since this is a common problem)
if(!have_s3tc)
- DEBUG_DISPLAY_ERROR(L"Performance warning: your graphics card does not support compressed textures. The game will try to continue anyway, but may be slower than expected. Please try updating your graphics drivers; if that doesn't help, please try upgrading your hardware.");
+ debug_printf(L"Performance warning: your graphics card does not support compressed textures. The game will try to continue anyway, but may be slower than expected. Please try updating your graphics drivers; if that doesn't help, please try upgrading your hardware.\n");
}
@@ -1007,3 +1009,13 @@ LibError ogl_tex_transform_to(Handle ht, size_t new_flags)
LibError ret = tex_transform_to(&ot->t, new_flags);
return ret;
}
+
+
+// return whether native S3TC support is available
+bool ogl_tex_has_s3tc()
+{
+ // ogl_tex_upload must be called before this
+ debug_assert(have_s3tc != -1);
+
+ return have_s3tc;
+}
diff --git a/source/lib/res/graphics/ogl_tex.h b/source/lib/res/graphics/ogl_tex.h
index 067f9343d9..e3a2cc7554 100644
--- a/source/lib/res/graphics/ogl_tex.h
+++ b/source/lib/res/graphics/ogl_tex.h
@@ -426,4 +426,14 @@ extern LibError ogl_tex_transform(Handle ht, size_t flags);
*/
extern LibError ogl_tex_transform_to(Handle ht, size_t new_flags);
+/**
+ * Return whether native S3TC texture compression support is available.
+ * If not, textures will be decompressed automatically, hurting performance.
+ *
+ * @return true if native S3TC supported
+ *
+ * ogl_tex_upload must be called at least once before this.
+ */
+extern bool ogl_tex_has_s3tc();
+
#endif // #ifndef INCLUDED_OGL_TEX
diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp
index b1bc6145b1..ab41f5ae07 100644
--- a/source/ps/GameSetup/GameSetup.cpp
+++ b/source/ps/GameSetup/GameSetup.cpp
@@ -583,6 +583,22 @@ static void InitPs(bool setup_gui)
g_GUI->SwitchPage(L"page_pregame.xml", JSVAL_VOID);
else
g_GUI->SwitchPage(L"page_session_new.xml", JSVAL_VOID);
+
+ // Warn nicely about missing S3TC support
+ if (!ogl_tex_has_s3tc())
+ {
+ g_GUI->DisplayMessageBox(600, 350, L"Warning",
+ L"Performance warning:\n\n"
+ L"Your graphics drivers do not support S3TC compressed textures. This will significantly reduce performance and increase memory usage.\n\n"
+#if OS_LINUX
+ L"See http://dri.freedesktop.org/wiki/S3TC for details. "
+ L"Installing the libtxc_dxtn library will fix these problems. "
+ L"Alternatively, running 'driconf' and setting force_s3tc_enable will fix the performance but may cause rendering bugs."
+#else
+ L"Please try updating your graphics drivers to ensure you have full hardware acceleration."
+#endif
+ );
+ }
}
else
{
diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp
index b8faf9f95d..abcaeb252d 100644
--- a/source/scriptinterface/ScriptInterface.cpp
+++ b/source/scriptinterface/ScriptInterface.cpp
@@ -447,6 +447,14 @@ bool ScriptInterface::Eval_(const char* code, jsval& rval)
return ok ? true : false;
}
+bool ScriptInterface::Eval_(const wchar_t* code, jsval& rval)
+{
+ utf16string codeUtf16(code, code+wcslen(code));
+
+ JSBool ok = JS_EvaluateUCScript(m->m_cx, m->m_glob, (const jschar*)codeUtf16.c_str(), (uintN)codeUtf16.length(), "(eval)", 1, &rval);
+ return ok ? true : false;
+}
+
void ScriptInterface::ReportError(const char* msg)
{
// JS_ReportError by itself doesn't seem to set a JS-style exception, and so
diff --git a/source/scriptinterface/ScriptInterface.h b/source/scriptinterface/ScriptInterface.h
index e187526d79..e168d2d215 100644
--- a/source/scriptinterface/ScriptInterface.h
+++ b/source/scriptinterface/ScriptInterface.h
@@ -136,7 +136,7 @@ public:
bool Eval(const char* code);
- template bool Eval(const char* code, T& out);
+ template bool Eval(const CHAR* code, T& out);
/**
* Report the given error message through the JS error reporting mechanism,
@@ -188,6 +188,7 @@ public:
private:
bool CallFunction_(jsval val, const char* name, std::vector& args, jsval& ret);
bool Eval_(const char* code, jsval& ret);
+ bool Eval_(const wchar_t* code, jsval& ret);
bool SetGlobal_(const char* name, jsval value, bool replace);
bool SetProperty_(jsval obj, const char* name, jsval value, bool readonly);
bool GetProperty_(jsval obj, const char* name, jsval& value);
@@ -317,8 +318,8 @@ bool ScriptInterface::GetProperty(jsval obj, const char* name, T& out)
return FromJSVal(GetContext(), val, out);
}
-template
-bool ScriptInterface::Eval(const char* code, T& ret)
+template
+bool ScriptInterface::Eval(const CHAR* code, T& ret)
{
jsval rval;
if (! Eval_(code, rval))