diagonal flipping
This commit is contained in:
parent
adb7ec4a6a
commit
d28b47ffb1
|
@ -125,6 +125,7 @@ void MainWindow::init(string fname) {
|
||||||
// menuEdit->Append(miEditReset, wxT("Rese&t..."));
|
// menuEdit->Append(miEditReset, wxT("Rese&t..."));
|
||||||
menuEdit->Append(miEditResetPlayers, wxT("Reset &Players..."));
|
menuEdit->Append(miEditResetPlayers, wxT("Reset &Players..."));
|
||||||
menuEdit->Append(miEditResize, wxT("Re&size..."));
|
menuEdit->Append(miEditResize, wxT("Re&size..."));
|
||||||
|
menuEdit->Append(miEditFlipDiagonal, wxT("Flip &Diagonal"));
|
||||||
menuEdit->Append(miEditFlipX, wxT("Flip &X"));
|
menuEdit->Append(miEditFlipX, wxT("Flip &X"));
|
||||||
menuEdit->Append(miEditFlipY, wxT("Flip &Y"));
|
menuEdit->Append(miEditFlipY, wxT("Flip &Y"));
|
||||||
|
|
||||||
|
@ -747,6 +748,16 @@ void MainWindow::onMenuEditResetPlayers(wxCommandEvent &event) {
|
||||||
setExtension();
|
setExtension();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::onMenuEditFlipDiagonal(wxCommandEvent &event) {
|
||||||
|
if(program == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
program->setUndoPoint(ctAll);
|
||||||
|
program->flipDiagonal();
|
||||||
|
setDirty();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuEditResize(wxCommandEvent &event) {
|
void MainWindow::onMenuEditResize(wxCommandEvent &event) {
|
||||||
if(program == NULL) {
|
if(program == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -1255,6 +1266,7 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
||||||
EVT_MENU(miEditRedo, MainWindow::onMenuEditRedo)
|
EVT_MENU(miEditRedo, MainWindow::onMenuEditRedo)
|
||||||
EVT_MENU(miEditResetPlayers, MainWindow::onMenuEditResetPlayers)
|
EVT_MENU(miEditResetPlayers, MainWindow::onMenuEditResetPlayers)
|
||||||
EVT_MENU(miEditResize, MainWindow::onMenuEditResize)
|
EVT_MENU(miEditResize, MainWindow::onMenuEditResize)
|
||||||
|
EVT_MENU(miEditFlipDiagonal, MainWindow::onMenuEditFlipDiagonal)
|
||||||
EVT_MENU(miEditFlipX, MainWindow::onMenuEditFlipX)
|
EVT_MENU(miEditFlipX, MainWindow::onMenuEditFlipX)
|
||||||
EVT_MENU(miEditFlipY, MainWindow::onMenuEditFlipY)
|
EVT_MENU(miEditFlipY, MainWindow::onMenuEditFlipY)
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ private:
|
||||||
miEditReset,
|
miEditReset,
|
||||||
miEditResetPlayers,
|
miEditResetPlayers,
|
||||||
miEditResize,
|
miEditResize,
|
||||||
|
miEditFlipDiagonal,
|
||||||
miEditFlipX,
|
miEditFlipX,
|
||||||
miEditFlipY,
|
miEditFlipY,
|
||||||
|
|
||||||
|
@ -212,6 +213,7 @@ public:
|
||||||
void onMenuEditReset(wxCommandEvent &event);
|
void onMenuEditReset(wxCommandEvent &event);
|
||||||
void onMenuEditResetPlayers(wxCommandEvent &event);
|
void onMenuEditResetPlayers(wxCommandEvent &event);
|
||||||
void onMenuEditResize(wxCommandEvent &event);
|
void onMenuEditResize(wxCommandEvent &event);
|
||||||
|
void onMenuEditFlipDiagonal(wxCommandEvent &event);
|
||||||
void onMenuEditFlipX(wxCommandEvent &event);
|
void onMenuEditFlipX(wxCommandEvent &event);
|
||||||
void onMenuEditFlipY(wxCommandEvent &event);
|
void onMenuEditFlipY(wxCommandEvent &event);
|
||||||
|
|
||||||
|
|
|
@ -483,6 +483,22 @@ void Program::shiftLeft() {
|
||||||
map->changeStartLocation(map->getStartLocationX(i)-1, map->getStartLocationY(i), i); // it allready check limits
|
map->changeStartLocation(map->getStartLocationX(i)-1, map->getStartLocationY(i), i); // it allready check limits
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Program::flipDiagonal() {
|
||||||
|
if(map) {
|
||||||
|
int w=map->getW();
|
||||||
|
int h=map->getH();
|
||||||
|
for (int i=0; i<w; i++)
|
||||||
|
for (int j=i; j<h; j++){
|
||||||
|
map->swapXY(i,j , j,i);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < map->getMaxFactions(); ++i) // move players
|
||||||
|
if (map->getStartLocationX(i) != 0 || map->getStartLocationY(i) != 0) // don't move the unset ones
|
||||||
|
map->changeStartLocation(map->getStartLocationY(i), map->getStartLocationX(i), i); // it allready check limits
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Program::shiftRight() {
|
void Program::shiftRight() {
|
||||||
if(map) {
|
if(map) {
|
||||||
int w=map->getW()-1;
|
int w=map->getW()-1;
|
||||||
|
|
|
@ -133,6 +133,7 @@ public:
|
||||||
void rotatecopyY();
|
void rotatecopyY();
|
||||||
void rotatecopyXY();
|
void rotatecopyXY();
|
||||||
void rotatecopyCorner();
|
void rotatecopyCorner();
|
||||||
|
void flipDiagonal();
|
||||||
void shiftLeft();
|
void shiftLeft();
|
||||||
void shiftRight();
|
void shiftRight();
|
||||||
void shiftUp();
|
void shiftUp();
|
||||||
|
|
|
@ -171,6 +171,7 @@ public:
|
||||||
void flipX();
|
void flipX();
|
||||||
void flipY();
|
void flipY();
|
||||||
void copyXY(int x, int y, int sx, int sy); // destination x,y = source sx,sy
|
void copyXY(int x, int y, int sx, int sy); // destination x,y = source sx,sy
|
||||||
|
void swapXY(int x, int y, int sx, int sy);
|
||||||
void reset(int w, int h, float alt, MapSurfaceType surf);
|
void reset(int w, int h, float alt, MapSurfaceType surf);
|
||||||
void resize(int w, int h, float alt, MapSurfaceType surf);
|
void resize(int w, int h, float alt, MapSurfaceType surf);
|
||||||
void resetFactions(int maxFactions);
|
void resetFactions(int maxFactions);
|
||||||
|
|
|
@ -401,6 +401,27 @@ void MapPreview::copyXY(int x, int y, int sx, int sy) {
|
||||||
cells[x][y].surface = cells[sx][sy].surface;
|
cells[x][y].surface = cells[sx][sy].surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// swap a cell in the map with another, used by rotate etc
|
||||||
|
void MapPreview::swapXY(int x, int y, int sx, int sy) {
|
||||||
|
if(inside(x, y) and inside(sx, sy)){
|
||||||
|
float tmpHeight= cells[x][y].height;
|
||||||
|
cells[x][y].height= cells[sx][sy].height;
|
||||||
|
cells[sx][sy].height= tmpHeight;
|
||||||
|
|
||||||
|
int tmpObject= cells[x][y].object;
|
||||||
|
cells[x][y].object= cells[sx][sy].object;
|
||||||
|
cells[sx][sy].object= tmpObject;
|
||||||
|
|
||||||
|
int tmpResource= cells[x][y].resource;
|
||||||
|
cells[x][y].resource= cells[sx][sy].resource;
|
||||||
|
cells[sx][sy].resource= tmpResource;
|
||||||
|
|
||||||
|
int tmpSurface= cells[x][y].surface;
|
||||||
|
cells[x][y].surface= cells[sx][sy].surface;
|
||||||
|
cells[sx][sy].surface= tmpSurface;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MapPreview::changeSurface(int x, int y, MapSurfaceType surface, int radius) {
|
void MapPreview::changeSurface(int x, int y, MapSurfaceType surface, int radius) {
|
||||||
int i, j;
|
int i, j;
|
||||||
int dist;
|
int dist;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user