Add play/pause button to the bottom right of the pause screen

This commit is contained in:
Henrik Rydgård 2023-12-11 13:56:16 +01:00
parent 8d8ff5886b
commit 6e369e5188
9 changed files with 44 additions and 10 deletions

View file

@ -903,6 +903,18 @@ public:
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override {
w = size_; h = size_;
}
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override {
if (horiz.type == AT_MOST || horiz.type == EXACTLY)
w = horiz.size;
else
w = size_;
if (vert.type == AT_MOST || vert.type == EXACTLY)
h = vert.size;
else
h = size_;
}
void Draw(UIContext &dc) override {}
std::string DescribeText() const override { return ""; }

View file

@ -25,7 +25,7 @@ namespace UI {
static constexpr Size ITEM_HEIGHT = 64.f;
void ApplyGravity(const Bounds outer, const Margins &margins, float w, float h, int gravity, Bounds &inner) {
void ApplyGravity(const Bounds &outer, const Margins &margins, float w, float h, int gravity, Bounds &inner) {
inner.w = w;
inner.h = h;
@ -495,6 +495,10 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
if (views_.empty())
return;
if (tag_ == "debug") {
tag_ = "debug";
}
float sum = 0.0f;
float maxOther = 0.0f;
float totalWeight = 0.0f;
@ -666,6 +670,10 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
void LinearLayout::Layout() {
const Bounds &bounds = bounds_;
if (tag_ == "debug") {
tag_ = "debug";
}
Bounds itemBounds;
float pos;

View file

@ -356,8 +356,12 @@ void GamePauseScreen::CreateViews() {
leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, notAvailable, ""));
}
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(vertical ? 200 : 300, FILL_PARENT, actionMenuMargins));
root_->Add(rightColumn);
ViewGroup *rightColumnHolder = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(vertical ? 200 : 300, FILL_PARENT, actionMenuMargins));
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f));
rightColumnHolder->Add(rightColumn);
root_->Add(rightColumnHolder);
LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL);
rightColumn->Add(rightColumnItems);
@ -414,8 +418,17 @@ void GamePauseScreen::CreateViews() {
} else {
rightColumnItems->Add(new Choice(pa->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu);
}
rightColumnItems->Add(new Spacer(25.0f));
rightColumnItems->Add(new CheckBox(&g_Config.bRunBehindPauseMenu, "Run Behind"));
ViewGroup *playControls = rightColumnHolder->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
playControls->SetTag("debug");
playControls->Add(new Spacer(new LinearLayoutParams(1.0f)));
playButton_ = playControls->Add(new Button("", g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"), new LinearLayoutParams(0.0f, G_RIGHT)));
playButton_->OnClick.Add([=](UI::EventParams &e) {
g_Config.bRunBehindPauseMenu = !g_Config.bRunBehindPauseMenu;
playButton_->SetImageID(g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"));
return UI::EVENT_DONE;
});
rightColumnHolder->Add(new Spacer(10.0f));
}
UI::EventReturn GamePauseScreen::OnGameSettings(UI::EventParams &e) {

View file

@ -66,5 +66,5 @@ private:
bool finishNextFrame_ = false;
PauseScreenMode mode_ = PauseScreenMode::MAIN;
UI::Button *pauseButton_ = nullptr;
UI::Button *playButton_ = nullptr;
};

Binary file not shown.

Binary file not shown.

View file

@ -1,9 +1,9 @@
# Note that we do not copy the big font atlas to Android assets. No longer needed!
./ext/native/tools/build/atlastool ui_atlasscript.txt ui 8888 && cp ui_atlas.zim ui_atlas.meta assets && rm ui_atlas.cpp ui_atlas.h
./ext/native/tools/build/atlastool font_atlasscript.txt font 8888 && cp font_atlas.zim font_atlas.meta assets && rm font_atlas.cpp font_atlas.h
./ext/native/tools/build/atlastool asciifont_atlasscript.txt asciifont 8888 && cp asciifont_atlas.zim asciifont_atlas.meta assets && rm asciifont_atlas.cpp asciifont_atlas.h
#./ext/native/tools/build/atlastool font_atlasscript.txt font 8888 && cp font_atlas.zim font_atlas.meta assets && rm font_atlas.cpp font_atlas.h
#./ext/native/tools/build/atlastool asciifont_atlasscript.txt asciifont 8888 && cp asciifont_atlas.zim asciifont_atlas.meta assets && rm asciifont_atlas.cpp asciifont_atlas.h
rm ui_atlas.zim ui_atlas.meta
rm font_atlas.zim font_atlas.meta
rm asciifont_atlas.zim asciifont_atlas.meta
#rm font_atlas.zim font_atlas.meta
#rm asciifont_atlas.zim asciifont_atlas.meta

View file

Before

Width:  |  Height:  |  Size: 396 B

After

Width:  |  Height:  |  Size: 396 B

View file

@ -74,6 +74,7 @@ image I_RETROACHIEVEMENTS_LOGO source_assets/image/retroachievements_logo.png co
image I_CHECKMARK source_assets/image/checkmark.png copy
image I_PLAY source_assets/image/play.png copy
image I_STOP source_assets/image/stop.png copy
image I_PAUSE source_assets/image/pause.png copy
image I_FASTFORWARD source_assets/image/fast_forward.png copy
image I_RECORD source_assets/image/record.png copy
image I_SPEAKER source_assets/image/speaker.png copy