void CLight::Render(int priority, bool strictB2F) { inherited::Render(priority,strictB2F); if ((1==priority)&&(false==strictB2F)){ Device.SetShader (Device.m_WireShader); RCache.set_xform_world (Fidentity); u32 clr = Locked()?LOCK_COLOR:(Selected()?SEL_COLOR:(m_Flags.is(ELight::flAffectDynamic)?NORM_DYN_COLOR:NORM_COLOR)); switch (m_Type){ case ELight::ltPoint: if (Selected()) DU.DrawLineSphere( PPosition, m_Range, clr, true ); DU.DrawPointLight(PPosition,VIS_RADIUS, clr); if (m_Flags.is(ELight::flPointFuzzy)){ VERIFY(m_FuzzyData); for (FvectorIt it=m_FuzzyData->m_Positions.begin(); it!=m_FuzzyData->m_Positions.end(); it++){ Fvector tmp; _Transform().transform_tiny(tmp,*it); DU.DrawPointLight(tmp,VIS_RADIUS/6, clr); } } break; case ELight::ltSpot:{ // Fvector dir; // dir.setHP (PRotation.y,PRotation.x); // DU.DrawCone (Fidentity, PPosition, dir, Selected()?m_Range:VIS_RADIUS, radius2, clr, true, false); if (Selected()) DU.DrawSpotLight( PPosition, FTransformR.k, m_Range, m_Cone, clr ); else DU.DrawSpotLight( PPosition, FTransformR.k, VIS_RADIUS, m_Cone, clr ); }break; default: THROW; } ESceneLightTools* lt = dynamic_cast<ESceneLightTools*>(ParentTools); VERIFY(lt); if (lt->m_Flags.is(ESceneLightTools::flShowControlName)){ Fvector D; D.sub(Device.vCameraPosition,PPosition); float dist = D.normalize_magn(); if (!Scene->RayPickObject(dist,PPosition,D,OBJCLASS_SCENEOBJECT,0,0)) DU.OutText (PPosition,AnsiString().sprintf(" %s",GetLControlName()).c_str(),0xffffffff,0xff000000); } }else if ((1==priority)&&(true==strictB2F)){ Device.SetShader (Device.m_SelectionShader); RCache.set_xform_world (Fidentity); switch (m_Type){ case ELight::ltPoint: if (m_Flags.is(ELight::flPointFuzzy)){ u32 clr = Locked()?LOCK_COLOR:(Selected()?SEL_COLOR:(m_Flags.is(ELight::flAffectDynamic)?NORM_DYN_COLOR:NORM_COLOR)); clr = subst_alpha(clr,0x40); const Fvector zero={0.f,0.f,0.f}; VERIFY(m_FuzzyData); switch (m_FuzzyData->m_ShapeType){ case CLight::SFuzzyData::fstSphere: DU.DrawSphere (_Transform(),zero,m_FuzzyData->m_SphereRadius,clr,clr,true,true); break; case CLight::SFuzzyData::fstBox: DU.DrawAABB (_Transform(),zero,m_FuzzyData->m_BoxDimension,clr,clr,true,true); break; } } break; case ELight::ltSpot: break; default: THROW; } } }
void ESoundSource::Render(int priority, bool strictB2F) { if((1==priority)&&(false==strictB2F)){ RCache.set_xform_world (Fidentity); Device.SetShader (Device.m_WireShader); u32 clr0 = Locked()?SOUND_LOCK_COLOR:(Selected()?SOUND_SEL0_COLOR:SOUND_NORM_COLOR); u32 clr1 = Locked()?SOUND_LOCK_COLOR:(Selected()?SOUND_SEL1_COLOR:SOUND_NORM_COLOR); if (Selected()){ DU.DrawLineSphere (m_Params.position, m_Params.max_distance, clr1, true); DU.DrawLineSphere (m_Params.position, m_Params.min_distance, clr0, false); }else{ DU.DrawSound (m_Params.position,VIS_RADIUS, clr1); } } }
template<> bool Config<const char *>::Set(const char *newval) { if( m_current == newval ) return true; if( m_current && newval && 0==strcmp(newval, m_current) ) return true; if( !Locked() && Valid(newval) ){ size_t len; char *tmp; if( m_current ){ delete []m_current; m_current = (const char *)0; } if( newval ){ len = strlen(newval); if( MaxLen() && len > MaxLen() ) len = MaxLen(); if( !(tmp = new char[len + 1]) ) return false; strncpy(tmp, newval, len); tmp[len] = '\0'; m_current = tmp; } Handler(); if(*cfg_verbose) CONSOLE.Debug("Config: %s = \"%s\"", Tag(), m_current ? m_current : ""); return true; } return false; }
void CUICustomMap::Update() { SetPointerDistance (0.0f); if(!Locked()) UpdateSpots (); CUIStatic::Update (); }
void BH2009BehaviorControl::writeBHumanSharedMemory() { Locked(cognition_data->bhuman); cognition_data->bhuman.ball_time_when_last_seen = theBallModel.timeWhenLastSeen; cognition_data->bhuman.ball_velocity_estimate.x = theBallModel.estimate.velocity.x; cognition_data->bhuman.ball_velocity_estimate.y = theBallModel.estimate.velocity.y; cognition_data->bhuman.ball_position_estimate.x = theBallModel.estimate.position.x; cognition_data->bhuman.ball_position_estimate.y = theBallModel.estimate.position.y; cognition_data->bhuman.writes++; }
bool ContextManager::isManagingContext(char *addr) const { ssize_t slot = getSlotIndexFromAddress(addr); if (slot < 0) { return false; } llvm::MutexGuard Locked(mContextSlotOccupiedLock); return mContextSlotOccupied[slot]; }
void Matrix<T>::Update( Int i, Int j, T alpha ) { #ifndef RELEASE CallStackEntry entry("Matrix::Update"); AssertValidEntry( i, j ); if( Locked() ) LogicError("Cannot modify data of locked matrices"); #endif Set_( i, j ) += alpha; }
template<> bool Config<bool>::Set(bool newval) { if( newval == m_current ) return true; if( !Locked() && Valid(newval) ){ m_current = newval; Handler(); if(*cfg_verbose) CONSOLE.Debug("Config: %s = %s", Tag(), Sval()); return true; } return false; }
T* Matrix<T>::Buffer( Int i, Int j ) { #ifndef RELEASE CallStackEntry entry("Matrix::Buffer"); if( Locked() ) LogicError("Cannot return non-const buffer of locked Matrix"); #endif // NOTE: This const_cast has been carefully considered and should be safe // since the underlying data should be non-const if this is called. return &const_cast<T*>(data_)[i+j*ldim_]; }
char *ContextManager::allocateContext(char *addr, int imageFd, off_t imageOffset) { // This function should only allocate context when address is an context // slot address. And the image offset is aligned to the pagesize. if (imageFd < 0) { LOGE("Invalid file descriptor for bcc context image\n"); return NULL; } unsigned long pagesize = (unsigned long)sysconf(_SC_PAGESIZE); if (imageOffset % pagesize > 0) { LOGE("BCC context image offset is not aligned to page size\n"); return NULL; } ssize_t slot = getSlotIndexFromAddress(addr); if (slot < 0) { LOGE("Suggested address is not a bcc context slot address\n"); return NULL; } llvm::MutexGuard Locked(mContextSlotOccupiedLock); if (mContextSlotOccupied[slot]) { LOGW("Suggested bcc context slot has been occupied.\n"); return NULL; } // LOGI("addr=%x, imageFd=%d, imageOffset=%x", addr, imageFd, imageOffset); void *result = mmap(addr, ContextSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, imageFd, imageOffset); if (!result || result == MAP_FAILED) { LOGE("Unable to allocate. addr=%p\n", addr); return NULL; } if (result != addr) { LOGE("Unable to allocate at suggested=%p, result=%p\n", addr, result); munmap(result, ContextSize); return NULL; } LOGI("Allocate bcc context. addr=%p\n", addr); mContextSlotOccupied[slot] = true; return static_cast<char *>(result); }
void ScreenObject::Show() { if (Locked()) return; // _tran(SysLog(L"[%p] ScreenObject::Show()",this)); if (!Flags.Check(FSCROBJ_SETPOSITIONDONE)) return; // if (Flags.Check(FSCROBJ_ISREDRAWING)) // return; // Flags.Set(FSCROBJ_ISREDRAWING); SavePrevScreen(); DisplayObject(); // Flags.Clear(FSCROBJ_ISREDRAWING); }
void BH2009BehaviorControl::readCognitionSharedMemory() { static int jesus_moves = 0; { Locked(cognition_data->cognition); if (cognition_data->cognition.writes <= cognition_data->cognition.reads) return; cognition_data->cognition.reads++; if (cognition_data->cognition.startTurn) { jesus_moves++; behaviorControlOutput.motionRequest.motion = MotionRequest::specialAction; behaviorControlOutput.motionRequest.specialActionRequest.specialAction = SpecialActionRequest::demoJesus; } } if (cognition_data->cognition.startTurn) { // do cout out of the lock - might take time? std::cout << "Jesus move on " << jesus_moves << "\n"; } }
char *ContextManager::allocateContext() { { // Acquire mContextSlotOccupiedLock llvm::MutexGuard Locked(mContextSlotOccupiedLock); // Try to allocate context on the managed context slot. for (size_t i = 0; i < ContextSlotCount; ++i) { if (mContextSlotOccupied[i]) { continue; } void *addr = ContextFixedAddr + ContextSize * i; void *result = mmap(addr, ContextSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); if (result == addr) { LOGI("Allocate bcc context. addr=%p\n", result); mContextSlotOccupied[i] = true; return static_cast<char *>(result); } if (result && result != MAP_FAILED) { LOGE("Unable to allocate. suggested=%p, result=%p\n", addr, result); munmap(result, ContextSize); } LOGE("Unable to allocate. addr=%p. Retry ...\n", addr); } // Release mContextSlotOccupiedLock } // No slot available, allocate at arbitary address. void *result = mmap(0, ContextSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); if (!result || result == MAP_FAILED) { LOGE("Unable to mmap. (reason: %s)\n", strerror(errno)); return NULL; } LOGI("Allocate bcc context. addr=%p\n", result); return static_cast<char *>(result); }
void CEditShape::Render(int priority, bool strictB2F) { inherited::Render(priority, strictB2F); if (1==priority){ if (strictB2F){ Device.SetShader (Device.m_WireShader); Device.SetRS (D3DRS_CULLMODE,D3DCULL_NONE); u32 clr = Selected()?subst_alpha(m_DrawTranspColor, color_get_A(m_DrawTranspColor)*2):m_DrawTranspColor; Fvector zero ={0.f,0.f,0.f}; for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){ switch(it->type){ case cfSphere:{ Fsphere& S = it->data.sphere; Fmatrix B; B.scale (S.R,S.R,S.R); B.translate_over (S.P); B.mulA_43 (_Transform()); RCache.set_xform_world(B); Device.SetShader (Device.m_WireShader); DU.DrawCross (zero,1.f,m_DrawEdgeColor,false); DU.DrawIdentSphere (true,true,clr,m_DrawEdgeColor); }break; case cfBox: Fmatrix B = it->data.box; B.mulA_43 (_Transform()); RCache.set_xform_world(B); DU.DrawIdentBox (true,true,clr,m_DrawEdgeColor); break; } } Device.SetRS(D3DRS_CULLMODE,D3DCULL_CCW); }else{ if( Selected()&&m_Box.is_valid() ){ Device.SetShader (Device.m_SelectionShader); RCache.set_xform_world (_Transform()); u32 clr = Locked()?0xFFFF0000:0xFFFFFFFF; Device.SetShader (Device.m_WireShader); DU.DrawSelectionBox (m_Box,&clr); } } } }
void CSceneObject::Render(int priority, bool strictB2F) { inherited::Render(priority,strictB2F); if (!m_pReference) return; #ifdef _LEVEL_EDITOR Scene->SelectLightsForObject(this); #endif m_pReference->Render(_Transform(), priority, strictB2F); if (Selected()){ if (1==priority){ if (false==strictB2F){ Device.SetShader(Device.m_WireShader); RCache.set_xform_world(_Transform()); u32 clr = Locked()?0xFFFF0000:0xFFFFFFFF; DU.DrawSelectionBox(m_pReference->GetBox(),&clr); }else{ RenderBlink (); } } } }
void EParticlesObject::Render(int priority, bool strictB2F) { inherited::Render(priority,strictB2F); Fbox bb; GetBox(bb); if (::Render->occ_visible(bb)){ RCache.set_xform_world(Fidentity); if (1==priority){ if (false==strictB2F){ // draw emitter Device.SetShader(Device.m_WireShader); DU.DrawCross (PPosition,0.20f,0.25f,0.20f,0.20f,0.25f,0.20f,0xFFFFEBAA,false); // DU.DrawLineSphere(PPosition, PSOBJECT_SIZE/10, C, true); if( Selected() ){ Fbox bb; GetBox(bb); u32 clr = Locked()?0xFFFF0000:0xFFFFFFFF; DU.DrawSelectionBox(bb,&clr); } } } if (m_Particles) ::Render->model_Render(m_Particles,_Transform(),priority,strictB2F,1.f); } }
void ContextManager::deallocateContext(char *addr) { if (!addr) { return; } llvm::MutexGuard Locked(mContextSlotOccupiedLock); LOGI("Deallocate bcc context. addr=%p\n", addr); // Unmap if (munmap(addr, ContextSize) < 0) { LOGE("Unable to unmap. addr=%p (reason: %s)\n", addr, strerror(errno)); return; } // If the address is one of the context slot, then mark such slot // freely available as well. ssize_t slot = getSlotIndexFromAddress(addr); if (slot >= 0) { // Give the context slot back. mContextSlotOccupied[slot] = false; } }
void CGroupObject::Render(int priority, bool strictB2F) { inherited::Render(priority, strictB2F); for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++){ if ((*it)->IsRender()){ switch ((*it)->ClassID){ case OBJCLASS_SCENEOBJECT: (*it)->Render(priority,strictB2F); break; default: Device.SetShader(strictB2F?Device.m_SelectionShader:Device.m_WireShader); RCache.set_xform_world(Fidentity); (*it)->Render(priority,strictB2F); } } } if ((1==priority)&&(false==strictB2F)){ Fbox bb; if (Selected()&&GetBox(bb)){ Device.SetShader(Device.m_WireShader); RCache.set_xform_world(Fidentity); u32 clr = Locked()?0xFFFF0000:(IsOpened()?0xFF7070FF:0xFFFFFFFF); DU.DrawSelectionBox(bb,&clr); } } }
void CGlow::Render(int priority, bool strictB2F) { if ((1==priority)&&(true==strictB2F)){ if (!m_bDefLoad) OnDeviceCreate(); ESceneGlowTools* gt = dynamic_cast<ESceneGlowTools*>(ParentTools); VERIFY(gt); RCache.set_xform_world(Fidentity); if (gt->m_Flags.is(ESceneGlowTools::flTestVisibility)){ Fvector D; D.sub(Device.vCameraPosition,PPosition); float dist = D.normalize_magn(); if (!Scene->RayPickObject(dist,PPosition,D,OBJCLASS_SCENEOBJECT,0,0)){ if (m_GShader){ Device.SetShader(m_GShader); }else{ Device.SetShader(Device.m_WireShader);} m_RenderSprite.Render(PPosition,m_fRadius,m_Flags.is(gfFixedSize)); DU.DrawRomboid(PPosition, VIS_RADIUS, 0x00FF8507); }else{ // рендерим bounding sphere Device.SetShader(Device.m_WireShader); DU.DrawRomboid(PPosition, VIS_RADIUS, 0x00FF8507); } }else{ if (m_GShader){ Device.SetShader(m_GShader); }else{ Device.SetShader(Device.m_WireShader);} m_RenderSprite.Render(PPosition,m_fRadius,m_Flags.is(gfFixedSize)); } if( Selected() ){ Fbox bb; GetBox(bb); u32 clr = Locked()?0xFFFF0000:0xFFFFFFFF; Device.SetShader(Device.m_WireShader); DU.DrawSelectionBox(bb,&clr); if (gt->m_Flags.is(ESceneGlowTools::flDrawCross)){ Fvector sz; bb.getradius(sz); DU.DrawCross(PPosition,sz.x,sz.y,sz.z, sz.x,sz.y,sz.z,0xFFFFFFFF,false); } } } }
//-----------------------------------------------------------------------------------------// Flag::operator bool () { CriticalScope< MutexLock > Locked( lock_ ); return flag_; }
//-----------------------------------------------------------------------------------------// bool Flag::operator = ( bool flag ) { CriticalScope< MutexLock > Locked( lock_ ); return flag_ = flag; }
//-----------------------------------------------------------------------------------------// bool Flag::Get() { CriticalScope< MutexLock > Locked( lock_ ); return flag_; }
//-----------------------------------------------------------------------------------------// void Flag::Set( bool flag ) { CriticalScope< MutexLock > Locked( lock_ ); flag_ = flag; }
Locked operator->() const { std::cout << "Exclusive->" << std::endl; return Locked(b, 5); }
void FileList::ShowFileList(int Fast) { if (Locked()) { CorrectPosition(); return; } string strTitle; string strInfoCurDir; int Length; OpenPanelInfo Info; if (PanelMode==PLUGIN_PANEL) { if (ProcessPluginEvent(FE_REDRAW,nullptr)) return; CtrlObject->Plugins->GetOpenPanelInfo(hPlugin,&Info); strInfoCurDir=Info.CurDir; } bool CurFullScreen=IsFullScreen(); PrepareViewSettings(ViewMode,&Info); CorrectPosition(); if (CurFullScreen!=IsFullScreen()) { CtrlObject->Cp()->SetScreenPosition(); CtrlObject->Cp()->GetAnotherPanel(this)->Update(UPDATE_KEEP_SELECTION|UPDATE_SECONDARY); } SetScreen(X1+1,Y1+1,X2-1,Y2-1,L' ',ColorIndexToColor(COL_PANELTEXT)); Box(X1,Y1,X2,Y2,ColorIndexToColor(COL_PANELBOX),DOUBLE_BOX); if (Opt.ShowColumnTitles) { // SetScreen(X1+1,Y1+1,X2-1,Y1+1,' ',COL_PANELTEXT); SetColor(COL_PANELTEXT); //??? //GotoXY(X1+1,Y1+1); //FS<<fmt::Width(X2-X1-1)<<L""; } for (int I=0,ColumnPos=X1+1; I<ViewSettings.ColumnCount; I++) { if (ViewSettings.ColumnWidth[I]<0) continue; if (Opt.ShowColumnTitles) { LNGID IDMessage=MColumnUnknown; switch (ViewSettings.ColumnType[I] & 0xff) { case NAME_COLUMN: IDMessage=MColumnName; break; case EXTENSION_COLUMN: IDMessage=MColumnExtension; break; case SIZE_COLUMN: IDMessage=MColumnSize; break; case PACKED_COLUMN: IDMessage=MColumnAlocatedSize; break; case DATE_COLUMN: IDMessage=MColumnDate; break; case TIME_COLUMN: IDMessage=MColumnTime; break; case WDATE_COLUMN: IDMessage=MColumnWrited; break; case CDATE_COLUMN: IDMessage=MColumnCreated; break; case ADATE_COLUMN: IDMessage=MColumnAccessed; break; case CHDATE_COLUMN: IDMessage=MColumnChanged; break; case ATTR_COLUMN: IDMessage=MColumnAttr; break; case DIZ_COLUMN: IDMessage=MColumnDescription; break; case OWNER_COLUMN: IDMessage=MColumnOwner; break; case NUMLINK_COLUMN: IDMessage=MColumnMumLinks; break; case NUMSTREAMS_COLUMN: IDMessage=MColumnNumStreams; break; case STREAMSSIZE_COLUMN: IDMessage=MColumnStreamsSize; break; } strTitle=MSG(IDMessage); if (PanelMode==PLUGIN_PANEL && Info.PanelModesArray && ViewMode<static_cast<int>(Info.PanelModesNumber) && Info.PanelModesArray[ViewMode].ColumnTitles) { const wchar_t *NewTitle=Info.PanelModesArray[ViewMode].ColumnTitles[I]; if (NewTitle) strTitle=NewTitle; } string strTitleMsg; CenterStr(strTitle,strTitleMsg,ViewSettings.ColumnWidth[I]); SetColor(COL_PANELCOLUMNTITLE); GotoXY(ColumnPos,Y1+1); FS<<fmt::Precision(ViewSettings.ColumnWidth[I])<<strTitleMsg; } if (I>=ViewSettings.ColumnCount-1) break; if (ViewSettings.ColumnWidth[I+1]<0) continue; SetColor(COL_PANELBOX); ColumnPos+=ViewSettings.ColumnWidth[I]; GotoXY(ColumnPos,Y1); bool DoubleLine = Opt.DoubleGlobalColumnSeparator && (!((I+1)%ColumnsInGlobal)); BoxText(BoxSymbols[DoubleLine?BS_T_H2V2:BS_T_H2V1]); if (Opt.ShowColumnTitles) { GotoXY(ColumnPos,Y1+1); BoxText(BoxSymbols[DoubleLine?BS_V2:BS_V1]); } if (!Opt.ShowPanelStatus) { GotoXY(ColumnPos,Y2); BoxText(BoxSymbols[DoubleLine?BS_B_H2V2:BS_B_H2V1]); } ColumnPos++; } int NextX1=X1+1; if (Opt.ShowSortMode) { static int SortModes[]={UNSORTED,BY_NAME,BY_EXT,BY_MTIME,BY_CTIME, BY_ATIME,BY_CHTIME,BY_SIZE,BY_DIZ,BY_OWNER, BY_COMPRESSEDSIZE,BY_NUMLINKS, BY_NUMSTREAMS,BY_STREAMSSIZE, BY_FULLNAME,BY_CUSTOMDATA }; static LNGID SortStrings[]={MMenuUnsorted,MMenuSortByName, MMenuSortByExt,MMenuSortByWrite,MMenuSortByCreation, MMenuSortByAccess,MMenuSortByChange,MMenuSortBySize,MMenuSortByDiz,MMenuSortByOwner, MMenuSortByAllocatedSize,MMenuSortByNumLinks,MMenuSortByNumStreams,MMenuSortByStreamsSize, MMenuSortByFullName,MMenuSortByCustomData }; for (size_t I=0; I<ARRAYSIZE(SortModes); I++) { if (SortModes[I]==SortMode) { const wchar_t *SortStr=MSG(SortStrings[I]); const wchar_t *Ch=wcschr(SortStr,L'&'); if (Ch) { if (Opt.ShowColumnTitles) GotoXY(NextX1,Y1+1); else GotoXY(NextX1,Y1); SetColor(COL_PANELCOLUMNTITLE); OutCharacter[0]=SortOrder==1 ? Lower(Ch[1]):Upper(Ch[1]); Text(OutCharacter); NextX1++; if (Filter && Filter->IsEnabledOnPanel()) { OutCharacter[0]=L'*'; Text(OutCharacter); NextX1++; } } break; } } } /* <режимы сортировки> */ if (/*GetNumericSort() || GetCaseSensitiveSort() || GetSortGroups() || */GetSelectedFirstMode()) { if (Opt.ShowColumnTitles) GotoXY(NextX1,Y1+1); else GotoXY(NextX1,Y1); SetColor(COL_PANELCOLUMNTITLE); wchar_t *PtrOutCharacter=OutCharacter; *PtrOutCharacter=0; //if (GetSelectedFirstMode()) *PtrOutCharacter++=L'^'; /* if(GetNumericSort()) *PtrOutCharacter++=L'#'; if(GetSortGroups()) *PtrOutCharacter++=L'@'; */ /* if(GetCaseSensitiveSort()) { } */ *PtrOutCharacter=0; Text(OutCharacter); PtrOutCharacter[1]=0; } /* </режимы сортировки> */ if (!Fast && GetFocus()) { if (PanelMode==PLUGIN_PANEL) CtrlObject->CmdLine->SetCurDir(Info.CurDir); else CtrlObject->CmdLine->SetCurDir(strCurDir); CtrlObject->CmdLine->Show(); } int TitleX2=Opt.Clock && !Opt.ShowMenuBar ? Min(ScrX-4,X2):X2; int TruncSize=TitleX2-X1-3; if (!Opt.ShowColumnTitles && Opt.ShowSortMode && Filter && Filter->IsEnabledOnPanel()) TruncSize-=2; GetTitle(strTitle,TruncSize,2);//,(PanelMode==PLUGIN_PANEL?0:2)); Length=(int)strTitle.GetLength(); int ClockCorrection=FALSE; if ((Opt.Clock && !Opt.ShowMenuBar) && TitleX2==ScrX-4) { ClockCorrection=TRUE; TitleX2+=4; } int TitleX=X1+(TitleX2-X1+1-Length)/2; if (ClockCorrection) { int Overlap=TitleX+Length-TitleX2+5; if (Overlap > 0) TitleX-=Overlap; } if (TitleX <= X1) TitleX = X1+1; SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); GotoXY(TitleX,Y1); Text(strTitle); if (!FileCount) { SetScreen(X1+1,Y2-1,X2-1,Y2-1,L' ',ColorIndexToColor(COL_PANELTEXT)); SetColor(COL_PANELTEXT); //??? //GotoXY(X1+1,Y2-1); //FS<<fmt::Width(X2-X1-1)<<L""; } if (PanelMode==PLUGIN_PANEL && FileCount>0 && (Info.Flags & OPIF_REALNAMES)) { if (!strInfoCurDir.IsEmpty()) { strCurDir = strInfoCurDir; } else { if (!TestParentFolderName(ListData[CurFile]->strName)) { strCurDir=ListData[CurFile]->strName; size_t pos; if (FindLastSlash(pos,strCurDir)) { if (pos) { if (strCurDir.At(pos-1)!=L':') strCurDir.SetLength(pos); else strCurDir.SetLength(pos+1); } } } else { strCurDir = strOriginalCurDir; } } if (GetFocus()) { CtrlObject->CmdLine->SetCurDir(strCurDir); CtrlObject->CmdLine->Show(); } } if ((Opt.ShowPanelTotals || Opt.ShowPanelFree) && (Opt.ShowPanelStatus || !SelFileCount)) { ShowTotalSize(Info); } ShowList(FALSE,0); ShowSelectedSize(); if (Opt.ShowPanelScrollbar) { SetColor(COL_PANELSCROLLBAR); ScrollBarEx(X2,Y1+1+Opt.ShowColumnTitles,Height,Round(CurTopFile,Columns),Round(FileCount,Columns)); } ShowScreensCount(); if (!ProcessingPluginCommand && LastCurFile!=CurFile) { LastCurFile=CurFile; UpdateViewPanel(); } if (PanelMode==PLUGIN_PANEL) CtrlObject->Cp()->RedrawKeyBar(); }
/** Set or reset "VolumeClean" (ClnShutBitmask) flag. @param aClean if ETrue, marks the volume as clean, otherwise as dirty. @leave if write error occured. */ void CFatMountCB::SetVolumeCleanL(TBool aClean) { //-- The volume can't be set clean if there are disk access objects opened on it. This precondition must be checked before calling this function if(aClean && Locked()) { __PRINT1(_L("#- CFatMountCB::SetVolumeCleanL drive:%d isn't free!"),DriveNumber()); ASSERT(0); User::Leave(KErrInUse); return; } if(FatType() == EFat12) {//-- Fat12 doesn't support this feature; do nothing other than notify the underlying drive (ignoring any error for now as there's nothing we can do with it) (void)LocalDrive()->Finalise(aClean); return; } //-- further read and write will be directly from the CProxyDrive, bypassing FAT cache. //-- this is because CFatTable doesn't allow access to FAT[0] & FAT[1] //-- We also need to write data through CProxyDrive, because TDriveInterface has a call back that can call this method if(Is32BitFat()) {//-- Fat32 __PRINT2(_L("#- CFatMountCB::SetVolumeCleanL, drive:%d, param:%d, FAT32"),DriveNumber(), aClean); TFat32Entry fatEntry; const TInt KFatEntrySize=sizeof(fatEntry); //-- FAT entry size in bytes TPtr8 ptrFatEntry((TUint8*)&fatEntry,KFatEntrySize); User::LeaveIfError(LocalDrive()->Read(StartOfFatInBytes()+KFatEntrySize, KFatEntrySize, ptrFatEntry)); //read FAT32[1] entry const TFat32Entry tmp = fatEntry; if(aClean) fatEntry |= KFat32CleanShutDownMask; //-- set ClnShutBit flag else fatEntry &= ~KFat32CleanShutDownMask; //-- reset ClnShutBit flag if(tmp != fatEntry) {//-- write FAT[1] entry to all available FATs for(TUint32 i=0; i<NumberOfFats(); ++i) { const TInt64 pos = StartOfFatInBytes()+KFatEntrySize+(FatSizeInBytes()*i); User::LeaveIfError(LocalDrive()->Write(pos, ptrFatEntry)); //write FAT32[1] entry } } __PRINT2(_L("#- CFatMountCB::SetVolumeCleanL() entry: %x->%x"), tmp, fatEntry); } else if(Is16BitFat()) {//-- Fat16. __PRINT2(_L("#- CFatMountCB::SetVolumeCleanL, drive:%d, param:%d, FAT16"),DriveNumber(), aClean); if(FatConfig().FAT16_UseCleanShutDownBit()) { TFat16Entry fatEntry; const TInt KFatEntrySize=sizeof(fatEntry); //-- FAT entry size in bytes TPtr8 ptrFatEntry((TUint8*)&fatEntry,KFatEntrySize); User::LeaveIfError(LocalDrive()->Read(StartOfFatInBytes()+KFatEntrySize, KFatEntrySize, ptrFatEntry)); //read FAT16[1] entry const TFat16Entry tmp = fatEntry; if(aClean) fatEntry |= KFat16CleanShutDownMask; //-- set ClnShutBit flag else fatEntry &= ~KFat16CleanShutDownMask; //-- reset ClnShutBit flag if(tmp != fatEntry) {//-- write FAT[1] entry to all available FATs for(TUint32 i=0; i<NumberOfFats(); ++i) { const TInt64 pos = StartOfFatInBytes()+KFatEntrySize+(FatSizeInBytes()*i); User::LeaveIfError(LocalDrive()->Write(pos, ptrFatEntry)); //write FAT16[1] entry } } __PRINT2(_L("#- CFatMountCB::SetVolumeCleanL() entry: %x->%x"), tmp, fatEntry); } else { __PRINT(_L("#- changing FAT16[1] is disabled in config!")); } } else {//-- must never get here ASSERT(0); } //-- Notify the underlying media that the mount is consistent (ignoring any error for now as there's nothing we can do with it) (void)LocalDrive()->Finalise(aClean); }