OpenClonk
C4StartupLegalDlg.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2010-2020, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 // About/credits screen
17 
18 #include "C4Include.h"
19 #include "gui/C4StartupLegalDlg.h"
20 
21 #include "C4Version.h"
23 #include "game/C4Application.h"
24 #include "C4Licenses.h"
25 
26 
27 // Sorted by commit count this release, e.g.: git shortlog -s v7.0.. | sort -rn
28 // Stuff from the milestone project sorted in-between as those commits usually end up squashed.
29 
30 // ------------------------------------------------
31 // --- C4StartupLegalDlg
32 
34 {
35  // ctor
36  UpdateSize();
37 
38  C4Rect rcClient = GetContainedClientRect();
39 
40  // bottom line buttons and copyright messages
41  C4GUI::ComponentAligner caMain(rcClient, 0,0, true);
42  C4GUI::ComponentAligner caButtons(caMain.GetFromBottom(caMain.GetHeight()*1/8), 0,0, false);
44  int32_t iButtonWidth = caButtons.GetInnerWidth() / 4;
45  AddElement(btn = new C4GUI::CallbackButton<C4StartupLegalDlg>(LoadResStr("IDS_BTN_BACK"), caButtons.GetGridCell(0,3,0,1,iButtonWidth,C4GUI_ButtonHgt,true), &C4StartupLegalDlg::OnBackBtn));
46  btn->SetToolTip(LoadResStr("IDS_DLGTIP_BACKMAIN"));
47 
48  C4Rect rect = caMain.GetFromTop(caMain.GetHeight());
49  auto textbox = new C4GUI::TextWindow(rect, 0, 0, 0, 100, 4096, "", true, nullptr, 0, true);
50  AddElement(textbox);
51  textbox->SetDecoration(false, false, nullptr, true);
52 
53  for(const auto& license : OCLicenses) {
54  textbox->AddTextLine(license.name.c_str(), &::GraphicsResource.TitleFont, C4GUI_NotifyFontClr, false, true);
55  textbox->AddTextLine(license.content.c_str(), &::GraphicsResource.TextFont, C4GUI_MessageFontClr, false, true);
56  textbox->AddTextLine(" ", &::GraphicsResource.TitleFont, C4GUI_MessageFontClr, false, true);
57  }
58 
59  textbox->UpdateHeight();
60 }
61 
63 
65 {
67 }
C4GraphicsResource GraphicsResource
#define C4GUI_NotifyFontClr
Definition: C4Gui.h:46
#define C4GUI_MessageFontClr
Definition: C4Gui.h:43
#define C4GUI_ButtonHgt
Definition: C4Gui.h:111
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
const std::vector< OCLicenseInfo > OCLicenses
int32_t GetHeight() const
Definition: C4Gui.h:2804
int32_t GetInnerWidth() const
Definition: C4Gui.h:2808
bool GetFromTop(int32_t iHgt, int32_t iWdt, C4Rect &rcOut)
Definition: C4Gui.cpp:1059
C4Rect & GetGridCell(int32_t iSectX, int32_t iSectXMax, int32_t iSectY, int32_t iSectYMax, int32_t iSectSizeX=-1, int32_t iSectSizeY=-1, bool fCenterPos=false, int32_t iSectNumX=1, int32_t iSectNumY=1)
Definition: C4Gui.cpp:1148
bool GetFromBottom(int32_t iHgt, int32_t iWdt, C4Rect &rcOut)
Definition: C4Gui.cpp:1109
void AddElement(Element *pChild)
void UpdateSize() override
C4Rect GetContainedClientRect()
Definition: C4Gui.h:448
void SetToolTip(const char *szNewTooltip, bool is_immediate=false)
Definition: C4Gui.cpp:409
Definition: C4Rect.h:28
static C4Startup * Get()
Definition: C4Startup.h:147
@ SDID_About
Definition: C4Startup.h:114
class C4StartupDlg * SwitchDialog(DialogID eToDlg, bool fFade=true, const char *szSubDialog=nullptr)
Definition: C4Startup.cpp:139