コード例 #1
0
void CBuddycloudListComponent::TimerExpired(TInt aExpiryId) {
	if(aExpiryId == KDragTimerId) {
#ifdef __SERIES60_40__		
		if(iDraggingAllowed) {
			iDragVelocity = iDragVelocity * 0.95;		
			iScrollbarHandlePosition += TInt(iDragVelocity);		
			
			CBuddycloudListComponent::RepositionItems(false);
			RenderScreen();
			
			if(Abs(iDragVelocity) > 0.05) {
				iDragTimer->After(50000);
			}
		}
#endif
	}
	else if(aExpiryId == KTimeTimerId) {
#ifdef __3_2_ONWARDS__
		HBufC* aTitle = iEikonEnv->AllocReadResourceLC(R_LOCALIZED_STRING_APPNAME);
		SetTitleL(*aTitle);
		CleanupStack::PopAndDestroy();
#else
		TTime aTime;
		aTime.HomeTime();
		TBuf<32> aTextTime;
		aTime.FormatL(aTextTime, _L("%J%:1%T%B"));
	
		SetTitleL(aTextTime);
	
		TDateTime aDateTime = aTime.DateTime();
		iTimer->After((60 - aDateTime.Second() + 1) * 1000000);
#endif
	}
}
コード例 #2
0
ファイル: TheHUD.cpp プロジェクト: superwills/Wryv
void ATheHUD::DrawHUD()
{
  // Canvas is only initialized here.
  Super::DrawHUD();
  InitWidgets();
  RenderPortrait();
  
  // Render the minimap, only if the floor is present
  FBox box = Game->flycam->floor->GetBox();
  FVector lookPt = box.GetCenter();
  RenderScreen( rendererMinimap, lookPt, box.GetExtent().GetMax(), FVector( 0, 0, -1 ) );

  ui->SetSize( FVector2D( Canvas->SizeX, Canvas->SizeY ) );
  ui->Update( Game->gm->T ); // Ticked here, in case reflow is needed
  ui->render();

  // Overlay the lines for the minimap's view.
  vector< FVector2D > pts = ui->gameChrome->rightPanel->minimap->pts;
  for( int i = 0; i < pts.size()-1; i++ )
  {
    Canvas->K2_DrawLine( pts[i], pts[i+1], 2.f, FLinearColor::Green );
  }
  if( pts.size() > 1 )
  {
    Canvas->K2_DrawLine( pts[ pts.size()-1 ], pts[ 0 ], 2.f, FLinearColor::Green );
  }
}
コード例 #3
0
void CBuddycloudListComponent::NotificationEvent(TBuddycloudLogicNotificationType aEvent, TInt /*aId*/) {
	if(aEvent == ENotificationActivityChanged) {
		RenderScreen();
	}
	else if(aEvent == ENotificationLogicEngineDestroyed) {
		iBuddycloudLogic = NULL;
	}
}
コード例 #4
0
void CBuddycloudListComponent::HandleResourceChange(TInt aType) {
	if(aType == KEikDynamicLayoutVariantSwitch) {
		TRect aRect;
		AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, aRect);
		SetRect(aRect);
		RenderScreen();
	}
	else if(aType == KAknsMessageSkinChange){
		ReleaseFonts();
		ConfigureFonts();
		ConfigureSkin();

		if(iScrollBar) {
			iScrollBar->VerticalScrollBar()->HandleResourceChange(aType);
		}
		
		RenderScreen();
	}
}
コード例 #5
0
void CBuddycloudListComponent::HandlePointerEventL(const TPointerEvent &aPointerEvent) {
	CCoeControl::HandlePointerEventL(aPointerEvent);
	
	if(aPointerEvent.iType == TPointerEvent::EButton1Up) {			
		if(iDraggingAllowed) {
			if(Abs(iDragVelocity) > 5.0) {
				TimerExpired(KDragTimerId);
			}
		}
		else {
			for(TInt i = 0; i < iListItems.Count(); i++) {
				if(iListItems[i].iRect.Contains(aPointerEvent.iPosition)) {
					// Provide feedback
					iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
					
					HandleItemSelection(iListItems[i].iId);			
					break;
				}
			}
		}
	}
	else if(aPointerEvent.iType == TPointerEvent::EButton1Down) {
		iDragTimer->Stop();
		iDragVelocity = 0.0;
		iDraggingAllowed = false;
		
		iStartDragPosition = aPointerEvent.iPosition.iY;
		iStartDragHandlePosition = iScrollbarHandlePosition;
		
		iLastDragTime.UniversalTime();
		iLastDragPosition = iStartDragPosition;
	}
	else if(aPointerEvent.iType == TPointerEvent::EDrag) {	
		if(!iDraggingAllowed && (aPointerEvent.iPosition.iY + 32 < iStartDragPosition || aPointerEvent.iPosition.iY - 32 > iStartDragPosition)) {
			iDraggingAllowed = true;			
			iSnapToItem = false;
		}
		
		if(iDraggingAllowed) {
			TTime aNow;			
			aNow.UniversalTime();
			
			iDragVelocity = TReal(TReal(iLastDragPosition - aPointerEvent.iPosition.iY) * (1000000.0 / TReal(aNow.MicroSecondsFrom(iLastDragTime).Int64()))) / 20.0;
			
			iLastDragTime.UniversalTime();
			iLastDragPosition = aPointerEvent.iPosition.iY;
			
			iScrollbarHandlePosition = iStartDragHandlePosition + (iStartDragPosition - aPointerEvent.iPosition.iY);
			
			CBuddycloudListComponent::RepositionItems(false);
			RenderScreen();
		}
	}
}
コード例 #6
0
ファイル: TheHUD.cpp プロジェクト: superwills/Wryv
void ATheHUD::RenderPortrait()
{
  // Draws the portrait of the first selected object
  if( Selected.size() )
  {
    AGameObject* selected = *Selected.begin();
    // Portrait: render last-clicked object to texture zoom back by radius of bounding sphere of clicked object
    FVector camDir( .5f, .5f, -FMath::Sqrt( 2.f ) );
    RenderScreen( rendererIcon, selected->Pos, selected->HitBoundsCylindricalRadius(), camDir );
  }
}
コード例 #7
0
void CBuddycloudListComponent::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent /*aEventType*/) {
#ifdef __SERIES60_40__
	if(aScrollBar) {
		iSnapToItem = false;
		
		iDragTimer->Stop();
		iDragVelocity = 0.0;
		
		iScrollBarVModel.iThumbPosition = aScrollBar->ThumbPosition();	
		iScrollBarVModel.CheckBounds();	
		
		iScrollbarHandlePosition = iScrollBarVModel.iThumbPosition;	
		
		RenderScreen();
	}
#endif
}
コード例 #8
0
void main() {

Start_TP();

//initalize variables on startup
initVariables();

//translate.z = 10.0;

scale.x = 95.0;  //x scale
scale.y = 95.0;  //y scale
scale.z = 95.0;  //z scale


bg_color = TFT_RGBToColor16bit(92, 92, 92);

//Clear the screen
//TFT_Fill_Screen(CL_BLACK);
TFT_Fill_Screen(bg_color);


  ACCEL_Start(&cACCEL_test_status);
  while (1){

  //read the accelerometer
  ACCEL_Test();

  //Check for user input
  GetInput();

  //animate the objects in the frame
  //AnimateFrame();

  //Draw the graphics
  RenderScreen();

  frame_counter++;
  
  }

}
コード例 #9
0
ファイル: soccer.c プロジェクト: AndrewHazelden/IRIX-SOCCER
int main (int argc, char *argv[]){
	
	PrintVersion();  //Print game info
    InitGFX();       //Setup SDL
    LoadSprites();   //Load the game sprites
    ResetGame();     //Reset the game

    done = 0;
    while (!done){
        //Check for user input
        GetInput();

        //Draw the graphics
        RenderScreen();
    }
    
    //Free the game sprites
    FreeSprites();  

    return 0;
}
コード例 #10
0
ファイル: buildings.cpp プロジェクト: Siile/Ninslash
void CBuildings::OnRender()
{
	if(Client()->State() < IClient::STATE_ONLINE)
		return;
	
	int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT);
	for(int i = 0; i < Num; i++)
	{
		IClient::CSnapItem Item;
		const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, i, &Item);

		if(Item.m_Type == NETOBJTYPE_TURRET)
		{
			const struct CNetObj_Turret *pTurret = (const CNetObj_Turret *)pData;
			const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID);
			RenderTurret(pTurret, pPrev ? (const CNetObj_Turret *)pPrev : pTurret);
		}
		else if(Item.m_Type == NETOBJTYPE_POWERUPPER)
			RenderPowerupper((const CNetObj_Powerupper *)pData);
		else if(Item.m_Type == NETOBJTYPE_SHOP)
			RenderShop((const CNetObj_Shop *)pData);
		else if (Item.m_Type == NETOBJTYPE_BUILDING)
		{
			const struct CNetObj_Building *pBuilding = (const CNetObj_Building *)pData;
			const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID);
			
			switch (pBuilding->m_Type)
			{
			case BUILDING_SAWBLADE:
				RenderSawblade(pBuilding);
				break;
				
			case BUILDING_MINE1:
				RenderMine(pBuilding);
				break;
				
			case BUILDING_MINE2:
				RenderElectromine(pBuilding);
				break;
				
			case BUILDING_BARREL:
				RenderBarrel(pBuilding, pPrev ? (const CNetObj_Building *)pPrev : pBuilding);
				break;
				
			case BUILDING_POWERBARREL:
				RenderPowerBarrel(pBuilding, pPrev ? (const CNetObj_Building *)pPrev : pBuilding);
				break;
				
			case BUILDING_LAZER:
				RenderLazer(pBuilding);
				break;
				
			case BUILDING_FLAMETRAP:
				RenderFlametrap(pBuilding, pPrev ? (const CNetObj_Building *)pPrev : pBuilding);
				break;
				
			case BUILDING_BASE:
				RenderBase(pBuilding);
				break;
				
			case BUILDING_STAND:
				RenderStand(pBuilding, pPrev ? (const CNetObj_Building *)pPrev : pBuilding);
				break;
				
			case BUILDING_REACTOR:
				RenderReactor(pBuilding);
				break;
				
			case BUILDING_TESLACOIL:
				RenderTeslacoil(pBuilding, pPrev ? (const CNetObj_Building *)pPrev : pBuilding);
				break;
				
			case BUILDING_REACTOR_DESTROYED:
				RenderDestroyedReactor(pBuilding);
				break;
				
			case BUILDING_SWITCH:
				RenderSwitch(pBuilding);
				break;
				
			case BUILDING_DOOR1:
				RenderDoor1(pBuilding);
				break;
				
			case BUILDING_GENERATOR:
				RenderGenerator(pBuilding, pPrev ? (const CNetObj_Building *)pPrev : pBuilding);
				break;
				
			case BUILDING_SCREEN:
				RenderScreen(pBuilding);
				break;
				
			/*
			case BUILDING_SHOP:
				RenderShop(pBuilding);
				break;
				*/
				
			default:;
			};
			
			//m_pClient->m_pEffects->Light(vec2(pBuilding->m_X, pBuilding->m_Y), 512);
		}
	}
}
コード例 #11
0
ファイル: Shader.cpp プロジェクト: zouv/VGE_demo
//加载动态对象图片
bool CShader::LoadDynObjBpk(char *fileName,int *objAmount,
							int backDropPicID,int loadGuiID,float startShow,float endShow)
{
	if(NULL==m_ddraw7)
		return false;
	
	//用于保存位图信息的结构类型变量
	int bmpAmount;
	int bmpOffset;
	LPBYTE bmpBuffer;
	LPBITMAPINFOHEADER bmInfoHeader;
	LPBYTE dataBuffer;
	
	//读取Bpk文件
	FILE *file=NULL;
	file=fopen(fileName,"rb");
	if(NULL==file)
		return false;
	fscanf(file,"%d",&bmpAmount);
	for(int i=0;i<bmpAmount;i++)
	{
		//读位图信息
		fscanf(file,",%d,",&bmpOffset);
		bmpBuffer=new BYTE[bmpOffset];
		fread(bmpBuffer,sizeof(BYTE),bmpOffset,file);
		bmInfoHeader=(LPBITMAPINFOHEADER)bmpBuffer;
		dataBuffer=bmpBuffer+bmInfoHeader->biSize;
		//增加绘图表面结构列表的长度
		if(NULL==m_dynSurface)
		{
			m_dynSurface=new SSurface;
			m_iDynSrufaceLength=1;
		}
		else
		{
			SSurface *temp;
			temp=new SSurface[m_iDynSrufaceLength+1];
			memset(temp,0,sizeof(SSurface)*(m_iDynSrufaceLength+1));
			memcpy(temp,m_dynSurface,sizeof(SSurface)*m_iDynSrufaceLength);
			delete[] m_dynSurface;
			m_dynSurface=temp;
			m_iDynSrufaceLength++;
		}
		//绘制加载页页
		AddToShader(backDropPicID,0,0);
		AddToShader(35,57,526);
		RanderLoading(loadGuiID,
			startShow * bmpAmount/(endShow-startShow) + i , bmpAmount/(endShow-startShow) );
		RenderScreen(m_randerScreenX,m_randerScreenY);
		//保存位图信息
		m_hDc_temp=CreateCompatibleDC(m_hDc);
		m_hDc_sf=CreateCompatibleDC(m_hDc);	
		HBITMAP hBitmap,hOldBitmap;
		int w = bmInfoHeader->biWidth < 0 ? -bmInfoHeader->biWidth : bmInfoHeader->biWidth;			//!!
		int h = bmInfoHeader->biHeight < 0 ? -bmInfoHeader->biHeight : bmInfoHeader->biHeight;
		hBitmap=CreateCompatibleBitmap(m_hDc,w,h);
		hOldBitmap=(HBITMAP)SelectObject(m_hDc_temp,hBitmap);
		StretchDIBits(m_hDc_temp,0,0,w,h,0,0,w,h,dataBuffer,(BITMAPINFO*)bmInfoHeader,DIB_RGB_COLORS,SRCCOPY);
		//创建并添加图片信息到绘图页
		DDSURFACEDESC2 ddsDesc;
		memset(&ddsDesc,0,sizeof(DDSURFACEDESC2));
		ddsDesc.dwSize=sizeof(DDSURFACEDESC2);
		ddsDesc.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;
		ddsDesc.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN;
		ddsDesc.dwWidth=w;
		ddsDesc.dwHeight=h;
		if(m_ddraw7->CreateSurface(&ddsDesc,&m_dynSurface[m_iDynSrufaceLength-1].ddSurface,NULL))
			return false;
		//添加颜色键信息
		m_Colorkey.dwColorSpaceHighValue=0x000000;
		m_Colorkey.dwColorSpaceLowValue=0x000000;
		m_dynSurface[m_iDynSrufaceLength-1].ddSurface->SetColorKey(DDCKEY_SRCBLT,&m_Colorkey);
		m_dynSurface[m_iDynSrufaceLength-1].ddSurface->GetDC(&m_hDc_sf);
		BitBlt(m_hDc_sf,0,0,w,h,m_hDc_temp,0,0,SRCCOPY);
		m_dynSurface[m_iDynSrufaceLength-1].ddSurface->ReleaseDC(m_hDc_sf);
		m_dynSurface[m_iDynSrufaceLength-1].w=w;
		m_dynSurface[m_iDynSrufaceLength-1].h=h;
		m_dynSurface[m_iDynSrufaceLength-1].bTransparent=true;
		//清理内存
		DeleteDC(m_hDc_sf);
		SelectObject(m_hDc_temp,hOldBitmap);
		DeleteDC(m_hDc_temp);
		DeleteObject(m_hBitmap);
		DeleteObject(hOldBitmap);
		delete[] bmpBuffer;
	}
	fclose(file);

	*objAmount=bmpAmount;

	return true;
}
コード例 #12
0
ファイル: main.cpp プロジェクト: MensInvictaManet/Projects
// PROGRAM START
int main(int argc, char *argv[])
{
	srand((unsigned int)(time(0)));

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
	RMASK = 0xff000000;
	GMASK = 0x00ff0000;
	BMASK = 0x0000ff00;
	AMASK = 0x000000ff;
#else
	RMASK = 0x000000ff;
	GMASK = 0x0000ff00;
	BMASK = 0x00ff0000;
	AMASK = 0xff000000;
#endif

	// Load in the target image and create the two additional surfaces
	Target = IMG_Load("TestImage.png");
	if (Target->w > IMAGE_MAX_W) return -1;
	if (Target->h > IMAGE_MAX_H) return -2;
	Best		= SDL_CreateRGBSurface(SDL_SWSURFACE, Target->w, Target->h, 32, RMASK, GMASK, BMASK, AMASK);
	Evolve		= SDL_CreateRGBSurface(SDL_SWSURFACE, Target->w, Target->h, 32, RMASK, GMASK, BMASK, AMASK);

	// If the surfaces are wider or taller than the maximum render area, decide how to scale it to fit
	RenderScale = 1.0;
	if ((Target->w > RENDER_MAX_W) || (Target->h > RENDER_MAX_H))
		RenderScale = ((Target->w > Target->h) ? (double)(Target->w) / (double)(RENDER_MAX_W) : (double)(Target->h) / (double)(RENDER_MAX_H));

	// Find the pixel byte size (to avoid dividing over and over later (probably 4)
	TargetPixelSize = Target->pitch / Target->w;
	EvolvePixelSize = Evolve->pitch / Evolve->w;

	// Create bit shifting elements for later based on the system endian-ness and whether the image is 24-bit or 32-bit
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
	TargetBitMask_R		= 0xff << (8 * (TargetPixelSize - 1));
	TargetPixelShift_R	= 8 * (TargetPixelSize - 1);
	TargetBitMask_G		= 0xff << (8 * (TargetPixelSize - 2));
	TargetPixelShift_G	= 8 * (TargetPixelSize - 2);
	TargetBitMask_B		= 0xff << (8 * (TargetPixelSize - 3));
	TargetPixelShift_B	= 8 * (TargetPixelSize - 3);
	EvolveBitMask_R 	= 0xff << (8 * (EvolvePixelSize - 1));
	EvolvePixelShift_R	= 8 * (EvolvePixelSize - 1);
	EvolveBitMask_G 	= 0xff << (8 * (EvolvePixelSize - 2));
	EvolvePixelShift_G	= 8 * (EvolvePixelSize - 2);
	EvolveBitMask_B 	= 0xff << (8 * (EvolvePixelSize - 3));
	EvolvePixelShift_B	= 8 * (EvolvePixelSize - 3);
#else
	TargetBitMask_R		= 0xff << (8 * (TargetPixelSize - 3));
	TargetPixelShift_R	= 8 * (TargetPixelSize - 3);
	TargetBitMask_G 	= 0xff << (8 * (TargetPixelSize - 2));
	TargetPixelShift_G	= 8 * (TargetPixelSize - 2);
	TargetBitMask_B 	= 0xff << (8 * (TargetPixelSize - 1));
	TargetPixelShift_B	= 8 * (TargetPixelSize - 1);
	EvolveBitMask_R 	= 0xff << (8 * (EvolvePixelSize - 3));
	EvolvePixelShift_R	= 8 * (EvolvePixelSize - 3);
	EvolveBitMask_G 	= 0xff << (8 * (EvolvePixelSize - 2));
	EvolvePixelShift_G	= 8 * (EvolvePixelSize - 2);
	EvolveBitMask_B 	= 0xff << (8 * (EvolvePixelSize - 1));
	EvolvePixelShift_B	= 8 * (EvolvePixelSize - 1);
#endif

	// Load in the parts of the render rects that don't change
	SourceRect.x		= SourceRect.y	= 0;
	DestinationRect.w	= SourceRect.w	= Target->w;
	DestinationRect.h	= SourceRect.h	= Target->h;

	// Create the window
	if(!Window.DefineWindow(SCREEN_W, SCREEN_H, 32, false, "Triangle Image Evolution")) return -1;
	OpeningTick = SDL_GetTicks();
	TotalTime = 0.0;

	// Define all ListPolygon instances to a RANDOM state
	for (unsigned int i = 0; i < POLYGON_COUNT; i++) RandPolygon(&PolygonList[i]);

	// Calculate the starting fitness
	TempFitness		= 0.0;
	Fitness			= CalculateFitness();

	// Set the mutation information to NULL
	Attempts		= 0;
	Mutations		= 0;
	GoodMutations	= 0;
	RenderSwitch	= true;

	// Define the mutation type
	MutationType = Mutate1;

	while (true)
	{
		// Poll for input
		if(SDL_PollEvent(&event) > 0)
		{
			if(event.type & (SDL_KEYUP | SDL_KEYDOWN))
			{
				nKeyArray = SDL_GetKeyState(&nKeys);
				if (nKeyArray[SDLK_ESCAPE]) break;
				if (nKeyArray[SDLK_RETURN]) RenderSwitch = !RenderSwitch;
				if (nKeyArray[SDLK_1])		ExportBinary();
				if (nKeyArray[SDLK_2])		ImportBinary();
				if (nKeyArray[SDLK_3])		MutationType = Mutate1;
				if (nKeyArray[SDLK_4])		MutationType = Mutate2;
			}
		}

		// Go through a mutation sequence
		MutationType(PolygonList);

		if (RenderSwitch) RenderScreen(RenderScale);
	}

	SDL_FreeSurface(Target);
	SDL_FreeSurface(Best);
	SDL_FreeSurface(Evolve);
	Window.Undefine();
	printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
	return 0;
}
コード例 #13
0
LRESULT CALLBACK FrameProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
   switch(Message)
   {
      case WM_HSCROLL:{
        int xDelta;
        int xNewPos;
        int yDelta = 0;

        switch (LOWORD(wParam)) {
            /* User clicked the shaft left of the scroll box. */
            case SB_PAGEUP:
                xNewPos = xCurrentScroll - xPageScroll;
                break;
            /* User clicked the shaft right of the scroll box. */
            case SB_PAGEDOWN:
                xNewPos = xCurrentScroll + xPageScroll;
                break;
            /* User clicked the left arrow. */
            case SB_LINEUP:
                xNewPos = xCurrentScroll - xIncrementScroll;
                break;
            /* User clicked the right arrow. */
            case SB_LINEDOWN:
                xNewPos = xCurrentScroll + xIncrementScroll;
                break;
            /* User dragged or is dragging the scroll box. */
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                xNewPos = HIWORD(wParam);
                break;
            default:
                xNewPos = xCurrentScroll;
        }
        /* New position must be between 0 and the screen width. */
        xNewPos = max(0, xNewPos);
        xNewPos = min(xMaxScroll, xNewPos);

        /* If the current position does not change, do not scroll.*/
        if (xNewPos == xCurrentScroll)
            break;

        /* Determine the amount scrolled (in pixels). */
        xDelta = (xNewPos - xCurrentScroll)*xPixelsPerIncrement;
                           //(-) is hit left, scroll right
        /* Reset the current scroll position. */
        xCurrentScroll = xNewPos;

        ScrollDC(hdcMemoryTheMap,-xDelta,-yDelta,NULL,NULL,NULL,NULL);
        MapPositionX=xCurrentScroll;
        if (xDelta>0)    //hit right, scroll left
          RenderScreen(hwnd,max(0,(TheMapWidth-xDelta)),0,TheMapWidth,TheMapHeight);
        else   //hit left, scroll right
          RenderScreen(hwnd,0,0,min(TheMapWidth,-xDelta),TheMapHeight);
        ScrollWindowEx(hwnd, -xDelta, -yDelta, &TheWindowRect,
            &TheWindowRect, (HRGN) NULL, (LPRECT) NULL,
            SW_INVALIDATE);
//             InvalidateRect(hwnd,&TheWindowRect,false);
        UpdateWindow(hwnd);
        ResetScrollBarX(hwnd);
      }
      break;

      case WM_VSCROLL:{
        int xDelta=0;
        int yNewPos;
        int yDelta;

        switch (LOWORD(wParam)) {
            /* User clicked the shaft above scroll box. */
            case SB_PAGEUP:
                yNewPos = yCurrentScroll - yPageScroll;
                break;
            /* User clicked the shaft below the scroll box. */
            case SB_PAGEDOWN:
                yNewPos = yCurrentScroll + yPageScroll;
                break;
            /* User clicked the up arrow. */
            case SB_LINEUP:
                yNewPos = yCurrentScroll - yIncrementScroll;
                break;
            /* User clicked the down arrow. */
            case SB_LINEDOWN:
                yNewPos = yCurrentScroll + yIncrementScroll;
                break;
            /* User dragged or is dragging the scroll box. */
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                yNewPos = HIWORD(wParam);
                break;
            default:
                yNewPos = yCurrentScroll;
        }
        /* New position must be between 0 and the screen height. */
        yNewPos = max(0, yNewPos);
        yNewPos = min(yMaxScroll, yNewPos);

        /* If the current position does not change, do not scroll.*/
        if (yNewPos == yCurrentScroll)
            break;

        /* Determine the amount scrolled (in pixels). */
        yDelta = (yNewPos - yCurrentScroll)*yPixelsPerIncrement;
                           //(-) is hit up, scroll down
        /* Reset the current scroll position. */
        yCurrentScroll = yNewPos;

        ScrollDC(hdcMemoryTheMap,-xDelta,-yDelta,NULL,NULL,NULL,NULL);
        MapPositionY=yCurrentScroll;
        if (yDelta>0)    //hit down, scroll up
          RenderScreen(hwnd,0,max(0,(TheMapHeight-yDelta)),TheMapWidth,TheMapHeight);
        else   //hit up, scroll down
          RenderScreen(hwnd,0,0,TheMapWidth,min(TheMapHeight,-yDelta));

        ScrollWindowEx(hwnd, -xDelta, -yDelta, &TheWindowRect,
            &TheWindowRect, (HRGN) NULL, (LPRECT) NULL,
            SW_INVALIDATE);
        UpdateWindow(hwnd);
        ResetScrollBarY(hwnd);
      }
      break;
      case WM_COMMAND:
          MainWindowCommand(hwnd,LOWORD(wParam));
          break;
      case WM_ERASEBKGND:
          if (MapLoaded)
               return 1;   //don't erase background if we have the map loaded
          return DefWindowProc(hwnd, Message, wParam, lParam);
      case WM_PAINT:
         PAINTSTRUCT ps;
         HDC hdcWindow;
         hdcWindow = BeginPaint(hwnd, &ps);

         if (!TheMapBitmap)
         {
            CreateMainBitmapX(hwnd);
            RenderFullScreen(hwnd);
         }
         DisplayFullScreen2(hdcWindow);

         EndPaint(hwnd, &ps);
         break;

      case WM_SIZE:
         //Adjust our bitmap to fit window
         if ((wParam==SIZE_MAXIMIZED)||(wParam==SIZE_RESTORED))
            AdjustScreenSize(hwnd,LOWORD(lParam),HIWORD(lParam));
         break;
      case WM_CREATE:
         CreateMainMenu(hwnd);
         break;
      case WM_CLOSE:
         DestroyWindow(hwnd);
         break;
      case WM_DESTROY:
         FreeAllData();
         if (hdcMemoryTheMap)
            DeleteDC(hdcMemoryTheMap);
         if (TheMapBitmap)
            DeleteObject(TheMapBitmap);
         PostQuitMessage(0);
         break;
      default: return DefWindowProc(hwnd, Message, wParam, lParam);
   }
   return 0;
}
コード例 #14
0
unsigned int CreateMainBitmapXZ(HWND hwnd, int Width, int Height)  {
bool InvalidateOld=false;
RECT ARect;
int NewWidth;
int NewHeight;

     //Set up new window variables, create temp copy of old ones
   memcpy(&ARect,&TheWindowRect,sizeof(RECT));
   TheWindowHeight=Height;
   TheWindowWidth=Width;
   TheWindowRect.top=0;
   TheWindowRect.left=0;
   TheWindowRect.bottom=TheWindowHeight;
   TheWindowRect.right=TheWindowWidth;

   //Set up horizontal window scroll variables
   xMinScroll=0;
   xPageScroll=TheWindowWidth/8;
   if (!MapLoaded)
      xMaxScroll=0;
   else
      xMaxScroll=MaxXPixels/8-xPageScroll;

   if (xMaxScroll<=0)
   {
     xMaxScroll=0;
     InvalidateOld=true;
     MapPositionX=0;
   }
   xCurrentScroll=MapPositionX;
   xIncrementScroll=1;
   xPixelsPerIncrement=8;

   //Set up horizontal scrollbar
   si.cbSize = sizeof(si);
   si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS;
   si.nMin   = xMinScroll;
   si.nMax   = xMaxScroll;
   si.nPage  = xIncrementScroll;
   si.nPos   = xCurrentScroll;
   SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);

   //Set up vertical window scroll variables
   yMinScroll=0;
   yPageScroll=TheWindowHeight/8;
   if (!MapLoaded)
      yMaxScroll=0;
   else
      yMaxScroll=MaxYPixels/8-yPageScroll;
   if (yMaxScroll<=0)
   {
      yMaxScroll=0;
      InvalidateOld=true;
      MapPositionY=0;
   }
   yCurrentScroll=MapPositionY;
   yIncrementScroll=1;
   yPixelsPerIncrement=8;

   //Set up vertical scrollbar
   si.cbSize = sizeof(si);
   si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS;
   si.nMin   = yMinScroll;
   si.nMax   = yMaxScroll;
   si.nPage  = yIncrementScroll;
   si.nPos   = yCurrentScroll;
   SetScrollInfo(hwnd, SB_VERT, &si, TRUE);

   NewWidth=TheWindowWidth/8;
   NewHeight=TheWindowHeight/8;
   NewWidth=NewWidth*8;
   NewHeight=NewHeight*8;

   if (NewWidth<8)
     NewWidth=8;
   if (NewHeight<8)
     NewHeight=8;
   if (NewWidth<TheWindowWidth)
     NewWidth+=8;
   if (NewHeight<TheWindowHeight)
     NewHeight+=8;
   if (NewWidth>2048)
     NewWidth=2048;
   if (NewHeight>2048)
     NewHeight=2048;
   if (TheMapBitmap) //if we're recreating the bitmap...
     if ((NewWidth==TheMapWidth)&&(NewHeight==TheMapHeight))
         return false;
   if (hdcMemoryTheMap)
     DeleteDC(hdcMemoryTheMap);
   if (TheMapBitmap)
     DeleteObject(TheMapBitmap);
   hdcMemoryTheMap=NULL;
   TheMapBitmap=NULL;
   TheMapWidth=NewWidth;
   TheMapHeight=NewHeight;

   if (!(CreateMainBitmap(hwnd)))
      return false;

   if (InvalidateOld)
     InvalidateRect(hwnd,&ARect,false);   

   RenderScreen(hwnd,0,0,TheMapWidth,TheMapHeight);
   return true;
}
コード例 #15
0
void RenderFullScreen(HWND hwnd)  {

   if (!MapLoaded)
      return;
   RenderScreen(hwnd,0,0,TheMapWidth,TheMapHeight);
}