aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2011-06-02 00:07:18 +0200
committerMax Horn2011-06-02 00:07:18 +0200
commit333be9c072bf8972aa63bc4fb572956261f981cf (patch)
treec6f73aa5aa32c4fbd2a4bf5b11074cbb713f7bd5
parent8f36c52e5866bde77a5f79ac6c1ea96152e5e22f (diff)
downloadscummvm-rg350-333be9c072bf8972aa63bc4fb572956261f981cf.tar.gz
scummvm-rg350-333be9c072bf8972aa63bc4fb572956261f981cf.tar.bz2
scummvm-rg350-333be9c072bf8972aa63bc4fb572956261f981cf.zip
GUI: Replace some s(n)printf uses by Common::String::format
-rw-r--r--gui/launcher.cpp9
-rw-r--r--gui/massadd.cpp10
-rw-r--r--gui/options.cpp10
-rw-r--r--gui/widget.cpp4
-rw-r--r--gui/widgets/list.cpp7
5 files changed, 12 insertions, 28 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 86ca3162cb..6920e0ccd2 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -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++;
}
}
diff --git a/gui/massadd.cpp b/gui/massadd.cpp
index 861be970c4..b0adce3f47 100644
--- a/gui/massadd.cpp
+++ b/gui/massadd.cpp
@@ -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);
}
diff --git a/gui/options.cpp b/gui/options.cpp
index 0c9d03af0c..5022b808c4 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -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:
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 29838961df..8420391a3f 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -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) {
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index a0877fc68a..2a0d4afff0 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -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;
}