Ejemplo n.º 1
0
Bottle SpeechRecognizerModule::toBottle(SPPHRASE* pPhrase, const SPPHRASERULE* pRule)
{
    Bottle bCurrentLevelGlobal;

    const SPPHRASERULE* siblingRule = pRule;
    while (siblingRule != NULL)
    {   
        Bottle bCurrentSubLevel;
        bCurrentSubLevel.addString(ws2s(siblingRule->pszName));

        //we backtrack
        if(siblingRule->pFirstChild != NULL )
        {
            bCurrentSubLevel.addList()=toBottle(pPhrase, siblingRule->pFirstChild);
        }
        else
        {
            string nodeString = "";
            for(unsigned int i=0; i<siblingRule->ulCountOfElements; i++)
            {
                nodeString += ws2s(pPhrase->pElements[siblingRule->ulFirstElement + i].pszDisplayText);
                if (i<siblingRule->ulCountOfElements-1)
                    nodeString += " ";
            }
            bCurrentSubLevel.addString(nodeString);
        }
        siblingRule = siblingRule->pNextSibling;
        if (pRule->pNextSibling !=NULL)
            bCurrentLevelGlobal.addList() = bCurrentSubLevel;
        else
            bCurrentLevelGlobal = bCurrentSubLevel;

    }
    return bCurrentLevelGlobal;
}
Ejemplo n.º 2
0
void TransfersDialog::OnbtnAddTransferClick(wxCommandEvent& event)
{
    wxString wxstrId = TextCtrl1->GetValue();       // c
    wxString wxstrDescr = TextCtrl2->GetValue();    // consumption
    //string strId = string(TextCtrl2->GetValue().mb_str(wxConvISO8859_1));
    //string strDescr = string(TextCtrl1->GetValue().mb_str(wxConvISO8859_1));
    wxString wxstrFrom = ddFrom->GetString(ddFrom->GetCurrentSelection());
    wxStringTokenizer tok1(wxstrFrom, _("\t"));
    wxString wxstrFromShort = tok1.GetNextToken();
    wxString wxstrFromLong = tok1.GetNextToken();

    wxString wxstrTo = ddTo->GetString(ddTo->GetCurrentSelection());
    wxStringTokenizer tok2(wxstrTo, _("\t"));
    wxString wxstrToShort = tok2.GetNextToken();
    wxString wxstrToLong= tok2.GetNextToken();
    //wxString wxstrTo = ddTo->GetData(ddTo->GetCurrentSelection());

    string strVar = ws2s(wxstrId);
    string strDescr = ws2s(wxstrDescr);
    string strFrom = ws2s(wxstrFromShort);
    string strTo = ws2s(wxstrToShort);

    // USE CREATETRANSFER FUNCTION AND REMOVE CALL ON GETTRANSFERS

    createTransfer(wxstrToShort, wxstrFromShort, wxstrId, wxstrDescr);

    // Expression::makeToken(strVar); // moved to Transfer::create(...)

    populateList();
    TextCtrl1->Clear();
    TextCtrl2->Clear();
    TextCtrl1->SetFocus();
}
Ejemplo n.º 3
0
std::vector<std::string>* DataInDirectoryInvestigator::SearchFiles(std::string fileType){
	this->fileType = fileType;

	std::string searchQuery = dirPath;
	searchQuery.append(fileType);
	
	std::wstring stemp = s2ws(searchQuery);
	LPCWSTR DIRPATH = stemp.c_str();
	
	std::cout << "Searching Files in " << dirPath << std::endl;
	std::vector<std::string> * acquiredFilePaths = new std::vector<std::string>();

	HANDLE hFind;
	WIN32_FIND_DATA w32fd;
	hFind = FindFirstFile(DIRPATH, &w32fd);
	if( hFind != INVALID_HANDLE_VALUE){
		do {
			//std::cout << "cAlternateFileName : " << ws2s(w32fd.cAlternateFileName) << std::endl;
			//printf("ファイル名:%S\n", w32fd.cFileName);
			std::cout << "ファイル名: " << ws2s(w32fd.cFileName) << std::endl;
			acquiredFilePaths->push_back(ws2s(w32fd.cFileName));
		} while (FindNextFile (hFind, &w32fd));
		FindClose(hFind);
	}
	return acquiredFilePaths;
}
Ejemplo n.º 4
0
Transfer *TransfersDialog::createTransfer(wxString &to, wxString &from, wxString &name, wxString &descr)
{
    string strVar = ws2s(name);
    string strDescr = ws2s(descr);
    string strFrom = ws2s(from);
    string strTo = ws2s(to);

    return Transfer::create(strTo, strFrom, strVar, strDescr);
}
Ejemplo n.º 5
0
int WINAPI wWinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPWSTR lpCmdLine, int /* nCmdShow */)
{
	LPWSTR* arg_list;
	int arg_num = 0;

    // Ignore the return value because we want to continue running even in the
    // unlikely event that HeapSetInformation fails.
    HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);

    if (SUCCEEDED(CoInitialize(NULL)))
    {
		App *app = new App();
		arg_list = CommandLineToArgvW(lpCmdLine, &arg_num);
		if (arg_num == 2)
		{
			CardData data;
			strcpy_s(data.username, ws2s(arg_list[0]).c_str());
			strcpy_s(data.password, ws2s(arg_list[1]).c_str());

			try
			{
				NFC_READER->Initialize();
				NFC_READER->Write(data);
				NFC_READER->Uninitialize();
			}
			catch (...)
			{
				MessageBox(NULL, L"שגיאה התרחשה בכתיבה לכרטיס או שלא נמצא כרטיס...", L"שים/י לב!", STDMSGBOX | MB_ICONWARNING);
				return 1;
			}
			return 0;
		}
        if (SUCCEEDED(app->Initialize()))
        {
			app->ChangeScreenTo(App::Screens::WaitingToCardScreen);
			MSG msg;
			memset(&msg, 0, sizeof(msg));
			while (app->AppMode != -1)
			{
				if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
				{
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}

				app->Update();
				app->Render();
			}
        }
		delete app;
        CoUninitialize();
    }
	
    return 0;
}
Ejemplo n.º 6
0
void CDlgController::OpenFile(const std::wstring& wstrFilename)
{
	if (IOReadBase::Exists(ws2s(wstrFilename)))
	{
		OpenPath(GetParentPath(wstrFilename),s2ws(CRenderNodeMgr::getInstance().getDataPlugsMgr().getAllExtensions()));
		//m_ListBoxFolder.SetSelec()
		//GetFilename(wstrFilename)
		CMainRoot::getInstance().getMainDialog().getModelDisplay().LoadModel(ws2s(wstrFilename));
		CMainRoot::getInstance().getMainDialog().getDlgModelController().OnUpdate();
	}
}
Ejemplo n.º 7
0
bool ZipResourceDepot::RegisterPackages(std::wstring basePackagePath)
{
	HANDLE fileHandle;
	WIN32_FIND_DATA findData;

	//Get first file
	std::wstring pathSpec = basePackagePath + L"*";
	fileHandle = FindFirstFile(pathSpec.c_str(), &findData);
	if (fileHandle != INVALID_HANDLE_VALUE)
	{
		//Loop on all remaining entries
		while (FindNextFile(fileHandle, &findData))
		{
			//Skip if file is hidden
			if (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
			{
				continue;
			}

			//Do not currently support packages within directories, so throw Warning
			if (findData.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)
			{
				//Do not warn for directory symbol
				if (findData.cFileName != s2ws(".."))
				{
					BE_WARNING("Packages within Directories are ignored");
				}
			}
			else
			{
				std::wstring filename = findData.cFileName;
				std::wstring lowerPackageName = filename;

				std::transform(lowerPackageName.begin(), lowerPackageName.end(), lowerPackageName.begin(), (int(*)(int))std::tolower);
				lowerPackageName = lowerPackageName.substr(0, lowerPackageName.find_last_of('.'));

				pathSpec = pathSpec.substr(0, pathSpec.find_last_of('/'));
				pathSpec = pathSpec + s2ws("/") + filename;

				//Add Package to mapping
				m_packageMap[ws2s(lowerPackageName)] = PackageMappingDetails(m_numPackages, ws2s(pathSpec));
				m_numPackages++;
			}
		}
	}

	FindClose(fileHandle);


	return true;
}
Ejemplo n.º 8
0
 void BasicError<wchar_t>::setMsg()
 {
     std::string s = _(errMsg(code_));
     std::wstring wmsg(s.begin(), s.end());
     std::wstring::size_type pos;
     pos = wmsg.find(L"%0");
     if (pos != std::wstring::npos) {
         wmsg.replace(pos, 2, toBasicString<wchar_t>(code_));
     }
     if (count_ > 0) {
         pos = wmsg.find(L"%1");
         if (pos != std::wstring::npos) {
             wmsg.replace(pos, 2, arg1_);
         }
     }
     if (count_ > 1) {
         pos = wmsg.find(L"%2");
         if (pos != std::wstring::npos) {
             wmsg.replace(pos, 2, arg2_);
         }
     }
     if (count_ > 2) {
         pos = wmsg.find(L"%3");
         if (pos != std::wstring::npos) {
             wmsg.replace(pos, 2, arg3_);
         }
     }
     wmsg_ = wmsg;
     msg_ = ws2s(wmsg);
 }
Ejemplo n.º 9
0
void CProSetCameraTab::OnCbnSelchangeComboSoure()
{
	CString name;
	m_ComboSource.GetLBText(m_ComboSource.GetCurSel(),name);
	wstring wname = name;
	m_pConfigCenter->SetCameraName(ws2s(wname));
}
Ejemplo n.º 10
0
void OIBReader::ReadStream(POLE::Storage &pStg, wstring &stream_name)
{
	POLE::Stream pStm(&pStg,ws2s(stream_name));
	unsigned char *pbyData = 0;

	//open
	if (!pStm.eof() && !pStm.fail())
	{
		//get stream size
		size_t sz = pStm.size();
		//allocate 
		pbyData = new unsigned char[sz];
		if (!pbyData) return;
		//read
		if (pStm.read(pbyData,sz)) {
			//read oib info
			if (stream_name == wstring(L"OibInfo.txt")) {
				ReadOibInfo(pbyData, sz);
			} else {
				if (m_type==0 || (m_type==1 && m_oib_t==0))
					ReadOif(pbyData, sz);
			}
		}
	}

	//release
	if (pbyData)
		delete[] pbyData;
}
Ejemplo n.º 11
0
void CUpdateMgr::RestoreFile(wstring strRestorePath,wstring wsCurDirectory)
{
	CFileFind fileFinder;
	CString filePath ;//= strRestorePath.c_str() + _T("//*.*");
	filePath.Format(_T("%s\\*.*"),strRestorePath.c_str());
	BOOL bFinished = fileFinder.FindFile(filePath);
	wstring wsDestfile;
	wstring wsRestoreFile;
	while(bFinished)  //每次循环对应一个类别目录
	{
		bFinished = fileFinder.FindNextFile();
		if(fileFinder.IsDirectory() && !fileFinder.IsDots())  //若是目录则递归调用此方法
		{
			// BayesCategoryTest(bt, fileFinder.GetFilePath());
		}
		else  //再判断是否为txt文件
		{
			//获取文件类型
			CString fileName = fileFinder.GetFileName();
			if(fileName.Right(4).CompareNoCase(_T("_BAK")) == 0)
			{
				wsRestoreFile = strRestorePath + L"\\" + fileName.GetBuffer(0);
				wsDestfile = wsCurDirectory + L"\\" + fileName.Left(fileName.GetLength()-4).GetBuffer(0);
				BOOL bret = CsysFile::Copy(wsRestoreFile,wsDestfile);
				if (FALSE == bret)
				{
					g_Logger.Error(__FILE__,__LINE__,"还原文件失败 restore %s to %s",ws2s(wsRestoreFile).c_str(),ws2s(wsDestfile).c_str());
				}
			}
		}
	}
}
//----------------------------------------------------------------
void CPUTConfigEntry::ValueAsFloatArray(float *pFloats, int count)
{
//    char *szOrigValue = new char [szValue.length()+1];
//FIXME memory leak here
	char *pString = ws2s(szValue.c_str());
    //strcpy(szOrigValue, pString);

	char *szNewValue = NULL;
    char *szCurrValue = strtok_r(pString, " ", &szNewValue);
    for(int clear = 0; clear < count; clear++)
    {
        pFloats[clear] = 0.0f;
    }
    for(int ii=0;ii<count;++ii)
    {
        if(szCurrValue == NULL)
        {
			delete pString;
            return;
        }
        pFloats[ii] = (float) atof(szCurrValue);
        szCurrValue = strtok_r(NULL, " ", &szNewValue);

    }
    
    //delete szOrigValue;
	delete[] pString;
}
Ejemplo n.º 13
0
string ProcessList::getNameByProcessId(DWORD pid) {
	for (map<DWORD, wstring>::iterator it = cachedProcessList.begin(); it != cachedProcessList.end(); it++) {
		if (it->first == pid) {
			return ws2s(it->second).c_str();
		}
	}
	return "";
}
Ejemplo n.º 14
0
void CDlgUIList::OnDlgListBoxDblClk()
{
	if (m_ListBox.GetSelectedItem())
	{
		std::string strEditUIFilename = IniGetStr("UIEditorUI.cfg","UIConfig","edit");
		createDialogCodeFromXML(strEditUIFilename,ws2s(m_ListBox.GetSelectedItem()->wstrText));
	}
}
Ejemplo n.º 15
0
// buffer pointed to by pOut must be large enough for data
bool CommandParser::GetParameter(cString arg, char *pOut)
{
	std::map<cString, cString>::iterator it;
	std::stringstream ss;

	it = m_ArgumentMap.find(arg);
	if (it == m_ArgumentMap.end())
		return false;

#ifdef 	CPUT_OS_ANDROID
    ss << ws2s(it->second.c_str());
#else
    ss << ws2s(it->second);
#endif
	ss >> pOut;

	return true;
}
Ejemplo n.º 16
0
Bottle SpeechRecognizerModule::waitNextRecognition(int timeout)
{
    yInfo() <<"Recognition: blocking mode on" ;
    Bottle bOutGrammar;

    bool gotSomething = false;
    double endTime = Time::now() + timeout/1000.0;
    interruptRecognition = false;

    cout << endl ;
    yInfo() << "=========== GO Waiting for recog! ===========" ;

    while(Time::now()<endTime && !gotSomething && !interruptRecognition)
    {
        //std::cout<<".";
        const float ConfidenceThreshold = 0.3f;
        SPEVENT curEvent;
        ULONG fetched = 0;
        HRESULT hr = S_OK;

        m_cpRecoCtxt->GetEvents(1, &curEvent, &fetched);

        while (fetched > 0)
        {                   
            yInfo() << " received something in waitNextRecognition" ;
            gotSomething = true;            
            ISpRecoResult* result = reinterpret_cast<ISpRecoResult*>(curEvent.lParam);
            CSpDynamicString dstrText;
            result->GetText(SP_GETWHOLEPHRASE, SP_GETWHOLEPHRASE, TRUE, &dstrText, NULL);
            string fullSentence = ws2s(dstrText);
            yInfo() <<fullSentence ;
            if (m_useTalkBack)
                say(fullSentence);
            bOutGrammar.addString(fullSentence);

            SPPHRASE* pPhrase = NULL;
            result->GetPhrase(&pPhrase);    
            bOutGrammar.addList() = toBottle(pPhrase,&pPhrase->Rule);
            yInfo() <<"Sending semantic bottle : "<<bOutGrammar.toString() ;
            m_cpRecoCtxt->GetEvents(1, &curEvent, &fetched);

			if (m_forwardSound)
			{
				yarp::sig::Sound& rawSnd = m_portSound.prepare();
				rawSnd = toSound(result);
				m_portSound.write();
			}

        }
    }

    if(interruptRecognition) {
        yDebug() << "interrupted speech recognizer!";
    }
    yInfo() <<"Recognition: blocking mode off";
    return bOutGrammar;
}
Ejemplo n.º 17
0
    std::string FileIo::path() const
    {
#ifdef EXV_UNICODE_PATH
        if (p_->wpMode_ == Impl::wpUnicode) {
            return ws2s(p_->wpath_);
        }
#endif
        return p_->path_;
    }
Ejemplo n.º 18
0
//-----------------------------------------------------------------------------
void ReadMacrosFromConfigBlock(
    CPUTConfigBlock   *pMacrosBlock,
    CPUT_SHADER_MACRO  *pShaderMacros,
    CPUT_SHADER_MACRO **pUserSpecifiedMacros,
    int               *pNumUserSpecifiedMacros,
    CPUT_SHADER_MACRO **pFinalShaderMacros
    ){
        *pNumUserSpecifiedMacros = pMacrosBlock->ValueCount();

        // Count the number of macros passed in
        CPUT_SHADER_MACRO *pMacro = (CPUT_SHADER_MACRO*)pShaderMacros;
        int numPassedInMacros = 0;
        if( pMacro )
        {
            while( pMacro->Name )
            {
                ++numPassedInMacros;
                ++pMacro;
            }
        }

        // Allocate an array of macro pointer large enough to contain the passed-in macros plus those specified in the .mtl file.
        *pFinalShaderMacros = new CPUT_SHADER_MACRO[*pNumUserSpecifiedMacros + numPassedInMacros + 1];

        // Copy the passed-in macro pointers to the final array
        int jj;
        for( jj=0; jj<numPassedInMacros; jj++ )
        {
            (*pFinalShaderMacros)[jj] = *(CPUT_SHADER_MACRO*)&pShaderMacros[jj];
        }

        // Create a CPUT_SHADER_MACRO for each of the macros specified in the .mtl file.
        // And, add their pointers to the final array
        *pUserSpecifiedMacros = new CPUT_SHADER_MACRO[*pNumUserSpecifiedMacros];
        for( int kk=0; kk<*pNumUserSpecifiedMacros; kk++, jj++ )
        {
            CPUTConfigEntry *pValue   = pMacrosBlock->GetValue(kk);
            (*pUserSpecifiedMacros)[kk].Name       = ws2s(pValue->NameAsString());
            (*pUserSpecifiedMacros)[kk].Definition = ws2s(pValue->ValueAsString());
            (*pFinalShaderMacros)[jj] = (*pUserSpecifiedMacros)[kk];
        }
        (*pFinalShaderMacros)[jj].Name = NULL;
        (*pFinalShaderMacros)[jj].Definition = NULL;
}
Ejemplo n.º 19
0
vector<string> &RunDialog::getCheckedItems()
{
    int nItems = CheckListBox1->GetCount();
    for (int i = 0; i < nItems; i++) {
        if (CheckListBox1->IsChecked(i)) {
            checkedItems.push_back(ws2s(CheckListBox1->GetString(i)));
        }
    }
    return checkedItems;
}
Ejemplo n.º 20
0
//Create the folder that this resource ID's file will be placed in
void makeFolder(u32 resId)
{
    wstring sFilename = getName(resId);
    size_t pos = sFilename.find_last_of(L'/');
    if(pos != wstring::npos)
        sFilename = sFilename.substr(0,pos);
    sFilename = TEXT("./") + sFilename;
    //cout << "Creating folder " << ws2s(sFilename) << endl;
    ttvfs::CreateDirRec(ws2s(sFilename).c_str());
}
Ejemplo n.º 21
0
std::string DevelopmentResourceZipFile::VGetResourceName(int num) const 
{
	if (m_mode == Editor)
	{
		std::wstring wideName = m_AssetFileInfo[num].cFileName;
		return ws2s(wideName);
	}

	return ResourceZipFile::VGetResourceName(num);
}
std::string DevelopmentResourceZipFile::GetResourceName(int n) const
{
	if (m_Mode == Mode::Editor)
	{
		std::wstring wideName = m_AssetFileInfo[n].cFileName;
		return ws2s(wideName);
	}

	return ResourceZipFile::GetResourceName(n);
}
Ejemplo n.º 23
0
std::string variant::ValueAsString() {
  if (v_.vt != VT_BSTR) {
    variant v = *this;

    v.ChangeType(VT_BSTR);
    return v.ValueAsString();
  }

  return ws2s(v_.bstrVal);
}
Ejemplo n.º 24
0
//
// ModifyActor							- Chapter 22, page 762
//
void ModifyActor ( BSTR bstrActorModificationXML )
{
	std::string actorModificationXML = ws2s(std::wstring(bstrActorModificationXML, SysStringLen(bstrActorModificationXML))); 

	TiXmlDocument doc;
	doc.Parse(actorModificationXML.c_str());
    TiXmlElement* pRoot = doc.RootElement();
    if (!pRoot)
        return;

	g_pApp->m_pGame->VModifyActor(atoi(pRoot->Attribute("id")), pRoot);
}
Ejemplo n.º 25
0
void CMainTestView::OnSetting()
{
	// TODO: 在此添加命令处理程序代码
	/*m_pModalSettingPropSheet = new CModalSettingPropSheet;
	if (m_pModalSettingPropSheet->DoModal() == IDOK)
	{
		GetDocument()->SetModifiedFlag();
		GetDocument()->UpdateAllViews(NULL);
	}
	delete m_pModalSettingPropSheet;
	m_pModalSettingPropSheet = NULL;*/
	// If mini frame does not already exist, create a new one.
	// Otherwise, unhide it
	CChangeMode dlLogin;
	dlLogin.DoModal();

	wstring Gruop= CMI_DataConfig::GetDataConfig().GetUserGroupName();

	if ((_stricmp("ADMINISTRATOR",ws2s(Gruop).c_str())))
	{
		AfxMessageBox(_T("请输入管理员帐号进行用户管理"));

		return;
	}
	

	if (m_pSettingPropFrame == NULL)
	{
		m_pSettingPropFrame = new CSettingPropSheetFrame;
		CRect rect(0, 0, 0, 0);
		CString strTitle;
		strTitle.LoadString(IDS_OBJECT_PROPERTIES);
		if (!m_pSettingPropFrame->Create(NULL, strTitle,
			WS_POPUP | WS_CAPTION | WS_SYSMENU, rect, this))
		{
			m_pSettingPropFrame = NULL;
			return;
		}
		m_pSettingPropFrame->CenterWindow();
	}
	// Before unhiding the modeless property sheet, update its
	// settings to reflect the currently selected shape.
	/*CShapesView* pView =
		STATIC_DOWNCAST(CShapesView, MDIGetActive()->GetActiveView());
	ASSERT_VALID(pView);
	if (pView->m_pShapeSelected != NULL)
	{
	   m_pShapePropFrame->m_pModelessShapePropSheet->
		   SetSheetPropsFromShape(pView->m_pShapeSelected);
	}*/
	if (m_pSettingPropFrame != NULL && !m_pSettingPropFrame->IsWindowVisible())
		m_pSettingPropFrame->ShowWindow(SW_SHOW);
}
Ejemplo n.º 26
0
//
// CreateActor							- Chapter 22, page 761
//
int CreateActor( BSTR bstrActorXMLFile )
{
	std::string actorResource = ws2s(std::wstring(bstrActorXMLFile, SysStringLen(bstrActorXMLFile))); 
	StrongActorPtr pActor = g_pApp->m_pGame->VCreateActor(actorResource, NULL);
	if (!pActor)
		return INVALID_ACTOR_ID;

	// fire an event letting everyone else know that we created a new actor
	shared_ptr<EvtData_New_Actor> pNewActorEvent(GCC_NEW EvtData_New_Actor(pActor->GetId()));
	IEventManager::Get()->VQueueEvent(pNewActorEvent);
	return pActor->GetId();
}
Ejemplo n.º 27
0
BOOL CNtMagickView::DoReadImage()

{

  // Release image object memory

  m_Image.isValid(FALSE);



  // Read the image and handle any exceptions

  try

  {

    m_Image.read(ws2s(m_szFile.GetBuffer(MAX_PATH+1)));

  }



  catch(Exception e)

  {

    m_Image.isValid(FALSE);

    DoDisplayError("Read",e.what());

    return FALSE;

  }



  catch(exception e)

  {

    m_Image.isValid(FALSE);

    DoDisplayError("Read",e.what());

    return FALSE;

  }



  return TRUE;

}
Ejemplo n.º 28
0
//
// OpenLevel							- Chapter 22, page 756
//
//   FUTURE WORK: This should return a bool specifying if the level was successfully opened.
//
void OpenLevel( BSTR fullPathLevelFile )
{
	// We need to strip off the project directory from the filename first.
	std::string levelFile = ws2s(std::wstring(fullPathLevelFile, SysStringLen(fullPathLevelFile))); 
	EditorLogic* pEditorLogic = (EditorLogic*)g_pApp->m_pGame;
	if (pEditorLogic)
	{
		std::string assetsDir = "\\Assets\\";
		int projDirLength = pEditorLogic->GetProjectDirectory().length() + assetsDir.length();
		g_pApp->m_Options.m_Level = levelFile.substr(projDirLength, levelFile.length()-projDirLength);
		pEditorLogic->VChangeState(BGS_LoadingGameEnvironment);
	}
}
void DevelopmentPackageResource::ReadPackageDirectory(std::wstring fileSpec)
{
	HANDLE fileHandle;
	WIN32_FIND_DATA findData;

	std::wstring pathSpec = m_basePackagePath + fileSpec;
	fileHandle = FindFirstFile(pathSpec.c_str(), &findData);

	if (fileHandle != INVALID_HANDLE_VALUE)
	{
		while (FindNextFile(fileHandle, &findData))
		{
			if (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
			{
				continue;
			}

			std::wstring fileName = findData.cFileName;
			if (findData.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)
			{
				if (fileName != L".." && fileName != L".")
				{
					fileName = fileSpec.substr(0, fileSpec.length() - 1) + fileName + L"\\*";
					ReadPackageDirectory(fileName);
				}
			}
			else
			{
				fileName = fileSpec.substr(0, fileSpec.length() - 1) + fileName;

				std::wstring lower = fileName;
				std::transform(lower.begin(), lower.end(), lower.begin(), (int(*)(int))std::tolower);

				//Replace all slashes to dots
				std::wstring resourceName = lower;
				std::replace(resourceName.begin(), resourceName.end(), '\\', '.');
				std::replace(resourceName.begin(), resourceName.end(), '/', '.');

				//Add the packagename to start of the name
				resourceName = s2ws(m_packageName + ".") + resourceName;

				wcscpy_s(&findData.cFileName[0], MAX_PATH, lower.c_str());
				AssetFileInfo fileInfo = { findData, resourceName };
				m_contentsMap[ws2s(resourceName)] = m_assetsFileInfo.size();
				m_assetsFileInfo.push_back(fileInfo);
			}
		}
	}

	FindClose(fileHandle);
}
Ejemplo n.º 30
0
void CDlgUIList::OnDlgListBoxSelection()
{
	static CEditingDialog* s_pDialog = NULL;
	if (s_pDialog)
	{
		S_DEL(s_pDialog);
	}
	if (m_ListBox.GetSelectedItem())
	{
		s_pDialog = new CEditingDialog;
		s_pDialog->Create(ws2s(m_ListBox.GetSelectedItem()->wstrText), m_pDlgView);
		s_pDialog->OnSize(m_pDlgView->GetBoundingBox());
	}
}