bool Field::MakeVisible() { bool wasAlreadyVisible = IsVisible(); _visible = true; return !(wasAlreadyVisible); //return TRUE if we just made this field visible }
bool GuiTextEdit::OnKeyEvent(const KeyEvent& ke) { if (!IsVisible()) { return false; } // Buttons can generate key events, so this GuiTextEdit object may not have the focus (the button // just clicked would have it). So the last GuiTextEdit to have the focus should accept this key. if (!HasFocus()) { #ifdef TEXT_EDIT_DEBUG std::cout << "Key event ignored by " << m_name << " as does not have focus.\n"; #endif return false; } // Is this the current or most recent GuiTextEdit to have focus ? // TODO if (!ke.keyDown) { return true; } switch (ke.keyType) { case AMJU_KEY_CHAR: // Prevent chars like Tab if (ke.key >= ' ') // && ke.key <= (char)127) { Insert(ke.key); } else { // TODO Alert user that character is out of range } break; case AMJU_KEY_UP: case AMJU_KEY_DOWN: // TODO Multi line text break; case AMJU_KEY_LEFT: #ifdef MACOSX if (ke.modifier & AMJU_KEY_MOD_ALT) // jump to prev word #else if (ke.modifier & AMJU_KEY_MOD_CTRL) #endif { // Prev word if (ke.modifier & AMJU_KEY_MOD_SHIFT) { #ifdef TEXT_EDIT_DEBUG std::cout << "Prev word + select\n"; #endif m_caret = PrevWord(m_caret); m_triListSelection = 0; } else { #ifdef TEXT_EDIT_DEBUG std::cout << "Prev word\n"; #endif m_caret = PrevWord(m_caret); m_selectedText = m_caret; m_triListSelection = 0; } } else if (ke.modifier & AMJU_KEY_MOD_SHIFT) { #ifdef TEXT_EDIT_DEBUG std::cout << "Prev char + select\n"; #endif // Select char to left if (m_caret > 0) { m_caret--; m_triListSelection = 0; } } else { #ifdef TEXT_EDIT_DEBUG std::cout << "Prev char\n"; #endif if (m_caret > 0) { // Move caret left m_caret--; m_selectedText = m_caret; m_triListSelection = 0; } } break; case AMJU_KEY_RIGHT: #ifdef MACOSX if (ke.modifier & AMJU_KEY_MOD_ALT) // jump to next word #else if (ke.modifier & AMJU_KEY_MOD_CTRL) #endif { // Next word if (ke.modifier & AMJU_KEY_MOD_SHIFT) { #ifdef TEXT_EDIT_DEBUG std::cout << "Next word + select\n"; #endif m_caret = NextWord(m_caret); m_triListSelection = 0; } else { #ifdef TEXT_EDIT_DEBUG std::cout << "Next word\n"; #endif m_caret = NextWord(m_caret); m_selectedText = m_caret; m_triListSelection = 0; } } else if (ke.modifier & AMJU_KEY_MOD_SHIFT) { #ifdef TEXT_EDIT_DEBUG std::cout << "Next char + select\n"; #endif if (m_caret < (int)m_text.size()) { m_caret++; m_triListSelection = 0; } } else { #ifdef TEXT_EDIT_DEBUG std::cout << "Next char\n"; #endif if (m_caret < (int)m_text.size()) { m_caret++; m_selectedText = m_caret; m_triListSelection = 0; } } break; case AMJU_KEY_ENTER: // TODO multi-line ExecuteCommand(); break; case AMJU_KEY_SPACE: Insert(' '); break; case AMJU_KEY_ESC: // OnCancel(); break; case AMJU_KEY_BACKSPACE: { int left = std::min(m_caret, m_selectedText); int right = std::max(m_caret, m_selectedText); if (left == right && m_caret > 0) { left--; } std::string leftStr = m_text.substr(0, left); std::string rightStr = m_text.substr(right); m_text = leftStr + rightStr; m_caret = left; m_selectedText = m_caret; m_triListSelection = 0; if (m_onChangeFunc) { m_onChangeFunc(this); } m_triList = 0; // force rebuild } break; case AMJU_KEY_DELETE: //if () { int left = std::min(m_caret, m_selectedText); int right = std::max(m_caret, m_selectedText); if (left == right && m_caret < (int)m_text.size()) { right++; } std::string leftStr = m_text.substr(0, left); std::string rightStr = m_text.substr(right); m_text = leftStr + rightStr; m_caret = left; m_selectedText = m_caret; m_triListSelection = 0; if (m_onChangeFunc) { m_onChangeFunc(this); } m_triList = 0; // force rebuild } break; default: #ifdef _DEBUG std::cout << "Unexpected key type: " << ke.keyType << " key: '" << ke.key << "' (int: " << (int)ke.key << ")\n"; #endif // Assert(0); // handle this key ? break; } if (m_caret >= m_last || m_caret <= m_first) { RecalcFirstLast(); } return true; // handled }
void CActiveXUI::SetInternVisible(bool bVisible) { CControlUI::SetInternVisible(bVisible); if( m_hwndHost != NULL && !m_pControl->m_bWindowless ) ::ShowWindow(m_hwndHost, IsVisible() ? SW_SHOW : SW_HIDE); }
void CEditUI::SetVisible(bool bVisible) { CControlUI::SetVisible(bVisible); if( !IsVisible() && m_pWindow != NULL ) m_pManager->SetFocus(NULL); }
void Container::_OnSetSize() { if (IsVisible()) UpdateAllChildSizes(); }
HRESULT UIPdfTrimColumnedDlg::Draw(DK_IMAGE drawingImg) { DebugPrintf(DLC_ZHY,"enter %s::%s,%s(%d)",GetClassName(), __FUNCTION__, __FILE__, __LINE__); if (!IsVisible()) return S_OK; HRESULT hr(S_OK); CTpGraphics grf(drawingImg); DK_IMAGE imgSelf; DK_RECT rcSelf={m_iLeft, m_iTop, m_iLeft + m_iWidth, m_iTop + m_iHeight}; RTN_HR_IF_FAILED(CropImage(drawingImg, rcSelf, &imgSelf)); RTN_HR_IF_FAILED(DrawBackGround(imgSelf)); //draw flag SPtr<ITpImage> spImageCursor = ImageManager::GetImage(IMAGE_PDF_LOCATE_CURSOR); int w = spImageCursor->GetWidth(); int h = spImageCursor->GetHeight(); if (m_bIsActionFinished) { m_btnConfirmed.SetVisible(true); m_btnCancel.SetVisible(true); RTN_HR_IF_FAILED(m_btnConfirmed.Draw(imgSelf)); RTN_HR_IF_FAILED(m_btnCancel.Draw(imgSelf)); } else { m_btnConfirmed.SetVisible(false); m_btnCancel.SetVisible(false); } //draw lines if (m_iCurAction == PdfTrimAction) { //Trim grf.DrawImage(spImageCursor.Get(), m_iLeftCuttingEdge - w/2, m_iTopCuttingEdge -h/2); grf.DrawImage(spImageCursor.Get(), m_iRightCuttingEdge - w/2, m_iBottomCuttingEdge - h/2); DebugPrintf(DLC_ZHY,"rect,left,top,right,bottom:%d,%d,%d,%d",m_iLeftCuttingEdge, m_iTopCuttingEdge, m_iRightCuttingEdge, m_iBottomCuttingEdge); grf.DrawLine(m_iLeftCuttingEdge, m_iTop, 2, m_iHeight, SOLID_STROKE); grf.DrawLine(m_iRightCuttingEdge, m_iTop, 2, m_iHeight, SOLID_STROKE); grf.DrawLine(m_iLeft, m_iTopCuttingEdge, m_iWidth, 2, SOLID_STROKE); grf.DrawLine(m_iLeft, m_iBottomCuttingEdge, m_iWidth, 2, SOLID_STROKE); } else { grf.DrawLine(m_iColumnedX, m_iTop, 2, m_iHeight, SOLID_STROKE); grf.DrawImage(spImageCursor.Get(), m_iColumnedX - w/2, m_iColumnedY - h/2); if (m_iCurAction==PdfColumnedComicOrderLR || m_iCurAction==PdfColumnedComicOrderRL) { //split to 2 pages } else { //split to 4 pages grf.DrawLine(m_iLeft, m_iColumnedY, m_iWidth, 2, SOLID_STROKE); } } if (m_btnTips.IsVisible()) m_btnTips.SetVisible(false); DebugPrintf(DLC_ZHY,"leave %s::%s,%s(%d)",GetClassName(), __FUNCTION__, __FILE__, __LINE__); return hr; }
int Win::DoModal() { WinID lastParentFC = parent ? parent->lastFocusChild : 0; bool visibled = IsVisible(); bool enabled = IsEnabled(); try { if (!visibled) Show(); if (!enabled) Enable(true); if (parent && type != WT_POPUP) parent->RecalcLayouts(); AppBlock(GetID()); UnblockTree(GetID()); ModalStruct modalStruct; modal = &modalStruct; MSG msg; while (!modalStruct.end) { wth_DoEvents(); if (modalStruct.end) break; if (!PeekMessage(&msg, NULL, 0, 0,PM_NOREMOVE)) { unsigned waitTime = RunTimers(); if (waitTime > 5000) waitTime = 5000; if (modalStruct.end) break; HANDLE thEvent = wthInternalEvent.SignalFD(); DWORD res = MsgWaitForMultipleObjects(1,&thEvent,FALSE, waitTime, QS_ALLINPUT); if (res == WAIT_TIMEOUT) CheckMousePosition(); continue; } if (!GetMessage(&msg, NULL, 0, 0)) break; DispatchMessage(&msg); } modal = 0; AppUnblock(GetID()); if (!visibled) Hide(); /// if (type == WT_POPUP || type == WT_CHILD && parent) { Win *w = GetWinByID(lastParentFC); if (w) w->SetFocus(); } return modalStruct.id; } catch (...) { modal = 0; AppUnblock(GetID()); if (!visibled) Hide(); throw; } }
/*@Function============================================================ @Desc: PutEnemy: This function draws an enemy into the combat window. The only parameter given is the number of the enemy within the AllEnemys array. Everything else is computed in here. @Ret: void * $Function----------------------------------------------------------*/ void PutEnemy (int Enum , int x , int y) { SDL_Rect dst; enemy *droid = &AllEnemys[Enum]; int type = droid->type; int phase = droid->phase; char *name = Druidmap[type].druidname; if ( (droid->status == TERMINATED) || (droid->status == OUT) || (droid->levelnum != CurLevel->levelnum) ) return; // if the enemy is out of sight, we need not do anything more here if ((!show_all_droids) && (!IsVisible (&AllEnemys[Enum].pos)) ) { DebugPrintf (3, "\nvoid PutEnemy(int Enum): ONSCREEN=FALSE --> usual end of function reached.\n"); return; } // We check for incorrect droid types, which sometimes might occor, especially after // heavy editing of the crew initialisation functions ;) if ( droid->type >= Number_Of_Droid_Types ) { DebugPrintf (0, "ERROR: nonexistant droid-type encountered: %d\n", droid->type); Terminate(ERR); } //-------------------- // First blit just the enemy hat and shoes. SDL_BlitSurface (EnemySurfacePointer[phase], NULL, BuildBlock, NULL); //-------------------- // Now the numbers should be blittet. dst.x = FirstDigit_Rect.x; dst.y = FirstDigit_Rect.y; SDL_BlitSurface( EnemyDigitSurfacePointer[name[0]-'1'+1 ], NULL, BuildBlock, &dst); dst.x = SecondDigit_Rect.x; dst.y = SecondDigit_Rect.y; SDL_BlitSurface( EnemyDigitSurfacePointer[name[1]-'1'+1 ], NULL, BuildBlock, &dst); dst.x = ThirdDigit_Rect.x; dst.y = ThirdDigit_Rect.y; SDL_BlitSurface( EnemyDigitSurfacePointer[name[2]-'1'+1], NULL, BuildBlock, &dst); // now blit the whole construction to screen: if ( x == -1 ) { dst.x=UserCenter_x + (droid->pos.x - Me.pos.x) * Block_Rect.w - Block_Rect.w/2; dst.y=UserCenter_y + (droid->pos.y - Me.pos.y) * Block_Rect.h - Block_Rect.h/2; } else { dst.x=x ; dst.y=y ; } SDL_BlitSurface (BuildBlock, NULL, ne_screen, &dst); //-------------------- // At this point we can assume, that the enemys has been blittet to the // screen, whether it's a friendly enemy or not. // // So now we can add some text the enemys says. That might be fun. // if ( (x == -1) && ( AllEnemys[Enum].TextVisibleTime < GameConfig.WantedTextVisibleTime ) && GameConfig.Droid_Talk ) { PutStringFont ( ne_screen , Font0_BFont , User_Rect.x+(User_Rect.w/2) + Block_Rect.w/3 + (AllEnemys[Enum].pos.x - Me.pos.x) * Block_Rect.w , User_Rect.y+(User_Rect.h/2) - Block_Rect.h/2 + (AllEnemys[Enum].pos.y - Me.pos.y) * Block_Rect.h , AllEnemys[Enum].TextToBeDisplayed ); } DebugPrintf (2, "\nvoid PutEnemy(int Enum): ENEMY HAS BEEN PUT --> usual end of function reached.\n"); } // void PutEnemy(int Enum , int x , int y)
void Assemble_Combat_Picture (int mask) { int MapBrick; int line, col; int i; static float TimeSinceLastFPSUpdate=10; static int FPS_Displayed=1; SDL_Rect TargetRectangle; SDL_Rect TxtRect; finepoint pos, vect; float len; bool vis = TRUE; grob_point upleft, downright; #define UPDATE_FPS_HOW_OFTEN 0.75 DebugPrintf (2, "\nvoid Assemble_Combat_Picture(...): Real function call confirmed."); SDL_SetClipRect (ne_screen , &User_Rect); if ( !GameConfig.AllMapVisible ) Fill_Rect (User_Rect, Black); if ( (mask & SHOW_FULL_MAP) != 0 ) { upleft.x = -5; upleft.y = -5; downright.x = CurLevel->xlen + 5; downright.y = CurLevel->ylen + 5; } else { upleft.x = Me.pos.x - 6; upleft.y = Me.pos.y - 5; downright.x = Me.pos.x + 7; downright.y = Me.pos.y + 5; } for (line = (int)upleft.y; line < (int)downright.y; line++) { for (col = (int)upleft.x; col < (int)downright.x; col++) { vis = TRUE; if ( !GameConfig.AllMapVisible && ( (mask & SHOW_FULL_MAP) == 0x0) ) { pos.x = col; pos.y = line; vect.x = Me.pos.x - pos.x; vect.y = Me.pos.y - pos.y; len = sqrt( vect.x * vect.x + vect.y * vect.y) + 0.01; vect.x /= len; vect.y /= len; if (len > 0.5) { pos.x += vect.x; pos.y += vect.y; } if ( !IsVisible (&pos) ) continue; } MapBrick = GetMapBrick( CurLevel, col , line ); TargetRectangle.x = UserCenter_x + (int)rint( (-Me.pos.x+1.0*col-0.5 )*Block_Rect.w); TargetRectangle.y = UserCenter_y + (int)rint( (-Me.pos.y+1.0*line-0.5 )*Block_Rect.h); SDL_BlitSurface( MapBlockSurfacePointer[CurLevel->color][MapBrick], NULL, ne_screen, &TargetRectangle); } // for(col) } // for(line) // if we don't use Fullscreen mode, we have to clear the text-background manually // for the info-line text: TxtRect.x = Full_User_Rect.x; TxtRect.y = Full_User_Rect.y+Full_User_Rect.h - FontHeight (Font0_BFont); TxtRect.h = FontHeight (Font0_BFont); TxtRect.w = Full_User_Rect.w; SDL_SetClipRect (ne_screen, &TxtRect); if (!GameConfig.FullUserRect) SDL_FillRect(ne_screen, &TxtRect, 0); if ( GameConfig.Draw_Position ) { PrintStringFont( ne_screen , Font0_BFont , Full_User_Rect.x+Full_User_Rect.w/6 , Full_User_Rect.y+Full_User_Rect.h - FontHeight( Font0_BFont ), "GPS: X=%d Y=%d Lev=%d" , (int) rintf(Me.pos.x) , (int) rintf(Me.pos.y) , CurLevel->levelnum ); } if (!(mask & ONLY_SHOW_MAP) ) { if ( GameConfig.Draw_Framerate ) { TimeSinceLastFPSUpdate += Frame_Time(); if ( TimeSinceLastFPSUpdate > UPDATE_FPS_HOW_OFTEN ) { FPS_Displayed=(int)(1.0/Frame_Time()); TimeSinceLastFPSUpdate=0; } PrintStringFont( ne_screen , Font0_BFont , Full_User_Rect.x , Full_User_Rect.y+Full_User_Rect.h - FontHeight( Font0_BFont ), "FPS: %d " , FPS_Displayed ); } if ( GameConfig.Draw_Energy ) { PrintStringFont( ne_screen , Font0_BFont , Full_User_Rect.x+Full_User_Rect.w/2 , Full_User_Rect.y+Full_User_Rect.h - FontHeight( Font0_BFont ), "Energy: %d" , (int)Me.energy); } if (GameConfig.Draw_DeathCount) { PrintStringFont( ne_screen , Font0_BFont , Full_User_Rect.x+2*Full_User_Rect.w/3 , Full_User_Rect.y+Full_User_Rect.h - FontHeight( Font0_BFont ), "Deathcount: %d", (int)DeathCount ); } SDL_SetClipRect (ne_screen, &User_Rect); // make sure Ashes are displayed _before_ droids, so that they are _under_ them! for (i = 0; i < NumEnemys ; i++) if ( (AllEnemys[i].status == TERMINATED) && (AllEnemys[i].levelnum == CurLevel->levelnum) ) { if (IsVisible (&(AllEnemys[i].pos) ) ) PutAshes (AllEnemys[i].pos.x, AllEnemys[i].pos.y); } for (i = 0; i < NumEnemys ; i++) if ( (AllEnemys[i].levelnum != CurLevel->levelnum) || (AllEnemys[i].status == OUT) || (AllEnemys[i].status == TERMINATED) ) continue; else PutEnemy (i , -1 , -1 ); if (Me.energy > 0) PutInfluence ( -1 , -1 ); for (i = 0; i < (MAXBULLETS); i++) if (AllBullets[i].type != OUT) PutBullet (i); for (i = 0; i < (MAXBLASTS); i++) if (AllBlasts[i].type != OUT) PutBlast (i); } // At this point we are done with the drawing procedure // and all that remains to be done is updating the screen. if ( mask & DO_SCREEN_UPDATE ) { SDL_UpdateRect (ne_screen, User_Rect.x, User_Rect.y, User_Rect.w, User_Rect.h); SDL_UpdateRect (ne_screen, TxtRect.x, TxtRect.y, TxtRect.w, TxtRect.h); } SDL_SetClipRect (ne_screen, NULL); return; } // void Assemble_Combat_Picture(...)
// Give Exp bool CWorldServer::GiveExp( CMonster* thismon, UINT special_lvl, UINT special_exp ) { if( thismon->owner != 0) // Summon { MapList.Index[thismon->Position->Map]->DeleteMonster( thismon ); return true; } //LMA TEST bool lma_debug=false; if(thismon->Position->respawn == 4589) { lma_debug=true; Log(MSG_INFO,"GiveExp Spawn %u CID %u",thismon->Position->respawn,thismon->clientid); } // Give Experience Drops and Quest Items vector<CPartyExp*> PartyExp; for(UINT i=0;i<thismon->PlayersDamage.size();i++) { MonsterDamage* thisplayer = thismon->PlayersDamage.at(i); CPlayer* thisclient = GetClientByCID( thisplayer->charid, thismon->Position->Map ); //LMA: Player mustn't be dead. if( thisplayer->damage > 0 && thisclient != NULL && !thisclient->IsDead()) { if( thisclient->Battle->target == thismon->clientid ) { ClearBattle( thisclient->Battle ) thisclient->Position->destiny = thisclient->Position->current; //GIVE EXP FUNCTION } if( thismon->MonsterDrop->firsthit == thisclient->CharInfo->charid ) { for( int q=0;q<10;q++) { // Give Quest Item if( thisclient->quest.quests[q].QuestID != 0 ) { BEGINPACKET( pak, 0x731 ) ADDWORD ( pak, thismon->montype ); thisclient->client->SendPacket( &pak ); break; } } } //LMA BEGIN //20070621-211100 //mods for CF... //unsigned int exp = (unsigned int)ceil((thismon->thisnpc->exp * thisplayer->damage) / (thismon->thisnpc->hp*thismon->thisnpc->level)+special_exp); unsigned long long exp = (unsigned long long)ceil((double)(thismon->thisnpc->exp * thisplayer->damage) / (thismon->thisnpc->hp*thismon->thisnpc->level)+special_exp); //LMA END /*unsigned int cp = (unsigned int)ceil((thismon->thisnpc->level/6 * thisplayer->damage) / thismon->thisnpc->hp); //ADD Clan points under any condition if ((thismon->Position->Map>=11 && thismon->Position->Map<= 13) || thismon->Position->Map== 59) //So far only junon maps { thisclient->AddClanPoints(GetColorExp( cp)); }*/ exp = exp * (unsigned long long) (Config.EXP_RATE * 6); if( thisclient->Party->party!=NULL ) { bool pflag = false; for(int i=0;i<PartyExp.size();i++) { CPartyExp* thisparty = PartyExp.at( i ); if( thisparty->thisparty == thisclient->Party->party ) { //LMA: We get exp only if we deserve it. //thisparty->exp += exp; thisparty->exp += GetColorExp( thisclient->Stats->Level, thismon->thisnpc->level + special_lvl, exp ); //LMA: bug... //thisparty->exp += exp * (unsigned long long) ((thisclient->Party->party->PartyLevel*2) / 100); thisparty->exp += (unsigned long long) ((exp*thisclient->Party->party->PartyLevel*2) / 100); pflag = true; } } if( !pflag ) { CPartyExp* thisparty = new CPartyExp; thisparty->thisparty = thisclient->Party->party; //LMA: We get exp only if we deserve it. thisparty->exp = exp; thisparty->exp = GetColorExp( thisclient->Stats->Level, thismon->thisnpc->level + special_lvl, exp ); thisparty->flag = false; //LMA: bug //thisparty->exp += exp * (unsigned long long) ((thisclient->Party->party->PartyLevel*2) / 100); thisparty->exp += (unsigned long long) ((exp*thisclient->Party->party->PartyLevel*2) / 100); thisparty->num = 1; thisparty->partymember[0] = thisclient->CharInfo->charid; thisparty->cheat_max_lvl=thisclient->Stats->Level; thisparty->cheat_min_lvl=thisclient->Stats->Level; thisparty->maxlevel = thisclient->Stats->Level; for(unsigned int p=0;p<ClientList.size();p++) { CPlayer* otherclient = (CPlayer*) ClientList.at( p )->player; if(otherclient->client==NULL) continue; if(otherclient->Party->party==NULL) continue; if(!otherclient->client->isActive) continue; if(!otherclient->Session->inGame) continue; //LMA: checking the gap between the max and min level of people in the party. if (thisclient->Party->party == otherclient->Party->party) { if(otherclient->Stats->Level>thisparty->cheat_max_lvl) { thisparty->cheat_max_lvl=otherclient->Stats->Level; } if(otherclient->Stats->Level<thisparty->cheat_min_lvl) { thisparty->cheat_min_lvl=otherclient->Stats->Level; } } if( IsVisible(thisclient, otherclient)) { if(thisclient->Party->party == otherclient->Party->party ) { //LMA: Little stupid check. if (thisparty->num==7) { Log(MSG_WARNING,"Too many people in this party, already at max, skipping"); break; } thisparty->partymember[thisparty->num] = otherclient->CharInfo->charid; thisparty->num++; thisparty->maxlevel += otherclient->Stats->Level; } } } PartyExp.push_back( thisparty ); } continue; } //LMA BEGIN //20070621-211100 //mod for CF //Adding bonusxp (mileage) //UINT prev_xp=thisclient->CharInfo->Exp; //LMA: Xp nullifier. if(!thisclient->no_exp) { int tempexp = thisclient->bonusxp*GetColorExp( thisclient->Stats->Level, thismon->thisnpc->level + special_lvl, exp ); if (tempexp <= 0) tempexp = thismon->thisnpc->exp; thisclient->CharInfo->Exp += tempexp; } //Log(MSG_INFO,"Bonus XP %i, previous XP, %i, new: %i",thisclient->bonusxp,prev_xp,thisclient->CharInfo->Exp); //LMA END //LMA: We don't send exp packet if there is a level up coming up next. if(thisclient->CharInfo->Exp < thisclient->GetLevelEXP()) { //LMA: TEST //Log(MSG_INFO,"new exp in giveexp %I64i",thisclient->CharInfo->Exp); BEGINPACKET( pak, 0x79b ); ADDDWORD ( pak, thisclient->CharInfo->Exp ); ADDWORD ( pak, thisclient->CharInfo->stamina ); //ADDWORD ( pak, 0 ); ADDWORD ( pak, thismon->clientid ); thisclient->client->SendPacket( &pak ); } } } for(int p=0;p<PartyExp.size();p++) { CPartyExp* thisparty = PartyExp.at( p ); //LMA: no exp if a player has a too low level... This is another version in this case, NONE of the guys got exp... //HIGHRATEPARTYEXPNONE /*if(abs(thisparty->cheat_min_lvl-thisparty->cheat_max_lvl)>(Config.Partygap+1)) { Log(MSG_HACK,"A Party tryes to get exp which has min_lvl %i and max_lvl %i that don't fit max gap %i",thisparty->cheat_min_lvl,thisparty->cheat_max_lvl,Config.Partygap+1); continue; }*/ //LMA: End of HIGHRATEPARTYEXPNONE. for(int i=0;i<thisparty->num;i++) { CPlayer* partyclient = GetClientByCID( thisparty->partymember[i], thismon->Position->Map ); if( partyclient==NULL ) continue; if(partyclient->Party->party==NULL) continue; //LMA: no exp if a player has a too low level... //Uncomment this part of code below if you want to use it... (HIGHRATEPARTYEXP) /*if(abs(partyclient->Stats->Level-thisparty->cheat_max_lvl)>(Config.Partygap+1)) { Log(MSG_HACK,"Player %s is lvl %i and tryes to get exp in a party which has max_lvl %i and max gap %i",partyclient->CharInfo->charname,partyclient->Stats->Level,thisparty->cheat_max_lvl,Config.Partygap+1); continue; }*/ //Uncomment should end here for HIGHRATEPARTYEXP. if(!thisparty->flag) { //partyclient->Party->party->Exp += (thisparty->exp / 6) / 2; partyclient->Party->party->Exp += (thisparty->exp / 6) / 6; //Tomiz: thisparty->exp decreased if( partyclient->Party->party->PartyLevel == 50) { partyclient->Party->party->Exp = 0; } //LMA: old code /*if( partyclient->Party->party->Exp > GetMaxPartyExp( partyclient->Party->party->PartyLevel ) ) { partyclient->Party->party->PartyLevel++; partyclient->Party->party->Exp -= GetMaxPartyExp( partyclient->Party->party->PartyLevel-1 ); } */ //New code. bool new_level=false; while(partyclient->Party->party->PartyLevel<50&&partyclient->Party->party->Exp > GetMaxPartyExp( partyclient->Party->party->PartyLevel ) ) { partyclient->Party->party->PartyLevel++; partyclient->Party->party->Exp -= GetMaxPartyExp( partyclient->Party->party->PartyLevel-1 ); Log(MSG_INFO,"Going from party level %i to %i, exp left %I64i",partyclient->Party->party->PartyLevel-1,partyclient->Party->party->PartyLevel,partyclient->Party->party->Exp); new_level=true; } if( partyclient->Party->party->PartyLevel == 50) { partyclient->Party->party->Exp = 0; } //Strange thing when a new level: unsigned long long send_exp=partyclient->Party->party->Exp; if(new_level) { send_exp+=0x80000000; } Log(MSG_INFO,"Exp sent: %I64i",send_exp); //End of code. BEGINPACKET( pak, 0x7d4 ); ADDBYTE ( pak, partyclient->Party->party->PartyLevel ); //LMA: little change. //ADDDWORD ( pak, partyclient->Party->party->Exp ); ADDDWORD ( pak, send_exp ); partyclient->Party->party->SendToMembers( &pak ); thisparty->flag = true; } //LMA: no exp for dead people. if(partyclient->IsDead()) { Log(MSG_INFO,"No exp for player %s, he's dead.",partyclient->CharInfo->charname); continue; } //LMA Begin //20070621-211100 //mods for CF unsigned int expoption = partyclient->Party->party->Option%0x80; //LMA: Exp nullfier. if(!partyclient->no_exp) { if( expoption==0 ) { partyclient->CharInfo->Exp += GetColorExp( partyclient->Stats->Level, thismon->Stats->Level + special_lvl, (UINT)round(thisparty->exp / thisparty->num) ); } else { partyclient->CharInfo->Exp += GetColorExp( partyclient->Stats->Level, thismon->Stats->Level + special_lvl, (UINT)round(partyclient->Stats->Level * thisparty->exp / thisparty->maxlevel) ); } } //LMA END if(partyclient->CharInfo->Exp<partyclient->GetLevelEXP()) { //LMA: TEST //Log(MSG_INFO,"new exp in giveexp %I64i",partyclient->CharInfo->Exp); BEGINPACKET( pak, 0x79b ); ADDDWORD ( pak, partyclient->CharInfo->Exp ); ADDWORD ( pak, partyclient->CharInfo->stamina ); //ADDWORD ( pak, 0 ); ADDWORD ( pak, thismon->clientid ); partyclient->client->SendPacket( &pak ); } } } //LMA: cleaning time. for(int p=0;p<PartyExp.size();p++) { //It seems it's ok, the class party destructor isn't beeing called... delete PartyExp.at(p); } if (lma_debug) { Log(MSG_INFO,"END GiveExp Spawn %u CID %u",thismon->Position->respawn,thismon->clientid); } //PY: This bloody line of code has been driving me mad by deleting monsters out of time and place. Good ridance to it. More lmame stuff i suspect //MapList.Index[thismon->Position->Map]->DeleteMonster( thismon ); return true; }
bool CGUIRenderingControl::CanFocusFromPoint(const CPoint &point) const { // mouse is allowed to focus this control, but it doesn't actually receive focus return IsVisible() && HitTest(point); }
void UserIDScreenInterface::Create ( ComputerScreen *newcs ) { UplinkAssert ( newcs ); cs = newcs; if ( !IsVisible () ) { EclRegisterButton ( 130, 90, 320, 25, GetComputerScreen ()->maintitle, "", "useridscreen_maintitle" ); EclRegisterButtonCallbacks ( "useridscreen_maintitle", DrawMainTitle, NULL, NULL, NULL ); EclRegisterButton ( 130, 110, 320, 20, GetComputerScreen ()->subtitle, "", "useridscreen_subtitle" ); EclRegisterButtonCallbacks ( "useridscreen_subtitle", DrawSubTitle, NULL, NULL, NULL ); EclRegisterButton ( 168, 155, 220, 120, "", "", "useridscreen_image" ); button_assignbitmap ( "useridscreen_image", "userid.tif" ); EclRegisterButtonCallbacks ( "useridscreen_image", imagebutton_draw, CodeButtonClick, button_click, button_highlight ); EclRegisterButton ( 227, 210, 148, 15, "", "Enter your userID here", "useridscreen_name" ); EclRegisterButtonCallbacks ( "useridscreen_name", UserIDButtonDraw, CodeButtonClick, button_click, button_highlight ); EclRegisterButton ( 227, 236, 148, 15, "", "Enter your access code here", "useridscreen_code" ); EclRegisterButtonCallbacks ( "useridscreen_code", CodeButtonDraw, CodeButtonClick, button_click, button_highlight ); EclRegisterButton ( 168, 280, 120, 15, "", "", "useridscreen_message" ); EclRegisterButtonCallbacks ( "useridscreen_message", textbutton_draw, NULL, NULL, NULL ); EclRegisterButton ( 308, 280, 80, 15, "Proceed", "Click here when done", "useridscreen_proceed" ); button_assignbitmaps ( "useridscreen_proceed", "proceed.tif", "proceed_h.tif", "proceed_c.tif" ); EclRegisterButtonCallback ( "useridscreen_proceed", ProceedClick ); EclMakeButtonEditable ( "useridscreen_name" ); EclMakeButtonEditable ( "useridscreen_code" ); // Create the box that will show the currently known codes for this screen UplinkAssert ( cs->GetComputer () ); if ( game->GetWorld ()->GetPlayer ()->codes.LookupTree ( cs->GetComputer ()->ip ) ) { DArray <char *> *codes = game->GetWorld ()->GetPlayer ()->codes.ConvertToDArray (); DArray <char *> *ips = game->GetWorld ()->GetPlayer ()->codes.ConvertIndexToDArray (); EclRegisterButton ( 200, 310, 250, 15, "Known Access Codes", "", "useridscreen_codestitle" ); EclRegisterButtonCallbacks ( "useridscreen_codestitle", textbutton_draw, NULL, NULL, NULL ); int currentcode = 0; for ( int i = 0; i < codes->Size (); ++i ) { if ( codes->ValidIndex (i) && ips->ValidIndex (i) ) { if ( strcmp ( ips->GetData (i), cs->GetComputer ()->ip ) == 0 ) { char name [64]; UplinkSnprintf ( name, sizeof ( name ), "useridscreen_code %d", currentcode ); EclRegisterButton ( 200, 330 + currentcode*15, 250, 15, codes->GetData (i), "Use this code", name ); EclRegisterButtonCallbacks ( name, textbutton_draw, AccessCodeClick, button_click, button_highlight ); ++currentcode; } } } delete codes; delete ips; } #ifdef CHEATMODES_ENABLED // Create a symbol for quick entry into this screen EclRegisterButton ( 3, 20, 30, 15, "#", "Click here to bypass this screen (DEBUG MODE ONLY)", "useridscreen_bypass" ); EclRegisterButtonCallbacks ( "useridscreen_bypass", textbutton_draw, BypassClick, button_click, button_highlight ); #endif } }
void CriminalScreenInterface::Update () { if ( searchname && IsVisible () ) { int timems = (int)EclGetAccurateTime () - lastupdate; if ( timems > 100 ) { // We are searching for a record // Is this one it? Computer *comp = game->GetWorld ()->GetComputer ( "Global Criminal Database" ); UplinkAssert (comp); // Have we searched all records? //if ( recordindex == comp->recordbank.records.Size () ) { if ( recordindex == -1 ) { delete [] searchname; searchname = NULL; recordindex = -1; return; } Record *rec = comp->recordbank.GetRecord ( recordindex ); char *thisname = rec->GetField ( RECORDBANK_NAME ); UplinkAssert (thisname); char *lowercasethisname = LowerCaseString (thisname); // Update display with the current record UpdateScreen (); if ( strcmp ( searchname, lowercasethisname ) == 0 ) { // Record found - stop searching delete [] searchname; searchname = NULL; } else { // Record not found //recordindex++; recordindex = comp->recordbank.FindNextRecordIndexNameNotSystemAccount ( recordindex ); } delete [] lowercasethisname; lastupdate = (int)EclGetAccurateTime (); } } }
void CriminalScreenInterface::Create ( ComputerScreen *newcs ) { UplinkAssert (newcs); cs = newcs; if ( !IsVisible () ) { // Draw the screen titles EclRegisterButton ( 80, 60, 350, 25, GetComputerScreen ()->maintitle, "", "criminalscreen_maintitle" ); EclRegisterButtonCallbacks ( "criminalscreen_maintitle", DrawMainTitle, NULL, NULL, NULL ); EclRegisterButton ( 80, 80, 350, 20, GetComputerScreen ()->subtitle, "", "criminalscreen_subtitle" ); EclRegisterButtonCallbacks ( "criminalscreen_subtitle", DrawSubTitle, NULL, NULL, NULL ); EclRegisterButton ( 30, 130, 128, 160, "", "Shows the person's photograph", "criminal_photo" ); button_assignbitmap ( "criminal_photo", "photos/image0.tif" ); EclRegisterButton ( 180, 130, 210, 15, "Name", " ", "criminal_nametitle" ); EclRegisterButtonCallbacks ( "criminal_nametitle", button_draw, NULL, NULL, NULL ); EclRegisterButton ( 190, 146, 190, 38, " ", " ", "criminal_name" ); EclRegisterButtonCallbacks ( "criminal_name", NameDraw, NULL, NULL, NULL ); EclRegisterButton ( 180, 145, 210, 40, " ", " ", "criminal_nameborder" ); EclRegisterButtonCallbacks ( "criminal_nameborder", NameBorderDraw, NULL, NULL, NULL ); // History text box EclRegisterButton ( 180, 200, 210, 15, "Criminal History", "", "criminal_historytitle" ); EclRegisterButtonCallbacks ( "criminal_historytitle", button_draw, NULL, NULL, NULL ); EclRegisterButton ( 180, 215, 210, 140, "", "", "criminal_history" ); EclRegisterButtonCallbacks ( "criminal_history", HistoryDraw, NULL, NULL, NULL ); if ( game->GetInterface ()->GetRemoteInterface ()->security_level <= 2 ) { EclRegisterButton ( 180, 354, 180, 16, "", "Enter new convictions here", "criminal_newconvictiontext" ); EclRegisterButtonCallbacks ( "criminal_newconvictiontext", HistoryDraw, NULL, NULL, button_highlight ); EclRegisterButton ( 360, 355, 30, 15, "Add", "Click to add this conviction", "criminal_newconvictionadd" ); EclRegisterButtonCallback ( "criminal_newconvictionadd", AddConvictionClick ); // Control buttons EclRegisterButton ( 30, 315, 128, 15, "Clear history", "Click here to clear this man's record", "criminal_clear" ); EclRegisterButtonCallback ( "criminal_clear", ClearClick ); EclRegisterButton ( 30, 335, 128, 15, "Authorise Arrest", "Click here to authorise this man's arrest", "criminal_arrest" ); EclRegisterButtonCallback ( "criminal_arrest", ArrestClick ); } EclRegisterButton ( 30, 355, 128, 15, "Done", "Close this screen", "criminal_close" ); EclRegisterButtonCallback ( "criminal_close", CloseClick ); EclMakeButtonEditable ( "criminal_newconvictiontext" ); } }
HRESULT CWordObject::Release() { HRESULT hr; if (m_pUnknown == NULL) return S_OK; LPUNKNOWN lpUnk = NULL; if (m_pStrUnknown != NULL) { hr = CoGetInterfaceAndReleaseStream(m_pStrUnknown, IID_IUnknown, (void**) &lpUnk); if (FAILED(hr)) { LOG_WS_ERROR(_T("CoGetInterfaceAndReleaseStream FAILED.")); } } else { lpUnk = m_pUnknown; m_pWordCreator->AddRef(lpUnk); } try { m_pUnknown->Release(); m_pUnknown = NULL; } catch(...) { m_pUnknown = NULL; LOG_WS_ERROR(_T("m_pUnknown Failed to release")); } if (NULL == lpUnk) { LOG_WS_ERROR(_T("lpUnk == NULL")); return E_FAIL; } if (m_bUsingCurrentInstance) { hr = S_FALSE; } else if (!IsVisible(lpUnk)) { hr = Quit(lpUnk); } else { // If Word is visible, then only quit the cached Word instance if we are sure that // there aren't any manually opened documents. i.e. if the user has opened a document, // so that there is a visible instance of Word open while DeltaVw is still open. Word::_ApplicationPtr pApp = GetApplicationPtr(); if( pApp ) { long lNumDocs = pApp->Documents->Count; if( lNumDocs <= 0 ) { LOG_WS_INFO(L"No open documents found for the current Word instance. Quitting Word"); SetVisible(false); hr = Quit(lpUnk); } else { LOG_WS_INFO(L"Documents are still open in the current Word instance. NOT quitting Word"); } } } if (IsCachingWordEnabled()) m_pGit->RevokeInterfaceFromGlobal(m_dwSessionCookie); try { if (lpUnk) { lpUnk->Release(); lpUnk = NULL; } } catch(...) { lpUnk = NULL; LOG_WS_ERROR(_T("m_pUnknown Failed to release")); } // This is required to stop the DeltaView app tests from hanging Sleep(125); return hr; }
void CSVNStatusListCtrl::ColumnManager::ReadSettings ( DWORD defaultColumns , const CString& containerName) { // defaults DWORD selectedStandardColumns = defaultColumns; columns.resize (SVNSLC_NUMCOLUMNS); for (size_t i = 0; i < SVNSLC_NUMCOLUMNS; ++i) { columns[i].index = static_cast<int>(i); columns[i].width = 0; columns[i].visible = true; columns[i].relevant = true; } userProps.clear(); // where the settings are stored within the registry registryPrefix = L"Software\\TortoiseSVN\\StatusColumns\\" + containerName; // we accept only the current version bool valid = (DWORD)CRegDWORD (registryPrefix + L"Version", 0xff) == SVNSLC_COL_VERSION; if (valid) { // read (possibly different) column selection selectedStandardColumns = CRegDWORD (registryPrefix, selectedStandardColumns); // read user-prop lists CString userPropList = CRegString (registryPrefix + L"UserProps"); CString shownUserProps = CRegString (registryPrefix + L"ShownUserProps"); ParseUserPropSettings (userPropList, shownUserProps); // read column widths CString colWidths = CRegString (registryPrefix + L"_Width"); ParseWidths (colWidths); } // process old-style visibility setting SetStandardColumnVisibility (selectedStandardColumns); // clear all previously set header columns int c = ((CHeaderCtrl*)(control->GetDlgItem(0)))->GetItemCount()-1; while (c>=0) control->DeleteColumn(c--); // create columns for (int i = 0, count = GetColumnCount(); i < count; ++i) control->InsertColumn (i, GetName(i), LVCFMT_LEFT, IsVisible(i) ? -1 : GetVisibleWidth(i, false)); // restore column ordering if (valid) ParseColumnOrder (CRegString (registryPrefix + L"_Order")); else ParseColumnOrder (CString()); ApplyColumnOrder(); // auto-size the columns so we can see them while fetching status // (seems the same values will not take affect in InsertColumn) for (int i = 0, count = GetColumnCount(); i < count; ++i) if (IsVisible(i)) control->SetColumnWidth (i, GetVisibleWidth (i, true)); }
bool IsPunctuation(const char &ch) { return !IsAlphaNumeric(ch) && IsVisible(ch); }
int CSVNStatusListCtrl::ColumnManager::GetVisibleWidth (int column, bool useDefaults) const { return IsVisible (column) ? GetWidth (column, useDefaults) : 0; }
//************************************ // 函数名称: OnTimer // 返回类型: void // 参数信息: IDuiTimer * pTimer // 参数信息: HWND hWnd // 参数信息: CTrayIconUI * lParam // 参数信息: WPARAM wParam // 函数说明: //************************************ void CTrayIconUI::OnTimer( IDuiTimer* pTimer,HWND hWnd,CTrayIconUI* lParam,WPARAM wParam ) { IsVisible()?SetHideIcon():SetShowIcon(); }
void mitk::PolyDataGLMapper2D::Paint( mitk::BaseRenderer * renderer ) { if ( IsVisible( renderer ) == false ) return ; // ok, das ist aus GenerateData kopiert mitk::BaseData::Pointer input = const_cast<mitk::BaseData*>( GetData() ); assert( input ); input->Update(); vtkPolyData * vtkpolydata = this->GetVtkPolyData(); assert( vtkpolydata ); vtkLinearTransform * vtktransform = GetDataNode() ->GetVtkTransform(); if (vtktransform) { vtkLinearTransform * inversetransform = vtktransform->GetLinearInverse(); Geometry2D::ConstPointer worldGeometry = renderer->GetCurrentWorldGeometry2D(); PlaneGeometry::ConstPointer worldPlaneGeometry = dynamic_cast<const PlaneGeometry*>( worldGeometry.GetPointer() ); if ( vtkpolydata != NULL ) { Point3D point; Vector3D normal; if(worldPlaneGeometry.IsNotNull()) { // set up vtkPlane according to worldGeometry point=worldPlaneGeometry->GetOrigin(); normal=worldPlaneGeometry->GetNormal(); normal.Normalize(); m_Plane->SetTransform((vtkAbstractTransform*)NULL); } else { //@FIXME: does not work correctly. Does m_Plane->SetTransform really transforms a "plane plane" into a "curved plane"? return; AbstractTransformGeometry::ConstPointer worldAbstractGeometry = dynamic_cast<const AbstractTransformGeometry*>(renderer->GetCurrentWorldGeometry2D()); if(worldAbstractGeometry.IsNotNull()) { // set up vtkPlane according to worldGeometry point=const_cast<mitk::BoundingBox*>(worldAbstractGeometry->GetParametricBoundingBox())->GetMinimum(); FillVector3D(normal, 0, 0, 1); m_Plane->SetTransform(worldAbstractGeometry->GetVtkAbstractTransform()->GetInverse()); } else return; } vtkFloatingPointType vp[ 3 ], vnormal[ 3 ]; vnl2vtk(point.Get_vnl_vector(), vp); vnl2vtk(normal.Get_vnl_vector(), vnormal); //normally, we would need to transform the surface and cut the transformed surface with the cutter. //This might be quite slow. Thus, the idea is, to perform an inverse transform of the plane instead. //@todo It probably does not work for scaling operations yet:scaling operations have to be //dealed with after the cut is performed by scaling the contour. inversetransform->TransformPoint( vp, vp ); inversetransform->TransformNormalAtPoint( vp, vnormal, vnormal ); m_Plane->SetOrigin( vp ); m_Plane->SetNormal( vnormal ); // set data into cutter m_Cutter->SetInput( vtkpolydata ); // m_Cutter->GenerateCutScalarsOff(); // m_Cutter->SetSortByToSortByCell(); // calculate the cut m_Cutter->Update(); // fetch geometry mitk::DisplayGeometry::Pointer displayGeometry = renderer->GetDisplayGeometry(); assert( displayGeometry ); // float toGL=displayGeometry->GetSizeInDisplayUnits()[1]; //apply color and opacity read from the PropertyList ApplyProperties( renderer ); // traverse the cut contour vtkPolyData * contour = m_Cutter->GetOutput(); vtkPoints *vpoints = contour->GetPoints(); vtkCellArray *vpolys = contour->GetLines(); vtkPointData *vpointdata = contour->GetPointData(); vtkDataArray* vscalars = vpointdata->GetScalars(); vtkCellData *vcelldata = contour->GetCellData(); vtkDataArray* vcellscalars = vcelldata->GetScalars(); int i, numberOfCells = vpolys->GetNumberOfCells(); Point3D p; Point2D p2d, last, first; vpolys->InitTraversal(); vtkScalarsToColors* lut = GetVtkLUT(); assert ( lut != NULL ); for ( i = 0;i < numberOfCells;++i ) { vtkIdType *cell(NULL); vtkIdType cellSize(0); vpolys->GetNextCell( cellSize, cell ); if ( m_ColorByCellData ) { // color each cell according to cell data vtkFloatingPointType* color = lut->GetColor( vcellscalars->GetComponent( i, 0 ) ); glColor3f( color[ 0 ], color[ 1 ], color[ 2 ] ); } if ( m_ColorByPointData ) { vtkFloatingPointType* color = lut->GetColor( vscalars->GetComponent( cell[0], 0 ) ); glColor3f( color[ 0 ], color[ 1 ], color[ 2 ] ); } glBegin ( GL_LINE_LOOP ); for ( int j = 0;j < cellSize;++j ) { vpoints->GetPoint( cell[ j ], vp ); //take transformation via vtktransform into account vtktransform->TransformPoint( vp, vp ); vtk2itk( vp, p ); //convert 3D point (in mm) to 2D point on slice (also in mm) worldGeometry->Map( p, p2d ); //convert point (until now mm and in worldcoordinates) to display coordinates (units ) displayGeometry->WorldToDisplay( p2d, p2d ); //convert display coordinates ( (0,0) is top-left ) in GL coordinates ( (0,0) is bottom-left ) //p2d[1]=toGL-p2d[1]; //add the current vertex to the line glVertex2f( p2d[0], p2d[1] ); } glEnd (); } } } }
bool CCWidget::Event(CCEvent* pEvent){ if(m_bVisible==false) return false; sRect r = GetRect(); r.x = r.y = 0; if(pEvent->iMessage==CCWM_LBUTTONDOWN) int k=0; CCEvent LocalEvent; MakeLocalEvent(&LocalEvent, pEvent); if(m_iDebugType==2){ if(pEvent->iMessage==CCWM_LBUTTONDOWN ) int k=0; } if(r.InPoint(LocalEvent.sPos)==true && (CCWidget::m_pCapturedWidget==NULL || CCWidget::m_pCapturedWidget==this) && IsVisible()==true){ if(m_pCursor!=NULL) CCCursorSystem::Set(m_pCursor); else CCCursorSystem::Set(CCCURSOR_ARROW); if(m_pToolTip!=NULL){ SetZOrder(CC_TOP); m_pToolTip->Show(true); } } else{ if(m_pToolTip!=NULL){ m_pToolTip->Show(false); } } if(m_bEnable==false) return false; if(GetLatestExclusive()!=NULL){ if(GetLatestExclusive()->Event(pEvent)==true) return true; if(GetLatestExclusive()!=NULL) return false; } if(pEvent->iMessage==CCWM_LBUTTONDOWN){ if ( r.InPoint(LocalEvent.sPos)==true){ SetFocus(); if((m_bFocusEnable)&&(m_bZOrderChangable==true)) SetZOrder(CC_TOP); } else // ReleaseFocus { // ReleaseFocus(); // OnReleaseFocus(); // ReleaseCapture(); } } if(GetLatestExclusive()==NULL){ for(int i=m_Children.GetCount()-1; i>=0; i--){ CCWidget* pCurWnd = m_Children.Get(i); if(pCurWnd->Event(pEvent)==true) { return true; } } } if(EventResize(pEvent)==true) return true; if(pEvent->iMessage==CCWM_HOTKEY){ if(OnHotKey(pEvent->uKey)==true) return true; } if(pEvent->iMessage==CCWM_CHAR || pEvent->iMessage==CCWM_KEYDOWN || pEvent->iMessage==CCWM_IMECOMPOSE || pEvent->iMessage==CCWM_ACTIONKEYDOWN || pEvent->iMessage==CCWM_ACTIONKEYUP || pEvent->iMessage==CCWM_ACTIONPRESSED || pEvent->iMessage==CCWM_ACTIONRELEASED){ if (IsFocus()) { if(OnEvent(&LocalEvent, GetListener())==true) return true; // Tab Key if(pEvent->iMessage==CCWM_KEYDOWN && pEvent->uKey==VK_TAB){ if(OnTab(!pEvent->GetShiftState())==true) return true; } } } else{ if((CCWidget::m_pCapturedWidget==NULL || CCWidget::m_pCapturedWidget==this)) if(OnEvent(&LocalEvent, GetListener())==true) return true; } if(pEvent->iMessage==CCWM_LBUTTONUP) ReleaseCapture(); return false; }
void CLCDText::OnDraw(CLCDGfx &rGfx) { if (GetBackgroundMode() == OPAQUE) { // clear the clipped area RECT rcClp = { 0, 0, m_Size.cx, m_Size.cy }; FillRect(rGfx.GetHDC(), &rcClp, (HBRUSH) GetStockObject(BLACK_BRUSH)); // clear the logical area RECT rcLog = { 0, 0, m_sizeLogical.cx, m_sizeLogical.cy }; FillRect(rGfx.GetHDC(), &rcLog, (HBRUSH) GetStockObject(BLACK_BRUSH)); } if (m_nTextLength) { // map mode text, with transparency int nOldMapMode = SetMapMode(rGfx.GetHDC(), MM_TEXT); int nOldBkMode = SetBkMode(rGfx.GetHDC(), GetBackgroundMode()); // select current font HFONT hOldFont = (HFONT)SelectObject(rGfx.GetHDC(), m_hFont); // select color COLORREF crOldTextColor = SetTextColor(rGfx.GetHDC(), m_crColor); if (m_bRecalcExtent) { int nTextFormat; RECT rExtent; // calculate vertical extent with word wrap nTextFormat = (m_nTextFormat | DT_WORDBREAK | DT_CALCRECT); rExtent.left = rExtent.top = 0; rExtent.right = GetWidth(); rExtent.bottom = GetHeight(); DrawTextEx(rGfx.GetHDC(), m_szText, m_nTextLength, &rExtent, nTextFormat, &m_dtp); m_sizeVExtent.cx = rExtent.right; m_sizeVExtent.cy = rExtent.bottom; // calculate horizontal extent w/o word wrap nTextFormat = (m_nTextFormat | DT_CALCRECT); rExtent.left = rExtent.top = 0; rExtent.right = GetWidth(); rExtent.bottom = GetHeight(); DrawTextEx(rGfx.GetHDC(), m_szText, m_nTextLength, &rExtent, nTextFormat, &m_dtp); m_sizeHExtent.cx = rExtent.right; m_sizeHExtent.cy = rExtent.bottom; m_bRecalcExtent = FALSE; } if (IsVisible()) { DrawText(rGfx); } // restores SetMapMode(rGfx.GetHDC(), nOldMapMode); SetTextColor(rGfx.GetHDC(), crOldTextColor); SetBkMode(rGfx.GetHDC(), nOldBkMode); SelectObject(rGfx.GetHDC(), hOldFont); } }
void CEditUI::SetInternVisible(bool bVisible) { if( !IsVisible() && m_pWindow != NULL ) m_pManager->SetFocus(NULL); }
int KeyBar::ProcessMouse(MOUSE_EVENT_RECORD *MouseEvent) { INPUT_RECORD rec; int Key; if (!IsVisible()) return FALSE; if (!(MouseEvent->dwButtonState & 3) || MouseEvent->dwEventFlags) return FALSE; if (MouseEvent->dwMousePosition.X<X1 || MouseEvent->dwMousePosition.X>X2 || MouseEvent->dwMousePosition.Y!=Y1) return FALSE; #if 1 //Maximus: на таблетках лучше бы все кнопки показать, для пальцетыканья int KeyWidth=(X2-X1+2)/12; #else int KeyWidth=(X2-X1-1)/12; #endif #if 1 //Maximus: на таблетках лучше бы все кнопки показать, для пальцетыканья if (KeyWidth<3) KeyWidth=3; #else if (KeyWidth<8) KeyWidth=8; #endif int X=MouseEvent->dwMousePosition.X-X1; if (X<KeyWidth*9) Key=X/KeyWidth; else Key=9+(X-KeyWidth*9)/(KeyWidth+1); for (;;) { GetInputRecord(&rec); if (rec.EventType==MOUSE_EVENT && !(rec.Event.MouseEvent.dwButtonState & 3)) break; } if (rec.Event.MouseEvent.dwMousePosition.X<X1 || rec.Event.MouseEvent.dwMousePosition.X>X2 || rec.Event.MouseEvent.dwMousePosition.Y!=Y1) return FALSE; int NewKey,NewX=MouseEvent->dwMousePosition.X-X1; if (NewX<KeyWidth*9) NewKey=NewX/KeyWidth; else NewKey=9+(NewX-KeyWidth*9)/(KeyWidth+1); if (Key!=NewKey) return FALSE; if (Key>11) Key=11; if (MouseEvent->dwControlKeyState & (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED) || (MouseEvent->dwButtonState & RIGHTMOST_BUTTON_PRESSED)) { if (MouseEvent->dwControlKeyState & SHIFT_PRESSED) Key+=KEY_ALTSHIFTF1; else if (MouseEvent->dwControlKeyState & (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED)) Key+=KEY_CTRLALTF1; else Key+=KEY_ALTF1; } else if (MouseEvent->dwControlKeyState & (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED)) { if (MouseEvent->dwControlKeyState & SHIFT_PRESSED) Key+=KEY_CTRLSHIFTF1; else Key+=KEY_CTRLF1; } else if (MouseEvent->dwControlKeyState & SHIFT_PRESSED) Key+=KEY_SHIFTF1; else Key+=KEY_F1; //if (Owner) //Owner->ProcessKey(Key); FrameManager->ProcessKey(Key); return TRUE; }
void ElementInfo::ProcessEvent(Core::Event& event) { Core::ElementDocument::ProcessEvent(event); // Only process events if we're visible if (IsVisible()) { if (event == "click") { Core::Element* target_element = event.GetTargetElement(); // Deal with clicks on our own elements differently. if (target_element->GetOwnerDocument() == this) { // If it's a pane title, then we need to toggle the visibility of its sibling (the contents pane underneath it). if (target_element->GetTagName() == "h2") { Core::Element* panel = target_element->GetNextSibling(); if (panel->IsVisible()) panel->SetProperty("display", "none"); else panel->SetProperty("display", "block"); event.StopPropagation(); } else if (event.GetTargetElement()->GetId() == "close_button") { if (IsVisible()) SetProperty("visibility", "hidden"); } // Check if the id is in the form "a %d" or "c %d" - these are the ancestor or child labels. else { int element_index; if (sscanf(target_element->GetId().CString(), "a %d", &element_index) == 1) { Core::Element* new_source_element = source_element; for (int i = 0; i < element_index; i++) { if (new_source_element != NULL) new_source_element = new_source_element->GetParentNode(); } SetSourceElement(new_source_element); } else if (sscanf(target_element->GetId().CString(), "c %d", &element_index) == 1) { if (source_element != NULL) SetSourceElement(source_element->GetChild(element_index)); } event.StopPropagation(); } } // Otherwise we just want to focus on the clicked element (unless it's on a debug element) else if (target_element->GetOwnerDocument() != NULL && !IsDebuggerElement(target_element)) { Core::Element* new_source_element = target_element; if (new_source_element != source_element) { SetSourceElement(new_source_element); event.StopPropagation(); } } } else if (event == "mouseover") { Core::Element* target_element = event.GetTargetElement(); // Deal with clicks on our own elements differently. Core::ElementDocument* owner_document = target_element->GetOwnerDocument(); if (owner_document == this) { // Check if the id is in the form "a %d" or "c %d" - these are the ancestor or child labels. int element_index; if (sscanf(target_element->GetId().CString(), "a %d", &element_index) == 1) { hover_element = source_element; for (int i = 0; i < element_index; i++) { if (hover_element != NULL) hover_element = hover_element->GetParentNode(); } } else if (sscanf(target_element->GetId().CString(), "c %d", &element_index) == 1) { if (source_element != NULL) hover_element = source_element->GetChild(element_index); } } // Otherwise we just want to focus on the clicked element (unless it's on a debug element) else if (owner_document != NULL && owner_document->GetId().Find("rkt-debug-") != 0) { hover_element = target_element; } } } }
bool CGUIBaseContainer::OnMessage(CGUIMessage& message) { if (message.GetControlId() == GetID() ) { if (!m_listProvider) { if (message.GetMessage() == GUI_MSG_LABEL_BIND && message.GetPointer()) { // bind our items Reset(); CFileItemList *items = (CFileItemList *)message.GetPointer(); for (int i = 0; i < items->Size(); i++) m_items.push_back(items->Get(i)); UpdateLayout(true); // true to refresh all items UpdateScrollByLetter(); SelectItem(message.GetParam1()); return true; } else if (message.GetMessage() == GUI_MSG_LABEL_RESET) { Reset(); SetPageControlRange(); return true; } } if (message.GetMessage() == GUI_MSG_ITEM_SELECT) { SelectItem(message.GetParam1()); return true; } else if (message.GetMessage() == GUI_MSG_SETFOCUS) { if (message.GetParam1()) // subfocus item is specified, so set the offset appropriately { int offset = GetOffset(); if (message.GetParam2() && message.GetParam2() == 1) offset = 0; int item = std::min(offset + (int)message.GetParam1() - 1, (int)m_items.size() - 1); SelectItem(item); } } else if (message.GetMessage() == GUI_MSG_ITEM_SELECTED) { message.SetParam1(GetSelectedItem()); return true; } else if (message.GetMessage() == GUI_MSG_PAGE_CHANGE) { if (message.GetSenderId() == m_pageControl && IsVisible()) { // update our page if we're visible - not much point otherwise if ((int)message.GetParam1() != GetOffset()) m_pageChangeTimer.StartZero(); ScrollToOffset(message.GetParam1()); return true; } } else if (message.GetMessage() == GUI_MSG_REFRESH_LIST) { // update our list contents for (unsigned int i = 0; i < m_items.size(); ++i) m_items[i]->SetInvalid(); } else if (message.GetMessage() == GUI_MSG_MOVE_OFFSET) { int count = (int)message.GetParam1(); while (count < 0) { MoveUp(true); count++; } while (count > 0) { MoveDown(true); count--; } return true; } } return CGUIControl::OnMessage(message); }
void GuiTextEdit::Draw() { static const float BLINK_TIME_END = 0.5f; static const float BLINK_TIME_HALF = BLINK_TIME_END * 0.5f; if (!IsVisible()) { return; } float dt = TheTimer::Instance()->GetDt(); m_caretTimer += dt; m_drawCaret = false; if (m_caretTimer > BLINK_TIME_END) { m_caretTimer = 0; } else if (m_caretTimer < BLINK_TIME_HALF) { m_drawCaret = true; } if (HasFocus()) { // Draw border // TODO Could be image - allow flexible way to give GUIs themes static float t = 0; t += dt; PushColour(); float s = (sin(t * 5.0f) + 1.0f) * 0.5f; Colour c(s, s, 1, 1); AmjuGL::SetColour(c); //inverse ? m_fgCol : m_bgCol); AmjuGL::Disable(AmjuGL::AMJU_TEXTURE_2D); const float BORDER = 0.02f; m_rect.SetSize(GetSize() + Vec2f(2 * BORDER, 2 * BORDER)); m_rect.SetLocalPos(Vec2f(-BORDER, BORDER)); m_rect.SetCornerRadius(BORDER); m_rect.SetRoundCorners(0); m_rect.SetColour(c); m_rect.Draw(); AmjuGL::Enable(AmjuGL::AMJU_TEXTURE_2D); PopColour(); } GuiText::Draw(); if (m_drawCaret && HasFocus()) { // Draw caret - TODO multi line PushColour(); AmjuGL::SetColour(m_drawCaret ? m_fgCol : m_bgCol); float startX = GetCombinedPos().x; float x = (GetFont()->GetTextWidth(m_text.substr(m_first, m_caret - m_first)) * GetFontSize() * m_scaleX) + startX; if (!m_triListCaret) { m_triListCaret = GetFont()->MakeTriList(0, 0, "|", 1.0f); } float y = GetCombinedPos().y - GetFontSize() * CHAR_HEIGHT_FOR_SIZE_1; AmjuGL::PushMatrix(); AmjuGL::Translate(x, y, 0); AmjuGL::Draw(m_triListCaret); AmjuGL::PopMatrix(); PopColour(); } }
// Return: false if deleted bool CItem::StartRefresh() { ASSERT(GetType() != IT_FREESPACE); ASSERT(GetType() != IT_UNKNOWN); m_ticksWorked = 0; // Special case IT_MYCOMPUTER if (GetType() == IT_MYCOMPUTER) { ZeroMemory(&m_lastChange, sizeof(m_lastChange)); for (int i=0; i < GetChildrenCount(); i++) GetChild(i)->StartRefresh(); return true; } ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY || GetType() == IT_FILESFOLDER); bool wasExpanded = IsVisible() && IsExpanded(); int oldScrollPosition = 0; if (IsVisible()) oldScrollPosition = GetScrollPosition(); UncacheImage(); // Upward clear data UpdateLastChange(); UpwardSetUndone(); UpwardAddReadJobs(-GetReadJobs()); ASSERT(GetReadJobs() == 0); if (GetType() == IT_FILE) GetParent()->UpwardAddFiles(-1); else UpwardAddFiles(-GetFilesCount()); ASSERT(GetFilesCount() == 0); if (GetType() == IT_DIRECTORY || GetType() == IT_DRIVE) UpwardAddSubdirs(-GetSubdirsCount()); ASSERT(GetSubdirsCount() == 0); UpwardAddSize(-GetSize()); ASSERT(GetSize() == 0); RemoveAllChildren(); UpwardRecalcLastChange(); // Special case IT_FILESFOLDER if (GetType() == IT_FILESFOLDER) { CFileFindWDS finder; BOOL b = finder.FindFile(GetFindPattern()); while (b) { b = finder.FindNextFile(); if (finder.IsDirectory()) continue; FILEINFO fi; fi.name = finder.GetFileName(); fi.attributes = finder.GetAttributes(); // Retrieve file size fi.length = finder.GetCompressedLength(); finder.GetLastWriteTime(&fi.lastWriteTime); AddFile(fi); UpwardAddFiles(1); } SetDone(); if (wasExpanded) GetTreeListControl()->ExpandItem(this); return true; } ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY); // The item may have been deleted. bool deleted = false; if (GetType() == IT_DRIVE) deleted = !DriveExists(GetPath()); else if (GetType() == IT_FILE) deleted = !FileExists(GetPath()); else if (GetType() == IT_DIRECTORY) deleted = !FolderExists(GetPath()); if (deleted) { if (GetParent() == NULL) { GetDocument()->UnlinkRoot(); } else { GetParent()->UpwardRecalcLastChange(); GetParent()->RemoveChild(GetParent()->FindChildIndex(this)); // --> delete this } return false; } // Case IT_FILE if (GetType() == IT_FILE) { CFileFindWDS finder; BOOL b = finder.FindFile(GetPath()); if (b) { finder.FindNextFile(); if (!finder.IsDirectory()) { FILEINFO fi; fi.name = finder.GetFileName(); fi.attributes = finder.GetAttributes(); // Retrieve file size fi.length = finder.GetCompressedLength(); finder.GetLastWriteTime(&fi.lastWriteTime); SetLastChange(fi.lastWriteTime); UpwardAddSize(fi.length); UpwardUpdateLastChange(GetLastChange()); GetParent()->UpwardAddFiles(1); } } SetDone(); return true; } ASSERT(GetType() == IT_DRIVE || GetType() == IT_DIRECTORY); if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsMountPoint(GetPath()) && !GetOptions()->IsFollowMountPoints()) return true; if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsJunctionPoint(GetPath()) && !GetOptions()->IsFollowJunctionPoints()) return true; // Initiate re-read SetReadJobDone(false); // Re-create <free space> and <unknown> if (GetType() == IT_DRIVE) { if (GetDocument()->OptionShowFreeSpace()) CreateFreeSpaceItem(); if (GetDocument()->OptionShowUnknown()) CreateUnknownItem(); } DoSomeWork(0); if (wasExpanded) GetTreeListControl()->ExpandItem(this); if (IsVisible()) SetScrollPosition(oldScrollPosition); return true; }
void mitk::ToFSurfaceVtkMapper3D::GenerateDataForRenderer(mitk::BaseRenderer* renderer) { LocalStorage *ls = m_LSH.GetLocalStorage(renderer); bool visible = IsVisible(renderer); if(visible==false) { ls->m_Actor->VisibilityOff(); return; } // // set the input-object at time t for the mapper // //mitk::ToFSurface::Pointer input = const_cast< mitk::ToFSurface* >( this->GetInput() ); mitk::Surface::Pointer input = const_cast< mitk::Surface* >( this->GetInput() ); vtkPolyData * polydata = input->GetVtkPolyData( this->GetTimestep() ); if(polydata == NULL) { ls->m_Actor->VisibilityOff(); return; } if ( m_GenerateNormals ) { ls->m_VtkPolyDataNormals->SetInput( polydata ); ls->m_VtkPolyDataMapper->SetInput( ls->m_VtkPolyDataNormals->GetOutput() ); } else { ls->m_VtkPolyDataMapper->SetInput( polydata ); } // // apply properties read from the PropertyList // ApplyProperties(ls->m_Actor, renderer); if(visible) ls->m_Actor->VisibilityOn(); // // TOF extension for visualization (color/texture mapping) // if (this->m_VtkScalarsToColors) { // set the color transfer funtion if applied ls->m_VtkPolyDataMapper->SetLookupTable(this->m_VtkScalarsToColors); } if (this->m_Texture) { // create a vtk image as basic for texture vtkImageData* imageData = vtkImageData::New(); int width = this->m_TextureWidth; int height = this->m_TextureHeight; imageData->SetDimensions(width, height, 1); imageData->SetScalarTypeToUnsignedChar(); imageData->SetNumberOfScalarComponents(3); // RGB imageData->SetSpacing(0.0, 0.0, 0.0); imageData->SetOrigin(width/2, height/2, 0.0); imageData->AllocateScalars(); // allocate storage for image data imageData->SetScalarType( VTK_UNSIGNED_CHAR ); // create a vtk array to hold the input unsigned char* texture (e.g. from the video camera) vtkDataArray *scalars; scalars = vtkUnsignedCharArray::New(); scalars->SetNumberOfComponents(3); scalars->SetVoidArray(this->GetTexture(), width*height*3, 1); // prepare the image data from vtk array imageData->GetPointData()->SetScalars(scalars); scalars->Delete(); // create vtk texture vtkTexture *aTexture = vtkTexture::New(); aTexture->SetInput(imageData); aTexture->InterpolateOn(); ls->m_Actor->SetTexture(aTexture); aTexture->Delete(); } else { // remove the texture ls->m_Actor->SetTexture(0); } }
// Analytically computes the 'SuperLeavesPVS'. // A prior call to 'DetermineTrivialVisibility()' is assumed. void BuildPVS() { /* // Der komplette alte, aber einfache Code. Evtl. nützlich für Debugging-Zwecke. for (unsigned long MasterSL=0; MasterSL+1<SuperLeaves.Size(); MasterSL++) { printf("%5.1f%%\r", (double)MasterSL/SuperLeaves.Size()*100.0); fflush(stdout); // Bestimme für jedes SuperLeaves-Paar, ob eine gegenseitige Sichtbarkeit besteht. // Beachte, daß die folgende Schleife bei 'MasterSL+1' starten kann (statt bei '0'), da Sichtbarkeit immer wechselseitig ist. for (unsigned long TargetSL=MasterSL+1; TargetSL<SuperLeaves.Size(); TargetSL++) { // Wenn die Sichtbarkeit zwischen 'MasterSL' und 'TargetSL' bereits festgestellt wurde, // können wir direkt mit dem nächsten 'TargetSL' weitermachen. Sinnvoll für unmittelbare Nachbarn. // Auch vorangegangene Iterationen für andere, aber weiter weg liegende 'TargetSL's haben u.U. // "auf dem Weg" liegende SuperLeaves als sichtbar markiert, sodaß diese hier nicht nochmal getestet werden müssen. if (IsVisible(MasterSL, TargetSL)) continue; // Wenn das 'TargetSL' keine Nachbarn hat, können wir direkt mit dem nächsten 'TargetSL' weitermachen. // Für ein solches SL ohne Nachbarn haben wir sowieso keine sinnvolle "Target Bounding Box" in den 'SuperLeavesBBs' konstruiert! if (SuperLeaves[TargetSL].Neighbours.Size()==0) continue; // Intentionally ignore the returned result. CanSeeFromAToB(MasterSL, TargetSL); } } */ // Für jedes SuperLeaf das PVS bestimmen. for (unsigned long MasterSL=0; MasterSL<SuperLeaves.Size(); MasterSL++) { printf("%5.1f%%\r", (double)MasterSL/SuperLeaves.Size()*100.0); fflush(stdout); // Initialisiere die Hilfsarrays für das 'MasterSL'. ArrayT<bool> AV; // List of "Already Visible" SuperLeaves from 'MasterSL'. ArrayT<bool> PV; // List of "Potentially Visible" SuperLeaves from 'MasterSL'. ArrayT<bool> NV; // List of "Not Visible" SuperLeaves from 'MasterSL'. unsigned long SL; for (SL=0; SL<SuperLeaves.Size(); SL++) { AV.PushBack(false); PV.PushBack(false); NV.PushBack(false); } // Bestimme, welche SuperLeaves wir von 'MasterSL' aus schon sehen können. for (SL=0; SL<SuperLeaves.Size(); SL++) if (IsVisible(MasterSL, SL)) AV[SL]=true; // Bilde eine Liste 'PV' aller SuperLeaves, die von 'MasterSL' aus "potentially visible" sind. // Dies sind zunächst *alle* Nachbarn aller SuperLeaves in der 'AV' Liste, außer denjenigen, // die bereits in der 'AV' oder 'NV' Liste sind, oder deren Index-Nummern 'NeighbourSL' kleiner/gleich 'MasterSL' sind. // Der Grund für letzteres: Wenn früher schon festgestellt wurde, daß wir nicht von 'NeighbourSL' nach 'MasterSL' sehen können, // können wir uns jetzt den Test, ob wir von 'MasterSL' nach 'NeighbourSL' sehen können, sparen. // Wäre der frühere Test dagegen positiv gewesen, wäre 'AV[NeighbourSL]==true', was auch keinen 'PV'-Eintrag verursacht. for (SL=0; SL<SuperLeaves.Size(); SL++) if (AV[SL]) for (unsigned long NeighbourNr=0; NeighbourNr<SuperLeaves[SL].Neighbours.Size(); NeighbourNr++) { const unsigned long NeighbourSL=SuperLeaves[SL].Neighbours[NeighbourNr].SuperLeafNr; if (!AV[NeighbourSL] && !NV[NeighbourSL] && NeighbourSL>MasterSL) PV[NeighbourSL]=true; } // For each 'TargetSL' in 'PV': Determine if 'TargetSL' is visible from 'MasterSL'. while (true) { unsigned long TargetSL; for (TargetSL=0; TargetSL<PV.Size(); TargetSL++) if (PV[TargetSL]) break; if (TargetSL>=PV.Size()) break; if (CanSeeFromAToB(MasterSL, TargetSL)) { // Redo the init (but 'NV' is possibly not empty anymore). for (SL=0; SL<SuperLeaves.Size(); SL++) { AV[SL]=false; PV[SL]=false; } // Bestimme, welche SuperLeaves wir von 'MasterSL' aus schon sehen können. for (SL=0; SL<SuperLeaves.Size(); SL++) if (IsVisible(MasterSL, SL)) AV[SL]=true; // Bilde eine Liste 'PV' aller SuperLeaves, die von 'MasterSL' aus "potentially visible" sind. // Dies sind zunächst *alle* Nachbarn aller SuperLeaves in der 'AV' Liste, außer denjenigen, // die bereits in der 'AV' oder 'NV' Liste sind, oder deren Index-Nummern 'NeighbourSL' kleiner/gleich 'MasterSL' sind. // Der Grund für letzteres: Wenn früher schon festgestellt wurde, daß wir nicht von 'NeighbourSL' nach 'MasterSL' sehen können, // können wir uns jetzt den Test, ob wir von 'MasterSL' nach 'NeighbourSL' sehen können, sparen. // Wäre der frühere Test dagegen positiv gewesen, wäre 'AV[NeighbourSL]==true', was auch keinen 'PV'-Eintrag verursacht. for (SL=0; SL<SuperLeaves.Size(); SL++) if (AV[SL]) for (unsigned long NeighbourNr=0; NeighbourNr<SuperLeaves[SL].Neighbours.Size(); NeighbourNr++) { const unsigned long NeighbourSL=SuperLeaves[SL].Neighbours[NeighbourNr].SuperLeafNr; if (!AV[NeighbourSL] && !NV[NeighbourSL] && NeighbourSL>MasterSL) PV[NeighbourSL]=true; } } else { PV[TargetSL]=false; // Delete 'TargetSL' from PV list. NV[TargetSL]=true; // Add 'TargetSL' to NV list. } } } printf("Final Avg Visibility: %10.5f\n", GetAverageVisibility()); }