예제 #1
0
bool MailSender::SendEmail(const WideString& email, const WideString& subject, const WideString& messageText)
{
	if (!JniMailSender::jniMailSender)
		JniMailSender::jniMailSender = new JniMailSender();

	return JniMailSender::jniMailSender->SendEmail(WStringToString(email), WStringToString(subject), WStringToString(messageText));
}
예제 #2
0
bool AutotestingSystemLua::CheckMsgText(UIControl *control, const String &key)
{
	WideString expectedText = StringToWString(key);
	//TODO: check key in localized strings for Lua
	expectedText = autotestingLocalizationSystem->GetLocalizedString(expectedText);

	UIStaticText *uiStaticText = dynamic_cast<UIStaticText*>(control);
	if(uiStaticText)
	{
		WideString actualText = uiStaticText->GetText();
		Log("DEBUG", Format("Compare text in control %s with text by key %s", uiStaticText->GetName().c_str(), key.c_str()));
		Log("DEBUG", WStringToString(actualText));
		Log("DEBUG", WStringToString(expectedText));
		return (actualText == expectedText);
	}
	UITextField *uiTextField = dynamic_cast<UITextField*>(control);
	if(uiTextField)
	{
		WideString actualText = uiTextField->GetText();
		Log("DEBUG", Format("Compare text in control %s with text by key %s", uiTextField->GetName().c_str(), key.c_str()));
		Log("DEBUG", WStringToString(actualText));
		Log("DEBUG", WStringToString(expectedText));
		return (actualText == expectedText);
	}
	return false;
}
void LandscapeToolsPanelHeightmap::OnToolSelected(LandscapeToolsSelection * forControl, LandscapeTool *newTool)
{
    newTool->height = (float32)atof(WStringToString(heightValue->GetText()).c_str());
    newTool->averageDrawing = average->Checked();
    newTool->relativeDrawing = relative->Checked();
    
    newTool->maxStrength = (float32)fabsf((float32)atof(WStringToString(strengthValue->GetText()).c_str()));
    newTool->maxSize = (float32)fabsf((float32)atof(WStringToString(sizeValue->GetText()).c_str()));
    newTool->averageStrength = averageStrength->GetValue();

    LandscapeToolsPanel::OnToolSelected(forControl, newTool);
}
예제 #4
0
void UITextField::RenderText()
{
#ifdef __DAVAENGINE_IPHONE__
    // nothing to do
#else

#if 0
    SafeRelease(textSprite);

    int32 w = GetRect().dx;
    int32 h = GetRect().dy;

    EnsurePowerOf2(w);
    EnsurePowerOf2(h);

    int16 * buf;
	buf = new int16[w * h];
	memset(buf, 0, w * h * sizeof(int16));

    Size2i ds = textFont->DrawString(text, buf, w, h, 0, 0);
    String addInfo = WStringToString(Format(L"Text texture: %S", text.c_str()));
    Texture *tex = Texture::CreateTextFromData(FORMAT_RGBA4444, (uint8*)buf, w, h, addInfo.c_str());
    delete [] buf;

    textSprite = Sprite::CreateFromTexture(tex, 0, 0, GetRect().dx, GetRect().dy);
    SafeRelease(tex);

    textSprite->SetDefaultPivotPoint(0.0f, (float32)(textFont->GetBaseline() - h));
    
    SetSprite(textSprite, 0);

#endif

#endif
}
bool LocalizationSystem::SaveToYamlFile(const StringFile* stringFile)
{
	if (!stringFile)
	{
		return false;
	}

	YamlParser* parser = YamlParser::Create();
	if (!parser)
	{
		return false;
	}
	
	YamlNode *node = new YamlNode(YamlNode::TYPE_MAP);
	for (Map<WideString, WideString>::const_iterator iter = stringFile->strings.begin();
		 iter != stringFile->strings.end(); iter ++)
	{
		node->Add(WStringToString(iter->first), iter->second);
	}
	
	bool result = parser->SaveStringsList(stringFile->pathName, node);

	SafeDelete(node);
	SafeRelease(parser);
	return result;
}
	bool ModuleIrisAudio::BgsPlay(wstring filePath, int volume, int rate){

		string sfilepath = WStringToString(filePath);
		const char* fpath = sfilepath.c_str();

		if (channels == 0){
			if (bgsChannel != NULL){
				bool isPlaying;
				bgsChannel->isPlaying(&isPlaying);
				if (isPlaying)
					bgsChannel->stop();
			}
		}

		FMOD_RESULT result;

		result = fmodSystem->createStream(fpath, FMOD_DEFAULT, 0, &bgs);
		if (result != FMOD_OK)
			return false;

		result = fmodSystem->playSound(FMOD_CHANNEL_FREE, bgs, true, &bgsChannel);
		if (result != FMOD_OK)
			return false;

		bgsChannel->setMode(FMOD_LOOP_NORMAL);;
		bgsChannel->setVolume(volume / 100.0);

		float frequancy;

		bgsChannel->getFrequency(&frequancy);
		bgsChannel->setFrequency(frequancy * (rate / 100.0));
		bgsChannel->setPaused(false);

		return true;
	}
	void CoreWin32Platform::InitArgs()
	{
		LPWSTR *szArglist;
		int nArgs;
		int i;
		szArglist = ::CommandLineToArgvW(::GetCommandLineW(), &nArgs);
		if( NULL == szArglist )
		{
			Logger::Error("CommandLineToArgvW failed\n");
			return;
		}
		else 
		{
			Vector<String> & cl = GetCommandLine();
			for( i=0; i<nArgs; i++)
			{
				WideString w = szArglist[i];
				String nonWide = WStringToString(w);
				cl.push_back(nonWide);
				Logger::FrameworkDebug("%d: %s\n", i, nonWide.c_str());
			}
		}
		// Free memory allocated for CommandLineToArgvW arguments.
		LocalFree(szArglist);
	}
예제 #8
0
void ScriptManager::RunScript()
{
	if(curCom != coms.end())
	{
		if(state == SRun)
		{
			wstringstream comStream(curCom->second);
			command = curCom->first;
			if(command == L"Wait")
			{
				state = SWait;
				curCom++;
				clock.Reset();
			}
			else if(command == L"SetBackground")
			{
				//输出背景图像
				//读入背景图像名称
				state = SRun;
				wstring bgName;
				comStream>>bgName;
				//设置背景
				bgManager.SetBackground(WStringToString(bgName));
				clock.Reset();
				curCom++;
			}
			else if(command == L"ChangeBackground")
예제 #9
0
extern "C" __declspec(dllexport) void GetPeerID(CHAR * pszPeerID)
{
	HKEY hKEY;
	LPCSTR data_Set= "Software\\ldthost";
	if (ERROR_SUCCESS == ::RegOpenKeyExA(HKEY_CURRENT_USER,data_Set,0,KEY_READ,&hKEY))
	{
		char szValue[256] = {0};
		DWORD dwSize = sizeof(szValue);
		DWORD dwType = REG_SZ;
		if (::RegQueryValueExA(hKEY,"PeerId", 0, &dwType, (LPBYTE)szValue, &dwSize) == ERROR_SUCCESS)
		{
			strcpy(pszPeerID, szValue);
			return;
		}
		::RegCloseKey(hKEY);
	}
	std::wstring wstrPeerID;
	GetPeerId_(wstrPeerID);
	std::string strPeerID;
	WStringToString(wstrPeerID, strPeerID);
	strcpy(pszPeerID,strPeerID.c_str());

	HKEY hKey, hTempKey;
	if (ERROR_SUCCESS == ::RegOpenKeyExA(HKEY_CURRENT_USER, "Software",0,KEY_SET_VALUE, &hKey))
	{
		if (ERROR_SUCCESS == ::RegCreateKeyA(hKey, "ldthost", &hTempKey))
		{
			::RegSetValueExA(hTempKey, "PeerId", 0, REG_SZ, (LPBYTE)pszPeerID, strlen(pszPeerID)+1);
		}
		RegCloseKey(hKey);
	}

}
	bool ModuleIrisAudio::MePlay(wstring filePath, int volume, int rate){

		string sfilepath = WStringToString(filePath);
		const char* fpath = sfilepath.c_str();

		float frequency;
		bool playing;
		meChannel->isPlaying(&playing);
		if (channels == 0){
			if (meChannel != NULL){
				meChannel->isPlaying(&playing);
				if (playing == true){
					meChannel->stop();
				}
			}
		}

		FMOD_RESULT result;

		result = fmodSystem->createSound(fpath, FMOD_HARDWARE, 0, &me);
		if (result != FMOD_OK){
			return false;
		}
		result = fmodSystem->playSound(FMOD_CHANNEL_FREE, me, true, &meChannel);
		if (result != FMOD_OK){
			return false;
		}
		me->setMode(FMOD_LOOP_OFF);
		meChannel->setVolume(volume / 100.0);
		meChannel->getFrequency(&frequency);
		meChannel->setFrequency(frequency * (rate / 100.0));
		meChannel->setPaused(false);
		return true;
	}
예제 #11
0
HRESULT DXDiagNVUtil::GetDirectXVersion( DWORD * pdwDirectXVersionMajor, 
										 DWORD * pdwDirectXVersionMinor,
										 TCHAR * pcDirectXVersionLetter )
{
	HRESULT hr = S_OK;
	FAIL_IF_NULL( m_pDxDiagRoot );
	FAIL_IF_NULL( pdwDirectXVersionMajor );
	FAIL_IF_NULL( pdwDirectXVersionMinor );
	FAIL_IF_NULL( pcDirectXVersionLetter );

	wstring propval;
	GetProperty( L"DxDiag_SystemInfo", L"dwDirectXVersionMajor", &propval );
	*pdwDirectXVersionMajor = _wtoi( propval.c_str() );

	GetProperty( L"DxDiag_SystemInfo", L"dwDirectXVersionMinor", &propval );
	*pdwDirectXVersionMinor = _wtoi( propval.c_str() );

	GetProperty( L"DxDiag_SystemInfo", L"szDirectXVersionLetter", &propval );
	string str;

	str = WStringToString( &propval );
	if( str.length() > 0 )
		*pcDirectXVersionLetter = str.at(0);
	else
		*pcDirectXVersionLetter = ' ';

	return( hr );
}
	bool ModuleIrisAudio::MePlay(wstring filePath, int volume, int rate){
		string sfilepath = WStringToString(filePath);
		const char* fpath = sfilepath.c_str();

		if (channels == 0){
			if (meChannel != NULL){
				BOOL isPlaying;
				FMOD_Channel_IsPlaying(meChannel, &isPlaying);
				if (isPlaying)
					FMOD_Channel_Stop(meChannel);
			}
		}

		FMOD_RESULT result;

		result = FMOD_System_CreateStream(fmodSystem, fpath, FMOD_DEFAULT, 0, &me);
		if (result != FMOD_OK)
			return false;

		result = FMOD_System_PlaySound(fmodSystem, FMOD_CHANNEL_FREE, me, true, &meChannel);
		if (result != FMOD_OK)
			return false;

		FMOD_Channel_SetMode(meChannel, FMOD_LOOP_NORMAL);
		FMOD_Channel_SetVolume(meChannel, volume / 100.0f);

		float frequancy;

		FMOD_Channel_GetFrequency(meChannel, &frequancy);
		FMOD_Channel_SetFrequency(meChannel, frequancy * (rate / 100.0));
		FMOD_Channel_SetPaused(meChannel, FALSE);

		return true;
	}
void TextBlockSoftwareRender::Prepare(Texture *texture /*=NULL*/)
{
    // Prevent releasing sprite when texture is invalidated
    if(!texture)
    {
        TextBlockRender::Prepare(NULL);
    }
	
	int32 bsz = textBlock->cacheDx * textBlock->cacheDy;
	buf = new int16[bsz];
    memset(buf, 0, bsz * sizeof(int16));
	
	DrawText();
	
	String addInfo;
	if (!textBlock->isMultilineEnabled)
	{
		addInfo = WStringToString(textBlock->text.c_str());
	}
	else
	{
		if (textBlock->multilineStrings.size() >= 1)
		{
			addInfo = WStringToString(textBlock->multilineStrings[0].c_str());
		}else
		{
			addInfo = "empty";
		}
	}
	
    if(!texture)
    {
        Texture *tex = Texture::CreateTextFromData(FORMAT_A8, (uint8*)buf, textBlock->cacheDx, textBlock->cacheDy, false, addInfo.c_str());
        if(textBlock->textureInvalidater)
        {
            tex->SetInvalidater(textBlock->textureInvalidater);
        }
        sprite = Sprite::CreateFromTexture(tex, 0, 0, textBlock->cacheFinalSize.dx, textBlock->cacheFinalSize.dy);
        SafeRelease(tex);
    }
    else
    {
        texture->ReloadFromData(FORMAT_A8, (uint8*)buf, textBlock->cacheDx, textBlock->cacheDy);
    }
    
	SafeDeleteArray(buf);
}
예제 #14
0
void LandscapeToolsPanel::SetSliderHeaderPoition(UISlider *slider, const WideString &headerText)
{
    UIStaticText *textControl = static_cast<UIStaticText *>(this->FindByName(WStringToString(headerText)));
    if(textControl)
    {
        Rect sliderRect = slider->GetRect();
        Vector2 textPosition = textControl->GetPosition();

        textControl->SetPosition(Vector2(sliderRect.x - OFFSET - sliderRect.dx, textPosition.y));
    }
}
예제 #15
0
String AutotestingSystem::GetDeviceName()
{ 
	if (AUTOTESTING_PLATFORM_NAME == "Android")
	{
		return DeviceInfo::GetModel();
	}
	else
	{
		return WStringToString(DeviceInfo::GetName());
	}	
}
void LandscapeToolsPanelHeightmap::TextFieldLostFocus(UITextField * textField)
{
    if(textField == sizeValue)
    {
        float32 value = (float32)atof(WStringToString(sizeValue->GetText()).c_str());
        
        sizeSlider->SetMinMaxValue(0.f, value);
        selectedBrushTool->maxSize = value;
        if(value < selectedBrushTool->size)
        {
            selectedBrushTool->size = value;
        }
        sizeSlider->SetValue(selectedBrushTool->size);
    }
    else if(textField == strengthValue)
    {
        float32 value = (float32)fabsf((float32)atof(WStringToString(strengthValue->GetText()).c_str()));

        strengthSlider->SetMinMaxValue(-value, value);
        selectedBrushTool->maxStrength = value;
        if(value < selectedBrushTool->strength)
        {
            selectedBrushTool->strength = value;
        }
        else if(selectedBrushTool->strength < -value)
        {
            selectedBrushTool->strength = -value;
        }
        strengthSlider->SetValue(selectedBrushTool->strength);
    }
    else if(textField == heightValue)
    {
        prevHeightValue = (float32)fabsf((float32)atof(WStringToString(heightValue->GetText()).c_str()));
        dropperTool->height = prevHeightValue;

        if(selectedBrushTool)
        {
            selectedBrushTool->height = prevHeightValue;
        }
    }
}
예제 #17
0
bool AutotestingSystemLua::CheckText(UIControl *control, const String &expectedText)
{
	UIStaticText *uiStaticText = dynamic_cast<UIStaticText*>(control);
	if(uiStaticText)
	{
		String actualText = WStringToString(uiStaticText->GetText());
		Log("DEBUG", Format("Compare text in control %s with expected text", uiStaticText->GetName().c_str()));
		Log("DEBUG", actualText);
		Log("DEBUG", expectedText);
		return (actualText == expectedText);
	}
	UITextField *uiTextField = dynamic_cast<UITextField*>(control);
	if(uiTextField)
	{
		String actualText = WStringToString(uiTextField->GetText());
		Log("DEBUG", Format("Compare text in control %s with expected text", uiTextField->GetName().c_str()));
		Log("DEBUG", actualText);
		Log("DEBUG", expectedText);
		return (actualText == expectedText);
	}
	return false;
}
예제 #18
0
Choice& FileManager::GetFileButton(const wstring info)
{
	vector<Choice>::iterator iter;
	for(iter = fileButtons.begin(); iter != fileButtons.end(); iter++)
	{
		if(iter->GetInfo() == info)
		{
			return *iter;
		}
	}
	if(iter == fileButtons.end())
		throw runtime_error("Cannot find the file button:" + WStringToString(info));
}
예제 #19
0
파일: World.cpp 프로젝트: gasbank/poolg
World::World( const char* worldName, const TCHAR* modelFilePath )
    : m_modelSg (0)
    , m_sampleTeapotMeshRot (0)
    , m_heroUnit (0)
    , m_curDialog (0)
    , m_sound (0)
    , m_bNotEntered (true)
{
    m_worldName				= worldName;
    m_modelFilePath			= modelFilePath;

    std::string path (WStringToString (m_modelFilePath));
    m_modelSg = ArnSceneGraph::createFrom (path.c_str ());
}
예제 #20
0
파일: Mesh.hpp 프로젝트: xubingyue/XIRE
	void LoadFromObj(String filepath)
	{
		ObjLoader loader;
		io::Memfile memfile;
		loader.LoadGeometryFromObj(filepath, primitives);

		return;

		std::string s_filepath = WStringToString(filepath);

		memfile.Open(s_filepath.c_str()); 

		loader.LoadGeometryFromObj(StringToWString(memfile.Data()), primitives); 
	}
예제 #21
0
void LandscapeToolsPanel::AddSliderHeader(UISlider *slider, const WideString &text)
{
    Rect rect = slider->GetRect();
    rect.x -= rect.dx - OFFSET;
    
    UIStaticText *textControl = new UIStaticText(rect);
    textControl->SetName(WStringToString(text));
    textControl->SetText(text);
    textControl->SetFont(ControlsFactory::GetFont12());
	textControl->SetTextColor(ControlsFactory::GetColorLight());
    textControl->SetAlign(ALIGN_VCENTER | ALIGN_RIGHT);
    AddControl(textControl);
    SafeRelease(textControl);
}
예제 #22
0
void LodDistanceControl::TextFieldLostFocus(UITextField * textField)
{
    for(int32 iText = 0; iText < count; ++iText)
    {
        if(textField == distanceTextValues[iText])
        {
            float32 newDistance = atof(WStringToString(textField->GetText()).c_str());
            
            newDistance = Max(newDistance, 0.f);
            newDistance = Min(newDistance, (float32)LodNode::MAX_LOD_DISTANCE);
            if(iText)
            {
                newDistance = Max(newDistance, distances[iText-1]);
            }
            if(iText < count - 1)
            {
                newDistance = Min(newDistance, distances[iText + 1]);
            }

            //TODO: udpate sliders
            float32 deltaX = ((newDistance - distances[iText]) / maxDistance * GetRect().dx);
            if(iText)
            {
                Vector2 sz = zones[iText - 1]->GetSize();
                sz.x += deltaX; 
                zones[iText-1]->SetSize(sz);
                
                Vector2 pos = sliders[iText - 1]->GetPosition();
                pos.x += deltaX;
                sliders[iText - 1]->SetPosition(pos);
            }
            
            Rect r = zones[iText]->GetRect();
            r.x += deltaX; 
            r.dx -= deltaX;
            zones[iText]->SetRect(r);

            textField->SetText(Format(L"%3.0f", newDistance));
            distances[iText] = newDistance;
            if(delegate)
            {
                delegate->DistanceChanged(this, iText, newDistance);
            }
            
            break;
        }
    }
}
예제 #23
0
void EditMatrixControl::TextFieldShouldReturn(UITextField * textField)
{
    if (textFieldBackground->GetParent())
    {
        String value = WStringToString(textField->GetText());
        if ((editI != -1) && (editJ != -1))
        {
            matrix._data[editI][editJ] = (float32)atof(value.c_str());
            editI = editJ = -1;
        }
        
        RemoveControl(textFieldBackground);
        RemoveControl(textField);
        
        OnMatrixChanged(this, 0);
        
        SetMatrix(matrix);
    }
}
예제 #24
0
파일: PEFormat.cpp 프로젝트: yzx65/Packer
SharedPtr<FormatBase> FormatBase::loadImport(const String &filename, int architecture)
{
	if(File::isPathExists(filename))
		return ::loadImport(filename, architecture);

	List<String> searchPaths;
	String currentDirectory = WStringToString(Win32NativeHelper::get()->getCurrentDirectory());
	searchPaths.push_back(currentDirectory.substr(0, currentDirectory.length() - 1));
#ifdef _WIN32
	wchar_t *environmentBlock = Win32NativeHelper::get()->getEnvironments();
	WString path;
	while(*environmentBlock)
	{
		size_t equal = 0;
		size_t currentLength = 0;
		wchar_t *start = environmentBlock;
		while(*environmentBlock ++) 
		{
			if(*environmentBlock == L'=')
				equal = currentLength;
			currentLength ++;
		}
		if(equal >= 3 && 
			WString::to_lower(start[0]) == L'p' &&
			WString::to_lower(start[1]) == L'a' &&
			WString::to_lower(start[2]) == L't' &&
			WString::to_lower(start[3]) == L'h' &&
			start[4] == L'=')
		{
			path.assign(start + equal + 2);
			break;
		}
	}
	int s = 0, e = 0;
	while(true)
	{
		e = path.find(L';', e + 1);
		if(e == -1)
			break;
		String currentPath = WStringToString(path.substr(s, e - s));
		searchPaths.push_back(currentPath);
		s = e + 1;
	}
#endif
	for(auto &i : searchPaths)
	{
		String path = File::combinePath(i, filename);
		SharedPtr<FormatBase> result = ::loadImport(path, architecture);
		if(!result)
		{
			if(path.substr(path.length() - 4).icompare(".dll") != 0)
			{
				path.append(".dll");
				result = ::loadImport(path, architecture);
			}
		}
		if(result.get())
			return result;
	}
	return SharedPtr<FormatBase>(nullptr);
}
예제 #25
0
const String CreatePropertyControl::GetPropName() const
{
    return WStringToString(nameField->GetText());
}
예제 #26
0
std::wstring ParseXORContents(std::wstring &TempLine)
{
	/*Check if the line has an XOR in it, accounts for multiple
	XORs on the same line*/
	std::size_t StartXOR = 0;
	std::size_t EndQuote = 0;
	std::size_t StartQuote = 0;
	std::size_t EndXOR = 0;
	int StartSearch = 0;
	bool NeedsEnd = false;

	int EraseFixup = 0;
	int InsertFixup = 0;
	std::wstring TotalLine = TempLine;

	if (TempLine.length() <= 0)
		return TempLine;

	//BS Loop SHOULD exit before this
	while (EndQuote<TempLine.length())
	{
		//Do We need beginning of XOR or End
		if (!NeedsEnd)
		{
			//Find Start of XOR Macro
			StartXOR = TempLine.find(L"XOR(", StartSearch);
			if (StartXOR == std::string::npos)
				return TotalLine;

			NeedsEnd = true;

			//Move to End of XOR( character Sequence
			StartXOR += 4;

			//Find Start quote after macro
			StartQuote = TempLine.find(L"\"", StartXOR);
			if (StartQuote == std::string::npos)
				return TempLine;

			StartQuote += 1; //Move to End of Quote
		} else
		{
			EndQuote = TempLine.find(L"\"", StartQuote);
			if (EndQuote == std::string::npos)
				return TempLine;

			bool FoundUnEscapedEnd = false;
			int EscapedFixup = 0;
			while (!FoundUnEscapedEnd)
			{
				if (TempLine.at(EndQuote - 1) != '\\' || (TempLine.at(EndQuote - 2) == '\\' && TempLine.at(EndQuote - 1) == '\\'))
					FoundUnEscapedEnd = true;
				else
				{
					EscapedFixup += 1;
					EndQuote = TempLine.find(L"\"", StartQuote + EscapedFixup);
					if (EndQuote == std::string::npos)
						return TempLine;
				}
			}

			NeedsEnd = false;

			//For Next Iteration ignore previous
			StartSearch = EndQuote;

			std::wstring XORContents = TempLine.substr(StartQuote, EndQuote - StartQuote);

			BOOL Success;
			std::wstring EncryptedSubString = StringToWString(blub(WStringToString(XORContents), Success));
			if (!Success)
				return TempLine;

			EndXOR = TempLine.find(L")", EndQuote);
			if (EndXOR == std::string::npos)
				return TempLine;

			//Move to end of ) and go back to beginning of XOR Macro
			EndXOR += 1;
			StartXOR -= 4;

			//Erase Raw text and replace with encrypted
			TotalLine.erase(StartXOR - EraseFixup + InsertFixup, EndXOR - StartXOR);
			TotalLine.insert(StartXOR - EraseFixup + InsertFixup, EncryptedSubString);

			//Next Time around we need to account for the changed length of the string
			InsertFixup += EncryptedSubString.length();
			EraseFixup += (EndXOR - StartXOR);
		}
	}
	return TempLine;
}
예제 #27
0
std::wstring ParseFile(std::wstring& str)
{
	std::string LowerWorkingDir = lower_string(WStringToString((std::wstring(WorkingDirectory))));

	bool InDirectory = str.find(StringToWString(LowerWorkingDir)) != std::string::npos;
	if (str.find(L"\\") == std::string::npos && str.find(L":") == std::string::npos || InDirectory && str.find(L"resource.h")==std::string::npos)
	{
		if (str.find(L".cpp") != std::string::npos || str.find(L".h") != std::string::npos)
		{
			std::wstring InputFileName;
			std::wstring OutputFileName;
			if (InDirectory)
			{
				/*If we are a file such as D:\\Path\\Project\\Main.cpp
				  We need to strip Main.cpp off the end, and append it to 
				  the temp directory*/
				InputFileName = str;
				size_t IndexOfSlash = str.find_last_of(L"\\");
				if (IndexOfSlash == std::string::npos)
					return str;

				std::wstring FileDirRemoved = str.substr(IndexOfSlash + 1, str.length() - IndexOfSlash + 1);
				str.erase(IndexOfSlash + 1, str.length() - IndexOfSlash + 1);

				std::wstringstream ssTempFile;
				ssTempFile << WorkingDirectory << L"\\Temp\\" << FileDirRemoved;
				OutputFileName = ssTempFile.str();
			} else{
				/*If we are a file such as main.cpp we need to append it to the
				temp directory, and build up the input directory based on our 
				working directory (the project folder)*/
				std::wstringstream ssInFile;
				ssInFile << WorkingDirectory << L"\\" << str;
				InputFileName = ssInFile.str();

				std::wstringstream ssTempFile;
				ssTempFile << WorkingDirectory << L"\\Temp\\" << str;
				OutputFileName = ssTempFile.str();
			}
			std::wifstream InputFile;
			std::wofstream OutputFile;
			SkipNextHook = true;
			InputFile.open(InputFileName.c_str());
			OutputFile.open(OutputFileName.c_str());
			if (InputFile.is_open())
			{
				while (!InputFile.eof())
				{
					//Read Input File, Replace with Xor Contents, Write to output
					wchar_t Buffer[2048];
					InputFile.getline(Buffer, 2048);
					OutputFile << ParseXORContents(std::wstring(Buffer)) << L"\n";
				}
			}
			InputFile.close();
			OutputFile.close();
			SkipNextHook = false;
			return OutputFileName;
		}
		return str;
	}
	return str;
}
예제 #28
0
				//输出背景图像
				//读入背景图像名称
				state = SRun;
				wstring bgName;
				comStream>>bgName;
				//设置背景
				bgManager.SetBackground(WStringToString(bgName));
				clock.Reset();
				curCom++;
			}
			else if(command == L"ChangeBackground")
			{
				state = SRun;
				wstring type,name;
				comStream>>type>>name;
				bgName = WStringToString(name);

				buttonManager.Show() = false;
				characterManager.ShowCharacter() = false;
				dialogueManager.ShowDialogue() = false;

				if(type == L"MoveY")
				{
					objectsManager.AddObject(bgName);
					animeManager.MoveY(bgManager.GetBackground(),0.0f,-static_cast<float>(initManager.height),1.0f);
					animeManager.MoveY(bgName,static_cast<float>(initManager.height),0.0f,1.0f);
					if(animeManager.GetAnime(bgManager.GetBackground()).State() == AFinished)
					{
						animeManager.ResetEffect(bgManager.GetBackground());
						animeManager.GetAnime(bgManager.GetBackground()).SetPositionAll(0.0f,0.0f);
						animeManager.ResetEffect(bgName);
예제 #29
0
void ScriptManager::Init(const string scriptName)
{
	wstringstream ss;
	//从脚本文件中读入,采用宽字节
	wifstream infile(scriptName);
	//设置Locale,保证中文读入
	//Windows
#ifdef WIN
	infile.imbue(locale(".936"));
#endif
	//Linux
#ifdef LINUX
	infile.imbue(locale("zh_CN.gbk"));
#endif
	//MAC
#ifdef MAC
	infile.imbue(locale("zh_CN.GBK"));
#endif
	if(!infile)
	{
		//如果找不到文件则显示错误
		throw runtime_error("Cannot open the script file: " + scriptName);
	}
	//临时存储命令
	wstring tempCom;
	while(!infile.eof())
	{
		//读入命令
		getline(infile,tempCom);
		size_t firstSpace = tempCom.find_first_of(L" ",0);
		ss.clear();
		ss.str(L"");
		ss<<tempCom;
		wstring com,vals;
		ss>>com;
		vals.assign(tempCom.begin()+firstSpace+1,tempCom.end());
		//不记录注释
		if(com != L"#")
			coms.push_back(make_pair<wstring,wstring>(com,vals));
	}
	//关闭脚本文件
	infile.close();
	infile.clear();
	//记录所有跳转的位置

	bool bFirst = true;
	vector<pair<wstring,wstring>>::iterator it=coms.begin();
	while(it!=coms.end())
	{	
		//存储第一张背景
		if(bFirst && it->first == L"SetBackground")
		{
			gameFirst = WStringToString(it->second);
			bgName = gameFirst;
			bFirst = false;
		}

		//如果是跳转标记
		if(it->first == L"@")
		{
			if(markIters.count(it->second))
				throw runtime_error("Jump mark duplicated:"+WStringToString(it->second));
			markIters[it->second] = it;	
			coms.erase(it);
		}
		it++;
	}
	//将当前命令迭代器设于开头
	curCom = coms.begin();
}
예제 #30
0
// Recurse through all properties and child properties, outputting their names
//  to the file.
// This function is slow and takes a while to output all the nodes, so it can be
//  called with a sub-node initial argument if you only care about a small part of the
//  COM data structure tree.
// Adapted from DXSDK example file DxDiagOutput.cpp
// pOpenTextFile   Must be a file opened for writing text
// Call this with NULL 2nd and 3rd args to start from the top of the node structure.
HRESULT DXDiagNVUtil::ListAllDXDiagPropertyNamesToTxtFile(	FILE * pOpenTextFile,
															bool bGetPropertyValues,
															IDxDiagContainer * pDxDiagContainer,
															WCHAR * wszParentName )
{
	HRESULT hr = S_OK;
	FAIL_IF_NULL( pOpenTextFile );
	if( pDxDiagContainer == NULL )
		pDxDiagContainer = m_pDxDiagRoot;
	FAIL_IF_NULL( pDxDiagContainer );

    DWORD dwPropCount;
    DWORD dwPropIndex;
    WCHAR wszPropName[256];
    DWORD dwChildCount;
    DWORD dwChildIndex;
    WCHAR wszChildName[256];
    IDxDiagContainer* pChildContainer = NULL;
	string strParentName, strPropName, strPropVal;
	wstring wstrParentName, wstrPropName;

    hr = pDxDiagContainer->GetNumberOfProps( &dwPropCount );
    if( SUCCEEDED(hr) ) 
    {
		if( wszParentName != NULL )
			wstrParentName = wszParentName;
		else
			wstrParentName = L"";
		strParentName = WStringToString( wstrParentName );

        // Print each property in this container
        for( dwPropIndex = 0; dwPropIndex < dwPropCount; dwPropIndex++ )
        {
            hr = pDxDiagContainer->EnumPropNames( dwPropIndex, wszPropName, 256 );
			if( wszPropName != NULL )
				wstrPropName = wszPropName;
			else
				wstrPropName = L"";
			strPropName = WStringToString( wstrPropName );

			if( SUCCEEDED( hr ) )
			{
				if( bGetPropertyValues )
				{
					wstring wstrPropVal;
					hr = GetProperty( pDxDiagContainer, wszPropName, & wstrPropVal );
					strPropVal = WStringToString( wstrPropVal );

					fprintf( pOpenTextFile, "%35s : prop \"%s\" = %s\n", strParentName.c_str(), strPropName.c_str(), strPropVal.c_str() );
				}
				else
				{
					// otherwise, just list the property name and parent container info
					fprintf( pOpenTextFile, "%35s : prop \"%s\"\n", strParentName.c_str(), strPropName.c_str() );
				}
			}
        }
    }

    // Recursivly call this function for each of its child containers
    hr = pDxDiagContainer->GetNumberOfChildContainers( &dwChildCount );
    if( SUCCEEDED(hr) )
    {
        for( dwChildIndex = 0; dwChildIndex < dwChildCount; dwChildIndex++ )
        {
            hr = pDxDiagContainer->EnumChildContainerNames( dwChildIndex, wszChildName, 256 );
            if( SUCCEEDED(hr) )
            {
                hr = pDxDiagContainer->GetChildContainer( wszChildName, &pChildContainer );
                if( SUCCEEDED(hr) )
                {
                    // wszFullChildName isn't needed but is used for text output 
                    WCHAR wszFullChildName[256];

					// Append child name to parent and pass down in the recursion
					//  as full parent name.
                    if( wszParentName )
                        swprintf( wszFullChildName, L"%s.%s", wszParentName, wszChildName );
                    else
                        swprintf( wszFullChildName, L"%s", wszChildName );

					// recurse
                    ListAllDXDiagPropertyNamesToTxtFile( pOpenTextFile, bGetPropertyValues,
														 pChildContainer, wszFullChildName );
                    SAFE_RELEASE( pChildContainer );
                }
            }
        }
    }
	return( hr );
}