예제 #1
0
	void Message::MakeChoiceMessage() {
		Box::Ptr box = Box::Create(Box::Orientation::VERTICAL, 0);
		box->Pack(Label::Create(Message_));
		Box::Ptr buttonBox = Box::Create(Box::Orientation::HORIZONTAL, 0);
		{
			Box::Ptr spacer = Box::Create();
			spacer->SetRequisition(sf::Vector2f(10, 10));
			buttonBox->Pack(spacer, true, true);
		}
		Button::Ptr abort = Button::Create("Abort");
		abort->SetRequisition(sf::Vector2f(50, 10));
		abort->GetSignal(Button::OnLeftClick).Connect(std::bind(&Message::Abort, this));
		buttonBox->Pack(abort, false, false);
		Button::Ptr confirm = Button::Create("Confirm");
		confirm->SetRequisition(sf::Vector2f(50, 10));
		confirm->GetSignal(Button::OnLeftClick).Connect(std::bind(&Message::Confirm, this));
		buttonBox->Pack(confirm, false, false);
		{
			Box::Ptr spacer = Box::Create();
			spacer->SetRequisition(sf::Vector2f(10, 10));
			buttonBox->Pack(spacer, true, true);
		}
		box->Pack(buttonBox);
		Win->Add(box);
		Module::Get()->QueueEvent(Event("SCREEN_ADD_WINDOW", Win));
	}
예제 #2
0
	void Message::MakeModalMessage() {
		Box::Ptr box = Box::Create(Box::Orientation::VERTICAL, 0);
		box->Pack(Label::Create(Message_));
		Box::Ptr spacer = Box::Create();
		spacer->SetRequisition(sf::Vector2f(10, 10));
		box->Pack(spacer, true, true);

		Win->Add(box);
		Module::Get()->QueueEvent(Event("SCREEN_ADD_WINDOW", Win));
	}
예제 #3
0
	void Message::MakeOkMessage() {
		Box::Ptr box = Box::Create(Box::Orientation::VERTICAL, 0);
		box->Pack(Label::Create(Message_));
		Box::Ptr buttonBox = Box::Create(Box::Orientation::HORIZONTAL, 0);
		{
			Box::Ptr spacer = Box::Create();
			spacer->SetRequisition(sf::Vector2f(10, 10));
			buttonBox->Pack(spacer, true, true);
		}
		Button::Ptr ok = Button::Create("OK");
		ok->GetSignal(Button::OnLeftClick).Connect(std::bind(&Message::Ok, this));
		ok->SetRequisition(sf::Vector2f(50, 10));
		buttonBox->Pack(ok, false, false);
		box->Pack(buttonBox, false, false);
		{
			Box::Ptr spacer = Box::Create();
			spacer->SetRequisition(sf::Vector2f(10, 10));
			buttonBox->Pack(spacer, true, true);
		}

		Win->Add(box);
		Module::Get()->QueueEvent(Event("SCREEN_ADD_WINDOW", Win));
	}
예제 #4
0
void Control::InitWindow( const glm::ivec2 Size )
{
	Win = Window::Create();
	Win->SetStyle( 0 );
	Win->SetRequisition( sf::Vector2f( Size.x, Size.y ) );

	// main box, vertical
	Box::Ptr box( Box::Create( Box::Orientation::VERTICAL, 5.0f ) );
	Box::Ptr buttonBox( Box::Create( Box::Orientation::HORIZONTAL, 5.0f ) );
	buttonBox->SetRequisition({ (float)Size.x, 0});

		BtnMnMnWin =  ToggleButton::Create(  "MainMenu [Esc]" );
		BtnIPanWin =  ToggleButton::Create( "InfoPanel [F1]" );
		BtnSimPause = ToggleButton::Create(     "Pause [F2]" );
		BtnDbgWin =   ToggleButton::Create(   "Console [F3]" );
		BtnGraBoWin = ToggleButton::Create( "GraphBook [F4]" );
		BtnSimReset =       Button::Create(     "Reset [F5]" );
		BtnSimSingleFrame = Button::Create(     ">|" );
		BtnSimFrames = Button::Create(     ">>|" );
		SclTickSlider = sfg::Scale::Create();

		Box::Ptr boxTickSlider = Box::Create( Box::Orientation::HORIZONTAL, 5.0f );
		boxTickSlider->SetRequisition({ 100, 30 });
		SclTickSlider->SetRequisition({ 100, 20 });
		SclTickSlider->SetIncrements(1,500);
		SclTickSlider->SetValue(0);
		SclTickSlider->Show(Engine::getCfg()->get<bool>("sim.paused"));
		SclTickSlider->GetSignal(sfg::Scale::OnMouseLeftRelease).Connect( std::bind( &Control::TickSliderReleased, this) );
		SclTickSlider->GetSignal(sfg::Scale::OnMouseMove).Connect( std::bind( &Control::TickSliderLabelUpdate, this) );
		TickScaleDisplay = Entry::Create( "0 / 0" );
		TickScaleDisplay->SetRequisition({ 100, 0 });
		TickScaleDisplay->SetState( Widget::State::INSENSITIVE );

		boxTickSlider->Pack( SclTickSlider, true, true );
		boxTickSlider->Pack( TickScaleDisplay, false, false );

		Box::Ptr framesframe( Box::Create( Box::Orientation::HORIZONTAL, 0 ) );
			Framesdisplay = Entry::Create();
			Framesdisplay->SetRequisition( { 60, 0 } );
			//Framesdisplay->SetState( Widget::State::INSENSITIVE );
			Framesdisplay->SetText( boost::lexical_cast<std::string>( Frames ) );
			textchangeavoidrecursive = false;
			Framesdisplay->GetSignal( Entry::OnTextChanged ).Connect( std::bind( &Control::EntryTextChange , this ));
			Framesdisplay->GetSignal( Entry::OnGainFocus ).Connect( std::bind( &Control::EntryGainFocus , this ));
			Framesdisplay->GetSignal( Entry::OnLostFocus ).Connect( std::bind( &Control::EntryLostFocus , this ));
			Button::Ptr down = Button::Create( "<" );
			Button::Ptr up   = Button::Create( ">" );
				down->GetSignal( Button::OnLeftClick ).Connect( std::bind( &Control::BtnFramesDownClick, this ));
				down->GetSignal( Button::OnLeftClick ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));
				up->GetSignal(   Button::OnLeftClick ).Connect( std::bind( &Control::BtnFramesUpClick, this ));
				up->GetSignal(   Button::OnLeftClick ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));

			framesframe->Pack( down, false, false );
			framesframe->Pack( Framesdisplay, false, false );
			framesframe->Pack( up, false, false );

		//init the first look of the buttons BEFORE they are connected with their actions.
		BtnDbgWin->SetActive( true );
		BtnIPanWin->SetActive( true );
		BtnSimPause->SetActive( true );

		BtnDbgWin->GetSignal(   ToggleButton::OnToggle ).Connect( std::bind( &Control::BtnDbgWinClick, this ));
		BtnDbgWin->GetSignal(   ToggleButton::OnToggle ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));
		BtnIPanWin->GetSignal(  ToggleButton::OnToggle ).Connect( std::bind( &Control::BtnIPanWinClick, this ));
		BtnIPanWin->GetSignal(  ToggleButton::OnToggle ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));
		BtnMnMnWin->GetSignal(  ToggleButton::OnToggle ).Connect( std::bind( &Control::BtnMnMnWinClick, this ));
		BtnMnMnWin->GetSignal(  ToggleButton::OnToggle ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));
		BtnGraBoWin->GetSignal( ToggleButton::OnToggle ).Connect( std::bind( &Control::BtnGraBoWinClick, this ));
		BtnGraBoWin->GetSignal( ToggleButton::OnToggle ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));
			simPauseConnectionSerial =
		BtnSimPause->GetSignal( ToggleButton::OnToggle ).Connect( std::bind( &Control::BtnSimPauseClick, this ));
		BtnSimPause->GetSignal( ToggleButton::OnToggle ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));
		BtnSimReset->GetSignal( Button::OnLeftClick    ).Connect( std::bind( &Control::BtnSimResetClick, this ));
		BtnSimReset->GetSignal( Button::OnLeftClick    ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));
		BtnSimSingleFrame->GetSignal( Button::OnLeftClick    ).Connect( std::bind( &Control::BtnSimSingleFrameClick, this ));
		BtnSimSingleFrame->GetSignal( Button::OnLeftClick    ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));
		BtnSimFrames->GetSignal( Button::OnLeftClick    ).Connect( std::bind( &Control::BtnSimFramesClick, this ));
		BtnSimFrames->GetSignal( Button::OnLeftClick    ).Connect( std::bind( &Screen::OnHandledEvent, Screen::get() ));

		buttonBox->Pack( BtnMnMnWin,  false, false );
		buttonBox->Pack( BtnIPanWin,  false, false );
		buttonBox->Pack( BtnSimPause, false, false );
		buttonBox->Pack( BtnDbgWin,   false, false );
		buttonBox->Pack( BtnGraBoWin, false, false );
		buttonBox->Pack( BtnSimReset, false, false );
		buttonBox->Pack( framesframe, false, false );
		buttonBox->Pack( BtnSimSingleFrame, false, false );
		buttonBox->Pack( BtnSimFrames, false, false );
		box->Pack( boxTickSlider, true, true );
		box->Pack( buttonBox, false, false );

	Win->Add( box );
	Win->SetTitle( "Control" );
	updatePosition();

	Module::Get()->QueueEvent( Event( "SCREEN_ADD_WINDOW", Win ) );
}