(svn r24739) -Codechange: Simplify some code by using Textbuf::Assign.

This commit is contained in:
frosch 2012-11-14 22:50:21 +00:00
parent f6d4200f86
commit 6653ac6b36
7 changed files with 11 additions and 22 deletions

View File

@ -451,11 +451,10 @@ static void IConsoleHistoryNavigate(int direction)
if (direction > 0 && _iconsole_history[_iconsole_historypos] == NULL) _iconsole_historypos--;
if (_iconsole_historypos == -1) {
*_iconsole_cmdline.buf = '\0';
_iconsole_cmdline.DeleteAll();
} else {
ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[_iconsole_historypos], _iconsole_cmdline.max_bytes);
_iconsole_cmdline.Assign(_iconsole_history[_iconsole_historypos]);
}
_iconsole_cmdline.UpdateSize();
}
/**

View File

@ -567,8 +567,7 @@ public:
}
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO || _saveload_mode == SLD_SAVE_HEIGHTMAP) {
/* Copy clicked name to editbox */
ttd_strlcpy(this->text.buf, file->title, this->text.max_bytes);
this->text.UpdateSize();
this->text.Assign(file->title);
this->SetWidgetDirty(WID_SL_SAVE_OSK_TITLE);
}
} else if (!_load_check_data.HasErrors()) {

View File

@ -547,8 +547,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
case WID_GL_RANDOM_BUTTON: // Random seed
_settings_newgame.game_creation.generation_seed = InteractiveRandom();
snprintf(this->edit_str_buf, this->edit_str_size, "%u", _settings_newgame.game_creation.generation_seed);
this->text.UpdateSize();
this->text.Print("%u", _settings_newgame.game_creation.generation_seed);
this->SetDirty();
break;

View File

@ -437,14 +437,11 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */
if (pre_buf == tb_buf) {
snprintf(tb->buf, this->edit_str_size, "%s: ", cur_name);
this->text.Print("%s: ", cur_name);
} else {
snprintf(tb->buf, this->edit_str_size, "%s %s", pre_buf, cur_name);
this->text.Print("%s %s", pre_buf, cur_name);
}
/* Update the textbuffer */
this->text.UpdateSize();
this->SetDirty();
free(pre_buf);
return;
@ -453,12 +450,9 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
if (second_scan) {
/* We walked all posibilities, and the user presses tab again.. revert to original text */
strcpy(tb->buf, _chat_tab_completion_buf);
this->text.Assign(_chat_tab_completion_buf);
_chat_tab_completion_active = false;
/* Update the textbuffer */
this->text.UpdateSize();
this->SetDirty();
}
free(pre_buf);

View File

@ -188,8 +188,7 @@ struct OskWindow : public Window {
/* Window gets deleted when the parent window removes itself. */
return;
} else { // or reset to original string
strcpy(qs->text.buf, this->orig_str_buf);
qs->text.UpdateSize();
qs->text.Assign(this->orig_str_buf);
qs->text.MovePos(WKC_END);
this->InvalidateParent();
delete this;

View File

@ -175,8 +175,7 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
*/
void ClearFilterTextWidget()
{
this->edit_str_buf[0] = '\0';
this->text.UpdateSize();
this->text.DeleteAll();
this->SetWidgetDirty(WID_SIL_FILTER_TEXT);
}

View File

@ -1004,11 +1004,11 @@ public:
this->townnamevalid = GenerateTownName(&this->townnameparts);
if (!this->townnamevalid) {
this->edit_str_buf[0] = '\0';
this->text.DeleteAll();
} else {
GetTownName(this->edit_str_buf, &this->params, this->townnameparts, &this->edit_str_buf[this->edit_str_size - 1]);
this->text.UpdateSize();
}
this->text.UpdateSize();
UpdateOSKOriginalText(this, WID_TF_TOWN_NAME_EDITBOX);
this->SetWidgetDirty(WID_TF_TOWN_NAME_EDITBOX);