void TagExtractor::findStartEndPositions(const QString &tag)
{
    initializeTags(tag);

    starts = findAll(startTag);
    ends = findAll(endTag);
}
Beispiel #2
0
Point Board::getBomberman() const {
	PointList rslt;
	rslt.splice(rslt.end(), findAll(Element(LL("BOMBERMAN"))));
	rslt.splice(rslt.end(), findAll(Element(LL("BOMB_BOMBERMAN"))));
	rslt.splice(rslt.end(), findAll(Element(LL("DEAD_BOMBERMAN"))));
	return rslt.front();
}
Beispiel #3
0
PointList Board::getOtherBombermans() const {
	PointList rslt;
	rslt.splice(rslt.end(), findAll(Element(LL("OTHER_BOMBERMAN"))));
	rslt.splice(rslt.end(), findAll(Element(LL("OTHER_BOMB_BOMBERMAN"))));
	rslt.splice(rslt.end(), findAll(Element(LL("OTHER_DEAD_BOMBERMAN"))));
	return rslt;
}
Beispiel #4
0
QStringList InputMatcher::choices(bool allowpartial, bool allowpredicted, const QString &prefix, const QString &suffix) const
{
    if (nsets.size() == 0)
	return QStringList();

    if (mLookup) {
	QStringList ch;
	uint minError;
	int pl = prefixLength(prefix);
	int sl = suffixLength(suffix);
	if (pl == -1 || sl == -1 || (pl + sl >= (int)nsets.size()))
	    return QStringList();
	ch = searchDict(allowpartial, allowpredicted, dict, extradict,
		pl, nsets.size()-sl, &minError);
	if ( lowerdict ) {
	    for (QStringList::Iterator i=ch.begin(); i!=ch.end(); ++i)
		*i = (*i).toLower();
	}
	QStringList::Iterator it;
	for (it = ch.begin(); it != ch.end(); ++it) {
	    *it = prefix + *it + suffix;
	}
	return ch;
    } else {
	return findAll(nsets.size()-longestEnd, nsets.size(), QString() );
    }
}
Beispiel #5
0
void MoFileRepo::updateDesc(string title, string desc) throw (RepositoryException)
{
	vector<Movie*> allMovies = findAll();
	unsigned i = 0;
	while(i < allMovies.size() && allMovies[i]->getTitle().compare(title) != 0)
		i++;
	if (i == allMovies.size())
	{
		for(unsigned j = 0; j < allMovies.size(); j++)
			delete allMovies[j];
		throw RepositoryException("There is no artist with this name!");
	}
	allMovies[i]->setDesc(desc);

	ofstream out;
	out.open(fileName,ios::trunc);
	if(!out.is_open())
		cout << "Failed to open artists file!updateDesc"<<fileName<<endl;
	else
	{
		for(unsigned j = 0; j < allMovies.size(); j++)
		{
			out << allMovies[j]->getTitle() << endl << allMovies[j]->getType() << endl<< allMovies[j]->getDesc() << endl<< allMovies[j]->getAvailable() << endl;
			delete allMovies[j];
		}
		out.close();
	}
}
Beispiel #6
0
PointList Board::getFutureBlasts() const {
	PointList bombs = getBombs();
	bombs.splice(bombs.end(), findAll(Element(LL("OTHER_BOMB_BOMBERMAN"))));
	bombs.splice(bombs.end(), findAll(Element(LL("BOMB_BOMBERMAN"))));

	PointList rslt;
	PointList walls = getWalls();
	for (auto bmb : bombs) {
		rslt.push_back(bmb);
		PointList bombSurrs = bmb.getSurrounds(size);
		for (auto surr : bombSurrs) {
			if (std::find(walls.begin(), walls.end(), surr) == walls.end()) {
				rslt.push_back(surr);
			}
		}
	}

	return removeDuplicates(rslt);
}
QHash<typename MapperClass::Identity, typename MapperClass::Model *> CrudController<ControllerClass, MapperClass>::allModels()
{
    QHash<Identity, Model *> models;

    for (Model * model : findAll())
    {
        models.insert(getDataMapper().idOf(model), model);
    }

    return models;
}
Beispiel #8
0
  // Cчитает число связей от атомами, подходящими под фильтр from.
  // до атомов, подходящих под фильтр to
  // Подходит как для расчета Cn-Cm, где n != m, так и для Cn-Cn, Cn-OH и т.п.
  size_t CountConnections(const VertexFilter& from, const VertexFilter& to) const
  {
    if (from == to)
    {
      return CountConnections(from);
    }
        
    std::vector<Vertex> fromVertices = findAll(from);
    std::vector<Vertex> toVertices = findAll(to);
    
    size_t result = 0;
    for (size_t i=0; i<fromVertices.size(); ++i)
    {
      for (size_t j=0; j<toVertices.size(); ++j)
      {
	result += Distance(fromVertices[i], toVertices[j]);
      }
    }
    
    return result;
  }
Beispiel #9
0
QStringList InputMatcher::findAll(const QString &prefix, const QString &suffix) const
{
    int pl = prefixLength(prefix);
    int sl = suffixLength(suffix); 
    QStringList ch;
    if (pl != -1 && sl != -1 && (pl + sl < (int)nsets.size())) {
	ch = findAll(pl, nsets.size()-sl, QString());
    }
    QStringList::Iterator it;
    for (it = ch.begin(); it != ch.end(); ++it) {
	*it = prefix + *it + suffix;
    }
    return ch;
}
bool RegexEngine::findFirst(const std::string& text, std::string &matchedText)
{
	textToCheck = text;

	// Find all patterns
	if (findAll())
	{
		matchedText = foundPatterns_[0];
		currentPatternIndex_ = 0;
		return true;
	}

	return false;
}
Beispiel #11
0
PointList Board::getBombs() const {
	PointList rslt;
    rslt.splice(rslt.end(), findAll(Element(LL("BOMB_TIMER_1"))));
    rslt.splice(rslt.end(), findAll(Element(LL("BOMB_TIMER_2"))));
    rslt.splice(rslt.end(), findAll(Element(LL("BOMB_TIMER_3"))));
    rslt.splice(rslt.end(), findAll(Element(LL("BOMB_TIMER_4"))));
    rslt.splice(rslt.end(), findAll(Element(LL("BOMB_TIMER_5"))));
    rslt.splice(rslt.end(), findAll(Element(LL("BOMB_BOMBERMAN"))));
    return rslt;
}
Beispiel #12
0
/* WadArchive::detectIncludes
 * Parses the DECORATE, GLDEFS, etc. lumps for included files, and
 * mark them as being of the same type
 *******************************************************************/
void WadArchive::detectIncludes()
{
	// DECORATE: #include "lumpname"
	// GLDEFS: #include "lumpname"
	// SBARINFO: #include "lumpname"
	// ZMAPINFO: translator = "lumpname"
	// EMAPINFO: extradata = lumpname
	// EDFROOT: lumpinclude("lumpname")

	const char * lumptypes[6]  = { "DECORATE", "GLDEFS", "SBARINFO", "ZMAPINFO", "EMAPINFO", "EDFROOT" };
	const char * entrytypes[6] = { "decorate", "gldefslump", "sbarinfo", "xlat", "extradata", "edf" };
	const char * tokens[6] = { "#include", "#include", "#include", "translator", "extradata", "lumpinclude" };
	Archive::search_options_t opt;
	opt.ignore_ext = true;
	Tokenizer tz;
	tz.setSpecialCharacters(";,:|={}/()");

	for (int i = 0; i < 6; ++i)
	{
		opt.match_name = lumptypes[i];
		vector<ArchiveEntry*> entries = findAll(opt);
		if (entries.size())
		{
			for (size_t j = 0; j < entries.size(); ++j)
			{
				tz.openMem(&entries[j]->getMCData(), lumptypes[i]);
				string token = tz.getToken();
				while (token.length())
				{
					if (token.Lower() == tokens[i])
					{
						if (i >= 3) // skip '=' or '('
							tz.getToken();
						string name = tz.getToken();
						if (i == 5) // skip ')'
							tz.getToken();
						opt.match_name = name;
						ArchiveEntry * entry = findFirst(opt);
						if (entry)
							entry->setType(EntryType::getType(entrytypes[i]));
					}
					else tz.skipLineComment();
					token = tz.getToken();
				}
			}
		}
	}
}
Beispiel #13
0
void Finder::initFind(Atom **atoms, uint n)
{
    uint index = 0;
    Atom **dup = new Atom *[n];
    for (uint i = 0; i < n; ++i)
    {
        Atom *atom = atoms[i];
        if (!atom) continue;
        if (atom->lattice() && atom->lattice()->coords().z == 0) continue;

        dup[index++] = atom;
    }

    findAll(dup, index);

    delete [] dup;
}
Beispiel #14
0
  // Cчитает число связей между узлами, подходящими под фильтр.
  // Подходит для расчета Cn-Cn. Не походит для Cn-Cm, где n != m
  size_t CountConnections(const VertexFilter& filter) const
  {
    std::vector<Vertex> vertices = findAll(filter);
        
    size_t result = 0;
    if (!vertices.empty())
    {
      for (size_t i=0; i<vertices.size()-1; ++i)
      {
	for (size_t j=i+1; j<vertices.size(); ++j)
	{
	  result += Distance(vertices[i], vertices[j]);
	}
      }
    }
    
    return result;
  }
Beispiel #15
0
int main(int argc, char **argv)
{
    App::initializeDependencies();
    K4AboutData about("tasklister", "tasklister",
                     ki18n("Lists all the tasks"), "1.0");
    KCmdLineArgs::init(argc, argv, &about);
    KApplication app;

    auto repository = Utils::DependencyManager::globalInstance().create<Domain::TaskRepository>();
    auto queries = Utils::DependencyManager::globalInstance().create<Domain::TaskQueries>();
    auto taskList = queries->findAll();

    QListView view;
    view.setModel(new Presentation::TaskListModel(taskList, repository, &view));
    view.resize(640, 480);
    view.show();

    return app.exec();
}
void TextFindReplacePanel::initiate()
{
    mSearchPosition = -1;

    if(mEditor)
    {
        QTextCursor c( mEditor->textCursor() );
        if(c.hasSelection() &&
           c.document()->findBlock(c.selectionStart()) ==
           c.document()->findBlock(c.selectionEnd()))
        {
            mFindField->setText(c.selectedText());
            mReplaceField->clear();
        }
    }

    mFindField->selectAll();
    findAll();
}
Beispiel #17
0
QStringList InputMatcher::findAll(int set, int maxset, const QString& str) const
{
    if ( set == maxset ) {
	// fits in asked for set
	return QStringList(str);
    } else if (set > maxset ) {
	// does not fit in asked for set
	return QStringList();
    }

    QStringList r;
    const InputMatcherGuessList *g = nsets[set];
    InputMatcherGuessList::const_iterator it = g->begin();
    while(it != g->end()) {
	IMIGuess guess = *it;
	QChar c(guess.c);
	if (g->shift)
	    c = convertToUpper(c);
	r += findAll(set+guess.length, maxset, str+c);
	++it;
    }
    return r;

}
Beispiel #18
0
/* Archive::findAll
 * Returns a list of entries matching the search criteria in
 * [options]
 *******************************************************************/
vector<ArchiveEntry*> Archive::findAll(search_options_t& options)
{
	// Init search variables
	ArchiveTreeNode* dir = options.dir;
	if (!dir) dir = dir_root;
	vector<ArchiveEntry*> ret;
	options.match_name.MakeLower();		// Force case-insensitive

	// Begin search

	// Search entries
	for (unsigned a = 0; a < dir->numEntries(); a++)
	{
		ArchiveEntry* entry = dir->getEntry(a);

		// Check type
		if (options.match_type)
		{
			if (entry->getType() == EntryType::unknownType())
			{
				if (!options.match_type->isThisType(entry))
					continue;
			}
			else if (options.match_type != entry->getType())
				continue;
		}

		// Check name
		if (!options.match_name.IsEmpty())
		{
			// Cut extension if ignoring
			wxFileName fn(entry->getName());
			if (options.ignore_ext)
			{
				if (!fn.GetName().MakeLower().Matches(options.match_name))
					continue;
			}
			else if (!fn.GetFullName().MakeLower().Matches(options.match_name))
				continue;
		}

		// Check namespace
		if (!options.match_namespace.IsEmpty())
		{
			if (!(S_CMPNOCASE(detectNamespace(entry), options.match_namespace)))
				continue;
		}

		// Entry passed all checks so far, so we found a match
		ret.push_back(entry);
	}

	// Search subdirectories (if needed)
	if (options.search_subdirs)
	{
		for (unsigned a = 0; a < dir->nChildren(); a++)
		{
			search_options_t opt = options;
			opt.dir = (ArchiveTreeNode*)dir->getChild(a);

			// Add any matches to the list
			vector<ArchiveEntry*> vec = findAll(opt);
			ret.insert(ret.end(), vec.begin(), vec.end());
		}
	}

	// Return matches
	return ret;
}
Beispiel #19
0
 size_t CountVertices(const VertexFilter& filter) const
 {
   std::vector<Vertex> vertices = findAll(filter);
   return vertices.size();
 }
Beispiel #20
0
PointList Board::getDestoyWalls() const {
	return findAll(Element(LL("DESTROY_WALL")));
}
Beispiel #21
0
// -----------------------------------------------------------------------------
// Static function to check if an archive has sufficient texture related
// entries, and if not, prompts the user to either create or import them.
// Returns true if the entries exist, false otherwise
// -----------------------------------------------------------------------------
bool TextureXEditor::setupTextureEntries(Archive* archive)
{
	using Format = TextureXList::Format;

	// Check any archive was given
	if (!archive)
		return false;

	// Search archive for any ZDoom TEXTURES entries
	Archive::SearchOptions options;
	options.match_type = EntryType::fromId("zdtextures");
	auto entry_tx      = archive->findFirst(options); // Find any TEXTURES entry

	// If it's found, we're done
	if (entry_tx)
		return true;


	// Search archive for any texture-related entries
	options.match_type = EntryType::fromId("texturex");
	entry_tx           = archive->findFirst(options); // Find any TEXTUREx entry
	options.match_type = EntryType::fromId("pnames");
	auto entry_pnames  = archive->findFirst(options); // Find any PNAMES entry

	// If both exist, we're done
	if (entry_tx && entry_pnames)
		return true;

	// Todo: accept entry_tx without pnames if the textures are in Jaguar mode

	// If no TEXTUREx entry exists
	if (!entry_tx)
	{
		// No TEXTUREx entries found, so ask if the user wishes to create one
		wxMessageDialog dlg(
			nullptr,
			"The archive does not contain any texture definitions (TEXTURE1/2 or TEXTURES). "
			"Do you wish to create or import a texture definition list?",
			"No Texture Definitions Found",
			wxYES_NO);

		if (dlg.ShowModal() == wxID_YES)
		{
			CreateTextureXDialog ctxd(nullptr);

			while (true)
			{
				// Check if cancelled
				if (ctxd.ShowModal() == wxID_CANCEL)
					return false;

				if (ctxd.createNewSelected())
				{
					// User selected to create a new TEXTUREx list
					ArchiveEntry* texturex = nullptr;

					// Doom or Strife TEXTUREx
					if (ctxd.getSelectedFormat() == Format::Normal || ctxd.getSelectedFormat() == Format::Strife11)
					{
						// Create texture list
						TextureXList txlist;
						txlist.setFormat(ctxd.getSelectedFormat());

						// Create patch table
						PatchTable ptt;

						// Create dummy patch
						auto dpatch = App::archiveManager().programResourceArchive()->entryAtPath("s3dummy.lmp");
						archive->addEntry(dpatch, "patches", true);
						ptt.addPatch("S3DUMMY");

						// Create dummy texture
						auto dummytex = std::make_unique<CTexture>();
						dummytex->setName("S3DUMMY");
						dummytex->addPatch("S3DUMMY", 0, 0);
						dummytex->setWidth(128);
						dummytex->setHeight(128);
						dummytex->setScale({ 0., 0. });

						// Add dummy texture to list
						// (this serves two purposes - supplies the special 'invalid' texture by default,
						//   and allows the texturex format to be detected)
						txlist.addTexture(std::move(dummytex));

						// Add empty PNAMES entry to archive
						entry_pnames = archive->addNewEntry("PNAMES");
						ptt.writePNAMES(entry_pnames);
						entry_pnames->setType(EntryType::fromId("pnames"));
						entry_pnames->setExtensionByType();

						// Add empty TEXTURE1 entry to archive
						texturex = archive->addNewEntry("TEXTURE1");
						txlist.writeTEXTUREXData(texturex, ptt);
						texturex->setType(EntryType::fromId("texturex"));
						texturex->setExtensionByType();
					}
					else if (ctxd.getSelectedFormat() == Format::Textures)
					{
						// Create texture list
						TextureXList txlist;
						txlist.setFormat(Format::Textures);

						// Add empty TEXTURES entry to archive
						texturex = archive->addNewEntry("TEXTURES");
						texturex->setType(EntryType::fromId("zdtextures"));
						texturex->setExtensionByType();

						return false;
					}

					if (!texturex)
						return false;
				}
				else
				{
					// User selected to import texture definitions from the base resource archive
					auto bra = App::archiveManager().baseResourceArchive();

					if (!bra)
					{
						wxMessageBox(
							"No Base Resource Archive is opened, please select/open one", "Error", wxICON_ERROR);
						continue;
					}

					// Find all relevant entries in the base resource archive
					Archive::SearchOptions opt;
					opt.match_type     = EntryType::fromId("texturex");
					auto import_tx     = bra->findAll(opt); // Find all TEXTUREx entries
					opt.match_type     = EntryType::fromId("pnames");
					auto import_pnames = bra->findLast(opt); // Find last PNAMES entry

					// Check enough entries exist
					if (import_tx.empty() || !import_pnames)
					{
						wxMessageBox(
							"The selected Base Resource Archive does not contain "
							"sufficient texture definition entries",
							"Error",
							wxICON_ERROR);
						continue;
					}

					// Copy TEXTUREx entries over to current archive
					for (auto& a : import_tx)
					{
						auto texturex = archive->addEntry(a, "global", true);
						texturex->setType(EntryType::fromId("texturex"));
						texturex->setExtensionByType();
					}

					// Copy PNAMES entry over to current archive
					entry_pnames = archive->addEntry(import_pnames, "global", true);
					entry_pnames->setType(EntryType::fromId("pnames"));
					entry_pnames->setExtensionByType();
				}

				break;
			}

			return true;
		}

		// 'No' clicked
		return false;
	}
	else // TEXTUREx entry exists
	{
		// TODO: Probably a better idea here to get the user to select an archive to import the patch table from
		// If no PNAMES entry was found, search resource archives
		if (!entry_pnames)
		{
			Archive::SearchOptions opt;
			opt.match_type = EntryType::fromId("pnames");
			entry_pnames   = App::archiveManager().findResourceEntry(opt, archive);
		}

		// If no PNAMES entry is found at all, show an error and abort
		// TODO: ask user to select appropriate base resource archive
		if (!entry_pnames)
		{
			wxMessageBox("PNAMES entry not found!", wxMessageBoxCaptionStr, wxICON_ERROR);
			return false;
		}

		return true;
	}

	return false;
}
Beispiel #22
0
QStringList InputMatcher::findAll() const
{
    return findAll(0, nsets.size(), QString() );
}
Beispiel #23
0
// -----------------------------------------------------------------------------
// Returns a list of entries matching the search criteria in [options]
// -----------------------------------------------------------------------------
vector<ArchiveEntry*> Archive::findAll(SearchOptions& options)
{
	// Init search variables
	auto dir = options.dir;
	if (!dir)
		dir = &dir_root_;
	vector<ArchiveEntry*> ret;
	StrUtil::upperIP(options.match_name); // Force case-insensitive

	// Begin search

	// Search entries
	for (unsigned a = 0; a < dir->numEntries(); a++)
	{
		auto entry = dir->entryAt(a);

		// Check type
		if (options.match_type)
		{
			if (entry->type() == EntryType::unknownType())
			{
				if (!options.match_type->isThisType(entry))
					continue;
			}
			else if (options.match_type != entry->type())
				continue;
		}

		// Check name
		if (!options.match_name.empty())
		{
			// Cut extension if ignoring
			auto check_name = options.ignore_ext ? entry->upperNameNoExt() : entry->upperName();
			if (!StrUtil::matches(check_name, options.match_name))
				continue;
		}

		// Check namespace
		if (!options.match_namespace.empty())
		{
			if (!StrUtil::equalCI(detectNamespace(entry), options.match_namespace))
				continue;
		}

		// Entry passed all checks so far, so we found a match
		ret.push_back(entry);
	}

	// Search subdirectories (if needed)
	if (options.search_subdirs)
	{
		for (unsigned a = 0; a < dir->nChildren(); a++)
		{
			auto opt = options;
			opt.dir  = (ArchiveTreeNode*)dir->child(a);

			// Add any matches to the list
			auto vec = findAll(opt);
			ret.insert(ret.end(), vec.begin(), vec.end());
		}
	}

	// Return matches
	return ret;
}
Beispiel #24
0
PointList Board::getMeatChoppers() const {
	return findAll(Element(LL("MEAT_CHOPPER")));
}
Beispiel #25
0
PointList Board::getWalls() const {
	return findAll(Element(LL("WALL")));
}
void ArchiveOperations::removeUnusedTextures(Archive* archive)
{
	// Check archive was given
	if (!archive)
		return;

	// --- Build list of used textures ---
	TexUsedMap used_textures;
	int        total_maps = 0;

	// Get all SIDEDEFS entries
	Archive::SearchOptions opt;
	opt.match_type = EntryType::fromId("map_sidedefs");
	auto sidedefs  = archive->findAll(opt);
	total_maps += sidedefs.size();

	// Go through and add used textures to list
	DoomMapFormat::SideDef sdef;
	wxString               tex_lower, tex_middle, tex_upper;
	for (auto& sidedef : sidedefs)
	{
		int nsides = sidedef->size() / 30;
		sidedef->seek(0, SEEK_SET);
		for (int s = 0; s < nsides; s++)
		{
			// Read side data
			sidedef->read(&sdef, 30);

			// Get textures
			tex_lower  = wxString::FromAscii(sdef.tex_lower, 8);
			tex_middle = wxString::FromAscii(sdef.tex_middle, 8);
			tex_upper  = wxString::FromAscii(sdef.tex_upper, 8);

			// Add to used textures list
			used_textures[tex_lower].used  = true;
			used_textures[tex_middle].used = true;
			used_textures[tex_upper].used  = true;
		}
	}

	// Get all TEXTMAP entries
	opt.match_name = "TEXTMAP";
	opt.match_type = EntryType::fromId("udmf_textmap");
	auto udmfmaps  = archive->findAll(opt);
	total_maps += udmfmaps.size();

	// Go through and add used textures to list
	Tokenizer tz;
	tz.setSpecialCharacters("{};=");
	for (auto& udmfmap : udmfmaps)
	{
		// Open in tokenizer
		tz.openMem(udmfmap->data(), "UDMF TEXTMAP");

		// Go through text tokens
		wxString token = tz.getToken();
		while (!token.IsEmpty())
		{
			// Check for sidedef definition
			if (token == "sidedef")
			{
				tz.getToken(); // Skip {

				token = tz.getToken();
				while (token != "}")
				{
					// Check for texture property
					if (token == "texturetop" || token == "texturemiddle" || token == "texturebottom")
					{
						tz.getToken(); // Skip =
						used_textures[tz.getToken()].used = true;
					}

					token = tz.getToken();
				}
			}

			// Next token
			token = tz.getToken();
		}
	}

	// Check if any maps were found
	if (total_maps == 0)
		return;

	// Find all TEXTUREx entries
	opt.match_name  = "";
	opt.match_type  = EntryType::fromId("texturex");
	auto tx_entries = archive->findAll(opt);

	// Go through texture lists
	PatchTable    ptable; // Dummy patch table, patch info not needed here
	wxArrayString unused_tex;
	for (auto& tx_entrie : tx_entries)
	{
		TextureXList txlist;
		txlist.readTEXTUREXData(tx_entrie, ptable);

		// Go through textures
		bool anim = false;
		for (unsigned t = 1; t < txlist.size(); t++)
		{
			wxString texname = txlist.texture(t)->name();

			// Check for animation start
			for (int b = 0; b < n_tex_anim; b++)
			{
				if (texname == tex_anim_start[b])
				{
					anim = true;
					break;
				}
			}

			// Check for animation end
			bool thisend = false;
			for (int b = 0; b < n_tex_anim; b++)
			{
				if (texname == tex_anim_end[b])
				{
					anim    = false;
					thisend = true;
					break;
				}
			}

			// Mark if unused and not part of an animation
			if (!used_textures[texname].used && !anim && !thisend)
				unused_tex.Add(txlist.texture(t)->name());
		}
	}

	// Pop up a dialog with a checkbox list of unused textures
	wxMultiChoiceDialog dialog(
		theMainWindow,
		"The following textures are not used in any map,\nselect which textures to delete",
		"Delete Unused Textures",
		unused_tex);

	// Get base resource textures (if any)
	auto                  base_resource = App::archiveManager().baseResourceArchive();
	vector<ArchiveEntry*> base_tx_entries;
	if (base_resource)
		base_tx_entries = base_resource->findAll(opt);
	PatchTable   pt_temp;
	TextureXList tx;
	for (auto& texturex : base_tx_entries)
		tx.readTEXTUREXData(texturex, pt_temp, true);
	vector<wxString> base_resource_textures;
	for (unsigned a = 0; a < tx.size(); a++)
		base_resource_textures.push_back(tx.texture(a)->name());

	// Determine which textures to check initially
	wxArrayInt selection;
	for (unsigned a = 0; a < unused_tex.size(); a++)
	{
		bool swtex = false;

		// Check for switch texture
		if (unused_tex[a].StartsWith("SW1"))
		{
			// Get counterpart switch name
			wxString swname = unused_tex[a];
			swname.Replace("SW1", "SW2", false);

			// Check if its counterpart is used
			if (used_textures[swname].used)
				swtex = true;
		}
		else if (unused_tex[a].StartsWith("SW2"))
		{
			// Get counterpart switch name
			wxString swname = unused_tex[a];
			swname.Replace("SW2", "SW1", false);

			// Check if its counterpart is used
			if (used_textures[swname].used)
				swtex = true;
		}

		// Check for base resource texture
		bool br_tex = false;
		for (auto& texture : base_resource_textures)
		{
			if (texture.CmpNoCase(unused_tex[a]) == 0)
			{
				Log::info(3, "Texture " + texture + " is in base resource");
				br_tex = true;
				break;
			}
		}

		if (!swtex && !br_tex)
			selection.Add(a);
	}
	dialog.SetSelections(selection);

	int n_removed = 0;
	if (dialog.ShowModal() == wxID_OK)
	{
		// Get selected textures
		selection = dialog.GetSelections();

		// Go through texture lists
		for (auto& entry : tx_entries)
		{
			TextureXList txlist;
			txlist.readTEXTUREXData(entry, ptable);

			// Go through selected textures to delete
			for (int i : selection)
			{
				// Get texture index
				int index = txlist.textureIndex(WxUtils::strToView(unused_tex[i]));

				// Delete it from the list (if found)
				if (index >= 0)
				{
					txlist.removeTexture(index);
					n_removed++;
				}
			}

			// Write texture list data back to entry
			txlist.writeTEXTUREXData(entry, ptable);
		}
	}

	wxMessageBox(wxString::Format("Removed %d unused textures", n_removed));
}
Beispiel #27
0
QStringList InputMatcher::allChoices() const
{
    struct WordWraps
    {
	const char *prefix;
	const char *postfix;
    };

    // TODO should get from config file.
    WordWraps wraps[] = {
	{ 0, "'s"},
	{ "\"", "'s\""},
	{ "\"", "\""},
	{ "\"", "'s"},
	{ "\"", 0},
	{ 0, 0},
    };

    QStringList result;
    bool added_number = FALSE;
    if ( count() > 0 )  {
	result = choices(TRUE, FALSE, QString(), QString());
	if (count() == 1) {
	    QStringList all = findAll();
	    QStringList::Iterator it;
	    for (it = all.begin(); it != all.end(); ++it)
		if (!result.contains(*it))
		    result.append(*it);
	}

	WordWraps *w = wraps;
	// test if should add with gramar prefixes and post fixes.
	while(result.count() < 1 && (w->prefix != 0 || w->postfix != 0)) {
	    result = choices(TRUE, FALSE, w->prefix, w->postfix);
	    w += 1;
	}
	// test if should add with gramar prefixes and post fixes for number
	w = wraps;
	while(result.count() < 1 && (w->prefix != 0 || w->postfix != 0)) {
	    QString nword = numberWord(w->prefix, w->postfix);
	    if (!nword.isEmpty()) {
		added_number = TRUE;
		result += nword;
	    }
	    w += 1;
	}

	// test if anyting that may fit in prefix/postfix
	w = wraps;
	while(result.count() < 1 && (w->prefix != 0 || w->postfix != 0)) {
	    // only returns a word if sets have error values...
	    QString wword = writtenWord(w->prefix, w->postfix);
	    if (!wword.isEmpty())
		result += wword;
	    w += 1;
	}
	// always append the number word as a choice.
	if (!added_number) {
	    QString nword = numberWord(QString(), QString());
	    if (!nword.isEmpty()) {
		added_number = TRUE;
		result += nword;
	    }
	}
    }
    return result;
}
Beispiel #28
0
void CoreData::load() {
	string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);

	const string dir = data_path + "data/core";
	Logger::getInstance().add("Core data");

	Renderer &renderer= Renderer::getInstance();

	//textures
	backgroundTexture= renderer.newTexture2D(rsGlobal);
	backgroundTexture->setMipmap(false);
	backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga");

	fireTexture= renderer.newTexture2D(rsGlobal);
	fireTexture->setFormat(Texture::fAlpha);
	fireTexture->getPixmap()->init(1);
	fireTexture->getPixmap()->load(dir+"/misc_textures/fire_particle.tga");

	snowTexture= renderer.newTexture2D(rsGlobal);
	snowTexture->setMipmap(false);
	snowTexture->setFormat(Texture::fAlpha);
	snowTexture->getPixmap()->init(1);
	snowTexture->getPixmap()->load(dir+"/misc_textures/snow_particle.tga");

	customTexture= renderer.newTexture2D(rsGlobal);
	customTexture->getPixmap()->load(dir+"/menu/textures/custom_texture.tga");

	logoTexture= renderer.newTexture2D(rsGlobal);
	logoTexture->setMipmap(false);
	logoTexture->getPixmap()->load(dir+"/menu/textures/logo.tga");

	logoTextureList.clear();
	string logosPath= dir+"/menu/textures/logo*.*";
	vector<string> logoFilenames;
    findAll(logosPath, logoFilenames);
    for(int i = 0; i < logoFilenames.size(); ++i) {
    	string logo = logoFilenames[i];
    	if(strcmp("logo.tga",logo.c_str()) != 0) {
    		Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal);
    		logoTextureExtra->setMipmap(true);
    		logoTextureExtra->getPixmap()->load(dir+"/menu/textures/" + logo);
    		logoTextureList.push_back(logoTextureExtra);
    	}
    }

	waterSplashTexture= renderer.newTexture2D(rsGlobal);
	waterSplashTexture->setFormat(Texture::fAlpha);
	waterSplashTexture->getPixmap()->init(1);
	waterSplashTexture->getPixmap()->load(dir+"/misc_textures/water_splash.tga");

	buttonSmallTexture= renderer.newTexture2D(rsGlobal);
	buttonSmallTexture->setForceCompressionDisabled(true);
	buttonSmallTexture->getPixmap()->load(dir+"/menu/textures/button_small.tga");

	buttonBigTexture= renderer.newTexture2D(rsGlobal);
	buttonBigTexture->setForceCompressionDisabled(true);
	buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga");

	horizontalLineTexture= renderer.newTexture2D(rsGlobal);
	horizontalLineTexture->setForceCompressionDisabled(true);
	horizontalLineTexture->getPixmap()->load(dir+"/menu/textures/line_horizontal.tga");

	verticalLineTexture= renderer.newTexture2D(rsGlobal);
	verticalLineTexture->setForceCompressionDisabled(true);
	verticalLineTexture->getPixmap()->load(dir+"/menu/textures/line_vertical.tga");

	checkBoxTexture= renderer.newTexture2D(rsGlobal);
	checkBoxTexture->setForceCompressionDisabled(true);
	checkBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox.tga");

	checkedCheckBoxTexture= renderer.newTexture2D(rsGlobal);
	checkedCheckBoxTexture->setForceCompressionDisabled(true);
	checkedCheckBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox_checked.tga");

	//display font
	Config &config= Config::getInstance();
	string displayFontNamePrefix=config.getString("FontDisplayPrefix");
	string displayFontNamePostfix=config.getString("FontDisplayPostfix");
	int displayFontSize=computeFontSize(config.getInt("FontDisplayBaseSize"));
	string displayFontName=displayFontNamePrefix+intToStr(displayFontSize)+displayFontNamePostfix;
	displayFont= renderer.newFont(rsGlobal);
	displayFont->setType(displayFontName);
	displayFont->setSize(displayFontSize);

	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontName = [%s] displayFontSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontName.c_str(),displayFontSize);

	//menu fonts
	string displayFontNameSmallPrefix= config.getString("FontDisplayPrefix");
	string displayFontNameSmallPostfix= config.getString("FontDisplayPostfix");
	int displayFontNameSmallSize=computeFontSize(config.getInt("FontDisplaySmallBaseSize"));
	string displayFontNameSmall=displayFontNameSmallPrefix+intToStr(displayFontNameSmallSize)+displayFontNameSmallPostfix;
	displayFontSmall= renderer.newFont(rsGlobal);
	displayFontSmall->setType(displayFontNameSmall);
	displayFontSmall->setSize(displayFontNameSmallSize);

	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontSmallName = [%s] displayFontSmallNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontNameSmall.c_str(),displayFontNameSmallSize);

	string menuFontNameNormalPrefix= config.getString("FontMenuNormalPrefix");
	string menuFontNameNormalPostfix= config.getString("FontMenuNormalPostfix");
	int menuFontNameNormalSize=computeFontSize(config.getInt("FontMenuNormalBaseSize"));
	string menuFontNameNormal= menuFontNameNormalPrefix+intToStr(menuFontNameNormalSize)+menuFontNameNormalPostfix;
	menuFontNormal= renderer.newFont(rsGlobal);
	menuFontNormal->setType(menuFontNameNormal);
	menuFontNormal->setSize(menuFontNameNormalSize);
	menuFontNormal->setWidth(Font::wBold);

	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNormalName = [%s] menuFontNormalNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameNormal.c_str(),menuFontNameNormalSize);

	string menuFontNameBigPrefix= config.getString("FontMenuBigPrefix");
	string menuFontNameBigPostfix= config.getString("FontMenuBigPostfix");
	int menuFontNameBigSize=computeFontSize(config.getInt("FontMenuBigBaseSize"));
	string menuFontNameBig= menuFontNameBigPrefix+intToStr(menuFontNameBigSize)+menuFontNameBigPostfix;
	menuFontBig= renderer.newFont(rsGlobal);
	menuFontBig->setType(menuFontNameBig);
	menuFontBig->setSize(menuFontNameBigSize);

	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameBig = [%s] menuFontNameBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameBig.c_str(),menuFontNameBigSize);

	string menuFontNameVeryBigPrefix= config.getString("FontMenuBigPrefix");
	string menuFontNameVeryBigPostfix= config.getString("FontMenuBigPostfix");
	int menuFontNameVeryBigSize=computeFontSize(config.getInt("FontMenuVeryBigBaseSize"));
	string menuFontNameVeryBig= menuFontNameVeryBigPrefix+intToStr(menuFontNameVeryBigSize)+menuFontNameVeryBigPostfix;
	menuFontVeryBig= renderer.newFont(rsGlobal);
	menuFontVeryBig->setType(menuFontNameVeryBig);
	menuFontVeryBig->setSize(menuFontNameVeryBigSize);

	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameVeryBig = [%s] menuFontNameVeryBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameVeryBig.c_str(),menuFontNameVeryBigSize);

	//console font
	string consoleFontNamePrefix= config.getString("FontConsolePrefix");
	string consoleFontNamePostfix= config.getString("FontConsolePostfix");
	int consoleFontNameSize=computeFontSize(config.getInt("FontConsoleBaseSize"));
	string consoleFontName= consoleFontNamePrefix+intToStr(consoleFontNameSize)+consoleFontNamePostfix;
	consoleFont= renderer.newFont(rsGlobal);
	consoleFont->setType(consoleFontName);
	consoleFont->setSize(consoleFontNameSize);

	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] consoleFontName = [%s] consoleFontNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,consoleFontName.c_str(),consoleFontNameSize);

	//sounds
    clickSoundA.load(dir+"/menu/sound/click_a.wav");
    clickSoundB.load(dir+"/menu/sound/click_b.wav");
    clickSoundC.load(dir+"/menu/sound/click_c.wav");
    attentionSound.load(dir+"/menu/sound/attention.wav");
    highlightSound.load(dir+"/menu/sound/highlight.wav");
	introMusic.open(dir+"/menu/music/intro_music.ogg");
	introMusic.setNext(&menuMusic);
	menuMusic.open(dir+"/menu/music/menu_music.ogg");
	menuMusic.setNext(&menuMusic);
	waterSounds.resize(6);
	for(int i=0; i<6; ++i){
		waterSounds[i]= new StaticSound();
		waterSounds[i]->load(dir+"/water_sounds/water"+intToStr(i)+".wav");
	}

}
Beispiel #29
0
PointList Board::getBlasts() const {
	return findAll(Element(LL("BOOM")));
}