Have openMW launch through steam
Posted: 09 Jun 2016, 00:51
Aside from launching openMW in steam through "add non-steam game", is it possible to launch through the morrowind appid itself so it tracks playtime along with screenshots?
Code: Select all
diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt
index 8e938e0..a1dee30 100644
--- a/apps/openmw/CMakeLists.txt
+++ b/apps/openmw/CMakeLists.txt
@@ -119,6 +119,7 @@ include_directories(
)
target_link_libraries(openmw
+ "dl"
${OSG_LIBRARIES}
${OPENTHREADS_LIBRARIES}
${OSGPARTICLE_LIBRARIES}
diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp
index a4bf1fe..c730168 100644
--- a/apps/openmw/main.cpp
+++ b/apps/openmw/main.cpp
@@ -13,6 +13,8 @@
#include <boost/iostreams/stream_buffer.hpp>
#include <boost/filesystem/fstream.hpp>
+#include <dlfcn.h>
+
#if defined(_WIN32)
// For OutputDebugString
#ifndef WIN32_LEAN_AND_MEAN
@@ -294,6 +296,17 @@ private:
int main(int argc, char**argv)
{
+ setenv("SteamAppId", "22320", 0);
+
+ void* steamapi = dlopen("./libsteam_api64.so", RTLD_LAZY);
+ if (!steamapi)
+ throw std::runtime_error("Can't open libsteam_api64.so");
+ typedef void funcsig(void);
+ funcsig* steamapi_init = (funcsig*) dlsym(steamapi, "SteamAPI_Init");
+ if (steamapi_init == NULL)
+ throw std::runtime_error("Can't find SteamAPI_Init");
+ steamapi_init();
+
#if defined(__APPLE__)
setenv("OSG_GL_TEXTURE_STORAGE", "OFF", 0);
#endif
Code: Select all
LD_PRELOAD=/home/scrawl/Steam/ubuntu12_64/gameoverlayrenderer.so ./openmw
Would I just need to copy that code and paste it into notepad or notepad++? I'm just a little concerned because whenever I hear of DLL injecting I think of cheating but Morrowind doesn't have VAC protection so I think I should be fine. It also looks like you're running on linux so what changes would I have to make for it to work on windows?scrawl wrote:Just a quick test... it works:
Here's how I did it - I just added code to OpenMW that initializes the steam API. Ideally this code should be in a DLL so that it can be used for any other game not just OpenMW.Then all that's left is to launch OpenMW with the steam overlay loaded:Code: Select all
diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 8e938e0..a1dee30 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -119,6 +119,7 @@ include_directories( ) target_link_libraries(openmw + "dl" ${OSG_LIBRARIES} ${OPENTHREADS_LIBRARIES} ${OSGPARTICLE_LIBRARIES} diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index a4bf1fe..c730168 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -13,6 +13,8 @@ #include <boost/iostreams/stream_buffer.hpp> #include <boost/filesystem/fstream.hpp> +#include <dlfcn.h> + #if defined(_WIN32) // For OutputDebugString #ifndef WIN32_LEAN_AND_MEAN @@ -294,6 +296,17 @@ private: int main(int argc, char**argv) { + setenv("SteamAppId", "22320", 0); + + void* steamapi = dlopen("./libsteam_api64.so", RTLD_LAZY); + if (!steamapi) + throw std::runtime_error("Can't open libsteam_api64.so"); + typedef void funcsig(void); + funcsig* steamapi_init = (funcsig*) dlsym(steamapi, "SteamAPI_Init"); + if (steamapi_init == NULL) + throw std::runtime_error("Can't find SteamAPI_Init"); + steamapi_init(); + #if defined(__APPLE__) setenv("OSG_GL_TEXTURE_STORAGE", "OFF", 0); #endif
Code: Select all
LD_PRELOAD=/home/scrawl/Steam/ubuntu12_64/gameoverlayrenderer.so ./openmw
Maybe that could be a suggestion for future releases of openmw, but of course more things are important. Maybe someone will volunteer to make it as well.scrawl wrote:That is not something you can do as an end user, you'll need to wait for someone (a programmer) to compile a tool that does it for you. This tool will have to be built for the particular operating system that you are using. I do not use windows so I can't do it for you.
There is also the issue of trust, you don't want to be running a random person's DLL file, there could be a virus in it. I could think of a simpler version that works with just a Python script, that would work for tracking playtime but wouldn't work for taking screenshots and having those saved as Morrowind screenshots in Steam.. because the Steam API would be started outside of the OpenMW process, the steam overlay would not be able to know that it is running Morrowind.
You need to install OpenMW to your Morrowind Steam directory, backup or delete the original Morrowind.exe and Morrowind Launcher.exe, then rename openmw.exe and openmw-launcher.exe to Morrowind.exe and Morrowind Launcher.exe. When you go to launch Morrowind through Steam it will run OpenMW and track your hours and you can use the overlay.Ensgnblack wrote: ↑11 Jan 2021, 23:33 Is there any update on the ability to track hours in steam? Thanks so much.