Пример #1
0
int D_Typeface::lua_WordWrap(lua_State *L) {
	D_Typeface::Ref self = lua::SharedPtr::Get<D_Typeface>(L, "D_Typeface", 1, true);

	bool kern = (lua_gettop(L) < 4) || (lua_toboolean(L, 4) ? true : false);
	float kernScale = (lua_gettop(L) < 5) ? 1.f : (float)luaL_checknumber(L, 5);

	self->typeface->font->SetPixelSize(
		self->typeface->width,
		self->typeface->height
	);

	StringVec strings = self->typeface->font->WordWrapString(
		luaL_checkstring(L, 2),
		(float)luaL_checknumber(L, 3),
		kern,
		kernScale
	);

	if (strings.empty())
		return 0;

	int ofs = 1;
	lua_createtable(L, (int)strings.size(), 0);
	for (StringVec::const_iterator it = strings.begin(); it != strings.end(); ++it) {
		lua_pushinteger(L, ofs++);
		lua_pushstring(L, (*it).c_str);
		lua_settable(L, -3);
	}

	return 1;
}
Пример #2
0
void SBWorkspace::selectTargets(PotentialTargetsVec& ret) {
    String queryMessage;
    if (m_workspace) {
        queryMessage = "The \"" + getName() + "\" workspace contains multiple targets.";
    } else {
        queryMessage = "The project contains multiple targets.";
    }

    // Get all possible targets in the solution
    PotentialTargetsVec allTargets;
    getAllTargets(allTargets);

    // Construct vector of target names for the query, maintaining order
    StringVec targetNames;
    std::transform(allTargets.begin(), allTargets.end(), back_inserter(targetNames), [](auto kv) { return kv.first->getNameWithType(); });
    sbAssertWithTelemetry(!targetNames.empty(), "The workspace contains no targets");

    // Query the user for which targets should be queued
    std::vector<size_t> selection;
    queryListSelection(targetNames, queryMessage, "target", selection);

    // Return selection of targets
    ret.clear();
    std::transform(selection.begin(), selection.end(), back_inserter(ret), [&allTargets](size_t i) { return allTargets[i]; });
}
Пример #3
0
static String expandRecursivePath(const String& path, const String& prefix, const VariableCollectionHierarchy& vch)
{
  // Check if recursive expansion is necessary
  if (!strEndsWith(path, "/**"))
    return addPrefixQuoted(path, prefix, vch);
  
  // Remove the pesky /** ending
  String fixedPath = path.substr(0, path.length() - 3);
  
  // Expand the path and get an absolute project path
  String expandedPath = vch.expand(fixedPath);
  String projectPath = vch.getValue("PROJECT_DIR");
  
  // Make an absolute path
  String absPath = joinPaths(projectPath, expandedPath);
  
  // Get a list of subdirectories to ignore
  StringVec ignoreList;
  vch.getValue("EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES", ignoreList);

  // Get recursive paths
  StringVec dirVec;
  getRecursiveDirList(absPath, dirVec, ignoreList);
  
  // Sort the paths such that they are in breadth-first, alphabetic order
  std::sort(dirVec.begin(), dirVec.end(), compare_nocase_breadth_first);

  // Substitute back the original form of the path (which likely contains variables)
  String ret;
  for (unsigned i = 0; i < dirVec.size(); i++) {
    dirVec[i].replace(0, absPath.length(), fixedPath);
    ret += addPrefixQuoted(dirVec[i], prefix, vch);
  }

  // Check that the recursive expansion succeeded
  if (dirVec.empty()) {
    SBLog::info() << "Failed recursive expansion of \"" << absPath << "\". Path does not exist." << std::endl;
    return "";
  } else { 
    return ret;
  }
}
Пример #4
0
std::string parseVocationString(StringVec vocStringVec)
{
	std::string str = "";
	if(!vocStringVec.empty())
	{
		for(StringVec::iterator it = vocStringVec.begin(); it != vocStringVec.end(); ++it)
		{
			if((*it) != vocStringVec.front())
			{
				if((*it) != vocStringVec.back())
					str += ", ";
				else
					str += " and ";
			}

			str += (*it);
			str += "s";
		}
	}

	return str;
}
Пример #5
0
void SBSourcesBuildPhase::writeVCProjectFiles(VCProject& proj) const
{
  // We don't support source compilation when building bundles
  TargetProductType productType = m_parentTarget.getProductType();
  if (productType == TargetBundle)
  {
    if (!m_phase->getBuildFileList().empty()) {
      SBLog::warning() << "Ignoring all source files in \"" << m_parentTarget.getName() << "\" bundle target." << std::endl;
    }
    return;
  }

  SBBuildPhase::writeVSFileDescriptions(proj, "Text");

  String xcProjectDir = m_parentTarget.getProject().getProjectDir();
  String vsProjectDir = sb_dirname(proj.getPath());
  StringSet prefixHeaders;
  for (auto bs : m_parentTarget.getBuildSettings()) {
    VCProjectConfiguration* config = proj.addConfiguration(bs.first);

    // Prefix header (recalculate relative path)
    String prefixHeader = bs.second->getValue("GCC_PREFIX_HEADER");
    if (!prefixHeader.empty()) {
      String absHeaderPath = m_parentTarget.makeAbsolutePath(prefixHeader);
      String relHeaderPath = m_parentTarget.makeRelativePath(prefixHeader, vsProjectDir);;
      relHeaderPath = winPath(relHeaderPath);
      config->setItemDefinition("ClangCompile", "PrefixHeader", relHeaderPath);

      // Add plist file to project (only once)
      if (prefixHeaders.find(absHeaderPath) == prefixHeaders.end()) {
        addRelativeFilePathToVS("ClInclude", absHeaderPath, "", proj, *bs.second);
        prefixHeaders.insert(absHeaderPath);
      }
    }

    // Preprocessor definitions
    StringVec preprocessorTokens;
    bs.second->getValue("GCC_PREPROCESSOR_DEFINITIONS", preprocessorTokens);
    String preprocessorDefs = joinStrings(preprocessorTokens, ";");
    if (!preprocessorDefs.empty()) {
      config->setItemDefinition("ClangCompile", "PreprocessorDefinitions", preprocessorDefs);
    }

    // Optimization level
    String optimizationLevel = bs.second->getValue("GCC_OPTIMIZATION_LEVEL");
    if (!optimizationLevel.empty()) {
      String vsOptimizationLevel;
      if (optimizationLevel == "s") {
        vsOptimizationLevel = "MinSpace";
      } else if (optimizationLevel == "0") {
        vsOptimizationLevel = "Disabled";
      } else {
        vsOptimizationLevel = "MaxSpeed";
      }
      config->setItemDefinition("ClangCompile", "OptimizationLevel", vsOptimizationLevel);
    }

    // ARC
    String enableARC = bs.second->getValue("CLANG_ENABLE_OBJC_ARC");
    if (enableARC == "YES") {
      config->setItemDefinition("ClangCompile", "ObjectiveCARC", "true");
    }

    // Modules
    String enableModules = bs.second->getValue("CLANG_ENABLE_MODULES");
    if (enableModules == "YES") {
        config->setItemDefinition("ClangCompile", "ObjectiveCModules", "true");
    }

    // Header search paths (make them relative)
    StringVec includePaths;
    bs.second->getValue("HEADER_SEARCH_PATHS", includePaths);
    for (auto &cur : includePaths) {
      cur = m_parentTarget.makeRelativePath(cur, vsProjectDir);
      cur = winPath(cur);
    }
    includePaths.insert(includePaths.begin(), "$(SolutionPublicHeadersDir)");
    config->setItemDefinition("ClangCompile", "IncludePaths", joinStrings(includePaths, ";"));

    // User header search paths (make them relative)
    StringVec userIncludePaths;
    bs.second->getValue("USER_HEADER_SEARCH_PATHS", userIncludePaths);
    for (auto &cur : userIncludePaths) {
      cur = m_parentTarget.makeRelativePath(cur, vsProjectDir);
      cur = winPath(cur);
    }
    if (!userIncludePaths.empty()) {
      config->setItemDefinition("ClangCompile", "UserIncludePaths", joinStrings(userIncludePaths, ";"));
    }

    // Exclude search path subdirectories
    StringVec excludeSubDirectories;
    bs.second->getValue("EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES", excludeSubDirectories);
    if (!excludeSubDirectories.empty()) {
        config->setItemDefinition("ClangCompile", "ExcludedSearchPathSubdirectories", joinStrings(excludeSubDirectories, ";"));
    }

    // Header map
    if (bs.second->getValue("USE_HEADERMAP") == "YES") {
      if (bs.second->getValue("ALWAYS_SEARCH_USER_PATHS") == "YES") {
        config->setItemDefinition("ClangCompile", "HeaderMap", "Combined");
      } else if (bs.second->getValue("HEADERMAP_INCLUDES_PROJECT_HEADERS") == "YES") {
        config->setItemDefinition("ClangCompile", "HeaderMap", "Project");
      }
    }

    // Other C flags
    String otherCFlags = bs.second->getValue("OTHER_CFLAGS");
    processClangFlags(otherCFlags, xcProjectDir, vsProjectDir);
    if (!otherCFlags.empty()) {
      config->setItemDefinition("ClangCompile", "OtherCFlags", otherCFlags);
    }

    // Other C++ flags
    String otherCPlusPlusFlags = bs.second->getValue("OTHER_CPLUSPLUSFLAGS");
    processClangFlags(otherCPlusPlusFlags, xcProjectDir, vsProjectDir);
    if (!otherCPlusPlusFlags.empty()) {
      config->setItemDefinition("ClangCompile", "OtherCPlusPlusFlags", otherCPlusPlusFlags);
    }

    // CRT
    String configNameUpper = strToUpper(bs.first);
    if (configNameUpper.find("DEBUG") != String::npos) {
      config->setItemDefinition("ClangCompile", "RuntimeLibrary", "MultiThreadedDebugDLL");
    }
  }
}
Пример #6
0
int VtModelParser::Load(
	const xtime::TimeSlice &time,
	Engine &engine,
	const pkg::Asset::Ref &asset,
	int flags
) {
	const String *s = asset->entry->KeyValue<String>("AnimStates.Source", P_TARGET_FLAGS(flags));
	if (!s)
		return SR_MetaError;

	m_statesRef = engine.sys->packages->Resolve(s->c_str, asset->zone);
	if (!m_statesRef)
		return SR_FileNotFound;

	int r = m_statesRef->Process(
		xtime::TimeSlice::Infinite,
		flags
	);

	if (r != SR_Success)
		return r;

	m_states = SkAnimStatesParser::Cast(m_statesRef);
	if (!m_states || !m_states->valid)
		return SR_ParseError;

	s = asset->entry->KeyValue<String>("Mesh.Source.File", P_TARGET_FLAGS(flags));
	if (!s)
		return SR_MetaError;

	file::MMFileInputBuffer::Ref ib = engine.sys->files->OpenInputBuffer(s->c_str, ZTools);
	if (!ib)
		return SR_FileNotFound;

	stream::InputStream is(*ib);

	tools::SceneFile mesh;
	if (!tools::LoadSceneFile(is, mesh, true))
		return SR_ParseError;

	ib.reset();

	if (mesh.worldspawn->models.size() != 1) {
		COut(C_Error) << "ERROR: 3DX file should only contain 1 model, it contains " << mesh.worldspawn->models.size() << ". File: '" << *s << "'" << std::endl;
		return SR_ParseError;
	}

	s = asset->entry->KeyValue<String>("Anims.Source.File", P_TARGET_FLAGS(flags));
	if (!s)
		return SR_MetaError;

	StringVec animSources;
	SkAnimSetParser::LoadToolsFile(s->c_str, engine, &animSources, 0);

	if (animSources.empty())
		return SR_ParseError;

	tools::SceneFileVec anims;
	for (StringVec::const_iterator it = animSources.begin(); it != animSources.end(); ++it) {
		ib = engine.sys->files->OpenInputBuffer((*it).c_str, ZTools);
		if (!ib)
			return SR_FileNotFound;
		stream::InputStream is(*ib);
		tools::SceneFileRef x(new (tools::Z3DX) tools::SceneFile());
		if (!tools::LoadSceneFile(is, *x, true))
			return SR_ParseError;
		anims.push_back(x);
	}

	m_vtmd = tools::CompileVtmData(
		asset->path,
		mesh,
		anims,
		0
	);

	return m_vtmd ? SR_Success : SR_ParseError;
}