mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-04 16:26:53 +00:00
GUI: Replace some s(n)printf uses by Common::String::format
This commit is contained in:
parent
8f36c52e58
commit
333be9c072
@ -685,10 +685,7 @@ void LauncherDialog::updateListing() {
|
||||
}
|
||||
|
||||
if (description.empty()) {
|
||||
char tmp[200];
|
||||
|
||||
snprintf(tmp, 200, "Unknown (target %s, gameid %s)", iter->_key.c_str(), gameid.c_str());
|
||||
description = tmp;
|
||||
description = Common::String::format("Unknown (target %s, gameid %s)", iter->_key.c_str(), gameid.c_str());
|
||||
}
|
||||
|
||||
if (!gameid.empty() && !description.empty()) {
|
||||
@ -841,12 +838,10 @@ Common::String addGameToConf(const GameDescriptor &result) {
|
||||
assert(!domain.empty());
|
||||
if (ConfMan.hasGameDomain(domain)) {
|
||||
int suffixN = 1;
|
||||
char suffix[16];
|
||||
Common::String gameid(domain);
|
||||
|
||||
while (ConfMan.hasGameDomain(domain)) {
|
||||
snprintf(suffix, 16, "-%d", suffixN);
|
||||
domain = gameid + suffix;
|
||||
domain = gameid + Common::String::format("-%d", suffixN);
|
||||
suffixN++;
|
||||
}
|
||||
}
|
||||
|
@ -234,23 +234,23 @@ void MassAddDialog::handleTickle() {
|
||||
|
||||
|
||||
// Update the dialog
|
||||
char buf[256];
|
||||
Common::String buf;
|
||||
|
||||
if (_scanStack.empty()) {
|
||||
// Enable the OK button
|
||||
_okButton->setEnabled(true);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s", _("Scan complete!"));
|
||||
buf = _("Scan complete!");
|
||||
_dirProgressText->setLabel(buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), _("Discovered %d new games, ignored %d previously added games."), _games.size(), _oldGamesCount);
|
||||
buf = Common::String::format(_("Discovered %d new games, ignored %d previously added games."), _games.size(), _oldGamesCount);
|
||||
_gameProgressText->setLabel(buf);
|
||||
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), _("Scanned %d directories ..."), _dirsScanned);
|
||||
buf = Common::String::format(_("Scanned %d directories ..."), _dirsScanned);
|
||||
_dirProgressText->setLabel(buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), _("Discovered %d new games, ignored %d previously added games ..."), _games.size(), _oldGamesCount);
|
||||
buf = Common::String::format(_("Discovered %d new games, ignored %d previously added games ..."), _games.size(), _oldGamesCount);
|
||||
_gameProgressText->setLabel(buf);
|
||||
}
|
||||
|
||||
|
@ -241,11 +241,8 @@ void OptionsDialog::open() {
|
||||
}
|
||||
|
||||
// MIDI gain setting
|
||||
char buf[10];
|
||||
|
||||
_midiGainSlider->setValue(ConfMan.getInt("midi_gain", _domain));
|
||||
sprintf(buf, "%.2f", (double)_midiGainSlider->getValue() / 100.0);
|
||||
_midiGainLabel->setLabel(buf);
|
||||
_midiGainLabel->setLabel(Common::String::format("%.2f", (double)_midiGainSlider->getValue() / 100.0));
|
||||
}
|
||||
|
||||
// MT-32 options
|
||||
@ -530,12 +527,9 @@ void OptionsDialog::close() {
|
||||
}
|
||||
|
||||
void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
char buf[10];
|
||||
|
||||
switch (cmd) {
|
||||
case kMidiGainChanged:
|
||||
sprintf(buf, "%.2f", (double)_midiGainSlider->getValue() / 100.0);
|
||||
_midiGainLabel->setLabel(buf);
|
||||
_midiGainLabel->setLabel(Common::String::format("%.2f", (double)_midiGainSlider->getValue() / 100.0));
|
||||
_midiGainLabel->draw();
|
||||
break;
|
||||
case kMusicVolumeChanged:
|
||||
|
@ -240,9 +240,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name,
|
||||
}
|
||||
|
||||
void StaticTextWidget::setValue(int value) {
|
||||
char buf[256];
|
||||
sprintf(buf, "%d", value);
|
||||
_label = buf;
|
||||
_label = Common::String::format("%d", value);
|
||||
}
|
||||
|
||||
void StaticTextWidget::setLabel(const Common::String &label) {
|
||||
|
@ -499,9 +499,7 @@ void ListWidget::drawWidget() {
|
||||
|
||||
// If in numbering mode, we first print a number prefix
|
||||
if (_numberingMode != kListNumberingOff) {
|
||||
char temp[10];
|
||||
sprintf(temp, "%2d. ", (pos + _numberingMode));
|
||||
buffer = temp;
|
||||
buffer = Common::String::format("%2d. ", (pos + _numberingMode));
|
||||
g_gui.theme()->drawText(Common::Rect(_x, y, _x + r.left + _leftPadding, y + fontHeight - 2),
|
||||
buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);
|
||||
pad = 0;
|
||||
@ -543,9 +541,8 @@ Common::Rect ListWidget::getEditRect() const {
|
||||
r.bottom += offset;
|
||||
|
||||
if (_numberingMode != kListNumberingOff) {
|
||||
char temp[10];
|
||||
// FIXME: Assumes that all digits have the same width.
|
||||
sprintf(temp, "%2d. ", (_list.size() - 1 + _numberingMode));
|
||||
Common::String temp = Common::String::format("%2d. ", (_list.size() - 1 + _numberingMode));
|
||||
r.left += g_gui.getStringWidth(temp) + _leftPadding;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user