void DIALOG_TEMPLATE_SELECTOR::buildPageContent( const wxString& aPath, int aPage ) { // Get a list of files under the template path to include as choices... wxDir dir; if( dir.Open( aPath ) ) { if( dir.HasSubDirs( "meta" ) ) { AddTemplate( aPage, new PROJECT_TEMPLATE( aPath ) ); } else { wxDir sub_dir; wxString sub_name; bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS ); while( cont ) { wxString sub_full = aPath + sub_name; if( sub_dir.Open( sub_full ) ) { AddTemplate( aPage, new PROJECT_TEMPLATE( sub_full ) ); } cont = dir.GetNext( &sub_name ); } } } }
void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPath ) { wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY ); m_notebook->AddPage( newPage, aTitle ); TEMPLATE_SELECTION_PANEL* p = new TEMPLATE_SELECTION_PANEL( newPage ); m_panels.push_back( p ); // Get a list of files under the template path to include as choices... wxArrayString files; wxDir dir, sub; if ( dir.Open( aPath.GetPath() ) ) { wxString filename; bool cont = dir.GetFirst( &filename, wxEmptyString, wxDIR_FILES | wxDIR_DIRS ); while( cont ) { if( sub.Open( aPath.GetPathWithSep() + filename ) ) { files.Add( filename ); PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( aPath.GetPathWithSep() + filename ); AddTemplate( m_notebook->GetPageCount() - 1, pt ); } cont = dir.GetNext( &filename ); } } }
void QueryClusterer::MergeClusters() { // Merge two clusters that are within the threshold in similarity // Iterate from left to right and merge the left one into right one and mark // the left one for deletion std::vector<Cluster *> to_delete; for (auto i = clusters_.begin(); i != clusters_.end(); i++) { for (auto j = i; ++j != clusters_.end();) { auto left = *i; auto right = *j; auto r_centroid = right->GetCentroid(); auto similarity = left->CosineSimilarity(r_centroid); if (similarity > threshold_) { auto templates = left->GetTemplates(); for (auto &fingerprint : templates) { right->AddTemplate(fingerprint); template_cluster_[fingerprint] = right; } right->UpdateCentroid(features_); to_delete.push_back(left); break; } } } // Delete the clusters that are empty for (auto cluster : to_delete) { clusters_.erase(cluster); delete cluster; } // Rebuild the KDTree to account for changed clusters kd_tree_.Build(clusters_); }
bool Task::AddTemplate(const QString &template_path) { Template *t = new Template(); if (t && t->Initialize(template_path)) { return AddTemplate(t); } else { return false; } }
void BlackMarketMgr::LoadTemplates() { uint32 oldMSTime = getMSTime(); // Clear in case we are reloading if (!_templates.empty()) { for (BlackMarketTemplateMap::iterator itr = _templates.begin(); itr != _templates.end(); ++itr) delete itr->second; _templates.clear(); } QueryResult result = WorldDatabase.Query("SELECT marketId, sellerNpc, itemEntry, quantity, minBid, duration, chance, bonusListIDs FROM blackmarket_template"); if (!result) { TC_LOG_INFO("server.loading", ">> Loaded 0 black market templates. DB table `blackmarket_template` is empty."); return; } do { Field* fields = result->Fetch(); BlackMarketTemplate* templ = new BlackMarketTemplate(); if (!templ->LoadFromDB(fields)) // Add checks { delete templ; continue; } AddTemplate(templ); } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u black market templates in %u ms.", uint32(_templates.size()), GetMSTimeDiffToNow(oldMSTime)); }
void CLevel::Load( TiXmlElement * root ) { if ( root == NULL ) { return; } int sw = VIRTUAL_WIDTH; int sh = VIRTUAL_HEIGHT; root->QueryIntAttribute("w", &sw); root->QueryIntAttribute("h", &sh); mSceneWidth = (uint32)sw; mSceneHeight = (uint32)sh; int initCamX = 0; int initCamY = 0; root->QueryIntAttribute("init_cam_x", &initCamX); root->QueryIntAttribute("init_cam_y", &initCamY); mInitCam.x = (float)initCamX; mInitCam.y = (float)initCamY; // includes TiXmlElement * elem_inc = root->FirstChildElement("include"); for(; elem_inc; elem_inc = elem_inc->NextSiblingElement("include")) { const char * path = elem_inc->Attribute("path"); if ( path != 0 ) { TiXmlDocument doc; if ( OpenXmlFile(path, &doc) ) { TiXmlElement * elem_templ = doc.FirstChildElement("template"); for(; elem_templ; elem_templ = elem_templ->NextSiblingElement("template")) { AddTemplate( (TiXmlElement *)elem_templ->Clone(), true ); } } } mIncludes.push_back((TiXmlElement *)elem_inc->Clone()); } // templates TiXmlElement * elem_templ = root->FirstChildElement("template"); for(; elem_templ; elem_templ = elem_templ->NextSiblingElement("template")) { AddTemplate( (TiXmlElement *)elem_templ->Clone(), false ); } TiXmlElement * elem_obj = root->FirstChildElement("object"); for(; elem_obj; elem_obj = elem_obj->NextSiblingElement("object")) { GameObjectPtr obj; const char * type = elem_obj->Attribute("type"); const char * tmpl = elem_obj->Attribute("template"); obj = CreateObject( type, tmpl ); IwAssert(LEVEL, obj != NULL); obj->Load( elem_obj ); obj->Init(); AddObject( obj ); #if APP_SAVE_XML obj->SetSave(true); #endif } DoAddObjs(); }
long ProjNewGUI::HandleButtonClick(NativeControl Handle, NativeGUIWin NW, int ButtonID) { SECURITY_INLINE_CHECK(073, 73); switch(ButtonID) { case ID_SAVE: { if(AppScope->GUIWins->CVG) AppScope->GUIWins->CVG->CloseViewsForIO(); if (CreateNewProject()) { // can't have two delayed notifications in queue at once so only way to open Import Wizard and close // New project is to do it ourselves. if (UserMessageYN("Import Data", "Your new Project has been created and saved.\nWould you like to import some data now?")) { Close(); if(!AppScope->GUIWins->IWG) { AppScope->GUIWins->IWG = new ImportWizGUI(AppScope->AppDB, AppScope->MainProj, AppScope->AppEffects, AppScope->StatusLog, true); if(AppScope->GUIWins->IWG->ConstructError) { delete AppScope->GUIWins->IWG; AppScope->GUIWins->IWG = NULL; } // if } // if if(AppScope->GUIWins->IWG) { AppScope->GUIWins->IWG->Open(AppScope->MainProj); } } // if AppScope->MCP->SetParam(1, WCS_TOOLBARCLASS_MODULES, WCS_TOOLBAR_CLOSE_MOD, WCS_TOOLBAR_ITEM_PNG, 0); } // if saved break; } // case IDCANCEL: { AppScope->MCP->SetParam(1, WCS_TOOLBARCLASS_MODULES, WCS_TOOLBAR_CLOSE_MOD, WCS_TOOLBAR_ITEM_PNG, 0); break; } // case IDC_ADDTEMPLATE: { AddTemplate(); break; } // IDC_ADDTEMPLATE case IDC_REMOVETEMPLATE: { RemoveTemplate(); break; } // IDC_REMOVETEMPLATE case IDC_MOVETEMPUP: { ChangeTemplateListPosition(1); break; } // IDC_MOVETEMPLATEUP case IDC_MOVETEMPDOWN: { ChangeTemplateListPosition(0); break; } // IDC_MOVETEMPLATEDOWN case IDC_ENABLETEMPLATE: { EnableTemplate(1); break; } // IDC_ENABLETEMPLATE case IDC_DISABLETEMPLATE: { EnableTemplate(0); break; } // IDC_DISABLETEMPLATE default: break; } // ButtonID return(0); } // ProjNewGUI::HandleButtonClick