mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Make the undo save/load buttons not scroll with the savestate list
This commit is contained in:
@@ -55,6 +55,9 @@ void ScrollView::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec ver
|
||||
if (layoutParams_->height == WRAP_CONTENT)
|
||||
MeasureBySpec(layoutParams_->height, views_[0]->GetMeasuredHeight(), vert, &measuredHeight_);
|
||||
}
|
||||
|
||||
// The below seems misguided and leads to wrong sized scrollviews. Need to investigate if it's needed somewhere...
|
||||
/*
|
||||
if (orientation_ == ORIENT_VERTICAL && vert.type != EXACTLY) {
|
||||
float bestHeight = std::max(views_[0]->GetMeasuredHeight(), views_[0]->GetBounds().h);
|
||||
if (vert.type == AT_MOST)
|
||||
@@ -63,7 +66,7 @@ void ScrollView::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec ver
|
||||
if (measuredHeight_ < bestHeight && layoutParams_->height < 0.0f) {
|
||||
measuredHeight_ = bestHeight;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,8 +279,8 @@ void ScrollView::Draw(UIContext &dc) {
|
||||
// If not anchored at the top of the screen exactly, and not scrolled to the top,
|
||||
// draw a subtle drop shadow to indicate scrollability.
|
||||
|
||||
const float darkness = 0.4f;
|
||||
if (bounds_.y > 0.0f && orientation_ == ORIENT_VERTICAL) {
|
||||
constexpr float darkness = 0.4f;
|
||||
if (shadows_ && bounds_.y > 0.0f && orientation_ == ORIENT_VERTICAL) {
|
||||
float radius = 20.0f;
|
||||
|
||||
Bounds shadowBounds = bounds_;
|
||||
@@ -292,8 +295,8 @@ void ScrollView::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
// Same at the bottom.
|
||||
float y2 = dc.GetLayoutBounds().y2();
|
||||
if (bounds_.y2() < y2 && orientation_ == ORIENT_VERTICAL) {
|
||||
const float y2 = dc.GetLayoutBounds().y2();
|
||||
if (shadows_ && bounds_.y2() < y2 && orientation_ == ORIENT_VERTICAL) {
|
||||
float radius = 20.0f;
|
||||
|
||||
Bounds shadowBounds = bounds_;
|
||||
@@ -483,10 +486,10 @@ float ScrollView::ClampedScrollPos(float pos) {
|
||||
float maxPull = bounds_.h * 0.1f;
|
||||
if (pos < 0.0f) {
|
||||
float dist = std::min(-pos * (1.0f / bounds_.h), 1.0f);
|
||||
pull_ = -(sqrt(dist) * maxPull);
|
||||
pull_ = -(sqrtf(dist) * maxPull);
|
||||
} else if (pos > scrollMax) {
|
||||
float dist = std::min((pos - scrollMax) * (1.0f / bounds_.h), 1.0f);
|
||||
pull_ = sqrt(dist) * maxPull;
|
||||
pull_ = sqrtf(dist) * maxPull;
|
||||
} else {
|
||||
pull_ = 0.0f;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ public:
|
||||
alignOpposite_ = alignOpposite;
|
||||
}
|
||||
|
||||
void SetShadows(bool shadows) {
|
||||
shadows_ = shadows;
|
||||
}
|
||||
|
||||
NeighborResult FindScrollNeighbor(View *view, const Point2D &target, FocusDirection direction, NeighborResult best) override;
|
||||
|
||||
private:
|
||||
@@ -81,6 +85,7 @@ private:
|
||||
bool alignOpposite_ = false;
|
||||
bool draggingBob_ = false;
|
||||
bool mouseHover_ = false;
|
||||
bool shadows_ = true;
|
||||
|
||||
float barDragStart_ = 0.0f;
|
||||
float barDragOffset_ = 0.0f;
|
||||
|
||||
+35
-30
@@ -380,7 +380,7 @@ void GamePauseScreen::OnVKey(VirtKey virtualKeyCode, bool down) {
|
||||
}
|
||||
}
|
||||
|
||||
void GamePauseScreen::CreateSavestateControls(UI::LinearLayout *leftColumnItems) {
|
||||
void GamePauseScreen::CreateSavestateControls(UI::LinearLayout *leftColumnItems, UI::LinearLayout **extraRow) {
|
||||
auto pa = GetI18NCategory(I18NCat::PAUSE);
|
||||
|
||||
using namespace UI;
|
||||
@@ -407,23 +407,39 @@ void GamePauseScreen::CreateSavestateControls(UI::LinearLayout *leftColumnItems)
|
||||
RecreateViews();
|
||||
});
|
||||
}
|
||||
leftColumnItems->Add(new Spacer(0.0));
|
||||
|
||||
LinearLayout *buttonRow = leftColumnItems->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(Margins(10, 0, 0, 0))));
|
||||
*extraRow = nullptr;
|
||||
|
||||
LinearLayout *buttonRow = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(Margins(10, 0, 0, 0)));
|
||||
if (g_Config.bEnableStateUndo && !Achievements::HardcoreModeActive() && NetworkAllowSaveState()) {
|
||||
UI::Choice *loadUndoButton = buttonRow->Add(new Choice(pa->T("Undo last load"), ImageID("I_NAVIGATE_BACK")));
|
||||
UI::Choice *loadUndoButton = buttonRow->Add(new Choice(pa->T("Undo last load"), ImageID("I_NAVIGATE_BACK"), new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)));
|
||||
loadUndoButton->SetEnabled(SaveState::HasUndoLoad(saveStatePrefix_));
|
||||
loadUndoButton->OnClick.Handle(this, &GamePauseScreen::OnLoadUndo);
|
||||
loadUndoButton->OnClick.Add([this](UI::EventParams &e) {
|
||||
SaveState::UndoLoad(saveStatePrefix_, &AfterSaveStateAction);
|
||||
TriggerFinish(DR_CANCEL);
|
||||
});
|
||||
|
||||
UI::Choice *saveUndoButton = buttonRow->Add(new Choice(pa->T("Undo last save"), ImageID("I_NAVIGATE_BACK")));
|
||||
UI::Choice *saveUndoButton = buttonRow->Add(new Choice(pa->T("Undo last save"), ImageID("I_NAVIGATE_BACK"), new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)));
|
||||
saveUndoButton->SetEnabled(SaveState::HasUndoLastSave(saveStatePrefix_));
|
||||
saveUndoButton->OnClick.Handle(this, &GamePauseScreen::OnLastSaveUndo);
|
||||
saveUndoButton->OnClick.Add([this](UI::EventParams &e) {
|
||||
SaveState::UndoLastSave(saveStatePrefix_);
|
||||
RecreateViews();
|
||||
});
|
||||
}
|
||||
|
||||
if (g_Config.iRewindSnapshotInterval > 0 && !Achievements::HardcoreModeActive() && NetworkAllowSaveState()) {
|
||||
UI::Choice *rewindButton = buttonRow->Add(new Choice(pa->T("Rewind"), ImageID("I_REWIND")));
|
||||
UI::Choice *rewindButton = buttonRow->Add(new Choice(pa->T("Rewind"), ImageID("I_REWIND"), new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)));
|
||||
rewindButton->SetEnabled(SaveState::CanRewind());
|
||||
rewindButton->OnClick.Handle(this, &GamePauseScreen::OnRewind);
|
||||
rewindButton->OnClick.Add([this](UI::EventParams &e) {
|
||||
SaveState::Rewind(&AfterSaveStateAction);
|
||||
TriggerFinish(DR_CANCEL);
|
||||
});
|
||||
}
|
||||
|
||||
if (buttonRow->GetNumSubviews() == 0) {
|
||||
delete buttonRow;
|
||||
} else {
|
||||
*extraRow = buttonRow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,8 +492,11 @@ void GamePauseScreen::CreateViews() {
|
||||
});
|
||||
}
|
||||
|
||||
ViewGroup *saveStateScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f, scrollMargins));
|
||||
root_->Add(saveStateScroll);
|
||||
ViewGroup *saveScrollContainer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f, scrollMargins));
|
||||
root_->Add(saveScrollContainer);
|
||||
|
||||
ScrollView *saveStateScroll = saveScrollContainer->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f)));
|
||||
saveStateScroll->SetShadows(false);
|
||||
|
||||
LinearLayout *saveDataScrollItems = new LinearLayoutList(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT));
|
||||
saveStateScroll->Add(saveDataScrollItems);
|
||||
@@ -547,7 +566,11 @@ void GamePauseScreen::CreateViews() {
|
||||
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/docs/troubleshooting/save-state-time-warps");
|
||||
});
|
||||
}
|
||||
CreateSavestateControls(saveDataScrollItems);
|
||||
LinearLayout *extraRow = nullptr;
|
||||
CreateSavestateControls(saveDataScrollItems, &extraRow);
|
||||
if (extraRow) {
|
||||
saveScrollContainer->Add(extraRow);
|
||||
}
|
||||
} else {
|
||||
// Let's show the active challenges.
|
||||
std::set<uint32_t> ids = Achievements::GetActiveChallengeIDs();
|
||||
@@ -846,24 +869,6 @@ void GamePauseScreen::OnReportFeedback(UI::EventParams &e) {
|
||||
screenManager()->push(new ReportScreen(gamePath_));
|
||||
}
|
||||
|
||||
void GamePauseScreen::OnRewind(UI::EventParams &e) {
|
||||
SaveState::Rewind(&AfterSaveStateAction);
|
||||
|
||||
TriggerFinish(DR_CANCEL);
|
||||
}
|
||||
|
||||
void GamePauseScreen::OnLoadUndo(UI::EventParams &e) {
|
||||
SaveState::UndoLoad(saveStatePrefix_, &AfterSaveStateAction);
|
||||
|
||||
TriggerFinish(DR_CANCEL);
|
||||
}
|
||||
|
||||
void GamePauseScreen::OnLastSaveUndo(UI::EventParams &e) {
|
||||
SaveState::UndoLastSave(saveStatePrefix_);
|
||||
|
||||
RecreateViews();
|
||||
}
|
||||
|
||||
void GamePauseScreen::OnCreateConfig(UI::EventParams &e) {
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO);
|
||||
if (info->Ready(GameInfoFlags::PARAM_SFO)) {
|
||||
|
||||
+1
-5
@@ -49,16 +49,12 @@ protected:
|
||||
void OnVKey(VirtKey virtualKeyCode, bool down) override;
|
||||
|
||||
private:
|
||||
void CreateSavestateControls(UI::LinearLayout *viewGroup);
|
||||
void CreateSavestateControls(UI::LinearLayout *viewGroup, UI::LinearLayout **extraRow);
|
||||
|
||||
void OnGameSettings(UI::EventParams &e);
|
||||
void OnExit(UI::EventParams &e);
|
||||
void OnReportFeedback(UI::EventParams &e);
|
||||
|
||||
void OnRewind(UI::EventParams &e);
|
||||
void OnLoadUndo(UI::EventParams &e);
|
||||
void OnLastSaveUndo(UI::EventParams &e);
|
||||
|
||||
void OnCreateConfig(UI::EventParams &e);
|
||||
void OnDeleteConfig(UI::EventParams &e);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user