map editor has much more powerful random height function

You can give parameters now, to influence the map height calculation.
This commit is contained in:
titiger
2015-02-10 02:06:02 +01:00
parent b4fabc2717
commit 4c5440f78c
6 changed files with 120 additions and 68 deletions

View File

@@ -103,6 +103,13 @@ MainWindow::MainWindow(string appPath)
resourceUnderMouse=0;
objectUnderMouse=0;
// default values for random height calculation that turned out to be quite useful
randomWithReset=true;
randomMinimumHeight=-300;
randomMaximumHeight=400;
randomChanceDevider=30;
randomRecursions=3;
this->appPath = appPath;
Properties::setApplicationPath(executable_path(appPath));
@@ -187,7 +194,7 @@ void MainWindow::init(string fname) {
// ---------------------------------------------------------
menuEdit->Append(miEditRandomizeHeights, wxT("Randomize &Heights"));
menuEdit->Append(miEditRandomize, wxT("Randomi&ze Heights/Players"));
menuEdit->Append(miEditRandomize, wxT("Randomi&ze Players"));
menuEdit->Append(miEditSwitchSurfaces, wxT("Switch Sur&faces..."));
menuEdit->Append(miEditInfo, wxT("&Info..."));
menuEdit->Append(miEditAdvanced, wxT("&Advanced..."));
@@ -985,10 +992,40 @@ void MainWindow::onMenuEditRandomizeHeights(wxCommandEvent &event) {
if(program == NULL) {
return;
}
while(true){
program->setUndoPoint(ctAll);//randomizeHeights(-300,400,30,3);
program->setUndoPoint(ctAll);
program->randomizeMapHeights();
setDirty();
SimpleDialog simpleDialog;
simpleDialog.addValue("Initial Reset", boolToStr(randomWithReset),"If set to '0' no height reset is done before calculating");
simpleDialog.addValue("Min Height", intToStr(randomMinimumHeight),"Lowest random height. example: -300 or below if you want water , 0 if you don't want water.");
simpleDialog.addValue("Max Height", intToStr(randomMaximumHeight),"Max random height. A good value is 400");
simpleDialog.addValue("Chance Devider", intToStr(randomChanceDevider),"Defines how often you get a hill or hole default is 30. Bigger number, less hills/holes.");
simpleDialog.addValue("Smooth Recursions", intToStr(randomRecursions),"Number of recursions cycles to smooth the hills and holes. 0<x<50 default is 3.");
if (!simpleDialog.show("Randomize Height")) return;
try {
randomWithReset=strToBool(simpleDialog.getValue("Initial Reset"));
randomMinimumHeight=strToInt(simpleDialog.getValue("Min Height"));
randomMaximumHeight=strToInt(simpleDialog.getValue("Max Height"));
randomChanceDevider=strToInt(simpleDialog.getValue("Chance Devider"));
randomRecursions=strToInt(simpleDialog.getValue("Smooth Recursions"));
// set insane inputs to something that does not crash
if(randomMinimumHeight>=randomMaximumHeight) randomMinimumHeight=randomMaximumHeight-1;
if(randomChanceDevider<1) randomChanceDevider=1;
// set randomRecursions to something useful
if(randomRecursions<0) randomRecursions=0;
if(randomRecursions>50) randomRecursions=50;
program->randomizeMapHeights(randomWithReset, randomMinimumHeight, randomMaximumHeight,
randomChanceDevider, randomRecursions);
}
catch (const exception &e) {
MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
}
setDirty();
}
}
void MainWindow::onMenuEditRandomize(wxCommandEvent &event) {
@@ -997,7 +1034,7 @@ void MainWindow::onMenuEditRandomize(wxCommandEvent &event) {
}
program->setUndoPoint(ctAll);
program->randomizeMap();
program->randomizeFactions();
setDirty();
}