mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Codechange: replace text-buf printf with fmt::format
This commit is contained in:
parent
173ed81dbe
commit
3105d0b09e
@ -28,7 +28,6 @@
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
#include <stdarg.h> /* va_list */
|
||||
#include <deque>
|
||||
|
||||
#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) */
|
||||
if (pre_buf == tb_buf) {
|
||||
this->message_editbox.text.Print("%s: ", cur_name);
|
||||
this->message_editbox.text.Assign(fmt::format("{}: ", cur_name));
|
||||
} 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();
|
||||
|
@ -403,7 +403,7 @@ struct NewGRFInspectWindow : Window {
|
||||
offset -= this->vscroll->GetPosition();
|
||||
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.
|
||||
* @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]);
|
||||
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);
|
||||
strecpy(this->buf, text.data(), &this->buf[this->max_bytes - 1]);
|
||||
this->UpdateSize();
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,7 @@ struct Textbuf {
|
||||
~Textbuf();
|
||||
|
||||
void Assign(StringID string);
|
||||
void Assign(const char *text);
|
||||
void CDECL Print(const char *format, ...) WARN_FORMAT(2, 3);
|
||||
void Assign(const std::string_view text);
|
||||
|
||||
void DeleteAll();
|
||||
bool InsertClipboard();
|
||||
|
Loading…
Reference in New Issue
Block a user