update UI and code to clarify that out wandering locs are shared

This commit is contained in:
2025-06-22 11:19:13 -05:00
parent 8ffd3f2ef6
commit 47ae32aaa9
4 changed files with 66 additions and 36 deletions

View File

@@ -17,9 +17,6 @@
<text name='ally1' framed='true' top='303' left='129' width='145' height='14'/>
<text name='ally2' framed='true' top='327' left='129' width='145' height='14'/>
<text name='ally3' framed='true' top='351' left='129' width='145' height='14'/>
<text name='location' framed='true' top='380' left='129' width='145' height='14'/>
<button name='left' type='left' def-key='left' top='400' left='11'/>
<button name='right' type='right' def-key='right' top='400' left='74'/>
<button name='choose-foe1' type='regular' top='130' left='280'>Choose</button>
<button name='choose-foe2' type='regular' top='154' left='280'>Choose</button>
<button name='choose-foe3' type='regular' top='178' left='280'>Choose</button>
@@ -30,7 +27,6 @@
<button name='choose-ally1' type='regular' top='298' left='280'>Choose</button>
<button name='choose-ally2' type='regular' top='322' left='280'>Choose</button>
<button name='choose-ally3' type='regular' top='346' left='280'>Choose</button>
<button name='choose-location' type='regular' top='375' left='280'>Choose</button>
<button name='edit-meet' type='large' top='186' left='412'>Create/Edit</button>
<button name='edit-win' type='large' top='229' left='412'>Create/Edit</button>
<button name='edit-flee' type='large' top='271' left='412'>Create/Edit</button>
@@ -45,7 +41,6 @@
<text top='303' left='11' width='113' height='14'>Friendly (7-10)</text>
<text top='327' left='11' width='113' height='14'>Friendly (2-4)</text>
<text top='351' left='11' width='113' height='14'>Friendly (1)</text>
<text name='loc-label' size='large' top='380' left='11' width='113' height='14'>Location</text>
<text top='97' left='50' width='127' height='14'>Encounter number:</text>
<text name='num' top='97' left='180' width='35' height='14'/>
<pict type='dlog' num='16' top='8' left='8'/>
@@ -70,7 +65,22 @@
<text top='256' left='352' width='194' height='14'>Special called if party flees</text>
<text top='299' left='352' width='103' height='33'>Stuff done flag to eliminate encounter</text>
<text name='loc-label' size='large' top='380' left='11' width='113' height='14'>Locations</text>
<text name='loc-label2' top='394' left='11' width='113' height='14'>(Any group can appear at any location.)</text>
<text name='loc1' framed='true' top='380' left='129' width='55' height='14'/>
<button name='choose-loc1' type='tiny' relative='pos abs' rel-anchor='prev' top='381' left='7'/>
<text name='loc2' framed='true' relative='pos abs' rel-anchor='prev' top='380' left='10' width='55' height='14'/>
<button name='choose-loc2' type='tiny' relative='pos abs' rel-anchor='prev' top='381' left='7'/>
<text name='loc3' framed='true' relative='pos abs' rel-anchor='prev' top='380' left='10' width='55' height='14'/>
<button name='choose-loc3' type='tiny' relative='pos abs' rel-anchor='prev' top='381' left='7'/>
<text name='loc4' framed='true' top='380' relative='pos abs' rel-anchor='prev' left='10' width='55' height='14'/>
<button name='choose-loc4' type='tiny' relative='pos abs' rel-anchor='prev' top='381' left='7'/>
<button name='left' type='left' def-key='left' top='412' left='11'/>
<button name='right' type='right' def-key='right' top='412' left='74'/>
<!-- OK button -->
<button name='okay' type='regular' top='400' left='489'>OK</button>
<button name='cancel' type='regular' top='400' left='423'>Cancel</button>
<button name='okay' type='regular' top='412' left='489'>OK</button>
<button name='cancel' type='regular' top='412' left='423'>Cancel</button>
</dialog>

View File

@@ -646,7 +646,6 @@ static void put_out_wand_in_dlog(cDialog& me, short which, const cOutdoors::cWan
me["onflee"].setTextToNum(wand.spec_on_flee);
me["endy"].setTextToNum(wand.end_spec1);
me["endx"].setTextToNum(wand.end_spec2);
me["location"].setText(boost::lexical_cast<std::string>(current_terrain->wandering_locs[which]));
}
// mode 0 - wandering, 1 - special, 100 - do not commit changes to the scenario yet
@@ -662,16 +661,13 @@ static void save_out_wand(cDialog& me, short which, cOutdoors::cWandering& wand,
wand.cant_flee = dynamic_cast<cLed&>(me["no-flee"]).getState() != led_off;
switch(mode) {
case 0:{
case 0:
current_terrain->wandering[which] = wand;
location old_loc = current_terrain->wandering_locs[which];
location new_loc = boost::lexical_cast<location>(me["location"].getText());
current_terrain->wandering_locs[which] = new_loc;
undo_list.add(action_ptr(new aEditOutEncounter(cur_out, which, old_wand, old_loc, wand, new_loc)));
}break;
undo_list.add(action_ptr(new aEditOutEncounter(true, cur_out, which, old_wand, wand)));
break;
case 1:
current_terrain->special_enc[which] = wand;
undo_list.add(action_ptr(new aEditOutEncounter(cur_out, which, old_wand, wand)));
undo_list.add(action_ptr(new aEditOutEncounter(false, cur_out, which, old_wand, wand)));
break;
}
update_edit_menu();
@@ -680,9 +676,8 @@ static void save_out_wand(cDialog& me, short which, cOutdoors::cWandering& wand,
static bool edit_out_wand_event_filter(cDialog& me, std::string hit, short& which, cOutdoors::cWandering& wand, short mode) {
if(!me.toast(true)) return true;
bool loc_changed = (mode == 0 && current_terrain->wandering_locs[which] != boost::lexical_cast<location>(me["location"].getText()));
cOutdoors::cWandering old_wand = (mode == 0 ? current_terrain->wandering[which] : current_terrain->special_enc[which]);
if((loc_changed || wand != old_wand)){
if(wand != old_wand){
// Confirm before moving left/right and committing changes
if(hit == "left" || hit == "right"){
cChoiceDlog dlog("confirm-edit-out-wand", {"keep","revert","cancel"}, &me);
@@ -772,18 +767,30 @@ void edit_out_wand(short mode) {
me["endy"].setTextToNum(sdf.y);
return true;
});
wand_dlg["choose-location"].attachClickHandler([&which](cDialog& me, std::string, eKeyMod) {
location current = boost::lexical_cast<location>(me["location"].getText());
current = cLocationPicker(current, *town, "Choose wandering encounter " + std::to_string(which) + " location", &me).run();
me["location"].setText(boost::lexical_cast<std::string>(current));
return true;
});
for(int i = 0; i < current_terrain->wandering_locs.size(); ++i){
wand_dlg["choose-loc" + std::to_string(i+1)].attachClickHandler([&which, i](cDialog& me, std::string, eKeyMod) {
location current = boost::lexical_cast<location>(me["loc" + std::to_string(i+1)].getText());
location new_loc = cLocationPicker(current, *current_terrain, "Choose wandering encounter location " + std::to_string(i+1), &me).run();
if(new_loc != current){
me["loc" + std::to_string(i+1)].setText(boost::lexical_cast<std::string>(new_loc));
current_terrain->wandering_locs[i] = new_loc;
undo_list.add(action_ptr(new aMoveOutEncounterLoc(i, current, new_loc)));
update_edit_menu();
}
return true;
});
wand_dlg["loc" + std::to_string(i+1)].setText(boost::lexical_cast<std::string>(current_terrain->wandering_locs[which]));
if(mode == 1){
wand_dlg["loc" + std::to_string(i+1)].hide();
wand_dlg["choose-loc" + std::to_string(i+1)].hide();
}
}
if(mode == 1){
wand_dlg["title"].setText("Outdoor Special Encounter:");
wand_dlg["loc-label"].hide();
wand_dlg["location"].hide();
wand_dlg["choose-location"].hide();
wand_dlg["loc-label2"].hide();
}
put_out_wand_in_dlog(wand_dlg, which, wand);

View File

@@ -986,7 +986,6 @@ bool aEditOutEncounter::undo_me() {
cOutdoors& outdoors = *scenario.outdoors[out_sec.x][out_sec.y];
auto& encounters = (mode == 0 ? outdoors.wandering : outdoors.special_enc);
encounters[which] = old_enc;
if(mode == 0) outdoors.wandering_locs[which] = old_loc;
return true;
}
@@ -994,7 +993,17 @@ bool aEditOutEncounter::redo_me() {
cOutdoors& outdoors = *scenario.outdoors[out_sec.x][out_sec.y];
auto& encounters = (mode == 0 ? outdoors.wandering : outdoors.special_enc);
encounters[which] = new_enc;
if(mode == 0) outdoors.wandering_locs[which] = new_loc;
return true;
}
// as a cTerrainAction, this one will already have the correct outdoor section active
bool aMoveOutEncounterLoc::undo_me() {
current_terrain->wandering_locs[which] = old_loc;
return true;
}
bool aMoveOutEncounterLoc::redo_me() {
current_terrain->wandering_locs[which] = area.where;
return true;
}

View File

@@ -655,18 +655,22 @@ class aEditOutEncounter : public cAction {
size_t which;
cOutdoors::cWandering old_enc;
cOutdoors::cWandering new_enc;
// Ignored for special encounters:
location old_loc;
location new_loc;
bool undo_me() override;
bool redo_me() override;
public:
aEditOutEncounter(location out_sec, size_t which, cOutdoors::cWandering old_enc, location old_loc, cOutdoors::cWandering new_enc, location new_loc) :
cAction("Edit Outdoor Wandering Encounter"),
out_sec(out_sec), mode(0), which(which), old_enc(old_enc), old_loc(old_loc), new_enc(new_enc), new_loc(new_loc) {}
aEditOutEncounter(location out_sec, size_t which, cOutdoors::cWandering old_enc, cOutdoors::cWandering new_enc) :
cAction("Edit Outdoor Special Encounter"),
out_sec(out_sec), mode(1), which(which), old_enc(old_enc), new_enc(new_enc) {}
aEditOutEncounter(bool wandering, location out_sec, size_t which, cOutdoors::cWandering old_enc, cOutdoors::cWandering new_enc) :
cAction(wandering ? "Edit Outdoor Wandering Encounter" : "Edit Outdoor Special Encounter"),
out_sec(out_sec), mode(wandering ? 0 : 1), which(which), old_enc(old_enc), new_enc(new_enc) {}
};
class aMoveOutEncounterLoc : public cTerrainAction {
size_t which;
location old_loc;
bool undo_me() override;
bool redo_me() override;
public:
aMoveOutEncounterLoc(size_t which, location old_loc, location new_loc) :
cTerrainAction("Move Outdoor Encounter Location", new_loc), which(which), old_loc(old_loc) {}
};
class aEditPersonality : public cAction {