Store rect descriptions together with their rectangle and remove now-unused string-length members

This commit is contained in:
2015-01-22 15:19:26 -05:00
parent 3e0e3d3b8a
commit 952d81ae5a
18 changed files with 58 additions and 112 deletions

View File

@@ -472,19 +472,19 @@ bool handle_action(location the_point,sf::Event /*event*/) {
else { // MODE_ROOM_RECT
if(editing_town) {
for(x = 0; x < 16; x++)
if(town->room_rect(x).right == 0) {
town->room_rect(x) = working_rect;
town->rect_names[x] = "";
if(town->room_rect[x].right == 0) {
static_cast<rectangle&>(town->room_rect[x]) = working_rect;
town->room_rect[x].descr = "";
if(!edit_area_rect_str(x,1))
town->room_rect(x).right = 0;
town->room_rect[x].right = 0;
x = 500;
}
}
else {
for(x = 0; x < 8; x++)
if(current_terrain->info_rect[x].right == 0) {
current_terrain->info_rect[x] = working_rect;
current_terrain->rect_names[x] = "";
static_cast<rectangle&>(current_terrain->info_rect[x]) = working_rect;
current_terrain->info_rect[x].descr = "";
if(!edit_area_rect_str(x,0))
current_terrain->info_rect[x].right = 0;
x = 500;

View File

@@ -1056,8 +1056,8 @@ void scen_text_dump(){
fout << " Name: " << scenario.outdoors[out_sec.x][out_sec.y]->out_name;
fout << " Comment: " << scenario.outdoors[out_sec.x][out_sec.y]->comment;
for(i = 0; i < 8; i++)
if(scenario.outdoors[out_sec.x][out_sec.y]->rect_names[i][0] != '*')
fout << " Area Rectangle " << i << ": " << scenario.outdoors[out_sec.x][out_sec.y]->rect_names[i] << endl;
if(scenario.outdoors[out_sec.x][out_sec.y]->info_rect[i].descr[0] != '*')
fout << " Area Rectangle " << i << ": " << scenario.outdoors[out_sec.x][out_sec.y]->info_rect[i].descr << endl;
for(i = 0; i < 90; i++)
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;
@@ -1073,8 +1073,8 @@ void scen_text_dump(){
fout << " Town Messages:" << endl;
fout << " Name: " << scenario.towns[i]->town_name << endl;
for(i = 0; i < 16; i++)
if(scenario.towns[i]->rect_names[i][0] != '*')
fout << " Area Rectangle " << i << ": " << scenario.towns[i]->rect_names[i] << endl;
if(scenario.towns[i]->room_rect[i].descr[0] != '*')
fout << " Area Rectangle " << i << ": " << scenario.towns[i]->room_rect[i].descr << endl;
fout << " Name: " << scenario.towns[i]->town_name << endl;
for(i = 0; i < 3; i++)
if(scenario.towns[i]->comment[i][0] != '*')

View File

@@ -777,11 +777,11 @@ void draw_terrain(){
if(editing_town) {
// draw info rects
for(i = 0; i < 16; i++)
if(town->room_rect(i).left > 0) {
draw_rect.left = 22 + 28 * (town->room_rect(i).left - cen_x + 4);
draw_rect.right = 22 + 28 * (town->room_rect(i).right - cen_x + 4);
draw_rect.top = 24 + 36 * (town->room_rect(i).top - cen_y + 4);
draw_rect.bottom = 24 + 36 * (town->room_rect(i).bottom - cen_y + 4);
if(town->room_rect[i].left > 0) {
draw_rect.left = 22 + 28 * (town->room_rect[i].left - cen_x + 4);
draw_rect.right = 22 + 28 * (town->room_rect[i].right - cen_x + 4);
draw_rect.top = 24 + 36 * (town->room_rect[i].top - cen_y + 4);
draw_rect.bottom = 24 + 36 * (town->room_rect[i].bottom - cen_y + 4);
frame_rect(ter_draw_gworld, draw_rect, sf::Color::Red);
}
// draw border rect

View File

@@ -344,8 +344,8 @@ static bool edit_area_rect_event_filter(cDialog& me, std::string item_hit, short
me.toast(true);
std::string str = me["area"].getText().substr(0,29);
if(str_mode == 0)
current_terrain->rect_names[which_str];
else town->rect_names[which_str];
current_terrain->info_rect[which_str].descr;
else town->room_rect[which_str].descr;
} else if(item_hit == "cancel") {
me.setResult(false);
me.toast(false);
@@ -361,8 +361,8 @@ bool edit_area_rect_str(short which_str,short mode) {
dlog.attachClickHandlers(std::bind(edit_area_rect_event_filter, _1, _2, which_str, mode), {"okay", "cancel"});
if(mode == 0)
dlog["area"].setText(current_terrain->rect_names[which_str]);
else dlog["area"].setText(town->rect_names[which_str]);
dlog["area"].setText(current_terrain->info_rect[which_str].descr);
else dlog["area"].setText(town->room_rect[which_str].descr);
dlog.run();

View File

@@ -292,11 +292,11 @@ static bool save_roomdescs(cDialog& me, bool isTown, bool str_do_delete[]) {
for(int i = 0; i < numDescs; i++) {
std::string id = "desc" + std::to_string(i + 1);
if(isTown) {
town->rect_names[i] = me[id].getText().substr(0,30);
town->room_rect[i].descr = me[id].getText().substr(0,30);
if(str_do_delete[i])
town->room_rect(i).right = 0;
town->room_rect[i].right = 0;
} else {
current_terrain->rect_names[i] = me[id].getText().substr(0,30);
current_terrain->info_rect[i].descr = me[id].getText().substr(0,30);
if(str_do_delete[i])
current_terrain->info_rect[i].right = 0;
}
@@ -310,17 +310,17 @@ static void put_roomdescs_in_dlog(cDialog& me, bool isTown, bool str_do_delete[]
std::string id = std::to_string(i + 1);
std::ostringstream str;
bool active = true;
if(isTown && town->room_rect(i).right == 0) active = false;
if(isTown && town->room_rect[i].right == 0) active = false;
if(!isTown && current_terrain->info_rect[i].right == 0) active = false;
if(str_do_delete[i]) active = false;
if(!active) {
str << "Not yet placed.";
me["del" + id].hide();
} else if(isTown) {
me["desc" + id].setText(town->rect_names[i]);
str << "X = " << town->room_rect(i).left << ", Y = " << town->room_rect(i).top;
me["desc" + id].setText(town->room_rect[i].descr);
str << "X = " << town->room_rect[i].left << ", Y = " << town->room_rect[i].top;
} else {
me["desc" + id].setText(current_terrain->rect_names[i]);
me["desc" + id].setText(current_terrain->info_rect[i].descr);
str << "X = " << current_terrain->info_rect[i].left << ", Y = " << current_terrain->info_rect[i].top;
}
me["rect" + id].setText(str.str());