mirror of https://github.com/OpenTTD/OpenTTD
Codechange: replace text-buf printf with fmt::format
parent
173ed81dbe
commit
3105d0b09e
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
#include <stdarg.h> /* va_list */
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
@ -429,9 +428,9 @@ struct NetworkChatWindow : public Window {
|
||||||
|
|
||||||
/* 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) {
|
||||||
this->message_editbox.text.Print("%s: ", cur_name);
|
this->message_editbox.text.Assign(fmt::format("{}: ", cur_name));
|
||||||
} else {
|
} else {
|
||||||
this->message_editbox.text.Print("%s %s", pre_buf, cur_name);
|
this->message_editbox.text.Assign(fmt::format("{} {}", pre_buf, cur_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
|
@ -403,7 +403,7 @@ struct NewGRFInspectWindow : Window {
|
||||||
offset -= this->vscroll->GetPosition();
|
offset -= this->vscroll->GetPosition();
|
||||||
if (offset < 0 || offset >= this->vscroll->GetCapacity()) return;
|
if (offset < 0 || offset >= this->vscroll->GetCapacity()) return;
|
||||||
|
|
||||||
::DrawString(r.Shrink(WidgetDimensions::scaled.frametext).Shrink(0, offset * this->resize.step_height, 0, 0), buf, TC_BLACK);
|
::DrawString(r.Shrink(WidgetDimensions::scaled.frametext).Shrink(0, offset * this->resize.step_height, 0, 0), string, TC_BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -400,21 +400,9 @@ void Textbuf::Assign(StringID string)
|
||||||
* Copy a string into the textbuffer.
|
* Copy a string into the textbuffer.
|
||||||
* @param text Source.
|
* @param text Source.
|
||||||
*/
|
*/
|
||||||
void Textbuf::Assign(const char *text)
|
void Textbuf::Assign(const std::string_view text)
|
||||||
{
|
{
|
||||||
strecpy(this->buf, text, &this->buf[this->max_bytes - 1]);
|
strecpy(this->buf, text.data(), &this->buf[this->max_bytes - 1]);
|
||||||
this->UpdateSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a formatted string into the textbuffer.
|
|
||||||
*/
|
|
||||||
void Textbuf::Print(const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list va;
|
|
||||||
va_start(va, format);
|
|
||||||
vseprintf(this->buf, &this->buf[this->max_bytes - 1], format, va);
|
|
||||||
va_end(va);
|
|
||||||
this->UpdateSize();
|
this->UpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,7 @@ struct Textbuf {
|
||||||
~Textbuf();
|
~Textbuf();
|
||||||
|
|
||||||
void Assign(StringID string);
|
void Assign(StringID string);
|
||||||
void Assign(const char *text);
|
void Assign(const std::string_view text);
|
||||||
void CDECL Print(const char *format, ...) WARN_FORMAT(2, 3);
|
|
||||||
|
|
||||||
void DeleteAll();
|
void DeleteAll();
|
||||||
bool InsertClipboard();
|
bool InsertClipboard();
|
||||||
|
|
Loading…
Reference in New Issue