mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
UI: Add text description for all views.
This commit is contained in:
parent
7c72fe7110
commit
3c778f567c
@ -655,7 +655,7 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
char temp[64];
|
||||
sprintf(temp, "%d", sliderValue_);
|
||||
edit_ = new TextEdit(temp, "", new LinearLayoutParams(10.0f));
|
||||
edit_ = new TextEdit(temp, Title(), "", new LinearLayoutParams(10.0f));
|
||||
edit_->SetMaxLen(16);
|
||||
edit_->SetTextColor(dc.theme->popupStyle.fgColor);
|
||||
edit_->SetTextAlign(FLAG_DYNAMIC_ASCII);
|
||||
@ -689,7 +689,7 @@ void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
char temp[64];
|
||||
sprintf(temp, "%0.3f", sliderValue_);
|
||||
edit_ = new TextEdit(temp, "", new LinearLayoutParams(10.0f));
|
||||
edit_ = new TextEdit(temp, Title(), "", new LinearLayoutParams(10.0f));
|
||||
edit_->SetMaxLen(16);
|
||||
edit_->SetTextColor(dc.theme->popupStyle.fgColor);
|
||||
edit_->SetTextAlign(FLAG_DYNAMIC_ASCII);
|
||||
@ -818,7 +818,7 @@ void TextEditPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
textEditValue_ = *value_;
|
||||
LinearLayout *lin = parent->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams((UI::Size)300, WRAP_CONTENT)));
|
||||
edit_ = new TextEdit(textEditValue_, placeholder_, new LinearLayoutParams(1.0f));
|
||||
edit_ = new TextEdit(textEditValue_, Title(), placeholder_, new LinearLayoutParams(1.0f));
|
||||
edit_->SetMaxLen(maxLen_);
|
||||
edit_->SetTextColor(dc.theme->popupStyle.fgColor);
|
||||
lin->Add(edit_);
|
||||
|
@ -88,6 +88,7 @@ protected:
|
||||
virtual bool ShowButtons() const { return true; }
|
||||
virtual bool CanComplete(DialogResult result) { return true; }
|
||||
virtual void OnCompleted(DialogResult result) {}
|
||||
const std::string &Title() { return title_; }
|
||||
|
||||
virtual void update() override;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "Common/Render/DrawBuffer.h"
|
||||
#include "Common/Render/TextureAtlas.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/UI/UI.h"
|
||||
#include "Common/UI/View.h"
|
||||
#include "Common/UI/Context.h"
|
||||
@ -513,6 +514,11 @@ void Choice::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Choice::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 choice"), "%1", text_);
|
||||
}
|
||||
|
||||
InfoItem::InfoItem(const std::string &text, const std::string &rightText, LayoutParams *layoutParams)
|
||||
: Item(layoutParams), text_(text), rightText_(rightText) {
|
||||
// We set the colors later once we have a UIContext.
|
||||
@ -547,6 +553,11 @@ void InfoItem::Draw(UIContext &dc) {
|
||||
// dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y + 2, dc.theme->itemDownStyle.bgColor);
|
||||
}
|
||||
|
||||
std::string InfoItem::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(ReplaceAll(u->T("%1: %2"), "%1", text_), "%2", rightText_);
|
||||
}
|
||||
|
||||
ItemHeader::ItemHeader(const std::string &text, LayoutParams *layoutParams)
|
||||
: Item(layoutParams), text_(text) {
|
||||
layoutParams_->width = FILL_PARENT;
|
||||
@ -572,6 +583,11 @@ void ItemHeader::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec hor
|
||||
dc.MeasureTextRect(dc.theme->uiFontSmall, 1.0f, 1.0f, text_.c_str(), (int)text_.length(), bounds, &w, &h, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
}
|
||||
|
||||
std::string ItemHeader::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 heading"), "%1", text_);
|
||||
}
|
||||
|
||||
void PopupHeader::Draw(UIContext &dc) {
|
||||
const float paddingHorizontal = 12;
|
||||
const float availableWidth = bounds_.w - paddingHorizontal * 2;
|
||||
@ -600,6 +616,11 @@ void PopupHeader::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string PopupHeader::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 heading"), "%1", text_);
|
||||
}
|
||||
|
||||
void CheckBox::Toggle() {
|
||||
if (toggle_) {
|
||||
*toggle_ = !(*toggle_);
|
||||
@ -642,6 +663,15 @@ void CheckBox::Draw(UIContext &dc) {
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
|
||||
std::string CheckBox::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
std::string text = ReplaceAll(u->T("%1 checkbox"), "%1", text_);
|
||||
if (!smallText_.empty()) {
|
||||
text += "\n" + smallText_;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
float CheckBox::CalculateTextScale(const UIContext &dc, float availWidth) const {
|
||||
float actualWidth, actualHeight;
|
||||
Bounds availBounds(0, 0, availWidth, bounds_.h);
|
||||
@ -705,6 +735,11 @@ void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const
|
||||
h *= scale_;
|
||||
}
|
||||
|
||||
std::string Button::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 button"), "%1", GetText());
|
||||
}
|
||||
|
||||
void Button::Click() {
|
||||
Clickable::Click();
|
||||
UI::PlayUISound(UI::UISound::CONFIRM);
|
||||
@ -812,8 +847,8 @@ void TextView::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
TextEdit::TextEdit(const std::string &text, const std::string &placeholderText, LayoutParams *layoutParams)
|
||||
: View(layoutParams), text_(text), undo_(text), placeholderText_(placeholderText),
|
||||
TextEdit::TextEdit(const std::string &text, const std::string &title, const std::string &placeholderText, LayoutParams *layoutParams)
|
||||
: View(layoutParams), text_(text), title_(title), undo_(text), placeholderText_(placeholderText),
|
||||
textColor_(0xFFFFFFFF), maxLen_(255) {
|
||||
caret_ = (int)text_.size();
|
||||
}
|
||||
@ -861,6 +896,11 @@ void TextEdit::GetContentDimensions(const UIContext &dc, float &w, float &h) con
|
||||
h += 2;
|
||||
}
|
||||
|
||||
std::string TextEdit::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 text field"), "%1", GetText());
|
||||
}
|
||||
|
||||
// Handles both windows and unix line endings.
|
||||
static std::string FirstLine(const std::string &text) {
|
||||
size_t pos = text.find("\r\n");
|
||||
@ -1037,6 +1077,12 @@ void ProgressBar::Draw(UIContext &dc) {
|
||||
dc.DrawTextRect(temp, bounds_, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
}
|
||||
|
||||
std::string ProgressBar::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
float percent = progress_ * 100.0f;
|
||||
return ReplaceAll(u->T("Progress: %1%"), "%1", StringFromInt((int)percent));
|
||||
}
|
||||
|
||||
void Spinner::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
w = 48;
|
||||
h = 48;
|
||||
@ -1181,6 +1227,12 @@ void Slider::Draw(UIContext &dc) {
|
||||
dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), dc.theme->popupStyle.fgColor, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
|
||||
std::string Slider::DescribeText() const {
|
||||
if (showPercent_)
|
||||
return StringFromFormat("%i%% / %i%%", *value_, maxValue_);
|
||||
return StringFromFormat("%i / %i", *value_, maxValue_);
|
||||
}
|
||||
|
||||
void Slider::Update() {
|
||||
View::Update();
|
||||
if (repeat_ >= 0) {
|
||||
@ -1291,6 +1343,10 @@ void SliderFloat::Draw(UIContext &dc) {
|
||||
dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), dc.theme->popupStyle.fgColor, ALIGN_CENTER);
|
||||
}
|
||||
|
||||
std::string SliderFloat::DescribeText() const {
|
||||
return StringFromFormat("%0.2f / %0.2f", *value_, maxValue_);
|
||||
}
|
||||
|
||||
void SliderFloat::Update() {
|
||||
View::Update();
|
||||
if (repeat_ >= 0) {
|
||||
|
@ -366,6 +366,8 @@ public:
|
||||
// If this view covers these coordinates, it should add itself and its children to the list.
|
||||
virtual void Query(float x, float y, std::vector<View *> &list);
|
||||
virtual std::string DescribeLog() const;
|
||||
// Accessible/searchable description.
|
||||
virtual std::string DescribeText() const { return ""; }
|
||||
|
||||
virtual void FocusChanged(int focusFlags) {}
|
||||
virtual void PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
|
||||
@ -523,6 +525,7 @@ public:
|
||||
void Draw(UIContext &dc) override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
const std::string &GetText() const { return text_; }
|
||||
std::string DescribeText() const override;
|
||||
void SetPadding(int w, int h) {
|
||||
paddingW_ = w;
|
||||
paddingH_ = h;
|
||||
@ -555,6 +558,7 @@ public:
|
||||
step_ = step <= 0 ? 1 : step;
|
||||
}
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
bool Key(const KeyInput &input) override;
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Update() override;
|
||||
@ -585,6 +589,7 @@ public:
|
||||
SliderFloat(float *value, float minValue, float maxValue, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), paddingLeft_(5), paddingRight_(70), repeat_(-1) {}
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
bool Key(const KeyInput &input) override;
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Update() override;
|
||||
@ -661,6 +666,7 @@ public:
|
||||
virtual void HighlightChanged(bool highlighted);
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
virtual void SetCentered(bool c) {
|
||||
centered_ = c;
|
||||
}
|
||||
@ -711,6 +717,7 @@ public:
|
||||
InfoItem(const std::string &text, const std::string &rightText, LayoutParams *layoutParams = nullptr);
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
|
||||
// These are focusable so that long lists of them can be keyboard scrolled.
|
||||
bool CanBeFocused() const override { return true; }
|
||||
@ -737,6 +744,7 @@ class ItemHeader : public Item {
|
||||
public:
|
||||
ItemHeader(const std::string &text, LayoutParams *layoutParams = 0);
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
|
||||
private:
|
||||
@ -751,6 +759,8 @@ public:
|
||||
layoutParams_->height = 64;
|
||||
}
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
|
||||
private:
|
||||
std::string text_;
|
||||
};
|
||||
@ -763,6 +773,7 @@ public:
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
|
||||
EventReturn OnClicked(EventParams &e);
|
||||
@ -803,6 +814,8 @@ public:
|
||||
w = size_; h = size_;
|
||||
}
|
||||
void Draw(UIContext &dc) override {}
|
||||
std::string DescribeText() const override { return ""; }
|
||||
|
||||
private:
|
||||
float size_;
|
||||
};
|
||||
@ -820,6 +833,7 @@ public:
|
||||
|
||||
void SetText(const std::string &text) { text_ = text; }
|
||||
const std::string &GetText() const { return text_; }
|
||||
std::string DescribeText() const override { return GetText(); }
|
||||
void SetSmall(bool small) { small_ = small; }
|
||||
void SetTextColor(uint32_t color) { textColor_ = color; hasTextColor_ = true; }
|
||||
void SetShadow(bool shadow) { shadow_ = shadow; }
|
||||
@ -841,7 +855,7 @@ private:
|
||||
|
||||
class TextEdit : public View {
|
||||
public:
|
||||
TextEdit(const std::string &text, const std::string &placeholderText, LayoutParams *layoutParams = 0);
|
||||
TextEdit(const std::string &text, const std::string &title, const std::string &placeholderText, LayoutParams *layoutParams = nullptr);
|
||||
void SetText(const std::string &text) { text_ = text; scrollPos_ = 0; caret_ = (int)text_.size(); }
|
||||
void SetTextColor(uint32_t color) { textColor_ = color; hasTextColor_ = true; }
|
||||
const std::string &GetText() const { return text_; }
|
||||
@ -850,6 +864,7 @@ public:
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
bool Key(const KeyInput &key) override;
|
||||
void Touch(const TouchInput &touch) override;
|
||||
|
||||
@ -860,6 +875,7 @@ private:
|
||||
void InsertAtCaret(const char *text);
|
||||
|
||||
std::string text_;
|
||||
std::string title_;
|
||||
std::string undo_;
|
||||
std::string placeholderText_;
|
||||
uint32_t textColor_;
|
||||
@ -880,13 +896,15 @@ enum ImageSizeMode {
|
||||
|
||||
class ImageView : public InertView {
|
||||
public:
|
||||
ImageView(ImageID atlasImage, ImageSizeMode sizeMode, LayoutParams *layoutParams = 0)
|
||||
: InertView(layoutParams), atlasImage_(atlasImage), sizeMode_(sizeMode) {}
|
||||
ImageView(ImageID atlasImage, const std::string &text, ImageSizeMode sizeMode, LayoutParams *layoutParams = 0)
|
||||
: InertView(layoutParams), text_(text), atlasImage_(atlasImage), sizeMode_(sizeMode) {}
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return text_; }
|
||||
|
||||
private:
|
||||
std::string text_;
|
||||
ImageID atlasImage_;
|
||||
ImageSizeMode sizeMode_;
|
||||
};
|
||||
@ -898,6 +916,7 @@ public:
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
|
||||
void SetProgress(float progress) {
|
||||
if (progress > 1.0f) {
|
||||
@ -922,6 +941,7 @@ public:
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return ""; }
|
||||
void SetColor(uint32_t color) { color_ = color; }
|
||||
|
||||
private:
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
#include "Common/Input/KeyCodes.h"
|
||||
#include "Common/Math/curves.h"
|
||||
@ -154,6 +155,18 @@ void ViewGroup::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string ViewGroup::DescribeText() const {
|
||||
std::stringstream ss;
|
||||
// TODO: In some cases, might be nice to define as a list explicitly.
|
||||
for (size_t i = 0; i < views_.size(); ++i) {
|
||||
if (i != 0) {
|
||||
ss << "\n";
|
||||
}
|
||||
ss << views_[i]->DescribeText();
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void ViewGroup::Update() {
|
||||
View::Update();
|
||||
for (View *view : views_) {
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
|
||||
void SetClip(bool clip) { clip_ = clip; }
|
||||
std::string DescribeLog() const override { return "ViewGroup: " + View::DescribeLog(); }
|
||||
std::string DescribeText() const override;
|
||||
|
||||
protected:
|
||||
std::mutex modifyLock_; // Hold this when changing the subviews.
|
||||
|
@ -22,7 +22,7 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0)));
|
||||
LinearLayout *bottom = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || defined(SDL)
|
||||
chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat Here"), new LinearLayoutParams(1.0)));
|
||||
chatEdit_ = bottom->Add(new TextEdit("", n->T("Chat message"), n->T("Chat Here"), new LinearLayoutParams(1.0)));
|
||||
#if defined(USING_WIN_UI)
|
||||
// freeze the ui when using ctrl + C hotkey need workaround
|
||||
if (g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen) {
|
||||
|
@ -434,6 +434,7 @@ public:
|
||||
xAxis_(xAxis), xDir_(xDir),
|
||||
yAxis_(yAxis), yDir_(yDir) {}
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return ""; }
|
||||
void Update() override;
|
||||
void Axis(const AxisInput &input) override {
|
||||
// TODO: Check input.deviceId?
|
||||
|
@ -207,7 +207,7 @@ void LogScreen::CreateViews() {
|
||||
scroll_ = outer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0)));
|
||||
LinearLayout *bottom = outer->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
bottom->Add(new Button(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
cmdLine_ = bottom->Add(new TextEdit("", "Command Line", new LinearLayoutParams(1.0)));
|
||||
cmdLine_ = bottom->Add(new TextEdit("", "Command", "Command Line", new LinearLayoutParams(1.0)));
|
||||
cmdLine_->OnEnter.Handle(this, &LogScreen::OnSubmit);
|
||||
bottom->Add(new Button(di->T("Submit")))->OnClick.Handle(this, &LogScreen::OnSubmit);
|
||||
|
||||
@ -805,7 +805,7 @@ void JitCompareScreen::CreateViews() {
|
||||
leftColumn->Add(new Choice(dev->T("Stats")))->OnClick.Handle(this, &JitCompareScreen::OnShowStats);
|
||||
leftColumn->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
blockName_ = leftColumn->Add(new TextView(dev->T("No block")));
|
||||
blockAddr_ = leftColumn->Add(new TextEdit("", "", new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
blockAddr_ = leftColumn->Add(new TextEdit("", dev->T("Block address"), "", new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
blockAddr_->OnTextChange.Handle(this, &JitCompareScreen::OnAddressChange);
|
||||
blockStats_ = leftColumn->Add(new TextView(""));
|
||||
|
||||
|
@ -65,7 +65,9 @@ public:
|
||||
: MultiTouchDisplay(img, scale, new UI::AnchorLayoutParams(x * screenBounds.w, y * screenBounds.h, UI::NONE, UI::NONE, true)),
|
||||
x_(x), y_(y), screenBounds_(screenBounds) {
|
||||
UpdateScale(scale);
|
||||
}
|
||||
}
|
||||
|
||||
std::string DescribeText() const override;
|
||||
|
||||
void SaveDisplayPosition() {
|
||||
x_ = bounds_.centerX() / screenBounds_.w;
|
||||
@ -84,6 +86,11 @@ private:
|
||||
const Bounds &screenBounds_;
|
||||
};
|
||||
|
||||
std::string DragDropDisplay::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return u->T("Screen representation");
|
||||
}
|
||||
|
||||
DisplayLayoutScreen::DisplayLayoutScreen() {
|
||||
// Ignore insets - just couldn't get the logic to work.
|
||||
ignoreInsets_ = true;
|
||||
@ -219,6 +226,10 @@ public:
|
||||
Boundary(UI::LayoutParams *layoutParams) : UI::View(layoutParams) {
|
||||
}
|
||||
|
||||
std::string DescribeText() const override {
|
||||
return "";
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc) override {
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y2(), dc.theme->itemDownStyle.background.color);
|
||||
}
|
||||
|
@ -1002,6 +1002,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string DescribeText() const override {
|
||||
return "";
|
||||
}
|
||||
|
||||
void SetColor(uint32_t c) {
|
||||
color_ = c;
|
||||
}
|
||||
|
@ -1803,7 +1803,7 @@ void HostnameSelectScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
LinearLayout *valueRow = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, Margins(0, 0, 0, 10)));
|
||||
|
||||
addrView_ = new TextEdit(*value_, "");
|
||||
addrView_ = new TextEdit(*value_, n->T("Hostname"), "");
|
||||
addrView_->SetTextAlign(FLAG_DYNAMIC_ASCII);
|
||||
valueRow->Add(addrView_);
|
||||
parent->Add(valueRow);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common/Data/Color/RGBAUtil.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/Render/TextureAtlas.h"
|
||||
@ -36,7 +37,7 @@ static u32 GetButtonColor() {
|
||||
return g_Config.iTouchButtonStyle != 0 ? 0xFFFFFF : 0xc0b080;
|
||||
}
|
||||
|
||||
GamepadView::GamepadView(UI::LayoutParams *layoutParams) : UI::View(layoutParams) {
|
||||
GamepadView::GamepadView(const char *key, UI::LayoutParams *layoutParams) : UI::View(layoutParams), key_(key) {
|
||||
lastFrameTime_ = time_now_d();
|
||||
}
|
||||
|
||||
@ -53,6 +54,11 @@ void GamepadView::Update() {
|
||||
lastFrameTime_ = now;
|
||||
}
|
||||
|
||||
std::string GamepadView::DescribeText() const {
|
||||
auto co = GetI18NCategory("Controls");
|
||||
return co->T(key_);
|
||||
}
|
||||
|
||||
float GamepadView::GetButtonOpacity() {
|
||||
if (coreState != CORE_RUNNING) {
|
||||
return 0.0f;
|
||||
@ -262,8 +268,8 @@ bool PSPButton::IsDown() {
|
||||
return (__CtrlPeekButtons() & pspButtonBit_) != 0;
|
||||
}
|
||||
|
||||
PSPDpad::PSPDpad(ImageID arrowIndex, ImageID arrowDownIndex, ImageID overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams)
|
||||
: GamepadView(layoutParams), arrowIndex_(arrowIndex), arrowDownIndex_(arrowDownIndex), overlayIndex_(overlayIndex),
|
||||
PSPDpad::PSPDpad(ImageID arrowIndex, const char *key, ImageID arrowDownIndex, ImageID overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams)
|
||||
: GamepadView(key, layoutParams), arrowIndex_(arrowIndex), arrowDownIndex_(arrowDownIndex), overlayIndex_(overlayIndex),
|
||||
scale_(scale), spacing_(spacing), dragPointerId_(-1), down_(0) {
|
||||
}
|
||||
|
||||
@ -391,8 +397,8 @@ void PSPDpad::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
PSPStick::PSPStick(ImageID bgImg, ImageID stickImg, ImageID stickDownImg, int stick, float scale, UI::LayoutParams *layoutParams)
|
||||
: GamepadView(layoutParams), dragPointerId_(-1), bgImg_(bgImg), stickImageIndex_(stickImg), stickDownImg_(stickDownImg), stick_(stick), scale_(scale), centerX_(-1), centerY_(-1) {
|
||||
PSPStick::PSPStick(ImageID bgImg, const char *key, ImageID stickImg, ImageID stickDownImg, int stick, float scale, UI::LayoutParams *layoutParams)
|
||||
: GamepadView(key, layoutParams), dragPointerId_(-1), bgImg_(bgImg), stickImageIndex_(stickImg), stickDownImg_(stickDownImg), stick_(stick), scale_(scale), centerX_(-1), centerY_(-1) {
|
||||
stick_size_ = 50;
|
||||
}
|
||||
|
||||
@ -494,8 +500,8 @@ void PSPStick::ProcessTouch(float x, float y, bool down) {
|
||||
}
|
||||
}
|
||||
|
||||
PSPCustomStick::PSPCustomStick(ImageID bgImg, ImageID stickImg, ImageID stickDownImg, float scale, UI::LayoutParams *layoutParams)
|
||||
: PSPStick(bgImg, stickImg, stickDownImg, -1, scale, layoutParams) {
|
||||
PSPCustomStick::PSPCustomStick(ImageID bgImg, const char *key, ImageID stickImg, ImageID stickDownImg, float scale, UI::LayoutParams *layoutParams)
|
||||
: PSPStick(bgImg, key, stickImg, stickDownImg, -1, scale, layoutParams) {
|
||||
}
|
||||
|
||||
void PSPCustomStick::Draw(UIContext &dc) {
|
||||
@ -769,49 +775,49 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause) {
|
||||
const ImageID stickBg = g_Config.iTouchButtonStyle ? ImageID("I_STICK_BG_LINE") : ImageID("I_STICK_BG");
|
||||
static const ImageID comboKeyImages[5] = { ImageID("I_1"), ImageID("I_2"), ImageID("I_3"), ImageID("I_4"), ImageID("I_5") };
|
||||
|
||||
auto addPSPButton = [=](int buttonBit, ImageID bgImg, ImageID bgDownImg, ImageID img, const ConfigTouchPos &touch, ButtonOffset off = { 0, 0 }) -> PSPButton * {
|
||||
auto addPSPButton = [=](int buttonBit, const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, const ConfigTouchPos &touch, ButtonOffset off = { 0, 0 }) -> PSPButton * {
|
||||
if (touch.show) {
|
||||
return root->Add(new PSPButton(buttonBit, bgImg, bgDownImg, img, touch.scale, buttonLayoutParams(touch, off)));
|
||||
return root->Add(new PSPButton(buttonBit, key, bgImg, bgDownImg, img, touch.scale, buttonLayoutParams(touch, off)));
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
auto addComboKey = [=](int buttonBit, bool toggle, ImageID bgImg, ImageID bgDownImg, ImageID img, const ConfigTouchPos &touch) -> ComboKey * {
|
||||
auto addComboKey = [=](int buttonBit, const char *key, bool toggle, ImageID bgImg, ImageID bgDownImg, ImageID img, const ConfigTouchPos &touch) -> ComboKey * {
|
||||
if (touch.show) {
|
||||
return root->Add(new ComboKey(buttonBit, toggle, bgImg, bgDownImg, img, touch.scale, buttonLayoutParams(touch)));
|
||||
return root->Add(new ComboKey(buttonBit, key, toggle, bgImg, bgDownImg, img, touch.scale, buttonLayoutParams(touch)));
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
auto addBoolButton = [=](bool *value, ImageID bgImg, ImageID bgDownImg, ImageID img, const ConfigTouchPos &touch) -> BoolButton * {
|
||||
auto addBoolButton = [=](bool *value, const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, const ConfigTouchPos &touch) -> BoolButton * {
|
||||
if (touch.show) {
|
||||
return root->Add(new BoolButton(value, bgImg, bgDownImg, img, touch.scale, buttonLayoutParams(touch)));
|
||||
return root->Add(new BoolButton(value, key, bgImg, bgDownImg, img, touch.scale, buttonLayoutParams(touch)));
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
auto addFPSLimitButton = [=](FPSLimit value, ImageID bgImg, ImageID bgDownImg, ImageID img, const ConfigTouchPos &touch) -> FPSLimitButton * {
|
||||
auto addFPSLimitButton = [=](FPSLimit value, const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, const ConfigTouchPos &touch) -> FPSLimitButton * {
|
||||
if (touch.show) {
|
||||
return root->Add(new FPSLimitButton(value, bgImg, bgDownImg, img, touch.scale, buttonLayoutParams(touch)));
|
||||
return root->Add(new FPSLimitButton(value, key, bgImg, bgDownImg, img, touch.scale, buttonLayoutParams(touch)));
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
if (!System_GetPropertyBool(SYSPROP_HAS_BACK_BUTTON) || g_Config.bShowTouchPause) {
|
||||
root->Add(new BoolButton(pause, roundImage, ImageID("I_ROUND"), ImageID("I_ARROW"), 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90);
|
||||
root->Add(new BoolButton(pause, "Pause button", roundImage, ImageID("I_ROUND"), ImageID("I_ARROW"), 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90);
|
||||
}
|
||||
|
||||
// touchActionButtonCenter.show will always be true, since that's the default.
|
||||
if (g_Config.bShowTouchCircle)
|
||||
addPSPButton(CTRL_CIRCLE, roundImage, ImageID("I_ROUND"), ImageID("I_CIRCLE"), g_Config.touchActionButtonCenter, circleOffset);
|
||||
addPSPButton(CTRL_CIRCLE, "Circle button", roundImage, ImageID("I_ROUND"), ImageID("I_CIRCLE"), g_Config.touchActionButtonCenter, circleOffset);
|
||||
if (g_Config.bShowTouchCross)
|
||||
addPSPButton(CTRL_CROSS, roundImage, ImageID("I_ROUND"), ImageID("I_CROSS"), g_Config.touchActionButtonCenter, crossOffset);
|
||||
addPSPButton(CTRL_CROSS, "Cross button", roundImage, ImageID("I_ROUND"), ImageID("I_CROSS"), g_Config.touchActionButtonCenter, crossOffset);
|
||||
if (g_Config.bShowTouchTriangle)
|
||||
addPSPButton(CTRL_TRIANGLE, roundImage, ImageID("I_ROUND"), ImageID("I_TRIANGLE"), g_Config.touchActionButtonCenter, triangleOffset);
|
||||
addPSPButton(CTRL_TRIANGLE, "Triangle button", roundImage, ImageID("I_ROUND"), ImageID("I_TRIANGLE"), g_Config.touchActionButtonCenter, triangleOffset);
|
||||
if (g_Config.bShowTouchSquare)
|
||||
addPSPButton(CTRL_SQUARE, roundImage, ImageID("I_ROUND"), ImageID("I_SQUARE"), g_Config.touchActionButtonCenter, squareOffset);
|
||||
addPSPButton(CTRL_SQUARE, "Square button", roundImage, ImageID("I_ROUND"), ImageID("I_SQUARE"), g_Config.touchActionButtonCenter, squareOffset);
|
||||
|
||||
addPSPButton(CTRL_START, rectImage, ImageID("I_RECT"), ImageID("I_START"), g_Config.touchStartKey);
|
||||
addPSPButton(CTRL_SELECT, rectImage, ImageID("I_RECT"), ImageID("I_SELECT"), g_Config.touchSelectKey);
|
||||
addPSPButton(CTRL_START, "Start button", rectImage, ImageID("I_RECT"), ImageID("I_START"), g_Config.touchStartKey);
|
||||
addPSPButton(CTRL_SELECT, "Select button", rectImage, ImageID("I_RECT"), ImageID("I_SELECT"), g_Config.touchSelectKey);
|
||||
|
||||
BoolButton *unthrottle = addBoolButton(&PSP_CoreParameter().unthrottle, rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchUnthrottleKey);
|
||||
BoolButton *unthrottle = addBoolButton(&PSP_CoreParameter().unthrottle, "Unthrottle button", rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchUnthrottleKey);
|
||||
if (unthrottle) {
|
||||
unthrottle->SetAngle(180.0f);
|
||||
unthrottle->OnChange.Add([](UI::EventParams &e) {
|
||||
@ -823,50 +829,50 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause) {
|
||||
}
|
||||
|
||||
if (g_Config.touchRapidFireKey.show) {
|
||||
auto rapidFire = root->Add(new RapidFireButton(rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchRapidFireKey.scale, buttonLayoutParams(g_Config.touchRapidFireKey)));
|
||||
auto rapidFire = root->Add(new RapidFireButton("Rapid fire button", rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchRapidFireKey.scale, buttonLayoutParams(g_Config.touchRapidFireKey)));
|
||||
rapidFire->SetAngle(90.0f, 180.0f);
|
||||
}
|
||||
|
||||
if (g_Config.touchAnalogRotationCWKey.show) {
|
||||
auto analogRotationCC = root->Add(new AnalogRotationButton(true, rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchAnalogRotationCWKey.scale, buttonLayoutParams(g_Config.touchAnalogRotationCWKey)));
|
||||
auto analogRotationCC = root->Add(new AnalogRotationButton(true, "Analog clockwise rotation button", rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchAnalogRotationCWKey.scale, buttonLayoutParams(g_Config.touchAnalogRotationCWKey)));
|
||||
analogRotationCC->SetAngle(190.0f, 180.0f);
|
||||
}
|
||||
|
||||
if (g_Config.touchAnalogRotationCCWKey.show) {
|
||||
auto analogRotationCCW = root->Add(new AnalogRotationButton(false, rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchAnalogRotationCCWKey.scale, buttonLayoutParams(g_Config.touchAnalogRotationCCWKey)));
|
||||
auto analogRotationCCW = root->Add(new AnalogRotationButton(false, "Analog counter clockwise rotation button", rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchAnalogRotationCCWKey.scale, buttonLayoutParams(g_Config.touchAnalogRotationCCWKey)));
|
||||
analogRotationCCW->SetAngle(350.0f, 180.0f);
|
||||
}
|
||||
|
||||
FPSLimitButton *speed1 = addFPSLimitButton(FPSLimit::CUSTOM1, rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchSpeed1Key);
|
||||
FPSLimitButton *speed1 = addFPSLimitButton(FPSLimit::CUSTOM1, "Alternate speed 1 button", rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchSpeed1Key);
|
||||
if (speed1)
|
||||
speed1->SetAngle(170.0f, 180.0f);
|
||||
FPSLimitButton *speed2 = addFPSLimitButton(FPSLimit::CUSTOM2, rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchSpeed2Key);
|
||||
FPSLimitButton *speed2 = addFPSLimitButton(FPSLimit::CUSTOM2, "Alternate speed 2 button", rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchSpeed2Key);
|
||||
if (speed2)
|
||||
speed2->SetAngle(190.0f, 180.0f);
|
||||
|
||||
addPSPButton(CTRL_LTRIGGER, shoulderImage, ImageID("I_SHOULDER"), ImageID("I_L"), g_Config.touchLKey);
|
||||
PSPButton *rTrigger = addPSPButton(CTRL_RTRIGGER, shoulderImage, ImageID("I_SHOULDER"), ImageID("I_R"), g_Config.touchRKey);
|
||||
addPSPButton(CTRL_LTRIGGER, "Left shoulder button", shoulderImage, ImageID("I_SHOULDER"), ImageID("I_L"), g_Config.touchLKey);
|
||||
PSPButton *rTrigger = addPSPButton(CTRL_RTRIGGER, "Right shoulder button", shoulderImage, ImageID("I_SHOULDER"), ImageID("I_R"), g_Config.touchRKey);
|
||||
if (rTrigger)
|
||||
rTrigger->FlipImageH(true);
|
||||
|
||||
if (g_Config.touchDpad.show)
|
||||
root->Add(new PSPDpad(dirImage, ImageID("I_DIR"), ImageID("I_ARROW"), g_Config.touchDpad.scale, g_Config.fDpadSpacing, buttonLayoutParams(g_Config.touchDpad)));
|
||||
root->Add(new PSPDpad(dirImage, "D-pad", ImageID("I_DIR"), ImageID("I_ARROW"), g_Config.touchDpad.scale, g_Config.fDpadSpacing, buttonLayoutParams(g_Config.touchDpad)));
|
||||
|
||||
if (g_Config.touchAnalogStick.show)
|
||||
root->Add(new PSPStick(stickBg, stickImage, ImageID("I_STICK"), 0, g_Config.touchAnalogStick.scale, buttonLayoutParams(g_Config.touchAnalogStick)));
|
||||
root->Add(new PSPStick(stickBg, "Left analog stick", stickImage, ImageID("I_STICK"), 0, g_Config.touchAnalogStick.scale, buttonLayoutParams(g_Config.touchAnalogStick)));
|
||||
|
||||
if (g_Config.touchRightAnalogStick.show) {
|
||||
if (g_Config.bRightAnalogCustom)
|
||||
root->Add(new PSPCustomStick(stickBg, stickImage, ImageID("I_STICK"), g_Config.touchRightAnalogStick.scale, buttonLayoutParams(g_Config.touchRightAnalogStick)));
|
||||
root->Add(new PSPCustomStick(stickBg, "Right analog stick", stickImage, ImageID("I_STICK"), g_Config.touchRightAnalogStick.scale, buttonLayoutParams(g_Config.touchRightAnalogStick)));
|
||||
else
|
||||
root->Add(new PSPStick(stickBg, stickImage, ImageID("I_STICK"), 1, g_Config.touchRightAnalogStick.scale, buttonLayoutParams(g_Config.touchRightAnalogStick)));
|
||||
root->Add(new PSPStick(stickBg, "Right analog stick", stickImage, ImageID("I_STICK"), 1, g_Config.touchRightAnalogStick.scale, buttonLayoutParams(g_Config.touchRightAnalogStick)));
|
||||
}
|
||||
|
||||
addComboKey(g_Config.iCombokey0, g_Config.bComboToggle0, roundImage, ImageID("I_ROUND"), comboKeyImages[0], g_Config.touchCombo0);
|
||||
addComboKey(g_Config.iCombokey1, g_Config.bComboToggle1, roundImage, ImageID("I_ROUND"), comboKeyImages[1], g_Config.touchCombo1);
|
||||
addComboKey(g_Config.iCombokey2, g_Config.bComboToggle2, roundImage, ImageID("I_ROUND"), comboKeyImages[2], g_Config.touchCombo2);
|
||||
addComboKey(g_Config.iCombokey3, g_Config.bComboToggle3, roundImage, ImageID("I_ROUND"), comboKeyImages[3], g_Config.touchCombo3);
|
||||
addComboKey(g_Config.iCombokey4, g_Config.bComboToggle4, roundImage, ImageID("I_ROUND"), comboKeyImages[4], g_Config.touchCombo4);
|
||||
addComboKey(g_Config.iCombokey0, "Combo 1 button", g_Config.bComboToggle0, roundImage, ImageID("I_ROUND"), comboKeyImages[0], g_Config.touchCombo0);
|
||||
addComboKey(g_Config.iCombokey1, "Combo 2 button", g_Config.bComboToggle1, roundImage, ImageID("I_ROUND"), comboKeyImages[1], g_Config.touchCombo1);
|
||||
addComboKey(g_Config.iCombokey2, "Combo 3 button", g_Config.bComboToggle2, roundImage, ImageID("I_ROUND"), comboKeyImages[2], g_Config.touchCombo2);
|
||||
addComboKey(g_Config.iCombokey3, "Combo 4 button", g_Config.bComboToggle3, roundImage, ImageID("I_ROUND"), comboKeyImages[3], g_Config.touchCombo3);
|
||||
addComboKey(g_Config.iCombokey4, "Combo 5 button", g_Config.bComboToggle4, roundImage, ImageID("I_ROUND"), comboKeyImages[4], g_Config.touchCombo4);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
@ -26,25 +26,27 @@
|
||||
|
||||
class GamepadView : public UI::View {
|
||||
public:
|
||||
GamepadView(UI::LayoutParams *layoutParams);
|
||||
GamepadView(const char *key, UI::LayoutParams *layoutParams);
|
||||
|
||||
void Touch(const TouchInput &input) override;
|
||||
bool Key(const KeyInput &input) override {
|
||||
return false;
|
||||
}
|
||||
void Update() override;
|
||||
std::string DescribeText() const override;
|
||||
|
||||
protected:
|
||||
virtual float GetButtonOpacity();
|
||||
|
||||
const char *key_;
|
||||
double lastFrameTime_;
|
||||
float secondsWithoutTouch_ = 0.0;
|
||||
};
|
||||
|
||||
class MultiTouchButton : public GamepadView {
|
||||
public:
|
||||
MultiTouchButton(ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: GamepadView(layoutParams), scale_(scale), bgImg_(bgImg), bgDownImg_(bgDownImg), img_(img) {
|
||||
MultiTouchButton(const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: GamepadView(key, layoutParams), scale_(scale), bgImg_(bgImg), bgDownImg_(bgDownImg), img_(img) {
|
||||
}
|
||||
|
||||
void Touch(const TouchInput &input) override;
|
||||
@ -71,8 +73,8 @@ private:
|
||||
|
||||
class BoolButton : public MultiTouchButton {
|
||||
public:
|
||||
BoolButton(bool *value, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(bgImg, bgDownImg, img, scale, layoutParams), value_(value) {
|
||||
BoolButton(bool *value, const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), value_(value) {
|
||||
|
||||
}
|
||||
void Touch(const TouchInput &input) override;
|
||||
@ -86,8 +88,8 @@ private:
|
||||
|
||||
class FPSLimitButton : public MultiTouchButton {
|
||||
public:
|
||||
FPSLimitButton(FPSLimit limit, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(bgImg, bgDownImg, img, scale, layoutParams), limit_(limit) {
|
||||
FPSLimitButton(FPSLimit limit, const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), limit_(limit) {
|
||||
|
||||
}
|
||||
void Touch(const TouchInput &input) override;
|
||||
@ -99,8 +101,8 @@ private:
|
||||
|
||||
class RapidFireButton : public MultiTouchButton {
|
||||
public:
|
||||
RapidFireButton(ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(bgImg, bgDownImg, img, scale, layoutParams) {
|
||||
RapidFireButton(const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams) {
|
||||
}
|
||||
void Touch(const TouchInput &input) override;
|
||||
bool IsDown() override;
|
||||
@ -108,8 +110,8 @@ public:
|
||||
|
||||
class AnalogRotationButton : public MultiTouchButton {
|
||||
public:
|
||||
AnalogRotationButton(bool clockWise, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(bgImg, bgDownImg, img, scale, layoutParams), clockWise_(clockWise) {
|
||||
AnalogRotationButton(bool clockWise, const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), clockWise_(clockWise) {
|
||||
}
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Update() override;
|
||||
@ -121,8 +123,8 @@ private:
|
||||
|
||||
class PSPButton : public MultiTouchButton {
|
||||
public:
|
||||
PSPButton(int pspButtonBit, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(bgImg, bgDownImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit) {
|
||||
PSPButton(int pspButtonBit, const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit) {
|
||||
}
|
||||
void Touch(const TouchInput &input) override;
|
||||
bool IsDown() override;
|
||||
@ -133,7 +135,7 @@ private:
|
||||
|
||||
class PSPDpad : public GamepadView {
|
||||
public:
|
||||
PSPDpad(ImageID arrowIndex, ImageID arrowDownIndex, ImageID overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams);
|
||||
PSPDpad(ImageID arrowIndex, const char *key, ImageID arrowDownIndex, ImageID overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams);
|
||||
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Draw(UIContext &dc) override;
|
||||
@ -154,7 +156,7 @@ private:
|
||||
|
||||
class PSPStick : public GamepadView {
|
||||
public:
|
||||
PSPStick(ImageID bgImg, ImageID stickImg, ImageID stickDownImg, int stick, float scale, UI::LayoutParams *layoutParams);
|
||||
PSPStick(ImageID bgImg, const char *key, ImageID stickImg, ImageID stickDownImg, int stick, float scale, UI::LayoutParams *layoutParams);
|
||||
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Draw(UIContext &dc) override;
|
||||
@ -179,7 +181,7 @@ private:
|
||||
|
||||
class PSPCustomStick : public PSPStick {
|
||||
public:
|
||||
PSPCustomStick(ImageID bgImg, ImageID stickImg, ImageID stickDownImg, float scale, UI::LayoutParams *layoutParams);
|
||||
PSPCustomStick(ImageID bgImg, const char *key, ImageID stickImg, ImageID stickDownImg, float scale, UI::LayoutParams *layoutParams);
|
||||
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Draw(UIContext &dc) override;
|
||||
@ -201,8 +203,8 @@ const int baseActionButtonSpacing = 60;
|
||||
|
||||
class ComboKey : public MultiTouchButton {
|
||||
public:
|
||||
ComboKey(int pspButtonBit, bool toggle, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(bgImg, bgDownImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit), toggle_(toggle) {
|
||||
ComboKey(int pspButtonBit, const char *key, bool toggle, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit), toggle_(toggle) {
|
||||
}
|
||||
void Touch(const TouchInput &input) override;
|
||||
private:
|
||||
|
@ -119,6 +119,7 @@ public:
|
||||
: UI::Clickable(layoutParams), gridStyle_(gridStyle), gamePath_(gamePath) {}
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override {
|
||||
if (gridStyle_) {
|
||||
w = 144*g_Config.fGameGridScale;
|
||||
@ -408,6 +409,12 @@ void GameButton::Draw(UIContext &dc) {
|
||||
dc.RebindTexture();
|
||||
}
|
||||
|
||||
std::string GameButton::DescribeText() const {
|
||||
std::shared_ptr<GameInfo> ginfo = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0);
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 button"), "%1", ginfo->GetTitle());
|
||||
}
|
||||
|
||||
class DirButton : public UI::Button {
|
||||
public:
|
||||
DirButton(const std::string &path, bool gridStyle, UI::LayoutParams *layoutParams)
|
||||
@ -1065,11 +1072,11 @@ void MainScreen::CreateViews() {
|
||||
rightColumnItems->SetSpacing(0.0f);
|
||||
AnchorLayout *logos = new AnchorLayout(new AnchorLayoutParams(FILL_PARENT, 60.0f, false));
|
||||
if (System_GetPropertyBool(SYSPROP_APP_GOLD)) {
|
||||
logos->Add(new ImageView(ImageID("I_ICONGOLD"), IS_DEFAULT, new AnchorLayoutParams(64, 64, 0, 0, NONE, NONE, false)));
|
||||
logos->Add(new ImageView(ImageID("I_ICONGOLD"), "", IS_DEFAULT, new AnchorLayoutParams(64, 64, 0, 0, NONE, NONE, false)));
|
||||
} else {
|
||||
logos->Add(new ImageView(ImageID("I_ICON"), IS_DEFAULT, new AnchorLayoutParams(64, 64, 0, 0, NONE, NONE, false)));
|
||||
logos->Add(new ImageView(ImageID("I_ICON"), "", IS_DEFAULT, new AnchorLayoutParams(64, 64, 0, 0, NONE, NONE, false)));
|
||||
}
|
||||
logos->Add(new ImageView(ImageID("I_LOGO"), IS_DEFAULT, new AnchorLayoutParams(180, 64, 64, -5.0f, NONE, NONE, false)));
|
||||
logos->Add(new ImageView(ImageID("I_LOGO"), "PPSSPP", IS_DEFAULT, new AnchorLayoutParams(180, 64, 64, -5.0f, NONE, NONE, false)));
|
||||
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
if (!g_Config.bFullScreen) {
|
||||
|
@ -589,9 +589,9 @@ void CreditsScreen::CreateViews() {
|
||||
root_->Add(new Button(cr->T("Share PPSSPP"), new AnchorLayoutParams(260, 64, NONE, NONE, 10, rightYOffset + 158, false)))->OnClick.Handle(this, &CreditsScreen::OnShare);
|
||||
#endif
|
||||
if (System_GetPropertyBool(SYSPROP_APP_GOLD)) {
|
||||
root_->Add(new ImageView(ImageID("I_ICONGOLD"), IS_DEFAULT, new AnchorLayoutParams(100, 64, 10, 10, NONE, NONE, false)));
|
||||
root_->Add(new ImageView(ImageID("I_ICONGOLD"), "", IS_DEFAULT, new AnchorLayoutParams(100, 64, 10, 10, NONE, NONE, false)));
|
||||
} else {
|
||||
root_->Add(new ImageView(ImageID("I_ICON"), IS_DEFAULT, new AnchorLayoutParams(100, 64, 10, 10, NONE, NONE, false)));
|
||||
root_->Add(new ImageView(ImageID("I_ICON"), "", IS_DEFAULT, new AnchorLayoutParams(100, 64, 10, 10, NONE, NONE, false)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <sstream>
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
|
||||
#include "Common/Data/Color/RGBAUtil.h"
|
||||
@ -44,6 +45,18 @@ void OnScreenMessagesView::Draw(UIContext &dc) {
|
||||
osm.Unlock();
|
||||
}
|
||||
|
||||
std::string OnScreenMessagesView::DescribeText() const {
|
||||
std::stringstream ss;
|
||||
const auto &messages = osm.Messages();
|
||||
for (auto iter = messages.begin(); iter != messages.end(); ++iter) {
|
||||
if (iter != messages.begin()) {
|
||||
ss << "\n";
|
||||
}
|
||||
ss << iter->text;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void OnScreenMessages::Clean() {
|
||||
restart:
|
||||
double now = time_now_d();
|
||||
|
@ -43,6 +43,7 @@ class OnScreenMessagesView : public UI::InertView {
|
||||
public:
|
||||
OnScreenMessagesView(UI::LayoutParams *layoutParams = nullptr) : UI::InertView(layoutParams) {}
|
||||
void Draw(UIContext &dc);
|
||||
std::string DescribeText() const override;
|
||||
};
|
||||
|
||||
extern OnScreenMessages osm;
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return text_; }
|
||||
|
||||
void DeviceLost() override;
|
||||
void DeviceRestored(Draw::DrawContext *draw) override;
|
||||
|
@ -174,6 +174,7 @@ public:
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override {
|
||||
w = 500;
|
||||
h = 74;
|
||||
@ -323,6 +324,11 @@ void SavedataButton::Draw(UIContext &dc) {
|
||||
dc.RebindTexture();
|
||||
}
|
||||
|
||||
std::string SavedataButton::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 button"), "%1", title_) + "\n" + subtitle_;
|
||||
}
|
||||
|
||||
SavedataBrowser::SavedataBrowser(std::string path, UI::LayoutParams *layoutParams)
|
||||
: LinearLayout(UI::ORIENT_VERTICAL, layoutParams), path_(path) {
|
||||
Refresh();
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return ""; }
|
||||
|
||||
void SetFilename(std::string filename);
|
||||
void SetColor(uint32_t color) { color_ = color; }
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return ""; }
|
||||
|
||||
private:
|
||||
std::string gamePath_;
|
||||
|
@ -38,8 +38,8 @@ static u32 GetButtonColor() {
|
||||
|
||||
class DragDropButton : public MultiTouchButton {
|
||||
public:
|
||||
DragDropButton(ConfigTouchPos &pos, ImageID bgImg, ImageID img, const Bounds &screenBounds)
|
||||
: MultiTouchButton(bgImg, bgImg, img, pos.scale, new UI::AnchorLayoutParams(pos.x * screenBounds.w, pos.y * screenBounds.h, UI::NONE, UI::NONE, true)),
|
||||
DragDropButton(ConfigTouchPos &pos, const char *key, ImageID bgImg, ImageID img, const Bounds &screenBounds)
|
||||
: MultiTouchButton(key, bgImg, bgImg, img, pos.scale, new UI::AnchorLayoutParams(pos.x * screenBounds.w, pos.y * screenBounds.h, UI::NONE, UI::NONE, true)),
|
||||
x_(pos.x), y_(pos.y), theScale_(pos.scale), screenBounds_(screenBounds) {
|
||||
scale_ = theScale_;
|
||||
}
|
||||
@ -76,8 +76,8 @@ private:
|
||||
|
||||
class PSPActionButtons : public DragDropButton {
|
||||
public:
|
||||
PSPActionButtons(ConfigTouchPos &pos, float &spacing, const Bounds &screenBounds)
|
||||
: DragDropButton(pos, ImageID::invalid(), ImageID::invalid(), screenBounds), spacing_(spacing) {
|
||||
PSPActionButtons(ConfigTouchPos &pos, const char *key, float &spacing, const Bounds &screenBounds)
|
||||
: DragDropButton(pos, key, ImageID::invalid(), ImageID::invalid(), screenBounds), spacing_(spacing) {
|
||||
using namespace UI;
|
||||
roundId_ = g_Config.iTouchButtonStyle ? ImageID("I_ROUND_LINE") : ImageID("I_ROUND");
|
||||
};
|
||||
@ -155,8 +155,8 @@ private:
|
||||
|
||||
class PSPDPadButtons : public DragDropButton {
|
||||
public:
|
||||
PSPDPadButtons(ConfigTouchPos &pos, float &spacing, const Bounds &screenBounds)
|
||||
: DragDropButton(pos, ImageID::invalid(), ImageID::invalid(), screenBounds), spacing_(spacing) {
|
||||
PSPDPadButtons(ConfigTouchPos &pos, const char *key, float &spacing, const Bounds &screenBounds)
|
||||
: DragDropButton(pos, key, ImageID::invalid(), ImageID::invalid(), screenBounds), spacing_(spacing) {
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc) override {
|
||||
@ -221,6 +221,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string DescribeText() const override {
|
||||
return "";
|
||||
}
|
||||
|
||||
private:
|
||||
int x1, x2, y1, y2;
|
||||
u32 col;
|
||||
@ -338,7 +342,7 @@ void ControlLayoutView::CreateViews() {
|
||||
|
||||
// Create all the views.
|
||||
|
||||
PSPActionButtons *actionButtons = new PSPActionButtons(g_Config.touchActionButtonCenter, g_Config.fActionButtonSpacing, bounds);
|
||||
PSPActionButtons *actionButtons = new PSPActionButtons(g_Config.touchActionButtonCenter, "Action buttons", g_Config.fActionButtonSpacing, bounds);
|
||||
actionButtons->setCircleVisibility(g_Config.bShowTouchCircle);
|
||||
actionButtons->setCrossVisibility(g_Config.bShowTouchCross);
|
||||
actionButtons->setTriangleVisibility(g_Config.bShowTouchTriangle);
|
||||
@ -354,53 +358,53 @@ void ControlLayoutView::CreateViews() {
|
||||
|
||||
const ImageID comboKeyImages[5] = { ImageID("I_1"), ImageID("I_2"), ImageID("I_3"), ImageID("I_4"), ImageID("I_5") };
|
||||
|
||||
auto addDragDropButton = [&](ConfigTouchPos &pos, ImageID bgImg, ImageID img) {
|
||||
auto addDragDropButton = [&](ConfigTouchPos &pos, const char *key, ImageID bgImg, ImageID img) {
|
||||
DragDropButton *b = nullptr;
|
||||
if (pos.show) {
|
||||
b = new DragDropButton(pos, bgImg, img, bounds);
|
||||
b = new DragDropButton(pos, key, bgImg, img, bounds);
|
||||
controls_.push_back(b);
|
||||
}
|
||||
return b;
|
||||
};
|
||||
|
||||
if (g_Config.touchDpad.show) {
|
||||
controls_.push_back(new PSPDPadButtons(g_Config.touchDpad, g_Config.fDpadSpacing, bounds));
|
||||
controls_.push_back(new PSPDPadButtons(g_Config.touchDpad, "D-pad", g_Config.fDpadSpacing, bounds));
|
||||
}
|
||||
|
||||
addDragDropButton(g_Config.touchSelectKey, rectImage, ImageID("I_SELECT"));
|
||||
addDragDropButton(g_Config.touchStartKey, rectImage, ImageID("I_START"));
|
||||
addDragDropButton(g_Config.touchSelectKey, "Select button", rectImage, ImageID("I_SELECT"));
|
||||
addDragDropButton(g_Config.touchStartKey, "Start button", rectImage, ImageID("I_START"));
|
||||
|
||||
if (auto *unthrottle = addDragDropButton(g_Config.touchUnthrottleKey, rectImage, ImageID("I_ARROW"))) {
|
||||
if (auto *unthrottle = addDragDropButton(g_Config.touchUnthrottleKey, "Unthrottle button", rectImage, ImageID("I_ARROW"))) {
|
||||
unthrottle->SetAngle(180.0f);
|
||||
}
|
||||
if (auto *speed1 = addDragDropButton(g_Config.touchSpeed1Key, rectImage, ImageID("I_ARROW"))) {
|
||||
if (auto *speed1 = addDragDropButton(g_Config.touchSpeed1Key, "Alternate speed 1 button", rectImage, ImageID("I_ARROW"))) {
|
||||
speed1->SetAngle(170.0f, 180.0f);
|
||||
}
|
||||
if (auto *speed2 = addDragDropButton(g_Config.touchSpeed2Key, rectImage, ImageID("I_ARROW"))) {
|
||||
if (auto *speed2 = addDragDropButton(g_Config.touchSpeed2Key, "Alternate speed 2 button", rectImage, ImageID("I_ARROW"))) {
|
||||
speed2->SetAngle(190.0f, 180.0f);
|
||||
}
|
||||
if (auto *rapidFire = addDragDropButton(g_Config.touchRapidFireKey, rectImage, ImageID("I_ARROW"))) {
|
||||
if (auto *rapidFire = addDragDropButton(g_Config.touchRapidFireKey, "Rapid fire button", rectImage, ImageID("I_ARROW"))) {
|
||||
rapidFire->SetAngle(90.0f, 180.0f);
|
||||
}
|
||||
if (auto *analogRotationCW = addDragDropButton(g_Config.touchAnalogRotationCWKey, rectImage, ImageID("I_ARROW"))) {
|
||||
if (auto *analogRotationCW = addDragDropButton(g_Config.touchAnalogRotationCWKey, "Analog clockwise rotation button", rectImage, ImageID("I_ARROW"))) {
|
||||
analogRotationCW->SetAngle(190.0f, 180.0f);
|
||||
}
|
||||
if (auto *analogRotationCCW = addDragDropButton(g_Config.touchAnalogRotationCCWKey, rectImage, ImageID("I_ARROW"))) {
|
||||
if (auto *analogRotationCCW = addDragDropButton(g_Config.touchAnalogRotationCCWKey, "Analog counter clockwise rotation button", rectImage, ImageID("I_ARROW"))) {
|
||||
analogRotationCCW->SetAngle(350.0f, 180.0f);
|
||||
}
|
||||
|
||||
addDragDropButton(g_Config.touchLKey, shoulderImage, ImageID("I_L"));
|
||||
if (auto *rbutton = addDragDropButton(g_Config.touchRKey, shoulderImage, ImageID("I_R"))) {
|
||||
addDragDropButton(g_Config.touchLKey, "Left shoulder button", shoulderImage, ImageID("I_L"));
|
||||
if (auto *rbutton = addDragDropButton(g_Config.touchRKey, "Right shoulder button", shoulderImage, ImageID("I_R"))) {
|
||||
rbutton->FlipImageH(true);
|
||||
}
|
||||
|
||||
addDragDropButton(g_Config.touchAnalogStick, stickBg, stickImage);
|
||||
addDragDropButton(g_Config.touchRightAnalogStick, stickBg, stickImage);
|
||||
addDragDropButton(g_Config.touchCombo0, roundImage, comboKeyImages[0]);
|
||||
addDragDropButton(g_Config.touchCombo1, roundImage, comboKeyImages[1]);
|
||||
addDragDropButton(g_Config.touchCombo2, roundImage, comboKeyImages[2]);
|
||||
addDragDropButton(g_Config.touchCombo3, roundImage, comboKeyImages[3]);
|
||||
addDragDropButton(g_Config.touchCombo4, roundImage, comboKeyImages[4]);
|
||||
addDragDropButton(g_Config.touchAnalogStick, "Left analog stick", stickBg, stickImage);
|
||||
addDragDropButton(g_Config.touchRightAnalogStick, "Right analog stick", stickBg, stickImage);
|
||||
addDragDropButton(g_Config.touchCombo0, "Combo 1 button", roundImage, comboKeyImages[0]);
|
||||
addDragDropButton(g_Config.touchCombo1, "Combo 2 button", roundImage, comboKeyImages[1]);
|
||||
addDragDropButton(g_Config.touchCombo2, "Combo 3 button", roundImage, comboKeyImages[2]);
|
||||
addDragDropButton(g_Config.touchCombo3, "Combo 4 button", roundImage, comboKeyImages[3]);
|
||||
addDragDropButton(g_Config.touchCombo4, "Combo 5 button", roundImage, comboKeyImages[4]);
|
||||
|
||||
for (size_t i = 0; i < controls_.size(); i++) {
|
||||
Add(controls_[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user