Fixed a CVS-only problem with buttons that disappeared in the editor.

Made the new map dialog a bit faster and fixed a CVS-only problem
where its buttons disappeared.
This commit is contained in:
Kristoffer Erlandsson 2004-05-08 10:42:21 +00:00
parent 373fd7b49e
commit afd5c4ad07
4 changed files with 61 additions and 51 deletions

View file

@ -167,7 +167,7 @@ height=600
[menu]
title=main_menu
image=lite
items=editnewmap,editloadmap,editrevert,undo,redo,editsavemap,editsaveas,togglegrid,editquit,
items=editnewmap,editloadmap,editrevert,undo,redo,editsavemap,editsaveas,togglegrid,editquit
rect=3,1,107,22
xanchor=fixed
yanchor=fixed

View file

@ -95,7 +95,10 @@ map_editor::map_editor(display &gui, gamemap &map, config &theme, config &game_c
reports::set_report_content(reports::SELECTED_TERRAIN,
get_terrain_string(palette_.selected_terrain()));
gui_.begin_game();
gui_.invalidate_all();
gui_.draw();
events::raise_draw_event();
}
void map_editor::handle_event(const SDL_Event &event) {
@ -941,6 +944,7 @@ void map_editor::main_loop() {
gui_.draw(false);
palette_.draw();
brush_.draw();
events::raise_draw_event();
if(tup_.process(mousex,mousey,l_button_down)) {
palette_.scroll_up();

View file

@ -127,34 +127,37 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
}
if(new_map_button.process(mousex,mousey,left_button)) {
if ((confirmation_needed &&
confirm_modification_disposal(disp))
|| !confirmation_needed) {
int i;
std::stringstream str;
std::stringstream map_str;
for (i = 0; i < width_slider.value(); i++) {
str << fill_terrain;
}
str << "\n";
for (i = 0; i < height_slider.value(); i++) {
map_str << str.str();
}
return map_str.str();
draw = true;
if ((confirmation_needed &&
confirm_modification_disposal(disp))
|| !confirmation_needed) {
int i;
std::stringstream str;
std::stringstream map_str;
for (i = 0; i < width_slider.value(); i++) {
str << fill_terrain;
}
str << "\n";
for (i = 0; i < height_slider.value(); i++) {
map_str << str.str();
}
return map_str.str();
}
}
if(random_map_setting_button.process(mousex,mousey,left_button)) {
draw = true;
if (generator.get()->allow_user_config()) {
generator.get()->user_config(disp);
}
}
if(random_map_button.process(mousex,mousey,left_button)) {
if ((confirmation_needed
&& confirm_modification_disposal(disp))
|| !confirmation_needed) {
const std::string map = generator.get()->create_map(std::vector<std::string>());
draw = true;
if ((confirmation_needed
&& confirm_modification_disposal(disp))
|| !confirmation_needed) {
const std::string map = generator.get()->create_map(std::vector<std::string>());
if (map == "") {
gui::show_dialog(disp, NULL, "Creation Failed",
"Map creation failed.", gui::OK_ONLY);
@ -162,13 +165,38 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
return map;
}
}
map_width = width_slider.value();
map_height = height_slider.value();
if (width_slider.value() != map_width
|| height_slider.value() != map_height) {
draw = true;
}
if (draw) {
map_width = width_slider.value();
map_height = height_slider.value();
gui::draw_dialog_frame(xpos,ypos,width,height,disp);
title_rect = font::draw_text(&disp,disp.screen_area(),24,font::NORMAL_COLOUR,
"Create New Map",xpos+(width-title_rect.w)/2,ypos+10);
gui::draw_dialog_frame(xpos,ypos,width,height,disp);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,
width_label,width_rect.x,width_rect.y);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,
height_label,height_rect.x,height_rect.y);
std::stringstream width_str;
width_str << map_width;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
slider_right+horz_margin,width_rect.y);
std::stringstream height_str;
height_str << map_height;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
slider_right+horz_margin,height_rect.y);
}
width_slider.process();
height_slider.process();
new_map_button.set_dirty();
random_map_button.set_dirty();
random_map_setting_button.set_dirty();
cancel_button.set_dirty();
width_slider.set_min(min_width);
height_slider.set_min(min_width);
@ -176,31 +204,9 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
events::raise_process_event();
events::raise_draw_event();
title_rect = font::draw_text(&disp,disp.screen_area(),24,font::NORMAL_COLOUR,
"Create New Map",xpos+(width-title_rect.w)/2,ypos+10);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,
width_label,width_rect.x,width_rect.y);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,
height_label,height_rect.x,height_rect.y);
std::stringstream width_str;
width_str << map_width;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
slider_right+horz_margin,width_rect.y);
std::stringstream height_str;
height_str << map_height;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
slider_right+horz_margin,height_rect.y);
new_map_button.draw();
random_map_button.draw();
random_map_setting_button.draw();
cancel_button.draw();
update_rect(xpos,ypos,width,height);
if (draw) {
update_rect(xpos,ypos,width,height);
}
disp.update_display();
SDL_Delay(10);
events::pump();

View file

@ -85,6 +85,7 @@ int main(int argc, char** argv)
theme_cfg = &dummy_theme;
}
std::map<gamemap::location,unit> units;
events::event_context ec;
while (! done) {
try {
gamemap map(cfg, mapdata);
@ -94,7 +95,6 @@ int main(int argc, char** argv)
*theme_cfg, cfg);
gui.set_grid(preferences::grid());
events::event_context ec;
map_editor::map_editor editor(gui, map, *theme_cfg, cfg);
editor.set_file_to_save_as(filename);
editor.main_loop();