bool CStrengthenItem::init() { if (BaseLayer::init()) { MaskLayer* lay = MaskLayer::create("StrengthenItem"); lay->setContentSize(CCSizeMake(2824,640)); LayerManager::instance()->push(lay); m_ui = LoadComponent("StrengItem.xaml"); // m_ui->setPosition(VCENTER); this->addChild(m_ui); //添加ItemTip m_pItemTip = CItemTip::create(); m_ui->findWidgetById("attr")->addChild(m_pItemTip, -1); CCPoint pos = m_ui->convertToNodeSpace(m_pItemTip->getPosition()); m_pItemTip->setPosition(pos+ccp(36, 30)); m_pItemTip->DoNotPopItem(); m_pItemTip->hideBg(); //m_pItemTip->hideHeroEquipHead(); m_pItemTip->hideButton(); setVisible(false); return true; } return false; }
fwRefContainer<ComponentData> ComponentLoader::LoadComponent(const char* componentName) { auto component = m_knownComponents[componentName]; if (!component.GetRef()) { FatalError("Unknown component %s.", componentName); } if (component->IsLoaded()) { return component; } // match and resolve dependencies auto dependencies = component->GetDepends(); for (auto& dependency : dependencies) { // find the first component to provide this bool match = false; for (auto& it : m_knownComponents) { auto matchProvides = it.second->GetProvides(); for (auto& provide : matchProvides) { if (dependency.IsMatchedBy(provide)) { trace("Resolving dependency for %s by %s (%s).\n", dependency.GetString().c_str(), it.second->GetName().c_str(), provide.GetString().c_str()); auto dependencyData = LoadComponent(it.second->GetName().c_str()); component->AddDependency(dependencyData); match = true; break; } } // break if matched if (match) { break; } } if (!match && dependency.GetCategory() != "vendor") { trace("Unable to resolve dependency for %s.\n", dependency.GetString().c_str()); return nullptr; } } // load the component component->Load(); return component; }
bool CDownloadPackage::init() { if (BaseLayer::init()) { MaskLayer* lay = MaskLayer::create("CDownloadPackageMask"); lay->setContentSize(CCSizeMake(2824,640)); LayerManager::instance()->push(lay); lay->setVisible(false); m_ui = LoadComponent("downloadPackage.xaml"); m_ui->setPosition(VCENTER); this->addChild(m_ui, 2); this->setVisible(true); //初始化下载路径 initDownloadDir(); m_iPackageIndex = CCUserDefault::sharedUserDefault()->getIntegerForKey(PACKAGE_DOWNLOAD_INDEX, 0); m_VersionJson = new CPackageVersionJson; updateForChangePic(0); schedule(schedule_selector(CDownloadPackage::updateForChangePic), 3); scheduleUpdate(); return true; } return false; }
bool SetPanel::init() { bool res = CCNode::init(); do { if(!res)break; CWidgetWindow* layout = CWidgetWindow::create(); layout->setTag(1); layout->setTouchPriority(-4); addChild(layout); m_panel = LoadComponent("SetPanel.xaml"); if(!m_panel) break; m_panel->retain(); m_panel->setPosition(CCSizeCenter(m_panel->getContentSize())); this->setContentSize(m_panel->getContentSize()); this->setAnchorPoint(CCPointCenter); layout->addChild(m_panel); for(int i = 1; i <=5; ++i) { CButton* button = (CButton*)m_panel->getChildByTag(i); button->setOnClickListener(this,ccw_click_selector(SetPanel::onClick)); } res = true; } while (0); return res; }
bool CVipCard::init() { if (BaseLayer::init()) { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //黑底 MaskLayer* pMaskLayer = MaskLayer::create("VipCardMask"); pMaskLayer->setContentSize(winSize); LayerManager::instance()->push(pMaskLayer); pMaskLayer->setOpacity(255); pMaskLayer->setIsShowBlack(true); this->setVisible(true); m_ui = LoadComponent("VipCard.xaml"); m_ui->setTag(1); m_ui->setPosition(VCENTER); this->addChild(m_ui, 2); return true; } return false; }
void ProjectApplication::OnLoad() { // Load Sound Definitions _xmlReader = ProjectApplication::CreateXmlManager(HydraClassFactory::XmlReaderCreateSoundData); _xmlReader->ParseFile("Sounds"); ResourceMgr()->AddSoundDefinitions(_xmlReader->GetResultList()); ResourceMgr()->LoadSoundScope("global"); LogMemUsage(); free(_xmlReader); _xmlReader = NULL; // Load Texture Definitions _xmlReader = ProjectApplication::CreateXmlManager(HydraClassFactory::XmlReaderCreateTextureData); _xmlReader->ParseFile("Textures"); ResourceMgr()->AddTextureDefinitions(_xmlReader->GetResultList()); ResourceMgr()->LoadTextureScope(SCOPE_GLOBAL); // ResourceMgr()->LoadTextureScope(SCOPE_GAME); free(_xmlReader); _xmlReader = NULL; // Load animation definitions _xmlReader = ProjectApplication::CreateXmlManager(HydraClassFactory::XmlReaderCreateAnimationData); _xmlReader->ParseFile("Animations"); ResourceMgr()->AddAnimationDefinitions(_xmlReader->GetResultList()); free(_xmlReader); _xmlReader = NULL; LoadComponent(CMP_TEMPLATE); }
void LoadScene::onCreate() { CWidgetWindow* layout = CWidgetWindow::create(); layout->setTag(1); addChild(layout); m_ui = LoadComponent("loading.xaml"); m_ui->setPosition(VCENTER); this->addChild(m_ui); CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("skill/9049.plist"); AnimationManager::sharedAction()->ParseAnimation("9049"); }
bool CHeroExpItem::init() { if (BaseLayer::init()) { MaskLayer* lay = MaskLayer::create("heroExpItemMask"); lay->setContentSize(CCSizeMake(1138,640)); LayerManager::instance()->push(lay); m_ui = LoadComponent("HeroExpItem.xaml"); m_ui->setPosition(VCENTER); this->addChild(m_ui); return true; } return false; }
bool CCommandLayer::init() { if (BaseLayer::init()) { MaskLayer* lay = MaskLayer::create("MaskLayer"); lay->setContentSize(CCSizeMake(2824,640)); LayerManager::instance()->push(lay); m_ui = LoadComponent("command.xaml"); // m_ui->setPosition(VCENTER); this->addChild(m_ui); return true; } return false; }
bool CChangeHeadImg::init() { if (BaseLayer::init()) { MaskLayer* lay = MaskLayer::create("ChangeHeadImg"); lay->setContentSize(CCSizeMake(2824,640)); LayerManager::instance()->push(lay); lay->setVisible(false); m_ui = LoadComponent("ChangeHeadImg.xaml"); m_ui->setPosition(VCENTER); this->addChild(m_ui); return true; } return false; }
bool CHeroEvolveEffectLayer::init() { if (BaseLayer::init()) { m_pUI = LoadComponent("HeroEvolveEffect.xaml"); // m_pUI->setPosition(VCENTER); this->addChild(m_pUI); this->setIsShowBlack(false); this->setVisible(false); m_pSkillBg = (CImageViewScale9 *)m_pUI->findWidgetById("bg1"); return true; } return false; }
bool CHandBookHeroLayer::init() { if(BaseLayer::init()) { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //内容 m_ui = LoadComponent("handBookHero.xaml"); m_ui->setPosition(VCENTER); this->addChild(m_ui); setIsShowBlack(false); //保存Cell m_pCell = (CLayout*)findWidgetById("Cell"); m_pCell->retain(); m_pCell->removeFromParent(); m_pCellBlank = (CLayout*)m_ui->findWidgetById("CellBg"); m_pCellBlank->retain(); m_pCellBlank->removeFromParent(); //获取空的滑动列表Scroll m_pTableView = (CTableView*)m_ui->findWidgetById("scroll"); m_pTableView->setDirection(eScrollViewDirectionVertical); m_pTableView->setSizeOfCell(m_pCellBlank->getContentSize()); m_pTableView->setCountOfCell(0); m_pTableView->setBounceable(true); m_pTableView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(CHandBookHeroLayer::tableviewDataSource)); setVisible(false); return true; } return false; }
bool CHandBookPanel::init() { if(BaseLayer::init()) { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //黑底 MaskLayer* pMaskLayer = MaskLayer::create("HandBookMaskLayer"); pMaskLayer->setContentSize(winSize); LayerManager::instance()->push(pMaskLayer); //内容 m_ui = LoadComponent("handBook.xaml"); m_ui->setPosition(VCENTER); this->addChild(m_ui); setVisible(false); return true; } return false; }
void ComponentLoader::Initialize() { // run local initialization functions InitFunctionBase::RunAll(); // set up the root component m_rootComponent = FxGameComponent::Create(); AddComponent(m_rootComponent); // parse and load additional components FILE* componentCache = _pfopen(MakeRelativeCitPath(L"components.json").c_str(), _P("rb")); if (!componentCache) { FatalError("Could not find component cache storage file (components.json)."); } // read component cache file fseek(componentCache, 0, SEEK_END); int length = ftell(componentCache); fseek(componentCache, 0, SEEK_SET); char* cacheBuf = new char[length + 1]; fread(cacheBuf, 1, length, componentCache); cacheBuf[length] = '\0'; fclose(componentCache); // parse the list rapidjson::Document doc; doc.Parse(cacheBuf); delete[] cacheBuf; if (doc.HasParseError()) { FatalError("Error parsing components.json: %d", doc.GetParseError()); } // look through the list for components to load std::vector<std::string> components; for (auto it = doc.Begin(); it != doc.End(); it++) { const char* name = it->GetString(); components.push_back(name); // replace colons with dashes char* nameStr = strdup(name); char* p = nameStr; while (*p) { if (*p == ':') { *p = '-'; } p++; } fwPlatformString nameWide(nameStr); free(nameStr); AddComponent(new DllGameComponent(va(PLATFORM_LIBRARY_STRING, nameWide.c_str()))); } // load the components, but don't instance them std::vector<fwRefContainer<ComponentData>> componentDatas; for (auto& component : components) { auto comp = LoadComponent(component.c_str()); if (!comp.GetRef()) { FatalError("Could not load component %s.", component.c_str()); } componentDatas.push_back(comp); } // sort the list by dependency std::queue<fwRefContainer<ComponentData>> sortedList = SortDependencyList(componentDatas); // clear the loaded list (it'll be added afterwards in order) m_loadedComponents.clear(); while (!sortedList.empty()) { auto comp = sortedList.front(); sortedList.pop(); m_loadedComponents.push_back(comp); // create a component instance if need be if (comp->ShouldAutoInstance()) { trace("Initializing instance of %s.\n", comp->GetName().c_str()); comp->CreateInstance(std::string()); } } }