editor: shift map + mirror do player positions

This commit is contained in:
nosogo 2010-12-06 20:13:27 +00:00
parent df042b5bf2
commit 8c115809ce
3 changed files with 148 additions and 1 deletions

View File

@ -747,6 +747,7 @@ void MainWindow::onMenuViewHelp(wxCommandEvent &event) {
MsgDialog(this,
wxT("Draw with left mouse\nMove viewport with right mouse drag\nZoom with center mouse drag, or mousewheel\n\
You can change brush in the same category with key 1-9\n\
To center things in the map shift it with Shift-Up/Down/Left/Right keys\n\
Height tool (blue) builds with integer height steps 0-20, \nwhile Gradient tool (red) uses any real number \n\
Units can go over water as long as it is less than 1.5 deep\n\
A good idea is to put some stone, gold and tree near starting position\n\
@ -964,6 +965,25 @@ void MainWindow::uncheckRadius() {
} else if (e.GetKeyCode() == 'L') {
wxCommandEvent evt(wxEVT_NULL, miBrushStartLocation + startLocation + 1);
onMenuBrushStartLocation(evt);
} else if (e.GetKeyCode() == WXK_LEFT && e.GetModifiers() == wxMOD_SHIFT) { // shift-left/right/up/down to shift the map one square
program->setUndoPoint(ctAll);
program->shiftLeft();
setDirty();
} else if (e.GetKeyCode() == WXK_RIGHT && e.GetModifiers() == wxMOD_SHIFT) {
program->setUndoPoint(ctAll);
program->shiftRight();
setDirty();
} else if (e.GetKeyCode() == WXK_UP && e.GetModifiers() == wxMOD_SHIFT) {
program->setUndoPoint(ctAll);
program->shiftUp();
setDirty();
} else if (e.GetKeyCode() == WXK_DOWN && e.GetModifiers() == wxMOD_SHIFT) {
program->setUndoPoint(ctAll);
program->shiftDown();
setDirty();
} else if (e.GetKeyCode() == WXK_BACK && e.GetModifiers() == wxMOD_ALT) { // undo
wxCommandEvent evt(wxEVT_NULL, 0);
onMenuEditUndo(evt);
} else {
e.Skip();
}

View File

@ -263,6 +263,18 @@ void Program::mirrorX() { // copy left to right
map->copyXY(w-i-1,j , i,j);
}
}
// move players
for (int i = 0; i < map->getMaxFactions(); ++i) // first remove players from target corner
if (map->getStartLocationX(i) >= w/2) map->changeStartLocation(0,0,i);
for (int i = 0; i < map->getMaxFactions(); ++i) {
if((map->getStartLocationX(i) < w/2) && (map->getStartLocationX(i)!=0 || map->getStartLocationY(i)!=0)) // any startpositions to copy?
for (int ii = 0; ii < map->getMaxFactions(); ++ii)
if(map->getStartLocationX(ii)==0 && map->getStartLocationY(ii)==0) { // first free one
map->changeStartLocation(w-map->getStartLocationX(i)-1, map->getStartLocationY(i), ii);
break;
}
}
}
void Program::mirrorY() { // copy top to bottom
@ -273,6 +285,18 @@ void Program::mirrorY() { // copy top to bottom
map->copyXY(i,h-j-1 , i,j);
}
}
// move players
for (int i = 0; i < map->getMaxFactions(); ++i) // first remove players from target corner
if (map->getStartLocationY(i) >= h/2) map->changeStartLocation(0,0,i);
for (int i = 0; i < map->getMaxFactions(); ++i) {
if((map->getStartLocationY(i) < h/2) && (map->getStartLocationX(i)!=0 || map->getStartLocationY(i)!=0)) // any startpositions to copy?
for (int ii = 0; ii < map->getMaxFactions(); ++ii)
if(map->getStartLocationX(ii)==0 && map->getStartLocationY(ii)==0) { // first free one
map->changeStartLocation(map->getStartLocationX(i), h-map->getStartLocationY(i)-1, ii);
break;
}
}
}
void Program::mirrorXY() { // copy leftbottom to topright, can handle non-sqaure maps
@ -302,6 +326,18 @@ void Program::mirrorXY() { // copy leftbottom to topright, can handle non-sqaure
}
}
}
// move players
for (int i = 0; i < map->getMaxFactions(); ++i) // first remove players from target corner
if (map->getStartLocationX(i) > map->getStartLocationY(i)) map->changeStartLocation(0,0,i);
for (int i = 0; i < map->getMaxFactions(); ++i) {
if(map->getStartLocationX(i) < map->getStartLocationY(i)) // any startpositions to copy?
for (int ii = 0; ii < map->getMaxFactions(); ++ii)
if(map->getStartLocationX(ii)==0 && map->getStartLocationY(ii) == 0) { // first free one
map->changeStartLocation(map->getStartLocationY(i)*w/h, map->getStartLocationX(i)*h/w, ii);
break;
}
}
}
void Program::rotatecopyX() {
@ -312,6 +348,18 @@ void Program::rotatecopyX() {
map->copyXY(w-i-1,h-j-1 , i,j);
}
}
// move players
for (int i = 0; i < map->getMaxFactions(); ++i) // first remove players from target corner
if (map->getStartLocationX(i) >= w/2) map->changeStartLocation(0,0,i);
for (int i = 0; i < map->getMaxFactions(); ++i) {
if((map->getStartLocationX(i) < w/2) && (map->getStartLocationX(i)!=0 || map->getStartLocationY(i)!=0)) // any startpositions to copy?
for (int ii = 0; ii < map->getMaxFactions(); ++ii)
if(map->getStartLocationX(ii)==0 && map->getStartLocationY(ii)==0) { // first free one
map->changeStartLocation(w-map->getStartLocationX(i)-1, h-map->getStartLocationY(i)-1, ii);
break;
}
}
}
void Program::rotatecopyY() {
@ -322,6 +370,18 @@ void Program::rotatecopyY() {
map->copyXY(w-i-1,h-j-1 , i,j);
}
}
// move players
for (int i = 0; i < map->getMaxFactions(); ++i) // first remove players from target corner
if (map->getStartLocationY(i) >= h/2) map->changeStartLocation(0,0,i);
for (int i = 0; i < map->getMaxFactions(); ++i) {
if((map->getStartLocationY(i) < h/2) && (map->getStartLocationX(i)!=0 || map->getStartLocationY(i)!=0)) // any startpositions to copy?
for (int ii = 0; ii < map->getMaxFactions(); ++ii)
if(map->getStartLocationX(ii)==0 && map->getStartLocationY(ii)==0) { // first free one
map->changeStartLocation(w-map->getStartLocationX(i)-1, h-map->getStartLocationY(i)-1, ii);
break;
}
}
}
void Program::rotatecopyXY() {
@ -341,6 +401,18 @@ void Program::rotatecopyXY() {
map->copyXY(w-i-1,j , i,h-j-1);
}
}
// move players
for (int i = 0; i < map->getMaxFactions(); ++i) // first remove players from target corner
if (map->getStartLocationX(i) > map->getStartLocationY(i)) map->changeStartLocation(0,0,i);
for (int i = 0; i < map->getMaxFactions(); ++i) {
if(map->getStartLocationX(i) < map->getStartLocationY(i)) // any startpositions to copy?
for (int ii = 0; ii < map->getMaxFactions(); ++ii)
if(map->getStartLocationX(ii)==0 && map->getStartLocationY(ii) == 0) { // first free one
map->changeStartLocation(w-map->getStartLocationX(i)-1, h-map->getStartLocationY(i)-1, ii);
break;
}
}
}
void Program::rotatecopyCorner() { // rotate top left 1/4 to top right 1/4
@ -370,6 +442,58 @@ void Program::rotatecopyCorner() { // rotate top left 1/4 to top right 1/4
}
}
}
// move players
for (int i = 0; i < map->getMaxFactions(); ++i) // first remove players from target corner
if (map->getStartLocationX(i) >= w/2 && map->getStartLocationY(i) < h/2) map->changeStartLocation(0,0,i);
for (int i = 0; i < map->getMaxFactions(); ++i) {
if((map->getStartLocationX(i) < w/2 && map->getStartLocationY(i) < h/2) && (map->getStartLocationX(i)!=0 || map->getStartLocationY(i)!=0)) // any startpositions to copy?
for (int ii = 0; ii < map->getMaxFactions(); ++ii)
if(map->getStartLocationX(ii)==0 && map->getStartLocationY(ii)==0) { // first free one
map->changeStartLocation(w-map->getStartLocationY(i)*w/h-1, map->getStartLocationX(i)*h/w, ii);
break;
}
}
}
void Program::shiftLeft() {
int w=map->getW()-1;
int h=map->getH();
for (int i=0; i<w; i++)
for (int j=0; j<h; j++)
map->copyXY(i,j , i+1,j);
for (int i = 0; i < map->getMaxFactions(); ++i) // move players
map->changeStartLocation(map->getStartLocationX(i)-1, map->getStartLocationY(i), i); // it allready check limits
}
void Program::shiftRight() {
int w=map->getW()-1;
int h=map->getH();
for (int i=w; i>0; i--)
for (int j=0; j<h; j++)
map->copyXY(i,j , i-1,j);
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->getStartLocationX(i)+1, map->getStartLocationY(i), i); // it allready check limits
}
void Program::shiftUp() {
int w=map->getW();
int h=map->getH()-1;
for (int i=0; i<w; i++)
for (int j=0; j<h; j++)
map->copyXY(i,j , i,j+1);
for (int i = 0; i < map->getMaxFactions(); ++i) // move players
map->changeStartLocation(map->getStartLocationX(i), map->getStartLocationY(i)-1, i); // it allready check limits
}
void Program::shiftDown() {
int w=map->getW();
int h=map->getH()-1;
for (int i=0; i<w; i++)
for (int j=h; j>0; j--)
map->copyXY(i,j , i,j-1);
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->getStartLocationX(i), map->getStartLocationY(i)+1, i); // it allready check limits
}

View File

@ -133,7 +133,10 @@ public:
void rotatecopyY();
void rotatecopyXY();
void rotatecopyCorner();
void shiftLeft();
void shiftRight();
void shiftUp();
void shiftDown();
void randomizeMapHeights();
void randomizeMap();