Skip to content

Commit 6e369e5

Browse files
committed
Add play/pause button to the bottom right of the pause screen
1 parent 8d8ff58 commit 6e369e5

File tree

9 files changed

+44
-10
lines changed

9 files changed

+44
-10
lines changed

Common/UI/View.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,18 @@ class Spacer : public InertView {
903903
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override {
904904
w = size_; h = size_;
905905
}
906+
907+
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override {
908+
if (horiz.type == AT_MOST || horiz.type == EXACTLY)
909+
w = horiz.size;
910+
else
911+
w = size_;
912+
if (vert.type == AT_MOST || vert.type == EXACTLY)
913+
h = vert.size;
914+
else
915+
h = size_;
916+
}
917+
906918
void Draw(UIContext &dc) override {}
907919
std::string DescribeText() const override { return ""; }
908920

Common/UI/ViewGroup.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace UI {
2525

2626
static constexpr Size ITEM_HEIGHT = 64.f;
2727

28-
void ApplyGravity(const Bounds outer, const Margins &margins, float w, float h, int gravity, Bounds &inner) {
28+
void ApplyGravity(const Bounds &outer, const Margins &margins, float w, float h, int gravity, Bounds &inner) {
2929
inner.w = w;
3030
inner.h = h;
3131

@@ -495,6 +495,10 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
495495
if (views_.empty())
496496
return;
497497

498+
if (tag_ == "debug") {
499+
tag_ = "debug";
500+
}
501+
498502
float sum = 0.0f;
499503
float maxOther = 0.0f;
500504
float totalWeight = 0.0f;
@@ -666,6 +670,10 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
666670
void LinearLayout::Layout() {
667671
const Bounds &bounds = bounds_;
668672

673+
if (tag_ == "debug") {
674+
tag_ = "debug";
675+
}
676+
669677
Bounds itemBounds;
670678
float pos;
671679

UI/PauseScreen.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,12 @@ void GamePauseScreen::CreateViews() {
356356
leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, notAvailable, ""));
357357
}
358358

359-
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(vertical ? 200 : 300, FILL_PARENT, actionMenuMargins));
360-
root_->Add(rightColumn);
359+
ViewGroup *rightColumnHolder = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(vertical ? 200 : 300, FILL_PARENT, actionMenuMargins));
360+
361+
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f));
362+
rightColumnHolder->Add(rightColumn);
363+
364+
root_->Add(rightColumnHolder);
361365

362366
LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL);
363367
rightColumn->Add(rightColumnItems);
@@ -414,8 +418,17 @@ void GamePauseScreen::CreateViews() {
414418
} else {
415419
rightColumnItems->Add(new Choice(pa->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu);
416420
}
417-
rightColumnItems->Add(new Spacer(25.0f));
418-
rightColumnItems->Add(new CheckBox(&g_Config.bRunBehindPauseMenu, "Run Behind"));
421+
422+
ViewGroup *playControls = rightColumnHolder->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
423+
playControls->SetTag("debug");
424+
playControls->Add(new Spacer(new LinearLayoutParams(1.0f)));
425+
playButton_ = playControls->Add(new Button("", g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"), new LinearLayoutParams(0.0f, G_RIGHT)));
426+
playButton_->OnClick.Add([=](UI::EventParams &e) {
427+
g_Config.bRunBehindPauseMenu = !g_Config.bRunBehindPauseMenu;
428+
playButton_->SetImageID(g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"));
429+
return UI::EVENT_DONE;
430+
});
431+
rightColumnHolder->Add(new Spacer(10.0f));
419432
}
420433

421434
UI::EventReturn GamePauseScreen::OnGameSettings(UI::EventParams &e) {

UI/PauseScreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ class GamePauseScreen : public UIDialogScreenWithGameBackground {
6666
bool finishNextFrame_ = false;
6767
PauseScreenMode mode_ = PauseScreenMode::MAIN;
6868

69-
UI::Button *pauseButton_ = nullptr;
69+
UI::Button *playButton_ = nullptr;
7070
};

assets/ui_atlas.meta

27 Bytes
Binary file not shown.

assets/ui_atlas.zim

213 Bytes
Binary file not shown.

buildatlas.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Note that we do not copy the big font atlas to Android assets. No longer needed!
22

33
./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
4-
./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
5-
./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
4+
#./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
5+
#./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
66

77
rm ui_atlas.zim ui_atlas.meta
8-
rm font_atlas.zim font_atlas.meta
9-
rm asciifont_atlas.zim asciifont_atlas.meta
8+
#rm font_atlas.zim font_atlas.meta
9+
#rm asciifont_atlas.zim asciifont_atlas.meta
File renamed without changes.

ui_atlasscript.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ image I_RETROACHIEVEMENTS_LOGO source_assets/image/retroachievements_logo.png co
7474
image I_CHECKMARK source_assets/image/checkmark.png copy
7575
image I_PLAY source_assets/image/play.png copy
7676
image I_STOP source_assets/image/stop.png copy
77+
image I_PAUSE source_assets/image/pause.png copy
7778
image I_FASTFORWARD source_assets/image/fast_forward.png copy
7879
image I_RECORD source_assets/image/record.png copy
7980
image I_SPEAKER source_assets/image/speaker.png copy

0 commit comments

Comments
 (0)