mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 14:11:15 +02:00
- g3d viewer now auto registers g3d files with itself in windows so users may double click a g3d file to launch it within the viewer from explorer. Windows G3d is now a console application so we can see commandline options and console output
This commit is contained in:
@@ -69,7 +69,7 @@
|
|||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
AdditionalLibraryDirectories="../../source/win32_deps/lib;"../../build/$(ConfigurationName)/libglest";../../source/shared_lib/sources/streflop/libstreflop"
|
AdditionalLibraryDirectories="../../source/win32_deps/lib;"../../build/$(ConfigurationName)/libglest";../../source/shared_lib/sources/streflop/libstreflop"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="2"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
@@ -147,7 +147,7 @@
|
|||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories="../../source/win32_deps/lib;"../../build/$(ConfigurationName)/libglest";../../source/shared_lib/sources/streflop/libstreflop"
|
AdditionalLibraryDirectories="../../source/win32_deps/lib;"../../build/$(ConfigurationName)/libglest";../../source/shared_lib/sources/streflop/libstreflop"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="2"
|
SubSystem="1"
|
||||||
OptimizeReferences="0"
|
OptimizeReferences="0"
|
||||||
EnableCOMDATFolding="0"
|
EnableCOMDATFolding="0"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "game_constants.h"
|
#include "game_constants.h"
|
||||||
|
#include <wx/stdpaths.h>
|
||||||
|
//#include <wx/filename.h>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#define stricmp strcasecmp
|
#define stricmp strcasecmp
|
||||||
@@ -108,7 +110,7 @@ bool hasCommandArgument(int argc, wxChar** argv,const string argName,
|
|||||||
if(foundIndex != NULL) {
|
if(foundIndex != NULL) {
|
||||||
*foundIndex = -1;
|
*foundIndex = -1;
|
||||||
}
|
}
|
||||||
int compareLen = strlen(argName.c_str());
|
size_t compareLen = strlen(argName.c_str());
|
||||||
|
|
||||||
for(int idx = startLookupIndex; idx < argc; idx++) {
|
for(int idx = startLookupIndex; idx < argc; idx++) {
|
||||||
const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(argv[idx]);
|
const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(argv[idx]);
|
||||||
@@ -389,6 +391,35 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
|
|||||||
|
|
||||||
timer = new wxTimer(this);
|
timer = new wxTimer(this);
|
||||||
timer->Start(100);
|
timer->Start(100);
|
||||||
|
|
||||||
|
// For windows register g3d file extension to launch this app
|
||||||
|
#ifdef WIN32
|
||||||
|
// example from: http://stackoverflow.com/questions/1387769/create-registry-entry-to-associate-file-extension-with-application-in-c
|
||||||
|
//[HKEY_CURRENT_USER\Software\Classes\blergcorp.blergapp.v1\shell\open\command]
|
||||||
|
//@="c:\path\to\app.exe \"%1\""
|
||||||
|
//[HKEY_CURRENT_USER\Software\Classes\.blerg]
|
||||||
|
//@="blergcorp.blergapp.v1"
|
||||||
|
|
||||||
|
//Open the registry key.
|
||||||
|
string subKey = "Software\\Classes\\megaglest.g3d\\shell\\open\\command";
|
||||||
|
HKEY keyHandle;
|
||||||
|
DWORD dwDisposition;
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
|
||||||
|
//Set the value.
|
||||||
|
string launchApp = appPath + " \"%1\"";
|
||||||
|
DWORD len = launchApp.length() + 1;
|
||||||
|
RegSetValueEx(keyHandle, NULL, 0, REG_SZ, (PBYTE)launchApp.c_str(), len);
|
||||||
|
RegCloseKey(keyHandle);
|
||||||
|
|
||||||
|
subKey = "Software\\Classes\\.g3d";
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
|
||||||
|
//Set the value.
|
||||||
|
launchApp = "megaglest.g3d";
|
||||||
|
len = launchApp.length() + 1;
|
||||||
|
RegSetValueEx(keyHandle, NULL, 0, REG_SZ, (PBYTE)launchApp.c_str(), len);
|
||||||
|
RegCloseKey(keyHandle);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow(){
|
MainWindow::~MainWindow(){
|
||||||
@@ -2024,13 +2055,29 @@ bool App::OnInit(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
string appPath = "";
|
string appPath = "";
|
||||||
|
|
||||||
|
//#if defined(__MINGW32__)
|
||||||
|
// const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(argv[0]));
|
||||||
|
// appPath = tmp_buf;
|
||||||
|
//#else
|
||||||
|
// appPath = wxFNCONV(argv[0]);
|
||||||
|
//#endif
|
||||||
|
// printf("appPath [%s]\n",argv[0]);
|
||||||
|
|
||||||
|
wxString exe_path = wxStandardPaths::Get().GetExecutablePath();
|
||||||
|
//wxString path_separator = wxFileName::GetPathSeparator();
|
||||||
|
//exe_path = exe_path.BeforeLast(path_separator[0]);
|
||||||
|
//exe_path += path_separator;
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(argv[0]));
|
const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(exe_path));
|
||||||
appPath = tmp_buf;
|
appPath = tmp_buf;
|
||||||
#else
|
#else
|
||||||
appPath = wxFNCONV(argv[0]);
|
appPath = wxFNCONV(exe_path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// printf("#2 appPath [%s]\n",appPath.c_str());
|
||||||
|
|
||||||
mainWindow= new MainWindow( unitToLoad,
|
mainWindow= new MainWindow( unitToLoad,
|
||||||
modelPath,
|
modelPath,
|
||||||
particlePath,
|
particlePath,
|
||||||
@@ -2068,4 +2115,4 @@ int App::OnExit(){
|
|||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
||||||
IMPLEMENT_APP(Shared::G3dViewer::App)
|
IMPLEMENT_APP_CONSOLE(Shared::G3dViewer::App)
|
||||||
|
Reference in New Issue
Block a user