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

pull/155/head
frosch 12 years ago
parent 0ab8e7939b
commit 838388dcd5

@ -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();
}
/**

@ -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()) {

@ -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;

@ -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);

@ -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;

@ -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);
}

@ -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);

Loading…
Cancel
Save