Exemplo n.º 1
0
bool EditorBase::DrawTab(VideoPtr video, InputPtr input, const Vector2 &v2Pos, const float width, const wstring &text, Color color)
{
	video->SetAlphaMode(Video::AM_PIXEL);
	video->SetVertexShader(ShaderPtr());
	video->SetPixelShader(ShaderPtr());
	video->SetZBuffer(false);
	video->SetZWrite(false);

	const Vector2 v2Cam = video->GetCameraPos();
	video->SetCameraPos(Vector2(0,0));
	bool mouseOver = false;
	if (mouseOver = ETHGlobal::PointInRect(input->GetCursorPositionF(video), v2Pos+Vector2(width/2, m_menuSize), Vector2(width, m_menuSize)))
	{
		if (color.a < 200)
			color.a = 200;
	}

	const Vector2 v2CurveSize = m_curve->GetBitmapSizeF();
	const float rectWidth = width-v2CurveSize.x*2;
	m_curve->FlipX();
	m_curve->Draw(v2Pos, color);

	const Vector2 v2RectPos = v2Pos+Vector2(v2CurveSize.x, 0);
	video->DrawRectangle(v2RectPos, Vector2(rectWidth, m_menuSize*2), color);

	m_curve->FlipX();
	m_curve->Draw(v2Pos+Vector2(v2CurveSize.x+rectWidth, 0), color);

	ShadowPrint(v2RectPos+Vector2(v2CurveSize.x, m_menuSize/2), text.c_str(), L"Verdana14_shadow.fnt", Color(color.a,255,255,255));
	video->SetCameraPos(v2Cam);
	return (mouseOver && input->GetKeyState(GSK_LMOUSE) == GSKS_HIT);
}
Exemplo n.º 2
0
GS_PLAYER_INFO PlayCutscene(VideoPtr pVideo, const std::wstring& fileName,
							InputPtr pInput, const GS_KEY escapeKey)
{
	if (!pVideo)
	{
		ShowMessage(L"Invalid video handler - gs2d::PlayCutscene", GSMT_ERROR);
		return GSPI_FAILED;
	}

	GS_PLAYER_INFO info = GSPI_FINISHED;
	//pVideo->TurnLoopManagerOff();

	const bool rendering = pVideo->Rendering();
	if (rendering)
		pVideo->EndSpriteScene();

	PlayerPtr player = CreatePlayer(pVideo, fileName);
	if (!player)
	{
		ShowMessage(L"Failed while trying to load the video - gs2d::PlayCutscene", GSMT_ERROR);
		if (rendering)
			pVideo->BeginSpriteScene();
		return GSPI_FAILED;
	}

	pVideo->EnableMediaPlaying(true);
	player->SetFullscreen();
	player->Rewind();
	player->Play();

	while (!player->IsFinished())
	{
		player->UpdateVideo();
		const Video::APP_STATUS status = pVideo->HandleEvents();
		if (status == Video::APP_QUIT)
		{
			info = GSPI_CLOSE_WINDOW;
			break;
		}
		else
		{
			if (status == Video::APP_SKIP)
				continue;
		}

		if (pInput)
		{
			pInput->Update();
			if (pInput->GetKeyState(escapeKey) == GSKS_HIT)
			{
				info = GSPI_SKIPPED;
				break;
			}
		}
	}

	if (rendering)
		pVideo->BeginSpriteScene();

	pVideo->EnableMediaPlaying(false);
	return info;
}
Exemplo n.º 3
0
void GSGUI_STRING_INPUT::PlaceInput(const Vector2& pos, const str_type::string& font, const unsigned int nMaxChars, 
				const float size, const Color& dwColor, VideoPtr video,
				InputPtr input)
{
	const unsigned int time = video->GetElapsedTime();
	if ((time-lastBlink) > blinkTime)
	{
		showingCarret = showingCarret==0 ? 1 : 0;
		lastBlink = video->GetElapsedTime();
	}

	// pick the text cursor position with a mouse click
	if (input->GetLeftClickState() == GSKS_HIT)
	{
		cursor = video->FindClosestCarretPosition(font, ss, pos, input->GetCursorPositionF(video));
	}
	
	// don't let the cursor exceed the text range
	cursor = Min(cursor, static_cast<unsigned int>(ss.length()));

	str_type::char_t lastInput = input->GetLastCharInput();
	if (lastInput != '\0' && ss.length() < nMaxChars)
	{
		if (numbersOnly)
		{
			if ((lastInput < 'a' || lastInput > 'z') &&
				(lastInput < 'A' || lastInput > 'Z'))
			{
				ss.insert(cursor, 1, lastInput);
			}
		}
		else
		{
			ss.insert(cursor, 1, lastInput);
		}
		cursor++;
	}

	if (input->GetKeyState(GSK_BACK) == GSKS_HIT)
	{
		if (cursor > 0)
		{
			ss.erase(cursor-1, 1);
			cursor--;
		}
	}
	
	if (input->GetKeyState(GSK_DELETE) == GSKS_HIT)
	{
		if (cursor < ss.length())
		{
			ss.erase(cursor, 1);
		}
	}
	
	if (input->GetKeyState(GSK_LEFT) == GSKS_HIT)
	{
		if (cursor > 0)
			cursor--;
	}
	if (input->GetKeyState(GSK_RIGHT) == GSKS_HIT)
	{
		cursor = Min(++cursor, static_cast<unsigned int>(ss.length()));
	}
	if (input->GetKeyState(GSK_END) == GSKS_HIT)
	{
		SendCursorToEnd();
	}

	const Vector2 cursorPosition = video->ComputeCarretPosition(font, ss, cursor);
	video->DrawBitmapText(pos, ss, font, dwColor);
	if (showingCarret==1)
		video->DrawRectangle(cursorPosition+pos-Vector2(2,0), Vector2(2,size), gs2d::constant::BLACK, gs2d::constant::BLACK, gs2d::constant::BLACK, gs2d::constant::BLACK, 0.0f);
}