Skip to content

Commit

Permalink
Merge pull request #16031 from hrydgard/screen-names
Browse files Browse the repository at this point in the history
Tag all the UI screens with names, improve logging of scissor errors
  • Loading branch information
hrydgard authored Sep 16, 2022
2 parents ca2962b + 0b9d6f9 commit a741922
Show file tree
Hide file tree
Showing 32 changed files with 162 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Common/UI/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void UIContext::ActivateTopScissor() {
int h = std::max(0.0f, ceilf(scale_y * bounds.h));
if (x < 0 || y < 0 || x + w > pixel_xres || y + h > pixel_yres) {
// This won't actually report outside a game, but we can try.
ERROR_LOG_REPORT(G3D, "UI scissor out of bounds: %d,%d-%d,%d / %d,%d", x, y, w, h, pixel_xres, pixel_yres);
ERROR_LOG_REPORT(G3D, "UI scissor out of bounds in %sScreen: %d,%d-%d,%d / %d,%d", screenTag_ ? screenTag_ : "N/A", x, y, w, h, pixel_xres, pixel_yres);
x = std::max(0, x);
y = std::max(0, y);
w = std::min(w, pixel_xres - x);
Expand Down
7 changes: 6 additions & 1 deletion Common/UI/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class UIContext {
const UI::Theme *theme;

// Utility methods

TextDrawer *Text() const { return textDrawer_; }

void SetFontStyle(const UI::FontStyle &style);
Expand Down Expand Up @@ -103,6 +102,10 @@ class UIContext {

void setUIAtlas(const std::string &name);

void SetScreenTag(const char *tag) {
screenTag_ = tag;
}

private:
Draw::DrawContext *draw_ = nullptr;
Bounds bounds_;
Expand All @@ -126,4 +129,6 @@ class UIContext {

std::string lastUIAtlas_;
std::string UIAtlas_ = "ui_atlas.zim";

const char *screenTag_ = nullptr;
};
2 changes: 1 addition & 1 deletion Common/UI/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Screen {
// what screen it is.
virtual void *dialogData() { return 0; }

virtual std::string tag() const { return std::string(""); }
virtual const char *tag() const = 0;

virtual bool isTransparent() const { return false; }
virtual bool isTopLevel() const { return false; }
Expand Down
3 changes: 3 additions & 0 deletions Common/UI/UIScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ void UIScreen::render() {

if (root_) {
UIContext *uiContext = screenManager()->getUIContext();

uiContext->SetScreenTag(tag());

UI::LayoutViewHierarchy(*uiContext, root_, ignoreInsets_);

uiContext->PushTransform({translation_, scale_, alpha_});
Expand Down
8 changes: 7 additions & 1 deletion Common/UI/UIScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class ListPopupScreen : public PopupScreen {
void SetHiddenChoices(std::set<int> hidden) {
hidden_ = hidden;
}
virtual std::string tag() const override { return std::string("listpopup"); }
const char *tag() const override { return "listpopup"; }

UI::Event OnChoice;

Expand Down Expand Up @@ -187,6 +187,8 @@ class SliderPopupScreen : public PopupScreen {
disabled_ = *value_ < 0;
}

const char *tag() const { return "SliderPopup"; }

Event OnChange;

private:
Expand Down Expand Up @@ -214,6 +216,8 @@ class SliderFloatPopupScreen : public PopupScreen {
: PopupScreen(title, "OK", "Cancel"), units_(units), value_(value), originalValue_(*value), minValue_(minValue), maxValue_(maxValue), step_(step), changing_(false), liveUpdate_(liveUpdate) {}
void CreatePopupContents(UI::ViewGroup *parent) override;

const char *tag() const { return "SliderFloatPopup"; }

Event OnChange;

private:
Expand Down Expand Up @@ -241,6 +245,8 @@ class TextEditPopupScreen : public PopupScreen {
: PopupScreen(title, "OK", "Cancel"), value_(value), placeholder_(placeholder), maxLen_(maxLen) {}
virtual void CreatePopupContents(ViewGroup *parent) override;

const char *tag() const { return "TextEditPopup"; }

Event OnChange;

private:
Expand Down
4 changes: 4 additions & 0 deletions UI/ComboKeyMappingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class ButtonShapeScreen : public PopupScreen {
parent->Add(scroll);
}

const char *tag() const override { return "ButtonShape"; }

private:
int *setting_;
};
Expand Down Expand Up @@ -84,6 +86,8 @@ class ButtonIconScreen : public PopupScreen {
parent->Add(scroll);
}

const char *tag() const override { return "ButtonIcon"; }

private:
int *setting_;
};
Expand Down
2 changes: 2 additions & 0 deletions UI/ComboKeyMappingScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class ComboKeyScreen : public UIDialogScreenWithBackground {
public:
ComboKeyScreen(int id): id_(id) {}

const char *tag() const override { return "ComboKey"; }

void CreateViews() override;
void onFinish(DialogResult result) override;

Expand Down
24 changes: 17 additions & 7 deletions UI/ControlMappingScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SingleControlMapper;
class ControlMappingScreen : public UIDialogScreenWithBackground {
public:
ControlMappingScreen() {}
std::string tag() const override { return "control mapping"; }
const char *tag() const override { return "ControlMapping"; }

protected:
void CreateViews() override;
Expand All @@ -47,7 +47,7 @@ class ControlMappingScreen : public UIDialogScreenWithBackground {
UI::EventReturn OnAutoConfigure(UI::EventParams &params);
UI::EventReturn OnVisualizeMapping(UI::EventParams &params);

virtual void dialogFinished(const Screen *dialog, DialogResult result) override;
void dialogFinished(const Screen *dialog, DialogResult result) override;

UI::ScrollView *rightScroll_;
std::vector<SingleControlMapper *> mappers_;
Expand All @@ -61,17 +61,19 @@ class KeyMappingNewKeyDialog : public PopupScreen {
pspBtn_ = btn;
}

virtual bool key(const KeyInput &key) override;
virtual bool axis(const AxisInput &axis) override;
const char *tag() const override { return "KeyMappingNewKey"; }

bool key(const KeyInput &key) override;
bool axis(const AxisInput &axis) override;

void SetDelay(float t);

protected:
void CreatePopupContents(UI::ViewGroup *parent) override;

virtual bool FillVertical() const override { return false; }
virtual bool ShowButtons() const override { return true; }
virtual void OnCompleted(DialogResult result) override {}
bool FillVertical() const override { return false; }
bool ShowButtons() const override { return true; }
void OnCompleted(DialogResult result) override {}

private:
int pspBtn_;
Expand All @@ -87,6 +89,8 @@ class KeyMappingNewMouseKeyDialog : public PopupScreen {
pspBtn_ = btn;
}

const char *tag() const override { return "KeyMappingNewMouseKey"; }

bool key(const KeyInput &key) override;
bool axis(const AxisInput &axis) override;

Expand Down Expand Up @@ -114,6 +118,8 @@ class AnalogSetupScreen : public UIDialogScreenWithBackground {

void update() override;

const char *tag() const override { return "AnalogSetup"; }

protected:
void CreateViews() override;

Expand Down Expand Up @@ -144,6 +150,8 @@ class TouchTestScreen : public UIDialogScreenWithBackground {
bool key(const KeyInput &key) override;
bool axis(const AxisInput &axis) override;

const char *tag() const override { return "TouchTest"; }

protected:
struct TrackedTouch {
int id;
Expand Down Expand Up @@ -171,6 +179,8 @@ class VisualMappingScreen : public UIDialogScreenWithBackground {
public:
VisualMappingScreen() {}

const char *tag() const override { return "VisualMapping"; }

protected:
void CreateViews() override;

Expand Down
2 changes: 2 additions & 0 deletions UI/CwCheatScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class CwCheatScreen : public UIDialogScreenWithBackground {
void update() override;
void onFinish(DialogResult result) override;

const char *tag() const override { return "CwCheat"; }

protected:
void CreateViews() override;

Expand Down
40 changes: 20 additions & 20 deletions UI/DevScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static const char *logLevelList[] = {
"Verb."
};

void DevMenu::CreatePopupContents(UI::ViewGroup *parent) {
void DevMenuScreen::CreatePopupContents(UI::ViewGroup *parent) {
using namespace UI;
auto dev = GetI18NCategory("Developer");
auto sy = GetI18NCategory("System");
Expand All @@ -94,25 +94,25 @@ void DevMenu::CreatePopupContents(UI::ViewGroup *parent) {
LinearLayout *items = new LinearLayout(ORIENT_VERTICAL);

#if !defined(MOBILE_DEVICE)
items->Add(new Choice(dev->T("Log View")))->OnClick.Handle(this, &DevMenu::OnLogView);
items->Add(new Choice(dev->T("Log View")))->OnClick.Handle(this, &DevMenuScreen::OnLogView);
#endif
items->Add(new Choice(dev->T("Logging Channels")))->OnClick.Handle(this, &DevMenu::OnLogConfig);
items->Add(new Choice(sy->T("Developer Tools")))->OnClick.Handle(this, &DevMenu::OnDeveloperTools);
items->Add(new Choice(dev->T("Jit Compare")))->OnClick.Handle(this, &DevMenu::OnJitCompare);
items->Add(new Choice(dev->T("Shader Viewer")))->OnClick.Handle(this, &DevMenu::OnShaderView);
items->Add(new Choice(dev->T("Logging Channels")))->OnClick.Handle(this, &DevMenuScreen::OnLogConfig);
items->Add(new Choice(sy->T("Developer Tools")))->OnClick.Handle(this, &DevMenuScreen::OnDeveloperTools);
items->Add(new Choice(dev->T("Jit Compare")))->OnClick.Handle(this, &DevMenuScreen::OnJitCompare);
items->Add(new Choice(dev->T("Shader Viewer")))->OnClick.Handle(this, &DevMenuScreen::OnShaderView);
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
// TODO: Make a new allocator visualizer for VMA.
// items->Add(new CheckBox(&g_Config.bShowAllocatorDebug, dev->T("Allocator Viewer")));
items->Add(new CheckBox(&g_Config.bShowGpuProfile, dev->T("GPU Profile")));
}
items->Add(new Choice(dev->T("Toggle Freeze")))->OnClick.Handle(this, &DevMenu::OnFreezeFrame);
items->Add(new Choice(dev->T("Dump Frame GPU Commands")))->OnClick.Handle(this, &DevMenu::OnDumpFrame);
items->Add(new Choice(dev->T("Toggle Audio Debug")))->OnClick.Handle(this, &DevMenu::OnToggleAudioDebug);
items->Add(new Choice(dev->T("Toggle Freeze")))->OnClick.Handle(this, &DevMenuScreen::OnFreezeFrame);
items->Add(new Choice(dev->T("Dump Frame GPU Commands")))->OnClick.Handle(this, &DevMenuScreen::OnDumpFrame);
items->Add(new Choice(dev->T("Toggle Audio Debug")))->OnClick.Handle(this, &DevMenuScreen::OnToggleAudioDebug);
#ifdef USE_PROFILER
items->Add(new CheckBox(&g_Config.bShowFrameProfiler, dev->T("Frame Profiler"), ""));
#endif
items->Add(new CheckBox(&g_Config.bDrawFrameGraph, dev->T("Draw Frametimes Graph")));
items->Add(new Choice(dev->T("Reset limited logging")))->OnClick.Handle(this, &DevMenu::OnResetLimitedLogging);
items->Add(new Choice(dev->T("Reset limited logging")))->OnClick.Handle(this, &DevMenuScreen::OnResetLimitedLogging);

scroll->Add(items);
parent->Add(scroll);
Expand All @@ -123,48 +123,48 @@ void DevMenu::CreatePopupContents(UI::ViewGroup *parent) {
}
}

UI::EventReturn DevMenu::OnToggleAudioDebug(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnToggleAudioDebug(UI::EventParams &e) {
g_Config.bShowAudioDebug = !g_Config.bShowAudioDebug;
return UI::EVENT_DONE;
}

UI::EventReturn DevMenu::OnResetLimitedLogging(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnResetLimitedLogging(UI::EventParams &e) {
Reporting::ResetCounts();
return UI::EVENT_DONE;
}

UI::EventReturn DevMenu::OnLogView(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnLogView(UI::EventParams &e) {
UpdateUIState(UISTATE_PAUSEMENU);
screenManager()->push(new LogScreen());
return UI::EVENT_DONE;
}

UI::EventReturn DevMenu::OnLogConfig(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnLogConfig(UI::EventParams &e) {
UpdateUIState(UISTATE_PAUSEMENU);
screenManager()->push(new LogConfigScreen());
return UI::EVENT_DONE;
}

UI::EventReturn DevMenu::OnDeveloperTools(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnDeveloperTools(UI::EventParams &e) {
UpdateUIState(UISTATE_PAUSEMENU);
screenManager()->push(new DeveloperToolsScreen());
return UI::EVENT_DONE;
}

UI::EventReturn DevMenu::OnJitCompare(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnJitCompare(UI::EventParams &e) {
UpdateUIState(UISTATE_PAUSEMENU);
screenManager()->push(new JitCompareScreen());
return UI::EVENT_DONE;
}

UI::EventReturn DevMenu::OnShaderView(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnShaderView(UI::EventParams &e) {
UpdateUIState(UISTATE_PAUSEMENU);
if (gpu) // Avoid crashing if chosen while the game is being loaded.
screenManager()->push(new ShaderListScreen());
return UI::EVENT_DONE;
}

UI::EventReturn DevMenu::OnFreezeFrame(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnFreezeFrame(UI::EventParams &e) {
if (PSP_CoreParameter().frozen) {
PSP_CoreParameter().frozen = false;
} else {
Expand All @@ -173,12 +173,12 @@ UI::EventReturn DevMenu::OnFreezeFrame(UI::EventParams &e) {
return UI::EVENT_DONE;
}

UI::EventReturn DevMenu::OnDumpFrame(UI::EventParams &e) {
UI::EventReturn DevMenuScreen::OnDumpFrame(UI::EventParams &e) {
gpu->DumpNextFrame();
return UI::EVENT_DONE;
}

void DevMenu::dialogFinished(const Screen *dialog, DialogResult result) {
void DevMenuScreen::dialogFinished(const Screen *dialog, DialogResult result) {
UpdateUIState(UISTATE_INGAME);
// Close when a subscreen got closed.
// TODO: a bug in screenmanager causes this not to work here.
Expand Down
Loading

0 comments on commit a741922

Please sign in to comment.