Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: Add more dialogs to dialog dumper #5433

Closed
wants to merge 0 commits into from

Conversation

lunox2004
Copy link
Contributor

No description provided.

Copy link
Contributor

coderabbitai bot commented Nov 14, 2023

Walkthrough

Walkthrough

The changes involve the removal of a function call in the main application code and the expansion of GUI-related functionality in a specific module. The GUI::dumpAllDialogs() function call has been removed from the main application file, while the GUI module has been enhanced with new classes for various dialog types and a utility function to handle dialog snapshot capturing. This suggests a refactoring effort to improve the GUI testing or documentation process.

Changes

File(s) Change Summary
base/main.cpp Removed the GUI::dumpAllDialogs() function call.
gui/dump-all-dialogs.cpp Added new GUI classes (Browser, DownloadDialog, RemoteBrowser, Chooser, CloudConnectionWizard, DownloadPacksDialog, FluidSynthSettingsDialog, ThemeBrowser, MassAddDialog) and a new function handleSimpleDialog to facilitate dialog snapshot capturing. Updated dumpDialogs to use the new handleSimpleDialog function.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Comment on lines 64 to 71
void handleSimpleDialog(GUI::Dialog &dialog, const Common::String &filename,Graphics::Surface &surf) {
dialog.open(); // For rendering
dialog.reflowLayout(); // For updating surface
g_gui.redrawFull();
g_system->grabOverlay(surf);
saveGUISnapshot(surf, filename);
dialog.close();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handleSimpleDialog function is a good abstraction that simplifies the process of taking snapshots of dialogs. However, ensure that the surf parameter is always in a valid state before passing it to saveGUISnapshot. It might be beneficial to check if surf is successfully created before using it.


// MassAddDialog
GUI::MassAddDialog massAddDialog(Common::FSNode("."));
handleSimpleDialog(massAddDialog, "massAddDialog-" + filename, surf);

// LauncherDialog
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LauncherDialog code is commented out with a preprocessor directive #if 0. If this code is no longer needed, it should be removed to avoid confusion. If it's being temporarily disabled for a specific reason, add a comment explaining why.

Comment on lines 88 to 141

Common::String filename = Common::String::format("%d-%s.png", res, lang.c_str());

// Skipping Tooltips as not required

// MessageDialog
GUI::MessageDialog messageDialog(message);
messageDialog.open(); // For rendering
messageDialog.reflowLayout(); // For updating surface
g_gui.redrawFull();
g_system->grabOverlay(surf);
saveGUISnapshot(surf, "message-" + filename);
messageDialog.close();
handleSimpleDialog(messageDialog, "messageDialog-" + filename, surf);

// AboutDialog
GUI::AboutDialog aboutDialog;
aboutDialog.open(); // For rendering
aboutDialog.reflowLayout(); // For updating surface
g_gui.redrawFull();
g_system->grabOverlay(surf);
saveGUISnapshot(surf, "about-" + filename);
aboutDialog.close();
handleSimpleDialog(aboutDialog, "aboutDialog-" + filename, surf);

// CloudConnectingWizard
GUI::CloudConnectionWizard cloudConnectingWizard;
handleSimpleDialog(cloudConnectingWizard, "cloudConnectingWizard-" + filename, surf);

// FluidSynthSettingsDialog
GUI::FluidSynthSettingsDialog fluidSynthSettingsDialog;
handleSimpleDialog(fluidSynthSettingsDialog, "fluidSynthSettings-" + filename, surf);

// ThemeBrowserDialog
GUI::ThemeBrowser themeBrowser;
handleSimpleDialog(themeBrowser, "themeBrowser" + filename, surf);

// BrowserDialog
GUI::BrowserDialog browserDialog(_("Select directory with game data"), true);
handleSimpleDialog(browserDialog, "browserDialog-" + filename, surf);

// RemoteBrowserDialog
GUI::RemoteBrowserDialog remoteBrowserDialog(_("Select directory with game data"));
handleSimpleDialog(remoteBrowserDialog, "remoteBrowserDialog-" + filename, surf);

// ChooserDialog
GUI::ChooserDialog chooserDialog(_("Pick the game:"));
handleSimpleDialog(chooserDialog, "chooserDialog-" + filename, surf);

// DownloadIconPacksDialog
GUI::DownloadPacksDialog downloadIconPacksDialog(_("icon packs"), "LIST", "gui-icons*.dat");
handleSimpleDialog(downloadIconPacksDialog, "downloadIconPacksDialog-" + filename, surf);

// DownloadShaderPacksDialog
GUI::DownloadPacksDialog downloadShaderPacksDialog(_("shader packs"), "LIST-SHADERS", "shaders*.dat");
handleSimpleDialog(downloadShaderPacksDialog, "downloadShaderPacksDialog-" + filename, surf);

// MassAddDialog
GUI::MassAddDialog massAddDialog(Common::FSNode("."));
handleSimpleDialog(massAddDialog, "massAddDialog-" + filename, surf);

// LauncherDialog
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dumpDialogs function has been updated to handle various new dialogs using the handleSimpleDialog function. This is a good use of abstraction to reduce code duplication. However, ensure that the surf object is properly disposed of after use to prevent any memory leaks. Additionally, the concatenation in line 111 is missing a hyphen before the filename, which could lead to incorrect file naming.

- handleSimpleDialog(themeBrowser, "themeBrowser" + filename, surf);
+ handleSimpleDialog(themeBrowser, "themeBrowser-" + filename, surf);

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Common::String filename = Common::String::format("%d-%s.png", res, lang.c_str());
// Skipping Tooltips as not required
// MessageDialog
GUI::MessageDialog messageDialog(message);
messageDialog.open(); // For rendering
messageDialog.reflowLayout(); // For updating surface
g_gui.redrawFull();
g_system->grabOverlay(surf);
saveGUISnapshot(surf, "message-" + filename);
messageDialog.close();
handleSimpleDialog(messageDialog, "messageDialog-" + filename, surf);
// AboutDialog
GUI::AboutDialog aboutDialog;
aboutDialog.open(); // For rendering
aboutDialog.reflowLayout(); // For updating surface
g_gui.redrawFull();
g_system->grabOverlay(surf);
saveGUISnapshot(surf, "about-" + filename);
aboutDialog.close();
handleSimpleDialog(aboutDialog, "aboutDialog-" + filename, surf);
// CloudConnectingWizard
GUI::CloudConnectionWizard cloudConnectingWizard;
handleSimpleDialog(cloudConnectingWizard, "cloudConnectingWizard-" + filename, surf);
// FluidSynthSettingsDialog
GUI::FluidSynthSettingsDialog fluidSynthSettingsDialog;
handleSimpleDialog(fluidSynthSettingsDialog, "fluidSynthSettings-" + filename, surf);
// ThemeBrowserDialog
GUI::ThemeBrowser themeBrowser;
handleSimpleDialog(themeBrowser, "themeBrowser" + filename, surf);
// BrowserDialog
GUI::BrowserDialog browserDialog(_("Select directory with game data"), true);
handleSimpleDialog(browserDialog, "browserDialog-" + filename, surf);
// RemoteBrowserDialog
GUI::RemoteBrowserDialog remoteBrowserDialog(_("Select directory with game data"));
handleSimpleDialog(remoteBrowserDialog, "remoteBrowserDialog-" + filename, surf);
// ChooserDialog
GUI::ChooserDialog chooserDialog(_("Pick the game:"));
handleSimpleDialog(chooserDialog, "chooserDialog-" + filename, surf);
// DownloadIconPacksDialog
GUI::DownloadPacksDialog downloadIconPacksDialog(_("icon packs"), "LIST", "gui-icons*.dat");
handleSimpleDialog(downloadIconPacksDialog, "downloadIconPacksDialog-" + filename, surf);
// DownloadShaderPacksDialog
GUI::DownloadPacksDialog downloadShaderPacksDialog(_("shader packs"), "LIST-SHADERS", "shaders*.dat");
handleSimpleDialog(downloadShaderPacksDialog, "downloadShaderPacksDialog-" + filename, surf);
// MassAddDialog
GUI::MassAddDialog massAddDialog(Common::FSNode("."));
handleSimpleDialog(massAddDialog, "massAddDialog-" + filename, surf);
// LauncherDialog
#if 0
Common::String filename = Common::String::format("%d-%s.png", res, lang.c_str());
// Skipping Tooltips as not required
// MessageDialog
GUI::MessageDialog messageDialog(message);
handleSimpleDialog(messageDialog, "messageDialog-" + filename, surf);
// AboutDialog
GUI::AboutDialog aboutDialog;
handleSimpleDialog(aboutDialog, "aboutDialog-" + filename, surf);
// CloudConnectingWizard
GUI::CloudConnectionWizard cloudConnectingWizard;
handleSimpleDialog(cloudConnectingWizard, "cloudConnectingWizard-" + filename, surf);
// FluidSynthSettingsDialog
GUI::FluidSynthSettingsDialog fluidSynthSettingsDialog;
handleSimpleDialog(fluidSynthSettingsDialog, "fluidSynthSettings-" + filename, surf);
// ThemeBrowserDialog
GUI::ThemeBrowser themeBrowser;
handleSimpleDialog(themeBrowser, "themeBrowser-" + filename, surf);
// BrowserDialog
GUI::BrowserDialog browserDialog(_("Select directory with game data"), true);
handleSimpleDialog(browserDialog, "browserDialog-" + filename, surf);
// RemoteBrowserDialog
GUI::RemoteBrowserDialog remoteBrowserDialog(_("Select directory with game data"));
handleSimpleDialog(remoteBrowserDialog, "remoteBrowserDialog-" + filename, surf);
// ChooserDialog
GUI::ChooserDialog chooserDialog(_("Pick the game:"));
handleSimpleDialog(chooserDialog, "chooserDialog-" + filename, surf);
// DownloadIconPacksDialog
GUI::DownloadPacksDialog downloadIconPacksDialog(_("icon packs"), "LIST", "gui-icons*.dat");
handleSimpleDialog(downloadIconPacksDialog, "downloadIconPacksDialog-" + filename, surf);
// DownloadShaderPacksDialog
GUI::DownloadPacksDialog downloadShaderPacksDialog(_("shader packs"), "LIST-SHADERS", "shaders*.dat");
handleSimpleDialog(downloadShaderPacksDialog, "downloadShaderPacksDialog-" + filename, surf);
// MassAddDialog
GUI::MassAddDialog massAddDialog(Common::FSNode("."));
handleSimpleDialog(massAddDialog, "massAddDialog-" + filename, surf);
// LauncherDialog
#if 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant