Store sign locations and text in the same structure

This commit is contained in:
2015-02-06 14:43:26 -05:00
parent efe03b977f
commit 7f6992da56
11 changed files with 65 additions and 66 deletions

View File

@@ -1105,10 +1105,10 @@ void do_sign(short town_num, short which_sign, short sign_type) {
if(town_num >= 200) {
town_num -= 200;
sign_text = univ.out->sign_strs[which_sign];
sign_text = univ.out->sign_locs[which_sign].text;
}
else {
sign_text = univ.town->sign_strs[which_sign];
sign_text = univ.town->sign_locs[which_sign].text;
}
sign->getControl("sign").setText(sign_text);

View File

@@ -80,6 +80,10 @@ struct info_rect_t : public rectangle {
std::string descr;
};
struct sign_loc_t : public location {
std::string text;
};
struct spec_loc_t : public location {
long spec;

View File

@@ -123,7 +123,6 @@ cOutdoors::cWandering::cWandering() {
cOutdoors::cOutdoors(cScenario& scenario, bool init_strings) : scenario(scenario) {
short i,j;
location d_loc(100,0);
location locs[4] = {loc(8,8),loc(32,8),loc(8,32),loc(32,32)};
bg_out = bg_fight = bg_town = bg_dungeon = -1;
@@ -134,8 +133,8 @@ cOutdoors::cOutdoors(cScenario& scenario, bool init_strings) : scenario(scenario
}
for(i = 0; i < 8; i++) {
exit_locs[i] = d_loc;
sign_locs[i] = d_loc;
exit_locs[i].x = 100;
sign_locs[i].x = 100;
}
for(i = 0; i < 4; i++) {
wandering_locs[i] = locs[i];
@@ -150,7 +149,7 @@ cOutdoors::cOutdoors(cScenario& scenario, bool init_strings) : scenario(scenario
else if(i >= 10 && i < 100)
spec_strs[i-10] = temp_str;
else if(i >= 100 && i < 108)
sign_strs[i-100] = temp_str;
sign_locs[i-100].text = temp_str;
}
}

View File

@@ -62,7 +62,7 @@ public:
ter_num_t terrain[48][48];
std::vector<spec_loc_t> special_locs;
std::array<spec_loc_t,8> exit_locs;
std::array<location,8> sign_locs;
std::array<sign_loc_t,8> sign_locs;
std::array<cWandering,4> wandering, special_enc;
location wandering_locs[4];
std::vector<cSpecial> specials;
@@ -72,7 +72,6 @@ public:
std::array<info_rect_t,8> info_rect;
std::string comment;
std::array<std::string,90> spec_strs;
std::array<std::string,8> sign_strs;
bool special_spot[48][48];
eAmbientSound ambient_sound;
snd_num_t out_sound;

View File

@@ -76,18 +76,17 @@ void cTown::append(legacy::town_record_type& old){
cTown::cTown(cScenario& scenario, bool init_strings) : scenario(scenario) {
short i;
location d_loc(100,0);
cTown::cWandering d_wan = {0,0,0,0};
town_chop_time = -1;
town_chop_key = -1;
for(i = 0; i < 4; i++) {
wandering[i] = d_wan;
wandering_locs[i] = d_loc;
wandering_locs[i].x = 100;
}
lighting_type = LIGHT_NORMAL;
for(i = 0; i < 4; i++) {
start_locs[i] = d_loc;
start_locs[i].x = 100;
exit_specs[i] = -1;
exit_locs[i].x = -1;
exit_locs[i].y = -1;
@@ -96,7 +95,6 @@ cTown::cTown(cScenario& scenario, bool init_strings) : scenario(scenario) {
spec_on_entry = -1;
spec_on_entry_if_dead = -1;
for(i = 0; i < 15; i++) {
sign_locs[i] = d_loc;
sign_locs[i].x = 100;
}
for(i = 0; i < 8; i++) {
@@ -132,7 +130,7 @@ cTown::cTown(cScenario& scenario, bool init_strings) : scenario(scenario) {
else if(i >= 20 && i < 120)
spec_strs[i-20] = temp_str;
else if(i >= 120 && i < 140)
sign_strs[i-120] = temp_str;
sign_locs[i-120].text = temp_str;
}
for(i = 0; i < 10; i++) {

View File

@@ -74,7 +74,7 @@ public:
cWandering wandering[4];
location wandering_locs[4];
std::vector<spec_loc_t> special_locs;
std::array<location,15> sign_locs;
std::array<sign_loc_t,20> sign_locs;
eLighting lighting_type;
location start_locs[4];
location exit_locs[4];
@@ -102,7 +102,6 @@ public:
std::array<info_rect_t,16> room_rect;
std::array<std::string,3> comment;
std::array<std::string,100> spec_strs;
std::array<std::string,20> sign_strs;
cSpeech talking;
virtual ~cTown(){}

View File

@@ -1707,7 +1707,7 @@ void set_terrain(location l,ter_num_t terrain_type) {
}
}
if(which_sign >= 0) {
town->sign_locs[which_sign] = l;
static_cast<location&>(town->sign_locs[which_sign]) = l;
edit_sign(which_sign,scenario.ter_types[terrain_type].picture);
sign_error_received = false;
}
@@ -1742,7 +1742,7 @@ void set_terrain(location l,ter_num_t terrain_type) {
}
}
if(which_sign >= 0) {
current_terrain->sign_locs[which_sign] = l;
static_cast<location&>(current_terrain->sign_locs[which_sign]) = l;
edit_sign(which_sign,scenario.ter_types[terrain_type].picture);
sign_error_received = false;
}
@@ -2331,11 +2331,11 @@ void start_string_editing(short mode,short just_redo_text) {
set_rb(i,RB_JOURNAL, i,str.str());
break;
case 4:
str << i << " - " << current_terrain->sign_strs[i].substr(0,30);
str << i << " - " << current_terrain->sign_locs[i].text.substr(0,30);
set_rb(i,RB_OUT_SIGN, i,str.str());
break;
case 5:
str << i << " - " << town->sign_strs[i].substr(0,30);
str << i << " - " << town->sign_locs[i].text.substr(0,30);
set_rb(i,RB_TOWN_SIGN, i,str.str());
break;
}

View File

@@ -588,8 +588,8 @@ static void writeOutdoorsToXml(ticpp::Printer&& data, cOutdoors& sector) {
for(auto& enc : sector.wandering)
data.PushElement("wandering", enc);
data.OpenElement("signs");
for(auto& sign : sector.sign_strs)
data.PushElement("string", sign);
for(auto& sign : sector.sign_locs)
data.PushElement("string", sign.text);
data.CloseElement("signs");
data.OpenElement("descriptions");
for(auto& area : sector.info_rect) {
@@ -722,11 +722,11 @@ static void writeTownToXml(ticpp::Printer&& data, cTown& town) {
if(!area.descr.empty() && area.top < area.bottom && area.left < area.right)
data.PushElement("description", area);
}
for(size_t i = 0; i < town.sign_strs.size(); i++) {
if(town.sign_strs[i].empty()) continue;
for(size_t i = 0; i < town.sign_locs.size(); i++) {
if(town.sign_locs[i].text.empty()) continue;
data.OpenElement("sign");
data.PushAttribute("id", i);
data.PushText(town.sign_strs[i]);
data.PushText(town.sign_locs[i].text);
data.CloseElement("sign");
}
for(size_t i = 0; i < town.spec_strs.size(); i++) {
@@ -801,8 +801,8 @@ static map_data buildOutMapData(location which) {
if(sector.exit_locs[i].spec >= 0)
terrain.addFeature(sector.exit_locs[i].x, sector.exit_locs[i].y, eMapFeature::TOWN, sector.exit_locs[i].spec);
}
for(size_t i = 0; i < sector.sign_strs.size(); i++) {
if(!sector.sign_strs[i].empty())
for(size_t i = 0; i < sector.sign_locs.size(); i++) {
if(!sector.sign_locs[i].text.empty())
terrain.addFeature(sector.sign_locs[i].x, sector.sign_locs[i].y, eMapFeature::SIGN, i);
}
for(size_t i = 0; i < 4; i++) {
@@ -837,8 +837,8 @@ static map_data buildTownMapData(size_t which) {
if(town.special_locs[i].spec >= 0)
terrain.addFeature(town.special_locs[i].x, town.special_locs[i].y, eMapFeature::SPECIAL_NODE, town.special_locs[i].spec);
}
for(size_t i = 0; i < town.sign_strs.size(); i++) {
if(!town.sign_strs[i].empty())
for(size_t i = 0; i < town.sign_locs.size(); i++) {
if(!town.sign_locs[i].text.empty())
terrain.addFeature(town.sign_locs[i].x, town.sign_locs[i].y, eMapFeature::SIGN, i);
}
for(size_t i = 0; i < 4; i++) {
@@ -1099,8 +1099,8 @@ void scen_text_dump(){
if(scenario.outdoors[out_sec.x][out_sec.y]->spec_strs[i][0] != '*')
fout << " Message " << i << ": " << scenario.outdoors[out_sec.x][out_sec.y]->spec_strs[i] << endl;
for(i = 0; i < 8; i++)
if(scenario.outdoors[out_sec.x][out_sec.y]->sign_strs[i][0] != '*')
fout << " Sign " << i << ": " << scenario.outdoors[out_sec.x][out_sec.y]->sign_strs[i] << endl;
if(scenario.outdoors[out_sec.x][out_sec.y]->sign_locs[i].text[0] != '*')
fout << " Sign " << i << ": " << scenario.outdoors[out_sec.x][out_sec.y]->sign_locs[i].text << endl;
fout << endl;
}
}
@@ -1122,8 +1122,8 @@ void scen_text_dump(){
fout << " Message " << i << ": " << scenario.towns[i]->spec_strs[i] << endl;
fout << " Name: " << scenario.towns[i]->town_name << endl;
for(i = 0; i < 20; i++)
if(scenario.towns[i]->sign_strs[i][0] != '*')
fout << " Sign " << i << ": " << scenario.towns[i]->sign_strs[i] << endl;
if(scenario.towns[i]->sign_locs[i].text[0] != '*')
fout << " Sign " << i << ": " << scenario.towns[i]->sign_locs[i].text << endl;
fout << endl << " Town Dialogue:" << endl;
for(i = 0; i < 10; i++) {
fout << " Personality " << j + i << " (" << scenario.towns[i]->talking.people[i].title << "): " << endl;

View File

@@ -34,8 +34,8 @@ size_t num_strs(short str_mode) {
case 1: return current_terrain->spec_strs.size();
case 2: return town->spec_strs.size();
case 3: return scenario.journal_strs.size();
case 4: return current_terrain->sign_strs.size();
case 5: return town->sign_strs.size();
case 4: return current_terrain->sign_locs.size();
case 5: return town->sign_locs.size();
}
return 0;
}
@@ -352,9 +352,9 @@ static bool edit_text_event_filter(cDialog& me, std::string item_hit, short& whi
if(str_mode == 3)
scenario.journal_strs[which_str] = newVal;
if(str_mode == 4)
current_terrain->sign_strs[which_str] = newVal;
current_terrain->sign_locs[which_str].text = newVal;
if(str_mode == 5)
town->sign_strs[which_str] = newVal;
town->sign_locs[which_str].text = newVal;
if(item_hit == "okay") me.toast(true);
else if(item_hit == "left" || item_hit == "right") {
if(item_hit[0] == 'l')
@@ -373,9 +373,9 @@ static bool edit_text_event_filter(cDialog& me, std::string item_hit, short& whi
if(str_mode == 3)
me["text"].setText(scenario.journal_strs[which_str]);
if(str_mode == 4)
me["text"].setText(current_terrain->sign_strs[which_str]);
me["text"].setText(current_terrain->sign_locs[which_str].text);
if(str_mode == 5)
me["text"].setText(town->sign_strs[which_str]);
me["text"].setText(town->sign_locs[which_str].text);
return true;
}
@@ -396,9 +396,9 @@ void edit_text_str(short which_str,short mode) {
if(mode == 3)
dlog["text"].setText(scenario.journal_strs[which_str]);
if(mode == 4)
dlog["text"].setText(current_terrain->sign_strs[which_str]);
dlog["text"].setText(current_terrain->sign_locs[which_str].text);
if(mode == 5)
dlog["text"].setText(town->sign_strs[which_str]);
dlog["text"].setText(town->sign_locs[which_str].text);
dlog.run();
}
@@ -929,13 +929,13 @@ static bool edit_spec_text_event_filter(cDialog& me, std::string item_hit, short
}
break;
case 4:
if(current_terrain->sign_strs[i][0] == '*') {
if(current_terrain->sign_locs[i].text[0] == '*') {
*str1 = i;
i = 500;
}
break;
case 5:
if(town->sign_strs[i][0] == '*') {
if(town->sign_locs[i].text[0] == '*') {
*str1 = i;
i = 500;
}
@@ -962,10 +962,10 @@ static bool edit_spec_text_event_filter(cDialog& me, std::string item_hit, short
scenario.journal_strs[*str1] = str;
break;
case 4:
current_terrain->sign_strs[*str1] = str;
current_terrain->sign_locs[*str1].text = str;
break;
case 5:
town->sign_strs[*str1] = str;
town->sign_locs[*str1].text = str;
break;
}
}
@@ -1001,13 +1001,13 @@ static bool edit_spec_text_event_filter(cDialog& me, std::string item_hit, short
}
break;
case 4:
if(current_terrain->sign_strs[i][0] == '*') {
if(current_terrain->sign_locs[i].text[0] == '*') {
*str2 = i;
i = 500;
}
break;
case 5:
if(town->sign_strs[i][0] == '*') {
if(town->sign_locs[i].text[0] == '*') {
*str2 = i;
i = 500;
}
@@ -1035,10 +1035,10 @@ static bool edit_spec_text_event_filter(cDialog& me, std::string item_hit, short
scenario.journal_strs[*str2] = str;
break;
case 4:
current_terrain->sign_strs[*str2] = str;
current_terrain->sign_locs[*str2].text = str;
break;
case 5:
town->sign_strs[*str2] = str;
town->sign_locs[*str2].text = str;
break;
}
}
@@ -1068,9 +1068,9 @@ void edit_spec_text(short mode,short *str1,short *str2,cDialog* parent) {
if(mode == 3)
edit["str1"].setText(scenario.journal_strs[*str1]);
if(mode == 4)
edit["str1"].setText(current_terrain->sign_strs[*str1]);
edit["str1"].setText(current_terrain->sign_locs[*str1].text);
if(mode == 5)
edit["str1"].setText(town->sign_strs[*str1]);
edit["str1"].setText(town->sign_locs[*str1].text);
}
if(str2 != nullptr) {
if(*str2 >= num_s_strs[mode])
@@ -1085,9 +1085,9 @@ void edit_spec_text(short mode,short *str1,short *str2,cDialog* parent) {
if(mode == 3)
edit["str2"].setText(scenario.journal_strs[*str2]);
if(mode == 4)
edit["str2"].setText(current_terrain->sign_strs[*str2]);
edit["str2"].setText(current_terrain->sign_locs[*str2].text);
if(mode == 5)
edit["str2"].setText(town->sign_strs[*str2]);
edit["str2"].setText(town->sign_locs[*str2].text);
}
}
edit.run();
@@ -1116,10 +1116,10 @@ static bool edit_dialog_text_event_filter(cDialog& me, std::string item_hit, sho
scenario.journal_strs[*str1 + i] = str;
break;
case 4:
current_terrain->sign_strs[*str1 + i] = str;
current_terrain->sign_locs[*str1 + i].text = str;
break;
case 5:
town->sign_strs[*str1 + i] = str;
town->sign_locs[*str1 + i].text = str;
break;
}
}
@@ -1158,11 +1158,11 @@ void edit_dialog_text(short mode,short *str1,cDialog* parent) {
j = 500;
break;
case 4:
if(current_terrain->sign_strs[j][0] != '*')
if(current_terrain->sign_locs[j].text[0] != '*')
j = 500;
break;
case 5:
if(town->sign_strs[j][0] != '*')
if(town->sign_locs[j].text[0] != '*')
j = 500;
break;
}
@@ -1187,10 +1187,10 @@ void edit_dialog_text(short mode,short *str1,cDialog* parent) {
scenario.journal_strs[i] = "";
break;
case 4:
current_terrain->sign_strs[i] = "";
current_terrain->sign_locs[i].text = "";
break;
case 5:
town->sign_strs[i] = "";
town->sign_locs[i].text = "";
break;
}
}
@@ -1216,9 +1216,9 @@ void edit_dialog_text(short mode,short *str1,cDialog* parent) {
if(mode == 3)
edit[id].setText(scenario.journal_strs[*str1 + i]);
if(mode == 4)
edit[id].setText(current_terrain->sign_strs[*str1 + i]);
edit[id].setText(current_terrain->sign_locs[*str1 + i].text);
if(mode == 5)
edit[id].setText(town->sign_strs[*str1 + i]);
edit[id].setText(town->sign_locs[*str1 + i].text);
}
}

View File

@@ -328,8 +328,8 @@ void edit_placed_item(short which_i) {
static bool edit_sign_event_filter(cDialog& me, short which_sign) {
if(!me.toast(true)) return true;
if(editing_town)
town->sign_strs[which_sign] = me["text"].getText();
else current_terrain->sign_strs[which_sign] = me["text"].getText();
town->sign_locs[which_sign].text = me["text"].getText();
else current_terrain->sign_locs[which_sign].text = me["text"].getText();
#if 0 // TODO: Apparently there used to be left/right buttons on this dialog.
if(item_hit == 3)
which_sign--;
@@ -358,8 +358,8 @@ void edit_sign(short which_sign,short picture) {
sign_dlg["num"].setTextToNum(which_sign);
if(!editing_town)
sign_dlg["text"].setText(current_terrain->sign_strs[which_sign]);
else sign_dlg["text"].setText(town->sign_strs[which_sign]);
sign_dlg["text"].setText(current_terrain->sign_locs[which_sign].text);
else sign_dlg["text"].setText(town->sign_locs[which_sign].text);
sign_dlg.run();
}

View File

@@ -362,7 +362,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
else if(i >= 20 && i < 120)
the_town.spec_strs[i-20] = temp_str;
else if(i >= 120 && i < 140)
the_town.sign_strs[i-120] = temp_str;
the_town.sign_locs[i-120].text = temp_str;
}
len = sizeof(legacy::talking_record_type);
@@ -496,7 +496,7 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out,
else if(i >= 10 && i < 100)
the_out.spec_strs[i-10] = temp_str;
else if(i >= 100 && i < 108)
the_out.sign_strs[i-100] = temp_str;
the_out.sign_locs[i-100].text = temp_str;
}
n = fclose(file_id);