Esempio n. 1
0
//==============================================================
// 로드
void CDIB::LoadFromFile(wstring file_name) {
	if (!FileExists(file_name)) return;
	file_name=ToUpper(file_name);	
	if (EndsWith(file_name, L".BMP")) LoadBMPFile(file_name); else
	if (EndsWith(file_name, L".PNG")) LoadPNGFile(file_name);
	if (EndsWith(file_name, L".JPG") || EndsWith(file_name, L".JPEG")) LoadJPEGFile(file_name);
}
Esempio n. 2
0
/*
 *	Given a URI, determine it's protocolInfo.
 */
enum MR_SupportedProtocolInfo UriToProtocolInfo(const char* targetUri)
{
	enum MR_SupportedProtocolInfo protInfo;

	/*
	 *	Determine protocolInfo based on file extension.
	 *
	 *	TODO: need more robust means of determining protocolInfo.
	 */

	if (EndsWith(targetUri, ".mp3", 1) != 0)
	{
		protInfo = MR_PROTINFO_HTTP_AUDIO_MPEG;
	}
	else if (EndsWith(targetUri, ".wma", 1) != 0)
	{
		protInfo = MR_PROTINFO_HTTP_AUDIO_WMA;
	}
	else if (EndsWith(targetUri, ".mpeg", 1) != 0)
	{
		protInfo = MR_PROTINFO_HTTP_VIDEO_MPEG;
	}
	else if (EndsWith(targetUri, ".wmv", 1) != 0)
	{
		protInfo = MR_PROTINFO_HTTP_VIDEO_WMV;
	}
	else
	{
		/* just assume something http. */
		protInfo = MR_PROTINFO_HTTP_UNKNOWN;
	}

	return protInfo;
}
//*
//* ONCLICK
//*
byte auia_click(AUI_VARSP v) {
  char * fl = afbox_getselectedfile(v->hFile);
  byte dtype = afbox_dtype(v->hFile);
  
  if (((dtype == 4) || (dtype == 24)) && (fl != NULL)) {
    aui_setpath(&v->path, v->path, fl, 1);
    v->reshow = 1;
    return 0;
  } 
  else if (strstr(fl, ".zip") != NULL) {
        if (EndsWith(fl,".zip")){
          char * full_fl = NULL;
          aui_setpath(&full_fl, v->path, fl, 0);
          choose_kernel(full_fl, 1);
          free(full_fl);
          v->reshow = 1;
          return 0;
        }
  } 
  else if (strstr(fl, ".img") != NULL) {
        if (EndsWith(fl,".img")){
          char * full_fl = NULL;
          aui_setpath(&full_fl, v->path, fl, 0);
          choose_kernel(full_fl,0);
          free(full_fl);
          v->reshow = 1;
          return 0;
      }
  } 
  else if (fl != NULL) {
    printf("File  [%i]: %s\n", dtype, fl);
  }
  
  return 1;
}
Esempio n. 4
0
string getGameReadWritePath(string lookupKey) {
	string path = "";

	if(lookupKey != "") {
        std::map<string,string> &pathCache = CacheManager::getCachedItem< std::map<string,string> >(GameConstants::pathCacheLookupKey);
        std::map<string,string>::const_iterator iterFind = pathCache.find(lookupKey);
        if(iterFind != pathCache.end()) {
            path = iterFind->second;

            if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
                path += "/";
            }

            //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path to be used for [%s] files [%s]\n",__FILE__,__FUNCTION__,__LINE__,lookupKey.c_str(),path.c_str());
        }
	}

    if(path == "") {
        path = safeCharPtrCopy(getenv("GLESTHOME"),8095);
        if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
            path += "/";
        }

        //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path to be used for read/write files [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
    }

    return path;
}
Esempio n. 5
0
ZipEntry *
ZipEntry::AddChildrenFromPath(zip_t *zipFile, wxMutex *mutex,
                              std::map<wxString, ZipEntry *> &entryMap,
                              const wxString &innerPath) {
  auto iter = entryMap.find(innerPath);
  if (iter != entryMap.end())
    return iter->second;

  auto path = innerPath;
  bool dir = false;
  if (path.EndsWith("/")) {
    dir = true;
    path = path.BeforeLast('/');
  }

  auto parentPath = path.BeforeLast('/');
  if (parentPath != "")
    parentPath += "/";

  auto parent = AddChildrenFromPath(zipFile, mutex, entryMap, parentPath);
  auto child = new ZipEntry(zipFile, mutex, innerPath);

  parent->AddChild(child);
  entryMap[innerPath] = child;

  return child;
}
Esempio n. 6
0
bool GatherTpp::MakeHtml(const char *folder, Gate2<int, int> progress) {
	DeleteFolderDeep(folder);
	DirectoryCreate(folder);

	for(int i = 0; i < tt.GetCount(); i++) {
		String topic = tt.GetKey(i);
		links.Add(topic, topic == indexTopic ? "index.html" :
		                 memcmp(topic, "topic://", 8) ? topic : TopicFileNameHtml(topic));
	}
	for(int i = 0; i < reflink.GetCount(); i++) {
		String l = reflink.GetKey(i);
		String lbl = Filter(l, CharFilterLbl);
		String f = links.Get(reflink[i], Null) + '#' + lbl;
		links.Add(l, f);
		static const char *x[] = { "::struct", "::class", "::union" };
		for(int ii = 0; ii < 3; ii++) {
			String e = x[ii];
			if(EndsWith(l, e)) {
				links.Add(l.Mid(0, l.GetLength() - e.GetLength()), f);
			}
		}
		labels.Add(l, lbl);
	}

	for(int i = 0; i < tt.GetCount(); i++) {
		if (progress(i+1, tt.GetCount()))
			return false;
		ExportPage(i, folder);
	}
	return true;
}
Esempio n. 7
0
static bool ShouldBypassWithEntry(URI& uri, SharedPtr<BypassEntry> entry)
{
    const std::string& uriHost = uri.getHost();
    const std::string& uriScheme = uri.getScheme();
    unsigned short uriPort = uri.getPort();
    const std::string& entryHost = entry->host;
    const std::string& entryScheme = entry->scheme;
    unsigned short entryPort = entry->port;

    GetLogger()->Debug("bypass entry: scheme='%s' host='%s' port='%i'",
                       entry->scheme.c_str(), entry->host.c_str(), entry->port);

    // An empty bypass entry equals an unconditional bypass.
    if (entry.isNull())
    {
        return true;
    }
    else
    {
        if (entryHost == "<local>" && uriHost.find(".") == string::npos)
        {
            return true;
        }
        else if (EndsWith(uriHost, entryHost) &&
                 (entryScheme.empty() || entryScheme == uriScheme) &&
                 (entryPort == 0 || entryPort == uriPort))
        {
            return true;
        }
    }

    return false;
}
Esempio n. 8
0
bool
TrackerString::Matches(const char* string, bool caseSensitivity,
	TrackerStringExpressionType expressionType) const
{
	switch (expressionType) {
		default:
		case kNone:
			return false;

		case kStartsWith:
			return StartsWith(string, caseSensitivity);

		case kEndsWith:
			return EndsWith(string, caseSensitivity);

		case kContains:
			return Contains(string, caseSensitivity);

		case kGlobMatch:
			return MatchesGlob(string, caseSensitivity);

		case kRegexpMatch:
			return MatchesRegExp(string, caseSensitivity);
	}
}
Esempio n. 9
0
int ILibFileDir_GetDirEntryCount(const char* fullPath, char *dirDelimiter)
{
	char fn[MAX_PATH_LENGTH];
	void *dirObj;
	int retVal = 0;
	int ewDD;
	int nextFile;

	dirObj = ILibFileDir_GetDirFirstFile(fullPath, fn, MAX_PATH_LENGTH, NULL);

	if (dirObj != NULL)
	{
		ewDD = EndsWith(fullPath, dirDelimiter, 0);

		do
		{
			retVal++;
			nextFile = ILibFileDir_GetDirNextFile(dirObj,fullPath,fn,MAX_PATH_LENGTH, NULL);
		}
		while (nextFile != 0);

		ILibFileDir_CloseDir(dirObj);
	}

	return retVal;
}
Esempio n. 10
0
XmlReaderPtr OgreXmlSerializer::OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename)
{
    if (!EndsWith(filename, ".skeleton.xml", false))
    {
        DefaultLogger::get()->error("Imported Mesh is referencing to unsupported '" + filename + "' skeleton file.");
        return XmlReaderPtr();
    }

    if (!pIOHandler->Exists(filename))
    {
        DefaultLogger::get()->error("Failed to find skeleton file '" + filename + "' that is referenced by imported Mesh.");
        return XmlReaderPtr();
    }

    std::unique_ptr<IOStream> file(pIOHandler->Open(filename));
    if (!file.get()) {
        throw DeadlyImportError("Failed to open skeleton file " + filename);
    }

    std::unique_ptr<CIrrXML_IOStreamReader> stream(new CIrrXML_IOStreamReader(file.get()));
    XmlReaderPtr reader = XmlReaderPtr(irr::io::createIrrXMLReader(stream.get()));
    if (!reader.get()) {
        throw DeadlyImportError("Failed to create XML reader for skeleton file " + filename);
    }
    return reader;
}
Esempio n. 11
0
void Data::InitFeatureMap(const string& str)
{
  string buf = str;
  string substr;
  string features = "";
  string tmp_name = "";
  size_t tmp_index = 0;

  while (!buf.empty()) {
    getNextPound(buf, substr);

    // string ending with "=" are skipped, because they are the names of the features
    if (!EndsWith(substr, "=")) {
      stringstream ss;
      ss << tmp_name << "_" << tmp_index << " ";
      features.append(ss.str());

      tmp_index++;
    } else if (substr.find("_") != string::npos) {
      // ignore sparse feature name and its value
      getNextPound(buf, substr);
    } else {                              // update current feature name
      tmp_index = 0;
      tmp_name = substr.substr(0, substr.size() - 1);
    }
  }
  m_feature_data->setFeatureMap(features);
}
Esempio n. 12
0
void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenarioName){
	SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scenarioDir = [%s] scenarioName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioDir.c_str(),scenarioName.c_str());

	string scenarioFolder = scenarioDir + "/" + scenarioName + "/";
	string path = scenarioFolder + scenarioName + "_" + language + ".lng";
	if(EndsWith(scenarioDir, ".xml") == true) {
		scenarioFolder = extractDirectoryPathFromFile(scenarioDir);
		path = scenarioFolder + scenarioName + "_" + language + ".lng";

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

	scenarioStrings.clear();

	//try to load the current language first
	if(fileExists(path)) {
		scenarioStrings.load(path);
	}
	else{
		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path not found [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());

		//try english otherwise
		path = scenarioFolder + scenarioName + "_english.lng";
		SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());

		if(fileExists(path)){
			scenarioStrings.load(path);
		}
	}
}
Esempio n. 13
0
	bool Proxy::ShouldBypass(URI& uri)
	{
		const std::string& uriHost = uri.getHost();
		const std::string& uriScheme = uri.getScheme();
		unsigned short uriPort = uri.getPort();
		for (size_t i = 0; i < bypassList.size(); i++)
		{
			SharedURI entry = bypassList.at(i);

			// An empty bypass entry equals an unconditional bypass.
			if (entry.isNull())
			{
				return true;
			}
			else
			{
				const std::string& entryHost = entry->getHost();
				const std::string& entryScheme = entry->getScheme();
				unsigned short entryPort = entry->getPort();

				if (entryHost == "<local>" && uriHost.find(".") == string::npos)
				{
					return true;
				}
				else if (EndsWith(uriHost, entryHost) &&
					(entryScheme.empty() || entryScheme == uriScheme) &&
					(entryPort == 0 || entryPort == uriPort))
				{
					return true;
				}
			}
		}

		return false;
	}
int PCGetGetDirEntryCount(const char* fullPath, char *dirDelimiter)
{
	char fn[MAX_PATH_LENGTH];
	void *dirObj;
	int retVal = 0;
	int ewDD;
	int nextFile;

	dirObj = PCGetDirFirstFile(fullPath, fn, MAX_PATH_LENGTH, NULL);

	if (dirObj != NULL)
	{
		ewDD = EndsWith(fullPath, dirDelimiter, 0);

		do
		{
			if (ProceedWithDirEntry(fullPath, fn, MAX_PATH_LENGTH) != 0)
			{
				retVal++;
			}

			nextFile = PCGetDirNextFile(dirObj,fullPath,fn,MAX_PATH_LENGTH, NULL);
		}
		while (nextFile != 0);

		PCCloseDir(dirObj);
	}

	return retVal;
}
Esempio n. 15
0
bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh)
{
    if (!mesh || mesh->skeletonRef.empty())
        return false;

    // Highly unusual to see in read world cases but support
    // XML mesh referencing a binary skeleton file.
    if (EndsWith(mesh->skeletonRef, ".skeleton", false))
    {
        if (OgreBinarySerializer::ImportSkeleton(pIOHandler, mesh))
            return true;

        /** Last fallback if .skeleton failed to be read. Try reading from
            .skeleton.xml even if the XML file referenced a binary skeleton.
            @note This logic was in the previous version and I don't want to break
            old code that might depends on it. */
        mesh->skeletonRef = mesh->skeletonRef + ".xml";
    }

    XmlReaderPtr reader = OpenReader(pIOHandler, mesh->skeletonRef);
    if (!reader.get())
        return false;

    Skeleton *skeleton = new Skeleton();
    OgreXmlSerializer serializer(reader.get());
    serializer.ReadSkeleton(skeleton);
    mesh->skeleton = skeleton;
    return true;
}
Esempio n. 16
0
bool OgreImporter::CanRead(const std::string &pFile, Assimp::IOSystem *pIOHandler, bool checkSig) const
{
	if (!checkSig) {
		return EndsWith(pFile, ".mesh.xml", false) || EndsWith(pFile, ".mesh", false);
	}

	if (EndsWith(pFile, ".mesh.xml", false))
	{
		const char* tokens[] = { "<mesh>" };
		return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
	}
	else
	{
		/// @todo Read and validate first header chunk?
		return EndsWith(pFile, ".mesh", false);
	}
}
Esempio n. 17
0
 //-----------------------------------------------------------------------
 void TerminateStringWith(std::string &instrMain, const std::string &instrEnding)
 {
     // Simplest case, already terminated
     if( EndsWith(instrMain, instrEnding))
         return;
     
     // Assume no partials if not already terminated
     instrMain += instrEnding;
 }
Esempio n. 18
0
void Scan(const wchar_t*folder, int depth=0)
{
	PrintIndent(depth);
	wprintf(L"[%s]\n",folder);

	wchar_t path[0x1000];
	swprintf_s(path,sizeof(path)/sizeof(wchar_t),L"%s\\*",folder);
	WIN32_FIND_DATA data;
	HANDLE find = FindFirstFile(path,&data);
	if (find!=NULL)
	{
		do
		{
			if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
			{
				if (!wcscmp(data.cFileName,L".") || !wcscmp(data.cFileName,L".."))
					continue;
				wchar_t sub[0x1000];
				swprintf_s(sub,sizeof(sub)/sizeof(wchar_t),L"%s\\%s",folder,data.cFileName);
				Scan(sub,depth+1);
			}
			else
			{
				PrintIndent(depth+1);
				wprintf(L"%s",data.cFileName);
				bool isTXT = EndsWith(data.cFileName,L".txt");
				if (isTXT)
				{
					wprintf(L" (!!!)");
				}
				wprintf(L"\n");

				if (isTXT && doReadFile)
				{
					doReadFile = false;
					wchar_t path[0x1000];
					swprintf_s(path,sizeof(path)/sizeof(wchar_t),L"%s\\%s",folder,data.cFileName);
					FILE*f = _wfopen(path,L"rb");
					if (f)
					{
						while(!feof(f))
						{
							char buffer[0x1000];
							size_t read = fread(buffer,1,sizeof(buffer)-1,f);
							buffer[read] = 0;
							printf("%s",buffer);
						}
						fclose(f);
					}

				}
			}
		}
		while (FindNextFile(find,&data));
		FindClose(find);
	}
}
Esempio n. 19
0
bool FString::RemoveFromEnd(const char* Text)
{
	if (EndsWith(Text))
	{
		int len = strlen(Text);
		RemoveAt(Len() - len, len);
		return true;
	}
	return false;
}
Esempio n. 20
0
String String::RemoveSuffix(const String &EndCandidate) const
{
    Assert(EndsWith(EndCandidate), "Removing invalid suffix");
    String Result = *this;
    for(UINT i = 0; i < EndCandidate._Length; i++)
    {
        Result.PopEnd();
    }
    return Result;
}
Esempio n. 21
0
int main(int argc, const char** argv)
{
  MFM::DateTimeStamp stamper;
  MFM::LOG.SetTimeStamper(&stamper);
  MFM::LOG.SetByteSink(MFM::STDERR);
  MFM::LOG.SetLevel(MFM::LOG.MESSAGE);

  if (EndsWith(argv[0],"_s"))
  {
    return MFM::RunSmall(argc, argv);
  }

  if (EndsWith(argv[0],"_l"))
  {
    return MFM::RunBig(argc, argv);
  }

  return MFM::RunMedium(argc, argv);
}
Esempio n. 22
0
//Decodes each line
int Decoder(char* symboldef, char* opcode_mnemonic, char* operand, unsigned int* opcode){
	char mode = StartsWith(operand);
	char* ptr = NULL;
	//Assembler Directive/Operation Code구분(opcode_mnemonic 처리)
	if(StartsWith(opcode_mnemonic) == '+') //Extended Address
	{
		opcode_mnemonic = strtok(opcode_mnemonic,"+");	//remove Extended Sign
		statusBit |= isExtended;	//set extended_flag++;
	}

	//find OP_TAB
	whereIsOnOPTAB = FindTAB(OPTAB,opcode_mnemonic);
	if(whereIsOnOPTAB>=0){ //if found
		*opcode = OPTAB[whereIsOnOPTAB].opcode;			//change mnemonic to opcode_mnemonic
		//printf("%X\n",*opcode);						//FOR DEBUG
		LOCCTR[0] = PC;									//increase locctr by format of instruction
		PC += OPTAB[whereIsOnOPTAB].format;
		//presentLOCCTR +=  OPTAB[whereIsOnOPTAB].format
		if(statusBit & isExtended){
			PC += 4-OPTAB[whereIsOnOPTAB].format;		//In the Case of Extended, the Opcode Format is 4.
		}
		//printf("%04X %04X",LOCCTR[0],PC);				//FOR DEBUG : PRINT CURRENT LOCCTR AND PC
	}
	else{
		//if assembler directive : START(0), RESW(1), RESB(2), BYTE(3), EQU(4), ORG(5)
		LOCCTR[0] = PC;
		whereIsOnASMTAB=FindTAB(ASMTAB,opcode_mnemonic);
		*opcode = ASMTAB[whereIsOnASMTAB].opcode;
	}

	//ADD SYMBOL DEFINITION AND ADDRESS TO SYMTAB(symboldef 처리)
	if(*symboldef != NULL){
		ht_set(SYMTAB,symboldef, LOCCTR[0],LOCCTR[0]);
	}

	//symbol reference and identify addressing mode (operand 처리)
	//identifying addressing mode
	ptr = strtok(operand,"#@");
	if(ptr!=NULL){
		strcpy(operand,ptr);
	}
	//operand = ptr;
	if(mode == '@') {
		statusBit |= isIndirect;
	} else if (mode == '#') {
		statusBit |= isImmediate;
	} else if (OPTAB[whereIsOnOPTAB].format > 2){
		statusBit |= isIndirect | isImmediate;
	}
	if(EndsWith(operand,",X") == 1){
		strtok(operand,",");
		statusBit |= isIndexed;
		//printf("%s",operand); //FOR DEBUG
	}
}
Esempio n. 23
0
void UpgradeDir(const char* path, bool force, bool subdir, int& upgraded, int& ok, int& failed)
{
	WIN32_FIND_DATA find;
	printf("Upgrade checking dir '%s'\n", path);
	HANDLE f = FindFirstFile(Formats("%s/*", path), &find);
	if(f == INVALID_HANDLE_VALUE)
	{
		printf("FIND failed...\n");
		++failed;
		return;
	}

	do
	{
		if(find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			if(subdir && strcmp(find.cFileName, ".") != 0 && strcmp(find.cFileName, "..") != 0)
			{
				string new_path = Formats("%s/%s", path, find.cFileName);
				UpgradeDir(new_path.c_str(), force, subdir, upgraded, ok, failed);
			}
		}
		else
		{
			if(EndsWith(find.cFileName, ".qmsh") || EndsWith(find.cFileName, ".phy"))
			{
				string file_path = Formats("%s/%s", path, find.cFileName);
				int result = Upgrade(file_path.c_str(), force);
				if(result == -1)
					failed++;
				else if(result == 0)
					ok++;
				else
					upgraded++;
			}
		}
	}
	while(FindNextFile(f, &find));

	FindClose(f);
}
Esempio n. 24
0
void TrimSuffixSelf(std::string& str, const std::string& strSuffix,
                    bool bIgnoreCase /*= false*/, bool bRecursive /*= false*/)
{
    if (str.empty() || strSuffix.empty())
        return;
    do 
    {
        if (!EndsWith(str, strSuffix, bIgnoreCase))
            break;
        str.erase(str.length() - strSuffix.length(), strSuffix.length());
    } while (bRecursive);
}
TEST(AudioUtils, cardNameToIndexLinkDoesNotExist)
{
    // File does not exist
    EXPECT_CALL(UnistdMock::getInstance(), readlink(EndsWith("InvalidLink"), _, _))
    .WillOnce(SetErrnoAndReturn(EACCES, -1));
    EXPECT_EQ(-EACCES, AudioUtils::getCardIndexByName("InvalidLink"));

    // Empty file name
    EXPECT_CALL(UnistdMock::getInstance(), readlink(_, _, _))
    .WillOnce(SetErrnoAndReturn(EACCES, -1));
    EXPECT_EQ(-EACCES, AudioUtils::getCardIndexByName(""));
}
Esempio n. 26
0
bool GLTexture::Init( const std::string &name, int textureUnit ) {
    byte *pic, *picCopy;
    GLuint texture;
    int width, height, format;

    format = GL_RGBA;

    if ( EndsWith( name, ".tga" ) ) {
        pic = R_LoadTGA( name, width, height, format );
    } else {
        msg_warning( "no image file with name `%s' found\n", name.c_str() );
        return false;
    }

    if ( !IsPowerOf2( width ) || !IsPowerOf2( height ) ) {
        msg_warning0( "texture must have size in power of two\n" );
        return false;
    }

    picCopy = (byte *)malloc( width * height * 4 );

    _CH(glActiveTexture( GL_TEXTURE0 + textureUnit ));
    _CH(glGenTextures( 1, &texture ));
    _CH(glBindTexture( GL_TEXTURE_2D, texture ));
    _CH(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
    _CH(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));

    int mipmap = 0;
    while ( width > 1 || height > 1 ) {
        _CH(glTexImage2D( GL_TEXTURE_2D,
            mipmap,
            format,
            width,
            height,
            0,
            format,
            GL_UNSIGNED_BYTE,
            pic));

        int oldWidth, oldHeight;

        oldWidth = width;
        oldHeight = height;

        if ( width > 1 ) {
            width >>= 1;
        }

        if ( height > 1 ) {
            height >>= 1;
        }
Esempio n. 27
0
MenuStateRoot::MenuStateRoot(Program *program, MainMenu *mainMenu):
	MenuState(program, mainMenu, "root")
{
	containerName = "MainMenu";
	Lang &lang= Lang::getInstance();
	int yPos=440;


	labelVersion.registerGraphicComponent(containerName,"labelVersion");
	if(EndsWith(glestVersionString, "-dev") == false){
		labelVersion.init(525, yPos);
		labelVersion.setText(glestVersionString);
	}
	else {
		labelVersion.init(405, yPos);
		labelVersion.setText(glestVersionString + " [" + getCompileDateTime() + ", " + getSVNRevisionString() + "]");
	}

	yPos-=55;
	buttonNewGame.registerGraphicComponent(containerName,"buttonNewGame");
	buttonNewGame.init(425, yPos, 150);
	yPos-=40;
	buttonJoinGame.registerGraphicComponent(containerName,"buttonJoinGame");
    buttonJoinGame.init(425, yPos, 150);
    yPos-=40;
    buttonMasterserverGame.registerGraphicComponent(containerName,"buttonMasterserverGame");
    buttonMasterserverGame.init(425, yPos, 150);
    yPos-=40;
    buttonOptions.registerGraphicComponent(containerName,"buttonOptions");
    buttonOptions.init(425, yPos, 150);
    yPos-=40;
    buttonAbout.registerGraphicComponent(containerName,"buttonAbout");
    buttonAbout.init(425, yPos , 150);
    yPos-=40;
    buttonExit.registerGraphicComponent(containerName,"buttonExit");
    buttonExit.init(425, yPos, 150);

	buttonNewGame.setText(lang.get("NewGame"));
	buttonJoinGame.setText(lang.get("JoinGame"));
	buttonMasterserverGame.setText(lang.get("JoinInternetGame"));
	buttonOptions.setText(lang.get("Options"));
	buttonAbout.setText(lang.get("About"));
	buttonExit.setText(lang.get("Exit"));
	
	//mesage box
	mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
	mainMessageBox.init(lang.get("Yes"), lang.get("No"));
	mainMessageBox.setEnabled(false);

	GraphicComponent::applyAllCustomProperties(containerName);
}
Esempio n. 28
0
TEST(OptionsTests, EndsWith) {
  EXPECT_TRUE(EndsWith("foo", ""));
  EXPECT_TRUE(EndsWith("foo", "o"));
  EXPECT_TRUE(EndsWith("foo", "foo"));
  EXPECT_FALSE(EndsWith("foo", "fooo"));
  EXPECT_FALSE(EndsWith("", "o"));
  EXPECT_TRUE(EndsWith("", ""));
}
Esempio n. 29
0
std::string CAgentCfg::FindXmlDevicesFilePath(std::string name)
{
	std::string contents;
	ReplaceAll(name, ".", "\\");
	if(!EndsWith(_cfgFolder,"\\"))
		_cfgFolder+="\\";

	std::string filename(_cfgFolder + name + ".txt");
	std::ifstream in( filename.c_str() );
	if(!in)
	{
		filename = RecursiveFileFind(_cfgFolder, name + ".txt");
	}
	return filename;
}
TEST(AudioUtils, cardNameToIndexNominalCase)
{
    // Valid card
    EXPECT_CALL(UnistdMock::getInstance(), readlink(EndsWith("Intel"), _, _))
    .WillOnce(unistdMock::ActionReadStr("card9"));
    EXPECT_EQ(9, AudioUtils::getCardIndexByName("Intel"));

    EXPECT_CALL(UnistdMock::getInstance(), readlink(EndsWith("Intel"), _, _))
    .WillOnce(unistdMock::ActionReadStr("card10"));
    EXPECT_EQ(10, AudioUtils::getCardIndexByName("Intel"));

    std::ostringstream number;
    number << std::numeric_limits<int>::max();
    std::string cardName = "card" + number.str();
    EXPECT_CALL(UnistdMock::getInstance(), readlink(EndsWith("Intel"), _, _))
    .WillOnce(unistdMock::ActionReadStr(cardName.c_str()));
    EXPECT_EQ(std::numeric_limits<int>::max(), AudioUtils::getCardIndexByName("Intel"));

    EXPECT_EQ(9, AudioUtils::getCardIndexByName("card9"));

    EXPECT_EQ(0, AudioUtils::getCardIndexByName("card0"));

    EXPECT_EQ(std::numeric_limits<int>::max(), AudioUtils::getCardIndexByName(cardName.c_str()));
}