void CzMarket::NotifyInfoAvailable() { Busy = false; ProcessEventActions(CZ_HASH("OnInfoAvailable"), Parent->getParent()); CzScriptCallback& callback = getScriptCallback(); if (callback.Valid) { CzString p1 = "info"; CzString p2 = CurrentProductID; callback.ScriptEngine->CallFunctionRef(callback.FunctionRef, &p1, &p2, NULL, NULL); } }
// // // // CzSettings implementation // // // int CzSettings::Init() { PreventPowerSaving = false; CzXmlParser* xml = new CzXmlParser(); if (xml->Parse("AppEasy.xml") == XmlErrorNone) { CzXmlNode* root = xml->getRoot()->getFirstNode(); if (root != NULL) { // Get debug trace info level CzXmlNode* node = root->getFirstNamedNode(CZ_HASH("debug")); if (node != NULL) { CzXmlAttribute* attrib = node->getAttribute(CZ_HASH("level")); if (attrib != NULL) { g_CzShowTracing = attrib->getValueAsInt(); CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "Debugging trace level set to ", CzString(g_CzShowTracing).c_str()); } } // Get Facebook App ID node = root->getFirstNamedNode(CZ_HASH("facebook")); if (node != NULL) { CzXmlAttribute* attrib = node->getAttribute(CZ_HASH("app_id")); if (attrib != NULL) { FacebookAppID = attrib->getValue(); CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "Got Facebook App ID"); } } } } delete xml; return 1; }
void CzMarket::NotifyBillingDisabled() { Busy = false; ProcessEventActions(CZ_HASH("OnBillingDisabled"), Parent->getParent()); CzScriptCallback& callback = getScriptCallback(); if (callback.Valid) { CzString p1 = "disabled"; CzString p2 = CurrentProductID; callback.ScriptEngine->CallFunctionRef(callback.FunctionRef, &p1, &p2, NULL, NULL); } Busy = false; }
// // LUA_isTypeOf(type-name) // static int LUA_isTypeOf(lua_State *lua) { int count = lua_gettop(lua); if (lua_gettop(lua) < 1) { CzScriptEngineLua::DisplayError(lua, "sys.isTypeOf() not enough parameters, expected type-name"); lua_pushboolean(lua, false); return 1; } // Get the resource IzXomlResource* resource = NULL; if (lua_isuserdata(lua, 1)) resource = (CzScene*)lua_touserdata(lua, 1); else { CzScriptEngineLua::DisplayError(lua, "sys.isTypeOf() Invalid parameter, expected object for Param0"); lua_pushboolean(lua, false); return 1; } // Get the type of actor to create const char* type = NULL; if (lua_isstring(lua, 2)) type = lua_tostring(lua, 2); else { CzScriptEngineLua::DisplayError(lua, "sys.isTypeOf() Invalid parameter, expected type-name for Param1"); lua_pushboolean(lua, false); return 1; } unsigned int type_hash = CZ_HASH(type); if (resource->getClassTypeHash() == type_hash) lua_pushboolean(lua, true); else lua_pushboolean(lua, false); return 1; }
// // LUA_MarketFindProduct(product-name (string)) // static int LUA_MarketFindProduct(lua_State *lua) { int count = lua_gettop(lua); if (count < 1) { CzScriptEngineLua::DisplayError(lua, "market.find() not enough parameters, expected product-name (string)"); lua_pushnil(lua); return 1; } // Get the product name const char* product = NULL; if (lua_isstring(lua, 1)) product = lua_tostring(lua, 1); else { CzScriptEngineLua::DisplayError(lua, "market.find() Invalid parameter, expected string for product-name for Param0"); lua_pushnil(lua); return 1; } if (PLATFORM_MARKET->getActiveMarket() == NULL) { CzScriptEngineLua::DisplayError(lua, "market.find() Market has not been created"); lua_pushnil(lua); return 1; } CzMarketProduct* p = PLATFORM_MARKET->getActiveMarket()->findProductByName(CZ_HASH(product)); if (p == NULL) { CzScriptEngineLua::DisplayError(lua, "market.find() Product not found - ", product); lua_pushnil(lua); return 1; } // Return the product lua_pushlightuserdata(lua, p); return 1; }
int CzUIWebView::LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node) { if (parent->getClassTypeHash() != CzHashes::Scene_Hash && parent->getClassTypeHash() != CzHashes::Actor_Hash) { CzDebug::Log(CZ_DEBUG_CHANNEL_ERROR, "WebView - Needs to be declared inside a scene or an actor - ", DebugInfo.c_str()); return 0; } // Load main actor attributes int ret = CzUIBase::LoadFromXoml(parent, false, node); if (ret <= 0) return ret; // Process WebView specific attributes bool modal = false; bool transparent = false; const char* java_script = NULL; for (CzXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); it++) { unsigned int name_hash = (*it)->getName().getHash(); if (name_hash == CzHashes::URI_Hash) URI = (*it)->getValue(); else if (name_hash == CzHashes::Modal_Hash) modal = (*it)->getValueAsBool(); else if (name_hash == CzHashes::JavaScript_Hash) java_script = (*it)->getValue().c_str(); else if (name_hash == CzHashes::Transparent_Hash) transparent = (*it)->getValueAsBool(); else if (name_hash == CzHashes::Html_Hash) setHtml((*it)->getValue().c_str()); else if (name_hash == CzHashes::OnError_Hash) EventsManager->addEvent("OnError", (*it)->getValue().c_str(), true); else if (name_hash == CzHashes::OnPageLoaded_Hash) EventsManager->addEvent("OnPageLoaded", (*it)->getValue().c_str(), true); else if (name_hash == CzHashes::OnPageLoading_Hash) EventsManager->addEvent("OnPageLoading", (*it)->getValue().c_str(), true); else if (name_hash == CzHashes::OnPageError_Hash) EventsManager->addEvent("OnPageError", (*it)->getValue().c_str(), true); else if (name_hash == CzHashes::OnJavascript_Hash) EventsManager->addEvent("OnJavascript", (*it)->getValue().c_str(), true); } if (!PLATFORM_UI->isWebViewAvailable()) { ProcessEventActions(CZ_HASH("OnError")); CzDebug::Log(CZ_DEBUG_CHANNEL_ERROR, "WebView - Not supported on this platform - ", DebugInfo.c_str()); return -1; } InitView(modal, transparent, java_script); // Process inner tags if (load_children) { if (!CZ_XOML->Process(this, node)) return 0; } return 1; }
// // LUA_CreateScene scene-name (string), width (number), height (number), canvas_fit (string), origin (string), physics (boolean), batching (boolean), script-engine (string) // static int LUA_CreateScene(lua_State *lua) { if (lua_gettop(lua) < 8) { CzScriptEngineLua::DisplayError(lua, "scene.create() not enough parameters, scene-name (string), width (number), height (number), canvas_fit (string), origin (string), physics (boolean), batching (boolean), script-engine (string)"); lua_pushnil(lua); return 1; } // Get the scene name const char* name = NULL; if (lua_isstring(lua, 1)) name = lua_tostring(lua, 1); if (name == NULL) { CzScriptEngineLua::DisplayError(lua, "scene.create() Invalid name for Param0, expected string"); lua_pushnil(lua); return 1; } // Get the scene size int width, height; if (lua_isnumber(lua, 2)) width = (int)lua_tonumber(lua, 2); else { CzScriptEngineLua::DisplayError(lua, "scene.create() Invalid width for Param1, expected number"); lua_pushnil(lua); return 1; } if (lua_isnumber(lua, 3)) height = (int)lua_tonumber(lua, 3); else { CzScriptEngineLua::DisplayError(lua, "scene.create() Invalid height for Param2, expected number"); lua_pushnil(lua); return 1; } // Get the scene canvas fit const char* canvas_fit = NULL; if (lua_isstring(lua, 4)) canvas_fit = lua_tostring(lua, 4); if (canvas_fit == NULL) { CzScriptEngineLua::DisplayError(lua, "scene.create() Invalid canvas_fit for Param3, expected string"); lua_pushnil(lua); return 1; } // Get the scene canvas origin const char* canvas_org = NULL; if (lua_isstring(lua, 5)) canvas_org = lua_tostring(lua, 5); if (canvas_org == NULL) { CzScriptEngineLua::DisplayError(lua, "scene.create() Invalid canvas_fit for Param4, expected string"); lua_pushnil(lua); return 1; } unsigned int canvas_fit_hash = CZ_HASH(canvas_fit); unsigned int canvas_org_hash = CZ_HASH(canvas_org); CzScene::eCanvasFit fit = CzScene::Fit_None; if (canvas_fit_hash == CZ_HASH("width")) fit = CzScene::Fit_Width; else if (canvas_fit_hash == CZ_HASH("height")) fit = CzScene::Fit_Height; else if (canvas_fit_hash == CZ_HASH("both")) fit = CzScene::Fit_Both; else if (canvas_fit_hash == CZ_HASH("best")) fit = CzScene::Fit_Best; CzScene::eCanvasOrigin org = CzScene::Origin_Centre; if (canvas_org_hash == CZ_HASH("top")) org = CzScene::Origin_Top; else if (canvas_org_hash == CZ_HASH("left")) org = CzScene::Origin_Left; else if (canvas_org_hash == CZ_HASH("topleft")) org = CzScene::Origin_TopLeft; // Get the scene physics / batching bool physics = false, batching = false; if (lua_isboolean(lua, 6)) physics = lua_toboolean(lua, 6) != 0; else { CzScriptEngineLua::DisplayError(lua, "scene.create() Invalid physics for Param5, expected boolean"); lua_pushnil(lua); return 1; } if (lua_isboolean(lua, 7)) batching = lua_toboolean(lua, 7) != 0; else { CzScriptEngineLua::DisplayError(lua, "scene.create() Invalid batching for Param6, expected boolean"); lua_pushnil(lua); return 1; } // Get the scene script engine const char* script_engine = NULL; if (lua_isstring(lua, 8)) script_engine = lua_tostring(lua, 8); if (script_engine == NULL) { CzScriptEngineLua::DisplayError(lua, "scene.create() Invalid script-engine for Param7, expected string"); lua_pushnil(lua); return 1; } CzScene* scene = new CzScene(); scene->setName(name); scene->Init(); scene->setBatching(batching); scene->setVirtualTransform(width, height, 0, fit, org); // Create script engine CzString se = script_engine; if (script_engine != NULL) scene->setScriptEngine(se); // Add scene to game CzApp* game = (CzApp*)CZ_GLOBAL_RESOURCES->getResourceManager()->getParent(); game->addScene(scene, false); // Return the scene lua_pushlightuserdata(lua, scene); return 1; }
bool CzCamera::getProperty(const char* property_name, CzXomlProperty& prop) { return getProperty(CZ_HASH(property_name), prop); }