mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 06:01:17 +02:00
- updated g3dviewer and map editor to default to the userdata folder areas
This commit is contained in:
@@ -305,8 +305,6 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
|
|||||||
menuMode->Check(miModeGrid, true);
|
menuMode->Check(miModeGrid, true);
|
||||||
menuCustomColor->Check(miColorRed, true);
|
menuCustomColor->Check(miColorRed, true);
|
||||||
|
|
||||||
//!!!
|
|
||||||
|
|
||||||
SetMenuBar(menu);
|
SetMenuBar(menu);
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
@@ -344,6 +342,13 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
|
|||||||
if(modelPath != "") {
|
if(modelPath != "") {
|
||||||
fileDialog->SetPath(ToUnicode(modelPath));
|
fileDialog->SetPath(ToUnicode(modelPath));
|
||||||
}
|
}
|
||||||
|
string userData = Config::getInstance().getString("UserData_Root","");
|
||||||
|
if(userData != "") {
|
||||||
|
endPathWithSlash(userData);
|
||||||
|
}
|
||||||
|
string defaultPath = userData + "techs/";
|
||||||
|
fileDialog->SetDirectory(wxString(defaultPath.c_str()));
|
||||||
|
|
||||||
|
|
||||||
glCanvas->SetFocus();
|
glCanvas->SetFocus();
|
||||||
|
|
||||||
|
@@ -60,18 +60,25 @@ ENDIF()
|
|||||||
SET(DIRS_WITH_SRC
|
SET(DIRS_WITH_SRC
|
||||||
. )
|
. )
|
||||||
|
|
||||||
|
SET(GLEST_MAIN_INCLUDE_ROOT "../glest_game/")
|
||||||
SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/")
|
SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/")
|
||||||
|
|
||||||
SET(GLEST_LIB_INCLUDE_DIRS
|
SET(GLEST_LIB_INCLUDE_DIRS
|
||||||
${GLEST_LIB_INCLUDE_ROOT}platform/common
|
${GLEST_LIB_INCLUDE_ROOT}platform/common
|
||||||
${GLEST_LIB_INCLUDE_ROOT}platform/sdl
|
${GLEST_LIB_INCLUDE_ROOT}platform/sdl
|
||||||
${GLEST_LIB_INCLUDE_ROOT}platform/posix
|
${GLEST_LIB_INCLUDE_ROOT}platform/posix
|
||||||
${GLEST_LIB_INCLUDE_ROOT}util
|
${GLEST_LIB_INCLUDE_ROOT}util
|
||||||
${GLEST_LIB_INCLUDE_ROOT}graphics
|
${GLEST_LIB_INCLUDE_ROOT}graphics
|
||||||
${GLEST_LIB_INCLUDE_ROOT}graphics/gl
|
${GLEST_LIB_INCLUDE_ROOT}graphics/gl
|
||||||
${GLEST_LIB_INCLUDE_ROOT}map)
|
${GLEST_LIB_INCLUDE_ROOT}map
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}streflop
|
||||||
|
${GLEST_MAIN_INCLUDE_ROOT}facilities
|
||||||
|
${GLEST_MAIN_INCLUDE_ROOT}game
|
||||||
|
${GLEST_MAIN_INCLUDE_ROOT}global)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )
|
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )
|
||||||
|
|
||||||
SET(MG_SOURCE_FILES "")
|
SET(MG_SOURCE_FILES "../glest_game/global/config.cpp")
|
||||||
|
|
||||||
FOREACH(DIR IN LISTS DIRS_WITH_SRC)
|
FOREACH(DIR IN LISTS DIRS_WITH_SRC)
|
||||||
INCLUDE_DIRECTORIES( ${DIR} )
|
INCLUDE_DIRECTORIES( ${DIR} )
|
||||||
|
@@ -14,17 +14,34 @@
|
|||||||
#include "conversion.h"
|
#include "conversion.h"
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "platform_common.h"
|
#include "platform_common.h"
|
||||||
|
#include "config.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <wx/stdpaths.h>
|
||||||
|
|
||||||
using namespace Shared::Util;
|
using namespace Shared::Util;
|
||||||
using namespace Shared::PlatformCommon;
|
using namespace Shared::PlatformCommon;
|
||||||
|
using namespace Glest::Game;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace Glest { namespace Game {
|
||||||
|
string getGameReadWritePath(string lookupKey) {
|
||||||
|
string path = "";
|
||||||
|
if(path == "" && getenv("GLESTHOME") != NULL) {
|
||||||
|
path = getenv("GLESTHOME");
|
||||||
|
if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
|
||||||
|
path += "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path to be used for read/write files [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
namespace MapEditor {
|
namespace MapEditor {
|
||||||
|
|
||||||
|
const string mapeditorVersionString = "v1.6.0";
|
||||||
|
|
||||||
const string mapeditorVersionString = "v1.5.1";
|
|
||||||
const string MainWindow::winHeader = "MegaGlest Map Editor " + mapeditorVersionString;
|
const string MainWindow::winHeader = "MegaGlest Map Editor " + mapeditorVersionString;
|
||||||
|
|
||||||
// ===============================================
|
// ===============================================
|
||||||
@@ -43,7 +60,7 @@ wxString ToUnicode(const string& str) {
|
|||||||
// class MainWindow
|
// class MainWindow
|
||||||
// ===============================================
|
// ===============================================
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow(string appPath)
|
||||||
: wxFrame(NULL, -1, ToUnicode(winHeader), wxPoint(0,0), wxSize(1024, 768))
|
: wxFrame(NULL, -1, ToUnicode(winHeader), wxPoint(0,0), wxSize(1024, 768))
|
||||||
, lastX(0), lastY(0)
|
, lastX(0), lastY(0)
|
||||||
, currentBrush(btHeight)
|
, currentBrush(btHeight)
|
||||||
@@ -60,6 +77,9 @@ MainWindow::MainWindow()
|
|||||||
, glCanvas(NULL)
|
, glCanvas(NULL)
|
||||||
, program(NULL), boxsizer(NULL), startupSettingsInited(false) {
|
, program(NULL), boxsizer(NULL), startupSettingsInited(false) {
|
||||||
|
|
||||||
|
this->appPath = appPath;
|
||||||
|
Properties::setApplicationPath(extractDirectoryPathFromFile(appPath));
|
||||||
|
|
||||||
this->panel = new wxPanel(this, wxID_ANY);
|
this->panel = new wxPanel(this, wxID_ANY);
|
||||||
|
|
||||||
//gl canvas
|
//gl canvas
|
||||||
@@ -340,6 +360,16 @@ void MainWindow::init(string fname) {
|
|||||||
//std::cout << "C" << std::endl;
|
//std::cout << "C" << std::endl;
|
||||||
SetIcon(icon);
|
SetIcon(icon);
|
||||||
fileDialog = new wxFileDialog(this);
|
fileDialog = new wxFileDialog(this);
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
string userData = config.getString("UserData_Root","");
|
||||||
|
if(userData != "") {
|
||||||
|
endPathWithSlash(userData);
|
||||||
|
}
|
||||||
|
string defaultPath = userData + "maps/";
|
||||||
|
fileDialog->SetDirectory(wxString(defaultPath.c_str()));
|
||||||
|
|
||||||
|
//printf("Default Path [%s]\n",defaultPath.c_str());
|
||||||
|
|
||||||
lastPaintEvent.start();
|
lastPaintEvent.start();
|
||||||
|
|
||||||
boxsizer = new wxBoxSizer(wxVERTICAL);
|
boxsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
@@ -580,7 +610,19 @@ void MainWindow::onMenuFileSaveAs(wxCommandEvent &event) {
|
|||||||
wxFileDialog fd(this, wxT("Select file"), wxT(""), wxT(""), wxT("*.gbm|*.mgm"), wxSAVE);
|
wxFileDialog fd(this, wxT("Select file"), wxT(""), wxT(""), wxT("*.gbm|*.mgm"), wxSAVE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fd.SetPath(fileDialog->GetPath());
|
if(fileDialog->GetPath() != "") {
|
||||||
|
fd.SetPath(fileDialog->GetPath());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
string userData = config.getString("UserData_Root","");
|
||||||
|
if(userData != "") {
|
||||||
|
endPathWithSlash(userData);
|
||||||
|
}
|
||||||
|
string defaultPath = userData + "maps/";
|
||||||
|
fd.SetDirectory(wxString(defaultPath.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
fd.SetWildcard(wxT("Glest Map (*.gbm)|*.gbm|MegaGlest Map (*.mgm)|*.mgm"));
|
fd.SetWildcard(wxT("Glest Map (*.gbm)|*.gbm|MegaGlest Map (*.mgm)|*.mgm"));
|
||||||
if (fd.ShowModal() == wxID_OK) {
|
if (fd.ShowModal() == wxID_OK) {
|
||||||
currentFile = fd.GetPath().ToAscii();
|
currentFile = fd.GetPath().ToAscii();
|
||||||
@@ -1368,7 +1410,20 @@ bool App::OnInit() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow = new MainWindow();
|
wxString exe_path = wxStandardPaths::Get().GetExecutablePath();
|
||||||
|
//wxString path_separator = wxFileName::GetPathSeparator();
|
||||||
|
//exe_path = exe_path.BeforeLast(path_separator[0]);
|
||||||
|
//exe_path += path_separator;
|
||||||
|
|
||||||
|
string appPath = "";
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(exe_path));
|
||||||
|
appPath = tmp_buf;
|
||||||
|
#else
|
||||||
|
appPath = wxFNCONV(exe_path);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mainWindow = new MainWindow(appPath);
|
||||||
mainWindow->Show();
|
mainWindow->Show();
|
||||||
mainWindow->init(fileparam);
|
mainWindow->init(fileparam);
|
||||||
mainWindow->Update();
|
mainWindow->Update();
|
||||||
|
@@ -184,9 +184,10 @@ private:
|
|||||||
wxBoxSizer *boxsizer;
|
wxBoxSizer *boxsizer;
|
||||||
|
|
||||||
bool startupSettingsInited;
|
bool startupSettingsInited;
|
||||||
|
string appPath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow(string appPath);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
void init(string fname);
|
void init(string fname);
|
||||||
|
Reference in New Issue
Block a user