undo/redo for town details
This commit is contained in:
@@ -185,7 +185,7 @@ public:
|
||||
std::istream& operator>> (std::istream& in, eContentRating& rating);
|
||||
std::ostream& operator<< (std::ostream& out, eContentRating rating);
|
||||
|
||||
// Store a version the scenario details for undo history.
|
||||
// Store a version of the scenario details for undo history.
|
||||
// This could be made a struct that cScenario contains, and that would eliminate the next 2 functions, but it would
|
||||
// require changing every reference to these detail values in the game and fileio code, making them more verbose. I don't know
|
||||
// if that's worth it.
|
||||
@@ -234,7 +234,7 @@ inline void scen_set_details(cScenario& scen, const scen_details_t& details) {
|
||||
scen.contact_info[i] = details.contact_info[i];
|
||||
}
|
||||
|
||||
// Store a version the scenario intro text/icon# for undo history.
|
||||
// Store a version of the scenario intro text/icon# for undo history.
|
||||
// This could be made a struct that cScenario contains, and that would eliminate the next 2 functions, but it would
|
||||
// require changing every reference to these detail values in the game and fileio code, making them more verbose. I don't know
|
||||
// if that's worth it.
|
||||
@@ -260,7 +260,7 @@ inline void scen_set_intro(cScenario& scen, const scen_intro_t& details) {
|
||||
scen.intro_strs = details.intro_strs;
|
||||
}
|
||||
|
||||
// Store a version the scenario advanced details for undo history.
|
||||
// Store a version of the scenario advanced details for undo history.
|
||||
// This could be made a struct that cScenario contains, and that would eliminate the next 2 functions, but it would
|
||||
// require changing every reference to these detail values in the game and fileio code, making them more verbose. I don't know
|
||||
// if that's worth it.
|
||||
|
@@ -132,4 +132,53 @@ public:
|
||||
std::ostream& operator<< (std::ostream& out, eLighting light);
|
||||
std::istream& operator>> (std::istream& in, eLighting& light);
|
||||
|
||||
// Store a version of the town details for undo history.
|
||||
// This could be made a struct that cTown contains, and that would eliminate the next 2 functions, but it would
|
||||
// require changing every reference to these detail values in the game and fileio code, making them more verbose. I don't know
|
||||
// if that's worth it.
|
||||
struct town_details_t {
|
||||
std::string name;
|
||||
short town_chop_time;
|
||||
short town_chop_key;
|
||||
long max_num_monst;
|
||||
short difficulty;
|
||||
eLighting lighting_type;
|
||||
std::array<std::string,3> comment;
|
||||
|
||||
bool operator==(const town_details_t& other) const {
|
||||
CHECK_EQ(other,name);
|
||||
CHECK_EQ(other,town_chop_key);
|
||||
CHECK_EQ(other,max_num_monst);
|
||||
CHECK_EQ(other,difficulty);
|
||||
CHECK_EQ(other,lighting_type);
|
||||
for(int i = 0; i < comment.size(); ++i){
|
||||
if(other.comment[i] != comment[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool operator!=(const town_details_t& other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
inline town_details_t details_from_town(cTown& town) {
|
||||
return {
|
||||
town.name,
|
||||
town.town_chop_time,
|
||||
town.town_chop_key,
|
||||
town.max_num_monst,
|
||||
town.difficulty,
|
||||
town.lighting_type,
|
||||
town.comment
|
||||
};
|
||||
}
|
||||
|
||||
inline void town_set_details(cTown& town, const town_details_t& details) {
|
||||
town.name = details.name;
|
||||
town.town_chop_time = details.town_chop_time;
|
||||
town.town_chop_key = details.town_chop_key;
|
||||
town.max_num_monst = details.max_num_monst;
|
||||
town.difficulty = details.difficulty;
|
||||
town.lighting_type = details.lighting_type;
|
||||
town.comment = details.comment;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user