- updated g3dviewer and map editor to default to the userdata folder areas

This commit is contained in:
Mark Vejvoda 2011-04-05 04:49:48 +00:00
parent 5cd4824c94
commit f684e7f356
4 changed files with 84 additions and 16 deletions

View File

@ -305,8 +305,6 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
menuMode->Check(miModeGrid, true);
menuCustomColor->Check(miColorRed, true);
//!!!
SetMenuBar(menu);
//misc
@ -344,6 +342,13 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
if(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();

View File

@ -60,7 +60,9 @@ ENDIF()
SET(DIRS_WITH_SRC
. )
SET(GLEST_MAIN_INCLUDE_ROOT "../glest_game/")
SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/")
SET(GLEST_LIB_INCLUDE_DIRS
${GLEST_LIB_INCLUDE_ROOT}platform/common
${GLEST_LIB_INCLUDE_ROOT}platform/sdl
@ -68,10 +70,15 @@ SET(GLEST_LIB_INCLUDE_DIRS
${GLEST_LIB_INCLUDE_ROOT}util
${GLEST_LIB_INCLUDE_ROOT}graphics
${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} )
SET(MG_SOURCE_FILES "")
SET(MG_SOURCE_FILES "../glest_game/global/config.cpp")
FOREACH(DIR IN LISTS DIRS_WITH_SRC)
INCLUDE_DIRECTORIES( ${DIR} )

View File

@ -14,17 +14,34 @@
#include "conversion.h"
#include "icons.h"
#include "platform_common.h"
#include "config.h"
#include <iostream>
#include <wx/stdpaths.h>
using namespace Shared::Util;
using namespace Shared::PlatformCommon;
using namespace Glest::Game;
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 {
const string mapeditorVersionString = "v1.5.1";
const string mapeditorVersionString = "v1.6.0";
const string MainWindow::winHeader = "MegaGlest Map Editor " + mapeditorVersionString;
// ===============================================
@ -43,7 +60,7 @@ wxString ToUnicode(const string& str) {
// class MainWindow
// ===============================================
MainWindow::MainWindow()
MainWindow::MainWindow(string appPath)
: wxFrame(NULL, -1, ToUnicode(winHeader), wxPoint(0,0), wxSize(1024, 768))
, lastX(0), lastY(0)
, currentBrush(btHeight)
@ -60,6 +77,9 @@ MainWindow::MainWindow()
, glCanvas(NULL)
, program(NULL), boxsizer(NULL), startupSettingsInited(false) {
this->appPath = appPath;
Properties::setApplicationPath(extractDirectoryPathFromFile(appPath));
this->panel = new wxPanel(this, wxID_ANY);
//gl canvas
@ -340,6 +360,16 @@ void MainWindow::init(string fname) {
//std::cout << "C" << std::endl;
SetIcon(icon);
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();
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);
#endif
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"));
if (fd.ShowModal() == wxID_OK) {
currentFile = fd.GetPath().ToAscii();
@ -1368,7 +1410,20 @@ bool App::OnInit() {
#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->init(fileparam);
mainWindow->Update();

View File

@ -184,9 +184,10 @@ private:
wxBoxSizer *boxsizer;
bool startupSettingsInited;
string appPath;
public:
MainWindow();
MainWindow(string appPath);
~MainWindow();
void init(string fname);