mirror of https://github.com/OpenTTD/OpenTTD
(svn r24739) -Codechange: Simplify some code by using Textbuf::Assign.
parent
f6d4200f86
commit
6653ac6b36
|
@ -451,11 +451,10 @@ static void IConsoleHistoryNavigate(int direction)
|
||||||
if (direction > 0 && _iconsole_history[_iconsole_historypos] == NULL) _iconsole_historypos--;
|
if (direction > 0 && _iconsole_history[_iconsole_historypos] == NULL) _iconsole_historypos--;
|
||||||
|
|
||||||
if (_iconsole_historypos == -1) {
|
if (_iconsole_historypos == -1) {
|
||||||
*_iconsole_cmdline.buf = '\0';
|
_iconsole_cmdline.DeleteAll();
|
||||||
} else {
|
} 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) {
|
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO || _saveload_mode == SLD_SAVE_HEIGHTMAP) {
|
||||||
/* Copy clicked name to editbox */
|
/* Copy clicked name to editbox */
|
||||||
ttd_strlcpy(this->text.buf, file->title, this->text.max_bytes);
|
this->text.Assign(file->title);
|
||||||
this->text.UpdateSize();
|
|
||||||
this->SetWidgetDirty(WID_SL_SAVE_OSK_TITLE);
|
this->SetWidgetDirty(WID_SL_SAVE_OSK_TITLE);
|
||||||
}
|
}
|
||||||
} else if (!_load_check_data.HasErrors()) {
|
} else if (!_load_check_data.HasErrors()) {
|
||||||
|
|
|
@ -547,8 +547,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
|
||||||
|
|
||||||
case WID_GL_RANDOM_BUTTON: // Random seed
|
case WID_GL_RANDOM_BUTTON: // Random seed
|
||||||
_settings_newgame.game_creation.generation_seed = InteractiveRandom();
|
_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.Print("%u", _settings_newgame.game_creation.generation_seed);
|
||||||
this->text.UpdateSize();
|
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
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) */
|
/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */
|
||||||
if (pre_buf == tb_buf) {
|
if (pre_buf == tb_buf) {
|
||||||
snprintf(tb->buf, this->edit_str_size, "%s: ", cur_name);
|
this->text.Print("%s: ", cur_name);
|
||||||
} else {
|
} 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();
|
this->SetDirty();
|
||||||
free(pre_buf);
|
free(pre_buf);
|
||||||
return;
|
return;
|
||||||
|
@ -453,12 +450,9 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||||
|
|
||||||
if (second_scan) {
|
if (second_scan) {
|
||||||
/* We walked all posibilities, and the user presses tab again.. revert to original text */
|
/* 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;
|
_chat_tab_completion_active = false;
|
||||||
|
|
||||||
/* Update the textbuffer */
|
|
||||||
this->text.UpdateSize();
|
|
||||||
|
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
}
|
}
|
||||||
free(pre_buf);
|
free(pre_buf);
|
||||||
|
|
|
@ -188,8 +188,7 @@ struct OskWindow : public Window {
|
||||||
/* Window gets deleted when the parent window removes itself. */
|
/* Window gets deleted when the parent window removes itself. */
|
||||||
return;
|
return;
|
||||||
} else { // or reset to original string
|
} else { // or reset to original string
|
||||||
strcpy(qs->text.buf, this->orig_str_buf);
|
qs->text.Assign(this->orig_str_buf);
|
||||||
qs->text.UpdateSize();
|
|
||||||
qs->text.MovePos(WKC_END);
|
qs->text.MovePos(WKC_END);
|
||||||
this->InvalidateParent();
|
this->InvalidateParent();
|
||||||
delete this;
|
delete this;
|
||||||
|
|
|
@ -175,8 +175,7 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
|
||||||
*/
|
*/
|
||||||
void ClearFilterTextWidget()
|
void ClearFilterTextWidget()
|
||||||
{
|
{
|
||||||
this->edit_str_buf[0] = '\0';
|
this->text.DeleteAll();
|
||||||
this->text.UpdateSize();
|
|
||||||
|
|
||||||
this->SetWidgetDirty(WID_SIL_FILTER_TEXT);
|
this->SetWidgetDirty(WID_SIL_FILTER_TEXT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1004,11 +1004,11 @@ public:
|
||||||
this->townnamevalid = GenerateTownName(&this->townnameparts);
|
this->townnamevalid = GenerateTownName(&this->townnameparts);
|
||||||
|
|
||||||
if (!this->townnamevalid) {
|
if (!this->townnamevalid) {
|
||||||
this->edit_str_buf[0] = '\0';
|
this->text.DeleteAll();
|
||||||
} else {
|
} else {
|
||||||
GetTownName(this->edit_str_buf, &this->params, this->townnameparts, &this->edit_str_buf[this->edit_str_size - 1]);
|
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);
|
UpdateOSKOriginalText(this, WID_TF_TOWN_NAME_EDITBOX);
|
||||||
|
|
||||||
this->SetWidgetDirty(WID_TF_TOWN_NAME_EDITBOX);
|
this->SetWidgetDirty(WID_TF_TOWN_NAME_EDITBOX);
|
||||||
|
|
Loading…
Reference in New Issue