Ejemplo n.º 1
0
bool Dialog::CreateFromXML(const char* idd){
	ScopedPointer<File> fh = gUiRender->OpenFile(idd);
	if(!fh) return false;
	char* xml = (char*)fh->ReadWholeFile();
	int tmpInt;
	bool result = true;
	
	try {
		ticpp::Document doc;
		doc.Parse(xml);

		ticpp::Element* root = doc.FirstChildElement("Root_Element");
		if(root->GetAttribute("ID", &tmpInt))			SetID(tmpInt);
		if(root->GetAttribute("X", &tmpInt))			SetPositionX(tmpInt);
		if(root->GetAttribute("Y", &tmpInt))			SetPositionY(tmpInt);
		if(root->GetAttribute("WIDTH", &tmpInt))		SetSizeX(tmpInt);
		if(root->GetAttribute("HEIGHT", &tmpInt))		SetSizeY(tmpInt);
		if(root->GetAttribute("MODAL", &tmpInt))		SetModal(tmpInt);
		if(root->GetAttribute("SHOWSID", &tmpInt))		SetShowSoundID(tmpInt);
		if(root->GetAttribute("HIDESID", &tmpInt))		SetHideSoundID(tmpInt);
		if(root->GetAttribute("EXTENT", &tmpInt))		SetExtent(tmpInt);
		if(root->GetAttribute("DEFAULT_X", &tmpInt))	SetDefaultPositionX(tmpInt);
		if(root->GetAttribute("DEFAULT_Y", &tmpInt))	SetDefaultPositionY(tmpInt);
		if(root->GetAttribute("ADJUST_X", &tmpInt))		SetDefaultAdjustPositionX(tmpInt);
		if(root->GetAttribute("ADJUST_Y", &tmpInt))		SetDefaultAdjustPositionY(tmpInt);
		if(root->GetAttribute("DEFAULT_VISIBLE", &tmpInt)) SetDefaultVisible(tmpInt);
		SetName(root->GetAttribute("NAME").c_str());
		
		for(ticpp::Element* child = root->FirstChildElement(false); child; child = child->NextSiblingElement(false)){
			if(child->Value() == "CAPTION"){
				mCaption = (Caption*)CreateControlFromXML(child, this);
			}else if(child->Value() == "RADIOBUTTON"){
				RadioButton* btn = (RadioButton*)CreateControlFromXML(child, this);
				if(int id = btn->RadioBoxID()){
					RadioBox* box = (RadioBox*)GetControlByID(id);
					if(box && box->ControlType() == CT_RADIOBOX)
						box->AddButton(btn);
				}

				AddChild(btn);
			}else{
				AddChild(CreateControlFromXML(child, this));
			}
		}

	}catch(ticpp::Exception& ex){
		LOG("TinyXML Exception %s", ex.what());
		result = false;
	}

	OnCreated();

	delete [] xml;
	return result;
}
Ejemplo n.º 2
0
void Player::Update(float dt)
{
	m_animator->Animate(dt);
	if (movementX != 0 && movementY != 0)
	{
		movementX /= 1.41f;
		movementY /= 1.41f;
	}
	managePlayersTextureDirection();
	SetPositionX(GetPositionX() + movementX);
	SetPositionY(GetPositionY() + movementY);
	m_sprite.setPosition(GetPositionX(),GetPositionY());

	if (m_bomb != nullptr)
	{
		m_bomb->Update(dt);
		if (m_bomb->GetState() == Bomb::exploding)
		{
			level->DestroyTile(m_bomb->GetPositionInTileCoordinatesX(), m_bomb->GetPositionInTileCoordinatesY(), false);
		}
		if (m_bomb->GetState() == Bomb::exploded)
		{
			delete m_bomb;
			m_bomb = nullptr;
		}
	}
	if (m_respawns > 0 && m_respawns < m_maxNumberOfRespawns && (m_respawnClock.getElapsedTime() >= m_respawnSafeTime))
	{
		m_canBeDamaged = true;
	}
	else if (m_respawns <= 0 && m_isAlive)
	{
		endGame();
		m_isAlive = false;
	}
	else
	{
		m_isAlive = true;
	}
}
Ejemplo n.º 3
0
FReply SProfilerThreadView::OnMouseMove( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
	//	SCOPE_LOG_TIME_FUNC();

	FReply Reply = FReply::Unhandled();

	if( IsReady() )
	{
		const FVector2D LocalMousePosition = MyGeometry.AbsoluteToLocal( MouseEvent.GetScreenSpacePosition() );
		
		HoveredPositionX = 0.0;//PositionToFrameIndex( LocalMousePosition.X );
		HoveredPositionY = 0.0;

		const float CursorPosXDelta = -MouseEvent.GetCursorDelta().X;
		const float ScrollSpeed = 1.0f / ZoomFactorX;

		if( MouseEvent.IsMouseButtonDown( EKeys::LeftMouseButton ) )
		{
			if( HasMouseCapture() && !MouseEvent.GetCursorDelta().IsZero() )
			{
				DistanceDragged += CursorPosXDelta*ScrollSpeed*0.1;

				// Inform other widgets that we have scrolled the thread-view.
				SetPositionX( FMath::Clamp( DistanceDragged, 0.0, TotalRangeXMS - RangeXMS ) );
				CursorType = EThreadViewCursor::Hand;
				Reply = FReply::Handled();
			}
		}
		else
		{
			CursorType = EThreadViewCursor::Default;
		}
	}

	return Reply;
}
Ejemplo n.º 4
0
void Player::Spawn()
{
	SetPositionX(static_cast<int>(m_respawnPosition.x*TILE_SIZE + TILE_SIZE / 2));
	SetPositionY(static_cast<int>(m_respawnPosition.y*TILE_SIZE + TILE_SIZE / 2));
}
Ejemplo n.º 5
0
/*!
@brief 設定ウィンドウの座標設定
@par   関数説明
ウィンドウの座標を設定する。設定反映はSetWindow()関数を使う。
@param unsigned int x X座標を与える。
@param unsigned int y Y座標を与える。
@return 0を返す。
*/
int Window::SetPositionXY( int x, int y )
{
	SetPositionX( x );
	SetPositionY( y );
	return 0;
}
Ejemplo n.º 6
0
/*!
@brief ウィンドウの設定を変更する
@par   関数説明
ウィンドウスタイルを設定する。
@param Type WT_で始まる定数。
@return false=設定反映かSetWindowPosでの設定失敗。
@return true=SetWindowPosでの設定成功。
*/
BOOL Window::SetWindow( int type, int display )
{
	HWND myhwnd = NULL;//ウィンドウハンドル
	RECT myrect;//RECT構造体
	BOOL ret;

	// ディスプレイ番号から領域を割り出して移動してからサイズ変更とかを行うように書き換え

	switch ( type )
	{
	case WT_DEFAULT://サイズ固定のウィンドウ
		//ウィンドウスタイルの設定
		SetWindowStyle( WT_DEFAULT );
		//ウィンドウスタイルの変更
		SetWindowLong( GetWindowHandle(), GWL_STYLE, GetWindowStyle() );
		wd.flags = SWP_SHOWWINDOW;
		wd.winpos = HWND_TOP;
		//ウィンドウのサイズや位置を変更
		ret = SetWindowPos(
			GetWindowHandle(), wd.winpos,
			GetPositionX(), GetPositionY(),//CW_USEDEFAULT, CW_USEDEFAULT,
			GetWindowWidth(), GetWindowHeight(),
			wd.flags
			);
		SetPositionX( GetPositionX( 1 ) );
		SetPositionY( GetPositionY( 1 ) );
		return ret;
	case WT_NORMAL://通常のリサイズ可能ウィンドウ
		//ウィンドウスタイルの設定
		SetWindowStyle( WT_NORMAL );
		//ウィンドウスタイルの変更
		SetWindowLong( GetWindowHandle(), GWL_STYLE, GetWindowStyle() );
		wd.flags = SWP_SHOWWINDOW;
		//ウィンドウのサイズや位置を変更
		wd.winpos = HWND_TOP;
		ret = SetWindowPos(
			GetWindowHandle(), wd.winpos,
			GetPositionX(), GetPositionY(),//CW_USEDEFAULT, CW_USEDEFAULT,
			GetWindowWidth(), GetWindowHeight(),
			wd.flags
			);
		SetPositionX( GetPositionX( 1 ) );
		SetPositionY( GetPositionY( 1 ) );
		return ret;
	case WT_NOFRAME:
	case WT_FULLSCREEN:
		//ウィンドウスタイルの設定
		SetWindowStyle( WT_NOFRAME );

		//ウィンドウスタイルの変更
		SetWindowLong( GetWindowHandle(), GWL_STYLE, GetWindowStyle() );
		wd.flags = SWP_SHOWWINDOW;
		wd.winpos = HWND_TOP;
		//ウィンドウのサイズや位置を変更
		return SetWindowPos(
			GetWindowHandle(), wd.winpos,
			GetPositionX(), GetPositionY(),
			GetWindowWidth(), GetWindowHeight(),
			wd.flags
			);
	case WT_NORESIZEFULLSCREEN://画面設定を変えないフルスクリーン
		//プログラムを起動したデスクトップサイズのウィンドウで
		//描写優先度が一番上のウィンドウを生成する

		//ウィンドウスタイルの設定
		SetWindowStyle( WT_NORESIZEFULLSCREEN );

		// 対象ディスプレイのサイズなどを取得。
		if ( GetDisplayRect( display, &myrect ) == 0 )
		{
			// 成功したので、うまい具合に設定。
			// 位置はディスプレイの左上。
			SetPositionXY( myrect.left, myrect.top );
			// サイズはディスプレイに合わせる。
			SetWindowSize( myrect.right - myrect.left, myrect.bottom - myrect.top );
		} else
		{
			// 失敗したので、デスクトップから取得。

			//デスクトップのウィンドウハンドル取得
			myhwnd = GetDesktopWindow();
			//デスクトップのサイズなどを取得
			if ( myhwnd && GetClientRect( myhwnd, &myrect ) )
			{
				//位置は原点に設定
				SetPositionXY( 0, 0 );
				//サイズはデスクトップと同じサイズに設定
				SetWindowSize( myrect.right, myrect.bottom );
			}
		}

		//ウィンドウスタイルの変更
		SetWindowLong( GetWindowHandle(), GWL_STYLE, GetWindowStyle() );
		wd.flags = SWP_SHOWWINDOW;
		wd.winpos = HWND_TOPMOST;
		//ウィンドウのサイズや位置を変更
		return SetWindowPos(
			GetWindowHandle(), wd.winpos,
			GetPositionX(), GetPositionY(),
			GetWindowWidth(), GetWindowHeight(),
			wd.flags
			);

	default:
		//後で考える
		//リサイズ程度
		MoveWindow(
			GetWindowHandle(),
			GetPositionX(), GetPositionY(),
			GetWindowWidth(), GetWindowHeight(),
			TRUE
			);
		break;
	}
	return 0;
}
Ejemplo n.º 7
0
void SceneObject::SetPosition(float x, float y, float z)
{
	SetPositionX(x);
	SetPositionY(y);
	SetPositionZ(z);
}