Пример #1
0
void CreateScene(Scene& scene)
{
	scene.Clear();

	scene.EnableLighting = false;
	scene.EnableFlatShading = false;

	TileTexture* tile = new TileTexture(256,256);
	WoodTexture* wood = new WoodTexture(256,256);

	scene.SetAmbient(Color(0.4, 0.4, 0.4));
	scene.AddLight(Point3D(100,80,50), Color(0.8, 0.8, 0.8));
	scene.AddLight(Point3D(-100,-80,-50), Color(0.8, 0.8, 0.8));

	scene.SetTexture(tile, NULL);
	scene.modeling.Push();
	scene.modeling.Translate(-0.6, 0.0, 0);
	scene.SetColor(HSVColor(0.083, 0.75, 0.8), HSVColor(0.0, 0.0, 0.0), 0);
	CreateRect(scene, 1.0, 1.0);
	scene.modeling.Pop();

	scene.SetTexture(wood, NULL);
	scene.modeling.Push();
	scene.modeling.Translate(0.6, 0.0, 0);
	scene.SetColor(HSVColor(0.125, 0.7, 0.8), HSVColor(0.0, 0.0, 0.0), 0);
	CreateRect(scene, 1.0, 1.0);
	scene.modeling.Pop();
}
Пример #2
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);
	m_ChessSelect.Create(IDD_CHESS_SELECT,this);
	m_GameScoreWnd.Create(NULL,NULL,WS_CHILD,CreateRect,this,10);
	m_ChessBorad.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,11);

	//创建按钮
	m_btStudy.Create(NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,IDC_STUDY);
	m_btStart.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_START);
	m_btPeace.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_PEACE);
	m_btRegret.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_REGRET);
	m_btGiveUp.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_GIVEUP);
	m_btPreserve.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_PRESERVE);

	//加载位图
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btPeace.SetButtonImage(IDB_PEACE,hInstance,false);
	m_btStudy.SetButtonImage(IDB_STUDY,hInstance,false);
	m_btGiveUp.SetButtonImage(IDB_GIVEUP,hInstance,false);
	m_btRegret.SetButtonImage(IDB_REGRET,hInstance,false);
	m_btPreserve.SetButtonImage(IDB_PRESERVE,hInstance,false);

	//请求控件
	m_PeaceRequest.InitRequest(IDM_PEACE_ANSWER,15,TEXT("对家请求 [ 和棋 ] 你是否同意?"));
	m_RegretRequest.InitRequest(IDM_REGRET_ANSWER,15,TEXT("对家请求 [ 悔棋 ] 你是否同意?"));

	return 0;
}
Пример #3
0
static void CompsInit(void)
{
  CglCanvas *pcan=pScreenMain->pBackCanvas;
  
  for(u32 idx=0;idx<CompLabelsCount;idx++){
    ComponentLabel_Init(&CompLabels[idx],pcan);
  }
  for(u32 idx=0;idx<CompChecksCount;idx++){
    ComponentCheck_Init(&CompChecks[idx],pcan);
  }
  for(u32 idx=0;idx<CompButtonsCount;idx++){
    ComponentButton_Init(&CompButtons[idx],pcan);
  }
  
  s32 x,y;
  
  x=173;
  y=163;
  
  {
    TComponentButton *pcb=&CompButtons[ECBS_CancelBtn];
    pcb->CallBack_Click=CB_CancelBtn_Click;
    pcb->pIcon=NULL;
    pcb->pMsgUTF8="";
    pcb->Rect=CreateRect(x,y,ScreenWidth-x,ScreenHeight-y);
    pcb->DrawFrame=false;
  }
}
Пример #4
0
//Draws the specified texture
//param:texture->the index given from load texture
//param:color->the tint to apply to the texture
//param:sourceRect->the rectangle to pull a smaller image from the texture with. NULL for the whole texture
//param:position->the point to draw to
//param:angle->the rotation to apply
//param:scale->the scale to apply. This is uniform across x and y
//param:flip->SDL_RendererFlip::None/FlipHorizontal/FlipVertical. If you want both Flip Horizontal and Flip Vertical,
//use the bitwise operator '|'
//param:origin->Origin to rotate around. If NULL, uses center of destRect created by position and scale
//param:layerDepth->The depth to draw the image at
//returns -1 on error, 0 for success
int SpriteBatch::DrawTexture(Uint32 texture, SDL_Color color, const SDL_Rect* sourceRect, const SDL_Point* position,
		float angle, float scale, SDL_RendererFlip flip, const SDL_Point* origin, float layerDepth)
{
	//Check if spritebatch.begin has been called
	if(!begun)
	{
		std::cout<<"Begin must be called before attempting to draw"<<std::endl;
		return -1;
	}

	///create a temporary point
	SDL_Point pos = SDL_Point();

	//if position is null, set our temp to 0,0
	if(!position)
	{
		pos = CreatePoint(0, 0);
	}
	else
	{
		//otherwise set with position
		pos = CreatePoint(position->x, position->y);
	}

	SDL_Rect destRect = SDL_Rect();

	//If we were given a source rectangle
	if(sourceRect)
	{
		//create a dest rectangle using position and source rectangle's dimensions
		destRect = CreateRect(pos.x, pos.y, (int)(sourceRect->w * scale), (int)(sourceRect->h * scale));
	}
	else
	{
		int w = 0;
		int h = 0;

		//get the width and height
		SDL_QueryTexture(textureList[texture], NULL, NULL, &w, &h);
		//create a dest rect using position and the image dimensions
		destRect = CreateRect(pos.x, pos.y, (int)(w * scale), (int)(h * scale));
	}

	//Call other DrawTexture to do the actual drawing
	return DrawTexture(texture, color, sourceRect, &destRect, angle, origin, flip, layerDepth);
}
Пример #5
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);
	m_ScoreView.Create(IDD_GAME_SCORE,this);

	//创建扑克
	for (WORD i=0;i<3;i++)
	{
		m_UserCardControl[i].SetDirection(true);
		m_UserCardControl[i].SetDisplayFlag(true);
		m_UserCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,20+i);
	}
	for (WORD i=0;i<2;i++) 
	{
		m_LeaveCardControl[i].SetDirection(false);
		m_LeaveCardControl[i].SetDisplayFlag(true);
		m_LeaveCardControl[i].SetCardSpace(0,18,0);
		m_LeaveCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
	}

	m_BackCardControl.SetCardSpace(80,0,0);
	m_BackCardControl.SetDisplayFlag(true);
	m_HandCardControl.SetSinkWindow(AfxGetMainWnd());
	m_HandCardControl.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,40);
	m_BackCardControl.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,41);

	//创建按钮
	m_btStart.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_START);
	m_btOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_OUT_CARD);
	m_btPassCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_PASS_CARD);
	m_btOneScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_ONE_SCORE);
	m_btTwoScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_TWO_SCORE);
	m_btThreeScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_THREE_SCORE);
	m_btGiveUpScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_GIVE_UP_SCORE);
	m_btAutoOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AUTO_OUTCARD);

	//设置按钮
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btOutCard.SetButtonImage(IDB_OUT_CARD,hInstance,false);
	m_btPassCard.SetButtonImage(IDB_PASS,hInstance,false);
	m_btOneScore.SetButtonImage(IDB_ONE_SCORE,hInstance,false);
	m_btTwoScore.SetButtonImage(IDB_TWO_SCORE,hInstance,false);
	m_btThreeScore.SetButtonImage(IDB_THREE_SCORE,hInstance,false);
	m_btGiveUpScore.SetButtonImage(IDB_GIVE_UP,hInstance,false);
	m_btAutoOutCard.SetButtonImage(IDB_AUTO_OUT_CARD,hInstance,false);

	//读取配置
	m_bDeasilOrder=AfxGetApp()->GetProfileInt(TEXT("GameOption"),TEXT("DeasilOrder"),FALSE)?true:false;

	return 0;
}
Пример #6
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件区域
	CRect CreateRect( 0, 0, 40, 30 );
	//变量定义
	enDirection Direction[]={Direction_North,Direction_East,Direction_South,Direction_West};

	//设置控件
	for (WORD i=0;i<4;i++)
	{
		//用户麻将
		m_HeapCard[i].SetDirection(Direction[i]);
		m_TableCard[i].SetDirection(Direction[i]);
		m_DiscardCard[i].SetDirection(Direction[i]);

		//组合麻将
		m_WeaveCard[i][0].SetDisplayItem(true);
		m_WeaveCard[i][1].SetDisplayItem(true);
		m_WeaveCard[i][2].SetDisplayItem(true);
		m_WeaveCard[i][3].SetDisplayItem(true);
		m_WeaveCard[i][0].SetDirection(Direction[i]);
		m_WeaveCard[i][1].SetDirection(Direction[i]);
		m_WeaveCard[i][2].SetDirection(Direction[i]);
		m_WeaveCard[i][3].SetDirection(Direction[i]);
	}

	//设置控件
	m_UserCard[0].SetDirection(Direction_North);
	m_UserCard[1].SetDirection(Direction_East);
	m_UserCard[2].SetDirection(Direction_West);

	//创建控件
	CRect rcCreate(0,0,0,0);
	m_GameScoreWnd.Create(NULL,NULL,WS_CHILD|WS_CLIPCHILDREN,rcCreate,this,100);
	m_ControlWnd.Create(NULL,NULL,WS_CHILD|WS_CLIPCHILDREN,rcCreate,this,10,NULL);

	//创建控件
	m_btStart.Create(NULL,WS_CHILD,rcCreate,this,IDC_START);
	m_btStart.SetButtonImage(IDB_BT_START,AfxGetInstanceHandle(),false);

	//听按钮
	m_btTingCard.Create(NULL,WS_CHILD,rcCreate,this,IDC_TING_CARD);
	m_btTingCard.SetButtonImage(IDB_BT_TING_CARD,AfxGetInstanceHandle(),false);
	//时钟控件
	m_Timer.SetBitmap( IDB_TIMERBACK, IDB_TIMERARROW );
	m_Timer.SetSinkWindow( AfxGetMainWnd() );
	m_Timer.SetDesOrder( false );
	m_Timer.Create( NULL, NULL, WS_VISIBLE|WS_CHILD, CreateRect, this, 20 );
	m_Timer.ShowWindow( SW_HIDE);
	return 0;
}
Пример #7
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);
	m_ChessSelect.Create(IDD_CHESS_SELECT,this);
	m_GameScoreWnd.Create(NULL,NULL,WS_CHILD,CreateRect,this,10);
	m_ChessBorad.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,11);

	//创建按钮
	m_btStudy.Create(NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,IDC_STUDY);
	m_btStart.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_START);
	m_btPeace.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_PEACE);
	m_btRegret.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_REGRET);
	m_btGiveUp.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_GIVEUP);
	m_btPreserve.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_PRESERVE);

	//加载位图
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btPeace.SetButtonImage(IDB_PEACE,hInstance,false);
	m_btStudy.SetButtonImage(IDB_STUDY,hInstance,false);
	m_btGiveUp.SetButtonImage(IDB_GIVEUP,hInstance,false);
	m_btRegret.SetButtonImage(IDB_REGRET,hInstance,false);
	m_btPreserve.SetButtonImage(IDB_PRESERVE,hInstance,false);

	//请求控件
	m_PeaceRequest.InitRequest(IDM_PEACE_ANSWER,15,TEXT("对家请求 [ 和棋 ] 你是否同意?"));
	m_RegretRequest.InitRequest(IDM_REGRET_ANSWER,15,TEXT("对家请求 [ 悔棋 ] 你是否同意?"));

#ifdef VIDEO_GAME
	//创建视频
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//创建视频
		m_DlgVideoService[i].Create(NULL,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS,CreateRect,this,200+i);
		m_DlgVideoService[i].InitVideoService(i==1,i==1);

		//设置视频
		g_VideoServiceManager.SetVideoServiceControl(i,&m_DlgVideoService[i]);
	}
#endif

	return 0;
}
Пример #8
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);
	m_ScoreView.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,CreateRect,this,9);

	//创建扑克
	for (WORD i=0;i<4;i++)
	{
		m_UserCardControl[i].SetDirection(true);
		m_UserCardControl[i].SetDisplayFlag(true);
		m_UserCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,20+i);
	}
	for (WORD i=0;i<3;i++)
	{
		m_LeaveCardControl[i].SetDisplayFlag(true);
		m_LeaveCardControl[i].SetCardSpace(20,18,0);
		m_LeaveCardControl[i].SetDirection((i==0)?true:false);
		m_LeaveCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
	}
	m_HandCardControl.SetSinkWindow(AfxGetMainWnd());
	m_HandCardControl.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,40);

	//创建按钮
	m_btStart.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_START);
	m_btOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_OUT_CARD);
	m_btPassCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_PASS_CARD);
	//m_btOutPrompt.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_OUT_PROMPT);

	//设置按钮
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btOutCard.SetButtonImage(IDB_OUT_CARD,hInstance,false);
	m_btPassCard.SetButtonImage(IDB_PASS,hInstance,false);
	//m_btOutPrompt.SetButtonImage(IDB_OUT_PROMPT,hInstance,false);

	//读取配置
	m_bDeasilOrder=AfxGetApp()->GetProfileInt(TEXT("GameOption"),TEXT("DeasilOrder"),FALSE)?true:false;

	return 0;
}
Пример #9
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    CString strFile,strTemp;
    CTime tmCur = CTime::GetCurrentTime();
    CString strTime = tmCur.Format("%m%d");
    strFile.Format("log\\%sCGameClientView.log",strTime);

    strTemp.Format("into OnCreate()");
    WriteLog(strFile, strTemp);


    if (__super::OnCreate(lpCreateStruct)==-1) return -1;

    //创建控件
    CRect CreateRect(0,0,0,0);
    m_ChessSelect.Create(IDD_CHESS_SELECT,this);
    m_GameScoreWnd.Create(NULL,NULL,WS_CHILD,CreateRect,this,10);
    m_ChessBorad.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,11);

    //创建按钮
    m_btStudy.Create(NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,IDC_STUDY);
    m_btStart.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_START);
    m_btPeace.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_PEACE);
    m_btRegret.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_REGRET);
    m_btGiveUp.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_GIVEUP);
    m_btPreserve.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_PRESERVE);

    //加载位图
    HINSTANCE hInstance=AfxGetInstanceHandle();
    m_btStart.SetButtonImage(IDB_START,hInstance,false);
    m_btPeace.SetButtonImage(IDB_PEACE,hInstance,false);
    m_btStudy.SetButtonImage(IDB_STUDY,hInstance,false);
    m_btGiveUp.SetButtonImage(IDB_GIVEUP,hInstance,false);
    m_btRegret.SetButtonImage(IDB_REGRET,hInstance,false);
    m_btPreserve.SetButtonImage(IDB_PRESERVE,hInstance,false);

    //请求控件
    m_PeaceRequest.InitRequest(IDM_PEACE_ANSWER,15,TEXT("对家请求 [ 和棋 ] 你是否同意?"));
    m_RegretRequest.InitRequest(IDM_REGRET_ANSWER,15,TEXT("对家请求 [ 悔棋 ] 你是否同意?"));

    return 0;
}
Пример #10
0
void MenuButton::Draw() {
	int heightOffset = 4; // without offset, font is a little to high

	// draw the background rectangle
	spriteBatch->DrawFilledRect(
		&CreateRect(x, y, width, height),
		bg
	);

	// draw the text
	spriteBatch->DrawString(
		font,
		text,
		StringDrawMode::Solid,
		fg,
		CreateColor(0, 0, 0, 255),
		width,
		&CreatePoint(x + width / 2 - spriteFont->GetMessageSize(0, text).x / 2, y + heightOffset + height / 2 - spriteFont->GetMessageSize(0, text).y / 2)
	);
}
Пример #11
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);
	m_GoldControl.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS,CreateRect,this,8,NULL);
	m_ScoreView.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,CreateRect,this,9);
	for (int i=0;i<4;i++) m_CardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,10+i);

	//创建按钮
	m_btStart.Create(NULL,WS_CHILD,CreateRect,this,IDC_START);
	m_btFollow.Create(NULL,WS_CHILD,CreateRect,this,IDC_FOLLOW);
	m_btGiveUp.Create(NULL,WS_CHILD,CreateRect,this,IDC_GIVE_UP);
	m_btAddGold.Create(NULL,WS_CHILD,CreateRect,this,IDC_ADD_GOLD);
	m_btShowHand.Create(NULL,WS_CHILD,CreateRect,this,IDC_SHOW_HAND);

	//加载位图
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_BT_STAR,hInstance,false);
	m_btFollow.SetButtonImage(IDB_BT_FOLLOW,hInstance,false);
	m_btGiveUp.SetButtonImage(IDB_BT_GIVE_UP,hInstance,false);
	m_btAddGold.SetButtonImage(IDB_BT_ADD_GOLD,hInstance,false);
	m_btShowHand.SetButtonImage(IDB_BT_SHOW_HAND,hInstance,false);

#ifdef VIDEO_GAME
	//创建视频
	for (WORD i=0;i<4;i++)
	{
		//创建视频
		m_DlgVedioService[i].Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,200+i);
		m_DlgVedioService[i].InitVideoService(i==2,i==2);

		//设置视频
		g_VedioServiceManager.SetVideoServiceControl(i,&m_DlgVedioService[i]);
	}
#endif


	return 0;
}
Пример #12
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);
	m_ScoreView.Create(IDD_GAME_SCORE,this);

	//创建扑克
	for (WORD i=0;i<4;i++)
	{
		m_UserCardControl[i].SetDirection(true);
		m_UserCardControl[i].SetDisplayFlag(true);
		m_UserCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,20+i);
	}
	for (WORD i=0;i<4;i++)
	{
		m_UserCardControl[i].SetlargCard();
		m_UserCardControl[i].SetCardSpace(15,0,0);
		m_HandCardControl[i].SetDisplayFlag(true);
		m_HandCardControl[i].SetCardSpace(14,13,0);
		m_HandCardControl[i].SetDirection(((i==0)||(i==2))?true:false);
		m_HandCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
	}
	m_BackCardControl.Create(NULL, NULL,WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,CreateRect,this, 70);
	m_BackCardControl.SetCardSpace(13,0,0);
	m_BackCardControl.SetDisplayFlag(true);
	m_HandCardControl[2].SetSinkWindow(AfxGetMainWnd());

	//设置大牌
	m_HandCardControl[2].SetlargCard();

	//创建按钮
	m_btStart.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_START);
	m_btOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_OUT_CARD);
	m_btPassCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_PASS_CARD);
	m_btOneScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_ONE_SCORE);
	m_btTwoScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_TWO_SCORE);
	m_btThreeScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_THREE_SCORE);
	m_btShowCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_SHOW_CARD);
	m_btGiveUpScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_GIVE_UP_SCORE);

	m_btSortByNum.Create(TEXT(""),WS_CHILD, CreateRect, this, IDC_SORT_BY_NUM);
	m_btSortBySize.Create(TEXT(""), WS_CHILD, CreateRect, this, IDC_SORT_BY_SIZE);

	//设置按钮
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btOutCard.SetButtonImage(IDB_OUT_CARD,hInstance,false);
	m_btPassCard.SetButtonImage(IDB_PASS,hInstance,false);
	m_btOneScore.SetButtonImage(IDB_ONE_SCORE,hInstance,false);
	m_btTwoScore.SetButtonImage(IDB_TWO_SCORE,hInstance,false);
	m_btThreeScore.SetButtonImage(IDB_THREE_SCORE,hInstance,false);
	m_btShowCard.SetButtonImage(IDB_BT_SHOW_CARD,hInstance,false);
	m_btGiveUpScore.SetButtonImage(IDB_GIVE_UP,hInstance,false);
	//按张数排序按钮
	m_btSortByNum.SetButtonImage(IDB_BT_2, hInstance, false);
	//按大小排序按钮
	m_btSortBySize.SetButtonImage(IDB_BT_1, hInstance, false);

	//读取配置
	m_bDeasilOrder=AfxGetApp()->GetProfileInt(TEXT("GameOption"),TEXT("DeasilOrder"),FALSE)?true:false;

#ifdef VIDEO_GAME
	//创建视频
	for (WORD i=0;i<4;i++)
	{
		//创建视频
		m_DlgVideoService[i].Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,200+i);
		m_DlgVideoService[i].InitVideoService(i==2,i==2);

		//设置视频
		g_VideoServiceManager.SetVideoServiceControl(i,&m_DlgVideoService[i]);
	}
		
	for (WORD i=0;i<4;i++)
	{
		m_HandCardControl[i].SetCardSpace(10,10,0);
		if(i==2) m_HandCardControl[i].SetCardSpace(15,12,0);
	}
#endif

	return 0;
}
Пример #13
0
static void CompsInit(void)
{
  CglCanvas *pcan=pScreenMain->pBackCanvas;
  
  for(u32 idx=0;idx<CompLabelsCount;idx++){
    ComponentLabel_Init(&CompLabels[idx],pcan);
    CompLabels[idx].TextColor=ColorTable.Setup.Label_Text;
  }
  for(u32 idx=0;idx<CompChecksCount;idx++){
    ComponentCheck_Init(&CompChecks[idx],pcan);
    CompChecks[idx].TextColor=ColorTable.Setup.Check_Text;
  }
  for(u32 idx=0;idx<CompButtonsCount;idx++){
    ComponentButton_Init(&CompButtons[idx],pcan);
    CompButtons[idx].NormalTextColor=ColorTable.Setup.Button_NormalText;
    CompButtons[idx].PressTextColor=ColorTable.Setup.Button_PressText;
  }
  
  s32 chksize=13;
  
  s32 x,y;
  
  x=5;
  y=5;
  
  {
    TComponentCheck *pcc=&CompChecks[ECCS_BootCheckDiskChk];
    pcc->CallBack_Click=CB_BootCheckDiskChk_Click;
    pcc->pOnIcon=SetupAlpha_GetSkin(ESSA_ChkOverlayOn);
    pcc->pOffIcon=NULL;
    pcc->pMsgUTF8=Lang_GetUTF8("Setup_BootCheckDisk");
    pcc->Rect=CreateRect(x,y,chksize+6,chksize+6);
  }
  
  y+=24;
  
  {
    TComponentCheck *pcc=&CompChecks[ECCS_ClickSoundChk];
    pcc->CallBack_Click=CB_ClickSoundChk_Click;
    pcc->pOnIcon=SetupAlpha_GetSkin(ESSA_ChkOverlayOn);
    pcc->pOffIcon=NULL;
    pcc->pMsgUTF8=Lang_GetUTF8("Setup_ClickSound");
    pcc->Rect=CreateRect(x,y,chksize+6,chksize+6);
  }
  
  y+=23;
  
  x+=16;
  {
    TComponentLabel *pcl=&CompLabels[ECLS_FileListModeLbl];
    pcl->pMsgUTF8=Lang_GetUTF8("Setup_FileListMode");
    pcl->Rect=CreateRect(x,y,0,0);
  }
  x-=16;
  
  x+=9;
  y+=13;
  
  {
    TComponentCheck *pcc=&CompChecks[ECCS_FileListMode_SingleRadio];
    pcc->CallBack_Click=CB_FileListMode_SingleRadio_Click;
    pcc->pOnIcon=SetupAlpha_GetSkin(ESSA_RadioOverlayOn);
    pcc->pOffIcon=NULL;
    pcc->pMsgUTF8=Lang_GetUTF8("Setup_FileListMode_Single");
    pcc->Rect=CreateRect(x,y,chksize+6,chksize+6);
  }
  
  y+=20;
  
  {
    TComponentCheck *pcc=&CompChecks[ECCS_FileListMode_DoubleRadio];
    pcc->CallBack_Click=CB_FileListMode_DoubleRadio_Click;
    pcc->pOnIcon=SetupAlpha_GetSkin(ESSA_RadioOverlayOn);
    pcc->pOffIcon=NULL;
    pcc->pMsgUTF8=Lang_GetUTF8("Setup_FileListMode_Double");
    pcc->Rect=CreateRect(x,y,chksize+6,chksize+6);
  }
  
  x-=9;
  
  y+=29;
  
  {
    TComponentCheck *pcc=&CompChecks[ECCS_LRClickLongSeekChk];
    pcc->CallBack_Click=CB_LRClickLongSeekChk_Click;
    pcc->pOnIcon=SetupAlpha_GetSkin(ESSA_ChkOverlayOn);
    pcc->pOffIcon=NULL;
    pcc->pMsgUTF8=Lang_GetUTF8("Setup_LRClickLongSeek");
    pcc->Rect=CreateRect(x,y,chksize+6,chksize+6);
  }
  
  y+=25;
  
  {
    TComponentCheck *pcc=&CompChecks[ECCS_SkipSetupChk];
    pcc->CallBack_Click=CB_SkipSetupChk_Click;
    pcc->pOnIcon=SetupAlpha_GetSkin(ESSA_ChkOverlayOn);
    pcc->pOffIcon=NULL;
    pcc->pMsgUTF8=Lang_GetUTF8("Setup_SkipSetup");
    pcc->Rect=CreateRect(x,y,chksize+6,chksize+6);
  }
  
  x=148;
  y=160;
  
  {
    TComponentButton *pcb=&CompButtons[ECBS_OKBtn];
    pcb->CallBack_Click=CB_OKBtn_Click;
    pcb->pIcon=NULL;
    pcb->pMsgUTF8=Lang_GetUTF8("Setup_OKBtn");
    pcb->Rect=CreateRect(x,y,ScreenWidth-x,ScreenHeight-y);
    pcb->DrawFrame=false;
  }
  
  if(Skin_OwnerDrawText.Setup_Bottom==true){
    for(u32 idx=0;idx<CompLabelsCount;idx++){
      CompLabels[idx].pMsgUTF8="";
    }
    for(u32 idx=0;idx<CompChecksCount;idx++){
      CompChecks[idx].pMsgUTF8="";
    }
    for(u32 idx=0;idx<CompButtonsCount;idx++){
      CompButtons[idx].pMsgUTF8="";
    }
  }
}
Пример #14
0
bool ff::Value::Convert(Type type, Value **ppValue) const
{
	assertRetVal(ppValue, false);
	*ppValue = nullptr;

	if (type == GetType())
	{
		*ppValue = GetAddRef(const_cast<Value *>(this));
		return true;
	}

	wchar_t buf[256];

	switch (GetType())
	{
	case Type::Null:
		switch (type)
		{
		case Type::String:
			CreateString(String(L"null"), ppValue);
			break;
		}
		break;

	case Type::Bool:
		switch (type)
		{
		case Type::Double:
			CreateDouble(AsBool() ? 1.0 : 0.0, ppValue);
			break;

		case Type::Float:
			CreateFloat(AsBool() ? 1.0f : 0.0f, ppValue);
			break;

		case Type::Int:
			CreateInt(AsBool() ? 1 : 0, ppValue);
			break;

		case Type::String:
			CreateString(AsBool() ? String(L"true") : String(L"false"), ppValue);
			break;
		}
		break;

	case Type::Double:
		switch (type)
		{
		case Type::Bool:
			CreateBool(AsDouble() != 0, ppValue);
			break;

		case Type::Float:
			CreateFloat((float)AsDouble(), ppValue);
			break;

		case Type::Int:
			CreateInt((int)AsDouble(), ppValue);
			break;

		case Type::String:
			_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%g", AsDouble());
			CreateString(String(buf), ppValue);
			break;
		}
		break;

	case Type::Float:
		switch (type)
		{
		case Type::Bool:
			CreateBool(AsFloat() != 0, ppValue);
			break;

		case Type::Double:
			CreateDouble((double)AsFloat(), ppValue);
			break;

		case Type::Int:
			CreateInt((int)AsFloat(), ppValue);
			break;

		case Type::String:
			_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%g", AsFloat());
			CreateString(String(buf), ppValue);
			break;
		}
		break;

	case Type::Int:
		switch (type)
		{
		case Type::Bool:
			CreateBool(AsInt() != 0, ppValue);
			break;

		case Type::Double:
			CreateDouble((double)AsInt(), ppValue);
			break;

		case Type::Float:
			CreateFloat((float)AsInt(), ppValue);
			break;

		case Type::String:
			_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%d", AsInt());
			CreateString(String(buf), ppValue);
			break;
		}
		break;

	case Type::Point:
		switch (type)
		{
		case Type::String:
			_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"(%d,%d)", AsPoint().x, AsPoint().y);
			CreateString(String(buf), ppValue);
			break;
		}
		break;

	case Type::PointF:
		switch (type)
		{
		case Type::String:
			_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"(%g,%g)", AsPointF().x, AsPointF().y);
			CreateString(String(buf), ppValue);
			break;
		}
		break;

	case Type::Rect:
		switch (type)
		{
		case Type::String:
			_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"(%d,%d,%d,%d)",
				AsRect().left, AsRect().top, AsRect().right, AsRect().bottom);
			CreateString(String(buf), ppValue);
			break;
		}
		break;

	case Type::RectF:
		switch (type)
		{
		case Type::String:
			_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"(%g,%g,%g,%g)",
				AsRectF().left, AsRectF().top, AsRectF().right, AsRectF().bottom);
			CreateString(String(buf), ppValue);
			break;
		}
		break;

	case Type::String:
		switch (type)
		{
		case Type::Bool:
			if (AsString().empty() || AsString() == L"false" || AsString() == L"no" || AsString() == L"0")
			{
				CreateBool(false, ppValue);
			}
			else if (AsString() == L"true" || AsString() == L"yes" || AsString() == L"1")
			{
				CreateBool(true, ppValue);
			}
			break;

		case Type::Double:
			{
				const wchar_t *start = AsString().c_str();
				wchar_t *end = nullptr;
				double val = wcstod(start, &end);

				if (end > start && !*end)
				{
					CreateDouble(val, ppValue);
				}
			} break;

		case Type::Float:
			{
				const wchar_t *start = AsString().c_str();
				wchar_t *end = nullptr;
				double val = wcstod(start, &end);

				if (end > start && !*end)
				{
					CreateFloat((float)val, ppValue);
				}
			} break;

		case Type::Int:
			{
				const wchar_t *start = AsString().c_str();
				wchar_t *end = nullptr;
				long val = wcstol(start, &end, 10);

				if (end > start && !*end)
				{
					CreateInt((int)val, ppValue);
				}
			} break;

		case Type::Guid:
			{
				GUID guid;
				if (StringToGuid(AsString(), guid))
				{
					CreateGuid(guid, ppValue);
				}
			} break;
		}
		break;

	case Type::Object:
		switch (type)
		{
		case Type::Bool:
			CreateBool(AsObject() != nullptr, ppValue);
			break;
		}
		break;

	case Type::Guid:
		switch (type)
		{
		case Type::String:
			CreateString(StringFromGuid(AsGuid()), ppValue);
			break;
		}
		break;

	case Type::Data:
		switch (type)
		{
		case Type::SavedData:
			{
				ff::ComPtr<ff::ISavedData> savedData;
				if (ff::CreateLoadedDataFromMemory(AsData(), false, &savedData))
				{
					CreateSavedData(savedData, ppValue);
				}
			}
			break;
		}
		break;

	case Type::SavedData:
		switch (type)
		{
		case Type::Data:
			{
				ff::ComPtr<ff::ISavedData> savedData;
				if (AsSavedData()->Clone(&savedData))
				{
					ff::ComPtr<ff::IData> data = savedData->Load();
					if (data)
					{
						CreateData(data, ppValue);
					}
				}
			}
			break;
		}
		break;

	case Type::Dict:
		switch (type)
		{
		case Type::Data:
		case Type::SavedData:
		case Type::SavedDict:
			{
				ff::ComPtr<ff::IData> data;
				ff::ComPtr<ff::ISavedData> savedData;

				if (ff::SaveDict(AsDict(), true, false, &data))
				{
					if (type == Type::Data)
					{
						CreateData(data, ppValue);
					}
					else if (ff::CreateLoadedDataFromMemory(data, true, &savedData))
					{
						if (type == Type::SavedData)
						{
							CreateSavedData(savedData, ppValue);
						}
						else
						{
							CreateSavedDict(savedData, ppValue);
						}
					}
				}
			}
			break;
		}
		break;

	case Type::SavedDict:
		switch (type)
		{
		case Type::Data:
			{
				ff::ComPtr<ff::ISavedData> savedData;
				if (AsSavedData()->Clone(&savedData))
				{
					ff::ComPtr<ff::IData> data = savedData->Load();
					if (data)
					{
						CreateData(data, ppValue);
					}
				}
			}
			break;

		case Type::SavedData:
			CreateSavedData(AsSavedData(), ppValue);
			break;

		case Type::Dict:
			{
				ff::ComPtr<ff::ISavedData> savedData;
				if (AsSavedData()->Clone(&savedData))
				{
					ff::ComPtr<ff::IData> data = savedData->Load();
					ff::ComPtr<ff::IDataReader> dataReader;
					Dict dict;

					if (data && ff::CreateDataReader(data, 0, &dataReader) && ff::LoadDict(dataReader, dict))
					{
						CreateDict(std::move(dict), ppValue);
					}
				}
			}
			break;
		}
		break;

	case Type::Resource:
		AsResource()->GetValue()->Convert(type, ppValue);
		break;

	case Type::IntVector:
		switch (type)
		{
		case Type::Point:
			if (AsIntVector().Size() == 2)
			{
				PointInt point(
					AsIntVector().GetAt(0),
					AsIntVector().GetAt(1));
				CreatePoint(point, ppValue);
			}
			break;

		case Type::Rect:
			if (AsIntVector().Size() == 4)
			{
				RectInt rect(
					AsIntVector().GetAt(0),
					AsIntVector().GetAt(1),
					AsIntVector().GetAt(2),
					AsIntVector().GetAt(3));
				CreateRect(rect, ppValue);
			}
			break;
		}
		break;

	case Type::FloatVector:
		switch (type)
		{
		case Type::PointF:
			if (AsFloatVector().Size() == 2)
			{
				PointFloat point(
					AsFloatVector().GetAt(0),
					AsFloatVector().GetAt(1));
				CreatePointF(point, ppValue);
			}
			break;

		case Type::RectF:
			if (AsFloatVector().Size() == 4)
			{
				RectFloat rect(
					AsFloatVector().GetAt(0),
					AsFloatVector().GetAt(1),
					AsFloatVector().GetAt(2),
					AsFloatVector().GetAt(3));
				CreateRectF(rect, ppValue);
			}
			break;
		}
		break;

	case Type::ValueVector:
		switch (type)
		{
		case Type::Point:
			if (AsValueVector().Size() == 2)
			{
				ValuePtr newValues[2];
				const Vector<ValuePtr> &values = AsValueVector();
				if (values[0]->Convert(Type::Int, &newValues[0]) &&
					values[1]->Convert(Type::Int, &newValues[1]))
				{
					CreatePoint(PointInt(newValues[0]->AsInt(), newValues[1]->AsInt()), ppValue);
				}
			}
			break;

		case Type::PointF:
			if (AsValueVector().Size() == 2)
			{
				ValuePtr newValues[2];
				const Vector<ValuePtr> &values = AsValueVector();
				if (values[0]->Convert(Type::Float, &newValues[0]) &&
					values[1]->Convert(Type::Float, &newValues[1]))
				{
					CreatePointF(PointFloat(newValues[0]->AsFloat(), newValues[1]->AsFloat()), ppValue);
				}
			}
			break;

		case Type::Rect:
			if (AsValueVector().Size() == 4)
			{
				ValuePtr newValues[4];
				const Vector<ValuePtr> &values = AsValueVector();
				if (values[0]->Convert(Type::Int, &newValues[0]) &&
					values[1]->Convert(Type::Int, &newValues[1]) &&
					values[2]->Convert(Type::Int, &newValues[2]) &&
					values[3]->Convert(Type::Int, &newValues[3]))
				{
					CreateRect(RectInt(
						newValues[0]->AsInt(),
						newValues[1]->AsInt(),
						newValues[2]->AsInt(),
						newValues[3]->AsInt()), ppValue);
				}
			}
			break;

		case Type::RectF:
			if (AsValueVector().Size() == 4)
			{
				ValuePtr newValues[4];
				const Vector<ValuePtr> &values = AsValueVector();
				if (values[0]->Convert(Type::Float, &newValues[0]) &&
					values[1]->Convert(Type::Float, &newValues[1]) &&
					values[2]->Convert(Type::Float, &newValues[2]) &&
					values[3]->Convert(Type::Float, &newValues[3]))
				{
					CreateRectF(RectFloat(
						newValues[0]->AsFloat(),
						newValues[1]->AsFloat(),
						newValues[2]->AsFloat(),
						newValues[3]->AsFloat()), ppValue);
				}
			}
			break;

		case Type::StringVector:
			{
				bool valid = true;
				Vector<String> newValues;
				const Vector<ValuePtr> &values = AsValueVector();
				for (ValuePtr oldValue : values)
				{
					ValuePtr newValue;
					valid = oldValue->Convert(Type::String, &newValue);
					if (valid)
					{
						newValues.Push(newValue->AsString());
					}
					else
					{
						break;
					}
				}

				if (valid)
				{
					CreateStringVector(std::move(newValues), ppValue);
				}
			}
			break;

		case Type::IntVector:
			{
				bool valid = true;
				Vector<int> newValues;
				const Vector<ValuePtr> &values = AsValueVector();
				for (ValuePtr oldValue : values)
				{
					ValuePtr newValue;
					valid = oldValue->Convert(Type::Int, &newValue);
					if (valid)
					{
						newValues.Push(newValue->AsInt());
					}
					else
					{
						break;
					}
				}

				if (valid)
				{
					CreateIntVector(std::move(newValues), ppValue);
				}
			}
			break;

		case Type::DoubleVector:
			{
				bool valid = true;
				Vector<double> newValues;
				const Vector<ValuePtr> &values = AsValueVector();
				for (ValuePtr oldValue : values)
				{
					ValuePtr newValue;
					valid = oldValue->Convert(Type::Double, &newValue);
					if (valid)
					{
						newValues.Push(newValue->AsDouble());
					}
					else
					{
						break;
					}
				}

				if (valid)
				{
					CreateDoubleVector(std::move(newValues), ppValue);
				}
			}
			break;

		case Type::FloatVector:
			{
				bool valid = true;
				Vector<float> newValues;
				const Vector<ValuePtr> &values = AsValueVector();
				for (ValuePtr oldValue : values)
				{
					ValuePtr newValue;
					valid = oldValue->Convert(Type::Float, &newValue);
					if (valid)
					{
						newValues.Push(newValue->AsFloat());
					}
					else
					{
						break;
					}
				}

				if (valid)
				{
					CreateFloatVector(std::move(newValues), ppValue);
				}
			}
			break;
		}
		break;
	}

	if (*ppValue)
	{
		return true;
	}

	return false;
}
Пример #15
0
void CTrack_Player2::Init()
{


	mpScrollPane = ge::IScrollPane::Create();
	mpScrollPane->Init(ge::IControl::giNoID, giTimerID_Player2_ScrollPane);
	mpPane = dynamic_cast<ge::IPane*>(mpScrollPane);
	mpPane->SetSize(gTrack_Scroll_Editor);
	mpPane->SetBackgroundColour(ge::SRGB(239,239,239));
	

	msLineColor[giColor_1] = ge::SRGB(83,124,214);
	msLineColor[giColor_2] = ge::SRGB(125,153,217);
	msLineColor[giColor_4] = ge::SRGB(125,153,217);
	msLineColor[giColor_8] = ge::SRGB(188,214,254);
	msLineColor[giColor_16] = ge::SRGB(188,214,254);
	msLineColor[giColor_32] = ge::SRGB(188,214,254);
	
	Allocate_Grid_Lines();
	
	Update_Zoom();
	Draw_Grid();
	
	tint32	iTrack_PosY		= 0;
	tint32	iTrack_SizeY	= gTrack_Info_Small.iCY - 1;

	tint i;
	//--------------------------------------------
	for( i=0; i<giNumber_Of_Tracks; i++) {

		// Create Tracks
		mppTrack[i] = new CTrack(this, GetGUI());
		mppTrack[i]->SetInfo(i, iTrack_SizeY, this );
		mppTrack[i]->Init();
		mpPane->AddControl(mppTrack[i]->GetPane(), ge::SPos(0, iTrack_PosY));
		mppTrack[i]->GetPane()->SetVisible(false);
		
		iTrack_PosY			+= iTrack_SizeY + 1;
	}
	
//	Snap_To_Grid();
	
	// Lasse, dynamic_cast is slow on Windows!
	
//	tfloat64 fPixelPrSample		= 	mpKSPlugIn->GetSamplesPrPixel();
	tfloat64 fSamplesPrPixel	=	mpKSPlugIn->GetSamplesPrPixel();
	
	
	//muiPane_Duration_In_Samples = gTrack_Scroll_Editor.iCX * fSamplesPrPixel;
	
	mpEmpty_Rect				= CreateRect(ge::IControl::giNoID, 
												ge::SRect(ge::SPos(0, iTrack_PosY), 
												ge::SSize(gTrack_Scroll_Editor.iCX, 
												gTrack_Scroll_Editor.iCY-iTrack_PosY)), 
												ge::SRGB(204, 204, 204));

	mpBack_Track_Shaddow_Bmp	= CreateBitmap(ge::IControl::giNoID, IDB_Back_Track_Shaddow, ge::SPos(0, iTrack_PosY));
	mpBack_Track_Shaddow_Bmp->SetSize(ge::SSize(gTrack_Scroll_Editor.iCX,8));

	// Mouse-trap for activation of track 
	mpMouseTrap = ge::IMouseTrap::Create();
	// Only link into chain, but don't remove message (the third param = false)
	mpMouseTrap->EnableOneTrap(ge::MouseMove, true, false);
	mpPane->AddControl(mpMouseTrap, ge::SPos(0, 0));
	mpMouseTrap->PlaceOnTopOf(GetPane());
	mpMouseTrap->AddListener(this);
	
	// Play Head
	mpPlay_Line = CreateLine(ge::IControl::giNoID, ge::SPos(0, 0), ge::SPos(0, 0), ge::SRGB(0, 0, 0));
	miLast_Play_Line_Pos_X = -1;
	
}
Пример #16
0
int main()
{
	eosFrameBuffer fb;
	if(eosFrameBuffer_Open(&fb)) {
		return 0;
	}

	CFrameBuffer bf = CreateFrameBuffer(1366, 768);

	struct timeval start, end;
 
    	long mtime, seconds, useconds;    
 
    	gettimeofday(&start, NULL);
 
	
	// Draw background rectangle.
	CRect bg_rect = CreateRect(100, 100, 200, 200);
	CColor bg_color = CreateColor(240, 0, 0);
	DrawRectangle(&bf, &bg_rect, &bg_color);

	// Draw rectangle contour.
	//CColor contour_color = CreateColor(0, 0, 0);
	//DrawRectangleContour(&bf, &bg_rect, &contour_color);

	// Draw diagonal line.
	//CPoint p0 = CPoint_Create(0, 499);
	//CPoint p1 = CPoint_Create(499, 0);
	//CColor p_color = CreateColor(255, 255, 0);
	//DrawLine(&bf, &p0, &p1, &p_color);

	// Draw char.
	CFont font = CreateFont("resources/test.myfont");
	//CPoint char_pos = CPoint_Create(300, 100);
	//CColor char_color = CreateColor(255, 255, 255);
	//DrawChar(&bf, &font, 'P', &char_pos, &char_color);

	// Draw text.
	CPoint str_pos = CPoint_Create(100, 200);
	CColor str_color = CreateColor(180, 180, 180);
	DrawString(&bf, &font, "Monster Truck", &str_pos, &str_color);

	// Draw text.
	CPoint str2_pos = CPoint_Create(100, 220);
	CColor str2_color = CreateColor(10, 180, 180);
	DrawString(&bf, &font, "Monster Truck", &str2_pos, &str2_color);

	// Get text width.
	//CString mst_str = CString_Create("Monster Truck");
	//printf("Monster Truck width : %d\n", GetStringXSize(&font, &mst_str));

	// Draw image resize.
	CImage image = CreateImageFromBitmap("resources/umbrella2.bmp");
	CPoint img_pos = CPoint_Create(300, 51);
	CSize img_size = CreateSize(500, 500);
	DrawImageResize(&bf, &image, &img_pos, &img_size);	

	eosFrameBuffer_Draw(&fb);
	eosFrameBuffer_DrawBackBuffer(&fb, &bf);
    	
	gettimeofday(&end, NULL);
    	seconds  = end.tv_sec  - start.tv_sec;
    	useconds = end.tv_usec - start.tv_usec;
    	mtime = seconds + useconds;
   	printf("Elapsed time: %d ms\n", mtime / 1000);

	gettimeofday(&start, NULL);
	
	DrawRectangle(&bf, &bg_rect, &bg_color);
	DrawString(&bf, &font, "Monster Truck", &str_pos, &str_color);
	DrawString(&bf, &font, "Monster Truck", &str2_pos, &str2_color);
	DrawImageResize(&bf, &image, &img_pos, &img_size);
	eosFrameBuffer_DrawBackBuffer(&fb, &bf);

	gettimeofday(&end, NULL);
	seconds  = end.tv_sec  - start.tv_sec;
        useconds = end.tv_usec - start.tv_usec;
        mtime = seconds + useconds;
        printf("Elapsed time: %d ms\n", mtime / 1000);

	eosFrameBuffer_Close(&fb);
	//printf("FIX:\n");
	//printf("FB len         : %d\n", m_FixInfo.smem_len);
	//printf("FB type        : %d\n", m_FixInfo.type);
	//printf("FB type aux    : %d\n", m_FixInfo.type_aux);
	//printf("FB visual      : %d\n", m_FixInfo.visual);
	//printf("FB xpanstep    : %d\n", m_FixInfo.xpanstep);
	//printf("FB ypanstep    : %d\n", m_FixInfo.ypanstep);
	//printf("FB ywrapstep   : %d\n", m_FixInfo.ywrapstep);
	//printf("FB line_length : %d\n", m_FixInfo.line_length);

	//printf("VAR:\n");
	//printf("Res            : %d %d\n", m_VarInfo.xres, m_VarInfo.yres);
	//printf("Res virtual    : %d %d\n", m_VarInfo.xres_virtual, m_VarInfo.yres_virtual);
	//printf("Offset         : %d %d\n", m_VarInfo.xoffset, m_VarInfo.yoffset);
	//printf("bits_per_pixel : %d\n", m_VarInfo.bits_per_pixel);
	//printf("grayscale      : %d\n", m_VarInfo.grayscale);
	return 0;
}
Пример #17
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);
	m_ScoreView.Create(IDD_GAME_SCORE,this);

	//创建扑克
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		m_UserCardControl[i].SetDirection(true);
		m_UserCardControl[i].SetDisplayFlag(true);
		m_UserCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,20+i);
		m_ForeTurn[i].SetDirection(true);
		m_ForeTurn[i].SetDisplayFlag(false);
		m_ForeTurn[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,23+i);
	}
	for (WORD i=0;i<2;i++) 
	{
		m_LeaveCardControl[i].SetDirection(false);
		m_LeaveCardControl[i].SetDisplayFlag(true);
		m_LeaveCardControl[i].SetCardSpace(0,18,0);
		m_LeaveCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
	}

	m_HandCardControl.SetSinkWindow(AfxGetMainWnd());
	m_HandCardControl.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,40);
	for(BYTE i=0;i<GAME_PLAYER;i++)m_ZhanCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,42+i);
	

	//创建按钮
	m_btStart.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_START);
	m_btOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_OUT_CARD);
	m_btPassCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_PASS_CARD);
	m_btKouPai.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_COUPAI);
	m_btXianPai.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_XIANPAI);
	m_btQiangCi.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_QIANGCI);
	m_btGiveUpCiangCi.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_GIVE_UP_SCORE);
	m_btAutoOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AUTO_OUTCARD);
	m_btForeTurn.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_FORETURN_CARD);


	//设置按钮
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btOutCard.SetButtonImage(IDB_OUT_CARD,hInstance,false);
	m_btPassCard.SetButtonImage(IDB_PASS,hInstance,false);
	m_btKouPai.SetButtonImage(IDB_VIEW_BUTTON,hInstance,false);
	m_btXianPai.SetButtonImage(IDB_VIEW_BUTTON,hInstance,false);
	m_btQiangCi.SetButtonImage(IDB_VIEW_BUTTON,hInstance,false);
	m_btGiveUpCiangCi.SetButtonImage(IDB_VIEW_BUTTON,hInstance,false);
	m_btAutoOutCard.SetButtonImage(IDB_AUTO_OUT_CARD,hInstance,false);
	m_btForeTurn.SetButtonImage(IDB_VIEW_BUTTON,hInstance,false);
	m_btKouPai.SetButtonImage(IDB_KOU_PAI,hInstance,false);
	m_btXianPai.SetButtonImage(IDB_XIAN_PAI,hInstance,false);
	m_btForeTurn.SetButtonImage(IDB_FORE_TURN,hInstance,false);
	m_btQiangCi.SetButtonImage(IDB_QIANG_CI,hInstance,false);
	m_btGiveUpCiangCi.SetButtonImage(IDB_GIVE_UP,hInstance,false);
	
	//设置占牌
	for(BYTE j=0;j<GAME_PLAYER;j++)
	{
		m_ZhanCardControl[j].SetCardSpace(14,0,0);
		m_ZhanCardControl[j].SetDisplayFlag(true);
	}
	//读取配置
	m_bDeasilOrder=AfxGetApp()->GetProfileInt(TEXT("GameOption"),TEXT("DeasilOrder"),FALSE)?true:false;

		

	return 0;
}
Пример #18
0
//==============================================================
// 区画を分ける
//==============================================================
void CDunHard::SplitRect(int nParentRectIndex, int nFlagHV)
{
	DUNRECT *pParent, *pChild;
	RECT *pRect;
	int nChildIndex1 = 0, nChildIndex2 = 0;

	// わける区画情報を取得
	pParent = &m_Rect[nParentRectIndex];
	pRect   = &pParent->Rect;

	//---------
	// 分割する
	//---------
	if((nFlagHV & 1) == 0) {
		// 横に分割する
		nFlagHV |= 1;

		// 区分を分割できるか?チェック
		if(RECT_W(*pRect) >= (MIN_ROOM_SIZE + 3) * 2 + 1) {
			int a, b, ab, p;
			// 左端のA点を求める
			a = MIN_ROOM_SIZE + 3;

			// 右端のB点を求める
			b = RECT_W(*pRect) - MIN_ROOM_SIZE - 4;

			// ABの距離を求める
			ab = b - a;

			// AB間のどこかに決定する
			p = a + GetRand(ab + 1);

			// 新しく右の区画を作成する
			pChild = CreateRect(pRect->left + p,
								pRect->top,
								pRect->right,
								pRect->bottom);

			// 元の区画の右を p 地点に移動させて、左側の区画とする
			pParent->Rect.right = pChild->Rect.left;

			// 子の部屋をさらに分割する
			nChildIndex1 = DunrectToIndex(pChild);
			SplitRect(nChildIndex1, 0);
		}
	}

	if((nFlagHV & 2) == 0) {
		// 縦に分割する
		nFlagHV |= 2;

		// 区分を分割できるか?チェック
		if( RECT_H(*pRect) >= (MIN_ROOM_SIZE+3)*2+1 ) {
			int a, b, ab, p;
			a = MIN_ROOM_SIZE + 3;
			b = RECT_H(*pRect) - MIN_ROOM_SIZE - 4;
			ab = b - a;

			p = a + GetRand(ab + 1);

			// 新しく下の区画を作成する
			pChild = CreateRect(pRect->left,
								pRect->top + p,
								pRect->right,
								pRect->bottom);

			// 元の区画の下を p 地点に移動させて、上側の区画とする
			pParent->Rect.bottom = pChild->Rect.top;

			// 子の部屋をさらに分割する
			nChildIndex2 = DunrectToIndex(pChild);
			SplitRect(nChildIndex2, 0);
		}
	}

	// 部屋を作る
	CreateRoom(nParentRectIndex);

	// 子供とつなげる
	if(nChildIndex1) {
		CreateRoad( nParentRectIndex, nChildIndex1 );
	}
	if(nChildIndex2) {
		CreateRoad( nParentRectIndex, nChildIndex2 );
	}
}
Пример #19
0
//==============================================================
// ダンジョンを作る
//==============================================================
void CDunHard::Make( CChara *pPlayer)
{
	// 区画の数をリセット
	m_uRectCnt = 0;
	m_pPlayer = pPlayer;

	//-----------------------------------
	// 初期化:一旦すべて壁にする
	//-----------------------------------
	int x, y;
	for(y = 0; y < m_uHeight; y ++) {
		for(x = 0; x < m_uWidth; x ++) {
			GetTile(x, y)->bIsWall = TRUE;
		}
	}
	
	//-----------------------------------
	// 区画を作る
	//-----------------------------------
	// まずは全体を1つの区画にする
	CreateRect(0, 0, m_uWidth - 1, m_uHeight - 1);
	// 再帰でどんどん細かくする
	SplitRect(0, 0);
	
	//-----------------------------------
	// 階段の設置
	//-----------------------------------
	// ランダムな部屋の適当な位置に下階段を配置
	int nStepDownIndex;
	nStepDownIndex = GetRand(m_uRectCnt);
	while (true) {
		RandRoomPoint(nStepDownIndex, &x, &y);
		if (GetTile(x, y)->bIsWall == false) {
			GetTile(x, y)->bIsStepDown = TRUE;
			m_uDownStepX = x;
			m_uDownStepY = y;
			break;
		}
	}

	// 下階段とは違う部屋でランダムな部屋の適当な位置に上階段を配置
	int nStepUpIndex;
	nStepUpIndex = GetRand(m_uRectCnt);
	while(nStepUpIndex == nStepDownIndex) {
		nStepUpIndex = GetRand(m_uRectCnt);
	}
	while (true) {
		RandRoomPoint(nStepUpIndex, &x, &y);
		if (GetTile(x, y)->bIsWall == false) {
			GetTile(x, y)->bIsStepUp = TRUE;
			m_uUpStepX = x;
			m_uUpStepY = y;
			break;
		}
	}

	//-----------------------------------
	// 迷路以外はもう一回区画を塗り直しておく
	//-----------------------------------
	ReFillRoom();

	//-----------------------------------
	// 各部屋にアイテムを配置する
	//-----------------------------------
	CreateItem(60);

	//-----------------------------------
	// 各部屋にモンスターを配置する
	//-----------------------------------
	CreateMob(60);
}
Пример #20
0
//Draws a string to the screen
//param:font->The index of the font
//param:message->The message to display
//param:drawMode->The draw mode to apply to the string:
//Blended: Blends the text with whatever is behind it using transparency. This mode is required for wrapping. Slowest mode
//Shaded: Gives the text a background that utilizes background color
//Solid: Fastest rendering speed. No box around, just quick straight text
//param:foregroundColor->The color of the text
//param:backgroundColor->The color of the background box. Used with Shaded drawmode
//param:wrapLength->Wraps the text past this width (in pixels). Requires empty space, will not separate words. Only
//works in Blended mode
//param:position->Point to draw the text at
//param:angle->Angle to rotate the text
//param:origin->The origin point to rotate about
//param:scale->Amount to size the text. Will distort quickly
//param:flip-> Flip texture horizontally, vertically, both or none
//param:layerDepth->The depth to draw on
//Returns 0 for success, -1 for errors
int SpriteBatch::DrawString(Uint32 font, std::string message, StringDrawMode drawMode, SDL_Color foregroundColor,
		SDL_Color backgroundColor, int wrapLength, const SDL_Point* position, float angle, const SDL_Point* origin, 
		float scale, SDL_RendererFlip flip, float layerDepth)
{
	//Check if spritebatch.begin has been called
	if(!begun)
	{
		std::cout<<"Begin must be called before attempting to draw"<<std::endl;
		return -1;
	}
	//make sure we have a valid layer depth
	if(layerDepth < 0 || layerDepth > 1)
	{
		std::cout <<"Layer Depth must be between 0 and 1"<<std::endl;
		return -1;
	}

	//Make sure we have a valid renderer
	if(!renderer)
	{	
		std::cout<<"Renderer is null. Did you Initialize Spritebatch?"<<std::endl;
		return -1;	
	}
	
	try{
		TTF_Font* fontToDraw;
		//Get the texture (at performs bounds checking, which will validate the index for us, regardless of sort mode)		
		fontToDraw = fontManager->GetFont(font);

		//If sort mode is immediate, draw right away
		if(sortMode == SpriteBatchSortMode::Immediate)
		{
			SDL_Surface* textSurface = nullptr;
			//Create surface based on draw mode
			if(drawMode == StringDrawMode::Blended)
			{
				if(wrapLength <= 0)					
					textSurface = TTF_RenderText_Blended(fontToDraw, message.c_str(), foregroundColor);
				else
					textSurface = TTF_RenderText_Blended_Wrapped(fontToDraw, message.c_str(), foregroundColor, wrapLength);
			}
			else if(drawMode == StringDrawMode::Shaded)
			{
				textSurface = TTF_RenderText_Shaded(fontToDraw, message.c_str(), foregroundColor, backgroundColor);
			}
			else if(drawMode == StringDrawMode::Solid)
			{
				textSurface = TTF_RenderText_Solid(fontToDraw, message.c_str(), foregroundColor);
			}

			//Generate the texture from the surface
			SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, textSurface);

			//Free the surface and get rid of the pointer to it
			SDL_FreeSurface(textSurface);
			textSurface = nullptr;

			int w = 0;
			int h = 0;
			SDL_QueryTexture(tex, NULL, NULL, &w, &h);
			//Check for null position
			SDL_Point point;

			if(position == nullptr)
				point = CreatePoint(0, 0);
			else
				point = CreatePoint(position->x, position->y);

			//Create a rectangle that is the size of the string
			SDL_Rect sourceRect = CreateRect(0, 0, w, h);
			SDL_Rect destRect = CreateRect(point.x, point.y, (int)(w * scale), (int)(h * scale));
			
			//if no flip or angle, draw with Render Copy
			if(angle == 0 && flip == 0)
				SDL_RenderCopy(renderer, tex, &sourceRect, &destRect);
			else
				///Draw the image with any flip/angle
				SDL_RenderCopyEx(renderer, tex, &sourceRect, &destRect, angle, origin, flip);
		}
		else
		{
			//Take the layer depth, multiply by 10 and floor it. A layer depth of 0.09 would then go into
			//index 0 map, while a 0.99 will go into index 9
			int sortIndex = (int)std::floor(layerDepth * 10);
			SDL_Rect* destRect = &CreateRect(position->x, position->y, 0, 0);
			SDL_Rect sourceRect = CreateRect(0, 0, 0, 0);

			//Package the information
			PackedSprite package = PackedSprite(PackedSprite::PackType::String, font, message, drawMode,
				destRect, origin, backgroundColor, foregroundColor, flip, angle, scale, wrapLength);

			//if sort index is greater than 9, put it in array slot 9. We do this because 
			//1.0 * 10 = floor(10) = 10. Our array only goes to the 9th index
			if(sortIndex >= 9)
			{
				sortedImages[9].insert(std::pair<float, PackedSprite>(layerDepth, package));
			}
			else
			{
				//otherwise, just put it in the appropriate slot
				sortedImages[sortIndex].insert(std::pair<float, PackedSprite>(layerDepth, package));
			}
		}
	}
	//If invalid index, we throw the error
	catch (std::out_of_range problem)
	{
		std::cout<<"SPRITEBATCH_DRAWSTRING ERROR: Font not a valid index"<<std::endl;
		return -1;
	}
	
	return 0;
}
Пример #21
0
//Draw the texture from the PackedSprite structure
//param:packedSprite->The packed sprite to draw from
void SpriteBatch::DrawTexture(PackedSprite packedSprite)
{
	if(packedSprite.Type == PackedSprite::PackType::Sprite)
	{
		//Get the texture (we dont do bounds checking because when we added the texture to the list
		//we checked the bounds) We also don't check for begin, because that would've been checked in the 
		//users call to DrawTexture. This is a private function. Only spritebatch calls this one.
		SDL_Texture* tex = textureList[packedSprite.Texture];

		//Apply any blends
		ApplyBlendToTexture(tex, packedSprite.Tint);

		//if no flip or angle, draw with Render Copy
		if(packedSprite.Rotation == 0 && packedSprite.FlipEffects == 0)
			SDL_RenderCopy(renderer, tex, packedSprite.SourceRect, packedSprite.DestRect);
		else
			///Draw the image with any flip/angle
			SDL_RenderCopyEx(renderer, tex, packedSprite.SourceRect, packedSprite.DestRect, 
				packedSprite.Rotation, packedSprite.Origin, packedSprite.FlipEffects);
	}
	else
	{
		SDL_Surface* textSurface;

		//Generate surface based on draw mode
		if(packedSprite.DrawMode == StringDrawMode::Blended)
		{
			if(packedSprite.WrapLength <= 0)					
				textSurface = TTF_RenderText_Blended(fontManager->GetFont(packedSprite.Texture), packedSprite.Message.c_str(), 
				packedSprite.Tint);
			else
				textSurface = TTF_RenderText_Blended_Wrapped(fontManager->GetFont(packedSprite.Texture), 
				packedSprite.Message.c_str(), packedSprite.Tint, packedSprite.WrapLength);
		}
		else if(packedSprite.DrawMode == StringDrawMode::Shaded)
		{
			textSurface = TTF_RenderText_Shaded(fontManager->GetFont(packedSprite.Texture), packedSprite.Message.c_str(), 
				packedSprite.Tint, packedSprite.BackgroundColor);
		}
		else if(packedSprite.DrawMode == StringDrawMode::Solid)
		{
			textSurface = TTF_RenderText_Solid(fontManager->GetFont(packedSprite.Texture), packedSprite.Message.c_str(), 
				packedSprite.Tint);
		}

		//Generate the texture from the surface
		SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, textSurface);

		//Free the surface and get rid of the pointer to it
		SDL_FreeSurface(textSurface);
		textSurface = nullptr;

		int w = 0;
		int h = 0;
		SDL_QueryTexture(tex, NULL, NULL, &w, &h);

		//Create a rectangle that is the size of the string
		SDL_Rect sourceRect = CreateRect(0, 0, w, h);
		SDL_Rect destRect = CreateRect(packedSprite.DestRect->x, packedSprite.DestRect->y,
			(Uint32)(w * packedSprite.StringScale), (Uint32)(h * packedSprite.StringScale));
		
		//if no flip or angle, draw with Render Copy
		if(packedSprite.Rotation == 0 && packedSprite.FlipEffects == SDL_RendererFlip::SDL_FLIP_NONE)
			SDL_RenderCopy(renderer, tex, &sourceRect, &destRect);
		else
			///Draw the image with any flip/angle
			SDL_RenderCopyEx(renderer, tex, &sourceRect, &destRect, 
				packedSprite.Rotation, packedSprite.Origin, packedSprite.FlipEffects);

	}
}
Пример #22
0
Primitive::Ptr Renderer::CreatePane( const sf::Vector2f& position, const sf::Vector2f& size, float border_width,
                                             const sf::Color& color, const sf::Color& border_color, int border_color_shift ) {
  if( border_width <= 0.f ) {
		return CreateRect( position, position + size, color );
  }

  Primitive::Ptr primitive( new Primitive );

	sf::Color dark_border( border_color );
	sf::Color light_border( border_color );

	Context::Get().GetEngine().ShiftBorderColors( light_border, dark_border, border_color_shift );

	float left = position.x;
	float top = position.y;
	float right = left + size.x;
	float bottom = top + size.y;

	Primitive::Ptr rect(
		CreateQuad(
			sf::Vector2f( left + border_width, top + border_width ),
			sf::Vector2f( left + border_width, bottom - border_width ),
			sf::Vector2f( right - border_width, bottom - border_width ),
			sf::Vector2f( right - border_width, top + border_width ),
			color
		)
	);

	Primitive::Ptr line_top(
		CreateLine(
			sf::Vector2f( left, top + border_width / 2.f ),
			sf::Vector2f( right - border_width, top + border_width / 2.f ),
			light_border,
			border_width
		)
	);

	Primitive::Ptr line_right(
		CreateLine(
			sf::Vector2f( right - border_width / 2.f, top ),
			sf::Vector2f( right - border_width / 2.f, bottom - border_width ),
			dark_border,
			border_width
		)
	);

	Primitive::Ptr line_bottom(
		CreateLine(
			sf::Vector2f( right, bottom - border_width / 2.f ),
			sf::Vector2f( left + border_width, bottom - border_width / 2.f ),
			dark_border,
			border_width
		)
	);

	Primitive::Ptr line_left(
		CreateLine(
			sf::Vector2f( left + border_width / 2.f, bottom ),
			sf::Vector2f( left + border_width / 2.f, top + border_width ),
			light_border,
			border_width
		)
	);

	primitive->Add( *rect.get() );
	primitive->Add( *line_top.get() );
	primitive->Add( *line_right.get() );
	primitive->Add( *line_bottom.get() );
	primitive->Add( *line_left.get() );

	std::vector<Primitive::Ptr>::iterator iter( std::find( m_primitives.begin(), m_primitives.end(), rect ) );

	assert( iter != m_primitives.end() );

	iter = m_primitives.erase( iter ); // rect
	iter = m_primitives.erase( iter ); // line_top
	iter = m_primitives.erase( iter ); // line_right
	iter = m_primitives.erase( iter ); // line_bottom
	m_primitives.erase( iter ); // line_left

	AddPrimitive( primitive );

	return primitive;
}
Пример #23
0
Primitive::Ptr Renderer::CreateRect( const sf::FloatRect& rect, const sf::Color& color ) {
	return CreateRect( sf::Vector2f( rect.left, rect.top ), sf::Vector2f( rect.left + rect.width, rect.top + rect.height ), color );
}
Пример #24
0
	static Polygon CreateRect (float x, float y, float width, float height) { return CreateRect(Vertex(x, y), width, height); }
Пример #25
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);

	//创建扑克
	for (WORD i=0;i<3;i++)
	{
		//用户扑克
		m_UserCardControl[i].SetDirection(true);
		m_UserCardControl[i].SetDisplayFlag(true);	
		m_UserCardControl[i].SetCardSpace( 16, 0, 0 );

		m_UserCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,20+i);

		//用户扑克
		if (i!=1)
		{
			m_HandCardControl[i].SetCardSpace(0,18,0);
			m_HandCardControl[i].SetDirection(false);
			m_HandCardControl[i].SetDisplayFlag(false);
			m_HandCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
		}
		else
		{
			m_HandCardControl[i].SetDirection(true);
			m_HandCardControl[i].SetDisplayFlag(false);
			m_HandCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
		}
	}

	//设置扑克
	m_BackCardControl.SetCardSpace(85,0,0);
	m_BackCardControl.SetDisplayFlag(false);
	m_HandCardControl[1].SetSinkWindow(AfxGetMainWnd());
	m_BackCardControl.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,41);

	//创建按钮
	m_btStart.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_START);
	m_btOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_OUT_CARD);
	m_btPassCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_PASS_CARD);
	m_btOneScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_ONE_SCORE);
	m_btTwoScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_TWO_SCORE);
	m_btGiveUpScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_GIVE_UP_SCORE);
	m_btAutoOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AUTO_OUTCARD);
	m_btThreeScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_THREE_SCORE);
	m_btAutoPlayOn.Create(TEXT(""), WS_CHILD,CreateRect,this,IDC_AUTOPLAY_ON);
	m_btAutoPlayOff.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AUTOPLAY_OFF);
	m_btSortCard.Create(NULL,WS_CHILD|WS_DISABLED|WS_VISIBLE,CreateRect,this,IDC_SORT_CARD);
    

	//设置按钮
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btOutCard.SetButtonImage(IDB_OUT_CARD,hInstance,false);
	m_btPassCard.SetButtonImage(IDB_PASS,hInstance,false);
	m_btOneScore.SetButtonImage(IDB_ONE_SCORE,hInstance,false);
	m_btTwoScore.SetButtonImage(IDB_TWO_SCORE,hInstance,false);
	m_btGiveUpScore.SetButtonImage(IDB_GIVE_UP,hInstance,false);
	m_btAutoOutCard.SetButtonImage(IDB_AUTO_OUT_CARD,hInstance,false);
	m_btThreeScore.SetButtonImage(IDB_THREE_SCORE,hInstance,false);
	m_btAutoPlayOn.SetButtonImage  (IDB_AUTOPLAY_ON,hInstance,false);
	m_btAutoPlayOff.SetButtonImage (IDB_AUTOPLAY_OFF,hInstance,false);
	m_btSortCard.SetButtonImage(IDB_COUNT_SORT,hInstance,false);

    m_btAutoPlayOn.ShowWindow(SW_SHOW);
    m_btAutoPlayOff.ShowWindow(SW_HIDE);

#ifdef VIDEO_GAME

	//创建视频
	for (WORD i=0; i<GAME_PLAYER; i++)
	{
		//创建视频
		m_DlgVedioService[i].Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,200+i);
		m_DlgVedioService[i].InitVideoService(i==1,i==1);

		//设置视频
		m_VedioServiceManager.SetVideoServiceControl(i,&m_DlgVedioService[i]);
	}

	m_HandCardControl[ 0 ].ShowWindow( SW_HIDE );
	m_HandCardControl[ 2 ].ShowWindow( SW_HIDE );

#endif

	return 0;
}
Пример #26
0
//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//创建控件
	CRect CreateRect(0,0,0,0);

	//创建扑克
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//用户扑克
		m_UserCardControl[i].SetDirection(true);
		m_UserCardControl[i].SetDisplayFlag(true);	
		m_UserCardControl[i].SetCardSpace( 16, 20, 0 );

		m_UserCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,50+i);

		if ( i == 0 || i == ME_VIEW_CHAIR )
			m_UserCardControl[i].SetDirection(true);
		else
			m_UserCardControl[i].SetDirection(false);

		if ( i ==ME_VIEW_CHAIR || i == 0 )
			m_HandCardControl[i].SetDirection(true);
		else
			m_HandCardControl[i].SetDirection(false);

		//用户扑克
		if (i!=ME_VIEW_CHAIR)
		{
			m_HandCardControl[i].SetCardSpace(8,8,0);
			m_HandCardControl[i].SetDisplayFlag(false);
			m_HandCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
		}
		else
		{
			m_HandCardControl[i].SetDisplayFlag(false);
			m_HandCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
		}
	}

	//设置扑克
	//m_BackCardControl.SetCardSpace(14,0,0);
	//m_BackCardControl.SetDisplayFlag(false);
	m_HandCardControl[ME_VIEW_CHAIR].SetSinkWindow(AfxGetMainWnd());
	//m_BackCardControl.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,41);

	//创建按钮
	m_btStart.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_START);
	m_btOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_OUT_CARD);
	m_btPassCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_PASS_CARD);
	m_btOneScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_ONE_SCORE);
	m_btTwoScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_TWO_SCORE);
	m_btGiveUpScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_GIVE_UP_SCORE);
	m_btAutoOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AUTO_OUTCARD);
	m_btThreeScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_THREE_SCORE);
	m_btAutoPlayOn.Create(TEXT(""), WS_CHILD,CreateRect,this,IDC_AUTOPLAY_ON);
	m_btAutoPlayOff.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AUTOPLAY_OFF);
	m_btSortCard.Create(NULL,WS_CHILD|WS_DISABLED|WS_VISIBLE,CreateRect,this,IDC_SORT_CARD);

	////////////////////////////////////////添加创建按钮////////////////////////////////////
	m_btLiGun.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_LI_GUN);
	m_btJueGun.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_JUE_GUN);
	m_btAgree.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AGREE);
	m_btDisagree.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_DISAGREE);
	m_btNotLiGun.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_NOT_LI_GUN);
	m_btNotJueGun.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_NOT_JUE_GUN);
	////////////////////////////////////////////////////////////////////////////////////////
    

	//设置按钮
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btOutCard.SetButtonImage(IDB_OUT_CARD,hInstance,false);
	m_btPassCard.SetButtonImage(IDB_PASS,hInstance,false);
	m_btOneScore.SetButtonImage(IDB_ONE_SCORE,hInstance,false);
	m_btTwoScore.SetButtonImage(IDB_TWO_SCORE,hInstance,false);
	m_btGiveUpScore.SetButtonImage(IDB_GIVE_UP,hInstance,false);
	m_btAutoOutCard.SetButtonImage(IDB_AUTO_OUT_CARD,hInstance,false);
	m_btThreeScore.SetButtonImage(IDB_THREE_SCORE,hInstance,false);
	m_btAutoPlayOn.SetButtonImage(IDB_AUTOPLAY_ON,hInstance,false);
	m_btAutoPlayOff.SetButtonImage(IDB_AUTOPLAY_OFF,hInstance,false);
	m_btSortCard.SetButtonImage(IDB_COUNT_SORT,hInstance,false);
	//////////////////////////////////////////加载按钮图片//////////////////////////////////////
	m_btLiGun.SetButtonImage(IDB_LI_GUN,hInstance,false);
	m_btJueGun.SetButtonImage(IDB_JUE_GUN,hInstance,false);
	m_btAgree.SetButtonImage(IDB_AGREE,hInstance,false);
	m_btDisagree.SetButtonImage(IDB_DISAGREE,hInstance,false);
	m_btNotLiGun.SetButtonImage(IDB_NOT_LI_GUN,hInstance,false);
	m_btNotJueGun.SetButtonImage(IDB_NOT_JUE_GUN,hInstance,false);
	////////////////////////////////////////////////////////////////////////////////////////////

    m_btAutoPlayOn.ShowWindow(SW_SHOW);
    m_btAutoPlayOff.ShowWindow(SW_HIDE);

#ifdef VIDEO_GAME

	//创建视频
	for (WORD i=0; i<GAME_PLAYER; i++)
	{
		//创建视频
		m_DlgVedioService[i].Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,200+i);
		m_DlgVedioService[i].InitVideoService(i==ME_VIEW_CHAIR,i==ME_VIEW_CHAIR);

		//设置视频
		m_VedioServiceManager.SetVideoServiceControl(i,&m_DlgVedioService[i]);
	}

	for ( WORD wChairID = 0; wChairID < GAME_PLAYER; ++wChairID )
	{
		if ( wChairID != ME_VIEW_CHAIR )
			m_HandCardControl[ wChairID ].ShowWindow( SW_HIDE );
	}

#endif

	return 0;
}