Skip to content

Commit

Permalink
FIX: renaming cities, convois and factories works again
Browse files Browse the repository at this point in the history
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11212 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed May 19, 2024
1 parent d1770dc commit b312230
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/simutrans/gui/city_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ void city_info_t::reset_city_name()
tstrncpy(old_name, city->get_name(), sizeof(old_name));
tstrncpy(name, city->get_name(), sizeof(name));
name_input.set_text(name, sizeof(name));
set_name(old_name);
}
}

Expand Down Expand Up @@ -368,8 +369,6 @@ void city_info_t::update_labels()
{
stadt_t* const c = city;

set_name(city->get_name());

// display city stats
lb_size.buf().printf( "%d (%.1f)", c->get_einwohner(), c->get_wachstum() / 10.0); lb_size.update();
lb_buildings.buf().printf( translator::translate("%d buildings\n"), c->get_buildings() ); lb_buildings.update();
Expand Down
11 changes: 9 additions & 2 deletions src/simutrans/gui/components/gui_textinput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,15 @@ void gui_textinput_t::set_text(char *text, size_t max)
this->text = text;
this->max = max;
// whole text is selected by default
head_cursor_pos = strlen(text);
tail_cursor_pos = 0;
size_t len = strlen(text);
if (tail_cursor_pos == head_cursor_pos) {
// if same, keep positions
}
else {
// whole text is selected by default
head_cursor_pos = strlen(text);
tail_cursor_pos = 0;
}
text_dirty = false;
}

Expand Down
1 change: 1 addition & 0 deletions src/simutrans/gui/convoi_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void convoi_info_t::init(convoihandle_t cnv)

input.add_listener(this);
reset_cnv_name();
input.set_notify_all_changes_delay(500);
add_component(&input);

// top part: speedbars, view, buttons
Expand Down
2 changes: 1 addition & 1 deletion src/simutrans/gui/fabrik_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ bool fabrik_info_t::action_triggered( gui_action_creator_t *comp, value_t)
{
if( comp == &input ) {
rename_factory();
return false;
}
else if (comp == &highlight_consumers)
{
Expand Down Expand Up @@ -301,7 +302,6 @@ void fabrik_info_t::update_info()
tstrncpy( fabname, fab->get_name(), lengthof(fabname) );
gui_frame_t::set_name(fab->get_name());
input.set_text( fabname, lengthof(fabname) );

update_components();
}

Expand Down

0 comments on commit b312230

Please sign in to comment.