Esempio n. 1
0
void PopupScreen::CreateViews() {
	using namespace UI;

	UIContext &dc = *screenManager()->getUIContext();

	AnchorLayout *anchor = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
	anchor->Overflow(false);
	root_ = anchor;

	float yres = screenManager()->getUIContext()->GetBounds().h;

	box_ = new LinearLayout(ORIENT_VERTICAL,
		new AnchorLayoutParams(550, FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), dc.GetBounds().centerY(), NONE, NONE, true));

	root_->Add(box_);
	box_->SetBG(UI::Drawable(0xFF303030));
	box_->SetHasDropShadow(true);

	View *title = new PopupHeader(title_);
	box_->Add(title);

	CreatePopupContents(box_);
	root_->SetDefaultFocusView(box_);

	if (ShowButtons() && !button1_.empty()) {
		// And the two buttons at the bottom.
		LinearLayout *buttonRow = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(200, WRAP_CONTENT));
		buttonRow->SetSpacing(0);
		Margins buttonMargins(5, 5);

		// Adjust button order to the platform default.
#if defined(_WIN32)
		defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f, buttonMargins)));
		defaultButton_->OnClick.Handle(this, &PopupScreen::OnOK);
		if (!button2_.empty())
			buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f, buttonMargins)))->OnClick.Handle(this, &PopupScreen::OnCancel);
#else
		if (!button2_.empty())
			buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f)))->OnClick.Handle(this, &PopupScreen::OnCancel);
		defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f)));
		defaultButton_->OnClick.Handle(this, &PopupScreen::OnOK);
#endif

		box_->Add(buttonRow);
	}
}
Esempio n. 2
0
UI::ViewGroup *CreatePadLayout(bool *pause) {
	//standard coord system

	using namespace UI;

	AnchorLayout *root = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));

	//PSP buttons (triangle, circle, square, cross)---------------------
	//space between the PSP buttons (traingle, circle, square and cross)
	const int Action_button_spacing = g_Config.iActionButtonSpacing;
	//position of the circle button (the PSP circle button). It is the farthest to the left
	int Action_button_center_X = g_Config.iActionButtonCenterX;
	int Action_button_center_Y = g_Config.iActionButtonCenterY;

	const int Action_circle_button_X = Action_button_center_X + Action_button_spacing;
	const int Action_circle_button_Y = Action_button_center_Y;

	const int Action_cross_button_X = Action_button_center_X;
	const int Action_cross_button_Y =  Action_button_center_Y + Action_button_spacing;

	const int Action_triangle_button_X = Action_button_center_X;
	const int Action_triangle_button_Y = Action_button_center_Y - Action_button_spacing;

	const int Action_square_button_X = Action_button_center_X - Action_button_spacing;
	const int Action_square_button_Y = Action_button_center_Y;

	//D-PAD (up down left right) (aka PSP cross)--------------------------------------------------------------
	//radius to the D-pad
	const int D_pad_Radius = g_Config.iDpadRadius;

	int D_pad_X = g_Config.iDpadX;
	int D_pad_Y = g_Config.iDpadY;

	//select, start, throttle--------------------------------------------
	//space between the bottom keys (space between select, start and un-throttle)
	int start_key_X = g_Config.iStartKeyX;
	int start_key_Y = g_Config.iStartKeyY;

	int select_key_X = g_Config.iSelectKeyX;
	int select_key_Y = g_Config.iSelectKeyY;

	int unthrottle_key_X = g_Config.iUnthrottleKeyX;
	int unthrottle_key_Y = g_Config.iUnthrottleKeyY;

	//L and R------------------------------------------------------------
	int l_key_X = g_Config.iLKeyX;
	int l_key_Y = g_Config.iLKeyY;

	int r_key_X = g_Config.iRKeyX;
	int r_key_Y = g_Config.iRKeyY;

	
	//analog stick-------------------------------------------------------
	int analog_stick_X = g_Config.iAnalogStickX;
	int analog_stick_Y = g_Config.iAnalogStickY;
	
	const int halfW = dp_xres / 2;

	if (g_Config.bShowTouchControls) {
		float scale = g_Config.fButtonScale;

#if USE_PAUSE_BUTTON
		root->Add(new BoolButton(pause, I_ROUND, I_ARROW, scale, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90);
#endif
		if (g_Config.bShowTouchCircle)
		root->Add(new PSPButton(CTRL_CIRCLE, I_ROUND, I_CIRCLE, scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchCross)
			root->Add(new PSPButton(CTRL_CROSS, I_ROUND, I_CROSS, scale, new AnchorLayoutParams(Action_cross_button_X, Action_cross_button_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchTriangle)
			root->Add(new PSPButton(CTRL_TRIANGLE, I_ROUND, I_TRIANGLE, scale, new AnchorLayoutParams(Action_triangle_button_X, Action_triangle_button_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchSquare)
			root->Add(new PSPButton(CTRL_SQUARE, I_ROUND, I_SQUARE, scale, new AnchorLayoutParams(Action_square_button_X, Action_square_button_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchStart)
			root->Add(new PSPButton(CTRL_START, I_RECT, I_START, scale, new AnchorLayoutParams(start_key_X, start_key_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchSelect)
			root->Add(new PSPButton(CTRL_SELECT, I_RECT, I_SELECT, scale, new AnchorLayoutParams(select_key_X, select_key_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchUnthrottle)
			root->Add(new BoolButton(&PSP_CoreParameter().unthrottle, I_RECT, I_ARROW, scale, new AnchorLayoutParams(unthrottle_key_X, unthrottle_key_Y, NONE, NONE, true)))->SetAngle(180);

		if (g_Config.bShowTouchLTrigger)
			root->Add(new PSPButton(CTRL_LTRIGGER, I_SHOULDER, I_L, scale, new AnchorLayoutParams(l_key_X, l_key_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchRTrigger)
			root->Add(new PSPButton(CTRL_RTRIGGER, I_SHOULDER, I_R, scale, new AnchorLayoutParams(r_key_X,r_key_Y, NONE, NONE, true)))->FlipImageH(true);

		if (g_Config.bShowTouchDpad)
			root->Add(new PSPCross(I_DIR, I_ARROW, scale, D_pad_Radius, new AnchorLayoutParams(D_pad_X, D_pad_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchAnalogStick)
			root->Add(new PSPStick(I_STICKBG, I_STICK, 0, scale, new AnchorLayoutParams(analog_stick_X, analog_stick_Y, NONE, NONE, true)));
	}

	return root;
}
Esempio n. 3
0
UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause) {
	//standard coord system

	using namespace UI;

	AnchorLayout *root = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
	
	//PSP buttons (triangle, circle, square, cross)---------------------
	//space between the PSP buttons (traingle, circle, square and cross)
	const float Action_button_scale = g_Config.fActionButtonScale;
	const float Action_button_spacing = g_Config.fActionButtonSpacing * baseActionButtonSpacing;
	//position of the circle button (the PSP circle button). It is the farthest to the left
	float Action_button_center_X = g_Config.fActionButtonCenterX * xres;
	float Action_button_center_Y = g_Config.fActionButtonCenterY * yres;

	const float Action_circle_button_X = Action_button_center_X + Action_button_spacing;
	const float Action_circle_button_Y = Action_button_center_Y;

	const float Action_cross_button_X = Action_button_center_X;
	const float Action_cross_button_Y =  Action_button_center_Y + Action_button_spacing;

	const float Action_triangle_button_X = Action_button_center_X;
	const float Action_triangle_button_Y = Action_button_center_Y - Action_button_spacing;

	const float Action_square_button_X = Action_button_center_X - Action_button_spacing;
	const float Action_square_button_Y = Action_button_center_Y;

	//D-PAD (up down left right) (aka PSP cross)--------------------------------------------------------------
	//radius to the D-pad

	float D_pad_X = g_Config.fDpadX * xres;
	float D_pad_Y = g_Config.fDpadY * yres;
	float D_pad_scale = g_Config.fDpadScale;
	float D_pad_spacing = g_Config.fDpadSpacing;

	//select, start, throttle--------------------------------------------
	//space between the bottom keys (space between select, start and un-throttle)
	float start_key_X = g_Config.fStartKeyX * xres;
	float start_key_Y = g_Config.fStartKeyY * yres;
	float start_key_scale = g_Config.fStartKeyScale;

	float select_key_X = g_Config.fSelectKeyX * xres;
	float select_key_Y = g_Config.fSelectKeyY * yres;
	float select_key_scale = g_Config.fSelectKeyScale;

	float unthrottle_key_X = g_Config.fUnthrottleKeyX * xres;
	float unthrottle_key_Y = g_Config.fUnthrottleKeyY * yres;
	float unthrottle_key_scale = g_Config.fUnthrottleKeyScale;

	//L and R------------------------------------------------------------
	float l_key_X = g_Config.fLKeyX * xres;
	float l_key_Y = g_Config.fLKeyY * yres;
	float l_key_scale = g_Config.fLKeyScale;

	float r_key_X = g_Config.fRKeyX * xres;
	float r_key_Y = g_Config.fRKeyY * yres;
	float r_key_scale = g_Config.fRKeyScale;

	//analog stick-------------------------------------------------------
	float analog_stick_X = g_Config.fAnalogStickX * xres;
	float analog_stick_Y = g_Config.fAnalogStickY * yres;
	float analog_stick_scale = g_Config.fAnalogStickScale;

	const int halfW = xres / 2;

	if (g_Config.bShowTouchControls) {
		int roundImage = g_Config.iTouchButtonStyle ? I_ROUND_LINE : I_ROUND;
		int rectImage = g_Config.iTouchButtonStyle ? I_RECT_LINE : I_RECT;
		int shoulderImage = g_Config.iTouchButtonStyle ? I_SHOULDER_LINE : I_SHOULDER;
		int dirImage = g_Config.iTouchButtonStyle ? I_DIR_LINE : I_DIR;
		int stickImage = g_Config.iTouchButtonStyle ? I_STICK_LINE : I_STICK;
		int stickBg = g_Config.iTouchButtonStyle ? I_STICK_BG_LINE : I_STICK_BG;

#if USE_PAUSE_BUTTON
		root->Add(new BoolButton(pause, roundImage, I_ARROW, 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90);
#endif
		if (g_Config.bShowTouchCircle)
		root->Add(new PSPButton(CTRL_CIRCLE, roundImage, I_CIRCLE, Action_button_scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchCross)
			root->Add(new PSPButton(CTRL_CROSS, roundImage, I_CROSS, Action_button_scale, new AnchorLayoutParams(Action_cross_button_X, Action_cross_button_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchTriangle)
			root->Add(new PSPButton(CTRL_TRIANGLE, roundImage, I_TRIANGLE, Action_button_scale, new AnchorLayoutParams(Action_triangle_button_X, Action_triangle_button_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchSquare)
			root->Add(new PSPButton(CTRL_SQUARE, roundImage, I_SQUARE, Action_button_scale, new AnchorLayoutParams(Action_square_button_X, Action_square_button_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchStart)
			root->Add(new PSPButton(CTRL_START, rectImage, I_START, start_key_scale, new AnchorLayoutParams(start_key_X, start_key_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchSelect)
			root->Add(new PSPButton(CTRL_SELECT, rectImage, I_SELECT, select_key_scale, new AnchorLayoutParams(select_key_X, select_key_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchUnthrottle)
			root->Add(new BoolButton(&PSP_CoreParameter().unthrottle, rectImage, I_ARROW, unthrottle_key_scale, new AnchorLayoutParams(unthrottle_key_X, unthrottle_key_Y, NONE, NONE, true)))->SetAngle(180);

		if (g_Config.bShowTouchLTrigger)
			root->Add(new PSPButton(CTRL_LTRIGGER, shoulderImage, I_L, l_key_scale, new AnchorLayoutParams(l_key_X, l_key_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchRTrigger)
			root->Add(new PSPButton(CTRL_RTRIGGER, shoulderImage, I_R, r_key_scale, new AnchorLayoutParams(r_key_X,r_key_Y, NONE, NONE, true)))->FlipImageH(true);

		if (g_Config.bShowTouchDpad)
			root->Add(new PSPDpad(dirImage, I_ARROW, D_pad_scale, D_pad_spacing, new AnchorLayoutParams(D_pad_X, D_pad_Y, NONE, NONE, true)));

		if (g_Config.bShowTouchAnalogStick)
			root->Add(new PSPStick(stickBg, stickImage, 0, analog_stick_scale, new AnchorLayoutParams(analog_stick_X, analog_stick_Y, NONE, NONE, true)));
	}

	return root;
}