bool Shot_net::Action(Game_Manager* gm_) { if(valid) { if(gm_) { for(list<Unit*>::iterator it = gm_->unit_list.begin();it != gm_->unit_list.end();it++) { if((*it)->isLive() && !(*it)->isNonTarget() && (*it)->GetTeam() != GetTeam() && (*it)->isCollution()) { if((*it)->collution(GetPos(), 5.0f)) { (*it)->SetNet(net_time); (*it)->StateApply("그물",net_time); valid = false; } } } } if(collution(3)) { valid = false; } else Move(); distance -= const_speed; if(distance<0) valid = false; } if(!valid) { return true; } return false; }
float Bazooka::Shot(Game_Manager* gm_, Unit* User_, int team_, const coord_def& start_, const coord_def& pos_, float focus_) { float angle_ = GetAngleToTarget(start_, pos_); if(UseBullet(1)) { for(int i = 0;i<bunch;i++) { float focus2_ = rand_float(-focus_, focus_, "Bazooka::Shot focus"); float speed2_ = shot_speed*GetShotSpeedApply(); float damage_ = damage*GetDamegeApply()*(User_?User_->GetAtkApply():1.0f); gm_->shot_list.push_back(new Shot_missile(&tex_missile, User_, damage_, GetPower(), GetMaxPower(), range, team_, start_, angle_+focus2_, speed2_, guided_range, guided_power, GetDistance())); } if (gm_->isPlayerCanHear(GetPos())) { PlaySE(se_rocket, false); } gm_->Noise(team_,start_,GetNoise() * User_->GetSilencer()); return burst_speed*(1.0f/(GetBurstSpeedApply()*(User_?User_->GetAtkSpdApply():1.0f))); } return -1; }
void TopMenuItem::Render(const Camera& curCamera) { menu_DrawQuad(0.f, 0.f, m_w, m_h, 1.f); float x = kHSpace; float y = m_h - kVSpace; for(int i = 0, c = GetChildren().size(); i < c; ++i) { auto child = GetChildren()[i]; float titlew,titleh; child->GetTitleDims(titlew, titleh); const Color* col = (GetPos() == i) ? &kTextSelColor : &kTextColor; if(child->HasFlag(MENUSTATE_Active)) col = &kTextActiveColor; child->DrawTitle(x, y, *col); x += 2.f * kHSpace + titlew; } for(auto child: GetChildren()) if(child->HasFlag(MENUSTATE_Active)) child->Render(curCamera); }
bool FuelCell::Load(File*) { Vec3f p = GetPos(); float s = 5.0f; // TODO CONFIG m_aabb.Set(p.x - s, p.x + s, p.y - s, p.y + s, p.z - s, p.z + s); FuelNode* sm = new FuelNode; sm->SetAABB(m_aabb); SetSceneNode(sm); Billboard* bb = new Billboard; Texture* tex = (Texture*)TheResourceManager::Instance()->GetRes("flare.png"); bb->SetTexture(tex); bb->SetSize(30.0f); // TODO CONFIG bb->SetAABB(m_aabb); sm->AddChild(bb); return true; }
GoalMapTarget::~GoalMapTarget() { sint32 index; if (what_goal != GOAL_TYPE_WANDER) { GetPos(*m_pos); m_ai->m_planner->the_strategic_map-> SetAreaGoal(*m_pos, what_goal, NULL); } else { index = m_ai->m_wanderGoalTargets->Find(this); Assert(index >= 0); if (index >= 0) m_ai->m_wanderGoalTargets->DelIndexFlat(index); } }
bool COggFile::Sync(HANDLE hBreak) { __int64 start = GetPos(); DWORD dw; for(__int64 i = 0, j = hBreak ? GetLength() - start : 65536; i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw)) && ((i&0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0); i++, Seek(start + i)) { if(dw == 'SggO') { Seek(start + i); return(true); } } Seek(start); return(false); }
void Player::OnLocationEntry() { Ve1ObjectChar::OnLocationEntry(); SceneNode* root = GetVe1SceneGraph()->GetRootNode(SceneGraph::AMJU_OPAQUE); if (root) { root->AddChild(m_arrow.GetPtr()); SetArrowVis(false); } m_nameTag = new PlayerNameNode(this); if (m_sceneNode) { if (m_nameTag) { m_sceneNode->AddChild(m_nameTag.GetPtr()); } if (m_effect) { m_sceneNode->AddChild(m_effect.GetPtr()); } } // TODO Portal should have a heading which you should face when you appear at the destination m_isMoving = false; SetVel(Vec3f(0, 0, 0)); // TODO walk out of doorway ? // TODO Set m_newPos ?? // Set appearance SetLoggedIn(IsLoggedIn()); // If we are carrying something, change its location too if (m_carrying) { TheObjectUpdater::Instance()->SendChangeLocationReq(m_carrying->GetId(), GetPos(), GetLocation()); } }
void CVolumeCtrl::IncreaseVolume() { AppSettings& s = AfxGetCurrentSettings(); if(GetPos() > 99 && !s.fAudioNormalize){ SetPosInternal(GetPos() + 1); /* DWORD plVolume; int WaveOutVol = 100; // if(MMSYSERR_NOERROR == waveOutGetVolume(0, (DWORD*)plVolume) ){ // WaveOutVol = (HIWORD(plVolume) + LOWORD(plVolume)) * 100 / 2 / 0xFFFF; // } if( WaveOutVol > 90){ int iBVol = (int)(50.0f*log10(s.AudioBoost)); iBVol = min(iBVol + 8, 100); s.AudioBoost = pow(10.0f, (float)iBVol/50); if( s.AudioBoost > 100) s.AudioBoost = 100; }else{ //increaseWaveOut //plVolume = (min( (HIWORD(plVolume) + 0x0FFF), 0xFFFF) << 16) | min( (LOWORD(plVolume) + 0x0FFF), 0xFFFF) ; //waveOutSetVolume(0, plVolume); }*/ }else{ if (GetPos() > 95 ){ SetPosInternal(100); }else if (GetPos() > 25 ){ SetPosInternal(GetPos() + GetPageSize()); }else if (GetPos() > 15 ){ SetPosInternal(GetPos() + 3); }else{ SetPosInternal(GetPos() + 1); } } }
void UnitBase::DrawUnit( bool is_walk , bool is_attack) { DrawGraphInCamera( Vector2( ( GetPos().x - mImageSize.x / 2 ), ( GetPos().y - GetHeight() - mImageSize.y ) ), mImageSize, mAnimIndex + (is_walk ? 2 : 0) + (is_attack ? 4 : 0), mImageType, TRUE, ( mDir.x < 0.0f ) ); //HP DrawBox( static_cast<int>( mPos.x + gCamera2D().GetDrawOffset().x - 25), static_cast<int>( mPos.y + gCamera2D().GetDrawOffset().y ), static_cast<int>( mPos.x + gCamera2D().GetDrawOffset().x + 25 ), static_cast<int>( mPos.y + gCamera2D().GetDrawOffset().y + 4 ), GetColor(255,0,0) , TRUE); DrawBox( static_cast<int>( mPos.x + gCamera2D().GetDrawOffset().x - 25), static_cast<int>( mPos.y + gCamera2D().GetDrawOffset().y ), static_cast<int>( mPos.x + gCamera2D().GetDrawOffset().x - 25 + (50 * mHP / mHPMax) ), static_cast<int>( mPos.y + gCamera2D().GetDrawOffset().y + 4 ), GetColor(0,255,0) , TRUE); if( IsVisibleCollision() ){ // コリジョン DrawBox( static_cast<int>( GetPos().x - GetSize().x / 2 + gCamera2D().GetDrawOffset().x ), static_cast<int>( GetPos().y - GetSize().y / 2 + gCamera2D().GetDrawOffset().y ), static_cast<int>( GetPos().x + GetSize().x / 2 + gCamera2D().GetDrawOffset().x ), static_cast<int>( GetPos().y + GetSize().y / 2 + gCamera2D().GetDrawOffset().y ), ColorOf(255,0,0), FALSE ); } if( IsDamaged() ){ SetFontSize(32); DrawFormatString( static_cast<int>( mPos.x + gCamera2D().GetDrawOffset().x + 32), static_cast<int>( mPos.y + gCamera2D().GetDrawOffset().y + ( - 150 + mDamageFrame ) / 2 ), GetColor(255,255,0) , "%d", mDamage ); } }
void MY_UI::Controls::Resizable::Resizing(cWidgetBase* widget){ unsigned int t = widget->GetId(); Utilities::Point size = GetSize(); Utilities::Point pos = GetPos(); int deltax = New_MousePosx - Old_MousePosx; int deltay = New_MousePosy - Old_MousePosy; switch(t){ case(Utilities::Tr_to_Bl):// this is top right to bottom left if(widget == Internal_Resizable.BottomLeft){// this means the bottom control is being draggged!!! SetPos(pos.x+ deltax, pos.y); SetSize(size.x - deltax, size.y + deltay); } else { SetPos(pos.x, pos.y + deltay); SetSize(size.x + deltax, size.y - deltay);// otherwise, its the top right .. which doesnt need a new pos } break; case(Utilities::U_to_D):// this is top to bottom if(widget == Internal_Resizable.Top){// this means the top control is being draggged!!! SetPos(pos.x, pos.y + deltay); SetSize(size.x, size.y - deltay); } else SetSize(size.x, size.y + deltay);// otherwise, its the bottom .. which doesnt need a new pos break; case(Utilities::Tl_to_Br):// this is top left to bottom right if(widget == Internal_Resizable.TopLeft){// this means the top left control is being draggged!!! SetPos(pos.x + deltax, pos.y + deltay); SetSize(size.x - deltax, size.y - deltay); } else SetSize(size.x + deltax, size.y + deltay);// otherwise, its the bottom right.. which doesnt need a new pos break; case(Utilities::L_to_R):// this is left to right if(widget == Internal_Resizable.Left){// this means the left control is being draggged!!! SetPos(pos.x + deltax, pos.y); SetSize(size.x - deltax, size.y); } else SetSize(size.x + deltax, size.y);// otherwise, its the bottom .. which doesnt need a new pos break; }; }
void g2Controller::GetGlobalPos(int* x, int* y) { // Get this controller's global position // Which is the summation of all parent offsets int gX, gY, tX, tY; // Global, temp holders GetPos(&gX, &gY); g2Controller* Parent = GetParent(); while(Parent != NULL) { Parent->GetPos(&tX, &tY); gX += tX; gY += tY; Parent = Parent->GetParent(); } // Post results if(x != NULL) *x = gX; if(y != NULL) *y = gY; }
void CLED::OnDraw(const SRect &rUpdate) { if( !IsVisible() ) return; tfloat fDrawSize = (miCurrent - miMin) / (float)(miMax - miMin); int iPixelsToDraw = (int)(GetSize().iCY * fDrawSize); // Possion to draw from SPos Pos(GetPos() + SPos(0, GetSize().iCY - iPixelsToDraw)); // Size to draw SSize Size(GetSize().iCX, iPixelsToDraw); // Set rect to draw SRect Rect(Pos, Size); // Draw mpPrimitives->DrawRect(rUpdate, Rect, mColor); }
bool Monster::Melee(Game_Manager* gm_) { if(!GetDamage()) return false; bool ok_ = false; if(GetStop()) return false; for(list<Unit*>::iterator it = gm_->unit_list.begin();it != gm_->unit_list.end();it++) { if((*it)->isLive() && !(*it)->isNonTarget() && GetTeam() != (*it)->GetTeam()) { if(GetSize()+(*it)->GetSize()+5.0f > distan_coord(GetPos(), (*it)->GetPos())) { //if(각도가 맞으면) MeleeDamage(gm_,(*it)); SetDelay(30.0f); ok_ = true; } } } return ok_; }
bool CMissile::PointInObject (CVector vPos) // PointInObject // // Returns TRUE if the given point is inside the object { if (m_fDestroyed) return false; // Figure out the coordinates of vPos relative to the center of the // object, in pixels. CVector vOffset = vPos - GetPos(); int x = (int)((vOffset.GetX() / g_KlicksPerPixel) + 0.5); int y = -(int)((vOffset.GetY() / g_KlicksPerPixel) + 0.5); if (m_pPainter) return m_pPainter->PointInImage(x, y, m_iTick, (m_pDesc->m_bDirectional ? Angle2Direction(m_iRotation) : 0)); else return m_pDesc->m_Image.PointInImage(x, y, m_iTick, (m_pDesc->m_bDirectional ? Angle2Direction(m_iRotation) : 0)); }
bool DIALOG_DRC_CONTROL::focusOnItem( const DRC_ITEM* aItem ) { if( !aItem ) return false; auto toolmgr = m_brdEditor->GetToolManager(); auto pos = aItem->GetPointA(); auto marker = static_cast<MARKER_PCB*>( aItem->GetParent() ); if( marker ) { pos = marker->GetPos(); toolmgr->RunAction( PCB_ACTIONS::selectionClear, true ); toolmgr->RunAction( PCB_ACTIONS::selectItem, true, marker ); } toolmgr->GetView()->SetCenter( pos ); m_brdEditor->GetCanvas()->Refresh(); return true; }
bool Player::Special(Game_Manager* gm_, coord_def c, float focus_) { if(GetStop()) return false; if(current_weapon) { //focus_ += GetFocusSum(); //InitNoneMoveCount(); if(SetDelay(current_weapon->special(gm_, this, GetTeam(), GetPos(), c, focus_)) == -1) { //ÀÌ ºÎºÐÀº ¹Ì±¸Çö //SetDelay(0); return false; } else { //ÀÌ ºÎºÐµµ ¹Ì±¸Çö return true; } } return false; }
int MultiButton::FindButton(int px) { if(IsReadOnly()) return Null; if(IsTrivial() && !Frame()) return button[0].enabled ? 0 : Null; int border, lx, rx; Metrics(border, lx, rx); for(int i = 0; i < button.GetCount(); i++) { SubButton& b = button[i]; int x = 0, cx = 0; if(GetPos(b, lx, rx, x, cx, px)) return b.enabled ? i : Null; } if(WhenPush || WhenClick) return MAIN; if(display) for(int i = 0; i < button.GetCount(); i++) if(button[i].main) return i; return Null; }
dword BlockStream::_Get(void *data, dword size) { if(IsError() || !IsOpen()) return 0; LLOG("Get " << size); if(size == 0) return 0; _Term(); byte *t = (byte *)data; int64 pos0 = GetPos(); int64 pg0 = pos0 & pagemask; size = (int)min<int64>(GetSize() - pos0, size); int64 pos1 = pos0 + size; int64 pg1 = pos1 & pagemask; if(pg0 == pg1) { SyncPage(); memcpy(data, buffer + pos0 - pos, size); ptr = buffer + pos1 - pos; _Term(); } else { int last = int(pos1 - pg1); if(pagepos == pg1) { memcpy(t + size - last, buffer, last); last = 0; } SyncPage(); int n = int(pos + pagesize - pos0); memcpy(t, buffer + pos0 - pos, n); dword q = dword(pg1 - pg0) - pagesize; if(q && Read(pos + pagesize, t + n, q) != q) { SetError(); return 0; } SetPos(pos0 + size); if(last) { SyncPage(); memcpy(t + size - last, buffer, last); } } return size; }
void ChatEchoPanel::PerformLayout() { float history_w = ScreenWidth() * 0.625f; float w = ScreenWidth() * 0.86f; int iLines = 4; if (ScreenHeight() <= 480) iLines = 3; //else if (ScreenHeight() <= 600) int line_tall = ScreenHeight() * 0.02f; if (m_hFont != vgui::INVALID_FONT) { line_tall = vgui::surface()->GetFontTall(m_hFont); } float h = line_tall * (iLines + 1.75f); SetSize(w, h); //Msg("ChatEchoPanel::PerformLayout line_tall=%d h=%f ScreenHeight=%d inputliney=%f\n", //line_tall, h, ScreenHeight(), float(line_tall) * (iLines + 0.5f)); int x, y; GetPos(x, y); SetPos(x, ScreenHeight() - h); // centre the input line in whatever gap is left beneath our 4 chat lines m_pChatInputLine->SetBounds(0, line_tall * (iLines + 0.5f), w, line_tall+10); //Resize the History Panel so it fits more lines depending on the screen resolution. int iChatHistoryX, iChatHistoryY, iChatHistoryW, iChatHistoryH; if (m_pChatHistory) { m_pChatHistory->GetBounds( iChatHistoryX, iChatHistoryY, iChatHistoryW, iChatHistoryH ); iChatHistoryH = line_tall * iLines; m_pChatHistory->SetBounds( 0, (h - line_tall) - iChatHistoryH, history_w, iChatHistoryH ); } }
// パワーアーツ bool Thief::PowerArts(void) { if ( !initflag ) { artsTimer = 0; sound->PlaySE( SE::KAITO_POWER ); initflag = true; } SetMotion(THIEF::MOTION_DATA::POWERARTS); //if (obj->GetFrame() >= 277) obj->SetFrame(277); // 行列から情報取得 Vector3 front = GetFront(); Vector3 p_pos = GetPos(); SetMove(Vector3(0.0f, move.y, 0.0f)); // 情報設定 p_pos.y += 1.0f; Vector3 vec = front * 1.0f; float bulletSpeed = 0.8f; int playerNum = GetPlayerNum(); if (artsTimer == 0/* obj->GetFrame() == ○○ */) { m_BulletManager->Set(BULLET_TYPE::THIEF_02, new ThiefBullet02, p_pos, vec, bulletSpeed, playerNum); } artsTimer++; if (obj->GetFrame() == THIEF::MOTION_FRAME::POWERARTS_END) { artsTimer = 0; initflag = false; return true; } return false; }
void CSeqVector_CI::x_PrevCacheSeg() { _ASSERT(m_SeqMap); TSeqPos pos = x_CachePos(); if ( pos-- == 0 ) { // Can not go further NCBI_THROW(CSeqVectorException, eOutOfRange, "Can not update cache: iterator beyond start"); } TSeqPos size = x_GetSize(); // save current cache in backup x_SwapCache(); // update segment if needed if ( m_Seg.IsInvalid() ) { x_InitSeg(pos); } else { while ( m_Seg && m_Seg.GetPosition() > pos ) { x_DecSeg(); } } if ( !m_Seg ) { NCBI_THROW_FMT(CSeqVectorException, eDataError, "CSeqVector_CI: invalid sequence length: " <<pos<<" <> "<<size); } // Try to re-use backup cache if ( pos >= x_CachePos() && pos < x_CacheEndPos() ) { m_Cache = m_CacheData.get() + pos - x_CachePos(); } else { // can not use backup cache x_ResetCache(); x_UpdateCacheDown(pos); _ASSERT(GetPos() == pos); _ASSERT(x_CacheSize()); _ASSERT(x_CacheEndPos() == pos+1); } }
void Keys::CheckLast( vector<Char *> arr, int all, string key ) { string str = GetString( arr, all ); if( str.length() >= key.length() ) { string str2 = str.substr( str.size() - key.length() ); if( key == str2 ) { // Задание параметров KeysArrayPos newKord; newKord.begin = GetPos( str.size() - key.length(), arr ); newKord.end = newKord.begin + key.length(); newKord.font = 1; newKord.color = BLUE; keysArrPos.push_back( newKord ); } } }
NAMESPACE_UPP void IconDes::LeftDown(Point p, dword flags) { SetFocus(); if(!IsCurrent()) return; SaveUndo(); startpoint = GetPos(p); if(IsPasting()) { if(Rect(Current().pastepos, Current().paste_image.GetSize()).Contains(startpoint)) { startpoint -= Current().pastepos; SetCapture(); } else FinishPaste(); return; } SetCapture(); Current().base_image = CurrentImage(); if(flags & K_SHIFT) { ImageBuffer ib(CurrentImage()); if(!doselection) { RGBA c = CurrentColor(); c.r += 127; MaskFill(ib, c, 0); } FloodFill(ib, CurrentColor(), startpoint, ib.GetSize()); SetCurrentImage(ib); if(!doselection) MaskSelection(); return; } if(selectrect) EmptyRectTool(startpoint, flags); else if(tool) (this->*tool)(startpoint, flags); }
void CKofProgressCtrl::OnPaint() { CPaintDC dc(this); // device context for painting CMemDC memDC (dc, this); CDC* pDC = &memDC.GetDC (); //if (!CMFCVisualManager::GetInstance()->OnFillParentBarBackground (this, pDC)) { afxGlobalData.DrawParentBackground (this, pDC); } CRect rect; GetClientRect (rect); CRect rectProgress = rect; rectProgress.DeflateRect (1, 1); int nMin = 0; int nMax = 0; GetRange (nMin, nMax); CRect rectChunk (0, 0, 0, 0); if (nMax > nMin) { rectChunk = rectProgress; rectChunk.right = rectChunk.left + GetPos () * rectChunk.Width () / (nMax - nMin); rectChunk.DeflateRect (1, 1); } CMFCRibbonProgressBar dummy; CKofStyleHelper::GetInstance()->OnDrawRibbonProgressBar( pDC, &dummy, rectProgress, rectChunk, FALSE); }
bool CCrossDlg::FadeTo(const CPatch& Patch, LPCTSTR Name, double Secs, bool RandPhase) { if (!m_Frm->IsVeejay() && !SaveCheck()) return(FALSE); m_Play = FALSE; // halt fader first, without updating UI double Pos = GetPos(); bool Fwd = Pos <= .5; // set fade direction int Src = SEL_A + !Fwd; // index of source int Dst = SEL_A + Fwd; // index of destination if (Pos > 0 && Pos < 1) { // if fader is between A and B SetInfo(Src, GetInfo(SEL_MIX)); // copy mix to source SetName(Src, m_MixName); // set source name to mix m_Frm->OnNewParms(Src); // update parameters dialog } SetPos(!Fwd); // move fader to source SetInfo(Dst, Patch); // copy arg to destination SetName(Dst, Name); // set destination file name SetSeconds(Secs); if (Secs) Play(TRUE); // start fading to new patch else { Play(FALSE); SetPos(Fwd); // jump to new patch m_Frm->GetView()->FlushHistory(); // prevent glitch } if (RandPhase) { TimerHook(); // make mod freqs non-zero so randomize phase works for (int i = 0; i < ROWS; i++) { // if modulator is unused in source, but active in destination if (!m_Info[Src].m_Row[i].Freq && m_Info[Dst].m_Row[i].Freq) m_Frm->GetView()->SetPhase(i, double(rand()) / RAND_MAX); // randomize phase } } if (m_Frm->GetPatchMode() == CMainFrame::PM_FULL) m_Frm->SetPatch(Patch); // restore master and main settings m_Frm->OnNewParms(Dst); // update parameters dialog return(TRUE); }
// 人 vs AI void GameManVsCom(void) { BOARD board; uint64_t pos, valid; Init(&board); DispBoard(&board); while(board.teban != GAME_OVER){ valid = GenValidMove(&board); if(board.teban == SENTE){ // 先手(人) の処理 while(1){ pos = GetPos(); if(pos == INPUT_ERROR){ printf("エラーです。\n"); continue; } else if((pos & valid) == 0){ printf("非合法手です。\n"); continue; } break; } } else if(board.teban == GOTE){ // 後手 (AI) の処理 // コンピュータ側の処理をここにかく pos = Think(&board, valid); } Put(&board, pos); DispBoard(&board); CheckFinishPass(&board); } ShowResult(&board); return; }
BOOL CProgressCtrlX::SetSnakePos(int& nOldPos, int nNewPos, BOOL fIncrement) { DWORD dwStyle = GetStyle(); if(!(dwStyle&PBS_SNAKE)) return FALSE; int nLower, nUpper; GetRange(nLower, nUpper); if(fIncrement) { int nCurPos = GetPos(); if(nCurPos == nUpper && nCurPos - m_nTail < m_nTailSize ) nCurPos = m_nTail + m_nTailSize; nNewPos = nCurPos + abs(nNewPos); } if(nNewPos > nUpper+m_nTailSize) { nNewPos -= nUpper-nLower + m_nTailSize; if(nNewPos > nUpper + m_nTailSize) { ASSERT(0); // too far - reset nNewPos = nUpper + m_nTailSize; } if(dwStyle&PBS_REVERSE) ModifyStyle(PBS_REVERSE, 0); else ModifyStyle(0, PBS_REVERSE); } else if(nNewPos >= nUpper) Invalidate(); m_nTail = nNewPos - m_nTailSize; if(m_nTail < nLower) m_nTail = nLower; nOldPos = DefWindowProc(PBM_SETPOS, nNewPos, 0); return TRUE; }
void Matrix::TurnToVertical (Vector& vPoint, float fAngle) { Vector vToPoint = vPoint - GetPos(); vToPoint.fComp[0] = 0; Vector vForward = GetZ(); vForward.fComp[0] = 0; if (vToPoint == Vector (0,0,0) || vForward == Vector (0,0,0)) return; // if the angle of rotation makes you rotate past the target point, face the target point instead float fFinalAngle = fAngle; float fAngleToPoint = vToPoint.AngleTo (vForward); if (fAngleToPoint < fAngle) fFinalAngle = fAngleToPoint; // find out whether to rotate left or right float yDot = -(GetY() * vToPoint); if (yDot < 0) fFinalAngle = -fFinalAngle; // now for the punchline RotateX (fFinalAngle); }
void MultiButton::LeftDown(Point p, dword flags) { push = true; Refresh(); if(IsNull(hl)) pushrect = Null; else { if(hl == MAIN) pushrect = GetScreenRect(); else { int x, cx; int border = IsTrivial() ? style->trivialborder : style->border; GetPos(hl, x, cx); pushrect = RectC(x, border, cx, GetSize().cy - 2 * border) .Offseted(GetScreenView().TopLeft()); } Sync(); if(hl >= 0) button[hl].WhenPush(); else WhenPush(); } }
void CNumSpinCtrl::SetRangeAndDelta(double lower, double upper, double delta) { m_MinVal = lower; m_MaxVal = upper; m_Delta = delta; ASSERT (m_MaxVal > m_MinVal); // reversed min/max is not implemented, although it's probably easy //// avoid division by zero if (m_Delta == 0.0) return; /// Figure out the integer range to use, so that acceleration can work properly double range = fabs ((m_MaxVal - m_MinVal) / m_Delta); if (range > (double)ULG_MAXVAL) m_IntRange = ULG_MAXVAL; else m_IntRange = (int) range; CSpinButtonCtrl::SetRange32 (0, m_IntRange); /// Set integer position SetIntPos (GetPos()); }