[Scummvm-git-logs] scummvm master -> fc6d124d70a6f28d9147d65ce1aae95ab64fb164
whiterandrek
noreply at scummvm.org
Thu Feb 10 12:48:39 UTC 2022
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c064f373b9 PETKA: update panel interface if changed settings from global menu
9328824877 PETKA: refactor panel interface
fc6d124d70 PETKA: fix reading ini files with null terminators before CR+LF
Commit: c064f373b9aa51a7fdcc49cf7d209c7b2266bd59
https://github.com/scummvm/scummvm/commit/c064f373b9aa51a7fdcc49cf7d209c7b2266bd59
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2022-02-10T14:48:34+02:00
Commit Message:
PETKA: update panel interface if changed settings from global menu
Changed paths:
engines/petka/interfaces/panel.cpp
engines/petka/interfaces/panel.h
engines/petka/petka.cpp
engines/petka/petka.h
diff --git a/engines/petka/interfaces/panel.cpp b/engines/petka/interfaces/panel.cpp
index 36c16822a7f..a17956ad429 100644
--- a/engines/petka/interfaces/panel.cpp
+++ b/engines/petka/interfaces/panel.cpp
@@ -92,7 +92,6 @@ InterfacePanel::InterfacePanel() {
void InterfacePanel::start(int id) {
QSystem *sys = g_vm->getQSystem();
- readSettings();
sys->getCase()->show(false);
@@ -118,10 +117,7 @@ void InterfacePanel::start(int id) {
}
SubInterface::start(id);
-
- updateSliders();
- updateSubtitles();
-
+ onSettingsChanged();
sys->getCursor()->_animate = true;
}
@@ -286,11 +282,32 @@ void InterfacePanel::applySettings() {
_sfxFrame = CLIP<int>(_sfxFrame, 1, 31);
_speedFrame = CLIP<int>(_speedFrame, 1, 26);
- ConfMan.setInt("speech_volume", 255 * (_speechFrame - 1) / (31 - 1));
- ConfMan.setInt("music_volume", 255 * (_musicFrame - 1) / (41 - 1));
- ConfMan.setInt("sfx_volume", 255 * (_sfxFrame - 1) / (31 - 1));
- ConfMan.setBool("subtitles", _subtitles);
- ConfMan.setInt("petka_speed", 4 * (_speedFrame - 1));
+ const auto speechFrame = _speechFrame;
+ const auto musicFrame = _musicFrame;
+ const auto sfxFrame = _sfxFrame;
+ const auto speedFrame = _speedFrame;
+ const auto subtitles = _subtitles;
+
+ readSettings();
+
+ if (speechFrame != _speechFrame) {
+ ConfMan.setInt("speech_volume", 255 * (speechFrame - 1) / (31 - 1));
+ }
+ if (musicFrame != _musicFrame) {
+ ConfMan.setInt("music_volume", 255 * (musicFrame - 1) / (41 - 1));
+ }
+ if (sfxFrame != _sfxFrame) {
+ ConfMan.setInt("sfx_volume", 255 * (sfxFrame - 1) / (31 - 1));
+ }
+
+ ConfMan.setBool("subtitles", subtitles);
+
+ if (speedFrame != _speedFrame) {
+ ConfMan.setInt("petka_speed", 4 * (speedFrame - 1));
+ }
+
+ readSettings();
+
ConfMan.flushToDisk();
g_vm->syncSoundSettings();
}
@@ -303,4 +320,10 @@ int InterfacePanel::getHeroSpeed() {
return (_speedFrame * 100 - 100) / 25;
}
+void InterfacePanel::onSettingsChanged() {
+ readSettings();
+ updateSliders();
+ updateSubtitles();
+}
+
} // End of namespace Petka
diff --git a/engines/petka/interfaces/panel.h b/engines/petka/interfaces/panel.h
index dc16618170c..7cd82aa551f 100644
--- a/engines/petka/interfaces/panel.h
+++ b/engines/petka/interfaces/panel.h
@@ -36,6 +36,8 @@ public:
void onRightButtonDown(Common::Point p) override;
void onMouseMove(Common::Point p) override;
+ void onSettingsChanged();
+
int getHeroSpeed();
bool showSubtitles() const { return _subtitles; }
diff --git a/engines/petka/petka.cpp b/engines/petka/petka.cpp
index 7385d5c3e0c..d1c0496925e 100644
--- a/engines/petka/petka.cpp
+++ b/engines/petka/petka.cpp
@@ -43,6 +43,7 @@
#include "petka/petka.h"
#include "petka/q_manager.h"
#include "petka/interfaces/interface.h"
+#include "petka/interfaces/panel.h"
#include "petka/q_system.h"
#include "petka/big_dialogue.h"
@@ -339,4 +340,13 @@ void PetkaEngine::pushMouseMoveEvent() {
_eventMan->pushEvent(ev);
}
+void PetkaEngine::applyGameSettings() {
+ if (_qsystem->_currInterface == _qsystem->_panelInterface.get())
+ {
+ _qsystem->_panelInterface->onSettingsChanged();
+ }
+
+ Engine::applyGameSettings();
+}
+
} // End of namespace Petka
diff --git a/engines/petka/petka.h b/engines/petka/petka.h
index e75e07b868b..48ccbec6214 100644
--- a/engines/petka/petka.h
+++ b/engines/petka/petka.h
@@ -96,6 +96,8 @@ public:
bool hasFeature(EngineFeature f) const override;
+ void applyGameSettings() override;
+
Common::SeekableReadStream *openFile(const Common::String &name, bool addCurrentPath);
void playVideo(Common::SeekableReadStream *stream);
Commit: 93288248773456e54e823b7a2dfaef7e7784c6ae
https://github.com/scummvm/scummvm/commit/93288248773456e54e823b7a2dfaef7e7784c6ae
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2022-02-10T14:48:34+02:00
Commit Message:
PETKA: refactor panel interface
Changed paths:
engines/petka/interfaces/panel.cpp
engines/petka/interfaces/panel.h
diff --git a/engines/petka/interfaces/panel.cpp b/engines/petka/interfaces/panel.cpp
index a17956ad429..20a30e55862 100644
--- a/engines/petka/interfaces/panel.cpp
+++ b/engines/petka/interfaces/panel.cpp
@@ -33,7 +33,7 @@
#include "petka/interfaces/save_load.h"
#include "petka/interfaces/panel.h"
-namespace Petka {
+namespace {
// ÐÐÐÐÐЬ УÐÐ ÐÐÐÐÐÐЯ
const char *const kPanelObjName = "\xCF\xC0\xCD\xC5\xCB\xDC\x20\xD3\xCF\xD0\xC0\xC2\xCB\xC5\xCD\xC8\xDF";
@@ -43,6 +43,7 @@ const uint kLoadButtonIndex = 2;
const uint kContinueButtonIndex = 3;
const uint kExitButtonIndex = 4;
const uint kSaveButtonIndex = 5;
+const uint kSafeObjectIndex = 6;
const uint kSfxLabelIndex = 7;
const uint kSubtitleButtonIndex = 8;
const uint kSfxVolumeSliderIndex = 9;
@@ -62,31 +63,59 @@ const uint kIncSfxButtonIndex = 22;
const uint kDecSpeedButtonIndex = 23;
const uint kIncSpeedButtonIndex = 24;
+Common::Point getObjectPos(uint index)
+{
+ switch (index) {
+ case kNewGameButtonIndex:
+ return {0, 2};
+ case kLoadButtonIndex:
+ return {5, 70};
+ case kContinueButtonIndex:
+ return {5, 136};
+ case kExitButtonIndex:
+ return {22, 328};
+ case kSaveButtonIndex:
+ return {87, 224};
+ case kSafeObjectIndex:
+ return {118, 395};
+ case kSfxLabelIndex:
+ return {467, 71};
+ case kSubtitleButtonIndex:
+ return {432, 144};
+ case kSfxVolumeSliderIndex:
+ return {428, 29};
+ case kSpeedSliderIndex:
+ return {434, 170};
+ case kMusicLabelIndex:
+ return {297, 214};
+ case kSubtitleLabelIndex:
+ return {470, 139};
+ case kSpeechLabelIndex:
+ return {318, 87};
+ case kSpeedLabelIndex:
+ return {468, 172};
+ case kSpeechVolumeSliderIndex:
+ return {262, 31};
+ case kMusicVolumeSliderIndex:
+ return {231, 137};
+ // case kDecSpeechButtonIndex:
+ // case kIncSpeechButtonIndex:
+ // case kDecMusicButtonIndex:
+ // case kIncMusicButtonIndex:
+ // case kDecSfxButtonIndex:
+ // case kIncSfxButtonIndex:
+ // case kDecSpeedButtonIndex:
+ // case kIncSpeedButtonIndex:
+ default:
+ return {0, 0};
+ }
+}
+
+}
+
+namespace Petka {
+
InterfacePanel::InterfacePanel() {
- _objectPoints[0] = Common::Point(0, 2);
- _objectPoints[1] = Common::Point(5, 70);
- _objectPoints[2] = Common::Point(5, 136);
- _objectPoints[3] = Common::Point(22, 328);
- _objectPoints[4] = Common::Point(87, 224);
- _objectPoints[5] = Common::Point(118, 395);
- _objectPoints[6] = Common::Point(467, 71);
- _objectPoints[7] = Common::Point(432, 144);
- _objectPoints[8] = Common::Point(428, 29);
- _objectPoints[9] = Common::Point(434, 170);
- _objectPoints[10] = Common::Point(297, 214);
- _objectPoints[11] = Common::Point(470, 139);
- _objectPoints[12] = Common::Point(318, 87);
- _objectPoints[13] = Common::Point(468, 172);
- _objectPoints[14] = Common::Point(262, 31);
- _objectPoints[15] = Common::Point(231, 137);
- _objectPoints[16] = Common::Point(0, 0);
- _objectPoints[17] = Common::Point(0, 0);
- _objectPoints[18] = Common::Point(0, 0);
- _objectPoints[19] = Common::Point(0, 0);
- _objectPoints[20] = Common::Point(0, 0);
- _objectPoints[21] = Common::Point(0, 0);
- _objectPoints[22] = Common::Point(0, 0);
- _objectPoints[23] = Common::Point(0, 0);
readSettings();
}
@@ -101,16 +130,20 @@ void InterfacePanel::start(int id) {
InterfaceSaveLoad::saveScreen();
QObjectBG *bg = (QObjectBG *)sys->findObject(kPanelObjName);
+ const BGInfo *info = sys->_mainInterface->findBGInfo(bg->_id);
+
+ _objs.reserve(info->attachedObjIds.size() + 1);
_objs.push_back(bg);
- const BGInfo *info = sys->_mainInterface->findBGInfo(bg->_id);
for (uint i = 0; i < info->attachedObjIds.size(); ++i) {
QMessageObject *obj = sys->findObject(info->attachedObjIds[i]);
FlicDecoder *flc = g_vm->resMgr()->getFlic(obj->_resourceId);
flc->setFrame(1);
+
+ const auto pos = getObjectPos(i + 1);
+ obj->_x = pos.x;
+ obj->_y = pos.y;
obj->_z = 1;
- obj->_x = _objectPoints[i].x;
- obj->_y = _objectPoints[i].y;
obj->_frame = 1;
obj->_animate = false;
_objs.push_back(obj);
@@ -202,35 +235,27 @@ void InterfacePanel::onMouseMove(Common::Point p) {
continue;
obj->_frame = frame;
- int pointIndex;
switch (i) {
case kDecSpeechButtonIndex:
case kIncSpeechButtonIndex:
- pointIndex = kSpeechLabelIndex - 1;
- obj = (QMessageObject *)_objs[kSpeechLabelIndex];
+ updateSprite(kSpeechLabelIndex, frame);
break;
case kDecMusicButtonIndex:
case kIncMusicButtonIndex:
- pointIndex = kMusicLabelIndex - 1;
- obj = (QMessageObject *)_objs[kMusicLabelIndex];
+ updateSprite(kMusicLabelIndex, frame);
break;
case kDecSfxButtonIndex:
case kIncSfxButtonIndex:
- pointIndex = kSfxLabelIndex - 1;
- obj = (QMessageObject *)_objs[kSfxLabelIndex];
+ updateSprite(kSfxLabelIndex, frame);
break;
case kIncSpeedButtonIndex:
case kDecSpeedButtonIndex:
- pointIndex = kSpeedLabelIndex - 1;
- obj = (QMessageObject *)_objs[kSpeedLabelIndex];
+ updateSprite(kSpeedLabelIndex, frame);
break;
default:
- pointIndex = i - 1;
+ updateSprite(i, frame);
break;
}
- FlicDecoder *flc = g_vm->resMgr()->getFlic(obj->_resourceId);
- flc->setFrame(frame);
- g_vm->videoSystem()->addDirtyRect(_objectPoints[pointIndex], *flc);
}
QObjectCursor *cursor = g_vm->getQSystem()->getCursor();
cursor->_isShown = true;
@@ -240,32 +265,17 @@ void InterfacePanel::onMouseMove(Common::Point p) {
void InterfacePanel::updateSliders() {
applySettings();
- FlicDecoder *flc = g_vm->resMgr()->getFlic(_objs[kSpeechVolumeSliderIndex]->_resourceId);
- flc->setFrame(_speechFrame);
- g_vm->videoSystem()->addDirtyRect(_objectPoints[kSpeechVolumeSliderIndex - 1], *flc);
-
- flc = g_vm->resMgr()->getFlic(_objs[kMusicVolumeSliderIndex]->_resourceId);
- flc->setFrame(_musicFrame);
- g_vm->videoSystem()->addDirtyRect(_objectPoints[kMusicVolumeSliderIndex - 1], *flc);
-
- flc = g_vm->resMgr()->getFlic(_objs[kSfxVolumeSliderIndex]->_resourceId);
- flc->setFrame(_sfxFrame);
- g_vm->videoSystem()->addDirtyRect(_objectPoints[kSfxVolumeSliderIndex - 1], *flc);
-
- flc = g_vm->resMgr()->getFlic(_objs[kSpeedSliderIndex]->_resourceId);
- flc->setFrame(_speedFrame);
- g_vm->videoSystem()->addDirtyRect(_objectPoints[kSpeedSliderIndex - 1], *flc);
+ updateSprite(kSpeechVolumeSliderIndex, _speechFrame);
+ updateSprite(kMusicVolumeSliderIndex, _musicFrame);
+ updateSprite(kSfxVolumeSliderIndex, _sfxFrame);
+ updateSprite(kSpeedSliderIndex, _speedFrame);
}
void InterfacePanel::updateSubtitles() {
applySettings();
- FlicDecoder *flc = g_vm->resMgr()->getFlic(_objs[kSubtitleButtonIndex]->_resourceId);
- flc->setFrame(_subtitles == 0 ? 1 : 7);
- g_vm->videoSystem()->addDirtyRect(_objectPoints[kSubtitleButtonIndex - 1], *flc);
- flc = g_vm->resMgr()->getFlic(_objs[kSubtitleLabelIndex]->_resourceId);
- flc->setFrame(_subtitles == 0 ? 1 : 2);
- g_vm->videoSystem()->addDirtyRect(_objectPoints[kSubtitleLabelIndex - 1], *flc);
+ updateSprite(kSubtitleButtonIndex, _subtitles == 0 ? 1 : 7);
+ updateSprite(kSubtitleLabelIndex, _subtitles == 0 ? 1 : 2);
}
void InterfacePanel::readSettings() {
@@ -316,6 +326,13 @@ void InterfacePanel::onRightButtonDown(Common::Point p) {
stop();
}
+void InterfacePanel::updateSprite(uint index, uint frame) const {
+ const auto *object = (QMessageObject *)(_objs[index]);
+ FlicDecoder *flc = g_vm->resMgr()->getFlic(object->_resourceId);
+ flc->setFrame(frame);
+ g_vm->videoSystem()->addDirtyRect(Common::Point(object->_x, object->_y), *flc);
+}
+
int InterfacePanel::getHeroSpeed() {
return (_speedFrame * 100 - 100) / 25;
}
diff --git a/engines/petka/interfaces/panel.h b/engines/petka/interfaces/panel.h
index 7cd82aa551f..75439f0ccae 100644
--- a/engines/petka/interfaces/panel.h
+++ b/engines/petka/interfaces/panel.h
@@ -48,13 +48,14 @@ private:
void updateSliders();
void updateSubtitles();
+ void updateSprite(uint index, uint frame) const;
+
private:
bool _subtitles;
int _speechFrame;
int _musicFrame;
int _sfxFrame;
int _speedFrame;
- Common::Point _objectPoints[24];
};
} // End of namespace Petka
Commit: fc6d124d70a6f28d9147d65ce1aae95ab64fb164
https://github.com/scummvm/scummvm/commit/fc6d124d70a6f28d9147d65ce1aae95ab64fb164
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2022-02-10T14:48:34+02:00
Commit Message:
PETKA: fix reading ini files with null terminators before CR+LF
Changed paths:
engines/petka/petka.cpp
engines/petka/petka.h
engines/petka/q_system.cpp
diff --git a/engines/petka/petka.cpp b/engines/petka/petka.cpp
index d1c0496925e..9d5f1911462 100644
--- a/engines/petka/petka.cpp
+++ b/engines/petka/petka.cpp
@@ -19,12 +19,12 @@
*
*/
+#include "common/substream.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/error.h"
#include "common/events.h"
#include "common/ini-file.h"
-#include "common/stream.h"
#include "common/system.h"
#include "common/file.h"
@@ -136,6 +136,48 @@ Common::SeekableReadStream *PetkaEngine::openFile(const Common::String &name, bo
return _fileMgr->getFileStream(addCurrentPath ? _currentPath + name : name);
}
+Common::SeekableReadStream *PetkaEngine::openIniFile(const Common::String &name) {
+ // Some lines in ini files have null terminators befoen CR+LF
+ class IniReadStream : public Common::SeekableSubReadStream
+ {
+ public:
+ using SeekableSubReadStream::SeekableSubReadStream;
+
+ char *readLine(char *buf, size_t bufSize, bool handleCR = true) override
+ {
+ memset(buf, '\0', bufSize);
+
+ if (!Common::SeekableSubReadStream::readLine(buf, bufSize, handleCR)) {
+ return nullptr;
+ }
+
+ char *null_term = nullptr;
+ for (uint i = 0; i < bufSize; ++i) {
+ if (buf[i] == '\n') {
+ if (null_term) {
+ null_term[0] = '\n';
+ null_term[1] = '\0';
+ }
+
+ return buf;
+ }
+
+ if (buf[i] == '\0' && !null_term) {
+ null_term = &buf[i];
+ }
+ }
+
+ return buf;
+ }
+ };
+
+
+ auto *file_stream = openFile(name, true);
+ if (!file_stream)
+ return nullptr;
+ return new IniReadStream(file_stream, 0, file_stream->size(), DisposeAfterUse::YES);
+}
+
void PetkaEngine::loadStores() {
debug("PetkaEngine::loadStores");
_fileMgr->closeAll();
@@ -286,8 +328,8 @@ void PetkaEngine::loadChapter(byte chapter) {
_fileMgr->openStore(_chapterStoreName);
- Common::ScopedPtr<Common::SeekableReadStream> namesStream(openFile("Names.ini", true));
- Common::ScopedPtr<Common::SeekableReadStream> castStream(openFile("Cast.ini", true));
+ Common::ScopedPtr<Common::SeekableReadStream> namesStream(openIniFile("Names.ini"));
+ Common::ScopedPtr<Common::SeekableReadStream> castStream(openIniFile("Cast.ini"));
Common::INIFile namesIni;
Common::INIFile castIni;
diff --git a/engines/petka/petka.h b/engines/petka/petka.h
index 48ccbec6214..c07e5b50e29 100644
--- a/engines/petka/petka.h
+++ b/engines/petka/petka.h
@@ -99,6 +99,7 @@ public:
void applyGameSettings() override;
Common::SeekableReadStream *openFile(const Common::String &name, bool addCurrentPath);
+ Common::SeekableReadStream *openIniFile(const Common::String &name);
void playVideo(Common::SeekableReadStream *stream);
QSystem *getQSystem() const;
diff --git a/engines/petka/q_system.cpp b/engines/petka/q_system.cpp
index 5874b06d5f8..d1b7a4cf034 100644
--- a/engines/petka/q_system.cpp
+++ b/engines/petka/q_system.cpp
@@ -58,9 +58,9 @@ bool QSystem::init() {
Common::ScopedPtr<Common::SeekableReadStream> stream(_vm.openFile("script.dat", true));
if (!stream)
return false;
- Common::ScopedPtr<Common::SeekableReadStream> namesStream(_vm.openFile("Names.ini", true));
- Common::ScopedPtr<Common::SeekableReadStream> castStream(_vm.openFile("Cast.ini", true));
- Common::ScopedPtr<Common::SeekableReadStream> bgsStream(_vm.openFile("BGs.ini", true));
+ Common::ScopedPtr<Common::SeekableReadStream> namesStream(_vm.openIniFile("Names.ini"));
+ Common::ScopedPtr<Common::SeekableReadStream> castStream(_vm.openIniFile("Cast.ini"));
+ Common::ScopedPtr<Common::SeekableReadStream> bgsStream(_vm.openIniFile("BGs.ini"));
Common::INIFile namesIni;
Common::INIFile castIni;
More information about the Scummvm-git-logs
mailing list