mirror of
https://github.com/scummvm/scummvm.git
synced 2024-05-31 18:27:36 -04:00
GUI: Refactored HelpDialog to let easy extension
This commit is contained in:
parent
cfdcfe80a7
commit
93c98b92e9
|
@ -32,10 +32,12 @@ namespace GUI {
|
|||
HelpDialog::HelpDialog()
|
||||
: Dialog("HelpDialog") {
|
||||
|
||||
TabWidget *tab = new TabWidget(this, "HelpDialog.TabWidget");
|
||||
_tab = new TabWidget(this, "HelpDialog.TabWidget");
|
||||
|
||||
tab->addTab(_("General"), "HelpDialog", false);
|
||||
Common::U32String helpText1 = _(
|
||||
static const char * const helpTabs[] = {
|
||||
_s("General"),
|
||||
"",
|
||||
_s(
|
||||
"## Where to get the games\n"
|
||||
"\n"
|
||||
"Visit [our Wiki](https://wiki.scummvm.org/index.php?title=Where_to_get_the_games) for a list of games and where to purchase them.\n"
|
||||
|
@ -51,40 +53,45 @@ HelpDialog::HelpDialog()
|
|||
"through affiliate referral links.\n"
|
||||
"\n"
|
||||
"Additionally, some games that are not available on ZOOM-Platform can be found on GOG.com.\n"
|
||||
);
|
||||
),
|
||||
|
||||
new RichTextWidget(tab, "HelpDialog.TabWidget", helpText1);
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
addTabs(helpTabs);
|
||||
// Now add backend-specific tabs if any
|
||||
const char * const *backendTabs = g_system->buildHelpDialogData();
|
||||
|
||||
if (backendTabs) {
|
||||
while (*backendTabs) {
|
||||
Common::U32String tabName(_(*backendTabs++));
|
||||
const char *imagePack = nullptr;
|
||||
if (backendTabs)
|
||||
addTabs(backendTabs);
|
||||
|
||||
if (*backendTabs && **backendTabs)
|
||||
imagePack = *backendTabs;
|
||||
|
||||
backendTabs++;
|
||||
|
||||
Common::U32String tabText(_(*backendTabs++));
|
||||
|
||||
tab->addTab(tabName, "HelpDialog", false);
|
||||
|
||||
RichTextWidget *rt = new RichTextWidget(tab, "HelpDialog.TabWidget", tabText);
|
||||
|
||||
if (imagePack)
|
||||
rt->setImageArchive(imagePack);
|
||||
}
|
||||
}
|
||||
|
||||
tab->setActiveTab(0);
|
||||
_tab->setActiveTab(0);
|
||||
|
||||
new ButtonWidget(this, "HelpDialog.Close", Common::U32String("Close"), Common::U32String(), kCloseCmd);
|
||||
}
|
||||
|
||||
void HelpDialog::addTabs(const char * const *tabData) {
|
||||
while (*tabData) {
|
||||
Common::U32String tabName(_(*tabData++));
|
||||
const char *imagePack = nullptr;
|
||||
|
||||
if (*tabData && **tabData)
|
||||
imagePack = *tabData;
|
||||
|
||||
tabData++;
|
||||
|
||||
Common::U32String tabText(_(*tabData++));
|
||||
|
||||
_tab->addTab(tabName, "HelpDialog", false);
|
||||
|
||||
RichTextWidget *rt = new RichTextWidget(_tab, "HelpDialog.TabWidget", tabText);
|
||||
|
||||
if (imagePack)
|
||||
rt->setImageArchive(imagePack);
|
||||
}
|
||||
}
|
||||
|
||||
void HelpDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
switch (cmd) {
|
||||
case kCloseCmd:
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
namespace GUI {
|
||||
|
||||
class CommandSender;
|
||||
class StaticTextWidget;
|
||||
class TabWidget;
|
||||
|
||||
/**
|
||||
* Multitab help dialog
|
||||
|
@ -39,6 +39,10 @@ public:
|
|||
HelpDialog();
|
||||
|
||||
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
|
||||
|
||||
private:
|
||||
void addTabs(const char * const *tabs);
|
||||
TabWidget *_tab;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue