diff options
author | Einar Johan Trøan Sømåen | 2012-07-17 22:56:08 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-07-17 23:20:47 +0200 |
commit | 10c4aa8cecd5fed3acc15cf6c8e7762a6722afc6 (patch) | |
tree | e496e764c8a8bbdf6182e947c6dbf6bdc865dc54 /engines | |
parent | 0e9d92a7aff5e03a3cdea26efc2cb8e01f2c21db (diff) | |
download | scummvm-rg350-10c4aa8cecd5fed3acc15cf6c8e7762a6722afc6.tar.gz scummvm-rg350-10c4aa8cecd5fed3acc15cf6c8e7762a6722afc6.tar.bz2 scummvm-rg350-10c4aa8cecd5fed3acc15cf6c8e7762a6722afc6.zip |
WINTERMUTE: Remove SXStore, since it's only usefull on iOS.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wintermute/Base/BGame.cpp | 23 | ||||
-rw-r--r-- | engines/wintermute/Base/BGame.h | 2 | ||||
-rw-r--r-- | engines/wintermute/Base/scriptables/SXStore.cpp | 518 | ||||
-rw-r--r-- | engines/wintermute/Base/scriptables/SXStore.h | 175 | ||||
-rw-r--r-- | engines/wintermute/persistent.cpp | 2 |
5 files changed, 2 insertions, 718 deletions
diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 3a3aad50e6..4ff0980e84 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -58,7 +58,6 @@ #include "engines/wintermute/Base/scriptables/ScStack.h"
#include "engines/wintermute/Base/scriptables/ScScript.h"
#include "engines/wintermute/Base/scriptables/SXMath.h"
-#include "engines/wintermute/Base/scriptables/SXStore.h"
#include "engines/wintermute/video/VidPlayer.h"
#include "engines/wintermute/video/VidTheoraPlayer.h"
#include "engines/wintermute/wintermute.h"
@@ -271,7 +270,6 @@ CBGame::CBGame(): CBObject(this) { _constrainedMemory = false;
#endif
- _store = NULL;
}
@@ -354,9 +352,6 @@ ERRORCODE CBGame::cleanup() { _musicStartTime[i] = 0;
}
- unregisterObject(_store);
- _store = NULL;
-
unregisterObject(_fader);
_fader = NULL;
@@ -470,11 +465,6 @@ ERRORCODE CBGame::initialize1() { if (_fader == NULL)
break;
registerObject(_fader);
-
- _store = new CSXStore(this);
- if (_store == NULL)
- break;
- registerObject(_store);
loaded = true;
}
@@ -482,7 +472,6 @@ ERRORCODE CBGame::initialize1() { return STATUS_OK;
} else {
delete _mathClass;
- delete _store;
delete _keyboardState;
delete _transMgr;
delete _debugMgr;
@@ -2556,8 +2545,8 @@ CScValue *CBGame::scGetProperty(const char *name) { // Store (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Store") == 0) {
- if (_store) _scValue->setNative(_store, true);
- else _scValue->setNULL();
+ _scValue->setNULL();
+ error("Request for a SXStore-object, which is not supported by ScummVM");
return _scValue;
}
@@ -2846,8 +2835,6 @@ ERRORCODE CBGame::unregisterObject(CBObject *object) { // is it main object?
if (_mainObject == object) _mainObject = NULL;
- if (_store) _store->OnObjectDestroyed(object);
-
// destroy object
for (int i = 0; i < _regObjects.getSize(); i++) {
if (_regObjects[i] == object) {
@@ -3314,7 +3301,6 @@ ERRORCODE CBGame::initAfterLoad() { CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL);
_scEngine->refreshScriptBreakpoints();
- if (_store) _store->afterLoad();
return STATUS_OK;
}
@@ -3663,11 +3649,6 @@ ERRORCODE CBGame::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_autoSaveSlot));
persistMgr->transfer(TMEMBER(_cursorHidden));
- if (persistMgr->checkVersion(1, 0, 1))
- persistMgr->transfer(TMEMBER(_store));
- else
- _store = NULL;
-
if (!persistMgr->_saving)
_quitting = false;
diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index dc1e476134..3bee3d134b 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -56,7 +56,6 @@ class CBRenderer; class CBRegistry;
class CBSaveThumbHelper;
class CBSurfaceStorage;
-class CSXStore;
class CSXMath;
class CBKeyboardState;
class CVidPlayer;
@@ -179,7 +178,6 @@ public: CBSoundMgr *_soundMgr;
CScEngine *_scEngine;
CSXMath *_mathClass;
- CSXStore *_store;
CBSurfaceStorage *_surfaceStorage;
CBFontStorage *_fontStorage;
CBGame();
diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp deleted file mode 100644 index 065fac5255..0000000000 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ /dev/null @@ -1,518 +0,0 @@ -/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This file is based on WME Lite.
- * http://dead-code.org/redir.php?target=wmelite
- * Copyright (c) 2011 Jan Nedoma
- */
-
-#include "engines/wintermute/Base/BGame.h"
-#include "engines/wintermute/Base/BRegistry.h"
-#include "engines/wintermute/Base/scriptables/SXStore.h"
-#include "engines/wintermute/Base/scriptables/ScValue.h"
-#include "engines/wintermute/Base/scriptables/ScScript.h"
-#include "engines/wintermute/Base/scriptables/ScStack.h"
-#include "engines/wintermute/utils/StringUtil.h"
-
-#ifdef __IPHONEOS__
-# include "IOS_StoreKit_interface.h"
-#endif
-
-namespace WinterMute {
-
-IMPLEMENT_PERSISTENT(CSXStore, false)
-
-CBScriptable *makeSXStore(CBGame *inGame, CScStack *stack) {
- return new CSXStore(inGame);
-}
-
-//////////////////////////////////////////////////////////////////////////
-CSXStore::CSXStore(CBGame *inGame) : CBObject(inGame) {
-#ifdef __IPHONEOS__
- StoreKit_SetExternalData((void *)this);
-#endif
-
- _eventsEnabled = false;
- _lastProductRequestOwner = NULL;
- _lastPurchaseOwner = NULL;
- _lastRestoreOwner = NULL;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-CSXStore::~CSXStore() {
- cleanup();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::cleanup() {
- setEventsEnabled(NULL, false);
-
- for (int i = 0; i < _validProducts.getSize(); i++) {
- delete _validProducts[i];
- }
- _validProducts.removeAll();
-
-
- for (int i = 0; i < _transactions.getSize(); i++) {
- delete _transactions[i];
- }
- _transactions.removeAll();
-
-
- _lastProductRequestOwner = _lastPurchaseOwner = _lastRestoreOwner = NULL;
-}
-
-//////////////////////////////////////////////////////////////////////////
-ERRORCODE CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) {
- //////////////////////////////////////////////////////////////////////////
- // EnableEvents
- //////////////////////////////////////////////////////////////////////////
- if (strcmp(name, "EnableEvents") == 0) {
- stack->correctParams(0);
- setEventsEnabled(script, true);
- stack->pushBool(getEventsEnabled() == true);
- return STATUS_OK;
- }
- //////////////////////////////////////////////////////////////////////////
- // DisableEvents
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "DisableEvents") == 0) {
- stack->correctParams(0);
- setEventsEnabled(script, false);
- stack->pushBool(getEventsEnabled() == false);
- return STATUS_OK;
- }
- //////////////////////////////////////////////////////////////////////////
- // ValidateProducts
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "ValidateProducts") == 0) {
- stack->correctParams(1);
- const char *prodIdList = stack->pop()->getString();
- _lastProductRequestOwner = script->_owner;
- validateProducts(prodIdList);
- stack->pushNULL();
- return STATUS_OK;
- }
- //////////////////////////////////////////////////////////////////////////
- // GetValidProduct
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "GetValidProduct") == 0) {
- stack->correctParams(1);
- int index = stack->pop()->getInt();
- if (index >= 0 && index < _validProducts.getSize()) {
- CScValue *prod = stack->getPushValue();
- if (prod) {
- prod->setProperty("Id", _validProducts[index]->getId());
- prod->setProperty("Name", _validProducts[index]->getName());
- prod->setProperty("Description", _validProducts[index]->getDesc());
- prod->setProperty("Price", _validProducts[index]->getPrice());
- }
- } else
- stack->pushNULL();
-
- return STATUS_OK;
- }
- //////////////////////////////////////////////////////////////////////////
- // GetInvalidProduct
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "GetInvalidProduct") == 0) {
- stack->correctParams(1);
- int index = stack->pop()->getInt();
- if (index >= 0 && (uint32)index < _invalidProducts.size())
- stack->pushString(_invalidProducts[(uint32)index].c_str());
- else
- stack->pushNULL();
-
- return STATUS_OK;
- }
- //////////////////////////////////////////////////////////////////////////
- // GetTransaction
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "GetTransaction") == 0) {
- stack->correctParams(1);
- int index = stack->pop()->getInt();
- if (index >= 0 && index < _transactions.getSize()) {
- CScValue *trans = stack->getPushValue();
- if (trans) {
- trans->setProperty("Id", _transactions[index]->getId());
- trans->setProperty("ProductId", _transactions[index]->getProductId());
- trans->setProperty("State", _transactions[index]->getState());
- }
- } else
- stack->pushNULL();
-
- return STATUS_OK;
- }
- //////////////////////////////////////////////////////////////////////////
- // Purchase
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "Purchase") == 0) {
- stack->correctParams(1);
- const char *prodId = stack->pop()->getString();
- stack->pushBool(purchase(script, prodId));
-
- return STATUS_OK;
- }
- //////////////////////////////////////////////////////////////////////////
- // FinishTransaction
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "FinishTransaction") == 0) {
- stack->correctParams(1);
- const char *transId = stack->pop()->getString();
- stack->pushBool(finishTransaction(script, transId));
-
- return STATUS_OK;
- }
- //////////////////////////////////////////////////////////////////////////
- // RestoreTransactions
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "RestoreTransactions") == 0) {
- stack->correctParams(0);
- restoreTransactions(script);
- stack->pushNULL();
-
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // UnlockProduct
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "UnlockProduct") == 0) {
- stack->correctParams(1);
- const char *prodId = stack->pop()->getString();
-
- Game->_registry->writeBool("Purchases", prodId, true);
- Game->_registry->saveValues();
-
- stack->pushBool(true);
-
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // IsProductUnlocked
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "IsProductUnlocked") == 0) {
- stack->correctParams(1);
- const char *prodId = stack->pop()->getString();
-
- stack->pushBool(Game->_registry->readBool("Purchases", prodId, false));
-
- return STATUS_OK;
- }
-
- else return STATUS_FAILED;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-CScValue *CSXStore::scGetProperty(const char *name) {
- _scValue->setNULL();
-
- //////////////////////////////////////////////////////////////////////////
- // Type
- //////////////////////////////////////////////////////////////////////////
- if (strcmp(name, "Type") == 0) {
- _scValue->setString("store");
- return _scValue;
- }
- //////////////////////////////////////////////////////////////////////////
- // Available (RO)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "Available") == 0) {
- _scValue->setBool(isAvailable());
- return _scValue;
- }
- //////////////////////////////////////////////////////////////////////////
- // EventsEnabled (RO)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "EventsEnabled") == 0) {
- _scValue->setBool(getEventsEnabled());
- return _scValue;
- }
- //////////////////////////////////////////////////////////////////////////
- // NumValidProducts (RO)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "NumValidProducts") == 0) {
- _scValue->setInt(_validProducts.getSize());
- return _scValue;
- }
- //////////////////////////////////////////////////////////////////////////
- // NumInvalidProducts (RO)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "NumInvalidProducts") == 0) {
- _scValue->setInt((int)_invalidProducts.size());
- return _scValue;
- }
- //////////////////////////////////////////////////////////////////////////
- // NumTransactions (RO)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "NumTransactions") == 0) {
- _scValue->setInt(_transactions.getSize());
- return _scValue;
- }
-
- else return _scValue;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-ERRORCODE CSXStore::persist(CBPersistMgr *persistMgr) {
- if (!persistMgr->_saving)
- cleanup();
-
- CBObject::persist(persistMgr);
-
- persistMgr->transfer(TMEMBER(_eventsEnabled));
- persistMgr->transfer(TMEMBER(_lastProductRequestOwner));
- persistMgr->transfer(TMEMBER(_lastPurchaseOwner));
- persistMgr->transfer(TMEMBER(_lastRestoreOwner));
- persistMgr->transfer(TMEMBER(_invalidProducts));
-
- // persist valid products
- int numProducts;
- if (persistMgr->_saving) {
- numProducts = _validProducts.getSize();
- persistMgr->transfer(TMEMBER(numProducts));
- for (int i = 0; i < numProducts; i++) _validProducts[i]->persist(persistMgr);
- } else {
- numProducts = _validProducts.getSize();
- persistMgr->transfer(TMEMBER(numProducts));
- for (int i = 0; i < numProducts; i++) {
- CBStoreProduct *prod = new CBStoreProduct;
- prod->persist(persistMgr);
- _validProducts.add(prod);
- }
- }
-
- return STATUS_OK;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::afterLoad() {
- if (_eventsEnabled) {
- setEventsEnabled(NULL, true);
- }
-#ifdef __IPHONEOS__
- StoreKit_SetExternalData((void *)this);
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::OnObjectDestroyed(CBScriptHolder *obj) {
- if (_lastProductRequestOwner == obj) _lastProductRequestOwner = NULL;
- if (_lastPurchaseOwner == obj) _lastPurchaseOwner = NULL;
- if (_lastRestoreOwner == obj) _lastRestoreOwner = NULL;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::setEventsEnabled(CScScript *script, bool val) {
- _eventsEnabled = val;
-
- if (val) {
- if (script) _lastPurchaseOwner = script->_owner;
-#ifdef __IPHONEOS__
- StoreKit_EnableEvents();
-#endif
- } else {
- _lastPurchaseOwner = NULL;
-#ifdef __IPHONEOS__
- StoreKit_DisableEvents();
-#endif
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::validateProducts(const char *prodIdList) {
-#ifdef __IPHONEOS__
- StoreKit_ValidateProducts(prodIdList);
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool CSXStore::isAvailable() {
-#ifdef __IPHONEOS__
- return StoreKit_IsStoreAvailable() > 0;
-#else
- return false;
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::receiveProductsStart() {
- for (int i = 0; i < _validProducts.getSize(); i++) {
- delete _validProducts[i];
- }
- _validProducts.removeAll();
-
- _invalidProducts.clear();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::receiveProductsEnd() {
- if (_lastProductRequestOwner) _lastProductRequestOwner->applyEvent("ProductsValidated");
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::addValidProduct(const char *id, const char *name, const char *desc, const char *price) {
- CBStoreProduct *prod = new CBStoreProduct(id, name, desc, price);
- _validProducts.add(prod);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::addInvalidProduct(const char *id) {
- _invalidProducts.push_back(id);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::receiveTransactionsStart() {
- for (int i = 0; i < _transactions.getSize(); i++) {
- delete _transactions[i];
- }
- _transactions.removeAll();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::receiveTransactionsEnd() {
- if (_lastPurchaseOwner)
- _lastPurchaseOwner->applyEvent("TransactionsUpdated");
- else
- Game->applyEvent("TransactionsUpdated");
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::addTransaction(const char *id, const char *productId, const char *state) {
- CBStoreTransaction *trans = new CBStoreTransaction(id, productId, state);
- _transactions.add(trans);
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool CSXStore::purchase(CScScript *script, const char *productId) {
- if (!productId) return false;
-
-#ifdef __IPHONEOS__
- for (int i = 0; i < _validProducts.getSize(); i++) {
- if (strcmp(productId, _validProducts[i]->GetId()) == 0) {
- _lastPurchaseOwner = script->_owner;
-
- StoreKit_Purchase(productId);
- return true;
- }
- }
-#endif
- script->runtimeError("Store.Purchase() - '%s' is not a valid product id", productId);
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool CSXStore::finishTransaction(CScScript *script, const char *transId) {
- if (!transId) return false;
-#ifdef __IPHONEOS__
- for (int i = 0; i < _transactions.getSize(); i++) {
- if (strcmp(transId, _transactions[i]->GetId()) == 0) {
- if (StoreKit_FinishTransaction(transId) > 0) {
- SAFE_DELETE(_transactions[i]);
- _transactions.removeAt(i);
- return true;
- } else return false;
- }
- }
-#endif
- script->runtimeError("Store.FinishTransaction() - '%s' is not a valid transaction id", transId);
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::restoreTransactions(CScScript *script) {
- _lastRestoreOwner = script->_owner;
-#ifdef __IPHONEOS__
- StoreKit_RestoreTransactions();
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CSXStore::onRestoreFinished(bool error) {
- if (_lastRestoreOwner) {
- if (error) _lastRestoreOwner->applyEvent("TransactionsRestoreFailed");
- else _lastRestoreOwner->applyEvent("TransactionsRestoreFinished");
- }
-}
-
-
-
-#ifdef __IPHONEOS__
-
-//////////////////////////////////////////////////////////////////////////
-// StoreKit callbacks (called from ObjC)
-//////////////////////////////////////////////////////////////////////////
-void StoreKit_AddValidProductCallback(const char *id, const char *name, const char *desc, const char *price, void *data) {
- CSXStore *store = static_cast<CSXStore *>(data);
- if (store) store->AddValidProduct(id, name, desc, price);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void StoreKit_AddInvalidProductCallback(const char *id, void *data) {
- CSXStore *store = static_cast<CSXStore *>(data);
- if (store) store->AddInvalidProduct(id);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void StoreKit_ReceiveProductsStartCallback(void *data) {
- CSXStore *store = static_cast<CSXStore *>(data);
- if (store) store->ReceiveProductsStart();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void StoreKit_ReceiveProductsEndCallback(void *data) {
- CSXStore *store = static_cast<CSXStore *>(data);
- if (store) store->ReceiveProductsEnd();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void StoreKit_AddTransactionCallback(const char *id, const char *productId, const char *state, void *data) {
- CSXStore *store = static_cast<CSXStore *>(data);
- if (store) store->AddTransaction(id, productId, state);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void StoreKit_ReceiveTransactionsStartCallback(void *data) {
- CSXStore *store = static_cast<CSXStore *>(data);
- if (store) store->ReceiveTransactionsStart();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void StoreKit_ReceiveTransactionsEndCallback(void *data) {
- CSXStore *store = static_cast<CSXStore *>(data);
- if (store) store->ReceiveTransactionsEnd();
-}
-//////////////////////////////////////////////////////////////////////////
-void StoreKit_RestoreFinishedCallback(void *data, int error) {
- CSXStore *store = static_cast<CSXStore *>(data);
- if (store) store->OnRestoreFinished(error > 0);
-}
-
-#endif // __IPHONEOS__
-
-} // end of namespace WinterMute
diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h deleted file mode 100644 index a6268689c6..0000000000 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ /dev/null @@ -1,175 +0,0 @@ -/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This file is based on WME Lite.
- * http://dead-code.org/redir.php?target=wmelite
- * Copyright (c) 2011 Jan Nedoma
- */
-
-#ifndef WINTERMUTE_SXSTORE_H
-#define WINTERMUTE_SXSTORE_H
-#include "engines/wintermute/Base/BPersistMgr.h"
-#include "engines/wintermute/utils/utils.h"
-#include "engines/wintermute/Base/BObject.h"
-
-namespace WinterMute {
-
-class CSXStore : public CBObject {
-public:
-
- //////////////////////////////////////////////////////////////////////////
- class CBStoreProduct {
- public:
- CBStoreProduct() {
- _id = _name = _desc = _price = NULL;
- }
-
- CBStoreProduct(const char *id, const char *name, const char *desc, const char *price) {
- _id = _name = _desc = _price = NULL;
-
- CBUtils::setString(&_id, id);
- CBUtils::setString(&_name, name);
- CBUtils::setString(&_desc, desc);
- CBUtils::setString(&_price, price);
- }
-
- ~CBStoreProduct() {
- delete [] _id;
- delete [] _name;
- delete [] _desc;
- delete [] _price;
- }
-
- ERRORCODE persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(_id));
- persistMgr->transfer(TMEMBER(_name));
- persistMgr->transfer(TMEMBER(_desc));
- persistMgr->transfer(TMEMBER(_price));
- return STATUS_OK;
- }
-
- const char *getId() {
- return _id;
- }
- const char *getName() {
- return _name;
- }
- const char *getDesc() {
- return _desc;
- }
- const char *getPrice() {
- return _price;
- }
-
- private:
- char *_id;
- char *_name;
- char *_desc;
- char *_price;
- };
-
- //////////////////////////////////////////////////////////////////////////
- class CBStoreTransaction {
- public:
- CBStoreTransaction() {
- _id = _productId = _state = NULL;
- }
-
- CBStoreTransaction(const char *id, const char *productId, const char *state) {
- _id = _productId = _state = NULL;
-
- CBUtils::setString(&_id, id);
- CBUtils::setString(&_productId, productId);
- CBUtils::setString(&_state, state);
- }
-
- ~CBStoreTransaction() {
- delete [] _id;
- delete [] _productId;
- delete [] _state;
- }
-
- const char *getId() {
- return _id;
- }
- const char *getProductId() {
- return _productId;
- }
- const char *getState() {
- return _state;
- }
-
- private:
- char *_id;
- char *_productId;
- char *_state;
- };
-
-
- DECLARE_PERSISTENT(CSXStore, CBObject)
- CSXStore(CBGame *inGame);
- virtual ~CSXStore();
- virtual CScValue *scGetProperty(const char *name);
- virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name);
-
- void afterLoad();
- void OnObjectDestroyed(CBScriptHolder *obj);
-
- bool isAvailable();
- void setEventsEnabled(CScScript *script, bool val);
- bool getEventsEnabled() const {
- return _eventsEnabled;
- }
- void validateProducts(const char *prodIdList);
-
- void receiveTransactionsStart();
- void receiveTransactionsEnd();
- void addTransaction(const char *id, const char *productId, const char *state);
-
- void receiveProductsStart();
- void receiveProductsEnd();
- void addValidProduct(const char *id, const char *name, const char *desc, const char *price);
- void addInvalidProduct(const char *id);
-
- void onRestoreFinished(bool error);
-
-private:
- void cleanup();
- bool purchase(CScScript *script, const char *productId);
- bool finishTransaction(CScScript *script, const char *transId);
- void restoreTransactions(CScScript *script);
-
- bool _eventsEnabled;
- CBArray<CBStoreProduct *, CBStoreProduct *> _validProducts;
- AnsiStringArray _invalidProducts;
- CBScriptHolder *_lastProductRequestOwner;
- CBScriptHolder *_lastPurchaseOwner;
- CBScriptHolder *_lastRestoreOwner;
-
- CBArray<CBStoreTransaction *, CBStoreTransaction *> _transactions;
-
-};
-
-} // end of namespace WinterMute
-
-#endif
diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index b753b58d26..5c09022746 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -78,7 +78,6 @@ #include "engines/wintermute/Base/scriptables/SXMath.h" #include "engines/wintermute/Base/scriptables/SXMemBuffer.h" #include "engines/wintermute/Base/scriptables/SxObject.h" -#include "engines/wintermute/Base/scriptables/SXStore.h" #include "engines/wintermute/Base/scriptables/SXString.h" #include "engines/wintermute/UI/UIButton.h" #include "engines/wintermute/UI/UIEdit.h" @@ -152,7 +151,6 @@ void CSysClassRegistry::registerClasses() { REGISTER_CLASS(CSXMath, true) REGISTER_CLASS(CSXMemBuffer, false) REGISTER_CLASS(CSXObject, false) - REGISTER_CLASS(CSXStore, false) REGISTER_CLASS(CSXString, false) REGISTER_CLASS(CUIButton, false) |