aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kohaut2019-03-09 21:03:43 +0100
committerPeter Kohaut2019-03-09 22:16:38 +0100
commitacb51d0e724a256e32959f805f0583d9000351f4 (patch)
tree1c5b0e5a5b92731c0b6f758d70142e25e3ebcb55
parent09dbe7686b171a25106a0037abed608b886c9b71 (diff)
downloadscummvm-rg350-acb51d0e724a256e32959f805f0583d9000351f4.tar.gz
scummvm-rg350-acb51d0e724a256e32959f805f0583d9000351f4.tar.bz2
scummvm-rg350-acb51d0e724a256e32959f805f0583d9000351f4.zip
BLADERUNNER: Savagame names fixes
It was not possible to change the name of exisitng savegame Saves were read too ofter just for over-drawing the thumbnail
-rw-r--r--engines/bladerunner/savefile.cpp5
-rw-r--r--engines/bladerunner/ui/kia_section_load.cpp8
-rw-r--r--engines/bladerunner/ui/kia_section_load.h1
-rw-r--r--engines/bladerunner/ui/kia_section_save.cpp10
-rw-r--r--engines/bladerunner/ui/kia_section_save.h1
5 files changed, 18 insertions, 7 deletions
diff --git a/engines/bladerunner/savefile.cpp b/engines/bladerunner/savefile.cpp
index b556b81756..bc5227dbb4 100644
--- a/engines/bladerunner/savefile.cpp
+++ b/engines/bladerunner/savefile.cpp
@@ -241,9 +241,10 @@ bool SaveFileReadStream::readBool() {
}
Common::String SaveFileReadStream::readStringSz(uint sz) {
- char *buf = new char[sz];
+ char *buf = new char[sz + 1];
read(buf, sz);
- Common::String result(buf, sz);
+ buf[sz] = 0;
+ Common::String result(buf);
delete[] buf;
return result;
}
diff --git a/engines/bladerunner/ui/kia_section_load.cpp b/engines/bladerunner/ui/kia_section_load.cpp
index 4d91fb51b0..5f8b635320 100644
--- a/engines/bladerunner/ui/kia_section_load.cpp
+++ b/engines/bladerunner/ui/kia_section_load.cpp
@@ -47,6 +47,7 @@ KIASectionLoad::KIASectionLoad(BladeRunnerEngine *vm) : KIASectionBase(vm) {
_timeLeft = 0;
_hoveredLineId = -1;
+ _displayingLineId = -1;
_newGameEasyLineId = -1;
_newGameMediumLineId = -1;
_newGameHardLineId = -1;
@@ -102,23 +103,25 @@ void KIASectionLoad::draw(Graphics::Surface &surface){
int selectedLineId = _scrollBox->getSelectedLineData();
if (_hoveredLineId != selectedLineId) {
- if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size()) {
+ if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size() && _displayingLineId != selectedLineId) {
if (_timeLeft == 0) {
SaveStateDescriptor desc = SaveFileManager::queryMetaInfos(_vm->getTargetName(), selectedLineId);
const Graphics::Surface *thumbnail = desc.getThumbnail();
if (thumbnail != nullptr) {
_vm->_kia->playImage(*thumbnail);
+ _displayingLineId = selectedLineId;
}
}
} else {
_vm->_kia->playerReset();
_timeLeft = 800;
+ _displayingLineId = -1;
}
_hoveredLineId = selectedLineId;
}
uint32 now = _vm->_time->currentSystem();
- if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size()) {
+ if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size() && _displayingLineId != selectedLineId) {
if (_timeLeft) {
uint32 timeDiff = now - _timeLast;
if (timeDiff >= _timeLeft) {
@@ -126,6 +129,7 @@ void KIASectionLoad::draw(Graphics::Surface &surface){
const Graphics::Surface *thumbnail = desc.getThumbnail();
if (thumbnail != nullptr) {
_vm->_kia->playImage(*thumbnail);
+ _displayingLineId = selectedLineId;
}
} else {
_timeLeft -= timeDiff;
diff --git a/engines/bladerunner/ui/kia_section_load.h b/engines/bladerunner/ui/kia_section_load.h
index 820b39f5e6..cd34d9946e 100644
--- a/engines/bladerunner/ui/kia_section_load.h
+++ b/engines/bladerunner/ui/kia_section_load.h
@@ -49,6 +49,7 @@ class KIASectionLoad : public KIASectionBase {
SaveStateList _saveList;
int _hoveredLineId;
+ int _displayingLineId;
int _newGameEasyLineId;
int _newGameMediumLineId;
int _newGameHardLineId;
diff --git a/engines/bladerunner/ui/kia_section_save.cpp b/engines/bladerunner/ui/kia_section_save.cpp
index f72254bafd..f24d0e01ab 100644
--- a/engines/bladerunner/ui/kia_section_save.cpp
+++ b/engines/bladerunner/ui/kia_section_save.cpp
@@ -62,8 +62,9 @@ KIASectionSave::KIASectionSave(BladeRunnerEngine *vm) : KIASectionBase(vm) {
_mouseX = 0;
_mouseY = 0;
- _selectedLineId = -1;
_hoveredLineId = -1;
+ _displayingLineId = -1;
+ _selectedLineId = -1;
_newSaveLineId = -1;
}
@@ -182,23 +183,25 @@ void KIASectionSave::draw(Graphics::Surface &surface){
int selectedLineId = _scrollBox->getSelectedLineData();
if (selectedLineId != _hoveredLineId) {
- if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size()) {
+ if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size() && _displayingLineId != selectedLineId) {
if (_timeLeft == 0) {
SaveStateDescriptor desc = SaveFileManager::queryMetaInfos(_vm->getTargetName(), selectedLineId);
const Graphics::Surface *thumbnail = desc.getThumbnail();
if (thumbnail != nullptr) {
_vm->_kia->playImage(*thumbnail);
+ _displayingLineId = selectedLineId;
}
}
} else {
_vm->_kia->playerReset();
_timeLeft = 800;
+ _displayingLineId = -1;
}
_hoveredLineId = selectedLineId;
}
uint32 now = _vm->_time->currentSystem();
- if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size()) {
+ if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size() && _displayingLineId != selectedLineId) {
if (_timeLeft) {
uint32 timeDiff = now - _timeLast;
if (timeDiff >= _timeLeft) {
@@ -206,6 +209,7 @@ void KIASectionSave::draw(Graphics::Surface &surface){
const Graphics::Surface *thumbnail = desc.getThumbnail();
if (thumbnail != nullptr) {
_vm->_kia->playImage(*thumbnail);
+ _displayingLineId = selectedLineId;
}
} else {
_timeLeft -= timeDiff;
diff --git a/engines/bladerunner/ui/kia_section_save.h b/engines/bladerunner/ui/kia_section_save.h
index d3af65288e..528771684d 100644
--- a/engines/bladerunner/ui/kia_section_save.h
+++ b/engines/bladerunner/ui/kia_section_save.h
@@ -64,6 +64,7 @@ class KIASectionSave : public KIASectionBase {
int _mouseY;
int _hoveredLineId;
+ int _displayingLineId;
int _selectedLineId;
int _newSaveLineId;