Ejemplo n.º 1
0
void FormTagManager::LoadTags(void)
{
	::PrintLog(L"FormTagManager.LoadTags.");
	_ASSERT_EXPR(NULL!=_hListTags,"_hListTags could not be NULL.");

	ListView_DeleteAllItems(_hListTags);

	auto &_tagHelper = *_handler->pTagHelper;

	// reload tags.
	_tagHelper.LoadTags(true);

	if ( _tagHelper.TagCount > 0 )
	{
		LVITEM item = {0};
		for (unsigned int i = 0; i < _tagHelper.TagCount; i++)
		{
			item.pszText = LPSTR_TEXTCALLBACK;
			item.mask = LVIF_TEXT | LVIF_IMAGE|LVIF_STATE;
			item.iItem = i;	//Zero-based index of the item to which this structure refers.
			item.stateMask = 0;
			item.iSubItem  = 0;
			item.state     = 0;
			item.iImage = I_IMAGECALLBACK;			
			ListView_InsertItem(_hListTags,&item);
		}
	}
}
Ejemplo n.º 2
0
void FormTagManager::AddTag(void)
{
	::PrintLog(L"FormTagManager.AddTag.");
	_ASSERT_EXPR(NULL!=_hEditCtlNewTag,"_hEditCtlNewTag could not be NULL.");

	wchar_t tmp[MAXLENGTH_EACHTAG];
	LPWSTR key = tmp;
	UINT keyLength;
	BOOL x = IsNewTagOk(key,keyLength);

	if( TRUE == x)
	{
		::PrintLog(L"Got new tag =[ %s ], adding to database.", key);
		BOOL isAttchWithFilesChecked = Button_GetCheck(_hCheckAttachToFiles) == BST_CHECKED;
		UINT TID = 0;
		TID = _handler->pTagHelper->InsertTag(key); // not need to reload tags here, as they will be reloaded after be associated with files.
		if( TID > 0 && TID != DB_RECORD_NOT_EXIST )
		{
			if( isAttchWithFilesChecked )
			{
				_handler->pTagHelper->AsynSetTagByRecordId(_hwnd,TID);
			}

			ShowMsg(L"Ìí¼Ó³É¹¦",COLOR_MY_OK);
		}
		else
		{
			// TODO: move the magic string to resource file.
			ShowMsg(L"Ìí¼Óʧ°Ü",COLOR_MY_ERROR);
		}
	}else{
		::PrintLog(L"Got new tag =[ %s ], but it is not available.", key);
		ShowMsg(::MyLoadString(IDS_MSG_TAG_UNAVAILABLE),COLOR_MY_ERROR);
	}
}
Ejemplo n.º 3
0
        STDMETHODIMP ArchiveExtractCallback::SetOperationResult(Int32 operationResult)
        {
            if (m_overwriteMode == OverwriteMode::kRollBack && operationResult != S_OK)
            {
                _ASSERT_EXPR(FALSE,L"begin rollback");
                bool succ = ProcessRollBack(); succ;
                _ASSERT_EXPR(succ, L"rollback error!");
                return E_FAIL;
            }
            

            if (m_absPath.empty())
            {
                wprintf_s(L"AllDone\n");
                if (m_callback)
                    m_callback->OnEnd(m_directory);
                return S_OK;
            }

            if (m_hasModifiedTime || m_hasAccessedTime || m_hasCreatedTime)
            {
                HANDLE fileHandle = CreateFile(m_absPath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
                if (fileHandle != INVALID_HANDLE_VALUE)
                {
                    SetFileTime(fileHandle,
                        m_hasCreatedTime ? &m_createdTime : NULL,
                        m_hasAccessedTime ? &m_accessedTime : NULL,
                        m_hasModifiedTime ? &m_modifiedTime : NULL);
                    CloseHandle(fileHandle);
                }
            }

            if (m_hasAttrib)
            {
                SetFileAttributes(m_absPath.c_str(), m_attrib);
            }

            wprintf_s(L"FileDone:%s\n", m_absPath.c_str());
            if (m_callback)
            {
                if(!m_callback->OnFileDone(m_absPath, m_newFileSize))
                    return E_FAIL;
                m_callback->OnProgress(m_absPath, m_newFileSize);
            }
            return S_OK;
        }
Ejemplo n.º 4
0
BOOL FormTagManager::IsNewTagOk(_Out_ wchar_t* key,_Out_  UINT & keyLength)
{
	_ASSERT_EXPR(NULL!=key,"key could not be NULL");
	_ASSERT_EXPR(NULL!=_hEditCtlNewTag,"_hEditCtlNewTag could not be NULL.");

	BOOL result = FALSE;
	int nMaxCount = MAXLENGTH_EACHTAG;
	keyLength = GetWindowText(_hEditCtlNewTag,key,nMaxCount);
	if( keyLength > 0 )
	{
		LPCWSTR tmp = key;
		auto &_tagHelper = *_handler->pTagHelper;
		result = !_tagHelper.IsTagExists(tmp);
	}

	return result;
}
Ejemplo n.º 5
0
void FormTagManager::InitFileList()
{
	_ASSERT_EXPR(NULL!=_hListFiles,"_hListFiles could not be NULL.");

	ListView_SetImageList(_hListFiles,_sysImgList,LVSIL_SMALL);

	UINT cIdx = 0;
	LVCOLUMN c = {0};
	c.pszText = ::MyLoadString(IDS_DLG_TAGMANAGER_LV_FILES_HEADER_SELECTEDITEMS);
	c.mask = LVCF_TEXT | LVCF_MINWIDTH | LVCF_WIDTH;
	c.cxMin = 100;
	c.cx = 600;
	ListView_InsertColumn(_hListFiles,cIdx++,&c);

	LoadSelectedFiles();
}
Ejemplo n.º 6
0
bool CNBTReader::read( boost::filesystem::path fullPath )
{
	boost::filesystem::ifstream inputStream;
	InputStream decompStream;

	std::cout << "Reading level.dat" << std::endl;

	// Open a stream and decompress
	try
	{
		// Make sure it exists and is valid
		if( !boost::filesystem::exists( fullPath ) ) {
			std::cout << "Failed: could not open level.dat because it does not exist" << std::endl;
			return false;
		}
		else if( !boost::filesystem::is_regular_file( fullPath ) ) {
			std::cout << "Failed: could not open level.dat because it is invalid" << std::endl;
			return false;
		}
		// Open the stream
		inputStream.open( fullPath, std::ios::in | std::ios::binary );
		if( !inputStream ) {
			std::cout << "Failed: could not open level.dat" << std::endl;
			return false;
		}
	}
	catch( const boost::filesystem::filesystem_error &e ) {
		std::cout << "Failed: could not open level.dat (" << e.what() << ")" << std::endl;
		return false;
	}

	// Setup decompression filter
	decompStream.push( boost::iostreams::gzip_decompressor() );
	decompStream.push( inputStream );

	// Read
	if( !this->read( decompStream ) )
		return false;

	_ASSERT_EXPR( inputStream.is_open(), L"inputStream was closed prematurely" );
	// Close
	boost::iostreams::close( decompStream );
	inputStream.close();

	return true;
}
Ejemplo n.º 7
0
bool CConsole::run( std::vector<char*> &arguments )
{
	std::string command;

	_ASSERT_EXPR( arguments.size() > 0, L"argument list was empty" );

	// Identify the command
	command = arguments[0];
	std::transform( command.begin(), command.end(), command.begin(), ::tolower );

	if( command.compare( "help" ) == 0 ) {
		if( arguments.size() >= 2 )
			this->commandHelp( arguments[1] );
		else
			this->commandHelp();
		return true;
	}
	else if( command.compare( "generate" ) == 0 ) {
		if( arguments.size() < 2 ) {
			this->commandHelp( "generate" );
			return true;
		}
		std::string map, output;
		std::vector<char> flags;
		map = arguments[1];
		if( arguments.size() >= 3 ) 
			flags = std::vector<char>( arguments[2], arguments[2]+strlen( arguments[2] ) );
		if( arguments.size() >= 4 )
			output = arguments[3];
		return this->commandGenerate( map, flags, output );
	}
	else if( command.compare( "genblocks" ) == 0 ) {
		return this->commandGenBlocks();
	}
	else {
		std::cout << "\'" << arguments[0] << "\' is not a valid command" << std::endl;
		this->commandHelp();
		return true;
	}

	return true;
}
Ejemplo n.º 8
0
void FormTagManager::InitTagList()
{
	_ASSERT_EXPR(NULL!=_hListTags,"_hListTags could not be NULL.");

	ListView_SetImageList(_hListTags,_sysImgList,LVSIL_SMALL);

	UINT cIdx = 0;
	LVCOLUMN c = {0};
	c.pszText = ::MyLoadString(IDS_DLG_TAGMANAGER_LV_TAGS_HEADER_TAGNAME);
	c.mask = LVCF_TEXT | LVCF_MINWIDTH | LVCF_WIDTH;
	c.cxMin = 80;
	c.cx = 105;
	ListView_InsertColumn(_hListTags,cIdx++,&c);

	c.pszText = ::MyLoadString(IDS_DLG_TAGMANAGER_LV_TAGS_HEADER_USECOUNT);
	c.mask = LVCF_TEXT | LVCF_MINWIDTH | LVCF_WIDTH | LVCF_FMT;
	c.cxMin = 40;
	c.cx = 50;
	c.fmt = LVCFMT_RIGHT;
	ListView_InsertColumn(_hListTags,cIdx++,&c);

	LoadTags();
}
Ejemplo n.º 9
0
void FormTagManager::LoadSelectedFiles(void)
{
	::PrintLog(L"FormTagManager.LoadSelectedFiles.");
	_ASSERT_EXPR(NULL!=_hListFiles,"_hListFiles could not be NULL.");

	ListView_DeleteAllItems(_hListFiles);

	auto &_tagHelper = *_handler->pTagHelper;
	if ( _tagHelper.FileCount > 0 )
	{
		LVITEM item = {0};
		for (unsigned int i = 0; i < _tagHelper.FileCount; i++)
		{
			item.pszText = LPSTR_TEXTCALLBACK;
			item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
			item.iItem = i;
			item.stateMask = 0;
			item.iSubItem  = 0;
			item.state     = 0;
			item.iImage = I_IMAGECALLBACK;
			ListView_InsertItem(_hListFiles,&item);
		}
	}
}
Ejemplo n.º 10
0
void SavedVariables::Save(lua_State *L){

	CheckCreateSVDir();

	auto FilePath = SavedVariablesFolderPath/FileName;

	SavedVariableFile = _wfopen(FilePath.c_str(),	_T("w"));
	
	if(SavedVariableFile == NULL){
		throw exception("failed to open SavedVariable file for writing");
	}

	int ContainerIndex = LUA_GLOBALSINDEX;

	if(ContainerTable.is_valid()) {
		ContainerTable.push(L);
		ContainerIndex = lua_gettop(L);
	}

	BOOST_FOREACH(const string& VariableName, VariableNames){
		lua_getfield(L, ContainerIndex, VariableName.c_str());

		int CurrentStackPos = lua_gettop(L);

		if(lua_type(L, -1) == LUA_TNIL){
			lua_pop(L, 1);
			continue;
		}

		fprintf(SavedVariableFile, "%s = ", VariableName.c_str());

		switch(lua_type(L, -1)){
			case LUA_TNUMBER:{
        double value = lua_tonumber(L, -1);

        if(value == ((int)value)){
          fprintf(SavedVariableFile,  "%i\n", (int)value);
        }else{
          fprintf(SavedVariableFile, "%f\n", value);
        }
      }break;

			case LUA_TSTRING:
				fprintf(SavedVariableFile, "\"%s\"\n", lua_tostring(L, -1));
			break;

			case LUA_TBOOLEAN:
				fprintf(SavedVariableFile, lua_toboolean(L, -1) ? "true\n" : "false\n");
			break;

			case LUA_TTABLE:
				fprintf(SavedVariableFile, "{\n");
					SaveTable(L);
				fprintf(SavedVariableFile, "}\n");
			break;

			case LUA_TUSERDATA:
				if(SerializeCustomType(L, -1)){
					fprintf(SavedVariableFile, "\n");
				}else{
					fprintf(SavedVariableFile, "nil --[[Skipping userdata thats not a Vector or Angles]]\n");
				}
			break;

			default:
				fprintf(SavedVariableFile, "nil --Skipping a %s value that cannot be serialized]]\n", lua_typename(L, lua_type(L, -1)));
			break;
		}

		//WriteValue(L);

		_ASSERT_EXPR(lua_gettop(L) == CurrentStackPos, _T("Stack Position is not the position before the call to SaveTable"));

		lua_pop(L, 1);
	}
Ejemplo n.º 11
0
void Assert(const char *msg, int n)
{
	_ASSERT_EXPR((0), NULL);
}
Ejemplo n.º 12
0
CTag* CNBTReader::readTag( InputStream &stream, size_t *pBytesRead, bool fullTag = true )
{
	boost::int8_t tagId;
	CTag *pTag;

	// Read the tag ID
	if( fullTag ) {
		stream.read( reinterpret_cast<char*>(&tagId), sizeof( tagId ) );
		(*pBytesRead) += sizeof( tagId );
	}
	else {
		_ASSERT_EXPR( !m_parentStack.empty(), L"can't create non-full tag when parent stack is empty" );
		_ASSERT_EXPR( m_parentStack.top()->getId() == TAGID_LIST, L"list not at top of parent stack" );
		tagId = reinterpret_cast<CTagList*>(m_parentStack.top())->getChildrenId();
	}

	if( stream.eof() )
		return 0;

	// Create the tag
	pTag = this->createTag( tagId );
	if( !pTag )
		return 0;

	// If it has no parents its a root tag
	if( m_parentStack.empty() )
		m_rootTags.push_back( pTag );
	// If not assign it to parent
	else
		m_parentStack.top()->addChild( pTag );

	// Check if its an end tag
	if( pTag->getId() == TAGID_END ) {
		if( m_parentStack.empty() ) {
			std::cout << "Failed: mismatched end tag" << std::endl;
			delete pTag;
			return 0;
		}
		m_parentStack.pop();
	}
	// Check if its a parent
	if( pTag->isParent() )
		m_parentStack.push( reinterpret_cast<CTagParent*>( pTag ) );

	// Read the tag
	pTag->read( stream, pBytesRead, fullTag );

	// Check if the list is full
	if( !m_parentStack.empty() ) {
		if( m_parentStack.top()->getId() == TAGID_LIST ) {
			if( m_parentStack.top()->getChildren().size() == reinterpret_cast<CTagList*>(m_parentStack.top())->getChildrenCount() )
				m_parentStack.pop(); // pop off the list
		}
	}

	/*if( pTag->isParent() )
		for( unsigned int i = 0; i < m_parentStack.size()-1; i++ )
			std::cout << "\t";
	else
		for( unsigned int i = 0; i < m_parentStack.size(); i++ )
			std::cout << "\t";
	std::cout << (int)pTag->getId() << "(" << pTag->getName().c_str() << ")" << std::endl;*/

	return pTag;
}
Ejemplo n.º 13
0
void FormTagManager::ShowMsg(LPWSTR msg, COLORREF color)
{
	_ASSERT_EXPR(NULL != msg,L"msg could not be NULL.");
	_msgColor = color;
	SetDlgItemText(_hwnd, IDC_TAGMANAGER_STATIC_ERROR_INFO, msg);
}
Ejemplo n.º 14
0
void Demo::ContentLoader::UploadShape(
	_In_ String const &file,
	_In_ String const &targetShape,
	_In_ String const &targetShapeTransform,
	_Notnull_ _Inout_ Shape *mesh

	)
{
	MayaShape *mayaShapeObject = nullptr;
	MayaTransform *mayaShapeTransformObject = nullptr;

	m_internalContentReader.Import(file);

	for (auto &handle : m_internalContentReader.Root->GetHandlesReference())
	{
		if (handle->GetNameReference() == targetShape &&
			handle->GetType() == MayaData::IItem::kShape)
		{
			mayaShapeObject = dynamic_cast<MayaShape*>(handle);
		}
		else if (handle->GetType() == MayaData::IItem::kTransform &&
			handle->GetNameReference() == targetShapeTransform)
		{
			mayaShapeTransformObject = dynamic_cast<MayaTransform*>(handle);
			break;
		}
	}

	for (::UINT32 p = 0; p < mayaShapeObject->Points->at(1)->Count; p++)
		mesh->PointListOS.push_back(mayaShapeObject->Points->at(1)->Vectors[p]);
	for (::UINT32 n = 0; n < mayaShapeObject->Normals->at(1)->Count; n++)
		mesh->NormalListOS.push_back(mayaShapeObject->Normals->at(1)->Vectors[n]);
	for (::UINT32 t = 0; t < mayaShapeObject->Sets[0]->UVs.size(); t++)
		mesh->TexcoordsList.push_back(mayaShapeObject->Sets[0]->UVs[t]);

	for (::UINT32 f = 0; f < mayaShapeObject->Polygons.size(); f++)
	{
		Shape::FACE face;

		for (::UINT32 v = 0; v < mayaShapeObject->Polygons[f]->VertexCount; v++)
		{
			face.V[v].P = mayaShapeObject->Polygons[f]->Vertices[v].PointIndex;
			face.V[v].N = mayaShapeObject->Polygons[f]->Vertices[v].NormalIndex;
			face.V[v].T = mayaShapeObject->Polygons[f]->Vertices[v].Texcoords[0].UVIndex;
		}

		mesh->PolygonList.push_back(face);
	}

	mesh->N2PMap = new UINT32[mayaShapeObject->Normals->at(1)->Count];
	for (::UINT32 n = 0; n < mayaShapeObject->Normals->at(1)->Count; n++)
	{
		::BOOL pointIndexFound = FALSE;

		for (::UINT32 f = 0; f < mayaShapeObject->Polygons.size() && !pointIndexFound; f++)
		for (::UINT32 v = 0; v < mayaShapeObject->Polygons[f]->VertexCount; v++)
		if (mayaShapeObject->Polygons[f]->Vertices[v].NormalIndex == n)
		{
			mesh->N2PMap[n] = mayaShapeObject->Polygons[f]->Vertices[v].PointIndex;

			/*Framework::Output("N%d ~ P%d\n",
			mayaShapeObject->Polygons[f].Vertices[v].NormalIndex,
			mayaShapeObject->Polygons[f].Vertices[v].PointIndex
			);*/

			pointIndexFound = TRUE;
			break;
		}

		_ASSERT_EXPR(pointIndexFound, L"Point index not found");
	}

	CopyTransform(
		&mesh->TransformOS, &mesh->TransformWS,
		mayaShapeTransformObject
		);
	m_internalContentReader.Clear();
}
HRESULT ThreadController::EnumeratePropertyMembers(_In_ ULONG propertyId, _In_ UINT radix, _Inout_ vector<shared_ptr<PropertyInfo>>& spPropertyInfos)
{
    ATLENSURE_RETURN_HR(ThreadHelpers::IsOnDispatchThread(m_dispatchThreadId), E_UNEXPECTED);

    // Lock the callframe access
    CComCritSecLock<CComAutoCriticalSection> lock(m_csCallFramesLock);

    if (!this->IsConnected() || !this->IsAtBreak())
    {
        return E_NOT_VALID_STATE;
    }

    auto it = m_propertyMap.find(propertyId);
    if (it != m_propertyMap.end())
    {
        CComPtr<IDebugProperty> spDebugProperty = it->second;

        // Get all the members for the children
        CComPtr<IEnumDebugPropertyInfo> spEnumProps;
        HRESULT hr = spDebugProperty->EnumMembers(PROP_INFO_ALL, radix, IID_IEnumDebugPropertyInfo, &spEnumProps);
        
        if (hr == E_NOTIMPL)
        {
            // This is reported in Watson, but we do not have a repro. Returning no properties is a 
            // better experience than failing, until we can diagnose and avoid this case.
            _ASSERT_EXPR(false, L"IEnumDebugPropertyInfo->EnumMembers returned E_NOTIMPL");
            return S_OK;
        }
        else if (hr == E_FAIL)
        {
            // The webcrawler hits an issue where the PDM returns E_FAIL. In this case we want to just
            // return an empty array back to the front end instead of asserting and blocking with a dialog.
            return S_OK;
        }

        BPT_FAIL_IF_NOT_S_OK(hr);

        hr = spEnumProps->Reset();
        BPT_FAIL_IF_NOT_S_OK(hr);

        ULONG count;
        hr = spEnumProps->GetCount(&count);
        if (hr == S_OK) // Since GetCount can fail when walking the properties, we return the hr which results in an empty array
        {
            for (ULONG i = 0; i < count; i++)
            {
                // Fetch each child one at a time, if we fail to get all of them, we can return with the successful ones
                CAutoVectorPtr<DebugPropertyInfo> spDebugPropertyInfo;
                bool alloced = spDebugPropertyInfo.Allocate(1);
                ATLENSURE_RETURN_HR(alloced == true, E_OUTOFMEMORY);

                // Fetch the next child and add it to the list
                ULONG numFetched = 0;
                hr = spEnumProps->Next(1, spDebugPropertyInfo.m_p, &numFetched);
                if (hr == S_OK && numFetched == 1) // This can fail for certain properties (e.g. location) in some conditions (e.g. a navigation), so we just ignore and continue
                {
                    // Get the property info
                    shared_ptr<PropertyInfo> spPropertyInfo;
                    hr = this->PopulatePropertyInfo(spDebugPropertyInfo[0], spPropertyInfo);
                    if (hr == S_OK)
                    {
                        // Store this to the out parameter
                        spPropertyInfos.push_back(spPropertyInfo);
                    }
                }
            }
        }
    }
    else
    {
        return E_NOT_FOUND;
    }

    return S_OK;
}
Ejemplo n.º 16
0
void Demo::ShadowMapping::HardValidation()
{
	HRESULT result = S_OK;

	Nena::App::Vars *vars = Nena::App::Vars::GetForCurrentThread();
	if (!vars->GetRecordsCount()) result = vars->Read();

	_ASSERT_EXPR(SUCCEEDED(result), 
		L"Cannot find app vars file");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/File"),
		L"Cannot find record: scene file");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Ground/Transform"),
		L"Cannot find record: ground shape name");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Sphere/Transform"),
		L"Cannot find record: sphere shape name");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Cube/Transform"),
		L"Cannot find record: cube shape name");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Ground/Texture"),
		L"Cannot find record: ground shape name");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Sphere/Texture"),
		L"Cannot find record: sphere shape name");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Cube/Texture"),
		L"Cannot find record: cube shape name");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Ground/Shape"),
		L"Cannot find record: ground shape name");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Sphere/Shape"),
		L"Cannot find record: sphere shape name");
	_ASSERT_EXPR(vars->HasRecord("Demo/ShadowMapping/Scene/Import/Cube/Shape"),
		L"Cannot find record: cube shape name");

	Depth.HardValidation();
	Shadow.HardValidation();
}