[Scummvm-git-logs] scummvm master -> c29cc21f6fd368038bc7f03e1d2cdf2b4704d6ef
dreammaster
paulfgilbert at gmail.com
Thu Feb 27 05:36:00 UTC 2020
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b2095095ed ULTIMA8: Starting the game will now auto-load the previous used savegame
1ed63adb6a ULTIMA8: Fix crash checking running process when saving game
b40f9c5833 ULTIMA8: Default to 16-bit graphics
9caabc94af ULTIMA8: Fix rendering TTF text in 16-bit mode
c29cc21f6f ULTIMA8: Cleanup of some of the TTF and texture rendering
Commit: b2095095edc8e8276f618a34ca10296ee1e94a7a
https://github.com/scummvm/scummvm/commit/b2095095edc8e8276f618a34ca10296ee1e94a7a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-26T21:35:48-08:00
Commit Message:
ULTIMA8: Starting the game will now auto-load the previous used savegame
Changed paths:
common/str.cpp
common/str.h
engines/ultima/ultima8/conf/config_file_manager.cpp
engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp
engines/ultima/ultima8/gumps/pentagram_menu_gump.h
engines/ultima/ultima8/ultima8.cpp
engines/ultima/ultima8/ultima8.h
diff --git a/common/str.cpp b/common/str.cpp
index 2090f464ae..d8e384760b 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -746,6 +746,26 @@ size_t String::findFirstOf(const char *chars, size_t pos) const {
return npos;
}
+size_t String::findLastOf(char c, size_t pos) const {
+ int start = (pos == npos) ? (int)_size - 1 : MIN((int)_size - 1, (int)pos);
+ for (int idx = start; idx >= 0; --idx) {
+ if ((*this)[idx] == c)
+ return idx;
+ }
+
+ return npos;
+}
+
+size_t String::findLastOf(const char *chars, size_t pos) const {
+ int start = (pos == npos) ? (int)_size - 1 : MIN((int)_size - 1, (int)pos);
+ for (int idx = start; idx >= 0; --idx) {
+ if (strchr(chars, (*this)[idx]))
+ return idx;
+ }
+
+ return npos;
+}
+
size_t String::findFirstNotOf(char c, size_t pos) const {
for (uint idx = pos; idx < _size; ++idx) {
if ((*this)[idx] != c)
diff --git a/common/str.h b/common/str.h
index 8b2528c5d4..101890279a 100644
--- a/common/str.h
+++ b/common/str.h
@@ -332,6 +332,15 @@ public:
return findFirstOf(chars.c_str(), pos);
}
+ /** Find the last character in the string that's the specified character */
+ size_t findLastOf(char c, size_t pos = npos) const;
+
+ /** Find the last character in the string that's in any of the passed characters */
+ size_t findLastOf(const char *chars, size_t pos = npos) const;
+ size_t findLastOf(const String &chars, size_t pos = npos) const {
+ return findLastOf(chars.c_str(), pos);
+ }
+
/** Find first character in the string that's not the specified character */
size_t findFirstNotOf(char c, size_t pos = 0) const;
diff --git a/engines/ultima/ultima8/conf/config_file_manager.cpp b/engines/ultima/ultima8/conf/config_file_manager.cpp
index 11bc5e4c50..44e8358ba4 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.cpp
+++ b/engines/ultima/ultima8/conf/config_file_manager.cpp
@@ -37,6 +37,7 @@ ConfigFileManager::ConfigFileManager() {
ConfigFileManager::~ConfigFileManager() {
debugN(MM_INFO, "Destroying ConfigFileManager...\n");
+ ConfMan.flushToDisk();
clear();
_configFileManager = 0;
}
@@ -145,38 +146,63 @@ bool ConfigFileManager::get(istring key, bool &ret) {
}
void ConfigFileManager::set(istring key, string val) {
- INIFile *ini = findWriteINI(key);
- if (!ini) return;
-
- ini->set(key, val);
+ if (key.hasPrefix("settings/")) {
+ Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
+ ConfMan.set(subKey, val);
+ } else {
+ INIFile *ini = findWriteINI(key);
+ if (!ini) return;
+
+ ini->set(key, val);
+ }
}
void ConfigFileManager::set(istring key, const char *val) {
- INIFile *ini = findWriteINI(key);
- if (!ini) return;
-
- ini->set(key, val);
+ if (key.hasPrefix("settings/")) {
+ Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
+ ConfMan.set(subKey, val);
+ } else {
+ INIFile *ini = findWriteINI(key);
+ if (!ini) return;
+
+ ini->set(key, val);
+ }
}
void ConfigFileManager::set(istring key, int val) {
- INIFile *ini = findWriteINI(key);
- if (!ini) return;
-
- ini->set(key, val);
+ if (key.hasPrefix("settings/")) {
+ Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
+ ConfMan.setInt(subKey, val);
+ } else {
+ INIFile *ini = findWriteINI(key);
+ if (!ini) return;
+
+ ini->set(key, val);
+ }
}
void ConfigFileManager::set(istring key, bool val) {
- INIFile *ini = findWriteINI(key);
- if (!ini) return;
-
- ini->set(key, val);
+ if (key.hasPrefix("settings/")) {
+ Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
+ ConfMan.setBool(subKey, val);
+ } else {
+ INIFile *ini = findWriteINI(key);
+ if (!ini) return;
+
+ ini->set(key, val);
+ }
}
void ConfigFileManager::unset(istring key) {
- INIFile *ini = findWriteINI(key);
- if (!ini) return;
-
- ini->unset(key);
+ if (key.hasPrefix("settings/")) {
+ Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
+ ConfMan.set(subKey, "");
+ } else {
+ INIFile *ini = findWriteINI(key);
+ if (!ini) return;
+
+ ini->unset(key);
+ }
}
diff --git a/engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp b/engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp
index 22d2ee7169..ad6ae56616 100644
--- a/engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp
+++ b/engines/ultima/ultima8/gumps/pentagram_menu_gump.cpp
@@ -226,11 +226,10 @@ bool PentagramMenuGump::OnKeyDown(int key, int mod) {
return false;
}
-void PentagramMenuGump::ProcessCallback(Std::string gamename, int message) {
+void PentagramMenuGump::ProcessCallback(const Std::string &gameName, int message) {
if (message != 0) {
- SettingManager *settingman = SettingManager::get_instance();
- settingman->set("lastSave", message != 1 ? message : -1);
- Ultima8Engine::get_instance()->changeGame(gamename);
+ Ultima8Engine::get_instance()->handleAutoSave();
+ Ultima8Engine::get_instance()->changeGame(gameName);
}
UnhideGump();
diff --git a/engines/ultima/ultima8/gumps/pentagram_menu_gump.h b/engines/ultima/ultima8/gumps/pentagram_menu_gump.h
index 88372bc2cf..dd10d87fc7 100644
--- a/engines/ultima/ultima8/gumps/pentagram_menu_gump.h
+++ b/engines/ultima/ultima8/gumps/pentagram_menu_gump.h
@@ -100,7 +100,7 @@ private:
Texture *_coversImage;
Texture *_flagsImage;
- void ProcessCallback(Std::string gamename, int message);
+ void ProcessCallback(const Std::string &gameName, int message);
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index c9227f8664..8663ff8b07 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -347,6 +347,9 @@ void Ultima8Engine::startupGame() {
_audioMixer->openMidiOutput();
int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
+ if (saveSlot == -1)
+ _settingMan->get("lastSave", saveSlot);
+
newGame(saveSlot);
pout << "-- Game Initialized --" << Std::endl << Std::endl;
@@ -1007,11 +1010,25 @@ bool Ultima8Engine::saveGame(int slot, const Std::string &desc, bool ignore_moda
return false;
}
- _settingMan->set("lastSave", slot);
-
return saveGameState(slot, desc).getCode() == Common::kNoError;
}
+Common::Error Ultima8Engine::loadGameState(int slot) {
+ Common::Error result = Shared::UltimaEngine::loadGameState(slot);
+ _settingMan->set("lastSave", (result.getCode() == Common::kNoError) ? slot : -1);
+
+ return result;
+}
+
+Common::Error Ultima8Engine::saveGameState(int slot, const Common::String &desc, bool isAutosave) {
+ Common::Error result = Shared::UltimaEngine::saveGameState(slot, desc, isAutosave);;
+
+ if (!isAutosave)
+ _settingMan->set("lastSave", (result.getCode() == Common::kNoError) ? slot : -1);
+
+ return result;
+}
+
Common::Error Ultima8Engine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
// Hack - don't save mouse over status for gumps
Gump *gump = _mouse->getMouseOverGump();
@@ -1191,7 +1208,8 @@ bool Ultima8Engine::newGame(int saveSlot) {
_game->startInitialUsecode(saveSlot);
- _settingMan->set("lastSave", saveSlot);
+ if (saveSlot == -1)
+ _settingMan->set("lastSave", -1);
return true;
}
@@ -1212,14 +1230,12 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
if (state == SavegameReader::SAVE_CORRUPT) {
Error("Invalid or corrupt savegame", "Error Loading savegame");
delete sg;
- _settingMan->set("lastSave", "");
return Common::kReadingFailed;
}
if (state != SavegameReader::SAVE_VALID) {
Error("Unsupported savegame version", "Error Loading savegame");
delete sg;
- _settingMan->set("lastSave", "");
return Common::kReadingFailed;
}
@@ -1250,7 +1266,6 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
}
perr << message << Std::endl;
#else
- _settingMan->set("lastSave", "");
Error(message, "Error Loading savegame");
return Common::kReadingFailed;
#endif
@@ -1341,8 +1356,6 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
pout << "Done" << Std::endl;
- _settingMan->set("lastSave", -1);
-
delete sg;
return Common::kNoError;
}
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index 7011fc12a0..f0022de490 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -286,6 +286,16 @@ public:
*/
bool canSaveGameStateCurrently(bool isAutosave = false) override;
+ /**
+ * Load a game
+ */
+ Common::Error loadGameState(int slot) override;
+
+ /**
+ * Saves the game
+ */
+ Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
+
/**
* Load a game state
*/
Commit: 1ed63adb6a84c118bc4981d2ed4c5fb59e9003ca
https://github.com/scummvm/scummvm/commit/1ed63adb6a84c118bc4981d2ed4c5fb59e9003ca
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-26T21:35:48-08:00
Commit Message:
ULTIMA8: Fix crash checking running process when saving game
Changed paths:
engines/ultima/ultima8/ultima8.cpp
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 8663ff8b07..a7ffc2b112 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -983,7 +983,7 @@ bool Ultima8Engine::canSaveGameStateCurrently(bool isAutosave) {
// Can't save when a modal gump is open
return false;
- if (_kernel->getRunningProcess()->IsOfType(StartU8Process::ClassType))
+ if (_kernel->getRunningProcess() && _kernel->getRunningProcess()->IsOfType(StartU8Process::ClassType))
// Don't save while starting up.
return false;
Commit: b40f9c583317a4bc8919d3aaaca0dd7810256fa8
https://github.com/scummvm/scummvm/commit/b40f9c583317a4bc8919d3aaaca0dd7810256fa8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-26T21:35:48-08:00
Commit Message:
ULTIMA8: Default to 16-bit graphics
Changed paths:
engines/ultima/ultima8/ultima8.cpp
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index a7ffc2b112..68bbb0908c 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -601,7 +601,7 @@ void Ultima8Engine::paint() {
void Ultima8Engine::GraphicSysInit() {
_settingMan->setDefault("width", DEFAULT_SCREEN_WIDTH);
_settingMan->setDefault("height", DEFAULT_SCREEN_HEIGHT);
- _settingMan->setDefault("bpp", 32);
+ _settingMan->setDefault("bpp", 16);
int width, height, bpp;
_settingMan->get("width", width);
Commit: 9caabc94af0b16b39d7b709a849e1637acb4d5e6
https://github.com/scummvm/scummvm/commit/9caabc94af0b16b39d7b709a849e1637acb4d5e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-26T21:35:48-08:00
Commit Message:
ULTIMA8: Fix rendering TTF text in 16-bit mode
Changed paths:
engines/ultima/ultima8/graphics/soft_render_surface.cpp
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
index 8d52f14e62..c30b15fcc8 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
@@ -631,34 +631,38 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, i
int tex_diff = _tex->_width - w;
while (pixel != end) {
- if (!alpha_blend) while (pixel != line_end) {
+ if (!alpha_blend) {
+ while (pixel != line_end) {
uintX *dest = reinterpret_cast<uintX *>(pixel);
- if ((*texel & TEX32_A_MASK) && (*dest & RenderSurface::_format.a_mask)) {
- *dest = static_cast<uintX>(
- PACK_RGB8(
- (TEX32_R(*texel) * ia + r) >> 8,
- (TEX32_G(*texel) * ia + g) >> 8,
- (TEX32_B(*texel) * ia + b) >> 8
- )
- );
+ if (*texel & TEX32_A_MASK) {
+ if (!RenderSurface::_format.a_mask || (*dest & RenderSurface::_format.a_mask)) {
+ *dest = static_cast<uintX>(
+ PACK_RGB8(
+ (TEX32_R(*texel) * ia + r) >> 8,
+ (TEX32_G(*texel) * ia + g) >> 8,
+ (TEX32_B(*texel) * ia + b) >> 8
+ )
+ );
+ }
}
pixel += sizeof(uintX);
texel++;
}
- else while (pixel != line_end) {
+ } else {
+ while (pixel != line_end) {
uintX *dest = reinterpret_cast<uintX *>(pixel);
- if (*dest & RenderSurface::_format.a_mask) {
+ if (!RenderSurface::_format.a_mask || (*dest & RenderSurface::_format.a_mask)) {
uint32 alpha = *texel & TEX32_A_MASK;
if (alpha == 0xFF) {
*dest = static_cast<uintX>(
- PACK_RGB8(
- (TEX32_R(*texel) * ia + r) >> 8,
- (TEX32_G(*texel) * ia + g) >> 8,
- (TEX32_B(*texel) * ia + b) >> 8
- )
- );
+ PACK_RGB8(
+ (TEX32_R(*texel) * ia + r) >> 8,
+ (TEX32_G(*texel) * ia + g) >> 8,
+ (TEX32_B(*texel) * ia + b) >> 8
+ )
+ );
} else if (alpha) {
uint32 src = *texel;
uint32 dr, dg, db;
@@ -677,6 +681,7 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, i
pixel += sizeof(uintX);
texel++;
}
+ }
line_end += _pitch;
pixel += diff;
Commit: c29cc21f6fd368038bc7f03e1d2cdf2b4704d6ef
https://github.com/scummvm/scummvm/commit/c29cc21f6fd368038bc7f03e1d2cdf2b4704d6ef
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-26T21:35:48-08:00
Commit Message:
ULTIMA8: Cleanup of some of the TTF and texture rendering
Changed paths:
engines/ultima/ultima8/graphics/fonts/tt_font.cpp
engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
engines/ultima/ultima8/graphics/texture.h
engines/ultima/ultima8/gumps/widgets/text_widget.cpp
diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
index 60602647a7..9eadd246bb 100644
--- a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
@@ -46,7 +46,7 @@ static const uint16 BULLETS[] = { 0x2022, 0x30FB, 0x25CF, 0 };
TTFont::TTFont(Graphics::Font *font, uint32 rgb, int borderSize,
bool antiAliased, bool SJIS) :
_borderSize(borderSize), _ttfFont(font), _antiAliased(antiAliased), _SJIS(SJIS),
- _pixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0) {
+ _pixelFormat(Texture::getPixelFormat()) {
_color = _pixelFormat.RGBToColor((rgb >> 16) & 0xFF, (rgb >> 8) & 0xff, rgb & 0xff);
_bullet = 0;
@@ -79,7 +79,7 @@ int TTFont::getBaseline() {
}
int TTFont::getBaselineSkip() {
- // TODO: See if
+ // TODO: Come up with something more generic than just hardcoding 2 pixel line separation
return getHeight() + 2;
}
diff --git a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
index 86421fe0fb..86c8b63836 100644
--- a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
@@ -43,27 +43,23 @@ TTFRenderedText::~TTFRenderedText() {
delete _texture;
}
-void TTFRenderedText::draw(RenderSurface *surface, int x, int y,
- bool destmasked) {
+void TTFRenderedText::draw(RenderSurface *surface, int x, int y, bool destmasked) {
if (!destmasked)
surface->Blit(_texture, 0, 0, _width, _height, x, y - _font->getBaseline(),
- _font->isAntialiased());
+ _font->isAntialiased());
else
surface->MaskedBlit(_texture, 0, 0, _width, _height,
- x, y - _font->getBaseline(),
- 0, _font->isAntialiased());
+ x, y - _font->getBaseline(), 0, _font->isAntialiased());
}
void TTFRenderedText::drawBlended(RenderSurface *surface, int x, int y,
- uint32 col, bool destmasked) {
+ uint32 col, bool destmasked) {
if (!destmasked)
surface->FadedBlit(_texture, 0, 0, _width, _height,
- x, y - _font->getBaseline(), col,
- _font->isAntialiased());
+ x, y - _font->getBaseline(), col, _font->isAntialiased());
else
surface->MaskedBlit(_texture, 0, 0, _width, _height,
- x, y - _font->getBaseline(), col,
- _font->isAntialiased());
+ x, y - _font->getBaseline(), col, _font->isAntialiased());
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/graphics/texture.h b/engines/ultima/ultima8/graphics/texture.h
index b36f08ba45..4f7bc04f63 100644
--- a/engines/ultima/ultima8/graphics/texture.h
+++ b/engines/ultima/ultima8/graphics/texture.h
@@ -101,6 +101,10 @@ struct Texture {
uint32 _glTex;
Texture *_next;
+ static Graphics::PixelFormat getPixelFormat() {
+ return Graphics::PixelFormat(4, 8, 8, 8, 8, TEX32_R_SHIFT, TEX32_G_SHIFT, TEX32_B_SHIFT, TEX32_A_SHIFT);
+ }
+
Texture() : _buffer(0), _format(TEX_FMT_STANDARD), _glTex(0), _next(0) {
}
diff --git a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
index 516e55171f..720af94bb3 100644
--- a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
@@ -188,23 +188,25 @@ void TextWidget::PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 s
if (!_gameFont || !font->isHighRes()) return;
- int32 x_ = 0, y_ = 0;
- GumpToScreenSpace(x_, y_, ROUND_BOTTOMRIGHT);
+ int32 x = 0, y = 0;
+ GumpToScreenSpace(x, y, ROUND_BOTTOMRIGHT);
if (!_blendColour)
- _cachedText->draw(surf, x_, y_, true);
+ _cachedText->draw(surf, x, y, true);
else
- _cachedText->drawBlended(surf, x_, y_, _blendColour, true);
+ _cachedText->drawBlended(surf, x, y, _blendColour, true);
- if (_parent->IsOfType<BarkGump>()) return;
+ if (_parent->IsOfType<BarkGump>())
+ return;
- if (_parent->IsOfType<ButtonWidget>() && _parent->GetParent()->IsOfType<AskGump>()) return;
+ if (_parent->IsOfType<ButtonWidget>() && _parent->GetParent()->IsOfType<AskGump>())
+ return;
- x_ = _dims.x;
- y_ = _dims.y;
+ x = _dims.x;
+ y = _dims.y;
int32 w = _dims.w, h = _dims.h;
- GumpRectToScreenSpace(x_, y_, w, h, ROUND_OUTSIDE);
- surf->FillAlpha(0x00, x_, y_, w, h);
+ GumpRectToScreenSpace(x, y, w, h, ROUND_OUTSIDE);
+ surf->FillAlpha(0x00, x, y, w, h);
}
// don't handle any mouse motion events, so let parent handle them for us.
More information about the Scummvm-git-logs
mailing list