Implement Credits.txt export from StartupAboutDlg

Pressing Ctrl+S while on the Credits screen will save everything to
Credits.txt in the current working directory. This is only meant for
developers modifying the credits; the shortcut isn't mentioned anywhere.
install-platforms
Lukas Werling 2018-01-31 21:05:06 +01:00
parent 9e01a861ce
commit 13f082e8c8
3 changed files with 105 additions and 31 deletions

View File

@ -1,15 +1,16 @@
<Engine and Tools>
Sven Eberhardt (Sven2)
Armin Burgmeier (Clonk-Karl)
Günther Brammer (Günther)
Nicolas Hake (Isilkor)
Martin Plicht (Mortimer)
Armin Burgmeier (Clonk-Karl)
Lukas Werling (Luchs)
Julius Michaelis (JCaesar)
Peter Wortmann (PeterW)
Julius Michaelis (Caesar)
<Scripting and Content>
Maikel de Vries (Maikel)
David Dormagen (Zapper)
Mark Haßelbusch (Marky)
Felix Wagner (Clonkonaut)
Bernhard Bonigl (Boni)
@ -26,11 +27,8 @@ Martin Strohmeier (K-Pone)
<Administration>
Tobias Zwick (Newton)
<Thanks to our package maintainers>
Benedict Etzel (B_E), Philipp Kern (pkern), Kevin Zheng and more
<Special Thanks to Contributors>
Martin Adam (Win), Florian Graier (Nachtfalter), Mark Haßelbusch (Marky), Merten Ehmig (pluto), Benjamin Herr (Loriel), Armin Schäfer, Pyrit, Philip Holzmann (Batman), Alexander Semeniuk (AlteredARMOR), Andriel, Peewee, Oliver Schneider (ker), Fabian Pietsch, Manuel Rieke (MrBeast), Felix Riese (Fungiform), Carl-Philip Hänsch (Carli), Sebastian Rühl, Gurkenglas and many more:
Luchs, Asmageddon, mizipzor, Tim Blume, Apfelclonk, Sven-Hendrik Haase, Lauri Niskanen (Ape), Daniel Theuke (ST-DDT), Russell, Stan, TomyLobo, Clonkine, Koronis, Johannes Nixdorf (mixi), grgecko, Dominik Bayerl, Misty de Meo, Lorenz Schwittmann, hasufell, Jan Heberer, dylanstrategie, Checkmaty, Faby
Also, big thanks to Matthes Bender and all those who contributed to previous Clonk titles for the passion they put into the game and for agreeing to make Clonk open source.
Contributors for OpenClonk 8.0: George Tokmaji (Fulgen), Martin Adam (Win), Merten Ehmig (pluto), Florian Graier (Nachtfalter), Philip Holzmann (Foaly), Dominik Bayerl (Kanibal), Linus Heckemann (sphalerite), Pyrit, Armin Schäfer, Tushar Maheshwari, jok, Tarte, Philip Kern (pkern), Arne Schauf (NativeException), Matthias Mailänder, marsmoon
Previous contributors: Tim Blume, Sven-Hendrik Haase, Carl-Philip Hänsch (Carli), Jan Heberer, Benjamin Herr (Loriel), Lauri Niskanen (Ape), Johannes Nixdorf (mixi), Misty de Meo, Fabian Pietsch, Manuel Rieke (MrBeast), Felix Riese (Fungiform), Sebastian Rühl, Oliver Schneider (ker), Lorenz Schwittmann, Alexander Semeniuk (AlteredARMOR), Daniel Theuke (ST-DDT), Andriel, Apfelclonk, Asmageddon, Checkmaty, Clonkine, dylanstrategie, Faby, grgecko, Gurkenglas, hasufell, Koronis, mizipzor, Peewee, Russell, Stan, TomyLobo
Also thanks to our Linux package maintainers Benedict Etzel (B_E), Linus Heckemann (sphalerite), Philip Kern (pkern), Matthias Mailänder, Julian Ospald (hasufell), Kevin Zeng, and more
Finally, a big thanks to Matthes Bender and all those who contributed to previous Clonk titles for the passion they put into the game and for agreeing to make Clonk open source.

View File

@ -22,6 +22,8 @@
#include "graphics/C4GraphicsResource.h"
#include "gui/C4UpdateDlg.h"
#include <fstream>
struct PersonList
{
struct Entry
@ -29,6 +31,7 @@ struct PersonList
const char *name, *nick;
};
virtual void WriteTo(C4GUI::TextWindow *textbox, CStdFont &font) = 0;
virtual std::string ToString() = 0;
virtual ~PersonList() { }
};
@ -45,6 +48,16 @@ static struct DeveloperList : public PersonList
textbox->AddTextLine(FormatString("%s <c f7f76f>(%s)</c>", p.name, p.nick).getData(), &font, C4GUI_MessageFontClr, false, true);
}
}
std::string ToString()
{
std::stringstream out;
for (auto& p : developers)
{
out << p.name << " (" << p.nick << ")\n";
}
return out.str();
}
}
// the following lists are all sorted by all-time commit count: git shortlog -s | sort -rn
engineAndTools =
@ -86,38 +99,65 @@ static struct ContributorList : public PersonList
{
static const std::vector<Entry> contributorsThisRelease, contributors, packageMaintainers;
StdStrBuf ConcatNames(const std::vector<Entry>& names)
std::string ConcatNames(const std::vector<Entry>& names, bool with_color)
{
StdStrBuf result;
const char *opening_tag = with_color ? "<c f7f76f>" : "";
const char *closing_tag = with_color ? "</c>" : "";
std::stringstream result;
bool first = true;
for (auto& p : names)
{
if (result.getLength()) result.Append(", ");
if (!first) result << ", ";
first = false;
if (p.nick)
result.AppendFormat("%s <c f7f76f>(%s)</c>", p.name, p.nick);
result << p.name << " " << opening_tag << "(" << p.nick << ")" << closing_tag;
else
result.Append(p.name);
result << p.name;
}
return result;
return result.str();
}
template<typename Func>
std::string WriteLines(Func f, bool with_color)
{
const char *opening_tag = with_color ? "<c ff0000>" : "";
const char *closing_tag = with_color ? "</c>" : "";
std::stringstream text;
text << opening_tag << "Contributors for OpenClonk 8.0:" << closing_tag << " ";
text << ConcatNames(contributorsThisRelease, with_color);
f(text);
text << opening_tag << "Previous contributors:" << closing_tag << " ";
text << ConcatNames(contributors, with_color);
f(text);
text << opening_tag << "Also thanks to our Linux package maintainers" << closing_tag << " ";
text << ConcatNames(packageMaintainers, with_color);
text << ", and more";
f(text);
text << "Finally, a big thanks to Matthes Bender and all those who contributed to previous Clonk titles for the passion they put into the game and for agreeing to make Clonk open source.";
f(text);
return text.str();
}
void WriteTo(C4GUI::TextWindow *textbox, CStdFont &font)
{
StdStrBuf text;
text = "<c ff0000>Contributors for OpenClonk 8.0:</c> ";
text.Append(ConcatNames(contributorsThisRelease));
textbox->AddTextLine(text.getData(), &font, C4GUI_MessageFontClr, false, true);
WriteLines([&](std::stringstream& text)
{
textbox->AddTextLine(text.str().c_str(), &font, C4GUI_MessageFontClr, false, true);
text.str("");
}, true);
}
text = "<c ff0000>Previous contributors:</c> ";
text.Append(ConcatNames(contributors));
textbox->AddTextLine(text.getData(), &font, C4GUI_MessageFontClr, false, true);
text = "<c ff0000>Also thanks to our Linux package maintainers</c> ";
text.Append(ConcatNames(packageMaintainers));
text.Append(", and more");
textbox->AddTextLine(text.getData(), &font, C4GUI_MessageFontClr, false, true);
text = "Finally, a big thanks to Matthes Bender and all those who contributed to previous Clonk titles for the passion they put into the game and for agreeing to make Clonk open source.";
textbox->AddTextLine(text.getData(), &font, C4GUI_MessageFontClr, false, true);
std::string ToString()
{
return WriteLines([&](std::stringstream& text)
{
text << "\n";
}, false);
}
} contributors;
@ -226,6 +266,8 @@ C4StartupAboutDlg::C4StartupAboutDlg() : C4StartupDlg(LoadResStr("IDS_DLG_ABOUT"
DrawPersonList(C4StartupAboutContributors, contributors, caContributors.GetFromTop(caContributors.GetHeight()));
keySaveCredits = std::make_unique<C4KeyBinding>(C4KeyCodeEx(K_S, KEYS_Control), "StartupAboutSaveCredits", KEYSCOPE_Gui,
new C4GUI::DlgKeyCB<C4StartupAboutDlg>(*this, &C4StartupAboutDlg::SaveCredits), C4CustomKey::PRIO_CtrlOverride);
}
C4StartupAboutDlg::~C4StartupAboutDlg() = default;
@ -247,6 +289,37 @@ void C4StartupAboutDlg::DrawPersonList(int title, PersonList& persons, C4Rect& r
textbox->UpdateHeight();
}
bool C4StartupAboutDlg::SaveCredits()
{
std::ofstream credits("Credits.txt", std::ios::out | std::ios::trunc);
if (!credits)
{
GetScreen()->ShowMessageModal("Couldn't open Credits.txt", "Credits", C4GUI::MessageDialog::btnOK, C4GUI::Ico_Error, nullptr);
return true;
}
credits << "<Engine and Tools>\n";
credits << engineAndTools.ToString();
credits << "\n<Scripting and Content>\n";
credits << scriptingAndContent.ToString();
credits << "\n<Art and Content>\n";
credits << artAndContent.ToString();
credits << "\n<Music and Sound>\n";
credits << musicAndSound.ToString();
credits << "\n<Administration>\n";
credits << administration.ToString();
credits << "\n<Special Thanks to Contributors>\n";
credits << contributors.ToString();
GetScreen()->ShowMessageModal("Saved to Credits.txt", "Credits", C4GUI::MessageDialog::btnOK, C4GUI::Ico_Notify, nullptr);
return true;
}
void C4StartupAboutDlg::DoBack()
{
C4Startup::Get()->SwitchDialog(C4Startup::SDID_Main);

View File

@ -39,6 +39,9 @@ protected:
private:
void DrawPersonList(int title, struct PersonList&, C4Rect& rect);
bool SaveCredits();
std::unique_ptr<C4KeyBinding> keySaveCredits;
public:
void DoBack(); // back to main menu