Exemplo n.º 1
0
UIWidget::UIWidget(UIWidget* pParent) : GTGameObject(pParent),
	m_nState(UISpriteSet::StateEnabled),
	m_nEventType(UIWidget::EventType_All),
	m_sTooltip(GTString::EmptyString),
	m_Size(GTSize::Zero),
	m_pSkin(NULL),
	m_pSkinPiece(NULL),
	m_pFont(NULL),
	m_sText(GTString::EmptyString),
	m_pUILabelBMFont(NULL),
	m_AnchorPoint(GSprite::AnchorPoint_Center),
	m_WidgetRegion(0.0f, 0.0f, 0.0f, 0.0f)
{
	SetAnchorPoint(m_AnchorPoint);
}
Exemplo n.º 2
0
// When the object is initialized, this method is called.
int32 UIWidget::OnInitialize(void)
{
	GTGameObject::OnInitialize();

	// Set AnchorPoint
	SetAnchorPoint(m_AnchorPoint);

	// If the tooltip and text are not available,
	// the font is not going to be initialized.
	if(GetTooltip().Length() || GetText().Length())
	{
		// Initialize the font
		InitializeFont();
		// Set the text
		if(m_pUILabelBMFont)
		{
			m_pUILabelBMFont->SetText(GetText().ToCharString());
			// Setup anchor point for the the lable object
			m_pUILabelBMFont->SetAnchorPoint(m_AnchorPoint);
		}
	}
		
	// Initialize sprite size
	if(m_Sprite.HasSprite())
	{
		UISkinPiece* pSkinPiece = GetSkinPiece();
		GTSize size = GetSize();
		if(pSkinPiece)
		{
			m_Sprite.SetScale(
				size.width/pSkinPiece->GetRect().size.width,
				size.height/pSkinPiece->GetRect().size.height
				);			
			// Setup anchor point for the sprite
			m_Sprite.SetAnchorPoint(m_AnchorPoint);
		}
	}
	
	return 1;
}
Exemplo n.º 3
0
void TitleScene::OnInit()
{
	auto bg = Sprite::Create(LR"(Resources/Images/bg.jpg)");
	bg->SetAnchorPoint(Point::ANCHOR_TOP_LEFT);
	this->AddChild(bg);

	auto scoreBoardImg = Sprite::Create(LR"(Resources/Images/score_board.png)");
	scoreBoardImg->SetPosition(WINDOW_X / 2, WINDOW_Y / 2);
	this->AddChild(scoreBoardImg);

	auto scoreBoardText = Label::Create(LR"(Resources/Fonts/NanumGothic.ttf)", 40, L"SCOREBOARD");
	scoreBoardText->SetPosition(WINDOW_X / 2, WINDOW_Y * 0.15f);
	this->AddChild(scoreBoardText);

	auto enterToStart = Label::Create(LR"(Resources/Fonts/NanumGothic.ttf)", 40, L"Press Enter To Start");
	enterToStart->SetPosition(WINDOW_X / 2, WINDOW_Y * 0.8f);
	this->AddChild(enterToStart);

	auto scoreBoardBox = scoreBoardImg->GetBoundingBox();

	auto scoreBoard = ScoreBoard::GetInstance();
	for (int i = 0; i < SCOREBOARD_MAX; ++i)
	{
		auto scoreInfo = scoreBoard->GetScoreInfo(i);
		
		wchar_t rankingStr[256];
		wsprintf(rankingStr, L"%d.", i + 1);
		auto ranking = Label::Create(LR"(Resources/Fonts/NanumGothic.ttf)", 30, rankingStr);
		ranking->SetPosition(scoreBoardBox.left + 300, scoreBoardBox.top + 100 + (i * 30));
		ranking->SetAnchorPoint(Point::ANCHOR_MIDDLE_RIGHT);
		this->AddChild(ranking);

		wchar_t nameStr[256];
		MultiByteToWideChar(CP_ACP, 0, scoreInfo.name.c_str(), -1, nameStr, 256);
		auto name = Label::Create(LR"(Resources/Fonts/NanumGothic.ttf)", 30, nameStr);
		name->SetPosition(scoreBoardBox.left + 400, ranking->GetPositionY());
		this->AddChild(name);

		wchar_t scoreStr[256];
		wsprintf(scoreStr, L"%d", scoreInfo.score);
		auto score = Label::Create(LR"(Resources/Fonts/NanumGothic.ttf)", 30, scoreStr);
		score->SetPosition(scoreBoardBox.left + 500, ranking->GetPositionY());
		this->AddChild(score);

		for (int starIndex = 0; starIndex < STAR_NUM; ++starIndex)
		{
			auto starEmpty = Sprite::Create(LR"(Resources/Images/star_empty.png)");
			starEmpty->SetScale(0.2f);
			starEmpty->SetPosition(scoreBoardBox.left + 600 + (starIndex * 30), ranking->GetPositionY());
			this->AddChild(starEmpty);

			if (scoreInfo.score > 300 + (starIndex * 300))
			{
				auto starFull = Sprite::Create(LR"(Resources/Images/star_full.png)");
				starFull->SetScale(0.2f);
				starFull->SetPosition(scoreBoardBox.left + 600 + (starIndex * 30), ranking->GetPositionY());
				this->AddChild(starFull);
			}
		}
	}
}
Exemplo n.º 4
0
 void Polygon::SetAnchorPoint(vec2 aAnchorPoint, double aDuration, EasingFunction aEasingFunction, bool aReverse, int aRepeatCount)
 {
     SetAnchorPoint(aAnchorPoint.x, aAnchorPoint.y, aDuration, aEasingFunction, aReverse, aRepeatCount);
 }
Exemplo n.º 5
0
//
// creates a new balloon window
// Parameters:
//    strTitle    |  Title of balloon
//    strContent  |  Content of balloon
//    ptAnchor    |  point tail of balloon will be "anchor"ed to
//    unOptions   |  One or more of:
//                :     unCLOSE_ON_LBUTTON_UP   |  closes window on WM_LBUTTON_UP
//                :     unCLOSE_ON_MBUTTON_UP   |  closes window on WM_MBUTTON_UP
//                :     unCLOSE_ON_RBUTTON_UP   |  closes window on WM_RBUTTON_UP
//                :     unCLOSE_ON_LBUTTON_DOWN |  closes window on WM_LBUTTON_DOWN
//                :     unCLOSE_ON_MBUTTON_DOWN |  closes window on WM_MBUTTON_DOWN
//                :     unCLOSE_ON_RBUTTON_DOWN |  closes window on WM_RBUTTON_DOWN
//                :     unCLOSE_ON_MOUSE_MOVE   |  closes window when user moves mouse past threshhold
//                :     unCLOSE_ON_KEYPRESS     |  closes window on the next keypress message sent to this thread.    (!!! probably not thread safe !!!)
//                :     unDELETE_THIS_ON_CLOSE  |  deletes object when window is closed.  Used by LaunchBalloon(), use with care
//                :     unSHOW_CLOSE_BUTTON     |  shows close button in upper right
//                :     unSHOW_INNER_SHADOW     |  draw inner shadow in balloon
//                :     unSHOW_TOPMOST          |  place balloon above all other windows
//                :     unDISABLE_FADE          |  disable the fade-in/fade-out effects (overrides system and user settings)
//                :     unDISABLE_FADEIN        |  disable the fade-in effect
//                :     unDISABLE_FADEOUT       |  disable the fade-out effect
//    pParentWnd  |  Parent window.  If NULL will be set to AfxGetMainWnd() and anchor to screen
//    strURL      |  If not empty, when the balloon is clicked ShellExecute() will
//                |  be called, with strURL passed in.
//    unTimeout   |  If not 0, balloon will automatically close after unTimeout milliseconds.
//    hIcon       |  If not NULL, the icon indicated by hIcon will be displayed at top-left of the balloon.
//
// Returns:
//    TRUE if successful, else FALSE
//
BOOL CBalloonHelp::Create(const CString& strTitle, const CString& strContent, 
						  const CPoint& ptAnchor, unsigned int unOptions,
						  CWnd* pParentWnd /*=NULL*/,
						  const CString strURL /*= ""*/,
						  unsigned int unTimeout /*= 0*/,
						  HICON hIcon /*= NULL*/)
{
	m_strContent   = strContent;
	SetAnchorPoint(ptAnchor, pParentWnd);
	m_unOptions    = unOptions;
	m_strURL       = strURL;
	m_unTimeout    = unTimeout;
	
	if ( NULL != hIcon )
		SetIcon(hIcon);
	
	pParentWnd = GetSafeOwner(pParentWnd);
	if (NULL == pParentWnd)
		return FALSE;
	
	// if no fonts set, use defaults
	if ( NULL == m_pContentFont )
	{
		m_pContentFont = new CFont;
		if ( !m_pContentFont->CreateStockObject(DEFAULT_GUI_FONT) )
			return FALSE;
	}
	
	// title font defaults to bold version of content font
	if ( NULL == m_pTitleFont )
	{
		m_pTitleFont = new CFont;
		LOGFONT LogFont;
		m_pContentFont->GetLogFont(&LogFont);
		LogFont.lfWeight = FW_BOLD;
		if ( !m_pTitleFont->CreateFontIndirect(&LogFont) )
			return FALSE;
	}
	
	if ( !GetClassAtom() )  // couldn't register class
		return FALSE;
	
	// check system settings: if fade effects are disabled or unavailable, disable here too
	BOOL bFade = FALSE;
	::SystemParametersInfo(SPI_GETTOOLTIPANIMATION, 0, &bFade, 0);
	if (bFade)
		::SystemParametersInfo(SPI_GETTOOLTIPFADE, 0, &bFade, 0);
	if (!bFade || NULL == m_fnAnimateWindow)
		m_unOptions |= unDISABLE_FADE;
	
	// create invisible at arbitrary position; then position, set region, and finally show
	
	// the idea with WS_EX_TOOLWINDOW is, you can't switch to this using alt+tab
	DWORD dwExStyle = WS_EX_TOOLWINDOW;
	if ( m_unOptions&unSHOW_TOPMOST )      // make topmost, if requested
		dwExStyle |= WS_EX_TOPMOST;
	if ( !CreateEx(dwExStyle, _T("BalloonHelpClass"), strTitle, WS_POPUP, CRect(0,0,10,10), pParentWnd, 0, NULL) )
		return FALSE;
	PositionWindow();
	
	if ( (m_unOptions&unCLOSE_ON_MOUSE_MOVE)
		||(m_unOptions&unCLOSE_ON_LBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_LBUTTON_DOWN)
		||(m_unOptions&unCLOSE_ON_MBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_MBUTTON_DOWN)
		||(m_unOptions&unCLOSE_ON_RBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_RBUTTON_DOWN) )
	{
		::GetCursorPos(&m_ptMouseOrig);
		SetMouseHook();
	}
	
	// these need to take effect even if the window receiving them
	// is not owned by this process.  So, if this process does not
	// already have the mouse captured, capture it!
	if ( (m_unOptions&unCLOSE_ON_LBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_MBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_RBUTTON_UP) )
	{
		// no, i don't particularly need or want to deal with a situation
		// where a balloon is being created and another program has captured
		// the mouse.  If you need it, it shouldn't be too hard, just do it here.
		if ( NULL == GetCapture() )
			SetCapture();
	}
	
	if ( m_unOptions&unCLOSE_ON_KEYPRESS )
		SetKeyboardHook();
	
	ShowBalloon();
	return TRUE;
}
Exemplo n.º 6
0
//=============================================================================
// constructor
//=============================================================================
Title::Title()
{
	//ウィンドウ
	auto window = GET_WINDOW();

	//とりあえず背景
	auto sprite = std::make_shared<mesh::Sprite>(float2(window->GetWidth(), window->GetHeight()));

	background_ = std::make_shared<MeshObject>(sprite);
	sprite->SetAnchorPoint(float2(0.0f, 0.0f));
	sprite->Apply();
	background_->SetPosition(0.0f, 0.0f, 0.0f);
	background_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/title_background.png"));
	
	//ロゴ
	auto sprite_logo = std::make_shared<mesh::Sprite>(float2(800, 400));
	logo_ = std::make_shared<MeshObject>(sprite_logo);
	sprite_logo->SetAnchorPoint(float2(0.0f, 0.0f));
	sprite_logo->Apply();
	logo_->SetPosition(window->GetWidth()/2-400.0f, window->GetHeight()/2-250.0f, 0.0f);
	logo_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/title_logo.png"));

	//ボタン
	auto sprite_button = std::make_shared<mesh::Sprite>(float2(400, 200));
	button_ = std::make_shared<MeshObject>(sprite_button);
	sprite_button->SetAnchorPoint(float2(0.0f, 0.0f));
	sprite_logo->Apply();
	button_->SetPosition(window->GetWidth() / 2 - 210.0f, window->GetHeight() - 250.0f, 0.0f);
	button_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/Start.png"));

	//ボタン背景
	auto sprite_button_interface_ = std::make_shared<mesh::Sprite>(float2(300, 100));
	button_interface_ = std::make_shared<MeshObject>(sprite_button_interface_);
	sprite_button_interface_->SetAnchorPoint(float2(0.0f, 0.0f));
	sprite_button_interface_->Apply();
	button_interface_->SetPosition(window->GetWidth() / 2 - 150.0f, window->GetHeight() - 200.0f, 0.0f);
	button_interface_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/window_256x512.png"));

	//パーティクル
	for (u32 i = 0; i < PARTICUL_MAX; ++i)
	{
		auto sprite_particul = std::make_shared<mesh::Sprite>(float2(30,30));
		particul_[i].particul_ = std::make_shared<MeshObject>(sprite_particul);
		sprite->SetAnchorPoint(float2(0.0f, 0.0f));
		particul_[i].particul_->SetPosition(f32((rand() % window->GetWidth())), -30.0f, 0.0f);
		particul_[i].particul_->SetTexture(0, GET_GRAPHIC_DEVICE()->LoadTexture("resources/texture/petal.png"));
		particul_[i].particul_angle_ = 0.0f;
		particul_[i].start_cnt_ = i * 10;
		particul_[i].start_flag_ = false;
	}

	//2D用カメラ設定
	observer_2d_ = std::make_shared<Observer2D>(window->GetWidth(), window->GetHeight());

	//BGM
	Sound::Instance().PlaySound(SOUND_LABEL_BGM000);

	draw_cnt_ = 0;
	use_flag_ = false;
	particul_cnt_ = 0;
}