file path in g3dviewers file dialog is kept for next file access

This commit is contained in:
Titus Tscharntke
2011-01-18 21:17:48 +00:00
parent c54e6dbf5d
commit 1ef0df2bf6
2 changed files with 26 additions and 24 deletions

View File

@@ -73,7 +73,6 @@ MainWindow::MainWindow(const string &modelPath)
//glCanvas->SetCurrent(); //glCanvas->SetCurrent();
//renderer->init(); //renderer->init();
menu= new wxMenuBar(); menu= new wxMenuBar();
//menu //menu
@@ -156,6 +155,11 @@ MainWindow::MainWindow(const string &modelPath)
timer->Start(100); timer->Start(100);
glCanvas->SetFocus(); glCanvas->SetFocus();
fileDialog = new wxFileDialog(this);
if(modelPath != "") {
fileDialog->SetPath(ToUnicode(modelPath));
}
} }
MainWindow::~MainWindow(){ MainWindow::~MainWindow(){
@@ -255,32 +259,31 @@ void MainWindow::onMouseMove(wxMouseEvent &event){
void MainWindow::onMenuFileLoad(wxCommandEvent &event){ void MainWindow::onMenuFileLoad(wxCommandEvent &event){
string fileName; string fileName;
wxFileDialog fileDialog(this);
fileDialog.SetWildcard(wxT("G3D files (*.g3d)|*.g3d"));
fileDialog.SetMessage(wxT("Selecting Glest Model for current view.")); fileDialog->SetWildcard(wxT("G3D files (*.g3d)|*.g3d"));
if(fileDialog.ShowModal()==wxID_OK){ fileDialog->SetMessage(wxT("Selecting Glest Model for current view."));
if(fileDialog->ShowModal()==wxID_OK){
modelPathList.clear(); modelPathList.clear();
loadModel((const char*)wxFNCONV(fileDialog.GetPath().c_str())); loadModel((const char*)wxFNCONV(fileDialog->GetPath().c_str()));
} }
isControlKeyPressed = false; isControlKeyPressed = false;
} }
void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){ void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){
string fileName; string fileName;
wxFileDialog fileDialog(this); fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
fileDialog.SetWildcard(wxT("XML files (*.xml)|*.xml"));
if(isControlKeyPressed == true) { if(isControlKeyPressed == true) {
fileDialog.SetMessage(wxT("Adding Mega-Glest particle to current view.")); fileDialog->SetMessage(wxT("Adding Mega-Glest particle to current view."));
} }
else { else {
fileDialog.SetMessage(wxT("Selecting Mega-Glest particle for current view.")); fileDialog->SetMessage(wxT("Selecting Mega-Glest particle for current view."));
} }
if(fileDialog.ShowModal()==wxID_OK){ if(fileDialog->ShowModal()==wxID_OK){
string path = (const char*)wxFNCONV(fileDialog.GetPath().c_str()); string path = (const char*)wxFNCONV(fileDialog->GetPath().c_str());
loadParticle(path); loadParticle(path);
} }
isControlKeyPressed = false; isControlKeyPressed = false;
@@ -288,18 +291,17 @@ void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){
void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){ void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){
string fileName; string fileName;
wxFileDialog fileDialog(this); fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
fileDialog.SetWildcard(wxT("XML files (*.xml)|*.xml"));
if(isControlKeyPressed == true) { if(isControlKeyPressed == true) {
fileDialog.SetMessage(wxT("Adding Mega-Glest projectile particle to current view.")); fileDialog->SetMessage(wxT("Adding Mega-Glest projectile particle to current view."));
} }
else { else {
fileDialog.SetMessage(wxT("Selecting Mega-Glest projectile particle for current view.")); fileDialog->SetMessage(wxT("Selecting Mega-Glest projectile particle for current view."));
} }
if(fileDialog.ShowModal()==wxID_OK){ if(fileDialog->ShowModal()==wxID_OK){
string path = (const char*)wxFNCONV(fileDialog.GetPath().c_str()); string path = (const char*)wxFNCONV(fileDialog->GetPath().c_str());
loadProjectileParticle(path); loadProjectileParticle(path);
} }
isControlKeyPressed = false; isControlKeyPressed = false;
@@ -307,18 +309,17 @@ void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){
void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){ void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){
string fileName; string fileName;
wxFileDialog fileDialog(this); fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
fileDialog.SetWildcard(wxT("XML files (*.xml)|*.xml"));
if(isControlKeyPressed == true) { if(isControlKeyPressed == true) {
fileDialog.SetMessage(wxT("Adding Mega-Glest splash particle to current view.")); fileDialog->SetMessage(wxT("Adding Mega-Glest splash particle to current view."));
} }
else { else {
fileDialog.SetMessage(wxT("Selecting Mega-Glest splash particle for current view.")); fileDialog->SetMessage(wxT("Selecting Mega-Glest splash particle for current view."));
} }
if(fileDialog.ShowModal()==wxID_OK){ if(fileDialog->ShowModal()==wxID_OK){
string path = (const char*)wxFNCONV(fileDialog.GetPath().c_str()); string path = (const char*)wxFNCONV(fileDialog->GetPath().c_str());
loadSplashParticle(path); loadSplashParticle(path);
} }
isControlKeyPressed = false; isControlKeyPressed = false;

View File

@@ -63,6 +63,7 @@ private:
wxMenu *menuMode; wxMenu *menuMode;
wxMenu *menuSpeed; wxMenu *menuSpeed;
wxMenu *menuCustomColor; wxMenu *menuCustomColor;
wxFileDialog *fileDialog;
Model *model; Model *model;