mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 23:45:14 +02:00
- some basic error catching to avoid application crash when errors occur
This commit is contained in:
@@ -225,21 +225,34 @@ void MainWindow::onClose(wxCloseEvent &event){
|
|||||||
|
|
||||||
// for the mousewheel
|
// for the mousewheel
|
||||||
void MainWindow::onMouseWheelDown(wxMouseEvent &event) {
|
void MainWindow::onMouseWheelDown(wxMouseEvent &event) {
|
||||||
|
try {
|
||||||
wxPaintEvent paintEvent;
|
wxPaintEvent paintEvent;
|
||||||
zoom*= 1.1f;
|
zoom*= 1.1f;
|
||||||
zoom= clamp(zoom, 0.1f, 10.0f);
|
zoom= clamp(zoom, 0.1f, 10.0f);
|
||||||
onPaint(paintEvent);
|
onPaint(paintEvent);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMouseWheelUp(wxMouseEvent &event) {
|
void MainWindow::onMouseWheelUp(wxMouseEvent &event) {
|
||||||
|
try {
|
||||||
wxPaintEvent paintEvent;
|
wxPaintEvent paintEvent;
|
||||||
zoom*= 0.90909f;
|
zoom*= 0.90909f;
|
||||||
zoom= clamp(zoom, 0.1f, 10.0f);
|
zoom= clamp(zoom, 0.1f, 10.0f);
|
||||||
onPaint(paintEvent);
|
onPaint(paintEvent);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::onMouseMove(wxMouseEvent &event){
|
void MainWindow::onMouseMove(wxMouseEvent &event){
|
||||||
|
try {
|
||||||
int x= event.GetX();
|
int x= event.GetX();
|
||||||
int y= event.GetY();
|
int y= event.GetY();
|
||||||
wxPaintEvent paintEvent;
|
wxPaintEvent paintEvent;
|
||||||
@@ -257,9 +270,15 @@ void MainWindow::onMouseMove(wxMouseEvent &event){
|
|||||||
|
|
||||||
lastX= x;
|
lastX= x;
|
||||||
lastY= y;
|
lastY= y;
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnChangeColor(wxCommandEvent &event) {
|
void MainWindow::OnChangeColor(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
//wxColour color = colorPicker->GetColour();
|
//wxColour color = colorPicker->GetColour();
|
||||||
wxColourData data;
|
wxColourData data;
|
||||||
data.SetChooseFull(true);
|
data.SetChooseFull(true);
|
||||||
@@ -281,13 +300,17 @@ void MainWindow::OnChangeColor(wxCommandEvent &event) {
|
|||||||
//myWindow->Clear();
|
//myWindow->Clear();
|
||||||
//myWindow->Refresh();
|
//myWindow->Refresh();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuFileLoad(wxCommandEvent &event){
|
void MainWindow::onMenuFileLoad(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
string fileName;
|
string fileName;
|
||||||
|
|
||||||
fileDialog->SetWildcard(wxT("G3D files (*.g3d)|*.g3d"));
|
fileDialog->SetWildcard(wxT("G3D files (*.g3d)|*.g3d"));
|
||||||
|
|
||||||
fileDialog->SetMessage(wxT("Selecting Glest Model for current view."));
|
fileDialog->SetMessage(wxT("Selecting Glest Model for current view."));
|
||||||
|
|
||||||
if(fileDialog->ShowModal()==wxID_OK){
|
if(fileDialog->ShowModal()==wxID_OK){
|
||||||
@@ -295,9 +318,15 @@ void MainWindow::onMenuFileLoad(wxCommandEvent &event){
|
|||||||
loadModel((const char*)wxFNCONV(fileDialog->GetPath().c_str()));
|
loadModel((const char*)wxFNCONV(fileDialog->GetPath().c_str()));
|
||||||
}
|
}
|
||||||
isControlKeyPressed = false;
|
isControlKeyPressed = false;
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){
|
void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
string fileName;
|
string fileName;
|
||||||
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
|
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
|
||||||
|
|
||||||
@@ -313,9 +342,15 @@ void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){
|
|||||||
loadParticle(path);
|
loadParticle(path);
|
||||||
}
|
}
|
||||||
isControlKeyPressed = false;
|
isControlKeyPressed = false;
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){
|
void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
string fileName;
|
string fileName;
|
||||||
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
|
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
|
||||||
|
|
||||||
@@ -331,9 +366,15 @@ void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){
|
|||||||
loadProjectileParticle(path);
|
loadProjectileParticle(path);
|
||||||
}
|
}
|
||||||
isControlKeyPressed = false;
|
isControlKeyPressed = false;
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){
|
void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
string fileName;
|
string fileName;
|
||||||
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
|
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
|
||||||
|
|
||||||
@@ -349,10 +390,16 @@ void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){
|
|||||||
loadSplashParticle(path);
|
loadSplashParticle(path);
|
||||||
}
|
}
|
||||||
isControlKeyPressed = false;
|
isControlKeyPressed = false;
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
} // is it possible to join loadParticle(), loadProjectileParticle() and loadSplashParticle() to one method?
|
} // is it possible to join loadParticle(), loadProjectileParticle() and loadSplashParticle() to one method?
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::onMenuFileSaveScreenshot(wxCommandEvent &event) {
|
void MainWindow::onMenuFileSaveScreenshot(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
string path = "screens/";
|
string path = "screens/";
|
||||||
if(isdir(path.c_str()) == true) {
|
if(isdir(path.c_str()) == true) {
|
||||||
//Config &config= Config::getInstance();
|
//Config &config= Config::getInstance();
|
||||||
@@ -372,9 +419,15 @@ void MainWindow::onMenuFileSaveScreenshot(wxCommandEvent &event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuFileClearAll(wxCommandEvent &event) {
|
void MainWindow::onMenuFileClearAll(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
modelPathList.clear();
|
modelPathList.clear();
|
||||||
particlePathList.clear();
|
particlePathList.clear();
|
||||||
particleProjectilePathList.clear();
|
particleProjectilePathList.clear();
|
||||||
@@ -402,6 +455,11 @@ void MainWindow::onMenuFileClearAll(wxCommandEvent &event) {
|
|||||||
GetStatusBar()->SetStatusText(ToUnicode(statusbarText.c_str()));
|
GetStatusBar()->SetStatusText(ToUnicode(statusbarText.c_str()));
|
||||||
timer->Start(100);
|
timer->Start(100);
|
||||||
isControlKeyPressed = false;
|
isControlKeyPressed = false;
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuFileExit(wxCommandEvent &event) {
|
void MainWindow::onMenuFileExit(wxCommandEvent &event) {
|
||||||
@@ -513,7 +571,7 @@ void MainWindow::loadParticle(string path) {
|
|||||||
}
|
}
|
||||||
catch(std::runtime_error e) {
|
catch(std::runtime_error e) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
wxMessageBox( ToUnicode(e.what()), wxT("Not a Mega-Glest particle XML file, or broken"), wxICON_ERROR);
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
timer->Start(100);
|
timer->Start(100);
|
||||||
}
|
}
|
||||||
@@ -619,7 +677,7 @@ void MainWindow::loadProjectileParticle(string path) {
|
|||||||
}
|
}
|
||||||
catch(std::runtime_error e) {
|
catch(std::runtime_error e) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
wxMessageBox( ToUnicode(e.what()), wxT("Not a Mega-Glest projectile particle XML file, or broken"), wxICON_ERROR);
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
timer->Start(100);
|
timer->Start(100);
|
||||||
}
|
}
|
||||||
@@ -718,27 +776,46 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
|
|||||||
}
|
}
|
||||||
catch(std::runtime_error e) {
|
catch(std::runtime_error e) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
wxMessageBox( ToUnicode(e.what()), wxT("Not a Mega-Glest splash particle XML file, or broken"), wxICON_ERROR);
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
timer->Start(100);
|
timer->Start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuModeNormals(wxCommandEvent &event){
|
void MainWindow::onMenuModeNormals(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
renderer->toggleNormals();
|
renderer->toggleNormals();
|
||||||
menuMode->Check(miModeNormals, renderer->getNormals());
|
menuMode->Check(miModeNormals, renderer->getNormals());
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuModeWireframe(wxCommandEvent &event){
|
void MainWindow::onMenuModeWireframe(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
renderer->toggleWireframe();
|
renderer->toggleWireframe();
|
||||||
menuMode->Check(miModeWireframe, renderer->getWireframe());
|
menuMode->Check(miModeWireframe, renderer->getWireframe());
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuModeGrid(wxCommandEvent &event){
|
void MainWindow::onMenuModeGrid(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
renderer->toggleGrid();
|
renderer->toggleGrid();
|
||||||
menuMode->Check(miModeGrid, renderer->getGrid());
|
menuMode->Check(miModeGrid, renderer->getGrid());
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuSpeedSlower(wxCommandEvent &event){
|
void MainWindow::onMenuSpeedSlower(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
speed /= 1.5f;
|
speed /= 1.5f;
|
||||||
if(speed < 0) {
|
if(speed < 0) {
|
||||||
speed = 0;
|
speed = 0;
|
||||||
@@ -746,9 +823,15 @@ void MainWindow::onMenuSpeedSlower(wxCommandEvent &event){
|
|||||||
|
|
||||||
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0);
|
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0);
|
||||||
GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str()));
|
GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str()));
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuSpeedFaster(wxCommandEvent &event){
|
void MainWindow::onMenuSpeedFaster(wxCommandEvent &event){
|
||||||
|
try {
|
||||||
speed *= 1.5f;
|
speed *= 1.5f;
|
||||||
if(speed > 1) {
|
if(speed > 1) {
|
||||||
speed = 1;
|
speed = 1;
|
||||||
@@ -756,10 +839,16 @@ void MainWindow::onMenuSpeedFaster(wxCommandEvent &event){
|
|||||||
|
|
||||||
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0 );
|
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0 );
|
||||||
GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str()));
|
GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str()));
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set menu checkboxes to what player color is used
|
// set menu checkboxes to what player color is used
|
||||||
void MainWindow::onMenuColorRed(wxCommandEvent &event){
|
void MainWindow::onMenuColorRed(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
playerColor= Renderer::pcRed;
|
playerColor= Renderer::pcRed;
|
||||||
menuCustomColor->Check(miColorRed, true);
|
menuCustomColor->Check(miColorRed, true);
|
||||||
menuCustomColor->Check(miColorBlue, false);
|
menuCustomColor->Check(miColorBlue, false);
|
||||||
@@ -769,9 +858,15 @@ void MainWindow::onMenuColorRed(wxCommandEvent &event){
|
|||||||
menuCustomColor->Check(miColorCyan, false);
|
menuCustomColor->Check(miColorCyan, false);
|
||||||
menuCustomColor->Check(miColorOrange, false);
|
menuCustomColor->Check(miColorOrange, false);
|
||||||
menuCustomColor->Check(miColorMagenta, false);
|
menuCustomColor->Check(miColorMagenta, false);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuColorBlue(wxCommandEvent &event){
|
void MainWindow::onMenuColorBlue(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
playerColor= Renderer::pcBlue;
|
playerColor= Renderer::pcBlue;
|
||||||
menuCustomColor->Check(miColorRed, false);
|
menuCustomColor->Check(miColorRed, false);
|
||||||
menuCustomColor->Check(miColorBlue, true);
|
menuCustomColor->Check(miColorBlue, true);
|
||||||
@@ -781,9 +876,15 @@ void MainWindow::onMenuColorBlue(wxCommandEvent &event){
|
|||||||
menuCustomColor->Check(miColorCyan, false);
|
menuCustomColor->Check(miColorCyan, false);
|
||||||
menuCustomColor->Check(miColorOrange, false);
|
menuCustomColor->Check(miColorOrange, false);
|
||||||
menuCustomColor->Check(miColorMagenta, false);
|
menuCustomColor->Check(miColorMagenta, false);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuColorGreen(wxCommandEvent &event){
|
void MainWindow::onMenuColorGreen(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
playerColor= Renderer::pcGreen;
|
playerColor= Renderer::pcGreen;
|
||||||
menuCustomColor->Check(miColorRed, false);
|
menuCustomColor->Check(miColorRed, false);
|
||||||
menuCustomColor->Check(miColorBlue, false);
|
menuCustomColor->Check(miColorBlue, false);
|
||||||
@@ -793,9 +894,15 @@ void MainWindow::onMenuColorGreen(wxCommandEvent &event){
|
|||||||
menuCustomColor->Check(miColorCyan, false);
|
menuCustomColor->Check(miColorCyan, false);
|
||||||
menuCustomColor->Check(miColorOrange, false);
|
menuCustomColor->Check(miColorOrange, false);
|
||||||
menuCustomColor->Check(miColorMagenta, false);
|
menuCustomColor->Check(miColorMagenta, false);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuColorYellow(wxCommandEvent &event){
|
void MainWindow::onMenuColorYellow(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
playerColor= Renderer::pcYellow;
|
playerColor= Renderer::pcYellow;
|
||||||
menuCustomColor->Check(miColorRed, false);
|
menuCustomColor->Check(miColorRed, false);
|
||||||
menuCustomColor->Check(miColorBlue, false);
|
menuCustomColor->Check(miColorBlue, false);
|
||||||
@@ -805,9 +912,15 @@ void MainWindow::onMenuColorYellow(wxCommandEvent &event){
|
|||||||
menuCustomColor->Check(miColorCyan, false);
|
menuCustomColor->Check(miColorCyan, false);
|
||||||
menuCustomColor->Check(miColorOrange, false);
|
menuCustomColor->Check(miColorOrange, false);
|
||||||
menuCustomColor->Check(miColorMagenta, false);
|
menuCustomColor->Check(miColorMagenta, false);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuColorWhite(wxCommandEvent &event){
|
void MainWindow::onMenuColorWhite(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
playerColor= Renderer::pcWhite;
|
playerColor= Renderer::pcWhite;
|
||||||
menuCustomColor->Check(miColorRed, false);
|
menuCustomColor->Check(miColorRed, false);
|
||||||
menuCustomColor->Check(miColorBlue, false);
|
menuCustomColor->Check(miColorBlue, false);
|
||||||
@@ -817,9 +930,15 @@ void MainWindow::onMenuColorWhite(wxCommandEvent &event){
|
|||||||
menuCustomColor->Check(miColorCyan, false);
|
menuCustomColor->Check(miColorCyan, false);
|
||||||
menuCustomColor->Check(miColorOrange, false);
|
menuCustomColor->Check(miColorOrange, false);
|
||||||
menuCustomColor->Check(miColorMagenta, false);
|
menuCustomColor->Check(miColorMagenta, false);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuColorCyan(wxCommandEvent &event){
|
void MainWindow::onMenuColorCyan(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
playerColor= Renderer::pcCyan;
|
playerColor= Renderer::pcCyan;
|
||||||
menuCustomColor->Check(miColorRed, false);
|
menuCustomColor->Check(miColorRed, false);
|
||||||
menuCustomColor->Check(miColorBlue, false);
|
menuCustomColor->Check(miColorBlue, false);
|
||||||
@@ -829,9 +948,15 @@ void MainWindow::onMenuColorCyan(wxCommandEvent &event){
|
|||||||
menuCustomColor->Check(miColorCyan, true);
|
menuCustomColor->Check(miColorCyan, true);
|
||||||
menuCustomColor->Check(miColorOrange, false);
|
menuCustomColor->Check(miColorOrange, false);
|
||||||
menuCustomColor->Check(miColorMagenta, false);
|
menuCustomColor->Check(miColorMagenta, false);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuColorOrange(wxCommandEvent &event){
|
void MainWindow::onMenuColorOrange(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
playerColor= Renderer::pcOrange;
|
playerColor= Renderer::pcOrange;
|
||||||
menuCustomColor->Check(miColorRed, false);
|
menuCustomColor->Check(miColorRed, false);
|
||||||
menuCustomColor->Check(miColorBlue, false);
|
menuCustomColor->Check(miColorBlue, false);
|
||||||
@@ -841,9 +966,15 @@ void MainWindow::onMenuColorOrange(wxCommandEvent &event){
|
|||||||
menuCustomColor->Check(miColorCyan, false);
|
menuCustomColor->Check(miColorCyan, false);
|
||||||
menuCustomColor->Check(miColorOrange, true);
|
menuCustomColor->Check(miColorOrange, true);
|
||||||
menuCustomColor->Check(miColorMagenta, false);
|
menuCustomColor->Check(miColorMagenta, false);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuColorMagenta(wxCommandEvent &event){
|
void MainWindow::onMenuColorMagenta(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
playerColor= Renderer::pcMagenta;
|
playerColor= Renderer::pcMagenta;
|
||||||
menuCustomColor->Check(miColorRed, false);
|
menuCustomColor->Check(miColorRed, false);
|
||||||
menuCustomColor->Check(miColorBlue, false);
|
menuCustomColor->Check(miColorBlue, false);
|
||||||
@@ -853,10 +984,15 @@ void MainWindow::onMenuColorMagenta(wxCommandEvent &event){
|
|||||||
menuCustomColor->Check(miColorCyan, false);
|
menuCustomColor->Check(miColorCyan, false);
|
||||||
menuCustomColor->Check(miColorOrange, false);
|
menuCustomColor->Check(miColorOrange, false);
|
||||||
menuCustomColor->Check(miColorMagenta, true);
|
menuCustomColor->Check(miColorMagenta, true);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::onTimer(wxTimerEvent &event){
|
void MainWindow::onTimer(wxTimerEvent &event) {
|
||||||
wxPaintEvent paintEvent;
|
wxPaintEvent paintEvent;
|
||||||
|
|
||||||
anim = anim + speed;
|
anim = anim + speed;
|
||||||
@@ -866,7 +1002,7 @@ void MainWindow::onTimer(wxTimerEvent &event){
|
|||||||
onPaint(paintEvent);
|
onPaint(paintEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
string MainWindow::getModelInfo(){
|
string MainWindow::getModelInfo() {
|
||||||
string str;
|
string str;
|
||||||
|
|
||||||
if(model!=NULL){
|
if(model!=NULL){
|
||||||
@@ -881,6 +1017,7 @@ string MainWindow::getModelInfo(){
|
|||||||
|
|
||||||
void MainWindow::onKeyDown(wxKeyEvent &e) {
|
void MainWindow::onKeyDown(wxKeyEvent &e) {
|
||||||
|
|
||||||
|
try {
|
||||||
// std::cout << "e.ControlDown() = " << e.ControlDown() << " e.GetKeyCode() = " << e.GetKeyCode() << " isCtrl = " << (e.GetKeyCode() == WXK_CONTROL) << std::endl;
|
// std::cout << "e.ControlDown() = " << e.ControlDown() << " e.GetKeyCode() = " << e.GetKeyCode() << " isCtrl = " << (e.GetKeyCode() == WXK_CONTROL) << std::endl;
|
||||||
|
|
||||||
// Note: This ctrl-key handling is buggy since it never resests when ctrl is released later, so I reset it at end of loadcommands for now.
|
// Note: This ctrl-key handling is buggy since it never resests when ctrl is released later, so I reset it at end of loadcommands for now.
|
||||||
@@ -945,9 +1082,15 @@ void MainWindow::onKeyDown(wxKeyEvent &e) {
|
|||||||
Vec4f ambientNEW= Vec4f(lightBrightness, lightBrightness, lightBrightness, 1.0f);
|
Vec4f ambientNEW= Vec4f(lightBrightness, lightBrightness, lightBrightness, 1.0f);
|
||||||
glLightfv(GL_LIGHT0,GL_AMBIENT, ambientNEW.ptr());
|
glLightfv(GL_LIGHT0,GL_AMBIENT, ambientNEW.ptr());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuRestart(wxCommandEvent &event){
|
void MainWindow::onMenuRestart(wxCommandEvent &event) {
|
||||||
|
try {
|
||||||
// std::cout << "pressed R (restart particle animation)" << std::endl;
|
// std::cout << "pressed R (restart particle animation)" << std::endl;
|
||||||
renderer->end();
|
renderer->end();
|
||||||
|
|
||||||
@@ -965,6 +1108,11 @@ void MainWindow::onMenuRestart(wxCommandEvent &event){
|
|||||||
|
|
||||||
renderer->initModelManager();
|
renderer->initModelManager();
|
||||||
renderer->initTextureManager();
|
renderer->initTextureManager();
|
||||||
|
}
|
||||||
|
catch(std::runtime_error e) {
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
||||||
|
Reference in New Issue
Block a user