NS_IMETHODIMP nsXFormsAccessors::IsRelevant(PRBool *aStateVal) { return GetState(NS_EVENT_STATE_ENABLED, aStateVal); }
void CArtefact::onMovementChanged (ACTOR_DEFS::EMoveCommand cmd) { if( (cmd == ACTOR_DEFS::mcSprint)&&(GetState()==eIdle) ) PlayAnimIdle (); }
NS_IMETHODIMP nsXFormsAccessors::IsValid(PRBool *aStateVal) { return GetState(NS_EVENT_STATE_VALID, aStateVal); }
NS_IMETHODIMP nsXFormsAccessors::IsReadonly(PRBool *aStateVal) { return GetState(NS_EVENT_STATE_MOZ_READONLY, aStateVal); }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CObjectTeleporter::TeleporterThink( void ) { SetContextThink( &CObjectTeleporter::TeleporterThink, gpGlobals->curtime + BUILD_TELEPORTER_NEXT_THINK, TELEPORTER_THINK_CONTEXT ); // At any point, if our match is not ready, revert to IDLE if ( IsDisabled() || IsMatchingTeleporterReady() == false ) { if ( GetState() != TELEPORTER_STATE_IDLE ) { SetState( TELEPORTER_STATE_IDLE ); ShowDirectionArrow( false ); } return; } if ( m_flMyNextThink && m_flMyNextThink > gpGlobals->curtime ) return; // pMatch is not NULL and is not building CObjectTeleporter *pMatch = GetMatchingTeleporter(); Assert( pMatch ); Assert( pMatch->m_iState != TELEPORTER_STATE_BUILDING ); switch ( m_iState ) { // Teleporter is not yet active, do nothing case TELEPORTER_STATE_BUILDING: break; default: case TELEPORTER_STATE_IDLE: // Do we have a match that is active? if ( IsMatchingTeleporterReady() ) { SetState( TELEPORTER_STATE_READY ); EmitSound( "Building_Teleporter.Ready" ); if ( GetType() == OBJ_TELEPORTER_ENTRANCE ) { ShowDirectionArrow( true ); } } break; case TELEPORTER_STATE_READY: break; case TELEPORTER_STATE_SENDING: { pMatch->TeleporterReceive( m_hTeleportingPlayer, 1.0 ); m_flRechargeTime = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEOUT_TIME + BUILD_TELEPORTER_FADEIN_TIME + TELEPORTER_RECHARGE_TIME ); // change state to recharging... SetState( TELEPORTER_STATE_RECHARGING ); } break; case TELEPORTER_STATE_RECEIVING: { // get the position we'll move the player to Vector newPosition = GetAbsOrigin(); newPosition.z += TELEPORTER_MAXS.z + 1; // Telefrag anyone in the way CBaseEntity *pEnts[256]; Vector mins, maxs; Vector expand( 4, 4, 4 ); mins = newPosition + VEC_HULL_MIN - expand; maxs = newPosition + VEC_HULL_MAX + expand; CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get(); // move the player if ( pTeleportingPlayer ) { CUtlVector<CBaseEntity*> hPlayersToKill; bool bClear = true; // Telefrag any players in the way int numEnts = UTIL_EntitiesInBox( pEnts, 256, mins, maxs, 0 ); if ( numEnts ) { //Iterate through the list and check the results for ( int i = 0; i < numEnts && bClear; i++ ) { if ( pEnts[i] == NULL ) continue; if ( pEnts[i] == this ) continue; // kill players and NPCs if ( pEnts[i]->IsPlayer() || pEnts[i]->IsNPC() ) { if ( !pTeleportingPlayer->InSameTeam(pEnts[i]) ) { hPlayersToKill.AddToTail( pEnts[i] ); } continue; } if ( pEnts[i]->IsBaseObject() ) continue; // Solid entities will prevent a teleport if ( pEnts[i]->IsSolid() && pEnts[i]->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), MASK_ALL ) && g_pGameRules->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), pEnts[i]->GetCollisionGroup() ) ) { // We're going to teleport into something solid. Abort & destroy this exit. bClear = false; } } } if ( bClear ) { // Telefrag all enemy players we've found for ( int player = 0; player < hPlayersToKill.Count(); player++ ) { hPlayersToKill[player]->TakeDamage( CTakeDamageInfo( pTeleportingPlayer, this, 1000, DMG_CRUSH ) ); } pTeleportingPlayer->Teleport( &newPosition, &(GetAbsAngles()), &vec3_origin ); // Unzoom if we are a sniper zoomed! if ( ( pTeleportingPlayer->GetPlayerClass()->GetClassIndex() == TF_CLASS_SNIPER ) && pTeleportingPlayer->m_Shared.InCond( TF_COND_AIMING ) ) { CTFWeaponBase *pWpn = pTeleportingPlayer->GetActiveTFWeapon(); if ( pWpn && pWpn->GetWeaponID() == TF_WEAPON_SNIPERRIFLE ) { CTFSniperRifle *pRifle = static_cast<CTFSniperRifle*>( pWpn ); pRifle->ToggleZoom(); } } pTeleportingPlayer->SetFOV( pTeleportingPlayer, 0, tf_teleporter_fov_time.GetFloat(), tf_teleporter_fov_start.GetInt() ); color32 fadeColor = {255,255,255,100}; UTIL_ScreenFade( pTeleportingPlayer, fadeColor, 0.25, 0.4, FFADE_IN ); } else { DetonateObject(); } } SetState( TELEPORTER_STATE_RECEIVING_RELEASE ); m_flMyNextThink = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEIN_TIME ); } break; case TELEPORTER_STATE_RECEIVING_RELEASE: { CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get(); if ( pTeleportingPlayer ) { pTeleportingPlayer->TeleportEffect(); pTeleportingPlayer->m_Shared.RemoveCond( TF_COND_SELECTED_TO_TELEPORT ); CTF_GameStats.Event_PlayerUsedTeleport( GetBuilder(), pTeleportingPlayer ); pTeleportingPlayer->SpeakConceptIfAllowed( MP_CONCEPT_TELEPORTED ); } // reset the pointers to the player now that we're done teleporting SetTeleportingPlayer( NULL ); pMatch->SetTeleportingPlayer( NULL ); SetState( TELEPORTER_STATE_RECHARGING ); m_flMyNextThink = gpGlobals->curtime + ( TELEPORTER_RECHARGE_TIME ); } break; case TELEPORTER_STATE_RECHARGING: // If we are finished recharging, go active if ( gpGlobals->curtime > m_flRechargeTime ) { SetState( TELEPORTER_STATE_READY ); EmitSound( "Building_Teleporter.Ready" ); } break; } }
NS_IMETHODIMP nsXFormsAccessors::IsRequired(PRBool *aStateVal) { return GetState(NS_EVENT_STATE_REQUIRED, aStateVal); }
void vpRJoint::BuildKinematics(void) { GetState().push_back(vpState(this, 0)); }
void wxSTEditorShell::OnKeyDown(wxKeyEvent &event) { // don't steal any keys from the autocomplete dropdown if (AutoCompActive()) { event.Skip(true); return; } event.Skip(false); CheckReadOnly(true); switch (event.GetKeyCode()) { case WXK_UP : case WXK_NUMPAD_UP : { // you can scroll up through multiline entry int current_line = GetCurrentLine(); int prompt_line = GetPromptLine(); if ((current_line < prompt_line) || (current_line > prompt_line)) break; // up/down arrows go through the history buffer wxString promptText = GetPromptText(); SetPromptText(GetNextHistoryLine(false, promptText)); return; } case WXK_DOWN : case WXK_NUMPAD_DOWN : { // you can scroll down through multiline entry int total_lines = GetLineCount(); total_lines = wxMax(0, total_lines - 1); int current_line = GetCurrentLine(); if (current_line < total_lines) break; // up/down arrows go through the history buffer wxString promptText = GetPromptText(); SetPromptText(GetNextHistoryLine(true, promptText)); return; } case WXK_LEFT : case WXK_NUMPAD_LEFT : { int current_line = GetCurrentLine(); int prompt_line = GetPromptLine(); if (current_line >= prompt_line) { int caret_pos = 0; GetCurLine(&caret_pos); if (caret_pos < 1) return; } break; } case WXK_PAGEUP : case WXK_NUMPAD_PAGEUP : case WXK_PAGEDOWN : case WXK_NUMPAD_PAGEDOWN : case WXK_END : case WXK_NUMPAD_END : case WXK_HOME : case WXK_NUMPAD_HOME : case WXK_RIGHT : case WXK_NUMPAD_RIGHT : case WXK_SHIFT : case WXK_CONTROL : case WXK_ALT : { // default processing for these keys event.Skip(); return; } case WXK_RETURN : case WXK_NUMPAD_ENTER : { // put cursor at end if not already on the last line if (!CaretOnPromptLine(STE_CARET_MOVE_NONE)) { GotoPos(GetLength()); return; } int current_line = GetCurrentLine(); int prompt_line = GetPromptLine(); // allow multiline entry for shift+enter if ((current_line >= prompt_line) && event.ShiftDown()) { event.Skip(); return; } wxString promptText = GetPromptText(); // goto the end of the line and store the line for the history LineEnd(); if (promptText.Length()) AddHistoryLine(promptText, true); // just send the event, the receiver can do what they like SendEvent(wxEVT_STESHELL_ENTER, 0, GetState(), promptText); return; } case WXK_BACK : { // go to the end of the last line if not on last line if (!CaretOnPromptLine(STE_CARET_MOVE_NONE)) { GotoPos(GetLength()); return; } // don't let them backspace into previous line int caret_pos = 0; GetCurLine(&caret_pos); if (caret_pos < 1) return; break; } default : // move cursor to end if not already there { // reset history to start at most recent again m_line_history_index = (int)(m_lineHistoryArray.GetCount() - 1); CaretOnPromptLine(STE_CARET_MOVE_ENDTEXT); break; } } event.Skip(); }
bool LFGGroupState::IsBootActive() { if (GetState() != LFG_STATE_BOOT) return false; return (time_t(time(NULL)) < m_bootCancelTime); };
void Boss::UpdateBoss() { int x = GetTimerAttack(); if( x >= BOSS_ATTACK_START || HeadsComing == true ) { HeadsComing = true; AnimPaceBoss++; HeadTimer++; SetState( BOSS_ATTACK ); if( AnimPaceBoss >= ANIMPACEBOSSHEAD ) { UpdateFrame(); AnimPaceBoss = 0; } ResetAttackTimer(); if( HeadTimer >= 20 ) { if( HeadAnimation == true ) { HeadTimer = 0; My_BossHead.push_back( CreateBossHeads( xPos, yPos + 10, surface, 20 * SizeHeads )); SizeHeads++; } if( GetFrame() >= 4 ) { HeadAnimation = true; SetFrame( BOSS_IDLE ); } } if( SizeHeads == 6 ) { HeadsComing = false; SetFrame( BOSS_IDLE ); SizeHeads = 1; } } else { SetFrame( BOSS_IDLE ); UpdateAttackTimer(); } //sanity check switch( GetState() ) { case BOSS_IDLE: { SDL_BlitSurface( gamestate.GetSurface( surface ), &GetClips( GetFrame() ), gamestate.screen, &ReturnDestRect() ); } case BOSS_ATTACK: { SDL_BlitSurface( gamestate.GetSurface( surface ), &GetClips( GetFrame() ), gamestate.screen, &ReturnDestRect() ); } case BOSS_DIE: { SDL_BlitSurface( gamestate.GetSurface( surface ), &GetClips( GetFrame() ), gamestate.screen, &ReturnDestRect() ); } } UpdateHeads(); }
bool TextEventDispatcher::DispatchKeyboardEventInternal( EventMessage aMessage, const WidgetKeyboardEvent& aKeyboardEvent, nsEventStatus& aStatus, DispatchTo aDispatchTo, uint32_t aIndexOfKeypress) { MOZ_ASSERT(aMessage == eKeyDown || aMessage == eKeyUp || aMessage == eKeyPress, "Invalid aMessage value"); nsresult rv = GetState(); if (NS_WARN_IF(NS_FAILED(rv))) { return false; } // If the key shouldn't cause keypress events, don't this patch them. if (aMessage == eKeyPress && !aKeyboardEvent.ShouldCauseKeypressEvents()) { return false; } // Basically, key events shouldn't be dispatched during composition. if (IsComposing()) { // However, if we need to behave like other browsers, we need the keydown // and keyup events. Note that this behavior is also allowed by D3E spec. // FYI: keypress events must not be fired during composition. if (!sDispatchKeyEventsDuringComposition || aMessage == eKeyPress) { return false; } // XXX If there was mOnlyContentDispatch for this case, it might be useful // because our chrome doesn't assume that key events are fired during // composition. } WidgetKeyboardEvent keyEvent(true, aMessage, mWidget); InitEvent(keyEvent); keyEvent.AssignKeyEventData(aKeyboardEvent, false); if (aStatus == nsEventStatus_eConsumeNoDefault) { // If the key event should be dispatched as consumed event, marking it here. // This is useful to prevent double action. E.g., when the key was already // handled by system, our chrome shouldn't handle it. keyEvent.mFlags.mDefaultPrevented = true; } // Corrects each member for the specific key event type. if (aMessage == eKeyDown || aMessage == eKeyUp) { MOZ_ASSERT(!aIndexOfKeypress, "aIndexOfKeypress must be 0 for either eKeyDown or eKeyUp"); // charCode of keydown and keyup should be 0. keyEvent.charCode = 0; } else if (keyEvent.mKeyNameIndex != KEY_NAME_INDEX_USE_STRING) { MOZ_ASSERT(!aIndexOfKeypress, "aIndexOfKeypress must be 0 for eKeyPress of non-printable key"); // If keypress event isn't caused by printable key, its charCode should // be 0. keyEvent.charCode = 0; } else { MOZ_RELEASE_ASSERT( !aIndexOfKeypress || aIndexOfKeypress < keyEvent.mKeyValue.Length(), "aIndexOfKeypress must be 0 - mKeyValue.Length() - 1"); keyEvent.keyCode = 0; wchar_t ch = keyEvent.mKeyValue.IsEmpty() ? 0 : keyEvent.mKeyValue[aIndexOfKeypress]; keyEvent.charCode = static_cast<uint32_t>(ch); if (ch) { keyEvent.mKeyValue.Assign(ch); } else { keyEvent.mKeyValue.Truncate(); } } if (aMessage == eKeyUp) { // mIsRepeat of keyup event must be false. keyEvent.mIsRepeat = false; } // mIsComposing should be initialized later. keyEvent.mIsComposing = false; // XXX Currently, we don't support to dispatch key event with native key // event information. keyEvent.mNativeKeyEvent = nullptr; // XXX Currently, we don't support to dispatch key events with data for // plugins. keyEvent.mPluginEvent.Clear(); // TODO: Manage mUniqueId here. DispatchInputEvent(mWidget, keyEvent, aStatus, aDispatchTo); return true; }
CLIENT_EXPORT_API void __stdcall AI() { hHero_1 = Tc_GetHeroHandle(TC_MEMBER1); hHero_2 = Tc_GetHeroHandle(TC_MEMBER2); hEnemy_1 = Tc_GetEnemyHandle(TC_MEMBER1); hEnemy_2 = Tc_GetEnemyHandle(TC_MEMBER2); hGhostBall = Tc_GetBallHandle(TC_GHOST_BALL); Tc_GetBallInfo(hGhostBall,&iGhostBall); Tc_GetHeroInfo(hHero_1,&iHero_1); Tc_GetHeroInfo(hHero_2,&iHero_2); Tc_GetEnemyInfo(hEnemy_1,&iEnemy_1); Tc_GetEnemyInfo(hEnemy_2,&iEnemy_2); Tc_GetOwnGate(hHero_1,&iOwnGate); Tc_GetEnemyGate(hEnemy_1,&iEnemyGate); Tc_GetForbiddenArea(&iForbiddenArea); if (iOwnGate.x < iEnemyGate.x) { iAttackDirection = TC_DIRECTION_RIGHT; } else { iAttackDirection = TC_DIRECTION_LEFT; } int state = GetState(); switch(state) { case GHOSTBALL_IN_SELF_TEAM: { TC_Position iPos; if (iAttackDirection==TC_DIRECTION_LEFT) { if (iHeroWithBall.pos.x<=1024) //禁区-100后有人接近放魔 { /////////////////// if( GetBallDistance(iEnemy_1,iGhostBall)<=400) { if (Tc_CanBeSpelled(hHero_1,hEnemy_1)) { Tc_Spell(hHero_1,hEnemy_1); } } if( GetBallDistance(iEnemy_2,iGhostBall)<=400) { if (Tc_CanBeSpelled(hHero_1,hEnemy_2)) { Tc_Spell(hHero_1,hEnemy_1); } } } if (iHeroWithBall.pos.x<(iForbiddenArea.right.left-100)&&(iHeroWithBall.pos.x>(iForbiddenArea.left.right+100))) { iPos.x = iForbiddenArea.left.right+1; iPos.y = (iEnemyGate.y_upper+iEnemyGate.y_lower)/2; if ((iEnemy_1.pos.x<(iForbiddenArea.right.left+100))&(iEnemy_1.pos.x>(iForbiddenArea.right.left-100))) { if (iEnemy_1.pos.y<iPos.y) { iPos.y=iPos.y+100; Tc_PassBall(hHeroWithBall,iPos); } else { iPos.y=iPos.y-100; Tc_PassBall(hHeroWithBall,iPos); } break; } if ((iEnemy_2.pos.x<(iForbiddenArea.right.left+100))&(iEnemy_2.pos.x>(iForbiddenArea.right.left-100))) { if (iEnemy_2.pos.y<iPos.y) { iPos.y=iPos.y+100; Tc_PassBall(hHeroWithBall,iPos); } else { iPos.y=iPos.y-100; Tc_PassBall(hHeroWithBall,iPos); } break; } Tc_PassBall(hHeroWithBall,iPos); } Tc_Move(hHeroWithBall,GetAttackDirection(&iHeroWithBall)); } else //向右进攻 { if (iHeroWithBall.pos.x>=1024) //禁区+100后有人接近放魔 { /////////////////// if( GetBallDistance(iEnemy_1,iGhostBall)<=400) { if (Tc_CanBeSpelled(hHero_1,hEnemy_1)) { Tc_Spell(hHero_1,hEnemy_1); } } if( GetBallDistance(iEnemy_2,iGhostBall)<=400) { if (Tc_CanBeSpelled(hHero_1,hEnemy_2)) { Tc_Spell(hHero_1,hEnemy_2); } } } if (iHeroWithBall.pos.x>(iForbiddenArea.left.right+100)&&iHeroWithBall.pos.x<(iForbiddenArea.right.left-100)) { iPos.x = iForbiddenArea.right.left-1; iPos.y = (iEnemyGate.y_upper+iEnemyGate.y_lower)/2; if ((iEnemy_1.pos.x<(iForbiddenArea.right.left+100))&(iEnemy_1.pos.x>(iForbiddenArea.right.left-100))) { if (iEnemy_1.pos.y<iPos.y) { iPos.y=iPos.y+100; Tc_PassBall(hHeroWithBall,iPos); } else { iPos.y=iPos.y-100; Tc_PassBall(hHeroWithBall,iPos); } break; } if ((iEnemy_2.pos.x<(iForbiddenArea.right.left+100))&(iEnemy_2.pos.x>(iForbiddenArea.right.left-100))) { if (iEnemy_2.pos.y<iPos.y) { iPos.y=iPos.y+100; Tc_PassBall(hHeroWithBall,iPos); } else { iPos.y=iPos.y-100; Tc_PassBall(hHeroWithBall,iPos); } break; } Tc_PassBall(hHeroWithBall,iPos); } Tc_Move(hHeroWithBall,GetAttackDirection(&iHeroWithBall)); } break; } case GHOSTBALL_IN_ENEMY_TEAM: { if (iAttackDirection == TC_DIRECTION_RIGHT) { if (iEnemyWithBall.pos.x - iOwnGate.x <= 200) { if (Tc_Spell(hHero_2,hEnemyWithBall)) { break; } else { Tc_Spell(hHero_1,hEnemyWithBall); } if(iHero_1.pos.x!=iGhostBall.pos.x || iHero_1.pos.y!=iGhostBall.pos.y) Tc_Move(hHero_1,GetBallDirection(&iHero_1,&iGhostBall)); if(iHero_2.pos.x!=iGhostBall.pos.x || iHero_2.pos.y!=iGhostBall.pos.y) Tc_Move(hHero_2,GetBallDirection(&iHero_2,&iGhostBall)); break; } if (iEnemyWithBall.pos.x < iForbiddenArea.left.right && iEnemyWithBall.pos.x-iOwnGate.x > 200) { if (iHero_1.b_snatch_ghostball == true||iHero_2.b_snatch_ghostball == true) { if (Tc_SnatchBall(hHero_1,TC_GHOST_BALL) == true) { break; } else { if (Tc_SnatchBall(hHero_2,TC_GHOST_BALL) == true)//1眩晕,2吹飞 { break; } Tc_Spell(hHero_1,hEnemyWithBall); } } else { Tc_Spell(hHero_1,hEnemyWithBall); } } } else //向左进攻 { if (iOwnGate.x - iEnemyWithBall.pos.x <= 200) { if (Tc_Spell(hHero_2,hEnemyWithBall))//1眩晕,2吹飞 { break; } else { Tc_Spell(hHero_1,hEnemyWithBall); } if(iHero_1.pos.x!=iGhostBall.pos.x || iHero_1.pos.y!=iGhostBall.pos.y) Tc_Move(hHero_1,GetBallDirection(&iHero_1,&iGhostBall)); if(iHero_2.pos.x!=iGhostBall.pos.x || iHero_2.pos.y!=iGhostBall.pos.y) Tc_Move(hHero_2,GetBallDirection(&iHero_2,&iGhostBall)); break; } if (iEnemyWithBall.pos.x > iForbiddenArea.right.left && iOwnGate.x-iEnemyWithBall.pos.x > 200) { if (iHero_1.b_snatch_ghostball == true||iHero_2.b_snatch_ghostball==true) { if (Tc_SnatchBall(hHero_1,TC_GHOST_BALL) == true) { break; } else { if (Tc_SnatchBall(hHero_2,TC_GHOST_BALL)==true) { break; } Tc_Spell(hHero_1,hEnemyWithBall); } } else { Tc_Spell(hHero_1,hEnemyWithBall); } } } if (iHero_1.b_snatch_ghostball == true) { if (Tc_SnatchBall(hHero_1,TC_GHOST_BALL) == true) { break; } } if (iHero_2.b_snatch_ghostball == true) { if (Tc_SnatchBall(hHero_2,TC_GHOST_BALL) == true) { break; } } if(iHero_1.pos.x!=iGhostBall.pos.x || iHero_1.pos.y!=iGhostBall.pos.y) Tc_Move(hHero_1,GetBallDirection(&iHero_1,&iGhostBall)); Tc_Move(hHero_2,GetBallDirection(&iHero_1,&iGhostBall)); break; } case GHOSTBALL_IN_NO_TEAM: { if (iGameInfo.game_time_left>=89000) { if ((sqrt(double(iEnemy_1.pos.x-iGhostBall.pos.x))+sqrt(double(iEnemy_1.pos.y-iGhostBall.pos.y)))<=(sqrt(double(iEnemy_2.pos.x-iGhostBall.pos.x))+sqrt(double(iEnemy_2.pos.y-iGhostBall.pos.y)))) { Tc_Spell(hHero_2,hEnemy_1); } else { Tc_Spell(hHero_2,hEnemy_2); } } if (iHero_1.b_snatch_ghostball == false) { if(iHero_1.pos.x!=iGhostBall.pos.x || iHero_1.pos.y!=iGhostBall.pos.y) Tc_Move(hHero_1,GetBallDirection(&iHero_1,&iGhostBall)); } else { Tc_SnatchBall(hHero_1,TC_GHOST_BALL); } if (iHero_2.b_ghostball == false) { if(iHero_2.pos.x!=iGhostBall.pos.x || iHero_2.pos.y!=iGhostBall.pos.y) Tc_Move(hHero_2,GetBallDirection(&iHero_2,&iGhostBall)); } else { Tc_SnatchBall(hHero_2,TC_GHOST_BALL); } break; } default: { break; } } }
bool IsRunning() { return (GetState() != CORE_UNINITIALIZED || s_hardware_initialized) && !s_is_stopping; }
void GeblGuiEditorBase::Draw(void) { if(YSTRUE!=drawingMasterSwitch) { DrawGuiOnly(); return; } // Do this at the beginning of Draw funtion. This will allow one of the elements set SetNeedRedraw(YSTRUE) // within drawing function so that Draw function will be called again in the next iteragion. >> SetNeedRedraw(YSFALSE); drawEnv.SetNeedRedraw(YSFALSE); threeDInterface.SetNeedRedraw(YSFALSE); // << glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1,1); if(NULL==slHd) { if(NULL!=GetTopStatusBar()) { GetTopStatusBar()->ClearStringAll(); } if(NULL!=GetBottomStatusBar()) { GetBottomStatusBar()->ClearStringAll(); } } if(NULL!=slHd && NULL!=GetTopStatusBar()) { YsWString ful,pth,fil; slHd->GetFileName(ful); ful.SeparatePathFile(pth,fil); if(YSTRUE==slHd->IsModified()) { fil.Append(L"(*)"); } YsWString curMsg; if(0!=YsWString::Strcmp(fil,GetTopStatusBar()->GetString(curMsg,0))) { GetTopStatusBar()->SetString(0,fil); } } if(NULL!=slHd && NULL!=GetBottomStatusBar()) { YsString str("Selection"); YsString append; { YsArray <YsShellVertexHandle> selVtHd; slHd->GetSelectedVertex(selVtHd); if(0<selVtHd.GetN()) { append.Printf(" Vertex:%d",(int)selVtHd.GetN()); str.Append(append); } } { YsArray <YsShellPolygonHandle> selPlHd; slHd->GetSelectedPolygon(selPlHd); if(0<selPlHd.GetN()) { append.Printf(" Polygon:%d",(int)selPlHd.GetN()); str.Append(append); } } { YsArray <YsShellExt::ConstEdgeHandle> selCeHd; slHd->GetSelectedConstEdge(selCeHd); if(0<selCeHd.GetN()) { append.Printf(" ConstEdge:%d",(int)selCeHd.GetN()); str.Append(append); } } { YsArray <YsShellExt::FaceGroupHandle> selFgHd; slHd->GetSelectedFaceGroup(selFgHd); if(0<selFgHd.GetN()) { append.Printf(" FaceGroup:%d",(int)selFgHd.GetN()); str.Append(append); } } GetBottomStatusBar()->SetString(0,str); } int viewport[4]; drawEnv.GetOpenGlCompatibleViewport(viewport); drawEnv.SetVerticalOrientation(YSTRUE); drawEnv.UpdateNearFar(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); if(YsCoordSysModel==YSOPENGL) { glFrontFace(GL_CCW); } else { glFrontFace(GL_CW); } const YsMatrix4x4 &projMat=drawEnv.GetProjectionMatrix(); const YsMatrix4x4 &viewMat=drawEnv.GetViewMatrix(); const YsMatrix4x4 projViewMat=(projMat*viewMat); threeDInterface.SetViewport(viewport); threeDInterface.SetProjViewModelMatrix(projViewMat); glViewport(viewport[0],viewport[1],viewport[2],viewport[3]); GLfloat glProjMat[16]; projMat.GetOpenGlCompatibleMatrix(glProjMat); GLfloat glModelviewMat[16]; viewMat.GetOpenGlCompatibleMatrix(glModelviewMat); // glMatrixMode(GL_PROJECTION); // glLoadIdentity(); // glMultMatrixf(glProjMat); // glMatrixMode(GL_MODELVIEW); // glLoadIdentity(); // glMultMatrixf(glModelviewMat); YsGLSLSetShared3DRendererProjection(glProjMat); YsGLSLSetShared3DRendererModelView(glModelviewMat); YsVec3 lightDir=YsUnitVector(YsVec3(0.1,1.0,3.0)); const GLfloat lightDirf[]={lightDir.xf(),lightDir.yf(),lightDir.zf()}; YsGLSLSetShared3DRendererDirectionalLightInCameraCoordinatefv(0,lightDirf); YsGLSLSetShared3DRendererSpecularColor(config->GetSpecularColor()); YsGLSLSetShared3DRendererAmbientColor(config->GetAmbientColor()); YsGLSLSetShared3DRendererLightColor(0,config->GetLightColor()); actuallyDrawVertex=drawVertex; actuallyDrawConstEdge=drawConstEdge; actuallyDrawPolygonEdge=drawPolygonEdge; actuallyDrawPolygon=drawPolygon; actuallyDrawShrunkPolygon=drawShrunkPolygon; actuallyDrawNonManifoldEdge=drawNonManifoldEdge; if(NULL!=UIBeforeDrawCallBack) { (*UIBeforeDrawCallBack)(*this); } glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); if(YSTRUE==viewDrawBackgroundGradation->GetCheck() && (NULL==guiExtension || YSTRUE!=guiExtension->DrawBackground())) { // Linear interpolation looks to be too fast. Probably need three colors. YsGLSLUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer()); YsGLSLUseWindowCoordinateInPlain2DDrawing(YsGLSLSharedPlain2DRenderer(),YSTRUE); glDepthMask(0); const GLfloat rect[12]= { 0 ,0, (GLfloat)viewport[2],0, 0 ,(GLfloat)viewport[3]/2.0f, (GLfloat)viewport[2],(GLfloat)viewport[3]/2.0f, 0 ,(GLfloat)viewport[3], (GLfloat)viewport[2],(GLfloat)viewport[3] }; const GLfloat color[24]= { config->bgColor[0].Rf(),config->bgColor[0].Gf(),config->bgColor[0].Bf(),1, config->bgColor[0].Rf(),config->bgColor[0].Gf(),config->bgColor[0].Bf(),1, config->bgColor[1].Rf(),config->bgColor[1].Gf(),config->bgColor[1].Bf(),1, config->bgColor[1].Rf(),config->bgColor[1].Gf(),config->bgColor[1].Bf(),1, config->bgColor[2].Rf(),config->bgColor[2].Gf(),config->bgColor[2].Bf(),1, config->bgColor[2].Rf(),config->bgColor[2].Gf(),config->bgColor[2].Bf(),1 }; YsGLSLDrawPlain2DPrimitivefv(YsGLSLSharedPlain2DRenderer(),GL_TRIANGLE_STRIP,6,rect,color); glDepthMask(1); YsGLSLEndUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer()); } threeDInterface.Draw(); if(NULL!=slHd && YSTRUE==slHd->NeedRemakeHighlightVertexBuffer()) { slHd->GetHighlight().RemakeVertexBuffer(*slHd); slHd->SetNeedRemakeHighlightVertexBuffer(YSFALSE); } if(NEED_REMAKE_DRAWING_NONE!=needRemakeDrawingBuffer || (nullptr!=slHd && YSTRUE==slHd->GetTemporaryModification().Changed())) { RemakeDrawingBuffer(slHd,needRemakeDrawingBuffer); needRemakeDrawingBuffer=NEED_REMAKE_DRAWING_NONE; slHd->GetTemporaryModification().ClearChangeFlag(); } if(NEED_REMAKE_DRAWING_NONE!=needRemakeDrawingBuffer_for_OtherShell && YSTRUE==actuallyDrawOtherShell) { YsArray <YsShellDnmContainer <YsShellExtEditGui>::Node *> allNode; shlGrp.GetNodePointerAll(allNode); for(YSSIZE_T nodeIdx=0; nodeIdx<allNode.GetN(); ++nodeIdx) { if(slHd!=allNode[nodeIdx]) { RemakeDrawingBuffer(allNode[nodeIdx],needRemakeDrawingBuffer_for_OtherShell); } } needRemakeDrawingBuffer_for_OtherShell=NEED_REMAKE_DRAWING_NONE; } { GLfloat prevTfm[16]; GLfloat curNodeTfm[16]; if(YSTRUE==dnmEditMode) { YsMatrix4x4 curMat; { YsGLSLShaded3DRenderer renderer; renderer.GetModelView(prevTfm); curMat.CreateFromOpenGlCompatibleMatrix(prevTfm); } YsMatrix4x4 tfm=curMat*dnmState.GetNodeToRootTransformation(slHd); tfm.GetOpenGlCompatibleMatrix(curNodeTfm); YsGLSLSetShared3DRendererModelView(curNodeTfm); } YsShellExtDrawingBuffer &drawBuf=slHd->GetDrawingBuffer(); if(YSTRUE==actuallyDrawVertex && NULL!=slHd) { GeblGuiFoundation::DrawVertex(*slHd,viewport); } if(0<drawBuf.selectedVertexPosBuffer.GetNumVertex() && NULL!=slHd) { GeblGuiFoundation::DrawSelectedVertex(*slHd,viewport); } if(0<drawBuf.selectedVertexLineBuffer.GetNumVertex() && NULL!=slHd) { GeblGuiFoundation::DrawSelectedVertexLine(*slHd); } if(YSTRUE==actuallyDrawPolygonEdge && NULL!=slHd) { GeblGuiFoundation::DrawPolygonEdge(*slHd); } if(YSTRUE==actuallyDrawShrunkPolygon && NULL!=slHd) { GeblGuiFoundation::DrawShrunkPolygon(*slHd); } if(0<drawBuf.selectedPolygonPosBuffer.GetNumVertex() && NULL!=slHd) { GeblGuiFoundation::DrawSelectedPolygon(*slHd); } if(YSTRUE==actuallyDrawConstEdge && 0<drawBuf.constEdgeVtxBuffer.GetNumVertex() && NULL!=slHd) { GeblGuiFoundation::DrawConstEdge(*slHd); } if(0<drawBuf.selectedConstEdgeVtxBuffer.GetNumVertex() && NULL!=slHd) { GeblGuiFoundation::DrawSelectedConstEdge(*slHd); } if(YSTRUE==dnmEditMode) { YsGLSLSetShared3DRendererModelView(prevTfm); } if(YSTRUE!=dnmEditMode) { DrawInGeometryEditMode(); } else { DrawInDnmEditMode(); } if(YSTRUE==dnmEditMode) { YsGLSLSetShared3DRendererModelView(curNodeTfm); } if(0<=drawBuf.selectedFaceGroupVtxBuffer.GetNumVertex() && NULL!=slHd) { GeblGuiFoundation::DrawSelectedFaceGroup(*slHd); } if(YSTRUE==dnmEditMode) { YsGLSLSetShared3DRendererModelView(prevTfm); } } if(NULL!=slHd && YSTRUE==actuallyDrawNonManifoldEdge) { if(YSTRUE==nonManifoldEdgeCache.IsModified(slHd)) { nonManifoldEdgeCache.CacheNonManifoldEdge(slHd); } struct YsGLSL3DRenderer *renderer=YsGLSLSharedVariColor3DRenderer(); YsGLSLUse3DRenderer(renderer); glLineWidth(3); YsGLSLDrawPrimitiveVtxColfv(renderer,GL_LINES,nonManifoldEdgeCache.lineVtxBuf.GetNi(),nonManifoldEdgeCache.lineVtxBuf,nonManifoldEdgeCache.lineColBuf); glLineWidth(1); YsGLSLEndUse3DRenderer(renderer); // The following could have easily be done by glPointSize. However, stupid OpenGL ES 2.0 got rid of glPointSize. // OpenGL ES should be gone. The hardware on the tablets and smart phones are good enough to support full-blown // OpenGL. OpenGL ES will be remembered as a dark history of OpenGL. That is bad. Not as bad as Direct 3D though. renderer=YsGLSLSharedVariColorMarkerByPointSprite3DRenderer(); YsGLSLUse3DRenderer(renderer); #ifdef GL_PROGRAM_POINT_SIZE glEnable(GL_POINT_SPRITE); glEnable(GL_PROGRAM_POINT_SIZE); #endif YsGLSLSet3DRendererUniformMarkerType(renderer,YSGLSL_MARKER_TYPE_RECT); YsGLSLSet3DRendererUniformMarkerDimension(renderer,3.0f); YsGLSLDrawPrimitiveVtxColfv( renderer,GL_POINTS, nonManifoldEdgeCache.pointVtxBuf.GetNi(), nonManifoldEdgeCache.pointVtxBuf, nonManifoldEdgeCache.pointColBuf); #ifdef GL_PROGRAM_POINT_SIZE glDisable(GL_POINT_SPRITE); glDisable(GL_PROGRAM_POINT_SIZE); #endif YsGLSLEndUse3DRenderer(renderer); } if(YSTRUE==drawHighlight) { auto &bufManager=YsGLBufferManager::GetSharedBufferManager(); auto &highlight=slHd->GetHighlight(); YsGLSLRenderer renderer(YsGLSLSharedFlat3DRenderer()); const GLfloat blue[]={0.0f,0.0f,1.0f,1.0f}; YsGLSLSet3DRendererUniformColorfv(renderer,blue); { auto unitPtr=bufManager.GetBufferUnit(highlight.highlightedEdgeVboHandle); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { unitPtr->GetActualBuffer()->DrawPrimitiveVtx(renderer,GL_LINES); } } glLineWidth(2); { auto unitPtr=bufManager.GetBufferUnit(highlight.highlightedThickEdgeVboHandle); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { unitPtr->GetActualBuffer()->DrawPrimitiveVtx(renderer,GL_LINES); } } glLineWidth(1); const GLfloat darkBlue[]={0.0f,0.0f,0.7f,1.0f}; YsGLSLSet3DRendererUniformColorfv(renderer,darkBlue); { auto unitPtr=bufManager.GetBufferUnit(highlight.highlightedPolygonVboHandle); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { unitPtr->GetActualBuffer()->DrawPrimitiveVtx(renderer,GL_TRIANGLES); } } } if(NULL!=UIDrawCallBack3D) { UIDrawCallBack3D(*this); } if(draw3dCallBack) { draw3dCallBack(); } refBmpStore->Draw(); if(YSTRUE==drawAxis) { const GLfloat axisLength=5.0; GeblGuiFoundation::DrawAxis(axisLength,viewport,projMat,viewMat); } // 2D Drawing // glMatrixMode(GL_PROJECTION); // glLoadIdentity(); // glOrtho(0.0,(double)viewport[2],(double)viewport[3],0.0,-1.0,1.0); // glMatrixMode(GL_MODELVIEW); // glLoadIdentity(); YsGLSLUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer()); YsGLSLUseWindowCoordinateInPlain2DDrawing(YsGLSLSharedPlain2DRenderer(),YSTRUE); { if(YSTRUE==lBtnDown) { const GLfloat rect[8]= { (GLfloat)lBtnDownMx,(GLfloat)lBtnDownMy, (GLfloat)moveMx, (GLfloat)lBtnDownMy, (GLfloat)moveMx, (GLfloat)moveMy, (GLfloat)lBtnDownMx,(GLfloat)moveMy }; const GLfloat color[16]= { 0,0,0,0.8f, 0,0,0,0.8f, 0,0,0,0.8f, 0,0,0,0.8f }; YsGLSLDrawPlain2DPrimitivefv(YsGLSLSharedPlain2DRenderer(),GL_LINE_LOOP,4,rect,color); } } YsGLSLEndUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer()); glDisable(GL_DEPTH_TEST); FsGuiCanvas::Show(); if(NULL!=UIDrawCallBack2D) { (*UIDrawCallBack2D)(*this); } FsSwapBuffers(); }
void GeblGuiEditorBase::DrawInGeometryEditMode(void) { if(YSTRUE==actuallyDrawPolygon && NULL!=slHd) { // auto &buf=slHd->GetDrawingBuffer(); auto &vboSet=slHd->GetVboSet(); auto &bufManager=YsGLBufferManager::GetSharedBufferManager(); glEnable(GL_CULL_FACE); if(NULL!=YsGLSLSharedVariColorShaded3DRenderer()) { auto unitPtr=bufManager.GetBufferUnit(vboSet.solidShadedPosNomColHd); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { YsGLSLRenderer renderer(YsGLSLSharedVariColorShaded3DRenderer()); unitPtr->GetActualBuffer()->DrawPrimitiveVtxNomCol(renderer,GL_TRIANGLES); } } if(NULL!=YsGLSLSharedVariColor3DRenderer()) { YsGLSLRenderer renderer(YsGLSLSharedVariColor3DRenderer()); { auto unitPtr=bufManager.GetBufferUnit(vboSet.solidUnshadedPosColHd); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { unitPtr->GetActualBuffer()->DrawPrimitiveVtxCol(renderer,GL_TRIANGLES); } } { auto unitPtr=bufManager.GetBufferUnit(vboSet.backFacePosColHd); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { unitPtr->GetActualBuffer()->DrawPrimitiveVtxCol(renderer,GL_TRIANGLES); } } } if(NULL!=YsGLSLSharedVariColorShaded3DRenderer()) { auto unitPtr=bufManager.GetBufferUnit(vboSet.trspShadedPosNomColHd); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { YsGLSLRenderer renderer(YsGLSLSharedVariColorShaded3DRenderer()); unitPtr->GetActualBuffer()->DrawPrimitiveVtxNomCol(renderer,GL_TRIANGLES); } } if(NULL!=YsGLSLSharedVariColor3DRenderer()) { auto unitPtr=bufManager.GetBufferUnit(vboSet.trspUnshadedPosColHd); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { YsGLSLRenderer renderer(YsGLSLSharedVariColor3DRenderer()); unitPtr->GetActualBuffer()->DrawPrimitiveVtxNomCol(renderer,GL_TRIANGLES); } } if(NULL!=YsGLSLSharedFlashByPointSprite3DRenderer()) { auto unitPtr=bufManager.GetBufferUnit(vboSet.lightPosColPointSizeHd); if(nullptr!=unitPtr && YsGLBufferManager::Unit::EMPTY!=unitPtr->GetState()) { int viewport[4]; glGetIntegerv(GL_VIEWPORT,viewport); #ifdef GL_PROGRAM_POINT_SIZE glEnable(GL_PROGRAM_POINT_SIZE); // Needed for enabling gl_PointSize in the vertex shader. glEnable(GL_POINT_SPRITE); // Needed for enabling gl_PointCoord in the fragment shader. #endif YsGLSLRenderer renderer(YsGLSLSharedFlashByPointSprite3DRenderer()); YsGLSLSet3DRendererViewportDimensionf(renderer,(float)viewport[2],(float)viewport[3]); YsGLSLSet3DRendererPointSizeMode(renderer,YSGLSL_POINTSPRITE_SIZE_IN_3DSPACE); unitPtr->GetActualBuffer()->DrawPrimitiveVtxColPointSize(renderer,GL_POINTS); #ifdef GL_PROGRAM_POINT_SIZE glDisable(GL_PROGRAM_POINT_SIZE); glDisable(GL_POINT_SPRITE); #endif } } glDisable(GL_CULL_FACE); } if(YSTRUE==actuallyDrawOtherShell) { YsArray <const YsShellDnmContainer <YsShellExtEditGui>::Node *,16> allNode; shlGrp.GetNodePointerAll(allNode); for(YSSIZE_T nodeIdx=0; nodeIdx<allNode.GetN(); ++nodeIdx) { if(slHd!=allNode[nodeIdx]) { YsShellExtDrawingBuffer &buf=allNode[nodeIdx]->GetDrawingBuffer(); YsGLSLRenderer renderer(YsGLSLSharedFlat3DRenderer()); const GLfloat edgeCol[4]={0,0,0,0.2f}; YsGLSLSet3DRendererUniformColorfv(renderer,edgeCol); YsGLSLDrawPrimitiveVtxfv(renderer,GL_LINES,buf.normalEdgePosBuffer.GetNi(),buf.normalEdgePosBuffer); } } } }