示例#1
0
void cDialogBox :: Draw( void )
{
	Draw_Game();
	pVideo->Draw_Gradient( NULL, 0.905f, &whitealpha128, &black, DIR_VERTICAL );

	pVideo->Render();

	pMouseCursor->Update_Position();
}
示例#2
0
void Player::Draw()
{
	switch (state)
	{
	case ePlayerState_Start: Draw_Start();	break;
	case ePlayerState_Game: Draw_Game();	break;
	case ePlayerState_Dead: Draw_Dead();	break;
	default:	printfDx("Player.cpp:ERROR\n");	break;
	}

	// TEST------------------------------------------------------------------------------------
	if (DebugMode::isTest == false)	return;

	DrawCircle(pos.x, pos.y + 9, HIT_RANGE, GetColor(0, 255, 0), false);
//	DrawFormatString(100, 100, GetColor(0, 255, 0), "rensha = %d", s_rensha);
//	DrawFormatString(100, 100, GetColor(0, 255, 0), "Dで死にます");
//	DrawFormatString(100, 120, GetColor(0, 255, 0), "Pでシフトアップ");
//	DrawFormatString(100, 140, GetColor(0, 255, 0), "Oでシフトダウン");
}
示例#3
0
void cText_Box :: Activate( void )
{
	CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
	CEGUI::MultiLineEditbox *editbox = static_cast<CEGUI::MultiLineEditbox *>(wmgr.createWindow( "TaharezLook/MultiLineEditbox", "text_box_text" ));

	// add to main window
	pGuiSystem->getGUISheet()->addChildWindow( editbox );


	// set on top
	editbox->setAlwaysOnTop( 1 );
	// set position
	float text_pos_x = m_pos_x - ( text_box_window_width * 0.5f ) + ( m_rect.m_w * 0.5f );
	float text_pos_y = m_pos_y - 5 - text_box_window_height;

	// if not on screen on the left side
	if( text_pos_x < 0 )
	{
		// put it on screen
		text_pos_x = 0;
	}
	// if not on screen on the right side
	if( text_pos_x > pActive_Camera->limit_rect.m_x + pActive_Camera->limit_rect.m_w - text_box_window_width )
	{
		// put it on screen
		text_pos_x = pActive_Camera->limit_rect.m_x + pActive_Camera->limit_rect.m_w - text_box_window_width;
	}

	editbox->setXPosition( CEGUI::UDim( 0, ( text_pos_x - pActive_Camera->x ) * global_upscalex ) );
	editbox->setYPosition( CEGUI::UDim( 0, ( text_pos_y - pActive_Camera->y ) * global_upscaley ) );
	// set size
	editbox->setWidth( CEGUI::UDim( 0, text_box_window_width * global_upscalex ) );
	editbox->setHeight( CEGUI::UDim( 0, text_box_window_height * global_upscaley ) );

	// set text
	editbox->setText( reinterpret_cast<const CEGUI::utf8*>(text.c_str()) );
	// always hide horizontal scrollbar
	editbox->getHorzScrollbar()->hide();

	bool display = 1;

	while( display )
	{
		while( SDL_PollEvent( &input_event ) )
		{
			if( input_event.type == SDL_KEYDOWN )
			{
				pKeyboard->keys[input_event.key.keysym.sym] = 1;

				// exit keys
				if( input_event.key.keysym.sym == pPreferences->m_key_action || input_event.key.keysym.sym == SDLK_ESCAPE || input_event.key.keysym.sym == SDLK_RETURN || input_event.key.keysym.sym == SDLK_SPACE )
				{
					display = 0;
					break;
				}
				// handled keys
				else if( input_event.key.keysym.sym == pPreferences->m_key_right || input_event.key.keysym.sym == pPreferences->m_key_left )
				{
					pKeyboard->Key_Down( input_event.key.keysym.sym );
				}
			}
			else if( input_event.type == SDL_KEYUP )
			{
				pKeyboard->keys[input_event.key.keysym.sym] = 0;

				// handled keys
				if( input_event.key.keysym.sym == pPreferences->m_key_right || input_event.key.keysym.sym == pPreferences->m_key_left )
				{
					pKeyboard->Key_Up( input_event.key.keysym.sym );
				}
			}
			else if( input_event.type == SDL_JOYBUTTONDOWN )
			{
				pJoystick->Set_Button( input_event.jbutton.button, 1 );

				if( input_event.jbutton.button == pPreferences->m_joy_button_action || input_event.jbutton.button == pPreferences->m_joy_button_exit )
				{
					display = 0;
					break;
				}
			}
			else if( input_event.type == SDL_JOYBUTTONUP )
			{
				pJoystick->Set_Button( input_event.jbutton.button, 0 );
			}
			else if( input_event.type == SDL_JOYHATMOTION )
			{
				pJoystick->Handle_Hat( &input_event );
				break;
			}
			else if( input_event.type == SDL_JOYAXISMOTION )
			{
				pJoystick->Handle_Motion( &input_event );
				break;
			}
		}

		Uint8 *keys = SDL_GetKeyState( NULL );
		Sint16 joy_ver_axis = 0;

		// if joystick enabled
		if( pPreferences->m_joy_enabled )
		{
			joy_ver_axis = SDL_JoystickGetAxis( pJoystick->joystick, pPreferences->m_joy_axis_ver );
		}

		// down
		if( keys[pPreferences->m_key_down] || joy_ver_axis > pPreferences->m_joy_axis_threshold )
		{
			editbox->getVertScrollbar()->setScrollPosition( editbox->getVertScrollbar()->getScrollPosition() + ( editbox->getVertScrollbar()->getStepSize() * 0.25f * pFramerate->m_speed_factor ) );
		}
		// up
		if( keys[pPreferences->m_key_up] || joy_ver_axis < -pPreferences->m_joy_axis_threshold )
		{
			editbox->getVertScrollbar()->setScrollPosition( editbox->getVertScrollbar()->getScrollPosition() - ( editbox->getVertScrollbar()->getStepSize() * 0.25f * pFramerate->m_speed_factor ) );
		}

		// move camera because text could not be completely visible
		if( pActive_Camera->y_offset > 0 )
		{
			pActive_Camera->y_offset -= 2;
			// set position
			pActive_Camera->Center();

			// set position
			editbox->setXPosition( CEGUI::UDim( 0, ( text_pos_x - pActive_Camera->x ) * global_upscalex ) );
			editbox->setYPosition( CEGUI::UDim( 0, ( text_pos_y - pActive_Camera->y ) * global_upscaley ) );
		}

		// update animation
		Update();
		
		// update audio
		pAudio->Update();
		// draw
		Draw_Game();
		// render
		pVideo->Render();
		pFramerate->Update();
	}

	wmgr.destroyWindow( editbox );
}
示例#4
0
void Draw_Static_Text( const std::string &text, const Color *color_text /* = &white */, const Color *color_bg /* = NULL */, bool wait_for_input /* = 1 */ )
{
	// fixme : Can't handle multiple lines of text. Change to MultiLineEditbox or use HorzFormatting=WordWrapLeftAligned property.
	bool draw = 1;

	// Statictext window
	CEGUI::Window *window_statictext = CEGUI::WindowManager::getSingleton().loadWindowLayout( "statictext.layout" );
	pGuiSystem->getGUISheet()->addChildWindow( window_statictext );
	// get default text
	CEGUI::Window *text_default = static_cast<CEGUI::Window *>(CEGUI::WindowManager::getSingleton().getWindow( "text_default" ));

	// set text
	text_default->setProperty( "TextColours", CEGUI::PropertyHelper::colourToString( CEGUI::colour( static_cast<float>(color_text->red) / 255, static_cast<float>(color_text->green) / 255, static_cast<float>(color_text->blue) / 255, 1 ) ) );
	CEGUI::String gui_text = reinterpret_cast<const CEGUI::utf8*>(text.c_str());
	text_default->setText( gui_text );

	// align text
	CEGUI::Font *font = &CEGUI::FontManager::getSingleton().get( "bluebold_medium" );
	float text_width = font->getTextExtent( gui_text ) * global_downscalex;

	text_default->setWidth( CEGUI::UDim( 0, ( text_width + 15 ) * global_upscalex ) );
	text_default->setXPosition( CEGUI::UDim( 0, ( game_res_w * 0.5f - text_width * 0.5f ) * global_upscalex ) );
	text_default->moveToFront();

	float text_height = font->getLineSpacing();
	text_height *= 1 + std::count(text.begin(), text.end(), '\n');
	// set window height
	text_default->setHeight( CEGUI::UDim( 0, text_height + ( 12 * global_upscaley ) ) );

	while( draw )
	{
		Draw_Game();

		// draw background
		if( color_bg )
		{
			// create request
			cRect_Request *request = new cRect_Request();

			pVideo->Draw_Rect( NULL, 0.9f, color_bg, request );
			request->m_render_count = wait_for_input ? 4 : 1;

			// add request
			pRenderer->Add( request );
		}

		pVideo->Render();

		if( wait_for_input )
		{
			while( SDL_PollEvent( &input_event ) )
			{
				if( input_event.type == SDL_KEYDOWN || input_event.type == SDL_JOYBUTTONDOWN || input_event.type == SDL_MOUSEBUTTONDOWN )
				{
					draw = 0;
				}
			}

			// if vsync is disabled then limit the fps to reduce the CPU usage
			if( !pPreferences->m_video_vsync )
			{
				Correct_Frame_Time( 100 );
			}
		}
		else
		{
			draw = 0;
		}

		pFramerate->Update();
	}

	// Clear possible active input
	if( wait_for_input )
	{
		Clear_Input_Events();
	}

	pGuiSystem->getGUISheet()->removeChildWindow( window_statictext );
	CEGUI::WindowManager::getSingleton().destroyWindow( window_statictext );
}