Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,129 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateDLLTestExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// IRC_init
// Used to connect to debug IRC server at games by Corbomite Games
// Specification: external "dlltest.dll" cdecl long IRC_init(string)
// Known usage: IRC_init(<PlayerName>)
// Known actions:
// 1. Connect to irc.starchat.net
// 2. Send "NICK ZU_<PlayerName>/"
// 3. Send "USER Blah ZbengHost ZbengServer ZbengRealname"
// 4. Send "Join #Zbeng"
// Returns 0 on success, other value on error
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "IRC_init") == 0) {
stack->correctParams(1);
/*const char *name =*/ stack->pop()->getString();
// do nothing
stack->pushInt(0);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// ChangeNick
// Used to update nick at debug IRC server at games by Corbomite Games
// Specification: external "dlltest.dll" cdecl long ChangeNick(string)
// Known usage: ChangeNick(<PlayerName>)
// Return value is never used
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "ChangeNick") == 0) {
stack->correctParams(1);
/*const char *name =*/ stack->pop()->getString();
// do nothing
stack->pushInt(0);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// IRC_SendString
// Used to send debug and chat lines to an IRC server at games by Corbomite Games
// Specification: external "dlltest.dll" cdecl IRC_SendString(string, string)
// Known usage: IRC_SendString(<Message>, <Channel>)
// Known Channel values are: "#Zbeng" and "#ZbengDebug"
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "IRC_SendString") == 0) {
stack->correctParams(2);
const char *message = stack->pop()->getString();
const char *channel = stack->pop()->getString();
inGame->LOG(0, "IRC logging: [%s] %s", channel, message);
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// IRC_GetChatStrings
// Used to get chat lines from an IRC server at games by Corbomite Games
// Specification: external "dlltest.dll" cdecl IRC_GetChatStrings(string, long)
// Known usage: IRC_GetChatStrings(<Buffer>, 65535)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "IRC_GetChatStrings") == 0) {
stack->correctParams(2);
/*const char *buffer =*/ stack->pop()->getString();
/*int bufferMaxSize =*/ stack->pop()->getInt();
// do nothing
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// IRC_quit
// Used to disconnect from debug IRC server at games by Corbomite Games
// Specification: external "dlltest.dll" cdecl IRC_quit()
// Known usage: IRC_quit()
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "IRC_quit") == 0) {
stack->correctParams(0);
// do nothing
stack->pushNULL();
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,72 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
// Implemented in their respective .cpp-files
bool EmulateGetURLExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// getURLContent
// Used to download news headlines at Demo 2012 of James Peris
// HTTP GET result is stored in 3rd param of the call as a plain string
// Specification: external "geturl.dll" cdecl getURLContent(string, string, string)
// Known usage: getURLContent("http://www.lacosaweb.com", <DirURL>, <Buffer>)
// Sets 3rd param to "Request Error." on error
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "getURLContent") == 0) {
stack->correctParams(3);
const char *domain = stack->pop()->getString();
const char *dirurl = stack->pop()->getString();
ScValue *buf = stack->pop();
if (strcmp(dirurl, "jpnews/demo-es1.txt") == 0) {
buf->setString("Ya disponible el juego completo en jamesperis.com");
} else if (strcmp(dirurl, "jpnews/demo-es2.txt") == 0) {
buf->setString("Cons\355guelo por solo 3,95 euros");
} else if (strcmp(dirurl, "jpnews/demo-en1.txt") == 0) {
buf->setString("You can get the full game in jamesperis.com");
} else if (strcmp(dirurl, "jpnews/demo-en2.txt") == 0) {
buf->setString("Get it for 3.95 euros");
} else {
warning("getURLContent(\"%s\",\"%s\",buf) is not implemented", domain, dirurl);
buf->setString("Request Error.");
}
stack->pushNULL();
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,163 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://res.dead-code.org/doku.php/wmelite:start
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateHTTPConnectExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// Register
// Used to register license key online at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
// Specification: external "httpconnect.dll" cdecl long Register(string, long, string, long)
// Known usage: Register(<productId>, 65535, <productKey>, 65535)
// Known product ID values are: "357868", "353058" and "353006"
// Known action: HTTP GET http://keygen.corbomitegames.com/keygen/validateKey.php?action=REGISTER&productId=productId&key=productKey
// Returns 1 on success
// Returns 0 on firewall error
// Returns -1 on invalid product key
// Returns -2 on invalid product ID
// Returns -3 on expired product key
// Returns -4 on invalid machine ID
// Returns -5 on number of installations exceeded
// Returns -6 on socket error
// Returns -7 on no internet connection
// Returns -8 on connection reset
// Returns -11 on validation temporary unavaliable
// Returns -12 on validation error
// For some reason always returns -7 for me in a test game
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "Register") == 0) {
stack->correctParams(4);
const char *productId = stack->pop()->getString();
int productIdMaxLen = stack->pop()->getInt();
const char *productKey = stack->pop()->getString();
int productKeyMaxLen = stack->pop()->getInt();
warning("Register(\"%s\",%d,\"%s\",%d) is not implemented", productId , productIdMaxLen, productKey, productKeyMaxLen);
stack->pushInt(-7); // "no internet connection" error
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Validate
// Used to validate something at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
// Specification: external "httpconnect.dll" cdecl long Validate()
// Known usage: Validate()
// Known action: HTTP GET http://keygen.corbomitegames.com/keygen/validateKey.php?action=VALIDATE&productId=Ar&key=Ar
// Used only when Debug mode is active or game is started with "INVALID" cmdline parameter
// For some reason always returns 1 for me in a test game
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "Validate") == 0) {
stack->correctParams(0);
// do nothing
stack->pushInt(1);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SendHTTPAsync
// Used to send game progress events to server at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
// Specification: external "httpconnect.dll" cdecl long SendHTTPAsync(string, long, string, long, string, long)
// Known usage: SendHTTPAsync("backend.pizzamorgana.com", 65535, <FullURL>, 65535, <Buffer?!>, 65535)
// FullURL is formed as "http://backend.pizzamorgana.com/event.php?Event=<EventName>&player=<PlayerName>&extraParams=<ExtraParams>&SN=<ProductKey>&Episode=1&GameTime=<CurrentTime>&UniqueID=<UniqueId>"
// Known EventName values are: "GameStart", "ChangeGoal", "EndGame" and "QuitGame"
// Known ExtraParams values are: "ACT0", "ACT1", "ACT2", "ACT3", "ACT4", "Ep0FindFood", "Ep0FindCellMenu", "Ep0BroRoom", "Ep0FindKey", "Ep0FindCellMenuKey", "Ep0FindMenuKey", "Ep0FindCell", "Ep0FindMenu", "Ep0OrderPizza", "Ep0GetRidOfVamp", "Ep0GetVampAttention", "Ep0License"
// Return value is never used
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "SendHTTPAsync") == 0) {
stack->correctParams(6);
const char *server = stack->pop()->getString();
int serverMaxLen = stack->pop()->getInt();
const char *fullUrl = stack->pop()->getString();
int fullUrlMaxLen = stack->pop()->getInt();
const char *param5 = stack->pop()->getString();
int param5MaxLen = stack->pop()->getInt();
// TODO: Maybe parse URL and call some Achievements API using ExtraParams values in some late future
warning("SendHTTPAsync(\"%s\",%d,\"%s\",%d,\"%s\",%d) is not implemented", server, serverMaxLen, fullUrl, fullUrlMaxLen, param5, param5MaxLen);
stack->pushInt(0);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SendRecvHTTP (6 params variant)
// Declared at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
// Seems to be unused, probably SendRecvHTTP was initially used instead of SendHTTPAsync
// Specification: external "httpconnect.dll" cdecl long SendRecvHTTP(string, long, string, long, string, long)
// Always returns -7 for me in a test game, probably returns the same network errors as Register()
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "SendRecvHTTP") == 0 && function->numParams == 6) {
stack->correctParams(6);
const char *server = stack->pop()->getString();
int serverMaxLen = stack->pop()->getInt();
const char *fullUrl = stack->pop()->getString();
int fullUrlMaxLen = stack->pop()->getInt();
const char *param5 = stack->pop()->getString();
int param5MaxLen = stack->pop()->getInt();
warning("SendRecvHTTP(\"%s\",%d,\"%s\",%d,\"%s\",%d) is not implemented", server, serverMaxLen, fullUrl, fullUrlMaxLen, param5, param5MaxLen);
stack->pushInt(-7); // "no internet connection" error
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SendRecvHTTP (4 params variant)
// Used to call HTTP methods at Zbang! The Game
// Specification: external "httpconnect.dll" cdecl long SendRecvHTTP(string, long, string, long)
// Known usage: SendRecvHTTP("scoresshort.php?player=<PlayerName>", 65535, <Buffer>, 65535)
// Known usage: SendRecvHTTP("/update.php?player=<PlayerName>&difficulty=<Difficulty>&items=<CommaSeparatedItemList>", 65535, <Buffer>, 65535)
// My Zbang demo does not have this dll, so there is no way to actually test it with a test game
// Return value is never used in Zbang scripts
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "SendRecvHTTP") == 0 && function->numParams == 4) {
stack->correctParams(4);
const char *dirUrl = stack->pop()->getString();
int dirUrlMaxLen = stack->pop()->getInt();
/*ScValue *buf =*/ stack->pop();
int bufMaxLen = stack->pop()->getInt();
//TODO: Count items and give scores, persist those values
warning("SendRecvHTTP(\"%s\",%d,buf,%d) is not implemented", dirUrl, dirUrlMaxLen, bufMaxLen);
stack->pushInt(0);
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,75 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateImgExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// changeWindowCaption
// Used to change game's window caption at games by HeroCraft
// Specification: external "img.dll" cdecl changeWindowCaption(long, string)
// Known usage: changeWindowCaption(Game.Hwnd, <Title>)
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "changeWindowCaption") == 0) {
stack->correctParams(2);
/*int hwnd =*/ stack->pop()->getInt();
/*const char *title =*/ stack->pop()->getString();
// do nothing
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// maximizedWindow
// Used to change game's window size at games by HeroCraft
// Specification: external "img.dll" cdecl maximizedWindow(long, long, long)
// Known usage: maximizedWindow(Game.Hwnd, 1024, 768)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "maximizedWindow") == 0) {
stack->correctParams(3);
/*int hwnd =*/ stack->pop()->getInt();
/*int width =*/ stack->pop()->getInt();
/*int height =*/ stack->pop()->getInt();
// do nothing
stack->pushNULL();
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,53 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateInstallUtilExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// _InstallUtilAnsi@0
// Used to check if DVD is inserted at Art of Murder: FBI Confidential
// Specification: external "installutil.dll" stdcall long _InstallUtilAnsi@0()
// Known usage: _InstallUtilAnsi@0()
// Returns 1 on success, other value on fail (which leads to Game.QuitGame() in non-Debug mode)
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "_InstallUtilAnsi@0") == 0) {
stack->correctParams(0);
stack->pushInt(1);
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,100 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateKernel32ExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// LoadLibraryA
// Used for checking library availability at games by Corbomite Games
// Specification: external "kernel32.dll" stdcall long LoadLibraryA(string)
// Known usage: LoadLibraryA("httpconnect.dll"), LoadLibraryA("dlltest.dll")
// Return values are only compared with zero and are never used in other APIs
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "LoadLibraryA") == 0) {
stack->correctParams(1);
const char *dllName = stack->pop()->getString();
int result = 0;
if (strcmp(dllName, "httpconnect.dll") == 0) {
result = 1; // some non-zero value
} else if (strcmp(dllName, "dlltest.dll") == 0) {
result = 2; // some other non-zero value
} else {
warning("LoadLibraryA(\"%s\") is not implemented", dllName);
}
stack->pushInt(result);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// FreeLibrary
// Declared at games by Corbomite Games
// Seems to be unused, probably was used for unloading IRC & HTTP libraries
// Specification: external "kernel32.dll" stdcall FreeLibrary(long)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "FreeLibrary") == 0) {
stack->correctParams(1);
/*int dllId =*/ stack->pop()->getInt();
// do nothing
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetEnvironmentVariableA
// Used for getting environment variables at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
// Specification: external "kernel32.dll" stdcall long GetEnvironmentVariableA(string, string, long)
// Known usage: GetEnvironmentVariableA(<EnvName>, <buffer>, 65535)
// Known EnvName values used in debug code: "USERKEY", "ALTUSERNAME", "ENHFINGERPRINT", "EXTRAINFO", "FINGERPRINT", "KEYSTRING", "STOLENKEY", "TRIAL"
// Known EnvName values used in licensing code: "FULLGAME"
//////////////////////////////////////////////////////////////////////////
else if (strcmp(function->name, "GetEnvironmentVariableA") == 0) {
stack->correctParams(3);
const char *name = stack->pop()->getString();
/*ScValue *buf =*/ stack->pop();
/*int bufMaxLen =*/ stack->pop()->getInt();
warning("Assuming variable \"%s\" is not set", name);
stack->pushInt(0);
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,118 @@
/* 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 "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateProtectExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// PSA_IsTrialMode
// Used to get if game is in trial mode for "Stroke of Fate: Operation Bunker"
// Specification: external "protect.dll" stdcall long PSA_IsTrialMode(membuffer);
// Known usage: long PSA_IsTrialMode(membuffer)
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "PSA_IsTrialMode") == 0) {
stack->correctParams(1);
/*void *buffer = */stack->pop()->getMemBuffer();
// do nothing
stack->pushInt(0);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// PSA_IsDemoMode
// Used to get if game is in trial mode for "Stroke of Fate: Operation Bunker"
// Specification: external "protect.dll" stdcall long PSA_IsDemoMode(membuffer);
// Known usage: long PSA_IsDemoMode(membuffer)
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "PSA_IsDemoMode") == 0) {
stack->correctParams(1);
/*void *buffer = */stack->pop()->getMemBuffer();
// do nothing
stack->pushInt(0);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// PSA_GetFeaturesGrantedByLicense
// Used to get if game features granted for "Stroke of Fate: Operation Bunker"
// Specification: external "protect.dll" stdcall long PSA_GetFeaturesGrantedByLicense(membuffer);
// Known usage: long PSA_GetFeaturesGrantedByLicense(membuffer)
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "PSA_GetFeaturesGrantedByLicense") == 0) {
stack->correctParams(1);
void *buffer = stack->pop()->getMemBuffer();
bool flag1 = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
bool flag5 = false;
*(uint32 *)(buffer) = (flag1 ? (1 << 0) : 0) | (flag2 ? (1 << 1) : 0) | (flag3 ? (1 << 2) : 0) | (flag4 ? (1 << 3) : 0) | (flag5 ? (1 << 4) : 0);
stack->pushInt(0);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// PSA_DisableFeaturesGrantedByLicense
// Reference in game scripts in "Stroke of Fate: Operation Bunker"
// Specification: external "protect.dll" stdcall long PSA_DisableFeaturesGrantedByLicense(membuffer);
// Known usage: none
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "PSA_DisableFeaturesGrantedByLicense") == 0) {
stack->correctParams(1);
/*void *buffer = */stack->pop()->getMemBuffer();
// do nothing
stack->pushInt(0);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// PSA_DummyFunction
// Reference in game scripts in "Stroke of Fate: Operation Bunker"
// Specification: external "protect.dll" stdcall void PSA_DummyFunction;
// Known usage: none
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "PSA_DummyFunction") == 0) {
stack->correctParams(0);
// do nothing
stack->pushNULL();
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,113 @@
/* 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 "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/file/base_savefile_manager_file.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateRoutineExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// GetCaption
// Used to get game's window caption for "Stroke of Fate" duology
// Specification: external "routine.dll" cdecl string GetCaption(int)
// Known usage: GetCaption(Game.Hwnd)
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "GetCaption") == 0) {
stack->correctParams(1);
/*int hwnd =*/ stack->pop()->getInt();
stack->pushString("Wintermute Engine");
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetCaption
// Used to change game's window caption for "Stroke of Fate" duology
// Specification: external "routine.dll" cdecl void SetCaption(int, string)
// Known usage: SetCaption(Game.Hwnd, <Title>)
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "SetCaption") == 0) {
stack->correctParams(2);
/*int hwnd =*/ stack->pop()->getInt();
/*const char *title =*/ stack->pop()->getString();
// do nothing
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetDPI
// Used to get display DPI for "Stroke of Fate" duology
// Specification: external "routine.dll" cdecl int GetDPI()
// Known usage: GetDPI()
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "GetDPI") == 0) {
stack->correctParams(0);
stack->pushInt(120); // standard Windows settings is 96 DPI, but 120 match original game
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// RemoveFile
// Used to remove screenshot files for "Stroke of Fate" duology
// Specification: external "routine.dll" cdecl bool RemoveFile(string)
// Known usage: RenameFile(oldname, newname);
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "RemoveFile") == 0) {
stack->correctParams(1);
const char *filename = stack->pop()->getString();
bool ret = sfmFileRemove(filename);
stack->pushInt(ret);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// RenameFile
// Used to rename screenshot files for "Stroke of Fate" duology
// Specification: external "routine.dll" cdecl bool RenameFile(string, string)
// Known usage: RenameFile(oldname, newname);
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "RenameFile") == 0) {
stack->correctParams(2);
const char *oldName = stack->pop()->getString();
const char *newName = stack->pop()->getString();
bool ret = sfmFileRename(oldName, newName);
stack->pushInt(ret);
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,66 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateShell32ExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// ShellExecuteA
// Used to open URL in browser at Wilma Tetris
// Specification: external "shell32.dll" stdcall long ShellExecuteA(long, string, string, string, string, long)
// Known usage: ShellExecuteA(0, "open", <URL>, "", "", 3)
// Returns value >32 on success
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "ShellExecuteA") == 0) {
stack->correctParams(6);
int hwnd = stack->pop()->getInt();
const char *operation = stack->pop()->getString();
const char *file = stack->pop()->getString();
const char *params = stack->pop()->getString();
const char *directory = stack->pop()->getString();
int cmd = stack->pop()->getInt();
if (strcmp(operation, "open") == 0 && !strlen(params) && !strlen(directory)) {
g_system->openUrl(file);
} else {
warning("ShellExecuteA(%d,\"%s\",\"%s\",\"%s\",\"%s\",%d) is not implemented", hwnd, operation, file, params, directory, cmd);
}
stack->pushInt(42);
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,63 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/gfx/base_renderer.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
namespace Wintermute {
bool EmulateToolsExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
//////////////////////////////////////////////////////////////////////////
// SetValueToReg
// Used to switch game's windowed/fullscreen mode at games by HeroCraft
// Specification: external "tools.dll" cdecl SetValueToReg(string, string, long)
// Known usage: SetValueToReg("Software\HeroCraft\<GameID>\Video", "Windowed", 1)
//////////////////////////////////////////////////////////////////////////
if (strcmp(function->name, "SetValueToReg") == 0) {
stack->correctParams(3);
const char *regpath = stack->pop()->getString();
const char *key = stack->pop()->getString();
int value = stack->pop()->getInt();
if (strcmp(key, "Windowed") == 0) {
inGame->_renderer->setWindowed(value);
} else {
warning("SetValueToReg(\"%s\",\"%s\",%d) is not implemented", regpath, key, value);
}
stack->pushNULL();
return STATUS_OK;
}
return STATUS_FAILED;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,98 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#ifndef WINTERMUTE_EXTERNALS_H
#define WINTERMUTE_EXTERNALS_H
namespace Wintermute {
// Implemented in their respective .cpp-files
bool EmulateGetURLExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateToolsExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateImgExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateShell32ExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateInstallUtilExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateDLLTestExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateKernel32ExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateHTTPConnectExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateRoutineExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateProtectExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
bool EmulateExternalCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
if (strcmp(function->dll_name, "geturl.dll") == 0) {
return EmulateGetURLExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "tools.dll") == 0) {
return EmulateToolsExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "img.dll") == 0) {
return EmulateImgExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "shell32.dll") == 0) {
return EmulateShell32ExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "installutil.dll") == 0) {
return EmulateInstallUtilExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "dlltest.dll") == 0) {
return EmulateDLLTestExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "kernel32.dll") == 0) {
return EmulateKernel32ExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "httpconnect.dll") == 0) {
return EmulateHTTPConnectExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "routine.dll") == 0) {
return EmulateRoutineExternalCalls(inGame, stack, thisStack, function);
}
if (strcmp(function->dll_name, "protect.dll") == 0) {
return EmulateProtectExternalCalls(inGame, stack, thisStack, function);
}
warning("External function %s from %s library is not known by ScummVM", function->name, function->dll_name);
return STATUS_FAILED;
}
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,89 @@
/* 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 WINTERMUTE_PLUGIN_EVENT_H
#define WINTERMUTE_PLUGIN_EVENT_H
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
// WME events
typedef enum {
WME_EVENT_UPDATE = 0,
WME_EVENT_SCENE_DRAW_BEGIN,
WME_EVENT_SCENE_DRAW_END,
WME_EVENT_SCENE_INIT,
WME_EVENT_SCENE_SHUTDOWN,
WME_EVENT_GAME_BEFORE_SAVE,
WME_EVENT_GAME_AFTER_LOAD,
WME_EVENT_MAX
} EWmeEvent;
typedef void (*PluginApplyEvent)(void *, void *);
typedef struct _PluginEventEntry {
EWmeEvent _type;
PluginApplyEvent _callback;
void *_plugin;
} PluginEventEntry;
class PluginEvent {
public:
PluginEvent() {};
~PluginEvent() {};
void subscribeEvent(PluginEventEntry &event) {
for (auto it = _entries.begin(); it != _entries.end(); ++it) {
if (event._type == (*it)._type && event._callback == (*it)._callback) {
break;
}
}
_entries.push_back(event);
}
void unsubscribeEvent(PluginEventEntry &event) {
for (auto it = _entries.begin(); it != _entries.end(); ++it) {
if (event._type == (*it)._type && event._callback == (*it)._callback) {
_entries.erase(it);
break;
}
}
}
void applyEvent(EWmeEvent type, void *eventData) {
for (auto it = _entries.begin(); it != _entries.end(); ++it) {
if (type == (*it)._type && (*it)._callback != nullptr) {
(*it)._callback(eventData, (*it)._plugin);
}
}
}
void clearEvents() {
_entries.clear();
}
private:
Common::List<PluginEventEntry> _entries;
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,179 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#ifndef WINTERMUTE_PLUGINS_H
#define WINTERMUTE_PLUGINS_H
namespace Wintermute {
// Implemented in their respective .cpp-files
BaseScriptable *makeSXSteamAPI(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXWMEGalaxyAPI(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSX3fStatistics(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXCommandLineHelper(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXSample(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXVlink(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXBlackAndWhite(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXShadowManager(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXDisplacement(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXProtection(BaseGame *inGame, ScStack *stack);
bool EmulatePluginCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, char *name) {
ScValue *thisObj;
//////////////////////////////////////////////////////////////////////////
// SteamAPI (from wme_steam.dll)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SteamAPI") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXSteamAPI(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// WMEGalaxyAPI (from GOG version of julia.exe)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WMEGalaxyAPI") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXWMEGalaxyAPI(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Statistics (from wme_3fstatistics.dll)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Statistics") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSX3fStatistics(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Commandline helper (from wme_commandlinehelper.dll)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CommandLineHelper") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXCommandLineHelper(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Window mode changer (from wme_windowmode.dll of "lostbride" game)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Sample") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXSample(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Displacement plugin (from wme_displacement.dll for "Beyond the Threshold" game)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Displacement") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXDisplacement(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Protection class for "Susan Rose: Mysterious Child" game)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Protection") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXProtection(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
#ifdef ENABLE_WME3D
//////////////////////////////////////////////////////////////////////////
// BinkVideo player (from wme_vlink.dll of "Sunrise" game)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "BinkVideo") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXVlink(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// BlackAndWhite (from wme_blackandwhite.dll of "Stroke of Fate" duology games)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "BlackAndWhite") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXBlackAndWhite(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// ShadowManager (from wme_shadows.dll of "Stroke of Fate" duology games)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ShadowManager") == 0) {
thisObj = thisStack->getTop();
thisObj->setNative(makeSXShadowManager(inGame, stack));
stack->pushNULL();
return STATUS_OK;
}
#endif
return STATUS_FAILED;
}
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,48 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/ext/scene_achievements_tables.h"
#include "engines/wintermute/ext/wme_steam.h"
namespace Wintermute {
void SceneAchievements(const char *sceneFilename) {
for (const AchievementsList *i = achievementsList; i->gameId; i++) {
if (BaseEngine::instance().getGameId() == i->gameId) {
for (const Achievement *it = i->mapping; it->sceneFilename; it++) {
if (strcmp(sceneFilename, it->sceneFilename) == 0) {
AchMan.setActiveDomain(getAchievementsInfo());
AchMan.setAchievement(it->id);
return;
}
}
}
}
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,81 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
namespace Wintermute {
struct Achievement {
const char *sceneFilename;
const char *id;
};
struct AchievementsList {
const char *gameId;
const Achievement mapping[64];
};
static const AchievementsList achievementsList[] = {
{
"carolreed10",
{
{"scenes\\barn\\barn_intro\\barn_intro.scene", "BARN"},
{"scenes\\brother\\bro_intro\\bro_intro.scene", "CAR_GRAVEYARD"},
{"scenes\\church\\church_intro\\church_intro.scene", "SAINT_MARIA_CHURCH"},
{"scenes\\emhart\\emhart_intro\\emhart_intro.scene", "EMHART_ZURICH"},
{"scenes\\falls_day\\falls_intro\\falls_intro.scene", "BLOOD_FALLS"},
{"scenes\\forge\\forge_intro\\forge_intro.scene", "SONIC_FORGE"},
{"scenes\\mansion\\mans_intro\\mans_intro.scene", "STIERN_HOUSE"},
{"scenes\\mus_malte\\mus_malte_intro\\mus_malte_intro.scene", "MALTE_MUSEUM"},
{"scenes\\mus_school\\mus_sch_intro\\mus_sch_intro.scene", "SCHOOL_MUSEUM"},
{"scenes\\peak\\kvarn_intro\\kvarn_intro.scene", "JOHANSSON_PEAK"},
{"scenes\\pyramid\\pyr_intro\\pyr_intro.scene", "PYRAMID"},
{"scenes\\ski\\dala_intro\\dala_intro.scene", "SKIING_HOUSE"},
{"scenes\\train\\train_intro\\train_intro.scene", "MALTES_TRAIN"},
{0,0}
}
},
{
"carolreed11",
{
{"scenes\\barn\\barn15d_cl\\barn15d_cl.scene", "PIPE"},
{"scenes\\black\\black02b_lift\\black02b_lift.scene", "NOTE"},
{"scenes\\black\\black02d_op_lift\\black02d_op_lift.scene", "BOTTLE"},
{"scenes\\cannon\\can11a_op\\can11a_op.scene", "WINDOW"},
{"scenes\\hobby\\hobby01a_cl1_moved\\hobby01a_cl1_moved.scene", "STONE"},
{"scenes\\m_house\\m03c_op2_lift3\\m03c_op2_lift3.scene", "BLINDFOLD"},
{"scenes\\m_house\\m04b_cl1_op1_lift3\\m04b_cl1_op1_lift3.scene", "POEM"},
{"scenes\\m_house\\m07d_tap1\\m07d_tap1.scene", "TESTING"},
{"scenes\\mine\\mine15d_lift1\\mine15d_lift1.scene", "MINE_LADY"},
{"scenes\\office\\office02d_cl2_lift\\office02d_cl2_lift.scene", "PENCIL"},
{0,0}
}
},
{0, {{0,0}}}
};
} // End of namespace Wintermute

View File

@@ -0,0 +1,42 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#ifndef WINTERMUTE_SCENE_HOOKS_H
#define WINTERMUTE_SCENE_HOOKS_H
namespace Wintermute {
// Implemented in their respective .cpp-files
void SceneAchievements(const char *sceneFilename);
void EmulateSceneHook(const char *sceneFilename) {
SceneAchievements(sceneFilename);
}
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,172 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_3fstatistics.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SX3fStatistics, false)
BaseScriptable *makeSX3fStatistics(BaseGame *inGame, ScStack *stack) {
return new SX3fStatistics(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SX3fStatistics::SX3fStatistics(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(4);
ScValue * tmp;
_baseUrl = stack->pop()->getString();
tmp = stack->pop();
_chapter = tmp->isNULL() ? "" : tmp->getString();
tmp = stack->pop();
_language = tmp->isNULL() ? "" : tmp->getString();
tmp = stack->pop();
_buildNum = tmp->isNULL() ? "" : tmp->getString();
_repeat = 0;
_game->LOG(0, "new Statistics(\"%s\", \"%s\", \"%s\", \"%s\")", _baseUrl.c_str(), _chapter.c_str(), _language.c_str(), _buildNum.c_str());
}
//////////////////////////////////////////////////////////////////////////
SX3fStatistics::~SX3fStatistics() {
}
//////////////////////////////////////////////////////////////////////////
const char *SX3fStatistics::scToString() {
return "[statistics object]";
}
//////////////////////////////////////////////////////////////////////////
bool SX3fStatistics::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// Send()
// Known stats to send are "Start a new game" and "--Juego Finalizado--"
// Known action: send HTTP POST request to _baseUrl
//
// Headers:
// Accept: */*
// User-Agent: Mozilla/4.0
// Content-Length: <len>
// Accept-Language: en-us
// Host: www.soluciones3f.com.ar
//
// Body:
// {
// "capitulo": "<_chapter value, e.g. '1'>",
// "dispositivo": "<OS family, e.g. 'windows'>",
// "hash": "<MD5 of MAC address, e.g. '58cb64ba781ca09f9e9cf8bd51ff0b05' for 44:8a:5b:00:00:00>",
// "idioma": "<_language value, e.g. 'ru'>",
// "idioma_os": "<OS language code, e.g. 'Russian_Russia.1251'>",
// "memoria": "<RAM size in bytes, e.g. '8504971264'>",
// "message": "<message value, e.g. 'Start a new game'>",
// "procesador": "<CPU model name, see /proc/cpuinfo for examples>",
// "resolucion": "<screen resolution, e.g. '1920x1080'>",
// "sistema": "<OS version, e.g. 'Microsoft (build 9200), 64-bit'",
// "version": "<_buildNum value, e.g. '1.3.2369'>",
// "windowed": "<screen mode windowed flag, e.g. 'yes'>"
// }
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Send") == 0) {
stack->correctParams(1);
const char *message = stack->pop()->getString();
_game->LOG(0, "Send(\"%s\")", message);
// do nothing
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetRepeat()
// Known _repeat values are 0 and 60
// Known action: set timer to send HTTP POST request every _repeat seconds
// HTTP POST request is the same as with Send(), message is "Tick"
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetRepeat") == 0) {
stack->correctParams(1);
_repeat = stack->pop()->getInt();
// do nothing
stack->pushNULL();
return STATUS_OK;
}
else {
return STATUS_FAILED;
}
}
//////////////////////////////////////////////////////////////////////////
ScValue *SX3fStatistics::scGetProperty(const char *name) {
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
// Type (RO)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Type") == 0) {
_scValue->setString("statistics");
return _scValue;
}
else {
return _scValue;
}
}
//////////////////////////////////////////////////////////////////////////
bool SX3fStatistics::scSetProperty(const char *name, ScValue *value) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SX3fStatistics::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
persistMgr->transferString(TMEMBER(_baseUrl));
persistMgr->transferString(TMEMBER(_chapter));
persistMgr->transferString(TMEMBER(_language));
persistMgr->transferString(TMEMBER(_buildNum));
persistMgr->transferSint32(TMEMBER(_repeat));
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,56 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#ifndef WINTERMUTE_SX3FSTATISTICS_H
#define WINTERMUTE_SX3FSTATISTICS_H
#include "common/str.h"
#include "engines/wintermute/base/base_scriptable.h"
namespace Wintermute {
class SX3fStatistics : public BaseScriptable {
public:
DECLARE_PERSISTENT(SX3fStatistics, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SX3fStatistics(BaseGame *inGame, ScStack *stack);
~SX3fStatistics() override;
private:
Common::String _baseUrl;
Common::String _chapter;
Common::String _language;
Common::String _buildNum;
int32 _repeat{};
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,250 @@
/* 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 "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_blackandwhite.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXBlackAndWhite, false)
BaseScriptable *makeSXBlackAndWhite(BaseGame *inGame, ScStack *stack) {
return new SXBlackAndWhite(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SXBlackAndWhite::SXBlackAndWhite(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(0);
_postFilterMode = kPostFilterOff;
}
//////////////////////////////////////////////////////////////////////////
SXBlackAndWhite::~SXBlackAndWhite() {
}
//////////////////////////////////////////////////////////////////////////
const char *SXBlackAndWhite::scToString() {
return "[blackandwhite object]";
}
//////////////////////////////////////////////////////////////////////////
bool SXBlackAndWhite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// Start()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Start") == 0) {
stack->correctParams(0);
// nothing todo
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Stop()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Stop") == 0) {
stack->correctParams(0);
// nothing todo
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetSepia()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetSepia") == 0) {
stack->correctParams(0);
_postFilterMode = kPostFilterSepia;
_game->_renderer3D->setPostfilter(_postFilterMode);
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetBlackAndWhite()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetBlackAndWhite") == 0) {
stack->correctParams(0);
_postFilterMode = kPostFilterBlackAndWhite;
_game->_renderer3D->setPostfilter(_postFilterMode);
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetNormalRender()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetNormalRender") == 0) {
stack->correctParams(0);
_postFilterMode = kPostFilterOff;
_game->_renderer3D->setPostfilter(_postFilterMode);
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetWeightedSepia()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetWeightedSepia") == 0) {
stack->correctParams(0);
// nothing todo
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetWeightedBlackAndWhite()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetWeightedBlackAndWhite") == 0) {
stack->correctParams(0);
// nothing todo
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetSepiaBlackAndWhite()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetSepiaBlackAndWhite") == 0) {
stack->correctParams(0);
// nothing todo
stack->pushBool(true);
return STATUS_OK;
}
stack->pushNULL();
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXBlackAndWhite::scGetProperty(const char *name) {
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
// Weight
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Weight") == 0) {
// nothing todo
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// AllShadersAvailable
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AllShadersAvailable") == 0) {
_scValue->setBool(false);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// BlackAndWhiteAvailable
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "BlackAndWhiteAvailable") == 0) {
_scValue->setBool(true);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// SepiaAvailable
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SepiaAvailable") == 0) {
_scValue->setBool(true);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// WeightedBlackAndWhiteAvailable
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WeightedBlackAndWhiteAvailable") == 0) {
_scValue->setBool(false);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// WeightedSepiaAvailable
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WeightedSepiaAvailable") == 0) {
_scValue->setBool(false);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// SepiaBlackAndWhiteAvailable
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SepiaBlackAndWhiteAvailable") == 0) {
_scValue->setBool(false);
return _scValue;
}
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
bool SXBlackAndWhite::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
// Weight
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Weight") == 0) {
// nothing todo
return STATUS_OK;
}
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXBlackAndWhite::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
persistMgr->transferSint32(TMEMBER_INT(_postFilterMode));
if (!persistMgr->getIsSaving()) {
_game->_renderer3D->setPostfilter(_postFilterMode);
}
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,48 @@
/* 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 WINTERMUTE_BLACKANDWHITE_H
#define WINTERMUTE_BLACKANDWHITE_H
#include "common/str.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/gfx/base_renderer3d.h"
namespace Wintermute {
class SXBlackAndWhite : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXBlackAndWhite, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXBlackAndWhite(BaseGame *inGame, ScStack *stack);
~SXBlackAndWhite() override;
private:
PostFilter _postFilterMode{};
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,102 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_commandlinehelper.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXCommandLineHelper, false)
BaseScriptable *makeSXCommandLineHelper(BaseGame *inGame, ScStack *stack) {
return new SXCommandLineHelper(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SXCommandLineHelper::SXCommandLineHelper(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(0);
_game->LOG(0, "new SXCommandLineHelper()");
}
//////////////////////////////////////////////////////////////////////////
SXCommandLineHelper::~SXCommandLineHelper() {
}
//////////////////////////////////////////////////////////////////////////
const char *SXCommandLineHelper::scToString() {
return "[commandlinehelper object]";
}
//////////////////////////////////////////////////////////////////////////
bool SXCommandLineHelper::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXCommandLineHelper::scGetProperty(const char *name) {
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
// Parameters (RO)
// Used to launch demo: "Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest"
// 'DEMO', 'FULLDEMO'
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Parameters") == 0) {
_scValue->setString("Pizza.exe DEMO");
return _scValue;
}
else {
return _scValue;
}
}
//////////////////////////////////////////////////////////////////////////
bool SXCommandLineHelper::scSetProperty(const char *name, ScValue *value) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXCommandLineHelper::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,51 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#ifndef WINTERMUTE_COMMANDLINEHELPER_H
#define WINTERMUTE_COMMANDLINEHELPER_H
#include "common/str.h"
#include "engines/wintermute/base/base_scriptable.h"
namespace Wintermute {
class SXCommandLineHelper : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXCommandLineHelper, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXCommandLineHelper(BaseGame *inGame, ScStack *stack);
~SXCommandLineHelper() override;
private:
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,243 @@
/* 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 "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_displacement.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXDisplacement, false)
BaseScriptable *makeSXDisplacement(BaseGame *inGame, ScStack *stack) {
return new SXDisplacement(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SXDisplacement::SXDisplacement(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(5);
_subFrameSrc = static_cast<BaseSubFrame *>(stack->pop()->getNative());
_subFrameDst = static_cast<BaseSubFrame *>(stack->pop()->getNative());
_forceX = stack->pop()->getInt();
_forceY = stack->pop()->getInt();
_speed = stack->pop()->getInt();
_animIndex = 0;
for (int32 i = 0; i < 1024; i++) {
_tableX[i] = sin(i * 6.283 / 128.0);
_tableY[i] = cos(i * 6.283 / 128.0);
}
int32 width = _subFrameSrc->getWidth();
int32 height = _subFrameSrc->getHeight();
_subFrameSrc->startPixelOperations();
_subFrameDst->startPixelOperations();
for (int32 y = 0; y < height; y++) {
for (int32 x = 0; x < width; x++) {
uint32 pixel = _subFrameSrc->getPixel(x, y);
_subFrameDst->putPixel(x, y, pixel);
}
}
_subFrameSrc->endPixelOperations();
_subFrameDst->endPixelOperations();
}
//////////////////////////////////////////////////////////////////////////
SXDisplacement::~SXDisplacement() {
}
//////////////////////////////////////////////////////////////////////////
const char *SXDisplacement::scToString() {
return "[displacement object]";
}
//////////////////////////////////////////////////////////////////////////
bool SXDisplacement::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// SetMe()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetMe") == 0) {
stack->correctParams(2);
_subFrameSrc = static_cast<BaseSubFrame *>(stack->pop()->getNative());
_subFrameDst = static_cast<BaseSubFrame *>(stack->pop()->getNative());
stack->pushBool(false);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Setforces()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Setforces") == 0) {
stack->correctParams(3);
_forceX = stack->pop()->getInt();
_forceY = stack->pop()->getInt();
_speed = stack->pop()->getInt();
stack->pushBool(false);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Animate()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Animate") == 0) {
stack->correctParams(0);
if (_subFrameSrc) {
int32 width = _subFrameSrc->getWidth();
int32 height = _subFrameSrc->getHeight();
_subFrameSrc->startPixelOperations();
_subFrameDst->startPixelOperations();
for (int32 y = 0; y < height; y++) {
for (int32 x = 0; x < width; x++) {
uint32 pixel = _subFrameSrc->getPixel(x, y);
_subFrameDst->putPixel(x, y, pixel);
}
}
_animIndex += _speed;
if (_animIndex > 128)
_animIndex = 0;
for (int32 y = 0; y < height; y++) {
for (int32 x = 0; x < width; x++) {
uint32 pixel = _subFrameSrc->getPixel(x, y);
int32 offsetX = (int32)(_forceX * _tableX[_animIndex + x]);
int32 offsetY = (int32)(_forceY * _tableY[_animIndex + y]);
if (width > (x + offsetX) &&
height > (y + offsetY) &&
(x + offsetX) >= 0 &&
(y + offsetY) >= 0) {
_subFrameDst->putPixel(x + offsetX, y + offsetY, pixel);
}
}
}
_subFrameSrc->endPixelOperations();
_subFrameDst->endPixelOperations();
stack->pushBool(true);
return STATUS_OK;
} else {
stack->pushBool(false);
}
}
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXDisplacement::scGetProperty(const char *name) {
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
// ForceX
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "ForceX") == 0) {
_scValue->setInt(_forceX);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// ForceY
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "ForceY") == 0) {
_scValue->setInt(_forceY);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// Speed
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Speed") == 0) {
_scValue->setInt(_speed);
return _scValue;
}
else {
return _scValue;
}
}
//////////////////////////////////////////////////////////////////////////
bool SXDisplacement::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
// ForceX
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "ForceX") == 0) {
_forceX = _scValue->getInt();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// ForceY
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "ForceY") == 0) {
_forceY = _scValue->getInt();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Speed
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Speed") == 0) {
_speed = _scValue->getInt();
return STATUS_OK;
}
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXDisplacement::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
persistMgr->transferPtr(TMEMBER_PTR(_subFrameSrc));
persistMgr->transferPtr(TMEMBER_PTR(_subFrameDst));
persistMgr->transferSint32(TMEMBER(_forceX));
persistMgr->transferSint32(TMEMBER(_forceY));
persistMgr->transferSint32(TMEMBER(_speed));
persistMgr->transferSint32(TMEMBER(_animIndex));
if (!persistMgr->getIsSaving()) {
for (int32 i = 0; i < 1024; i++) {
_tableX[i] = sin(i * 6.283 / 128.0);
_tableY[i] = cos(i * 6.283 / 128.0);
}
}
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,53 @@
/* 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 WINTERMUTE_DISPLACEMENT_H
#define WINTERMUTE_DISPLACEMENT_H
#include "common/str.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/base_sub_frame.h"
namespace Wintermute {
class SXDisplacement : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXDisplacement, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXDisplacement(BaseGame *inGame, ScStack *stack);
~SXDisplacement() override;
private:
BaseSubFrame *_subFrameSrc;
BaseSubFrame *_subFrameDst;
int32 _forceX;
int32 _forceY;
int32 _speed;
int32 _animIndex;
double _tableX[1024];
double _tableY[1024];
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,138 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_galaxy.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXWMEGalaxyAPI, false)
BaseScriptable *makeSXWMEGalaxyAPI(BaseGame *inGame, ScStack *stack) {
return new SXWMEGalaxyAPI(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SXWMEGalaxyAPI::SXWMEGalaxyAPI(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(0);
init();
}
//////////////////////////////////////////////////////////////////////////
void SXWMEGalaxyAPI::init() {
const MetaEngine *meta = g_engine->getMetaEngine();
const Common::String target = BaseEngine::instance().getGameTargetName();
AchMan.setActiveDomain(meta->getAchievementsInfo(target));
}
//////////////////////////////////////////////////////////////////////////
SXWMEGalaxyAPI::~SXWMEGalaxyAPI() {
}
//////////////////////////////////////////////////////////////////////////
const char *SXWMEGalaxyAPI::scToString() {
return "[wmegalaxyapi object]";
}
//////////////////////////////////////////////////////////////////////////
bool SXWMEGalaxyAPI::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// InitGalaxy()
// Initialization is already done at the constructor instead
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "InitGalaxy") == 0) {
stack->correctParams(2);
const char *clientId = stack->pop()->getString();
const char *clientSecret = stack->pop()->getString();
AchMan.setSpecialString("clientId", clientId);
AchMan.setSpecialString("clientSecret", clientSecret);
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetAchievement(string id)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetAchievement") == 0) {
stack->correctParams(1);
const char *id = stack->pop()->getString();
stack->pushBool(AchMan.setAchievement(id));
return STATUS_OK;
}
else {
return STATUS_FAILED;
}
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXWMEGalaxyAPI::scGetProperty(const char *name) {
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
// Type (RO)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Type") == 0) {
_scValue->setString("wmegalaxyapi");
return _scValue;
}
else {
return _scValue;
}
}
//////////////////////////////////////////////////////////////////////////
bool SXWMEGalaxyAPI::scSetProperty(const char *name, ScValue *value) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXWMEGalaxyAPI::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
if (!persistMgr->getIsSaving()) {
init();
}
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,52 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#ifndef WINTERMUTE_SXWMEGALAXYAPI_H
#define WINTERMUTE_SXWMEGALAXYAPI_H
#include "engines/achievements.h"
#include "wintermute/base/base_scriptable.h"
namespace Wintermute {
class SXWMEGalaxyAPI : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXWMEGalaxyAPI, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXWMEGalaxyAPI(BaseGame *inGame, ScStack *stack);
~SXWMEGalaxyAPI() override;
private:
void init();
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,90 @@
/* 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 "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_protection.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXProtection, false)
BaseScriptable *makeSXProtection(BaseGame *inGame, ScStack *stack) {
return new SXProtection(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SXProtection::SXProtection(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(0);
}
//////////////////////////////////////////////////////////////////////////
SXProtection::~SXProtection() {
}
//////////////////////////////////////////////////////////////////////////
const char *SXProtection::scToString() {
return "[protection object]";
}
//////////////////////////////////////////////////////////////////////////
bool SXProtection::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// CheckExeProtection
// Reference in game scripts in "Susan Rose: Mysterious Child"
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "CheckExeProtection") == 0) {
stack->correctParams(0);
stack->pushInt(1);
return STATUS_OK;
}
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXProtection::scGetProperty(const char *name) {
_scValue->setNULL();
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
bool SXProtection::scSetProperty(const char *name, ScValue *value) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXProtection::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,43 @@
/* 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 WINTERMUTE_PROTECTION_H
#define WINTERMUTE_PROTECTION_H
#include "common/str.h"
#include "engines/wintermute/base/base_scriptable.h"
namespace Wintermute {
class SXProtection : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXProtection, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXProtection(BaseGame *inGame, ScStack *stack);
~SXProtection() override;
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,463 @@
/* 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 "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/gfx/3dlight.h"
#include "engines/wintermute/ad/ad_game.h"
#include "engines/wintermute/ad/ad_scene.h"
#include "engines/wintermute/ad/ad_scene_geometry.h"
#include "engines/wintermute/ad/ad_actor_3dx.h"
#include "engines/wintermute/ext/wme_shadowmanager.h"
#include "engines/wintermute/ext/plugin_event.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXShadowManager, false)
BaseScriptable *makeSXShadowManager(BaseGame *inGame, ScStack *stack) {
return new SXShadowManager(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SXShadowManager::SXShadowManager(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(0);
PluginEventEntry event;
event._type = WME_EVENT_UPDATE;
event._callback = callback;
event._plugin = this;
_game->pluginEvents().subscribeEvent(event);
_defaultLightPos = DXVector3(1.0f, 200.0f, 1.0f);
_minShadow = 0.1f;
_maxShadow = 1.0f;
_useSmartShadows = false;
_shadowColor = 0x80000000;
}
//////////////////////////////////////////////////////////////////////////
SXShadowManager::~SXShadowManager() {
PluginEventEntry event;
event._type = WME_EVENT_UPDATE;
event._callback = callback;
event._plugin = this;
_game->pluginEvents().unsubscribeEvent(event);
}
//////////////////////////////////////////////////////////////////////////
const char *SXShadowManager::scToString() {
return "[shadowmanager object]";
}
//////////////////////////////////////////////////////////////////////////
bool SXShadowManager::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// Run()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Run") == 0) {
stack->correctParams(0);
run();
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// Stop()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Stop") == 0) {
stack->correctParams(0);
stop();
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// AddActor(string)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "AddActor") == 0) {
stack->correctParams(1);
AdObject *obj = (AdObject *)stack->pop()->getNative();
if (obj) {
if (strcmp(obj->scGetProperty("Type")->getString(), "actor3dx") == 0) {
AdActor3DX *actor = (AdActor3DX *)obj;
stack->pushBool(addActor(actor));
}
}
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// RemoveActor(string)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "RemoveActor") == 0) {
stack->correctParams(1);
// nothing todo
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// RemoveAllActors()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "RemoveAllActors") == 0) {
stack->correctParams(0);
stack->pushBool(removeAllActors());
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetNumLights()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetNumLights") == 0) {
stack->correctParams(0);
// nothing todo
stack->pushInt(0);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetLightInfo()
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetLightInfo") == 0) {
stack->correctParams(1);
// nothing todo
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetDefaultLightPos(float, float, float)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetDefaultLightPos") == 0) {
stack->correctParams(3);
_defaultLightPos._x = stack->pop()->getFloat();
_defaultLightPos._y = stack->pop()->getFloat();
_defaultLightPos._z = stack->pop()->getFloat();
stack->pushBool(true);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// EnableLight(string)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "EnableLight") == 0) {
stack->correctParams(1);
const char *lightName = stack->pop()->getString();
stack->pushBool(enableLight(lightName));
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// DisableLight(string)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "DisableLight") == 0) {
stack->correctParams(1);
const char *lightName = stack->pop()->getString();
stack->pushBool(disableLight(lightName));
return STATUS_OK;
}
stack->pushNULL();
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXShadowManager::scGetProperty(const char *name) {
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
// DefaultLightPos
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "DefaultLightPos") == 0) {
_scValue->setProperty("x", _defaultLightPos._x);
_scValue->setProperty("y", _defaultLightPos._y);
_scValue->setProperty("z", _defaultLightPos._z);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// DefaultLightPosX
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DefaultLightPosX") == 0) {
_scValue->setFloat(_defaultLightPos._x);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// DefaultLightPosY
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DefaultLightPosY") == 0) {
_scValue->setFloat(_defaultLightPos._y);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// DefaultLightPosZ
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DefaultLightPosZ") == 0) {
_scValue->setFloat(_defaultLightPos._z);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// MinShadow
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MinShadow") == 0) {
_scValue->setFloat(_minShadow);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// MaxShadow
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MaxShadow") == 0) {
_scValue->setFloat(_maxShadow);
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// UseSmartShadows
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "UseSmartShadows") == 0) {
_scValue->setBool(_useSmartShadows);
return _scValue;
}
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
bool SXShadowManager::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
// DefaultLightPos
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "DefaultLightPos") == 0) {
_defaultLightPos._x = value->getProp("x")->getFloat();
_defaultLightPos._y = value->getProp("y")->getFloat();
_defaultLightPos._z = value->getProp("z")->getFloat();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// DefaultLightPosX
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DefaultLightPosX") == 0) {
_defaultLightPos._x = value->getFloat();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// DefaultLightPosY
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DefaultLightPosY") == 0) {
_defaultLightPos._y = value->getFloat();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// DefaultLightPosZ
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DefaultLightPosZ") == 0) {
_defaultLightPos._z = value->getFloat();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// MinShadow
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MinShadow") == 0) {
_minShadow = value->getFloat();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// MaxShadow
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MaxShadow") == 0) {
_maxShadow = value->getFloat();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// UseSmartShadows
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "UseSmartShadows") == 0) {
_useSmartShadows = value->getBool();
return STATUS_OK;
}
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXShadowManager::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
if (!persistMgr->getIsSaving()) {
PluginEventEntry event;
event._type = WME_EVENT_UPDATE;
event._callback = callback;
event._plugin = this;
_game->pluginEvents().subscribeEvent(event);
// Actor and light lists is not get restored, plugin is not designed to work this way.
// Lists get refreshed by game script on scene change.
_actors.clear();
_lights.clear();
}
persistMgr->transferUint32(TMEMBER(_lastTime));
persistMgr->transferVector3d(TMEMBER(_defaultLightPos));
persistMgr->transferFloat(TMEMBER(_minShadow));
persistMgr->transferFloat(TMEMBER(_maxShadow));
persistMgr->transferBool(TMEMBER(_useSmartShadows));
return STATUS_OK;
}
void SXShadowManager::callback(void *eventData1, void *eventData2) {
SXShadowManager *shadowManager = (SXShadowManager *)eventData2;
uint32 time = shadowManager->_game->scGetProperty("CurrentTime")->getInt();
if (time - shadowManager->_lastTime > 20) {
shadowManager->_lastTime = time;
shadowManager->update();
}
}
void SXShadowManager::update() {
if (_useSmartShadows) {
AdGame *adGame = (AdGame *)_game;
if (!adGame->_scene || !adGame->_scene->_geom)
return;
for (auto actorIt = _actors.begin(); actorIt != _actors.end(); ++actorIt) {
_shadowColor = 0x00000000;
float shadowWeight = 0.0f;
uint32 numLights = 0;
for (auto lightIt = _lights.begin(); lightIt != _lights.end(); ++lightIt) {
if (!lightIt->second)
continue;
auto light = lightIt->first;
if (light->_isSpotlight)
continue;
float weight1 = 0.0 * 0.11f; // TODO
float r = RGBCOLGetR(light->_diffuseColor) / 255.0f;
float g = RGBCOLGetG(light->_diffuseColor) / 255.0f;
float b = RGBCOLGetB(light->_diffuseColor) / 255.0f;
float brightness = (r + g + b) / 3.0f;
float weight2 = brightness * 0.59f;
float weight3 = 0.0 * 0.3; // TODO
shadowWeight += (weight1 + weight2 + weight3);
numLights++;
}
if (numLights != 0)
shadowWeight /= numLights;
_shadowColor = (byte)(shadowWeight * 255) << 24;
actorIt->first->_shadowLightPos = _defaultLightPos;
actorIt->first->_shadowColor = _shadowColor;
}
}
}
void SXShadowManager::run() {
_lastTime = _game->scGetProperty("CurrentTime")->getInt();
_lights.clear();
AdGame *adGame = (AdGame *)_game;
if (!adGame->_scene || !adGame->_scene->_geom)
return;
for (int32 l = 0; l < adGame->_scene->_geom->_lights.getSize(); l++) {
auto light = adGame->_scene->_geom->_lights[l];
_lights.push_back(Common::Pair<Light3D *, bool>(light, true));
}
}
void SXShadowManager::stop() {
_lights.clear();
}
bool SXShadowManager::addActor(AdActor3DX *actorObj) {
if (_useSmartShadows) {
_actors.push_back(Common::Pair<AdActor3DX *, uint32>(actorObj, actorObj->_shadowColor));
}
return true;
}
bool SXShadowManager::removeAllActors() {
for (auto it = _actors.begin(); it != _actors.end(); ++it) {
it->first->_shadowColor = it->second;
}
_actors.clear();
return true;
}
bool SXShadowManager::enableLight(const char *lightName) {
for (auto it = _lights.begin(); it != _lights.end(); ++it) {
if (scumm_stricmp(it->first->_name, lightName) == 0)
it->second = true;
}
return true;
}
bool SXShadowManager::disableLight(const char *lightName) {
for (auto it = _lights.begin(); it != _lights.end(); ++it) {
if (scumm_stricmp(it->first->_name, lightName) == 0)
it->second = false;
}
return true;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,66 @@
/* 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 WINTERMUTE_SHADOWMANAGER_H
#define WINTERMUTE_SHADOWMANAGER_H
#include "common/str.h"
#include "engines/wintermute/base/base_scriptable.h"
namespace Wintermute {
class AdActor3DX;
class Light3D;
class SXShadowManager : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXShadowManager, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXShadowManager(BaseGame *inGame, ScStack *stack);
~SXShadowManager() override;
private:
static void callback(void *eventData1, void *eventData2);
void update();
void run();
void stop();
bool addActor(AdActor3DX *actorObj);
bool removeAllActors();
bool enableLight(const char *lightName);
bool disableLight(const char *lightName);
Common::List<Common::Pair<AdActor3DX *, uint32>> _actors;
Common::List<Common::Pair<Light3D *, bool>> _lights;
uint32 _lastTime{};
DXVector3 _defaultLightPos;
float _minShadow;
float _maxShadow;
bool _useSmartShadows;
uint32 _shadowColor;
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,249 @@
/* 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/>.
*
*/
/*
* This file is based on WME Steam Plugin.
* https://archive.softwareheritage.org/browse/origin/directory/?origin_url=https://bitbucket.org/MnemonicWME/wme_steam_plugin
* Copyright (c) 2013 Jan Nedoma
*/
#include "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_steam.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXSteamAPI, false)
BaseScriptable *makeSXSteamAPI(BaseGame *inGame, ScStack *stack) {
return new SXSteamAPI(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
Common::AchievementsInfo getAchievementsInfo() {
const MetaEngine *meta = g_engine->getMetaEngine();
const Common::String target = BaseEngine::instance().getGameTargetName();
return meta->getAchievementsInfo(target);
}
//////////////////////////////////////////////////////////////////////////
SXSteamAPI::SXSteamAPI(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(0);
init();
}
//////////////////////////////////////////////////////////////////////////
void SXSteamAPI::init() {
_achievementsInfo = getAchievementsInfo();
AchMan.setActiveDomain(_achievementsInfo);
}
//////////////////////////////////////////////////////////////////////////
SXSteamAPI::~SXSteamAPI() {
}
//////////////////////////////////////////////////////////////////////////
const char *SXSteamAPI::scToString() {
return "[steamapi object]";
}
//////////////////////////////////////////////////////////////////////////
bool SXSteamAPI::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// RequestStats()
// There are currently no known games that are using this
// So, all the initialization should be done at the constructor instead
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "RequestStats") == 0) {
stack->correctParams(0);
stack->pushBool(AchMan.isReady());
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetAchievement(string id)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetAchievement") == 0) {
stack->correctParams(1);
const char *id = stack->pop()->getString();
stack->pushBool(AchMan.setAchievement(id));
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// IsAchieved(string id)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsAchieved") == 0) {
stack->correctParams(1);
const char *id = stack->pop()->getString();
stack->pushBool(AchMan.isAchieved(id));
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// ClearAchievement(string id)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ClearAchievement") == 0) {
stack->correctParams(1);
const char *id = stack->pop()->getString();
stack->pushBool(AchMan.clearAchievement(id));
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetAchievementId(int index)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetAchievementId") == 0) {
stack->correctParams(1);
uint32 index = (uint32) stack->pop()->getInt();
const Common::AchievementDescription *descr = AchMan.getAchievementDescription(index);
if (descr) {
stack->pushString(descr->id.c_str());
} else {
stack->pushNULL();
}
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetStat(string id, int|float value)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetStat") == 0) {
stack->correctParams(2);
const char *id = stack->pop()->getString();
ScValue *val = stack->pop();
if (val->isFloat()) {
stack->pushBool(AchMan.setStatFloat(id, val->getFloat()));
} else {
stack->pushBool(AchMan.setStatInt(id, val->getInt()));
}
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetStatInt(string id)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetStatInt") == 0) {
stack->correctParams(1);
const char *id = stack->pop()->getString();
stack->pushInt(AchMan.getStatInt(id));
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetStatFloat(string id)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetStatFloat") == 0) {
stack->correctParams(1);
const char *id = stack->pop()->getString();
stack->pushFloat(AchMan.getStatFloat(id));
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// ResetAllStats(bool includingAchievements)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ResetAllStats") == 0) {
stack->correctParams(1);
bool includingAchievements = stack->pop()->getBool();
bool result = AchMan.resetAllStats();
if (includingAchievements) {
result = result && AchMan.resetAllAchievements();
}
stack->pushBool(result);
return STATUS_OK;
}
else {
return STATUS_FAILED;
}
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXSteamAPI::scGetProperty(const char *name) {
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
// Type (RO)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Type") == 0) {
_scValue->setString("steamapi");
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// SteamAvailable (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SteamAvailable") == 0) {
_scValue->setBool(AchMan.isReady());
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// StatsAvailable (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "StatsAvailable") == 0) {
_scValue->setBool(AchMan.isReady());
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// NumAchievements (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "NumAchievements") == 0) {
_scValue->setInt(AchMan.getAchievementCount());
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// AppId (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AppId") == 0) {
_scValue->setInt(atoi(_achievementsInfo.appId.c_str()));
return _scValue;
}
else {
return _scValue;
}
}
//////////////////////////////////////////////////////////////////////////
bool SXSteamAPI::scSetProperty(const char *name, ScValue *value) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXSteamAPI::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
if (!persistMgr->getIsSaving()) {
init();
}
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,57 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#ifndef WINTERMUTE_SXSTEAMAPI_H
#define WINTERMUTE_SXSTEAMAPI_H
#include "engines/achievements.h"
#include "wintermute/base/base_scriptable.h"
namespace Wintermute {
class SXSteamAPI : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXSteamAPI, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXSteamAPI(BaseGame *inGame, ScStack *stack);
~SXSteamAPI() override;
private:
void init();
Common::AchievementsInfo _achievementsInfo;
};
Common::AchievementsInfo getAchievementsInfo();
Common::String getAchievementMessage(const Common::AchievementsInfo &info, const char *id);
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,211 @@
/* 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 "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/platform_osystem.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_file_manager.h"
#include "engines/wintermute/base/gfx/base_renderer.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_vlink.h"
#include "common/timer.h"
#include "common/substream.h"
#ifdef USE_BINK
#include "video/bink_decoder.h"
#endif
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXVlink, false)
BaseScriptable *makeSXVlink(BaseGame *inGame, ScStack *stack) {
return new SXVlink(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SXVlink::SXVlink(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(1);
uint32 handle = (uint32)stack->pop()->getInt();
if (handle != 'D3DH') {
warning("SXVlink() Invalid D3D handle");
}
_volume = 100;
}
//////////////////////////////////////////////////////////////////////////
SXVlink::~SXVlink() {
_videoDecoder = nullptr;
}
//////////////////////////////////////////////////////////////////////////
const char *SXVlink::scToString() {
return "[binkvideo object]";
}
void SXVlink::timerCallback(void *instance) {
SXVlink *movie = static_cast<SXVlink *>(instance);
Common::StackLock lock(movie->_frameMutex);
movie->prepareFrame();
}
void SXVlink::prepareFrame() {
if (_videoDecoder->endOfVideo()) {
_videoFinished = true;
return;
}
if (_videoDecoder->getTimeToNextFrame() > 0)
return;
const Graphics::Surface *decodedFrame = _videoDecoder->decodeNextFrame();
if (decodedFrame) {
_surface = *decodedFrame;
if (_frame != _videoDecoder->getCurFrame()) {
_updateNeeded = true;
}
_frame = _videoDecoder->getCurFrame();
}
}
//////////////////////////////////////////////////////////////////////////
bool SXVlink::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// Play(string path)
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Play") == 0) {
stack->correctParams(1);
const char *path = stack->pop()->getString();
#ifdef USE_BINK
_game->freeze();
((WintermuteEngine *)g_engine)->savingEnable(false);
// Load a file, but avoid having the File-manager handle the disposal of it.
Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(path, true, false);
if (file) {
_videoDecoder = new Video::BinkDecoder();
if (_videoDecoder && _videoDecoder->loadStream(file) && _videoDecoder->isVideoLoaded()) {
_videoDecoder->setOutputPixelFormat(Graphics::PixelFormat(_game->_renderer->getPixelFormat()));
BaseSurface *texture = _game->_renderer->createSurface();
texture->create(_videoDecoder->getWidth(), _videoDecoder->getHeight());
_game->_renderer->setup2D();
_frame = -1;
_updateNeeded = false;
_videoFinished = false;
_videoDecoder->start();
_videoDecoder->setVolume(_volume);
g_system->getTimerManager()->installTimerProc(&timerCallback, 10000, this, "movieLoop");
do {
if (_updateNeeded) {
{
Common::StackLock lock(_frameMutex);
texture->putSurface(_surface, false);
}
texture->display(0, 0, Common::Rect32(texture->getWidth(), texture->getHeight()));
_updateNeeded = false;
_game->_renderer->flip();
}
g_system->delayMillis(10);
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
if (event.type == Common::EVENT_KEYDOWN) {
if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
_videoFinished = true;
g_system->getEventManager()->purgeKeyboardEvents();
}
} else if (event.type == Common::EVENT_LBUTTONDOWN) {
_videoFinished = true;
} else if (event.type == Common::EVENT_SCREEN_CHANGED) {
_game->_renderer->onWindowChange();
}
}
} while (!g_engine->shouldQuit() && !_videoFinished);
g_system->getTimerManager()->removeTimerProc(&timerCallback);
{
Common::StackLock lock(_frameMutex);
_videoDecoder->stop();
_videoDecoder->close();
}
delete texture;
}
delete _videoDecoder;
}
((WintermuteEngine *)g_engine)->savingEnable(true);
_game->unfreeze();
#else
warning("SXVlink::Play(%s) Bink playback not compiled in", path);
#endif
stack->pushNULL();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// SetVolume(int level)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetVolume") == 0) {
stack->correctParams(1);
_volume = stack->pop()->getInt();
stack->pushNULL();
return STATUS_OK;
}
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXVlink::scGetProperty(const char *name) {
_scValue->setNULL();
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
bool SXVlink::scSetProperty(const char *name, ScValue *value) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXVlink::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
persistMgr->transferSint32(TMEMBER(_volume));
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,60 @@
/* 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 WINTERMUTE_VLINK_H
#define WINTERMUTE_VLINK_H
#include "common/str.h"
#include "common/mutex.h"
#include "video/video_decoder.h"
#include "graphics/surface.h"
#include "engines/wintermute/base/base_scriptable.h"
#include "engines/wintermute/base/gfx/base_surface.h"
namespace Wintermute {
class SXVlink : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXVlink, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXVlink(BaseGame *inGame, ScStack *stack);
~SXVlink() override;
private:
Common::Mutex _frameMutex;
Video::VideoDecoder *_videoDecoder{};
Graphics::Surface _surface;
int32 _volume;
bool _videoFinished{};
bool _updateNeeded{};
int32 _frame{};
static void timerCallback(void *instance);
void prepareFrame();
};
} // End of namespace Wintermute
#endif

View File

@@ -0,0 +1,89 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/metaengine.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/gfx/base_renderer.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/ext/wme_windowmode.h"
namespace Wintermute {
IMPLEMENT_PERSISTENT(SXSample, false)
BaseScriptable *makeSXSample(BaseGame *inGame, ScStack *stack) {
return new SXSample(inGame, stack);
}
//////////////////////////////////////////////////////////////////////////
SXSample::SXSample(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
stack->correctParams(1);
int value = stack->pop()->getInt();
inGame->_renderer->setWindowed(value);
}
//////////////////////////////////////////////////////////////////////////
SXSample::~SXSample() {
}
//////////////////////////////////////////////////////////////////////////
const char *SXSample::scToString() {
return "[sample object]";
}
//////////////////////////////////////////////////////////////////////////
bool SXSample::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
ScValue *SXSample::scGetProperty(const char *name) {
_scValue->setNULL();
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
bool SXSample::scSetProperty(const char *name, ScValue *value) {
return STATUS_FAILED;
}
//////////////////////////////////////////////////////////////////////////
bool SXSample::persist(BasePersistenceManager *persistMgr) {
BaseScriptable::persist(persistMgr);
return STATUS_OK;
}
} // End of namespace Wintermute

View File

@@ -0,0 +1,49 @@
/* 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/>.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#ifndef WINTERMUTE_WINDOWMODE_H
#define WINTERMUTE_WINDOWMODE_H
#include "common/str.h"
#include "engines/wintermute/base/base_scriptable.h"
namespace Wintermute {
class SXSample : public BaseScriptable {
public:
DECLARE_PERSISTENT(SXSample, BaseScriptable)
ScValue *scGetProperty(const char *name) override;
bool scSetProperty(const char *name, ScValue *value) override;
bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
const char *scToString() override;
SXSample(BaseGame *inGame, ScStack *stack);
~SXSample() override;
};
} // End of namespace Wintermute
#endif