forked from 0ad/0ad
Add help button to Atlas with a link to the Manual and bugtracker.
Differential Revision: https://code.wildfiregames.com/D794 Patch By: Vladislav This was SVN commit r20021.
This commit is contained in:
parent
993b6c1632
commit
a93d260643
13
binaries/data/tools/atlas/help.json
Normal file
13
binaries/data/tools/atlas/help.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"Manual": {
|
||||
"title": "&Atlas Manual",
|
||||
"tooltip": "Click to visit the 0 A.D. Atlas Wiki.",
|
||||
"url": "https://trac.wildfiregames.com/wiki/Atlas_Manual"
|
||||
},
|
||||
"ReportBug": {
|
||||
"title": "Report a &Bug",
|
||||
"tooltip": "Click to visit our bug tracker to report a crash or other error.",
|
||||
"url": "https://trac.wildfiregames.com/wiki/ReportingErrors"
|
||||
}
|
||||
}
|
||||
|
@ -335,6 +335,9 @@ enum
|
||||
ID_DumpState,
|
||||
ID_DumpBinaryState,
|
||||
|
||||
ID_Manual,
|
||||
ID_ReportBug,
|
||||
|
||||
ID_Toolbar // must be last in the list
|
||||
};
|
||||
|
||||
@ -366,7 +369,10 @@ BEGIN_EVENT_TABLE(ScenarioEditor, wxFrame)
|
||||
EVT_MENU(ID_RenderPathFixed, ScenarioEditor::OnRenderPath)
|
||||
EVT_MENU(ID_RenderPathShader, ScenarioEditor::OnRenderPath)
|
||||
|
||||
EVT_MENU_OPEN(ScenarioEditor::OnMenuOpen)
|
||||
EVT_MENU(ID_Manual, ScenarioEditor::OnHelp)
|
||||
EVT_MENU(ID_ReportBug, ScenarioEditor::OnHelp)
|
||||
|
||||
EVT_MENU_OPEN(ScenarioEditor::OnMenuOpen)
|
||||
|
||||
EVT_IDLE(ScenarioEditor::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
@ -487,6 +493,36 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent)
|
||||
menuRP->Append(ID_RenderPathShader, _("&Shader (default)"));
|
||||
}
|
||||
|
||||
wxMenu *menuHelp = new wxMenu;
|
||||
menuBar->Append(menuHelp, _("&Help"));
|
||||
{
|
||||
const wxString helpPath("../data/tools/atlas/help.json");
|
||||
if (wxFileExists(helpPath))
|
||||
{
|
||||
wxFFile helpFile(helpPath);
|
||||
wxString helpData;
|
||||
helpFile.ReadAll(&helpData);
|
||||
AtObj data = AtlasObject::LoadFromJSON(std::string(helpData));
|
||||
#define ADD_HELP_ITEM(id) \
|
||||
do { \
|
||||
if (!data[#id].hasContent()) \
|
||||
break; \
|
||||
if (!data[#id]["title"].hasContent() || !data[#id]["url"].hasContent()) \
|
||||
break; \
|
||||
menuHelp->Append(ID_##id, _(wxString(data[#id]["title"])), _(wxString(data[#id]["tooltip"]))); \
|
||||
m_HelpData.insert(std::make_pair( \
|
||||
ID_##id, \
|
||||
HelpItem(wxString(data[#id]["title"]), wxString(data[#id]["tooltip"]), wxString(data[#id]["url"])) \
|
||||
)); \
|
||||
} while (0)
|
||||
ADD_HELP_ITEM(Manual);
|
||||
ADD_HELP_ITEM(ReportBug);
|
||||
#undef ADD_HELP_ITEM
|
||||
}
|
||||
else
|
||||
wxLogError(_("'%ls' does not exist"), helpPath.c_str());
|
||||
}
|
||||
|
||||
m_FileHistory.LoadFromSubDir(*wxConfigBase::Get());
|
||||
|
||||
|
||||
@ -943,6 +979,19 @@ void ScenarioEditor::OnSelectedObjectsChange(const std::vector<ObjectID>& select
|
||||
GetMenuBar()->Enable(ID_Copy, !selectedObjects.empty());
|
||||
}
|
||||
|
||||
void ScenarioEditor::OnHelp(wxCommandEvent& event)
|
||||
{
|
||||
std::map<int, HelpItem>::const_iterator it = m_HelpData.find(event.GetId());
|
||||
if (it == m_HelpData.end())
|
||||
return;
|
||||
wxMessageDialog* dialog = new wxMessageDialog(
|
||||
nullptr, _("Do you want to open '" + it->second.m_URL + "'?"),
|
||||
_("Atlas"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION
|
||||
);
|
||||
if (dialog->ShowModal() == wxID_YES)
|
||||
wxLaunchDefaultBrowser(it->second.m_URL);
|
||||
}
|
||||
|
||||
void ScenarioEditor::OnMenuOpen(wxMenuEvent& event)
|
||||
{
|
||||
// This could be done far more elegantly if wxMenuItem had changeable id.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -27,6 +27,8 @@
|
||||
#include "CustomControls/FileHistory/FileHistory.h"
|
||||
#include "SectionLayout.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
class ScenarioEditor : public wxFrame
|
||||
{
|
||||
public:
|
||||
@ -57,9 +59,11 @@ public:
|
||||
void OnCameraReset(wxCommandEvent& event);
|
||||
void OnRenderPath(wxCommandEvent& event);
|
||||
void OnDumpState(wxCommandEvent& event);
|
||||
void OnSelectedObjectsChange(const std::vector<AtlasMessage::ObjectID>& selectedObjects);
|
||||
void OnSelectedObjectsChange(const std::vector<AtlasMessage::ObjectID>& selectedObjects);
|
||||
|
||||
void OnMenuOpen(wxMenuEvent& event);
|
||||
void OnHelp(wxCommandEvent& event);
|
||||
|
||||
void OnMenuOpen(wxMenuEvent& event);
|
||||
|
||||
bool OpenFile(const wxString& name, const wxString& filename);
|
||||
|
||||
@ -95,6 +99,15 @@ private:
|
||||
|
||||
wxIcon m_Icon;
|
||||
|
||||
struct HelpItem
|
||||
{
|
||||
wxString m_Title, m_Tooltip, m_URL;
|
||||
HelpItem(const wxString& title, const wxString& tooltip, const wxString& url)
|
||||
: m_Title(title), m_Tooltip(tooltip), m_URL(url)
|
||||
{}
|
||||
};
|
||||
std::map<int, HelpItem> m_HelpData;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user