[Scummvm-cvs-logs] scummvm master -> 333be9c072bf8972aa63bc4fb572956261f981cf
fingolfin
max at quendi.de
Thu Jun 2 00:08:58 CEST 2011
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
333be9c072 GUI: Replace some s(n)printf uses by Common::String::format
Commit: 333be9c072bf8972aa63bc4fb572956261f981cf
https://github.com/scummvm/scummvm/commit/333be9c072bf8972aa63bc4fb572956261f981cf
Author: Max Horn (max at quendi.de)
Date: 2011-06-01T15:07:18-07:00
Commit Message:
GUI: Replace some s(n)printf uses by Common::String::format
Changed paths:
gui/launcher.cpp
gui/massadd.cpp
gui/options.cpp
gui/widget.cpp
gui/widgets/list.cpp
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 86ca316..6920e0c 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 861be97..b0adce3 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 0c9d03a..5022b80 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 2983896..8420391 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 a0877fc..2a0d4af 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;
}
More information about the Scummvm-git-logs
mailing list