Commit 99301eb1 authored by sm's avatar sm

Add website to game author

parent 43f624d0
......@@ -42,6 +42,7 @@ public:
{
std::string m_sName; /**< Author name. */
std::string m_sEmail; /**< Author email. */
std::string m_sWebSite; /**< Author web site. */
std::string m_sRole; /**< Author role. */
};
std::vector<Author> m_aAuthors; /**< All the authors. */
......
......@@ -74,8 +74,8 @@ GameDialog::GameDialog(const shared_ptr<StdConfig>& refStdConfig, GameLoader& oG
constexpr int32_t nTotTabs = sizeof(m_aPageIndex) / sizeof(m_aPageIndex[0]);
static_assert(nTotTabs == 3, "");
m_p0TabLabelGames = Gtk::manage(new Gtk::Label("Games"));
m_p0TabVBoxGamesShow = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
Gtk::Label* m_p0TabLabelGames = Gtk::manage(new Gtk::Label("Games"));
Gtk::Box* m_p0TabVBoxGamesShow = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
m_aPageIndex[s_nTabGames] = m_p0NotebookGames->append_page(*m_p0TabVBoxGamesShow, *m_p0TabLabelGames);
Gtk::ScrolledWindow* m_p0ScrolledGames = Gtk::manage(new Gtk::ScrolledWindow());
m_p0TabVBoxGamesShow->pack_start(*m_p0ScrolledGames, true, true);
......@@ -94,14 +94,17 @@ GameDialog::GameDialog(const shared_ptr<StdConfig>& refStdConfig, GameLoader& oG
m_p0TabVBoxGamesShow->pack_start(*m_p0CheckShowPlayedHistory, false, false, 5);
m_p0CheckShowPlayedHistory->signal_clicked().connect(sigc::mem_fun(*this, &GameDialog::onShowPlayedHistoryChanged));
m_p0TabLabelDescription = Gtk::manage(new Gtk::Label("Description"));
m_p0TabVBoxDescription = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
Gtk::Label* m_p0TabLabelDescription = Gtk::manage(new Gtk::Label("Description"));
Gtk::Box* m_p0TabVBoxDescription = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
m_aPageIndex[s_nTabDescription] = m_p0NotebookGames->append_page(*m_p0TabVBoxDescription, *m_p0TabLabelDescription);
m_p0TabVBoxDescription->set_border_width(5);
m_p0ImageGameImage = Gtk::manage(new Gtk::Image());
m_p0TabVBoxDescription->pack_start(*m_p0ImageGameImage, true, true);
m_p0TabVBoxDescription->pack_start(*m_p0ImageGameImage, false, true);
m_p0LabelGameName = Gtk::manage(new Gtk::Label("-"));
m_p0TabVBoxDescription->pack_start(*m_p0LabelGameName, true, true);
m_p0TabVBoxDescription->pack_start(*m_p0LabelGameName, false, true);
m_p0LabelGameName->set_margin_top(5);
m_p0LabelGameName->set_margin_bottom(5);
{
Pango::AttrList oAttrList;
Pango::AttrColor oAttrColor = Pango::Attribute::create_attr_foreground(std::numeric_limits<guint16>::max()
, std::numeric_limits<guint16>::min()
......@@ -109,22 +112,55 @@ GameDialog::GameDialog(const shared_ptr<StdConfig>& refStdConfig, GameLoader& oG
oAttrList.insert(oAttrColor);
Pango::AttrInt oAttrWeight = Pango::Attribute::create_attr_weight(Pango::WEIGHT_HEAVY);
oAttrList.insert(oAttrWeight);
Pango::AttrFloat oAttrScale = Pango::Attribute::create_attr_scale(2.0);
oAttrList.insert(oAttrScale);
m_p0LabelGameName->set_attributes(oAttrList);
m_p0TextDescription = Gtk::manage(new Gtk::TextView());
m_p0TabVBoxDescription->pack_start(*m_p0TextDescription, true, true);
m_p0TextDescription->set_wrap_mode(Gtk::WrapMode::WRAP_WORD);
m_p0TextDescription->set_left_margin(5);
m_p0TextDescription->set_right_margin(5);
m_refTextBufferDescription = m_p0TextDescription->get_buffer();
m_p0LabelConstraints = Gtk::manage(new Gtk::Label("Constraints:"));
m_p0TextConstraints = Gtk::manage(new Gtk::TextView());
m_p0TabVBoxDescription->pack_start(*m_p0TextConstraints, true, true);
m_p0TextConstraints->set_wrap_mode(Gtk::WrapMode::WRAP_WORD);
m_refTextBufferConstraints = m_p0TextConstraints->get_buffer();
}
Gtk::ScrolledWindow* m_p0ScrolledDescription = Gtk::manage(new Gtk::ScrolledWindow());
m_p0TabVBoxDescription->pack_start(*m_p0ScrolledDescription, true, true);
Gtk::Box* m_p0VBoxScroller = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
m_p0ScrolledDescription->add(*m_p0VBoxScroller);
m_p0TextDescription = Gtk::manage(new Gtk::TextView());
m_p0VBoxScroller->pack_start(*m_p0TextDescription, true, true);
m_p0TextDescription->set_wrap_mode(Gtk::WrapMode::WRAP_WORD);
m_p0TextDescription->set_left_margin(5);
m_p0TextDescription->set_right_margin(5);
m_refTextBufferDescription = m_p0TextDescription->get_buffer();
Gtk::Label* m_p0LabelConstraints = Gtk::manage(new Gtk::Label("Constraints:"));
m_p0VBoxScroller->pack_start(*m_p0LabelConstraints, true, true);
m_p0LabelConstraints->set_halign(Gtk::Align::ALIGN_START);
m_p0LabelConstraints->set_margin_top(8);
m_p0LabelConstraints->set_margin_bottom(3);
{
Pango::AttrList oAttrList;
Pango::AttrInt oAttrWeight = Pango::Attribute::create_attr_weight(Pango::WEIGHT_HEAVY);
oAttrList.insert(oAttrWeight);
m_p0LabelConstraints->set_attributes(oAttrList);
}
m_p0TextConstraints = Gtk::manage(new Gtk::TextView());
m_p0VBoxScroller->pack_start(*m_p0TextConstraints, true, true);
m_p0TextConstraints->set_wrap_mode(Gtk::WrapMode::WRAP_WORD);
m_refTextBufferConstraints = m_p0TextConstraints->get_buffer();
Gtk::Label* m_p0LabelAuthors = Gtk::manage(new Gtk::Label("Authors:"));
m_p0VBoxScroller->pack_start(*m_p0LabelAuthors, true, true);
m_p0LabelAuthors->set_halign(Gtk::Align::ALIGN_START);
m_p0LabelAuthors->set_margin_top(3);
m_p0LabelAuthors->set_margin_bottom(3);
{
Pango::AttrList oAttrList;
Pango::AttrInt oAttrWeight = Pango::Attribute::create_attr_weight(Pango::WEIGHT_HEAVY);
oAttrList.insert(oAttrWeight);
m_p0LabelAuthors->set_attributes(oAttrList);
}
m_p0TextAuthors = Gtk::manage(new Gtk::TextView());
m_p0VBoxScroller->pack_start(*m_p0TextAuthors, true, true);
m_p0TextAuthors->set_wrap_mode(Gtk::WrapMode::WRAP_WORD);
m_p0TextAuthors->set_vscroll_policy(Gtk::ScrollablePolicy::SCROLL_MINIMUM);
m_refTextBufferAuthors = m_p0TextAuthors->get_buffer();
if (m_refStdConfig->isTestMode()) {
m_p0TabLabelLoading = Gtk::manage(new Gtk::Label("Test"));
m_p0TabVBoxLoading = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
Gtk::Label* m_p0TabLabelLoading = Gtk::manage(new Gtk::Label("Test"));
Gtk::Box* m_p0TabVBoxLoading = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
m_aPageIndex[s_nTabLoading] = m_p0NotebookGames->append_page(*m_p0TabVBoxLoading, *m_p0TabLabelLoading);
m_p0TextLoadingError = Gtk::manage(new Gtk::TextView());
m_p0TabVBoxLoading->pack_start(*m_p0TextLoadingError, true, true);
......@@ -244,6 +280,7 @@ void GameDialog::regenerateGamesList()
m_sSelectedGameName = "";
}
refTreeSelection->select(oPath);
m_p0TreeViewGames->scroll_to_row(oPath);
//
m_p0CheckShowAllGames->set_active(m_bShowAllGames);
m_p0CheckShowPlayedHistory->set_active(m_bShowPlayedHistory);
......@@ -259,6 +296,7 @@ void GameDialog::regenerateGameInfos()
m_p0LabelGameName->set_label("");
m_refTextBufferDescription->set_text("");
m_refTextBufferConstraints->set_text("");
m_refTextBufferAuthors->set_text("");
if (m_refStdConfig->isTestMode()) {
m_refTextBufferLoadingError->set_text("");
}
......@@ -317,6 +355,23 @@ void GameDialog::regenerateGameInfos()
}
}
m_refTextBufferConstraints->set_text(sConstraints);
std::string sAuthors;
for (const GameLoader::GameInfo::Author& oAuthor : oGameInfo.m_aAuthors) {
if (! sAuthors.empty()) {
sAuthors += "\n";
}
sAuthors += "Name: " + oAuthor.m_sName;
if (! oAuthor.m_sEmail.empty()) {
sAuthors += "\n email: " + oAuthor.m_sEmail;
}
if (! oAuthor.m_sWebSite.empty()) {
sAuthors += "\n website: " + oAuthor.m_sWebSite;
}
if (! oAuthor.m_sRole.empty()) {
sAuthors += "\n role: " + oAuthor.m_sRole;
}
}
m_refTextBufferAuthors->set_text(sAuthors);
if (m_refStdConfig->isTestMode()) {
std::string sError = oGameInfo.m_sGameErrorString;
if (oGameInfo.m_bLoaded && sError.empty()) {
......
......@@ -106,27 +106,32 @@ private:
int32_t m_aPageIndex[3];
static const int32_t s_nTabGames = 0;
Gtk::Label* m_p0TabLabelGames = nullptr;
Gtk::Box* m_p0TabVBoxGamesShow = nullptr;
//Gtk::Label* m_p0TabLabelGames = nullptr;
//Gtk::Box* m_p0TabVBoxGamesShow = nullptr;
//Gtk::ScrolledWindow* m_p0ScrolledGames = nullptr;
GamesTreeView* m_p0TreeViewGames = nullptr;
Gtk::CheckButton* m_p0CheckShowAllGames = nullptr;
Gtk::CheckButton* m_p0CheckShowPlayedHistory = nullptr;
static const int32_t s_nTabDescription = 1;
Gtk::Label* m_p0TabLabelDescription = nullptr;
Gtk::Box* m_p0TabVBoxDescription = nullptr;
//Gtk::Label* m_p0TabLabelDescription = nullptr;
//Gtk::Box* m_p0TabVBoxDescription = nullptr;
Gtk::Image* m_p0ImageGameImage = nullptr;
Gtk::Label* m_p0LabelGameName = nullptr;
Gtk::TextView* m_p0TextDescription = nullptr;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBufferDescription;
Gtk::Label* m_p0LabelConstraints = nullptr;
Gtk::TextView* m_p0TextConstraints = nullptr;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBufferConstraints;
//Gtk::ScrolledWindow* m_p0ScrolledDescription = nullptr;
//Gtk::Box* m_p0VBoxScroller = nullptr;
Gtk::TextView* m_p0TextDescription = nullptr;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBufferDescription;
//Gtk::Label* m_p0LabelAuthors = nullptr;
Gtk::TextView* m_p0TextAuthors = nullptr;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBufferAuthors;
//Gtk::Label* m_p0LabelConstraints = nullptr;
Gtk::TextView* m_p0TextConstraints = nullptr;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBufferConstraints;
static const int32_t s_nTabLoading = 2;
Gtk::Label* m_p0TabLabelLoading = nullptr;
Gtk::Box* m_p0TabVBoxLoading = nullptr;
//Gtk::Label* m_p0TabLabelLoading = nullptr;
//Gtk::Box* m_p0TabVBoxLoading = nullptr;
Gtk::TextView* m_p0TextLoadingError = nullptr;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBufferLoadingError;
......
......@@ -57,8 +57,8 @@ ThemeDialog::ThemeDialog(const shared_ptr<StdConfig>& refStdConfig, ThemeLoader&
m_p0NotebookThemes->signal_switch_page().connect(
sigc::mem_fun(*this, &ThemeDialog::onNotebookSwitchPage) );
m_p0TabLabelThemes = Gtk::manage(new Gtk::Label("Themes"));
m_p0TabVBoxThemesShow = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
Gtk::Label* m_p0TabLabelThemes = Gtk::manage(new Gtk::Label("Themes"));
Gtk::Box* m_p0TabVBoxThemesShow = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
m_p0NotebookThemes->append_page(*m_p0TabVBoxThemesShow, *m_p0TabLabelThemes);
m_refTreeModelThemes = Gtk::TreeStore::create(m_oThemesColumns);
m_p0TreeViewThemes = Gtk::manage(new ThemesTreeView(this, m_refTreeModelThemes));
......@@ -69,8 +69,8 @@ ThemeDialog::ThemeDialog(const shared_ptr<StdConfig>& refStdConfig, ThemeLoader&
refTreeSelection->signal_changed().connect(
sigc::mem_fun(*this, &ThemeDialog::onThemeSelectionChanged));
m_p0TabLabelLoading = Gtk::manage(new Gtk::Label("Test"));
m_p0TabVBoxLoading = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
Gtk::Label* m_p0TabLabelLoading = Gtk::manage(new Gtk::Label("Test"));
Gtk::Box* m_p0TabVBoxLoading = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
m_p0NotebookThemes->append_page(*m_p0TabVBoxLoading, *m_p0TabLabelLoading);
m_p0TextLoadingError = Gtk::manage(new Gtk::TextView());
m_p0TabVBoxLoading->pack_start(*m_p0TextLoadingError, true, true);
......@@ -155,6 +155,7 @@ void ThemeDialog::regenerateThemesList()
m_sSelectedThemeName = "";
}
refTreeSelection->select(oPath);
m_p0TreeViewThemes->scroll_to_row(oPath);
m_bRegenerateThemesListInProgress = false;
//
......
......@@ -86,13 +86,13 @@ private:
Gtk::Notebook* m_p0NotebookThemes = nullptr;
static const int32_t s_nTabThemes = 0;
Gtk::Label* m_p0TabLabelThemes = nullptr;
Gtk::Box* m_p0TabVBoxThemesShow = nullptr;
//Gtk::Label* m_p0TabLabelThemes = nullptr;
//Gtk::Box* m_p0TabVBoxThemesShow = nullptr;
ThemesTreeView* m_p0TreeViewThemes = nullptr;
static const int32_t s_nTabLoading = 1;
Gtk::Label* m_p0TabLabelLoading = nullptr;
Gtk::Box* m_p0TabVBoxLoading = nullptr;
//Gtk::Label* m_p0TabLabelLoading = nullptr;
//Gtk::Box* m_p0TabVBoxLoading = nullptr;
Gtk::TextView* m_p0TextLoadingError = nullptr;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBufferLoadingError;
......
......@@ -47,6 +47,7 @@ static const std::string s_sGameDescriptionNodeName = "Description";
static const std::string s_sGameAuthorNodeName = "Author";
static const std::string s_sGameAuthorNameAttr = "name";
static const std::string s_sGameAuthorEmailAttr = "email";
static const std::string s_sGameAuthorWebSiteAttr = "website";
static const std::string s_sGameAuthorRoleAttr = "role";
static const std::string s_sGameConstraintsNodeName = "Constraints";
......@@ -174,12 +175,18 @@ const GameLoader::GameInfo& XmlGameInfoParser::parseGameInfo(GameInfoCtx& oCtx,
oCtx.addChecker(p0AuthorEl);
const auto oPairAuthorName = XmlCommonParser::getAttributeValue(oCtx, p0AuthorEl, s_sGameAuthorNameAttr);
const auto oPairAuthorEmail = XmlCommonParser::getAttributeValue(oCtx, p0AuthorEl, s_sGameAuthorEmailAttr);
const auto oPairAuthorWebSite = XmlCommonParser::getAttributeValue(oCtx, p0AuthorEl, s_sGameAuthorWebSiteAttr);
const auto oPairAuthorRole = XmlCommonParser::getAttributeValue(oCtx, p0AuthorEl, s_sGameAuthorRoleAttr);
if (oPairAuthorName.second.empty() && oPairAuthorEmail.second.empty()) {
throw XmlCommonErrors::errorAttrEitherMustBeDefined(oCtx, p0AuthorEl, s_sGameAuthorNameAttr, s_sGameAuthorEmailAttr);
}
//Author{m_sName, m_sEmail, m_sRole}
oCtx.m_oGameInfo.m_aAuthors.push_back({oPairAuthorName.second, oPairAuthorEmail.second, oPairAuthorRole.second});
GameLoader::GameInfo::Author oAuthor;
oAuthor.m_sName = oPairAuthorName.second;
oAuthor.m_sEmail = oPairAuthorEmail.second;
oAuthor.m_sWebSite = oPairAuthorWebSite.second;
oAuthor.m_sRole = oPairAuthorRole.second;
oCtx.m_oGameInfo.m_aAuthors.push_back(std::move(oAuthor));
oCtx.removeChecker(p0AuthorEl, true);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment