From d2f0591bfa1d39198b16853178ec59aad4b4d094 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Wed, 2 Oct 2013 22:26:06 +0000 Subject: [PATCH] patch from titi_son showing the map coordinates in the map editor --- source/glest_map_editor/main.cpp | 23 +++++++++++++++++------ source/glest_map_editor/main.h | 1 + source/glest_map_editor/program.cpp | 8 ++++++++ source/glest_map_editor/program.h | 2 ++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index faa5d0e5..6b2b7a20 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -298,12 +298,13 @@ void MainWindow::init(string fname) { fileName = "New (unsaved) map"; int status_widths[siCOUNT] = { 10, // empty - -2, // File name - -1, // File type - -2, // Current Object - -2, // Brush Type - -2, // Brush 'Value' - -1, // Brush Radius + -25, // File name + -6, // File type + -20, // Current Object + -14, // Brush Type + -20, // Brush 'Value' + -10, // Brush Radius + -25, // Position }; CreateStatusBar(siCOUNT); GetStatusBar()->SetStatusWidths(siCOUNT, status_widths); @@ -314,6 +315,7 @@ void MainWindow::init(string fname) { SetStatusText(wxT("Brush: Height"), siBRUSH_TYPE); SetStatusText(wxT("Value: 0"), siBRUSH_VALUE); SetStatusText(wxT("Radius: 1"), siBRUSH_RADIUS); + SetStatusText(wxT("Pos (Ingame): 0"), siPOS_VALUE); wxToolBar *toolbar = new MainToolBar(this->panel, wxID_ANY); toolbar->AddTool(miEditUndo, _("undo"), wxBitmap(edit_undo), _("Undo")); @@ -603,6 +605,15 @@ void MainWindow::onMouseMove(wxMouseEvent &event, int x, int y) { objectUnderMouse = currObject; } + SetStatusText(wxT("Pos (Ingame): ") + + ToUnicode(intToStr(program->getCellX(x)) + + "," + + intToStr(program->getCellY(y)) + + " (" + + intToStr(2*(program->getCellX(x))) + + "," + + intToStr(2*(program->getCellX(x))) + + ")"), siPOS_VALUE); //#ifdef WIN32 //repaint = true; //#endif diff --git a/source/glest_map_editor/main.h b/source/glest_map_editor/main.h index fbc0b1af..f9fb33e0 100644 --- a/source/glest_map_editor/main.h +++ b/source/glest_map_editor/main.h @@ -53,6 +53,7 @@ enum StatusItems { siBRUSH_TYPE, siBRUSH_VALUE, siBRUSH_RADIUS, + siPOS_VALUE, siCOUNT }; diff --git a/source/glest_map_editor/program.cpp b/source/glest_map_editor/program.cpp index e4120666..1d54a1d0 100644 --- a/source/glest_map_editor/program.cpp +++ b/source/glest_map_editor/program.cpp @@ -183,6 +183,14 @@ int Program::getObject(int x, int y) { } } +int Program::getCellX(int x) { + return (x - ofsetX) / cellSize; +} + +int Program::getCellY(int y) { + return (y + ofsetY) / cellSize; +} + int Program::getResource(int x, int y) { int i=(x - ofsetX) / cellSize; int j= (y + ofsetY) / cellSize; diff --git a/source/glest_map_editor/program.h b/source/glest_map_editor/program.h index 793dc2a0..12fd8920 100644 --- a/source/glest_map_editor/program.h +++ b/source/glest_map_editor/program.h @@ -175,6 +175,8 @@ public: int getObject(int x, int y); int getResource(int x, int y); + int getCellX(int x); + int getCellY(int y); static const MapPreview *getMap() {return map;} };