mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Some cleanup, make the DevTools LogView work slightly better. Though, it needs more work.
This commit is contained in:
1 parent
a97ea04827
commit
f168aa3aee
4 files changed
+25
-44
No files matched your search
@@ -56,9 +56,8 @@ ENUM_CLASS_BITOPS(LogOutput);
|
||||
class RingbufferLog {
|
||||
public:
|
||||
void Log(const LogMessage &msg);
|
||||
|
||||
int GetCount() const { return count_ < MAX_LOGS ? count_ : MAX_LOGS; }
|
||||
const char *TextAt(int i) const { return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].msg.c_str(); }
|
||||
std::string_view TextAt(int i) const { return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].msg; }
|
||||
LogLevel LevelAt(int i) const { return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].level; }
|
||||
|
||||
void Clear() {
|
||||
@@ -67,7 +66,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
enum { MAX_LOGS = 128 };
|
||||
enum { MAX_LOGS = 256 };
|
||||
LogMessage messages_[MAX_LOGS];
|
||||
int curMessage_ = 0;
|
||||
int count_ = 0;
|
||||
|
||||
+19
-36
@@ -122,14 +122,23 @@ void DevMenuScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f));
|
||||
LinearLayout *items = new LinearLayout(ORIENT_VERTICAL);
|
||||
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
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, &DevMenuScreen::OnLogConfig);
|
||||
items->Add(new Choice(dev->T("Log View")))->OnClick.Add([this](UI::EventParams & e) {
|
||||
UpdateUIState(UISTATE_PAUSEMENU);
|
||||
screenManager()->push(new LogViewScreen());
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
|
||||
items->Add(new Choice(dev->T("Logging Channels")))->OnClick.Add([this](UI::EventParams & e) {
|
||||
UpdateUIState(UISTATE_PAUSEMENU);
|
||||
screenManager()->push(new LogConfigScreen());
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
|
||||
items->Add(new Choice(dev->T("Debugger")))->OnClick.Add([](UI::EventParams &e) {
|
||||
g_Config.bShowImDebugger = !g_Config.bShowImDebugger;
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
|
||||
items->Add(new Choice(sy->T("Developer Tools")))->OnClick.Handle(this, &DevMenuScreen::OnDeveloperTools);
|
||||
|
||||
// Debug overlay
|
||||
@@ -187,18 +196,6 @@ UI::EventReturn DevMenuScreen::OnResetLimitedLogging(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn DevMenuScreen::OnLogView(UI::EventParams &e) {
|
||||
UpdateUIState(UISTATE_PAUSEMENU);
|
||||
screenManager()->push(new LogScreen());
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn DevMenuScreen::OnLogConfig(UI::EventParams &e) {
|
||||
UpdateUIState(UISTATE_PAUSEMENU);
|
||||
screenManager()->push(new LogConfigScreen());
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn DevMenuScreen::OnDeveloperTools(UI::EventParams &e) {
|
||||
UpdateUIState(UISTATE_PAUSEMENU);
|
||||
screenManager()->push(new DeveloperToolsScreen(gamePath_));
|
||||
@@ -235,14 +232,16 @@ void GPIGPOScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
}
|
||||
}
|
||||
|
||||
void LogScreen::UpdateLog() {
|
||||
void LogViewScreen::UpdateLog() {
|
||||
using namespace UI;
|
||||
const RingbufferLog *ring = g_logManager.GetRingbuffer();
|
||||
if (!ring)
|
||||
return;
|
||||
vert_->Clear();
|
||||
|
||||
// TODO: Direct rendering without TextViews.
|
||||
for (int i = ring->GetCount() - 1; i >= 0; i--) {
|
||||
TextView *v = vert_->Add(new TextView(ring->TextAt(i), FLAG_DYNAMIC_ASCII, false));
|
||||
TextView *v = vert_->Add(new TextView(StripSpaces(ring->TextAt(i)), FLAG_DYNAMIC_ASCII, true));
|
||||
uint32_t color = 0xFFFFFF;
|
||||
switch (ring->LevelAt(i)) {
|
||||
case LogLevel::LDEBUG: color = 0xE0E0E0; break;
|
||||
@@ -257,7 +256,7 @@ void LogScreen::UpdateLog() {
|
||||
toBottom_ = true;
|
||||
}
|
||||
|
||||
void LogScreen::update() {
|
||||
void LogViewScreen::update() {
|
||||
UIDialogScreenWithBackground::update();
|
||||
if (toBottom_) {
|
||||
toBottom_ = false;
|
||||
@@ -265,7 +264,7 @@ void LogScreen::update() {
|
||||
}
|
||||
}
|
||||
|
||||
void LogScreen::CreateViews() {
|
||||
void LogViewScreen::CreateViews() {
|
||||
using namespace UI;
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
|
||||
@@ -275,9 +274,6 @@ 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", "Command Line", new LinearLayoutParams(1.0)));
|
||||
cmdLine_->OnEnter.Handle(this, &LogScreen::OnSubmit);
|
||||
bottom->Add(new Button(di->T("Submit")))->OnClick.Handle(this, &LogScreen::OnSubmit);
|
||||
|
||||
vert_ = scroll_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
vert_->SetSpacing(0);
|
||||
@@ -285,19 +281,6 @@ void LogScreen::CreateViews() {
|
||||
UpdateLog();
|
||||
}
|
||||
|
||||
UI::EventReturn LogScreen::OnSubmit(UI::EventParams &e) {
|
||||
std::string cmd = cmdLine_->GetText();
|
||||
|
||||
// TODO: Can add all sorts of fun stuff here that we can't be bothered writing proper UI for, like various memdumps etc.
|
||||
|
||||
NOTICE_LOG(Log::System, "Submitted: %s", cmd.c_str());
|
||||
|
||||
UpdateLog();
|
||||
cmdLine_->SetText("");
|
||||
cmdLine_->SetFocus();
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
void LogConfigScreen::CreateViews() {
|
||||
using namespace UI;
|
||||
|
||||
|
||||
+1
-5
@@ -38,8 +38,6 @@ public:
|
||||
void dialogFinished(const Screen *dialog, DialogResult result) override;
|
||||
|
||||
protected:
|
||||
UI::EventReturn OnLogView(UI::EventParams &e);
|
||||
UI::EventReturn OnLogConfig(UI::EventParams &e);
|
||||
UI::EventReturn OnJitCompare(UI::EventParams &e);
|
||||
UI::EventReturn OnShaderView(UI::EventParams &e);
|
||||
UI::EventReturn OnDeveloperTools(UI::EventParams &e);
|
||||
@@ -76,7 +74,7 @@ private:
|
||||
UI::EventReturn OnLogLevelChange(UI::EventParams &e);
|
||||
};
|
||||
|
||||
class LogScreen : public UIDialogScreenWithBackground {
|
||||
class LogViewScreen : public UIDialogScreenWithBackground {
|
||||
public:
|
||||
void CreateViews() override;
|
||||
void update() override;
|
||||
@@ -85,9 +83,7 @@ public:
|
||||
|
||||
private:
|
||||
void UpdateLog();
|
||||
UI::EventReturn OnSubmit(UI::EventParams &e);
|
||||
|
||||
UI::TextEdit *cmdLine_ = nullptr;
|
||||
UI::LinearLayout *vert_ = nullptr;
|
||||
UI::ScrollView *scroll_ = nullptr;
|
||||
bool toBottom_ = false;
|
||||
|
||||
@@ -25,6 +25,7 @@ using namespace std::placeholders;
|
||||
#include "Common/GPU/OpenGL/GLFeatures.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
#include "Common/Log/LogManager.h"
|
||||
#include "Common/UI/Root.h"
|
||||
#include "Common/UI/UI.h"
|
||||
#include "Common/UI/Context.h"
|
||||
@@ -455,6 +456,8 @@ EmuScreen::~EmuScreen() {
|
||||
SetExtraAssertInfo(nullptr);
|
||||
SetAssertCancelCallback(nullptr, nullptr);
|
||||
|
||||
g_logManager.EnableOutput(LogOutput::RingBuffer);
|
||||
|
||||
#ifndef MOBILE_DEVICE
|
||||
if (g_Config.bDumpFrames && startDumping)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user