Author Topic: Glest tools patch  (Read 3887 times)

pseudonym404

  • Guest
Glest tools patch
« on: 23 January 2006, 11:17:46 »
This patch (against current Glest CVS) does a few (trivial) things:
    Allows the tools to be built using unicode or non-unicode wxWidgets (tested with unicode & non-unicode builds of wxGTK 2.6.2 on Fedora Core 4)
    Adds some double casts to pow statements in the map editor source (gcc4 has a tantrum trying to pass int to functions that take double)
    Changes the way onPaint gets called from mouse event handlers (gcc4 tantrums again)
    Removes glCanvas onPaint handler in g3d_viewer (solves a GLXBadDrawable error - function seems to be superfluous, window updates fine without it)
    Adds g3d_viewer to the linux build system

Code: [Select]
diff -urN glest.orig/mk/linux/autogen.sh glest/mk/linux/autogen.sh
--- glest.orig/mk/linux/autogen.sh 2006-01-23 09:24:55.000000000 +0000
+++ glest/mk/linux/autogen.sh 2006-01-22 17:55:11.000000000 +0000
@@ -34,4 +34,6 @@
 if [ ! -d glest_map_editor ]; then
   ln -sf ../../source/glest_map_editor .
 fi
-
+if [ ! -d g3d_viewer ]; then
+  ln -sf ../../source/g3d_viewer .
+fi
diff -urN glest.orig/mk/linux/configure.ac glest/mk/linux/configure.ac
--- glest.orig/mk/linux/configure.ac 2006-01-23 09:24:55.000000000 +0000
+++ glest/mk/linux/configure.ac 2006-01-22 15:46:37.000000000 +0000
@@ -134,7 +134,7 @@
 XIPH_PATH_OGG(, [AC_MSG_ERROR([Please install ogg/vorbis])])
 
 AM_OPTIONS_WXCONFIG
-AM_PATH_WXCONFIG([2.6.0], [WX_AVAILABLE="yes"], [WX_AVAILABLE="no"], [std,gl], [--unicode=no])
+AM_PATH_WXCONFIG([2.6.0], [WX_AVAILABLE="yes"], [WX_AVAILABLE="no"], [std,gl])
 AC_SUBST([WX_AVAILABLE])
 
 AC_INIT_JAM
diff -urN glest.orig/mk/linux/Jamfile glest/mk/linux/Jamfile
--- glest.orig/mk/linux/Jamfile 2006-01-23 09:24:55.000000000 +0000
+++ glest/mk/linux/Jamfile 2006-01-22 17:52:53.000000000 +0000
@@ -46,3 +46,18 @@
   ExternalLibs glest_map_editor : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL WX ;
   IncludeDir glest_map_editor : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_MAP_DIRS) ;
 }
+
+#### Viewer ####
+if $(WX_AVAILABLE) = "yes" {
+  SubDir TOP g3d_viewer ;
+
+  G3D_VIEWER_DIR = . ;
+  for i in $(GLEST_DIRS) {
+    G3D_VIEWER_SOURCES += [ Wildcard $(i) : *.cpp *.h ] ;
+  }
+
+  Application g3d_viewer : $(G3D_VIEWER_SOURCES) ;
+  LinkWith g3d_viewer : glestlib ;
+  ExternalLibs g3d_viewer : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL WX ;
+  IncludeDir g3d_viewer : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(G3D_VIEWER_DIR) ;
+}
diff -urN glest.orig/source/g3d_viewer/main.cpp glest/source/g3d_viewer/main.cpp
--- glest.orig/source/g3d_viewer/main.cpp 2006-01-23 09:24:54.000000000 +0000
+++ glest/source/g3d_viewer/main.cpp 2006-01-23 10:42:50.000000000 +0000
@@ -1,6 +1,5 @@
 #include "main.h"
 
-#include "graphics_factory_basic_gl.h"
 #include "graphics_interface.h"
 #include "util.h"
 
@@ -8,6 +7,13 @@
 using namespace Shared::Graphics;
 using namespace Shared::Graphics::Gl;
 using namespace Shared::Util;
+using std::exception;
+
+#if (wxUSE_UNICODE == 1)
+#define STRCONV(x) wxConvUTF8.cMB2WC(x)
+#else
+#define STRCONV(x) x
+#endif
 
 namespace Shared{ namespace G3dViewer{
 
@@ -20,7 +26,7 @@
 
 MainWindow::MainWindow(const string &modelPath):
  wxFrame(
- NULL, -1, winHeader.c_str(),
+ NULL, -1, STRCONV(winHeader.c_str()),
  wxPoint(Renderer::windowX, Renderer::windowY),
  wxSize(Renderer::windowW, Renderer::windowH))
 {
@@ -33,38 +39,33 @@
 
  glCanvas = new GlCanvas(this);
 
- glCanvas->SetCurrent();
-
- renderer->init();
-
-
  menu= new wxMenuBar();
 
  //menu
  menuFile= new wxMenu();
- menuFile->Append(miFileLoad, "Load");
- menu->Append(menuFile, "File");
+ menuFile->Append(miFileLoad, wxT("Load"));
+ menu->Append(menuFile, wxT("File"));
 
  //mode
  menuMode= new wxMenu();
- menuMode->AppendCheckItem(miModeNormals, "Normals");
- menuMode->AppendCheckItem(miModeWireframe, "Wireframe");
- menuMode->AppendCheckItem(miModeGrid, "Grid");
- menu->Append(menuMode, "Mode");
+ menuMode->AppendCheckItem(miModeNormals, wxT("Normals"));
+ menuMode->AppendCheckItem(miModeWireframe, wxT("Wireframe"));
+ menuMode->AppendCheckItem(miModeGrid, wxT("Grid"));
+ menu->Append(menuMode, wxT("Mode"));
 
  //mode
  menuSpeed= new wxMenu();
- menuSpeed->Append(miSpeedSlower, "Slower");
- menuSpeed->Append(miSpeedFaster, "Faster");
- menu->Append(menuSpeed, "Speed");
+ menuSpeed->Append(miSpeedSlower, wxT("Slower"));
+ menuSpeed->Append(miSpeedFaster, wxT("Faster"));
+ menu->Append(menuSpeed, wxT("Speed"));
 
  //custom color
  menuCustomColor= new wxMenu();
- menuCustomColor->AppendCheckItem(miColorRed, "Red");
- menuCustomColor->AppendCheckItem(miColorBlue, "Blue");
- menuCustomColor->AppendCheckItem(miColorYellow, "Yellow");
- menuCustomColor->AppendCheckItem(miColorGreen, "Green");
- menu->Append(menuCustomColor, "Custom Color");
+ menuCustomColor->AppendCheckItem(miColorRed, wxT("Red"));
+ menuCustomColor->AppendCheckItem(miColorBlue, wxT("Blue"));
+ menuCustomColor->AppendCheckItem(miColorYellow, wxT("Yellow"));
+ menuCustomColor->AppendCheckItem(miColorGreen, wxT("Green"));
+ menu->Append(menuCustomColor, wxT("Custom Color"));
 
  menuMode->Check(miModeGrid, true);
  menuCustomColor->Check(miColorRed, true);
@@ -85,11 +86,16 @@
  timer = new wxTimer(this);
  timer->Start(40);
 
+}
+
+void MainWindow::init(){
+ glCanvas->SetCurrent();
+ renderer->init();
  if(!modelPath.empty()){
  Model *tmpModel= new ModelGl();
  renderer->loadTheModel(tmpModel, modelPath);
  model= tmpModel;
- GetStatusBar()->SetStatusText(getModelInfo().c_str());
+ GetStatusBar()->SetStatusText(STRCONV(getModelInfo().c_str()));
  }
 }
 
@@ -121,12 +127,14 @@
  if(event.LeftIsDown()){
  rotX+= clamp(lastX-x, -10, 10);
  rotY+= clamp(lastY-y, -10, 10);
- onPaint(wxPaintEvent());
+ wxPaintEvent paint =* new wxPaintEvent();
+ onPaint(paint);
  }
  else if(event.RightIsDown()){
  zoom*= 1.0f+(lastX-x+lastY-y)/100.0f;
  zoom= clamp(zoom, 0.1f, 10.0f);
- onPaint(wxPaintEvent());
+ wxPaintEvent paint =* new wxPaintEvent();
+ onPaint(paint);
  }
 
  lastX= x;
@@ -136,13 +144,14 @@
 void MainWindow::onMenuFileLoad(wxCommandEvent &event){
  string fileName;
  wxFileDialog fileDialog(this);
- fileDialog.SetWildcard("G3D files (*.g3d)|*.g3d");
+ fileDialog.SetWildcard(wxT("G3D files (*.g3d)|*.g3d"));
  if(fileDialog.ShowModal()==wxID_OK){
  delete model;
  Model *tmpModel= new ModelGl();
- renderer->loadTheModel(tmpModel, fileDialog.GetPath().c_str());
+ fileName=wxFNCONV(fileDialog.GetPath());
+ renderer->loadTheModel(tmpModel, fileName);
  model= tmpModel;
- GetStatusBar()->SetStatusText(getModelInfo().c_str());
+ GetStatusBar()->SetStatusText(STRCONV(getModelInfo().c_str()));
  }
 }
 
@@ -206,7 +215,8 @@
  if(anim>1.0f){
  anim-= 1.f;
  }
- onPaint(wxPaintEvent());
+ wxPaintEvent paint =* new wxPaintEvent();
+ onPaint(paint);
 }
 
 string MainWindow::getModelInfo(){
@@ -254,13 +264,8 @@
  mainWindow->onMouseMove(event);
 }
 
-void GlCanvas::onPaint(wxPaintEvent &event){
- mainWindow->onPaint(event);
-}
-
 BEGIN_EVENT_TABLE(GlCanvas, wxGLCanvas)
  EVT_MOTION(GlCanvas::onMouseMove)
- EVT_PAINT(GlCanvas::onPaint)
 END_EVENT_TABLE()
 
 // ===============================================
@@ -270,11 +275,12 @@
 bool App::OnInit(){
  string modelPath;
  if(argc==2){
- modelPath= argv[1];
+ modelPath= wxFNCONV(argv[1]);
  }
 
  mainWindow= new MainWindow(modelPath);
  mainWindow->Show();
+ mainWindow->init();
  return true;
 }
 
@@ -283,9 +289,9 @@
  return wxApp::MainLoop();
  }
  catch(const exception &e){
- wxMessageDialog(NULL, e.what(), "Exception", wxOK | wxICON_ERROR).ShowModal();
- return 0;
+ wxMessageDialog(NULL, STRCONV(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
  }
+ return 0;
 }
 
 int App::OnExit(){
diff -urN glest.orig/source/g3d_viewer/main.h glest/source/g3d_viewer/main.h
--- glest.orig/source/g3d_viewer/main.h 2006-01-23 09:24:54.000000000 +0000
+++ glest/source/g3d_viewer/main.h 2006-01-22 20:36:42.000000000 +0000
@@ -3,6 +3,8 @@
 
 #include <string>
 
+#include "graphics_factory_basic_gl.h"
+
 #include <wx/wx.h>
 #include <wx/timer.h>
 #include <wx/glcanvas.h>
@@ -11,8 +13,8 @@
 #include "util.h"
 #include "window.h"
 
-using Shared::Platform::Window;
-using Shared::Platform::MouseState;
+//using Shared::Platform::Window;
+//using Shared::Platform::MouseState;
 
 using std::string;
 
@@ -70,6 +72,8 @@
  MainWindow(const string &modelPath);
  ~MainWindow();
 
+ void init();
+
  void Notify();
 
  void onPaint(wxPaintEvent &event);
@@ -102,7 +106,6 @@
  GlCanvas(MainWindow *mainWindow);
 
  void onMouseMove(wxMouseEvent &event);
- void onPaint(wxPaintEvent &event);
 
 private:
  MainWindow *mainWindow;
diff -urN glest.orig/source/glest_map_editor/main.cpp glest/source/glest_map_editor/main.cpp
--- glest.orig/source/glest_map_editor/main.cpp 2006-01-23 09:24:54.000000000 +0000
+++ glest/source/glest_map_editor/main.cpp 2006-01-23 10:40:13.000000000 +0000
@@ -4,6 +4,12 @@
 
 #include "conversion.h"
 
+#if (wxUSE_UNICODE == 1)
+#define STRCONV(x) wxConvUTF8.cMB2WC(x)
+#else
+#define STRCONV(x) x
+#endif
+
 using namespace Shared::Util;
 
 using namespace std;
@@ -18,7 +24,7 @@
 // ===============================================
 
 MainWindow::MainWindow():
- wxFrame(NULL, -1,  winHeader.c_str())
+ wxFrame(NULL, -1, STRCONV(winHeader.c_str()))
 {
  lastX= 0;
  lastY= 0;
@@ -40,34 +46,34 @@
 
  //file
  menuFile= new wxMenu();
- menuFile->Append(miFileLoad, "Load");
+ menuFile->Append(miFileLoad, wxT("Load"));
  menuFile->AppendSeparator();
- menuFile->Append(miFileSave, "Save");
- menuFile->Append(miFileSaveAs, "Save As");
+ menuFile->Append(miFileSave, wxT("Save"));
+ menuFile->Append(miFileSaveAs, wxT("Save As"));
  menuFile->AppendSeparator();
- menuFile->Append(miFileExit, "Exit");
- menuBar->Append(menuFile, "File");
+ menuFile->Append(miFileExit, wxT("Exit"));
+ menuBar->Append(menuFile, wxT("File"));
 
  //edit
  menuEdit= new wxMenu();
- menuEdit->Append(miEditReset, "Reset");
- menuEdit->Append(miEditResetPlayers, "Reset Players");
- menuEdit->Append(miEditResize, "Resize");
- menuEdit->Append(miEditFlipX, "Flip X");
- menuEdit->Append(miEditFlipY, "Flip Y");
- menuEdit->Append(miEditRandomizeHeights, "Randomize Heights");
- menuEdit->Append(miEditRandomize, "Randomize");
- menuEdit->Append(miEditSwitchSurfaces, "Switch Surfaces");
- menuEdit->Append(miEditInfo, "Info");
- menuEdit->Append(miEditAdvanced, "Advanced");
- menuBar->Append(menuEdit, "Edit");
+ menuEdit->Append(miEditReset, wxT("Reset"));
+ menuEdit->Append(miEditResetPlayers, wxT("Reset Players"));
+ menuEdit->Append(miEditResize, wxT("Resize"));
+ menuEdit->Append(miEditFlipX, wxT("Flip X"));
+ menuEdit->Append(miEditFlipY, wxT("Flip Y"));
+ menuEdit->Append(miEditRandomizeHeights, wxT("Randomize Heights"));
+ menuEdit->Append(miEditRandomize, wxT("Randomize"));
+ menuEdit->Append(miEditSwitchSurfaces, wxT("Switch Surfaces"));
+ menuEdit->Append(miEditInfo, wxT("Info"));
+ menuEdit->Append(miEditAdvanced, wxT("Advanced"));
+ menuBar->Append(menuEdit, wxT("Edit"));
 
  //misc
  menuMisc= new wxMenu();
- menuMisc->Append(miMiscResetZoomAndPos, "Reset zoom and pos");
- menuMisc->Append(miMiscAbout, "About");
- menuMisc->Append(miMiscHelp, "Help");
- menuBar->Append(menuMisc, "Misc");
+ menuMisc->Append(miMiscResetZoomAndPos, wxT("Reset zoom and pos"));
+ menuMisc->Append(miMiscAbout, wxT("About"));
+ menuMisc->Append(miMiscHelp, wxT("Help"));
+ menuBar->Append(menuMisc, wxT("Misc"));
 
  //brush
  menuBrush= new wxMenu();
@@ -75,62 +81,62 @@
  //height
  menuBrushHeight= new wxMenu();
  for(int i=0; i<heightCount; ++i){
- menuBrushHeight->AppendCheckItem(miBrushHeight+i+1, intToStr(i-heightCount/2).c_str());
+ menuBrushHeight->AppendCheckItem(miBrushHeight+i+1, wxString::Format(wxT("%d"),i-heightCount/2));
  }
  menuBrushHeight->Check(miBrushHeight + 1 + heightCount/2, true);
- menuBrush->Append(miBrushHeight, "Height", menuBrushHeight);
+ menuBrush->Append(miBrushHeight, wxT("Height"), menuBrushHeight);
 
  //surface
  menuBrushSurface= new wxMenu();
- menuBrushSurface->AppendCheckItem(miBrushSurface+1, "1 - Grass");
- menuBrushSurface->AppendCheckItem(miBrushSurface+2, "2 - Secondary Grass");
- menuBrushSurface->AppendCheckItem(miBrushSurface+3, "3 - Road");
- menuBrushSurface->AppendCheckItem(miBrushSurface+4, "4 - Stone");
- menuBrushSurface->AppendCheckItem(miBrushSurface+5, "5 - Custom");
- menuBrush->Append(miBrushSurface, "Surface", menuBrushSurface);
+ menuBrushSurface->AppendCheckItem(miBrushSurface+1, wxT("1 - Grass"));
+ menuBrushSurface->AppendCheckItem(miBrushSurface+2, wxT("2 - Secondary Grass"));
+ menuBrushSurface->AppendCheckItem(miBrushSurface+3, wxT("3 - Road"));
+ menuBrushSurface->AppendCheckItem(miBrushSurface+4, wxT("4 - Stone"));
+ menuBrushSurface->AppendCheckItem(miBrushSurface+5, wxT("5 - Custom"));
+ menuBrush->Append(miBrushSurface, wxT("Surface"), menuBrushSurface);
 
  //objects
  menuBrushObject= new wxMenu();
- menuBrushObject->AppendCheckItem(miBrushObject+1, "0 - None");
- menuBrushObject->AppendCheckItem(miBrushObject+2, "1 - Tree");
- menuBrushObject->AppendCheckItem(miBrushObject+3, "2 - Dead Tree");
- menuBrushObject->AppendCheckItem(miBrushObject+4, "3 - Stone");
- menuBrushObject->AppendCheckItem(miBrushObject+5, "4 - Bush");
- menuBrushObject->AppendCheckItem(miBrushObject+6, "5 - Water Object");
- menuBrushObject->AppendCheckItem(miBrushObject+7, "6 - Custom 1");
- menuBrushObject->AppendCheckItem(miBrushObject+8, "7 - Custom 2");
- menuBrushObject->AppendCheckItem(miBrushObject+9, "8 - Custom 3");
- menuBrushObject->AppendCheckItem(miBrushObject+10, "9 - Custom 4");
- menuBrushObject->AppendCheckItem(miBrushObject+11, "10 - Custom 5");
- menuBrush->Append(miBrushObject, "Object", menuBrushObject);
+ menuBrushObject->AppendCheckItem(miBrushObject+1, wxT("0 - None"));
+ menuBrushObject->AppendCheckItem(miBrushObject+2, wxT("1 - Tree"));
+ menuBrushObject->AppendCheckItem(miBrushObject+3, wxT("2 - Dead Tree"));
+ menuBrushObject->AppendCheckItem(miBrushObject+4, wxT("3 - Stone"));
+ menuBrushObject->AppendCheckItem(miBrushObject+5, wxT("4 - Bush"));
+ menuBrushObject->AppendCheckItem(miBrushObject+6, wxT("5 - Water Object"));
+ menuBrushObject->AppendCheckItem(miBrushObject+7, wxT("6 - Custom 1"));
+ menuBrushObject->AppendCheckItem(miBrushObject+8, wxT("7 - Custom 2"));
+ menuBrushObject->AppendCheckItem(miBrushObject+9, wxT("8 - Custom 3"));
+ menuBrushObject->AppendCheckItem(miBrushObject+10, wxT("9 - Custom 4"));
+ menuBrushObject->AppendCheckItem(miBrushObject+11, wxT("10 - Custom 5"));
+ menuBrush->Append(miBrushObject, wxT("Object"), menuBrushObject);
 
  //resources
  menuBrushResource= new wxMenu();
- menuBrushResource->AppendCheckItem(miBrushResource+1, "0 - None");
- menuBrushResource->AppendCheckItem(miBrushResource+2, "1 - Custom 1");
- menuBrushResource->AppendCheckItem(miBrushResource+3, "2 - Custom 2");
- menuBrushResource->AppendCheckItem(miBrushResource+4, "3 - Custom 3");
- menuBrushResource->AppendCheckItem(miBrushResource+5, "4 - Custom 4");
- menuBrushResource->AppendCheckItem(miBrushResource+6, "5 - Custom 5");
- menuBrush->Append(miBrushResource, "Resource", menuBrushResource);
+ menuBrushResource->AppendCheckItem(miBrushResource+1, wxT("0 - None"));
+ menuBrushResource->AppendCheckItem(miBrushResource+2, wxT("1 - Custom 1"));
+ menuBrushResource->AppendCheckItem(miBrushResource+3, wxT("2 - Custom 2"));
+ menuBrushResource->AppendCheckItem(miBrushResource+4, wxT("3 - Custom 3"));
+ menuBrushResource->AppendCheckItem(miBrushResource+5, wxT("4 - Custom 4"));
+ menuBrushResource->AppendCheckItem(miBrushResource+6, wxT("5 - Custom 5"));
+ menuBrush->Append(miBrushResource, wxT("Resource"), menuBrushResource);
 
  //players
  menuBrushStartLocation= new wxMenu();
- menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+1, "1 - Player 1");
- menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+2, "2 - Player 2");
- menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+3, "3 - Player 3");
- menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+4, "4 - Player 4");
- menuBrush->Append(miBrushStartLocation, "Player", menuBrushStartLocation);
+ menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+1, wxT("1 - Player 1"));
+ menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+2, wxT("2 - Player 2"));
+ menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+3, wxT("3 - Player 3"));
+ menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+4, wxT("4 - Player 4"));
+ menuBrush->Append(miBrushStartLocation, wxT("Player"), menuBrushStartLocation);
 
- menuBar->Append(menuBrush, "Brush");
+ menuBar->Append(menuBrush, wxT("Brush"));
 
  //radius
  menuRadius= new wxMenu();
  for(int i=0; i<radiusCount; ++i){
- menuRadius->AppendCheckItem(miRadius+i, intToStr(i+1).c_str());
+ menuRadius->AppendCheckItem(miRadius+i, wxString::Format(wxT("%d"),i+1));
  }
  menuRadius->Check(miRadius, true);
- menuBar->Append(menuRadius, "Radius");
+ menuBar->Append(menuRadius, wxT("Radius"));
 
  SetMenuBar(menuBar);
 }
@@ -154,7 +160,8 @@
  program->setRefAlt(event.GetX(), event.GetY());
  change(event.GetX(), event.GetY());
  }
- onPaint(wxPaintEvent());
+ wxPaintEvent paint =* new wxPaintEvent();
+ onPaint(paint);
 }
 
 void MainWindow::onMouseMove(wxMouseEvent &event){
@@ -177,10 +184,15 @@
  }
  lastX= x;
  lastY= y;
- onPaint(wxPaintEvent());
+ wxPaintEvent paint =* new wxPaintEvent();
+ onPaint(paint);
 }
 
 void MainWindow::onPaint(wxPaintEvent &event){
+
+ //Creating this objects tells wxWidgets that the invalid regions in the window have been repainted so that the windowing system won't keep sending paint events ad infinitum.
+ wxPaintDC dc(this);
+
  program->renderMap(GetClientSize().x, GetClientSize().y);
 
  glCanvas->SwapBuffers();
@@ -190,19 +202,20 @@
  string fileName;
 
  wxFileDialog fileDialog(this);
- fileDialog.SetWildcard("Glest Binary Map (*.gbm)|*.gbm");
+ fileDialog.SetWildcard(wxT("Glest Binary Map (*.gbm)|*.gbm"));
  if(fileDialog.ShowModal()==wxID_OK){
- fileName= fileDialog.GetPath();
+ fileName= wxFNCONV(fileDialog.GetPath());
  program->loadMap(fileName);
  }
 
  currentFile= fileName;
- SetTitle((winHeader + "; " + currentFile).c_str());
+ wxString newWinHeader = wxString(wxT("")) << STRCONV(winHeader.c_str()) << wxT("; ") << STRCONV(currentFile.c_str());
+ SetTitle(newWinHeader);
 }
 
 void MainWindow::onMenuFileSave(wxCommandEvent &event){
  if(currentFile.empty()){
- onMenuFileSaveAs(wxCommandEvent());
+ onMenuFileSaveAs(event);
  }
  else{
  program->saveMap(currentFile);
@@ -212,15 +225,16 @@
 void MainWindow::onMenuFileSaveAs(wxCommandEvent &event){
  string fileName;
 
- wxFileDialog fileDialog(this, "Select file", "", "", "*.gbm", wxSAVE);
- fileDialog.SetWildcard("Glest Binary Map (*.gbm)|*.gbm");
+ wxFileDialog fileDialog(this, wxT("Select file"), wxT(""), wxT(""), wxT("*.gbm"), wxSAVE);
+ fileDialog.SetWildcard(wxT("Glest Binary Map (*.gbm)|*.gbm"));
  if(fileDialog.ShowModal()==wxID_OK){
- fileName= fileDialog.GetPath();
+ fileName= wxFNCONV(fileDialog.GetPath());
  program->saveMap(fileName);
  }
 
  currentFile= fileName;
- SetTitle((winHeader + "; " + currentFile).c_str());
+ wxString newWinHeader = wxString(wxT("")) << STRCONV(winHeader.c_str()) << wxT("; ") << STRCONV(currentFile.c_str());
+ SetTitle(newWinHeader);
 }
 
 void MainWindow::onMenuFileExit(wxCommandEvent &event){
@@ -243,7 +257,7 @@
  strToInt(simpleDialog.getValue("Surface")));
  }
  catch(const exception &e){
- wxMessageDialog(NULL, e.what(), "Exception", wxOK | wxICON_ERROR).ShowModal();
+ wxMessageDialog(NULL, STRCONV(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
  }
 
 }
@@ -257,7 +271,7 @@
  program->resetPlayers(strToInt(simpleDialog.getValue("Players")));
  }
  catch(const exception &e){
- wxMessageDialog(NULL, e.what(), "Exception", wxOK | wxICON_ERROR).ShowModal();
+ wxMessageDialog(NULL, STRCONV(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
  }
 }
 
@@ -277,7 +291,7 @@
  strToInt(simpleDialog.getValue("Surface")));
  }
  catch(const exception &e){
- wxMessageDialog(NULL, e.what(), "Exception", wxOK | wxICON_ERROR).ShowModal();
+ wxMessageDialog(NULL, STRCONV(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
  }
 }
 
@@ -309,7 +323,7 @@
  strToInt(simpleDialog.getValue("Surface2")));
  }
  catch(const exception &e){
- wxMessageDialog(NULL, e.what(), "Exception", wxOK | wxICON_ERROR).ShowModal();
+ wxMessageDialog(NULL, STRCONV(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
  }
 }
 
@@ -339,7 +353,7 @@
  strToInt(simpleDialog.getValue("Water Level")));
  }
  catch(const exception &e){
- wxMessageDialog(NULL, e.what(), "Exception", wxOK | wxICON_ERROR).ShowModal();
+ wxMessageDialog(NULL, STRCONV(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
  }
 }
 
@@ -348,11 +362,11 @@
 }
 
 void MainWindow::onMenuMiscAbout(wxCommandEvent &event){
- wxMessageDialog(NULL, "Glest Map Editor - Copyright 2004 The Glest Team", "About").ShowModal();
+ wxMessageDialog(NULL, wxT("Glest Map Editor - Copyright 2004 The Glest Team"), wxT("About")).ShowModal();
 }
 
 void MainWindow::onMenuMiscHelp(wxCommandEvent &event){
- wxMessageDialog(NULL, "Left mouse click: draw\nRight mouse drag: move\nCenter mouse drag: zoom", "Help").ShowModal();
+ wxMessageDialog(NULL, wxT("Left mouse click: draw\nRight mouse drag: move\nCenter mouse drag: zoom"), wxT("Help")).ShowModal();
 }
 
 void MainWindow::onMenuBrushHeight(wxCommandEvent &event){
@@ -471,6 +485,7 @@
  EVT_MENU_RANGE(miBrushResource+1, miBrushResource+resourceCount, MainWindow::onMenuBrushResource)
  EVT_MENU_RANGE(miBrushStartLocation+1, miBrushStartLocation+startLocationCount, MainWindow::onMenuBrushStartLocation)
  EVT_MENU_RANGE(miRadius, miRadius+radiusCount, MainWindow::onMenuRadius)
+ EVT_PAINT(MainWindow::onPaint)
 END_EVENT_TABLE()
 
 // =====================================================
@@ -515,15 +530,15 @@
 
 void SimpleDialog::show(){
 
- Create(NULL, -1, "Edit Values");
+ Create(NULL, -1, wxT("Edit Values"));
 
  wxSizer *sizer= new wxFlexGridSizer(2);
 
  vector<wxTextCtrl*> texts;
 
  for(Values::iterator it= values.begin(); it!=values.end(); ++it){
- sizer->Add(new wxStaticText(this, -1, it->first.c_str()), 0, wxALL, 5);
- wxTextCtrl *text= new wxTextCtrl(this, -1, it->second.c_str());
+ sizer->Add(new wxStaticText(this, -1, STRCONV(it->first.c_str())), 0, wxALL, 5);
+ wxTextCtrl *text= new wxTextCtrl(this, -1, STRCONV(it->second.c_str()));
  sizer->Add(text, 0, wxALL, 5);
  texts.push_back(text);
  }
@@ -532,7 +547,7 @@
  ShowModal();
 
  for(int i=0; i<texts.size(); ++i){
- values[i].second= texts[i]->GetValue();
+ values[i].second= wxFNCONV(texts[i]->GetValue());
  }
 }
 
@@ -552,7 +567,7 @@
  return wxApp::MainLoop();
  }
  catch(const exception &e){
- wxMessageDialog(NULL, e.what(), "Exception", wxOK | wxICON_ERROR).ShowModal();
+ wxMessageDialog(NULL, STRCONV(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
  }
  return 0;
 }
diff -urN glest.orig/source/glest_map_editor/map.cpp glest/source/glest_map_editor/map.cpp
--- glest.orig/source/glest_map_editor/map.cpp 2006-01-23 09:24:54.000000000 +0000
+++ glest/source/glest_map_editor/map.cpp 2006-01-23 09:43:50.000000000 +0000
@@ -65,7 +65,7 @@
  for (int i=x-radius+1; i<x+radius; i++){
  for (int j=y-radius+1; j<y+radius; j++){
  if (inside(i, j)){
- int dist= static_cast<int>(sqrt(pow(i-x, 2)+pow(j-y, 2)));
+ int dist= static_cast<int>(sqrt(pow((double)(i-x), (double)2)+pow((double)(j-y), (double)2)));
  if (radius>dist){
  int oldAlt= static_cast<int>(cells[i][j].height);
  int altInc= height * (radius-dist-1)/radius;
@@ -148,7 +148,7 @@
      for (i=x-radius+1; i<x+radius; i++){
           for (j=y-radius+1; j<y+radius; j++){
                if (inside(i, j)){
-                    dist= (int) sqrt(pow(i-x, 2)+pow(j-y, 2));
+                    dist= (int) sqrt(pow((double)(i-x), (double)2)+pow((double)(j-y), (double)2));
                     if (radius>=dist){
                          cells[i][j].surface= surface;
                     }
@@ -164,7 +164,7 @@
      for (i=x-radius+1; i<x+radius; i++){
           for (j=y-radius+1; j<y+radius; j++){
                if (inside(i, j)){
-                    dist= (int) sqrt(pow(i-x, 2)+pow(j-y, 2));
+                    dist= (int) sqrt(pow((double)(i-x), (double)2)+pow((double)(j-y), (double)2));
                     if (radius>=dist){
                          cells[i][j].object= object;
                          cells[i][j].resource= 0;
@@ -181,7 +181,7 @@
      for (i=x-radius+1; i<x+radius; i++){
           for (j=y-radius+1; j<y+radius; j++){
                if (inside(i, j)){
-                    dist= (int) sqrt(pow(i-x, 2)+pow(j-y, 2));
+                    dist= (int) sqrt(pow((double)(i-x), (double)2)+pow((double)(j-y), (double)2));
                     if (radius>=dist){
                          cells[i][j].resource= resource;
                          cells[i][j].object= 0;
@@ -306,7 +306,7 @@
 
  //delete old cells
  if (oldCells!=NULL){
- for(i=0; i<oldW; i++)
+ for(int i=0; i<oldW; i++)
  delete oldCells[i];
  delete oldCells;
  }
« Last Edit: 1 January 1970, 00:00:00 by pseudonym404 »

martiño

  • Behemoth
  • *******
  • Posts: 1,095
    • View Profile
(No subject)
« Reply #1 on: 23 January 2006, 21:18:27 »
Thanks! If we didn´t release the source code for the tools was because we didn´t try it in Linux, so we wanted to make sure that the source was cross platform. I´ll tell Matze to take a look and we will try to release the final soruce as soon as possible.

Regards.
« Last Edit: 1 January 1970, 00:00:00 by martiño »

Yggdrasil

  • GAE Team
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Re: Glest tools patch
« Reply #2 on: 28 March 2009, 11:32:29 »
I know this thread is really old, but i want to let you know that this patch is still valid more or less. I applied the changes for the g3d_viewer mentioned in this patch and some small other changes. So here is a patch against svn trunk (r191) to enable g3d_viewer for linux:
http://www1.inf.tu-dresden.de/~s1445051/g3d_viewer.patch

After patching you need to run autogen.sh and configure before running jam because the build system changed. The binary is called glest_g3dviewer.

Have fun.

EDIT: Can someone move this thread to the ports subforum? ( titi: I did it )
« Last Edit: 28 March 2009, 17:21:59 by titi »