2020-08-05 00:20:50 +05:30
/* 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 .
*
2021-12-26 18:47:58 +01:00
* 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 .
2020-08-05 00:20:50 +05:30
*
* 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
2021-12-26 18:47:58 +01:00
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
2020-08-05 00:20:50 +05:30
*
*/
# include "common/config-manager.h"
# include "common/savefile.h"
# include "common/system.h"
2022-12-01 11:53:02 +01:00
# include "common/compression/installshield_cab.h"
2020-12-04 13:36:56 +00:00
# include "common/translation.h"
2020-08-05 00:20:50 +05:30
# include "engines/advancedDetector.h"
# include "engines/obsolete.h"
# include "agos/intern.h"
# include "agos/agos.h"
2020-08-25 13:52:43 +05:30
# include "agos/detection.h"
2020-08-05 00:20:50 +05:30
# include "agos/obsolete.h"
2022-11-03 18:38:42 +00:00
namespace AGOS {
static const ADExtraGuiOptionsMap optionsList [ ] = {
{
GAMEOPTION_OPL3_MODE ,
{
_s ( " AdLib OPL3 mode " ) ,
_s ( " When AdLib is selected, OPL3 features will be used. Depending on the game, this will prevent cut-off notes, add extra notes or instruments and/or add stereo. " ) ,
" opl3_mode " ,
false ,
0 ,
0
}
} ,
{
GAMEOPTION_DOS_TEMPOS ,
{
_s ( " Use DOS version music tempos " ) ,
_s ( " Selecting this option will play the music using the tempos used by the DOS version of the game. Otherwise, the faster tempos of the Windows version will be used. " ) ,
" dos_music_tempos " ,
true ,
0 ,
0
}
} ,
{
GAMEOPTION_WINDOWS_TEMPOS ,
{
_s ( " Use DOS version music tempos " ) ,
_s ( " Selecting this option will play the music using the tempos used by the DOS version of the game. Otherwise, the faster tempos of the Windows version will be used. " ) ,
" dos_music_tempos " ,
false ,
0 ,
0
}
} ,
{
GAMEOPTION_PREFER_DIGITAL_SFX ,
{
_s ( " Prefer digital sound effects " ) ,
_s ( " Prefer digital sound effects instead of synthesized ones " ) ,
" prefer_digitalsfx " ,
true ,
0 ,
0
}
} ,
{
GAMEOPTION_DISABLE_FADE_EFFECTS ,
{
_s ( " Disable fade-out effects " ) ,
_s ( " Don't fade every screen to black when leaving a room. " ) ,
" disable_fade_effects " ,
false ,
0 ,
0
}
} ,
AD_EXTRA_GUI_OPTIONS_TERMINATOR
} ;
} // End of namespace AGOS
2020-10-02 12:25:08 +05:30
class AgosMetaEngine : public AdvancedMetaEngine {
2020-08-05 00:20:50 +05:30
public :
2021-04-15 21:20:04 +02:00
const char * getName ( ) const override {
2020-08-05 00:20:50 +05:30
return " agos " ;
}
2022-11-03 18:38:42 +00:00
const ADExtraGuiOptionsMap * getAdvancedExtraGuiOptions ( ) const override {
return AGOS : : optionsList ;
}
2021-04-15 21:20:04 +02:00
bool hasFeature ( MetaEngineFeature f ) const override ;
2020-08-05 00:20:50 +05:30
2021-11-29 01:21:20 +01:00
Common : : Error createInstance ( OSystem * syst , Engine * * engine ) override {
2020-08-05 00:20:50 +05:30
Engines : : upgradeTargetIfNecessary ( obsoleteGameIDsTable ) ;
2020-10-02 12:25:08 +05:30
return AdvancedMetaEngine : : createInstance ( syst , engine ) ;
2020-08-05 00:20:50 +05:30
}
2020-11-17 00:06:05 +00:00
Common : : Error createInstance ( OSystem * syst , Engine * * engine , const ADGameDescription * desc ) const override ;
2020-08-05 00:20:50 +05:30
SaveStateList listSaves ( const char * target ) const override ;
int getMaximumSaveSlot ( ) const override ;
} ;
2020-10-02 12:25:08 +05:30
bool AgosMetaEngine : : hasFeature ( MetaEngineFeature f ) const {
2020-08-05 00:20:50 +05:30
return
( f = = kSupportsListSaves ) | |
( f = = kSimpleSavesNames ) ;
}
bool AGOS : : AGOSEngine : : hasFeature ( EngineFeature f ) const {
return
( f = = kSupportsReturnToLauncher ) ;
}
2020-11-17 00:06:05 +00:00
Common : : Error AgosMetaEngine : : createInstance ( OSystem * syst , Engine * * engine , const ADGameDescription * desc ) const {
2020-08-05 00:20:50 +05:30
const AGOS : : AGOSGameDescription * gd = ( const AGOS : : AGOSGameDescription * ) desc ;
switch ( gd - > gameType ) {
case AGOS : : GType_PN :
* engine = new AGOS : : AGOSEngine_PN ( syst , gd ) ;
break ;
case AGOS : : GType_ELVIRA1 :
* engine = new AGOS : : AGOSEngine_Elvira1 ( syst , gd ) ;
break ;
case AGOS : : GType_ELVIRA2 :
* engine = new AGOS : : AGOSEngine_Elvira2 ( syst , gd ) ;
break ;
case AGOS : : GType_WW :
* engine = new AGOS : : AGOSEngine_Waxworks ( syst , gd ) ;
break ;
case AGOS : : GType_SIMON1 :
* engine = new AGOS : : AGOSEngine_Simon1 ( syst , gd ) ;
break ;
case AGOS : : GType_SIMON2 :
* engine = new AGOS : : AGOSEngine_Simon2 ( syst , gd ) ;
break ;
# ifdef ENABLE_AGOS2
case AGOS : : GType_FF :
if ( gd - > features & AGOS : : GF_DEMO )
* engine = new AGOS : : AGOSEngine_FeebleDemo ( syst , gd ) ;
else
* engine = new AGOS : : AGOSEngine_Feeble ( syst , gd ) ;
break ;
case AGOS : : GType_PP :
if ( gd - > gameId = = AGOS : : GID_DIMP )
* engine = new AGOS : : AGOSEngine_DIMP ( syst , gd ) ;
else
* engine = new AGOS : : AGOSEngine_PuzzlePack ( syst , gd ) ;
break ;
2020-12-04 13:36:56 +00:00
# else
case AGOS : : GType_FF :
case AGOS : : GType_PP :
return Common : : Error ( Common : : kUnsupportedGameidError , _s ( " AGOS 2 support is not compiled in " ) ) ;
2020-08-05 00:20:50 +05:30
# endif
default :
2020-11-17 00:06:05 +00:00
return Common : : kUnsupportedGameidError ;
2020-08-05 00:20:50 +05:30
}
2020-11-17 00:06:05 +00:00
return Common : : kNoError ;
2020-08-05 00:20:50 +05:30
}
2020-10-02 12:25:08 +05:30
SaveStateList AgosMetaEngine : : listSaves ( const char * target ) const {
2020-08-05 00:20:50 +05:30
Common : : SaveFileManager * saveFileMan = g_system - > getSavefileManager ( ) ;
Common : : StringArray filenames ;
Common : : String saveDesc ;
Common : : String pattern = target ;
pattern + = " .### " ;
filenames = saveFileMan - > listSavefiles ( pattern ) ;
SaveStateList saveList ;
for ( Common : : StringArray : : const_iterator file = filenames . begin ( ) ; file ! = filenames . end ( ) ; + + file ) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi ( file - > c_str ( ) + file - > size ( ) - 3 ) ;
if ( slotNum > = 0 & & slotNum < = 999 ) {
Common : : InSaveFile * in = saveFileMan - > openForLoading ( * file ) ;
if ( in ) {
saveDesc = file - > c_str ( ) ;
2021-10-19 09:28:14 +03:00
saveList . push_back ( SaveStateDescriptor ( this , slotNum , saveDesc ) ) ;
2020-08-05 00:20:50 +05:30
delete in ;
}
}
}
// Sort saves based on slot number.
Common : : sort ( saveList . begin ( ) , saveList . end ( ) , SaveStateDescriptorSlotComparator ( ) ) ;
return saveList ;
}
2020-10-02 12:25:08 +05:30
int AgosMetaEngine : : getMaximumSaveSlot ( ) const { return 999 ; }
2020-08-05 00:20:50 +05:30
# if PLUGIN_ENABLED_DYNAMIC(AGOS)
2020-10-02 12:25:08 +05:30
REGISTER_PLUGIN_DYNAMIC ( AGOS , PLUGIN_TYPE_ENGINE , AgosMetaEngine ) ;
2020-08-05 00:20:50 +05:30
# else
2020-10-02 12:25:08 +05:30
REGISTER_PLUGIN_STATIC ( AGOS , PLUGIN_TYPE_ENGINE , AgosMetaEngine ) ;
2020-08-05 00:20:50 +05:30
# endif
namespace AGOS {
int AGOSEngine : : getGameId ( ) const {
return _gameDescription - > gameId ;
}
int AGOSEngine : : getGameType ( ) const {
return _gameDescription - > gameType ;
}
uint32 AGOSEngine : : getFeatures ( ) const {
return _gameDescription - > features ;
}
const char * AGOSEngine : : getExtra ( ) const {
return _gameDescription - > desc . extra ;
}
Common : : Language AGOSEngine : : getLanguage ( ) const {
return _gameDescription - > desc . language ;
}
Common : : Platform AGOSEngine : : getPlatform ( ) const {
return _gameDescription - > desc . platform ;
}
const char * AGOSEngine : : getFileName ( int type ) const {
// Required if the InstallShield cab is been used
if ( getGameType ( ) = = GType_PP ) {
if ( type = = GAME_BASEFILE )
return gss - > base_filename ;
}
// Required if the InstallShield cab is been used
if ( getGameType ( ) = = GType_FF & & getPlatform ( ) = = Common : : kPlatformWindows ) {
if ( type = = GAME_BASEFILE )
return gss - > base_filename ;
if ( type = = GAME_RESTFILE )
return gss - > restore_filename ;
if ( type = = GAME_TBLFILE )
return gss - > tbl_filename ;
}
for ( int i = 0 ; _gameDescription - > desc . filesDescriptions [ i ] . fileType ; i + + ) {
if ( _gameDescription - > desc . filesDescriptions [ i ] . fileType = = type )
return _gameDescription - > desc . filesDescriptions [ i ] . fileName ;
}
2021-11-13 23:40:15 +02:00
return nullptr ;
2020-08-05 00:20:50 +05:30
}
# ifdef ENABLE_AGOS2
void AGOSEngine : : loadArchives ( ) {
const ADGameFileDescription * ag ;
if ( getFeatures ( ) & GF_PACKED ) {
for ( ag = _gameDescription - > desc . filesDescriptions ; ag - > fileName ; ag + + ) {
2021-04-26 14:51:10 +02:00
if ( ag - > fileType ! = GAME_CABFILE )
continue ;
2020-08-05 00:20:50 +05:30
if ( ! SearchMan . hasArchive ( ag - > fileName ) ) {
2021-05-10 22:14:16 +03:00
// Assumes the cabinet file is named data1.cab
Common : : Archive * cabinet = Common : : makeInstallShieldArchive ( " data " ) ;
if ( cabinet )
SearchMan . add ( ag - > fileName , cabinet ) ;
2020-08-05 00:20:50 +05:30
}
}
}
}
# endif
} // End of namespace AGOS