[Scummvm-git-logs] scummvm master -> ba353bc58c9d663a15a0e016cfeed4ffcc9ba6b2
bluegr
noreply at scummvm.org
Fri Mar 25 22:48:40 UTC 2022
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:
ba353bc58c CHEWY: Remove the IOGame class and simplify the save game slot code
Commit: ba353bc58c9d663a15a0e016cfeed4ffcc9ba6b2
https://github.com/scummvm/scummvm/commit/ba353bc58c9d663a15a0e016cfeed4ffcc9ba6b2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-03-26T00:48:15+02:00
Commit Message:
CHEWY: Remove the IOGame class and simplify the save game slot code
Changed paths:
R engines/chewy/io_game.cpp
R engines/chewy/io_game.h
engines/chewy/dialogs/files.cpp
engines/chewy/dialogs/files.h
engines/chewy/globals.h
engines/chewy/inits.cpp
engines/chewy/main.cpp
engines/chewy/module.mk
engines/chewy/ngshext.h
diff --git a/engines/chewy/dialogs/files.cpp b/engines/chewy/dialogs/files.cpp
index 787bea35aba..66b391f23b3 100644
--- a/engines/chewy/dialogs/files.cpp
+++ b/engines/chewy/dialogs/files.cpp
@@ -49,12 +49,12 @@ static const Common::Rect fileHotspots[] = {
};
-int16 Files::execute(bool isInGame) {
+bool Files::execute(bool isInGame) {
int16 key = 0;
Common::Point pt[8];
int16 mode[9];
bool visibility[8];
- int16 ret = 0;
+ bool ret = false;
bool flag = false;
if (!ConfMan.getBool("original_menus")) {
@@ -70,7 +70,6 @@ int16 Files::execute(bool isInGame) {
_G(out)->map_spr2screen(_G(ablage)[_G(room_blk).AkAblage], 0, 0);
_G(out)->setPointer(_G(screen0));
_G(room)->set_ak_pal(&_G(room_blk));
- Common::StringArray &fnames = _G(iog)->io_init();
_G(fx)->blende1(_G(workptr), _G(screen0), _G(pal), 150, 0, 0);
_G(out)->setPointer(_G(workptr));
@@ -93,6 +92,7 @@ int16 Files::execute(bool isInGame) {
int16 text_off = 0; // Top visible save slot
int16 active_slot = 0; // Currently selected slot
+ SaveStateList saveList = g_engine->listSaves();
while (key != Common::KEYCODE_ESCAPE && !SHOULD_QUIT) {
// Draw the dialog background
@@ -113,16 +113,24 @@ int16 Files::execute(bool isInGame) {
}
}
- // Write the list of savegame slots
+ // Write the list of savegame slots
for (int16 i = 0; i < NUM_VISIBLE_SLOTS; i++) {
+ if (i + text_off >= saveList.size())
+ break;
+
+ // TODO: This implementation disallows gaps in the save list
+ if (saveList[i + text_off].getSaveSlot() != i + text_off)
+ continue;
+
Common::String slot = Common::String::format("%2d.", text_off + i);
+ Common::String saveName = saveList[i + text_off].getDescription();
if (i != active_slot) {
_G(out)->printxy(40, 68 + (i * 10), 14, 300, 0, slot.c_str());
- _G(out)->printxy(70, 68 + (i * 10), 14, 300, 0, fnames[i + text_off].c_str());
+ _G(out)->printxy(70, 68 + (i * 10), 14, 300, 0, saveName.c_str());
} else {
_G(out)->boxFill(40, 68 + (i * 10), 308, 68 + 8 + (i * 10), 42);
_G(out)->printxy(40, 68 + (i * 10), 255, 300, 0, slot.c_str());
- _G(out)->printxy(70, 68 + (i * 10), 255, 300, 0, fnames[i + text_off].c_str());
+ _G(out)->printxy(70, 68 + (i * 10), 255, 300, 0, saveName.c_str());
}
}
@@ -146,7 +154,7 @@ int16 Files::execute(bool isInGame) {
key = getch();
if (key == 'j' || key == 'J' || key == 'y' || key == 'Y' || key == 'z' || key == 'Z') {
- ret = 1;
+ ret = true;
key = Common::KEYCODE_ESCAPE;
} else {
key = 0;
@@ -259,7 +267,6 @@ int16 Files::execute(bool isInGame) {
enter:
if (mode[LOAD]) {
const int16 slotNum = text_off + active_slot;
- SaveStateList saveList = g_engine->listSaves();
for (uint j = 0; j < saveList.size(); ++j) {
if (saveList[j].getSaveSlot() == slotNum) {
_G(currentSong) = -1;
@@ -272,15 +279,15 @@ enter:
} else if (mode[SAVE]) {
_G(out)->back2screen(_G(workpage));
_G(out)->setPointer(_G(screen0));
- char tmp[81];
- tmp[0] = '\0';
+ char slotName[81];
+ slotName[0] = '\0';
key = _G(out)->scanxy(70, 68 + (active_slot * 10),
- 255, 42, 14, 0, "%36s36", tmp);
- fnames[text_off + active_slot] = tmp;
+ 255, 42, 14, 0, "%36s36", slotName);
_G(out)->setPointer(_G(workptr));
if (key != Common::KEYCODE_ESCAPE) {
- _G(iog)->save_entry(text_off + active_slot);
+ g_engine->saveGameState(text_off + active_slot, slotName);
+ saveList = g_engine->listSaves();
}
key = Common::KEYCODE_ESCAPE;
}
diff --git a/engines/chewy/dialogs/files.h b/engines/chewy/dialogs/files.h
index dee6248a1ef..92593a0bacd 100644
--- a/engines/chewy/dialogs/files.h
+++ b/engines/chewy/dialogs/files.h
@@ -33,9 +33,9 @@ public:
* Shows the file dialog
* @param isInGame True when called in-game,
* false when called from the main menu
- * @returns Returns 1 if quit was selected
+ * @returns Returns true if quit was selected
*/
- static int16 execute(bool isInGame);
+ static bool execute(bool isInGame);
};
} // namespace Dialogs
diff --git a/engines/chewy/globals.h b/engines/chewy/globals.h
index 7cb8260160c..513ff9ca722 100644
--- a/engines/chewy/globals.h
+++ b/engines/chewy/globals.h
@@ -46,7 +46,6 @@ class ChewyFont;
class Cursor;
class FontMgr;
class InputMgr;
-class IOGame;
class McgaGraphics;
class Memory;
@@ -239,7 +238,6 @@ public:
int16 _TmpFrameSpeed = 0;
InputMgr *_in = nullptr;
Memory *_mem = nullptr;
- IOGame *_iog = nullptr;
McgaGraphics *_out = nullptr;
Cursor *_cur = nullptr;
ChewyFont *_font6 = nullptr;
diff --git a/engines/chewy/inits.cpp b/engines/chewy/inits.cpp
index 77f740bed93..14e394cf488 100644
--- a/engines/chewy/inits.cpp
+++ b/engines/chewy/inits.cpp
@@ -61,7 +61,6 @@ void standard_init() {
_G(cur) = new Cursor(&_G(curblk));
_G(cur)->set_cur_ani(&_G(curani));
- _G(iog) = new IOGame();
alloc_buffers();
_G(pal)[765] = 63;
_G(pal)[766] = 63;
@@ -252,7 +251,6 @@ void tidy() {
free_buffers();
_G(obj)->free_inv_spr(&_G(inv_spr)[0]);
- delete _G(iog);
delete _G(cur);
delete _G(mov);
delete _G(atds);
@@ -267,7 +265,6 @@ void tidy() {
delete _G(out);
delete _G(mem);
- _G(iog) = nullptr;
_G(cur) = nullptr;
_G(mov) = nullptr;
_G(atds) = nullptr;
diff --git a/engines/chewy/io_game.cpp b/engines/chewy/io_game.cpp
deleted file mode 100644
index a579040833a..00000000000
--- a/engines/chewy/io_game.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "chewy/chewy.h"
-#include "chewy/events.h"
-#include "chewy/globals.h"
-#include "chewy/io_game.h"
-
-namespace Chewy {
-
-Common::StringArray &IOGame::io_init() {
- SaveStateList saveList = g_engine->listSaves();
-
- _fileFind.resize(1000);
-
- for (uint i = 0; i < saveList.size(); i++) {
- _fileFind[i] = "";
-
- for (uint j = 0; j < saveList.size(); ++j) {
- if (saveList[j].getSaveSlot() == (int)i) {
- Common::String name = saveList[j].getDescription();
- _fileFind[i] = name;
- break;
- }
- }
- }
-
- return _fileFind;
-}
-
-void IOGame::save_entry(int16 slotNum) {
- Common::String desc = _fileFind[slotNum];
- g_engine->saveGameState(slotNum, desc);
-}
-
-} // namespace Chewy
diff --git a/engines/chewy/io_game.h b/engines/chewy/io_game.h
deleted file mode 100644
index 854061a9a59..00000000000
--- a/engines/chewy/io_game.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef CHEWY_IO_GAME_H
-#define CHEWY_IO_GAME_H
-
-namespace Chewy {
-
-#define IOG_END 1
-#define USER_NAME 36
-
-class IOGame {
- Common::StringArray _fileFind;
-
-public:
- Common::StringArray &io_init();
- void save_entry(int16 nr);
-};
-
-} // namespace Chewy
-
-#endif
diff --git a/engines/chewy/main.cpp b/engines/chewy/main.cpp
index c3a6a85984b..3ad8b105faa 100644
--- a/engines/chewy/main.cpp
+++ b/engines/chewy/main.cpp
@@ -377,8 +377,8 @@ bool mainLoop(int16 mode) {
_G(out)->setPointer(_G(screen0));
cursorChoice(CUR_SAVE);
- int16 ret = Dialogs::Files::execute(true);
- if (ret == IOG_END) {
+ bool ret = Dialogs::Files::execute(true);
+ if (ret) {
retValue = true;
_G(fx_blend) = BLEND4;
}
diff --git a/engines/chewy/module.mk b/engines/chewy/module.mk
index cbc67a95ee0..3d5f35b6fb6 100644
--- a/engines/chewy/module.mk
+++ b/engines/chewy/module.mk
@@ -12,7 +12,6 @@ MODULE_OBJS = \
gedclass.o \
globals.o \
inits.o \
- io_game.o \
m_event.o \
main.o \
mouse.o \
diff --git a/engines/chewy/ngshext.h b/engines/chewy/ngshext.h
index a46a748b060..c914cc4861e 100644
--- a/engines/chewy/ngshext.h
+++ b/engines/chewy/ngshext.h
@@ -25,7 +25,6 @@
#include "chewy/memory.h"
#include "chewy/mcga.h"
#include "chewy/mouse.h"
-#include "chewy/io_game.h"
#include "chewy/cursor.h"
#endif
More information about the Scummvm-git-logs
mailing list