2009-05-08 13:28:41 +00:00
/*
* OpenClonk , http : //www.openclonk.org
*
2013-12-17 20:01:09 +00:00
* Copyright ( c ) 2001 - 2009 , RedWolf Design GmbH , http : //www.clonk.de/
2016-04-03 18:18:29 +00:00
* Copyright ( c ) 2010 - 2016 , The OpenClonk Team and contributors
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* Distributed under the terms of the ISC license ; see accompanying file
* " COPYING " for details .
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* " Clonk " is a registered trademark of Matthes Bender , used with permission .
* See accompanying file " TRADEMARK " for details .
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* To redistribute this file separately , substitute the full license texts
* for the above references .
2009-05-08 13:28:41 +00:00
*/
// About/credits screen
2016-04-03 18:07:56 +00:00
# include "C4Include.h"
# include "gui/C4StartupAboutDlg.h"
2015-01-02 20:13:26 +00:00
2016-04-03 18:07:56 +00:00
# include "C4Version.h"
2017-04-30 08:49:09 +00:00
# include "graphics/C4GraphicsResource.h"
# include "gui/C4UpdateDlg.h"
2009-05-08 13:28:41 +00:00
2018-01-31 20:05:06 +00:00
# include <fstream>
2017-12-20 23:02:28 +00:00
struct PersonList
{
struct Entry
{
const char * name , * nick ;
} ;
virtual void WriteTo ( C4GUI : : TextWindow * textbox , CStdFont & font ) = 0 ;
2018-01-31 20:05:06 +00:00
virtual std : : string ToString ( ) = 0 ;
2017-12-20 23:02:28 +00:00
virtual ~ PersonList ( ) { }
} ;
static struct DeveloperList : public PersonList
{
std : : vector < Entry > developers ;
DeveloperList ( std : : initializer_list < Entry > l ) : developers ( l ) { }
void WriteTo ( C4GUI : : TextWindow * textbox , CStdFont & font )
{
for ( auto & p : developers )
{
textbox - > AddTextLine ( FormatString ( " %s <c f7f76f>(%s)</c> " , p . name , p . nick ) . getData ( ) , & font , C4GUI_MessageFontClr , false , true ) ;
}
}
2018-01-31 20:05:06 +00:00
std : : string ToString ( )
{
std : : stringstream out ;
for ( auto & p : developers )
{
out < < p . name < < " ( " < < p . nick < < " ) \n " ;
}
return out . str ( ) ;
}
2017-12-20 23:02:28 +00:00
}
// the following lists are all sorted by all-time commit count: git shortlog -s | sort -rn
engineAndTools =
{
{ " Sven Eberhardt " , " Sven2 " } ,
{ " Günther Brammer " , " Günther " } ,
{ " Nicolas Hake " , " Isilkor " } ,
{ " Armin Burgmeier " , " Clonk-Karl " } ,
{ " Lukas Werling " , " Luchs " } ,
2018-01-31 20:18:27 +00:00
{ " Martin Plicht " , " Mortimer " } ,
2017-12-20 23:02:28 +00:00
{ " Julius Michaelis " , " JCaesar " } ,
{ " Peter Wortmann " , " PeterW " } ,
} ,
scriptingAndContent =
{
{ " Maikel de Vries " , " Maikel " } ,
{ " David Dormagen " , " Zapper " } ,
{ " Mark Haßelbusch " , " Marky " } ,
{ " Felix Wagner " , " Clonkonaut " } ,
{ " Bernhard Bonigl " , " Boni " } ,
} ,
administration =
{
{ " Tobias Zwick " , " Newton " } ,
} ,
artAndContent =
{
{ " Charles Spurrill " , " Ringwaul " } ,
{ " Richard Gerum " , " Randrian " } ,
{ " Timo Stabbert " , " Mimmo " } ,
{ " Matthias Rottländer " , " Matthi " } ,
} ,
musicAndSound =
{
{ " David Oerther " , " ala " } ,
{ " Martin Strohmeier " , " K-Pone " } ,
} ;
static struct ContributorList : public PersonList
{
static const std : : vector < Entry > contributorsThisRelease , contributors , packageMaintainers ;
2018-01-31 20:05:06 +00:00
std : : string ConcatNames ( const std : : vector < Entry > & names , bool with_color )
2017-12-20 23:02:28 +00:00
{
2018-01-31 20:05:06 +00:00
const char * opening_tag = with_color ? " <c f7f76f> " : " " ;
const char * closing_tag = with_color ? " </c> " : " " ;
std : : stringstream result ;
bool first = true ;
2017-12-20 23:02:28 +00:00
for ( auto & p : names )
{
2018-01-31 20:05:06 +00:00
if ( ! first ) result < < " , " ;
first = false ;
2017-12-20 23:02:28 +00:00
if ( p . nick )
2018-01-31 20:05:06 +00:00
result < < p . name < < " " < < opening_tag < < " ( " < < p . nick < < " ) " < < closing_tag ;
2017-12-20 23:02:28 +00:00
else
2018-01-31 20:05:06 +00:00
result < < p . name ;
2017-12-20 23:02:28 +00:00
}
2018-01-31 20:05:06 +00:00
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 ( ) ;
2017-12-20 23:02:28 +00:00
}
void WriteTo ( C4GUI : : TextWindow * textbox , CStdFont & font )
{
2018-01-31 20:05:06 +00:00
WriteLines ( [ & ] ( std : : stringstream & text )
{
textbox - > AddTextLine ( text . str ( ) . c_str ( ) , & font , C4GUI_MessageFontClr , false , true ) ;
text . str ( " " ) ;
} , true ) ;
}
std : : string ToString ( )
{
return WriteLines ( [ & ] ( std : : stringstream & text )
{
text < < " \n " ;
} , false ) ;
2017-12-20 23:02:28 +00:00
}
} contributors ;
// Sorted by commit count this release, e.g.: git shortlog -s v7.0.. | sort -rn
2018-01-07 17:10:52 +00:00
// Stuff from the milestone project sorted in-between as those commits usually end up squashed.
2017-12-20 23:02:28 +00:00
const std : : vector < ContributorList : : Entry > ContributorList : : contributorsThisRelease = {
2018-01-07 17:10:52 +00:00
{ " George Tokmaji " , " Fulgen " } , // 75 commits
{ " Martin Adam " , " Win " } , // lava core animal
{ " Merten Ehmig " , " pluto " } , // helmet
{ " Florian Graier " , " Nachtfalter " } , // tree and guidepost
2018-01-07 18:02:33 +00:00
{ " Philip Holzmann " , " Foaly " } , // "another decorative deciduous tree"
2018-01-07 17:10:52 +00:00
{ " Dominik Bayerl " , " Kanibal " } , // 7 commits
{ " Linus Heckemann " , " sphalerite " } , // 6 commits
{ " Pyrit " , nullptr } , // texture to sproutberry bush
{ " Armin Schäfer " , nullptr } , // 5 commits
{ " Tushar Maheshwari " , nullptr } , // 4 commits
{ " jok " , nullptr } , // 3 commits
{ " Tarte " , nullptr } , // fixed normal map for brick textures
{ " Philip Kern " , " pkern " } , // 2 commits
2018-01-28 20:16:14 +00:00
{ " Arne Schauf " , " NativeException " } , // 1 commit
2018-01-07 17:10:52 +00:00
{ " Matthias Mailänder " , nullptr } , // 1 commit
{ " marsmoon " , nullptr } , // 1 commit
2017-12-20 23:02:28 +00:00
} ;
// First real names sorted by last name (sort -k2), then nicks (sort)
const std : : vector < ContributorList : : Entry > ContributorList : : contributors = {
{ " Tim Blume " , nullptr } ,
{ " Sven-Hendrik Haase " , nullptr } ,
{ " Carl-Philip Hänsch " , " Carli " } ,
{ " Jan Heberer " , nullptr } ,
{ " Benjamin Herr " , " Loriel " } ,
{ " Lauri Niskanen " , " Ape " } ,
{ " Johannes Nixdorf " , " mixi " } ,
{ " Misty de Meo " , nullptr } , // note: three part name
{ " Fabian Pietsch " , nullptr } ,
{ " Manuel Rieke " , " MrBeast " } ,
{ " Felix Riese " , " Fungiform " } ,
{ " Sebastian Rühl " , nullptr } ,
{ " Oliver Schneider " , " ker " } ,
{ " Lorenz Schwittmann " , nullptr } ,
{ " Alexander Semeniuk " , " AlteredARMOR " } ,
{ " Daniel Theuke " , " ST-DDT " } ,
{ " Andriel " , nullptr } ,
{ " Apfelclonk " , nullptr } ,
{ " Asmageddon " , nullptr } ,
{ " Checkmaty " , nullptr } ,
{ " Clonkine " , nullptr } ,
{ " dylanstrategie " , nullptr } ,
{ " Faby " , nullptr } ,
{ " grgecko " , nullptr } ,
{ " Gurkenglas " , nullptr } ,
{ " hasufell " , nullptr } ,
{ " Koronis " , nullptr } ,
{ " mizipzor " , nullptr } ,
{ " Peewee " , nullptr } ,
{ " Russell " , nullptr } ,
{ " Stan " , nullptr } ,
{ " TomyLobo " , nullptr } ,
} ;
// Sorted alphabetically: sort -k2
const std : : vector < ContributorList : : Entry > ContributorList : : packageMaintainers = {
{ " Benedict Etzel " , " B_E " } , // Arch
{ " Linus Heckemann " , " sphalerite " } , // NixOS
{ " Philip Kern " , " pkern " } , // Debian
{ " Matthias Mailänder " , nullptr } , // OpenSUSE
{ " Julian Ospald " , " hasufell " } , // Gentoo
2018-02-17 10:54:48 +00:00
{ " Kevin Zheng " , nullptr } , // FreeBSD
2017-12-20 23:02:28 +00:00
} ;
2009-05-08 13:28:41 +00:00
// ------------------------------------------------
// --- C4StartupAboutDlg
2014-01-24 08:33:47 +00:00
C4StartupAboutDlg : : C4StartupAboutDlg ( ) : C4StartupDlg ( LoadResStr ( " IDS_DLG_ABOUT " ) )
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// ctor
UpdateSize ( ) ;
2010-06-27 00:42:48 +00:00
CStdFont & rUseFont = : : GraphicsResource . TextFont ;
2014-01-24 08:33:47 +00:00
C4Rect rcClient = GetContainedClientRect ( ) ;
2009-05-08 13:28:41 +00:00
2010-04-18 21:13:37 +00:00
// bottom line buttons and copyright messages
2009-05-08 13:28:41 +00:00
C4GUI : : ComponentAligner caMain ( rcClient , 0 , 0 , true ) ;
C4GUI : : ComponentAligner caButtons ( caMain . GetFromBottom ( caMain . GetHeight ( ) * 1 / 8 ) , 0 , 0 , false ) ;
C4GUI : : CallbackButton < C4StartupAboutDlg > * btn ;
int32_t iButtonWidth = caButtons . GetInnerWidth ( ) / 4 ;
AddElement ( btn = new C4GUI : : CallbackButton < C4StartupAboutDlg > ( LoadResStr ( " IDS_BTN_BACK " ) , caButtons . GetGridCell ( 0 , 3 , 0 , 1 , iButtonWidth , C4GUI_ButtonHgt , true ) , & C4StartupAboutDlg : : OnBackBtn ) ) ;
btn - > SetToolTip ( LoadResStr ( " IDS_DLGTIP_BACKMAIN " ) ) ;
2010-12-26 20:39:52 +00:00
# ifdef WITH_AUTOMATIC_UPDATE
2009-05-08 13:28:41 +00:00
AddElement ( btn = new C4GUI : : CallbackButton < C4StartupAboutDlg > ( LoadResStr ( " IDS_BTN_CHECKFORUPDATES " ) , caButtons . GetGridCell ( 2 , 3 , 0 , 1 , iButtonWidth , C4GUI_ButtonHgt , true ) , & C4StartupAboutDlg : : OnUpdateBtn ) ) ;
btn - > SetToolTip ( LoadResStr ( " IDS_DESC_CHECKONLINEFORNEWVERSIONS " ) ) ;
2010-12-26 20:39:52 +00:00
# endif
2015-08-09 17:16:39 +00:00
AddElement ( new C4GUI : : Label ( " 'Clonk' is a registered trademark of Matthes Bender. " ,
caButtons . GetFromBottom ( rUseFont . GetLineHeight ( ) ) ) ) ;
2017-12-20 23:02:28 +00:00
C4GUI : : ComponentAligner caDevelopers ( caMain . GetFromTop ( caMain . GetHeight ( ) * 1 / 2 ) , 0 , 0 , false ) ;
C4GUI : : ComponentAligner caContributors ( caMain . GetFromTop ( caMain . GetHeight ( ) ) , 0 , 0 , false ) ;
DrawPersonList ( C4StartupAboutEngineAndTools , engineAndTools , caDevelopers . GetFromLeft ( caMain . GetWidth ( ) * 1 / 3 ) ) ;
C4GUI : : ComponentAligner caDevelopersCol2 ( caDevelopers . GetFromLeft ( caMain . GetWidth ( ) * 1 / 3 ) , 0 , 0 , false ) ;
DrawPersonList ( C4StartupAboutScriptingAndContent , scriptingAndContent , caDevelopersCol2 . GetFromTop ( caDevelopers . GetHeight ( ) * 2 / 3 ) ) ;
DrawPersonList ( C4StartupAboutAdministration , administration , caDevelopersCol2 . GetFromTop ( caDevelopers . GetHeight ( ) * 1 / 3 ) ) ;
C4GUI : : ComponentAligner caDevelopersCol3 ( caDevelopers . GetFromLeft ( caMain . GetWidth ( ) * 1 / 3 ) , 0 , 0 , false ) ;
DrawPersonList ( C4StartupAboutArtAndContent , artAndContent , caDevelopersCol3 . GetFromTop ( caDevelopers . GetHeight ( ) * 2 / 3 ) ) ;
DrawPersonList ( C4StartupAboutMusicAndSound , musicAndSound , caDevelopersCol3 . GetFromTop ( caDevelopers . GetHeight ( ) * 1 / 3 ) ) ;
DrawPersonList ( C4StartupAboutContributors , contributors , caContributors . GetFromTop ( caContributors . GetHeight ( ) ) ) ;
2018-01-31 20:05:06 +00:00
keySaveCredits = std : : make_unique < C4KeyBinding > ( C4KeyCodeEx ( K_S , KEYS_Control ) , " StartupAboutSaveCredits " , KEYSCOPE_Gui ,
new C4GUI : : DlgKeyCB < C4StartupAboutDlg > ( * this , & C4StartupAboutDlg : : SaveCredits ) , C4CustomKey : : PRIO_CtrlOverride ) ;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
2017-05-03 18:28:00 +00:00
C4StartupAboutDlg : : ~ C4StartupAboutDlg ( ) = default ;
2009-05-08 13:28:41 +00:00
2017-12-20 23:02:28 +00:00
void C4StartupAboutDlg : : DrawPersonList ( int title , PersonList & persons , C4Rect & rect )
{
CStdFont & rUseFont = : : GraphicsResource . TextFont ;
auto image = C4Startup : : Get ( ) - > Graphics . fctAboutTitles . GetPhase ( 0 , title ) ;
int height = 2 * rUseFont . GetFontHeight ( ) , width = std : : min ( image . GetWidthByHeight ( height ) , rect . Wdt ) ;
auto picture = new C4GUI : : Picture ( C4Rect ( rect . x , rect . y , width , height ) , true ) ;
AddElement ( picture ) ;
picture - > SetFacet ( image ) ;
rect . y + = height ; rect . Hgt - = height ;
auto textbox = new C4GUI : : TextWindow ( rect , 0 , 0 , 0 , 100 , 4096 , " " , true , nullptr , 0 , true ) ;
AddElement ( textbox ) ;
textbox - > SetDecoration ( false , false , nullptr , true ) ;
persons . WriteTo ( textbox , rUseFont ) ;
textbox - > UpdateHeight ( ) ;
}
2018-01-31 20:05:06 +00:00
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 ;
}
2009-05-08 13:28:41 +00:00
void C4StartupAboutDlg : : DoBack ( )
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
C4Startup : : Get ( ) - > SwitchDialog ( C4Startup : : SDID_Main ) ;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
void C4StartupAboutDlg : : DrawElement ( C4TargetFacet & cgo )
2010-03-28 18:58:01 +00:00
{
}
2009-05-08 13:28:41 +00:00
2010-12-26 20:39:52 +00:00
# ifdef WITH_AUTOMATIC_UPDATE
2009-05-08 13:28:41 +00:00
void C4StartupAboutDlg : : OnUpdateBtn ( C4GUI : : Control * btn )
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
C4UpdateDlg : : CheckForUpdates ( GetScreen ( ) ) ;
2010-03-28 18:58:01 +00:00
}
2010-12-26 20:39:52 +00:00
# endif