void iPlayer::UpdatePassMap() { if (!m_bDirtPassMap) return; m_bDirtPassMap=false; bool bConstPass = (PlayerType() == PT_COMPUTER); check(m_pCurHero); sint32 mbonus = m_pCurHero->MoveCostBonus(); m_passMap.CopyFrom(gGame.Map().m_PassMap); for (sint32 yy=0; yy<m_passMap.GetHeight(); ++yy){ for (sint32 xx=0; xx<m_passMap.GetWidth(); ++xx){ sint32 res; if (m_FogMap.IsInvisible(iPoint(xx,yy))) { res = -1; } else { iBaseMapObject* pObj = gGame.Map().m_CoverMap.GetAt(xx,yy); if (pObj && pObj->Pos() == iPoint(xx,yy) && (!pObj->Disap() || bConstPass || !m_FogMap.IsHidden(pObj->Pos()))) { res = -2; } else { res = m_passMap.GetAt(xx,yy); } } if (mbonus && res > SURF_MOVE_COST[STYPE_DIRT]) res -= (res-SURF_MOVE_COST[STYPE_DIRT]) * mbonus / 100; m_passMap.GetAt(xx,yy) = (sint8)res; } } }
/// /// \brief 传送对象 /// \date 8/7/2009 /// \author Albert /// xgc_bool XGameMap::TeleportTo( XGameObject* pObject, XVector3 &vPositionNew, xgc_uintptr lpContext ) { XGC_CHECK_REENTER_CALL( mDynamicChecker ); XGC_ASSERT_RETURN( pObject->GetParent() == GetObjectID(), false, "对象不在该场景,却请求在该场景移动。" ); xgc_bool ret = true; XVector3 vPositionOld = pObject->GetPosition(); iPoint iOldCell = WorldToCell( vPositionOld.x, vPositionOld.y ); iPoint iNewCell = WorldToCell( vPositionNew.x, vPositionNew.y ); //XGC_DEBUG_CODE( CMapBlock *pArea = GetBlock(x,y); if( pArea ) XGC_ASSERT_MSG( pArea->CheckExist(pObj->GetObjID()), "发现飞机。" ); ) iPoint iOldArea = WorldToArea( vPositionOld.x, vPositionOld.y ); iPoint iNewArea = WorldToArea( vPositionNew.x, vPositionNew.y ); pObject->OnTeleport( 0, vPositionNew, lpContext ); ExchangeBlock( pObject, iOldCell, iPoint( -1, -1 ) ); ExchangeArea( pObject, iOldArea, iSize( -1, -1 ), mMapConf.mEyesight ); pObject->OnTeleport( 1, vPositionNew, lpContext ); pObject->SetPosition( vPositionNew ); //设置新位置 ExchangeBlock( pObject, iPoint( -1, -1 ), iNewCell ); ExchangeArea( pObject, iSize( -1, -1 ), iNewArea, mMapConf.mEyesight ); pObject->OnTeleport( 2, vPositionOld, lpContext ); return ret; }
/* * Hero Child */ iHeroChild::iHeroChild(iViewMgr* pViewMgr, IViewCmdHandler* pCmdHandler, iSimpleArray<iArtDragDropItem*>& competitors, const iPoint& pos) : iView(pViewMgr, iRect(pos.x, pos.y, 320, 109), GENERIC_VIEWPORT, 200, Enabled | Visible), m_pHero(NULL), m_pFriend(NULL) { AddChild(m_pPortrait = new iHeroBigPortBtn(pViewMgr, this, iRect(3,20,48,48), 201)); AddChild(m_pArtBackPackCtrl = new iArtBackPackCtrl(competitors, pViewMgr, this, iPoint(55,20+18), iSize(32,30), 7, iArtBackPackCtrl::Horizontal, 120)); AddChild(m_pSplitBtn = new iCheckButton(pViewMgr, this, iRect(m_Rect.w-23,m_Rect.h-38,20,36), PDGG_BTN_SPLIT, 140)); AddChild(m_pArmyList = new iArmyListEx(pViewMgr,this,iPoint(3,53+18), m_pSplitBtn, iSize(41,36),110)); }
/* * MeetView */ iMeetView::iMeetView() : iChildGameView(false, CV_OVERLAND) { AddChild(m_pChilds[0] = new iHeroChild(&gApp.ViewMgr(), this, m_Competitors, iPoint(0,0))); AddChild(m_pChilds[1] = new iHeroChild(&gApp.ViewMgr(), this, m_Competitors, iPoint(0,110))); m_pChilds[0]->ArmyList()->AddCompetitor(m_pChilds[1]->ArmyList()); m_pChilds[1]->ArmyList()->AddCompetitor(m_pChilds[0]->ArmyList()); m_pChilds[0]->SetFriend(m_pChilds[1]); m_pChilds[1]->SetFriend(m_pChilds[0]); AddChild(m_pToolBar = new iMeetToolBar(&gApp.ViewMgr(), this, iRect(0,m_Rect.h-21,m_Rect.w,21))); }
xgc_void XGameMap::OnRemoveChild( XObject* pChild ) { if( pChild->IsInheritFrom( &XGameObject::GetThisClass() ) ) { XGameObject* pObject = static_cast<XGameObject*>( pChild ); XVector3 vPosition = pObject->GetPosition(); ExchangeBlock( pObject, WorldToCell( vPosition.x, vPosition.y ), iPoint( -1, -1 ) ); ExchangeArea( pObject, WorldToArea( vPosition.x, vPosition.y ), iPoint( -1, -1 ), mMapConf.mEyesight ); pObject->OnLeaveMap( this ); pObject->RemoveEvent( GetObjectID() ); } }
void iDlg_LeaveGuards::OnCreateDlg() { iRect clRect = ClientRect(); AddChild(m_pSplitBtn = new iCheckButton(m_pMgr, this, iRect(clRect.x+5+36*7,clRect.y+20,18,34*2+1), PDGG_BTN_SPLIT, 103)); AddChild(m_pCnstArmyList = new iArmyListEx(m_pMgr,this,iPoint(clRect.x+5,clRect.y+20),m_pSplitBtn, iSize(35,34),101)); m_pCnstArmyList->SetArmy(&m_pOwnCnst->Guard(), NULL, true); AddChild(m_pHeroArmyList = new iArmyListEx(m_pMgr,this,iPoint(clRect.x+5,clRect.y+55),m_pSplitBtn, iSize(35,34),102)); m_pHeroArmyList->SetArmy(&m_pHero->Army(), m_pHero, false); m_pCnstArmyList->AddCompetitor(m_pHeroArmyList); m_pHeroArmyList->AddCompetitor(m_pCnstArmyList); AddChild(new iTextButton(m_pMgr, this, iRect((clRect.x+clRect.w/2)-20, clRect.y2()-DEF_BTN_HEIGHT, 40, DEF_BTN_HEIGHT), TRID_OK, DRC_OK)); }
void iMenuView::OnCompose() { m_crComposer.Compose(gApp.Surface(),iPoint(0,0)); // gGfxMgr.Blit(PDGG_LOGO, gApp.Surface(), iPoint(44,2)); // gGfxMgr.Blit(PDGG_LOGO2, gApp.Surface(), iPoint(174,3)); #if 0 gTextComposer.TextOut( iTextComposer::FontConfig(iTextComposer::FS_MEDIUM, iDibFont::ComposeProps(cColor_White, cColor_Black, iDibFont::DecBorder ) ), gApp.Surface(), iPoint(), _T("Ёксклюзивна¤ верси¤ дл¤ читателей журнала Mobi (www.mobi.ru)"), iRect(0,m_Rect.y2()-15,m_Rect.w, 15), AlignCenter); #endif }
void iHeroChild::OnCompose() { iRect rc = GetScrRect(); gGfxMgr.BlitTile(PDGG_BKTILE, gApp.Surface(),rc); gApp.Surface().Darken25Rect(rc); check(m_pHero); // Name iRect trc(rc.x,rc.y,rc.w,17); ButtonFrame(gApp.Surface(),trc,0); iStringT txt; txt.Addf(_T("#S0#FEEE%s#S2#FAFF %s #S0#FEEE%s %d"),gTextMgr[TRID_HERO_TYPE_KNIGHT+m_pHero->Type()],m_pHero->Name().CStr(),gTextMgr[TRID_LEVEL],m_pHero->Level()); gTextComposer.TextOut(gApp.Surface(),trc,txt,trc,AlignCenter); gApp.Surface().HLine(iPoint(rc.x,rc.y+17),rc.x2(),cColor_Black); rc.DeflateRect(0,18,0,0); // Portrait /* gApp.Surface().FrameRect(iRect(rc.x+2,rc.y+1,50,50),cColor_Black); gGfxMgr.Blit(m_pHero->Proto()->m_icn48,gApp.Surface(),iPoint(rc.x+3,rc.y+2)); ButtonFrame(gApp.Surface(),iRect(rc.x+3,rc.y+2,48,48),0); */ }
void ComposeLBItem(uint32 iIdx, bool bSel, const iRect& irc) { iTextComposer::FontConfig fc(dlgfc_plain); iRect rc=irc; if (bSel) { gGfxMgr.BlitTile(PDGG_CTILE, gApp.Surface(),rc); ButtonFrame(gApp.Surface(),rc,0); } rc.DeflateRect(2); iCastle* pCastle = *(m_pOwner->CastleFirst()+iIdx); // Glyph gApp.Surface().FillRect(iRect(rc.x,rc.y,34,22),cColor_Black); SpriteId sid = PDGG_CTL_SICONS + (pCastle->Proto()->Size()-1)*CTLT_COUNT + pCastle->Proto()->Type(); gGfxMgr.Blit(sid,gApp.Surface(), iPoint(rc.x+1,rc.y+1)); // Name rc.DeflateRect(36,0,0,0); rc.h = 10; gTextComposer.TextOut(dlgfc_topic,gApp.Surface(),rc,pCastle->Name(),rc,AlignTop); rc.y+=10; State state = GetItemState(iIdx); if (state == Occupied) { iTextComposer::FontConfig fc(iTextComposer::FS_SMALL,RGB16(255,128,128)); gTextComposer.TextOut(fc,gApp.Surface(),rc,pCastle->Visitor()->Name(),rc,AlignTop); } else if (state == Normal) { iTextComposer::FontConfig fc(iTextComposer::FS_SMALL,RGB16(128,255,128)); gTextComposer.TextOut(fc,gApp.Surface(),rc,gTextMgr[TRID_UNOCCUPIED],rc,AlignTop); } else { check(0); } }
void ComposeLBItem(uint32 iIdx, bool bSel, const iRect& irc) { iRect rc=irc; if (bSel) { gGfxMgr.BlitTile(PDGG_CTILE, gApp.Surface(),rc); ButtonFrame(gApp.Surface(),rc,0); } rc.DeflateRect(2); if (!m_pOwner) return; // School Level Name and Cost iStringT text(gTextMgr[TRID_SPNAME_MAGICARROW+m_spells[iIdx]]); uint8 cost = iBaseSpell::GetSpellCost((MAGIC_SPELL)m_spells[iIdx], m_pOwner); uint8 school = SPELL_DESCRIPTORS[m_spells[iIdx]].school; text.Addf(_T(" (%d)"), cost); iTextComposer::FontConfig fc(iTextComposer::FS_SMALL,MSCH_COLORS[school][0]); SpriteId icn = PDGG_MSCHICN_S+school; if (m_pOwner->ManaPts() < cost) { fc.cmpProps.alpha = 128; } gGfxMgr.Blit(icn, gApp.Surface(), rc.point()); rc.x += 12; gTextComposer.TextOut(fc, gApp.Surface(),iPoint(rc.x,rc.y),text,rc, AlignLeft); }
void iPopupMenu::ShowPopupMenu(const iPoint &pos, iAlignment algn) { if (m_Items.GetSize() == 0) return; iRect nrect(0,0,0,0); for (uint32 xx=0; xx< m_Items.GetSize(); ++xx) { m_Items[xx]->m_Button->SetElementPos(iPoint(nrect.w,0)); nrect.w += m_Items[xx]->m_Button->GetElementRect().w; nrect.h = iMAX(nrect.h,m_Items[xx]->m_Button->GetElementRect().h); } nrect.y = pos.y-nrect.h; nrect.x = pos.x - nrect.w/2; iSize ssize = iWindowManager::GetScreenSize(); if (nrect.x<0) nrect.x=0; else if (nrect.x2() > (sint32)ssize.w) nrect.x = ssize.w - nrect.w; if (nrect.y<0) nrect.y=0; else if (nrect.y2() > (sint32)ssize.h) nrect.y = ssize.h - nrect.h; SetWndRect(nrect); ShowWindow(SW_SHOW); SetActiveWindow(); }
xgc_void XGameMap::OnInsertChild( XObject* pChild, xgc_lpvoid lpContext ) { if( pChild->IsInheritFrom( &XGameObject::GetThisClass() ) ) { XGameObject* pObject = static_cast<XGameObject*>( pChild ); BuildTrigger( pObject ); pObject->SetPosition( *(XVector3*) lpContext ); pObject->OnBornInMap( this ); const XVector3& vPosition = pObject->GetPosition(); // 加入到区域列表中 ExchangeBlock( pObject, iPoint( -1, -1 ), WorldToCell( vPosition.x, vPosition.y ) ); ExchangeArea( pObject, iPoint( -1, -1 ), WorldToArea( vPosition.x, vPosition.y ), mMapConf.mEyesight ); pObject->OnEnterMap( this ); } }
void OnCompose() { iRect rc = GetScrRect(); sint32 tw = m_perks.GetSize() * 15 - 1; sint32 ox = rc.x + ((sint32)(rc.w/2) - tw/2); for (uint32 nn=0; nn<m_perks.GetSize(); ++nn) { gGfxMgr.Blit(PDGG_CREAT_PERKS + m_perks[nn], gApp.Surface(), iPoint(ox, rc.y)); ox += 15; } }
// 移动对象 void XUI_Wnd::MoveWindow( int left, int top, int right, int bottom, bool notify ) { m_WindowPosition = iPoint( left, top ); m_WindowSize = iSize( abs(right - left), abs(bottom - top) ); if( notify ) { // 发送位置变更消息 OnMoveWindow( iRect( left, top, right, bottom ) ); } }
void OnCompose() { // gApp.Surface().Darken50Rect(GetScrRect()); // Compose outer frame iRect rect = GetScrRect(); rect.InflateRect(1); iDibFont::ComposeProps props = iDibFont::ComposeProps(iGradient(menuBtnText,15), cColor_Black, iDibFont::DecBorder); uint32 state = GetButtonState(); if ( state & iButton::Disabled ) { props = iDibFont::ComposeProps(RGB16(255,160,80), cColor_Black, iDibFont::DecBorder); } else if ( state & iButton::Pressed ) { props = iDibFont::ComposeProps(RGB16(255,255,255), cColor_Black, iDibFont::DecBorder); uint16 cColor_Grey = RGB16(32,32,32); gApp.Surface().HLine(iPoint(rect.x+2, rect.y), rect.x+rect.w-3, cColor_Grey); gApp.Surface().HLine(iPoint(rect.x+2, rect.y+rect.h-1), rect.x+rect.w-3, cColor_Grey); gApp.Surface().VLine(iPoint(rect.x,rect.y+2), rect.y+rect.h-2, cColor_Grey); gApp.Surface().VLine(iPoint(rect.x+rect.w-1,rect.y+2), rect.y+rect.h-2, cColor_Grey); gApp.Surface().Darken50Rect(GetScrRect()); } iTextComposer::FontConfig fc(iTextComposer::FS_LARGE, props ); gTextComposer.TextOut(fc, gApp.Surface(), iPoint(), gTextMgr[m_TextKey], GetScrRect(), AlignCenter); }
void TorsionAngleContrib::getGrad(double *pos, double *grad) const { PRECONDITION(dp_forceField, "no owner"); PRECONDITION(pos, "bad vector"); PRECONDITION(grad, "bad vector"); RDGeom::Point3D iPoint(pos[3 * d_at1Idx], pos[3 * d_at1Idx + 1], pos[3 * d_at1Idx + 2]); RDGeom::Point3D jPoint(pos[3 * d_at2Idx], pos[3 * d_at2Idx + 1], pos[3 * d_at2Idx + 2]); RDGeom::Point3D kPoint(pos[3 * d_at3Idx], pos[3 * d_at3Idx + 1], pos[3 * d_at3Idx + 2]); RDGeom::Point3D lPoint(pos[3 * d_at4Idx], pos[3 * d_at4Idx + 1], pos[3 * d_at4Idx + 2]); double *g[4] = {&(grad[3 * d_at1Idx]), &(grad[3 * d_at2Idx]), &(grad[3 * d_at3Idx]), &(grad[3 * d_at4Idx])}; RDGeom::Point3D r[4] = {iPoint - jPoint, kPoint - jPoint, jPoint - kPoint, lPoint - kPoint}; RDGeom::Point3D t[2] = {r[0].crossProduct(r[1]), r[2].crossProduct(r[3])}; double d[2] = {t[0].length(), t[1].length()}; if (isDoubleZero(d[0]) || isDoubleZero(d[1])) { return; } t[0] /= d[0]; t[1] /= d[1]; double cosPhi = t[0].dotProduct(t[1]); clipToOne(cosPhi); double sinPhiSq = 1.0 - cosPhi * cosPhi; double sinPhi = ((sinPhiSq > 0.0) ? sqrt(sinPhiSq) : 0.0); double sin2Phi = 2.0 * sinPhi * cosPhi; double sin3Phi = 3.0 * sinPhi - 4.0 * sinPhi * sinPhiSq; // dE/dPhi is independent of cartesians: double dE_dPhi = 0.5 * (-(d_V1)*sinPhi + 2.0 * d_V2 * sin2Phi - 3.0 * d_V3 * sin3Phi); #if 0 if(dE_dPhi!=dE_dPhi){ std::cout << "\tNaN in Torsion("<<d_at1Idx<<","<<d_at2Idx<<","<<d_at3Idx<<","<<d_at4Idx<<")"<< std::endl; std::cout << "sin: " << sinPhi << std::endl; std::cout << "cos: " << cosPhi << std::endl; } #endif // FIX: use a tolerance here // this is hacky, but it's per the // recommendation from Niketic and Rasmussen: double sinTerm = -dE_dPhi * (isDoubleZero(sinPhi) ? (1.0 / cosPhi) : (1.0 / sinPhi)); Utils::calcTorsionGrad(r, t, d, g, sinTerm, cosPhi); }
void iNWSliderBar::DrawElement(iMemoryDC &ddc) const { iRect elrc = GetElementRect(); iSize bsiz(m_dibBack.GetWidth()/3,m_dibBack.GetHeight()/2); // Draw Background sint32 ypos = (m_IsEnabled?0:bsiz.h); m_dibBack.CopyRectToDibXY(&ddc.m_Dib, iRect(0,ypos,bsiz.w,bsiz.h),iPoint(elrc.x,elrc.y),BLEND_ALPHABLEND); m_dibBack.TileRectToDibRect(iRect(bsiz.w,ypos,bsiz.w,bsiz.h),ddc.m_Dib,iRect(elrc.x+bsiz.w,elrc.y,elrc.w-bsiz.w*2,bsiz.h),BLEND_ALPHABLEND); m_dibBack.CopyRectToDibXY(&ddc.m_Dib, iRect(bsiz.w*2,ypos,bsiz.w,bsiz.h),iPoint(elrc.x+elrc.w-bsiz.w,elrc.y),BLEND_ALPHABLEND); // Create Bar (fake impl) iSize belsiz(m_dibBar.GetWidth()/3,m_dibBar.GetHeight()/2); iSize barsiz(elrc.w - bsiz.w*2,belsiz.h); iDib eBar(barsiz); iDib fBar(barsiz); m_dibBar.CopyRectToDibXY(&eBar, iRect(0,0,belsiz.w,belsiz.h),iPoint(0,0),BLEND_SRCCOPY); m_dibBar.TileRectToDibRect(iRect(belsiz.w,0,belsiz.w,belsiz.h),eBar,iRect(belsiz.w,0,barsiz.w-belsiz.w*2,barsiz.h),BLEND_SRCCOPY); m_dibBar.CopyRectToDibXY(&eBar, iRect(belsiz.w*2,0,belsiz.w,belsiz.h),iPoint(barsiz.w-belsiz.w,0),BLEND_SRCCOPY); m_dibBar.CopyRectToDibXY(&fBar, iRect(0,belsiz.h,belsiz.w,belsiz.h),iPoint(0,0),BLEND_SRCCOPY); m_dibBar.TileRectToDibRect(iRect(belsiz.w,belsiz.h,belsiz.w,belsiz.h),fBar,iRect(belsiz.w,0,barsiz.w-belsiz.w*2,barsiz.h),BLEND_SRCCOPY); m_dibBar.CopyRectToDibXY(&fBar, iRect(belsiz.w*2,belsiz.h,belsiz.w,belsiz.h),iPoint(barsiz.w-belsiz.w,0),BLEND_SRCCOPY); // Compose iPoint bar_pos(elrc.x+bsiz.w,elrc.y+(bsiz.h/2 - barsiz.h/2)); sint32 hpos; sint32 cpos = m_bTracking?m_TrackPos:m_Cur; if (!m_IsEnabled || cpos == m_Min || m_Min == m_Max) { hpos = 0; eBar.CopyToDibXY(&ddc.m_Dib,bar_pos,BLEND_ALPHABLEND); } else if (cpos == m_Max) { hpos = barsiz.w; fBar.CopyToDibXY(&ddc.m_Dib,bar_pos,BLEND_ALPHABLEND); } else { hpos = iCLAMP<sint32>((sint32)0,(sint32)barsiz.w,(sint32)barsiz.w * (cpos-m_Min) / (m_Max-m_Min)); fBar.CopyRectToDibXY(&ddc.m_Dib,iRect(0,0,hpos,barsiz.h),iPoint(bar_pos.x,bar_pos.y),BLEND_ALPHABLEND); eBar.CopyRectToDibXY(&ddc.m_Dib,iRect(hpos,0,barsiz.w-hpos,barsiz.h),iPoint(bar_pos.x+hpos,bar_pos.y),BLEND_ALPHABLEND); } // Draw Handle if (m_IsEnabled) { iSize hndsiz(m_dibHandle.GetWidth()/2,m_dibHandle.GetHeight()); m_dibHandle.CopyRectToDibXY(&ddc.m_Dib, iRect(m_bTracking?hndsiz.w:0,0,hndsiz.w,hndsiz.h),iPoint(bar_pos.x+hpos-(sint32)(hndsiz.w/2),bar_pos.y+barsiz.h/2-hndsiz.h/2),BLEND_ALPHABLEND); } }
void ComposeCharacter(iMemoryDC& memDC, TCHAR ich, sint32 px, uint32 w) { iDibPrimitives::DrawHLine(memDC.m_Dib, iPoint(px,0), px+w, clrWidth, BLEND_SRCCOPY); memDC.m_Dib.PutPixel(iPoint(px,0), clrAnchor); /* // Frame memDC.SetTextColor(clrWFrame); TextOut(memDC,px,1,&ich,1); TextOut(memDC,px+1,1,&ich,1); TextOut(memDC,px+2,1,&ich,1); TextOut(memDC,px,2,&ich,1); TextOut(memDC,px+2,2,&ich,1); TextOut(memDC,px,3,&ich,1); TextOut(memDC,px+1,3,&ich,1); // Shadow memDC.SetTextColor(clrWShadow); TextOut(memDC,px+2,3,&ich,1); */ // Face memDC.SetTextColor(clrWFace); TextOut(memDC,px+1,2,&ich,1); }
double TorsionAngleContrib::getEnergy(double *pos) const { PRECONDITION(dp_forceField, "no owner"); PRECONDITION(pos, "bad vector"); RDGeom::Point3D iPoint(pos[3 * d_at1Idx], pos[3 * d_at1Idx + 1], pos[3 * d_at1Idx + 2]); RDGeom::Point3D jPoint(pos[3 * d_at2Idx], pos[3 * d_at2Idx + 1], pos[3 * d_at2Idx + 2]); RDGeom::Point3D kPoint(pos[3 * d_at3Idx], pos[3 * d_at3Idx + 1], pos[3 * d_at3Idx + 2]); RDGeom::Point3D lPoint(pos[3 * d_at4Idx], pos[3 * d_at4Idx + 1], pos[3 * d_at4Idx + 2]); return Utils::calcTorsionEnergy( d_V1, d_V2, d_V3, Utils::calcTorsionCosPhi(iPoint, jPoint, kPoint, lPoint)); }
void ComposeShadow(const iDib& src, iDib& dst, const iPoint& pos) { uint32 nh = (src.GetHeight()+1) / 2; uint32 nw = src.GetWidth() + nh; iDib sdib(iSize(nw,nh)); for (sint32 yy = 0; yy<(sint32)src.GetHeight(); yy+=2){ sint32 ny = yy/2; iColor* pDst = sdib.GetLine(ny) + ny; const iColor* pSrc = src.GetLine(yy); for (uint32 xx=0; xx<src.GetWidth(); ++xx){ if (pSrc->GetA()) { pDst->SetA(64); } pDst++; pSrc++; } } sdib.CopyToDibXY(&dst,iPoint(pos.x-nh,pos.y+nh),BLEND_ALPHABLEND); }
void iCastleView::iCMDH_ControlCommand(iView* pView, CTRL_CMD_ID cmd, sint32 param) { sint32 clsId = pView->GetClassId(); uint32 uid = pView->GetUID(); if (uid == 101) { SetCastle(gGame.Map().CurPlayer()->PrevCastle()); } else if (uid == 102) { SetCastle(gGame.Map().CurPlayer()->NextCastle()); } else if (uid == 103) { check(clsId == TABBED_SWITCH); if (cmd == CCI_TABCHANGED) ShowPage(param); } else if (uid == VPUID_BTN_CLOSECITY) { gGame.HideView(CV_CASTLE); } else if (uid == 150 && cmd == CCI_BTNCLICK) { iPoint pp = pView->GetScrPos(); m_pMgr->TrackPopup(new iCastleListPopup(m_pMgr), pp, iRect(0,0,320,240),AlignBottomLeft); } else if (uid == VPUID_BTN_STATE) { m_pMgr->TrackPopup(new iGamePopupMenu(m_pMgr), iPoint(320,15), iRect(0,0,320,240),AlignTopRight); } }
void Exporter<MeshType>::exportFlags( boost::shared_ptr<MeshType> mesh, boost::shared_ptr<Epetra_Comm> comm, flag_Type const & compareFlag ) { // @todo this is only for point flags, extension to other entity flags is trivial // @todo switch loops for efficiency! // @todo use FESpace M_spacemap for generality const ReferenceFE & refFE = feTetraP1; const QuadratureRule & qR = quadRuleTetra15pt; const QuadratureRule & bdQr = quadRuleTria4pt; feSpacePtr_Type FlagFESpacePtr( new feSpace_Type( mesh, refFE, qR, bdQr, 1, comm ) ); std::vector< vectorPtr_Type > FlagData ( EntityFlags::number ); for ( flag_Type kFlag ( 1 ), flagCount ( 0 ); kFlag < EntityFlags::ALL; kFlag *=2, flagCount++ ) { if ( kFlag & compareFlag ) { FlagData[ flagCount ].reset ( new vector_Type ( FlagFESpacePtr->map() ) ); for ( UInt iPoint( 0 ); iPoint < FlagFESpacePtr->mesh()->numPoints(); ++iPoint ) { typename MeshType::point_Type const & point = FlagFESpacePtr->mesh()->pointList[ iPoint ]; FlagData[ flagCount ]->setCoefficient ( point.id() , Flag::testOneSet( point.flag(), kFlag ) ); } addVariable( exporterData_Type::ScalarField, "Flag " + EntityFlags::name ( kFlag ), FlagFESpacePtr, FlagData[ flagCount ], 0, exporterData_Type::SteadyRegime, exporterData_Type::Node ); } } }
iPoint const operator^(const iPoint &p1, const iPoint &p2) { return iPoint(p1.y*p2.z - p1.z*p2.y, p1.z*p2.x - p1.x*p2.z, p1.x*p2.y - p1.y*p2.x); }
iPoint Input::getMouseMotion() { return iPoint(mouse_motion_x, mouse_motion_y); /*x = mouse_motion_x; y = mouse_motion_y;*/ }
void OopBendContrib::getGrad(double *pos, double *grad) const { PRECONDITION(dp_forceField, "no owner"); PRECONDITION(pos, "bad vector"); PRECONDITION(grad, "bad vector"); RDGeom::Point3D iPoint(pos[3 * d_at1Idx], pos[3 * d_at1Idx + 1], pos[3 * d_at1Idx + 2]); RDGeom::Point3D jPoint(pos[3 * d_at2Idx], pos[3 * d_at2Idx + 1], pos[3 * d_at2Idx + 2]); RDGeom::Point3D kPoint(pos[3 * d_at3Idx], pos[3 * d_at3Idx + 1], pos[3 * d_at3Idx + 2]); RDGeom::Point3D lPoint(pos[3 * d_at4Idx], pos[3 * d_at4Idx + 1], pos[3 * d_at4Idx + 2]); double *g1 = &(grad[3 * d_at1Idx]); double *g2 = &(grad[3 * d_at2Idx]); double *g3 = &(grad[3 * d_at3Idx]); double *g4 = &(grad[3 * d_at4Idx]); RDGeom::Point3D rJI = iPoint - jPoint; RDGeom::Point3D rJK = kPoint - jPoint; RDGeom::Point3D rJL = lPoint - jPoint; double dJI = rJI.length(); double dJK = rJK.length(); double dJL = rJL.length(); if (isDoubleZero(dJI) || isDoubleZero(dJK) || isDoubleZero(dJL)) { return; } rJI /= dJI; rJK /= dJK; rJL /= dJL; RDGeom::Point3D n = (-rJI).crossProduct(rJK); n /= n.length(); double const c2 = MDYNE_A_TO_KCAL_MOL * DEG2RAD * DEG2RAD; double sinChi = rJL.dotProduct(n); clipToOne(sinChi); double cosChiSq = 1.0 - sinChi * sinChi; double cosChi = std::max(((cosChiSq > 0.0) ? sqrt(cosChiSq) : 0.0), 1.0e-8); double chi = RAD2DEG * asin(sinChi); double cosTheta = rJI.dotProduct(rJK); clipToOne(cosTheta); double sinThetaSq = std::max(1.0 - cosTheta * cosTheta, 1.0e-8); double sinTheta = std::max(((sinThetaSq > 0.0) ? sqrt(sinThetaSq) : 0.0), 1.0e-8); double dE_dChi = RAD2DEG * c2 * d_koop * chi; RDGeom::Point3D t1 = rJL.crossProduct(rJK); RDGeom::Point3D t2 = rJI.crossProduct(rJL); RDGeom::Point3D t3 = rJK.crossProduct(rJI); double term1 = cosChi * sinTheta; double term2 = sinChi / (cosChi * sinThetaSq); double tg1[3] = {(t1.x / term1 - (rJI.x - rJK.x * cosTheta) * term2) / dJI, (t1.y / term1 - (rJI.y - rJK.y * cosTheta) * term2) / dJI, (t1.z / term1 - (rJI.z - rJK.z * cosTheta) * term2) / dJI}; double tg3[3] = {(t2.x / term1 - (rJK.x - rJI.x * cosTheta) * term2) / dJK, (t2.y / term1 - (rJK.y - rJI.y * cosTheta) * term2) / dJK, (t2.z / term1 - (rJK.z - rJI.z * cosTheta) * term2) / dJK}; double tg4[3] = {(t3.x / term1 - rJL.x * sinChi / cosChi) / dJL, (t3.y / term1 - rJL.y * sinChi / cosChi) / dJL, (t3.z / term1 - rJL.z * sinChi / cosChi) / dJL}; for (unsigned int i = 0; i < 3; ++i) { g1[i] += dE_dChi * tg1[i]; g2[i] += -dE_dChi * (tg1[i] + tg3[i] + tg4[i]); g3[i] += dE_dChi * tg3[i]; g4[i] += dE_dChi * tg4[i]; } }
iPoint const operator/(const iPoint &p, const double d) { return iPoint(p.x / d, p.y / d, p.z / d); }
void iSpellListView::OnCompose() { iRect rc = GetScrRect(); // Buttons frame; iRect brc = m_pSchoolSwitch->GetScrRect(); brc.InflateRect(1); gApp.Surface().FrameRect(brc, cColor_Black); rc.DeflateRect(m_pSchoolSwitch->GetRect().x2() + 5, -1, -1, -1); // Frame gApp.Surface().FrameRect(rc, cColor_Black); gApp.Surface().Darken25Rect(rc); rc.DeflateRect(3); // Spell if (m_curSel != MSP_INVALID) { // Name gTextComposer.TextOut(iTextComposer::FontConfig(iTextComposer::FS_MEDIUM,MSCH_COLORS[SPELL_DESCRIPTORS[m_curSel].school][0]), gApp.Surface(),iPoint(rc.x,rc.y),gTextMgr[TRID_SPNAME_MAGICARROW+m_curSel],rc, AlignTop); rc.DeflateRect(0,13,0,0); // Level gTextComposer.TextOut(iTextComposer::FontConfig(iTextComposer::FS_SMALL,MSCH_COLORS[SPELL_DESCRIPTORS[m_curSel].school][0]), gApp.Surface(),iPoint(rc.x,rc.y),gTextMgr[TRID_LEVEL] + iFormat(_T(": %d"), SPELL_DESCRIPTORS[m_curSel].level + 1),rc, AlignTop); rc.DeflateRect(0,16,0,0); // Icon rc.DeflateRect(0,40,0,0); // Hero school level ComposeSpellLevel(gApp.Surface(), rc, m_curSel, m_pOwner); rc.DeflateRect(0,12,0,0); // Cost uint8 cost = iBaseSpell::GetSpellCost(m_curSel, m_pOwner); uint8 school = SPELL_DESCRIPTORS[m_curSel].school; gTextComposer.TextOut(iTextComposer::FontConfig(iTextComposer::FS_SMALL,MSCH_COLORS[school][0]), gApp.Surface(),iPoint(rc.x,rc.y),gTextMgr[TRID_COST]+iFormat(_T(" %d"),cost),rc, AlignTop); rc.DeflateRect(0,20,0,0); // Inaccessebility reason if (m_pOwner->ManaPts() < cost) { iStringT msgStr(gTextMgr[TRID_MSG_SPELL_NOT_ENOUGH_MANA]); iTextComposer::FontConfig fntSmall(iTextComposer::FS_SMALL,RGB16(255,96,0)); gTextComposer.TextBoxOut( fntSmall, gApp.Surface(), msgStr,rc); } else if (iCombatSpell* pCombatSpell = DynamicCast<iCombatSpell*>(gGame.ItemMgr().m_spellMgr.Spell(m_curSel))) { iTextComposer::FontConfig fntSmallDifferentColor(iTextComposer::FS_SMALL,RGB16(255,255,0)); gTextComposer.TextBoxOut( fntSmallDifferentColor, gApp.Surface(), pCombatSpell->ActionText(m_pOwner),rc); } } else { iTextComposer::FontConfig fntSmall(iTextComposer::FS_SMALL,RGB16(255,96,0)); gTextComposer.TextBoxOut(fntSmall, gApp.Surface(), gTextMgr[TRID_NO_SPELL_SELECTED],rc); } }
iPoint const operator-(const iPoint &p1, const iPoint &p2) { return iPoint(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z); }
void iComposer::Compose(HDC hdc, const iSize& siz, const iPoint &offset, const iPoint& snode, iBaseNode* pSelItem) { DWORD btime = timeGetTime(); const iSpriteMgr& spriteMgr = gItemMgr.m_SpriteMgr; iAvatarMgr& avatarMgr = gItemMgr.m_AvatarMgr; iIsoMetric im(5); iPoint aanch = offset-iPoint(GetMapPixelWidth()/2+40,20); iPoint fpos = im.Screen2Map(aanch); fpos.Move(-1,-1); iPoint ppos = im.Map2Screen(fpos); ppos.Move(-20,-8); iPoint offs = aanch-ppos; sint32 cnt_x = siz.w/40+3; sint32 cnt_y = siz.h/8+5; sint32 step_x = im.GetCellStepX()*2; sint32 step_y = im.GetCellStepY(); const iPoint anchor_coor(fpos); iPoint init_map_coor(fpos); iPoint map_coor(fpos); ResizeComposeDib(siz); m_ComposeMemDC.m_Dib.Fill(cColorBlue64); // // Surface and grid for (sint32 yy=0; yy<cnt_y; ++yy) { for (sint32 xx=0; xx<cnt_x; ++xx){ if (m_pMap->IsValidPos(map_coor.x,map_coor.y)){ sint32 xpos = xx*step_x; sint32 ypos = yy*step_y; if (yy%2!=0) xpos -= step_x >> 1; iPoint op(xpos-offs.x,ypos-offs.y); iMapHandler::iSurfCell cell; if ( m_pMap->GetCellSurf(map_coor,cell) ) { // solid cell - do nothing const iSprite* pSprite = spriteMgr.GetSpritePtr(iFormat(_T("common.surf_tiles_%04d"),cell.lowestLayer*4+CalcCellSeq(map_coor,4))); pSprite->dib.CopyToDibXY(&m_ComposeMemDC.m_Dib,op+pSprite->anchor,BLEND_ALPHABLEND); } else { // Compose inclusive transition Water->Sand if (cell.lowestLayer == STYPE_WATER){ uint8 cfg = 0;//(uint8)( ((ccfg & 0xF0)>>4) | ((ccfg & 0xF00)>>8) | ((ccfg & 0xF000)>>12) | ((ccfg & 0xF0000)>>16) | ((ccfg & 0xF00000)>>20) | ((ccfg & 0xF000000)>>24)); for (uint32 zz=0; zz<STYPE_COUNT; ++zz) cfg |= cell.layers[zz]; const iSprite* pSprite = spriteMgr.GetSpritePtr(iFormat(_T("common.ws_tiles_%04d"),cfg-1)); pSprite->dib.CopyToDibXY(&m_ComposeMemDC.m_Dib,op+pSprite->anchor,BLEND_ALPHABLEND); } else { const iSprite* pSprite = spriteMgr.GetSpritePtr(iFormat(_T("common.surf_tiles_%04d"),cell.lowestLayer*4+CalcCellSeq(map_coor,4))); pSprite->dib.CopyToDibXY(&m_ComposeMemDC.m_Dib,op+pSprite->anchor,BLEND_ALPHABLEND); } // Compose other layers for (uint32 zz=1; zz<STYPE_COUNT; ++zz){ if (cell.layers[zz]){ const iSprite* pTransMask = spriteMgr.GetSpritePtr(iFormat(_T("common.trans_tiles_%04d"),cell.layers[zz]-1)); iGrayDib gmask; iDibGrayDibHandl::DibChannel2GrayDib(pTransMask->dib,gmask,Channel_Alpha); iDib vdib(&spriteMgr.GetSpritePtr(iFormat(_T("common.surf_tiles_%04d"),zz*4+CalcCellSeq(map_coor,4)))->dib); iDibGrayDibHandl::GrayDib2DibChannel(gmask,vdib,Channel_Alpha); vdib.CopyToDibXY(&m_ComposeMemDC.m_Dib,op,BLEND_ALPHABLEND); } } } if (m_bGrid) { m_dibGrid.CopyToDibXY(&m_ComposeMemDC.m_Dib, op, BLEND_ALPHABLEND); } } map_coor.x += 1; map_coor.y -= 1; } if (yy%2 != 0) { init_map_coor.x+=1; map_coor = init_map_coor; } else { init_map_coor.y+=1; map_coor = init_map_coor; } }
void PageBox::ch_value() { if (no_ch) return; page->set_active_id(iPoint(0,0)); signal_changed_.emit(); }