Allow selecting any preset terrain when creating a town.
The option of "grass with flowers" is removed. If you want that, select grass, then select frill up terrain.
This commit is contained in:
@@ -16,15 +16,10 @@
|
||||
<led name='med' anchor='lg' relative='pos-in pos' top='6' left='0'>Medium (48x48)</led>
|
||||
<led name='sm' anchor='med' relative='pos-in pos' top='6' left='0'>Small (32x32)</led>
|
||||
</group>
|
||||
<text anchor='preset' relative='abs pos-in' top='3' left='50' width='105' height='14'>Preset terrain:</text>
|
||||
<!--
|
||||
TODO: Put a field and a Choose button so they can pick any base terrain they want.
|
||||
-->
|
||||
<group name='preset'>
|
||||
<led name='cave' anchor='size' relative='pos-in pos' top='2' left='26' state='red'>Just cave floor</led>
|
||||
<led name='grass' anchor='cave' relative='pos-in pos' top='6' left='0'>Plain Grass</led>
|
||||
<led name='flowers' anchor='grass' relative='pos-in pos' top='6' left='0'>Grass with flowers</led>
|
||||
</group>
|
||||
<button name='cancel' anchor='preset' relative='pos-in pos' type='regular' def-key='esc' top='4' left='38'>Cancel</button>
|
||||
<text anchor='preset' relative='abs pos-in' top='0' left='50' width='105' height='14'>Preset terrain:</text>
|
||||
<pict name='preset' anchor='size' relative='pos-in pos' type='ter' num='0' top='4' left='6'/>
|
||||
<text name='preset-name' anchor='preset' relative='pos pos-in' top='0' left='6' width='120' height='13'/>
|
||||
<button name='choose-preset' anchor='preset' relative='pos pos-in' type='regular' top='14' left='6'>Choose</button>
|
||||
<button name='cancel' anchor='preset' relative='pos-in pos' type='regular' def-key='esc' top='4' left='58'>Cancel</button>
|
||||
<button name='okay' anchor='cancel' relative='pos pos-in' type='regular' top='0' left='0'>OK</button>
|
||||
</dialog>
|
||||
|
@@ -1561,12 +1561,19 @@ aNewTown::~aNewTown() {
|
||||
}
|
||||
|
||||
bool new_town() {
|
||||
ter_num_t preset = 0;
|
||||
cChoiceDlog new_dlg("new-town", {"okay", "cancel"});
|
||||
new_dlg->getControl("num").setTextToNum(scenario.towns.size());
|
||||
new_dlg->getControl("choose-preset").attachClickHandler([&preset](cDialog& me, std::string, eKeyMod) {
|
||||
preset = choose_text(STRT_TER, preset, &me, "Select a preset terrain:");
|
||||
dynamic_cast<cPict&>(me["preset"]).setPict(scenario.ter_types[preset].picture);
|
||||
me["preset-name"].setText(scenario.ter_types[preset].name);
|
||||
return true;
|
||||
});
|
||||
new_dlg->getControl("preset-name").setText(scenario.ter_types[preset].name);
|
||||
if(new_dlg.show() == "cancel") return false;
|
||||
|
||||
std::string size = dynamic_cast<cLedGroup&>(new_dlg->getControl("size")).getSelected();
|
||||
std::string preset = dynamic_cast<cLedGroup&>(new_dlg->getControl("preset")).getSelected();
|
||||
|
||||
if(size == "lg") scenario.addTown(AREA_LARGE);
|
||||
else if(size == "med") scenario.addTown(AREA_MEDIUM);
|
||||
@@ -1577,17 +1584,7 @@ bool new_town() {
|
||||
|
||||
for(short i = 0; i < town->max_dim; i++)
|
||||
for(short j = 0; j < town->max_dim; j++)
|
||||
if(preset == "cave") {
|
||||
town->terrain(i,j) = 0;
|
||||
} else {
|
||||
town->terrain(i,j) = 2;
|
||||
if(preset == "flowers") {
|
||||
if(get_ran(1,0,8) == 0)
|
||||
town->terrain(i,j) = 3;
|
||||
else if(get_ran(1,0,10) == 0)
|
||||
town->terrain(i,j) = 4;
|
||||
}
|
||||
}
|
||||
town->terrain(i,j) = preset;
|
||||
|
||||
undo_list.add(action_ptr(new aNewTown(scenario.towns.back())));
|
||||
change_made = true;
|
||||
|
Reference in New Issue
Block a user