openclonk/src/gui/C4StartupAboutDlg.cpp

108 lines
3.9 KiB
C++
Raw Normal View History

2009-05-08 13:28:41 +00:00
/*
* OpenClonk, http://www.openclonk.org
*
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
* Copyright (c) 2010-2013, The OpenClonk Team and contributors
2009-05-08 13:28:41 +00:00
*
* Distributed under the terms of the ISC license; see accompanying file
* "COPYING" for details.
2009-05-08 13:28:41 +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
*
* 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
#include <C4Include.h>
#include <C4StartupAboutDlg.h>
#include <C4UpdateDlg.h>
#include <C4GraphicsResource.h>
#include <C4Version.h>
2009-05-08 13:28:41 +00:00
#include <C4StartupMainDlg.h>
// ------------------------------------------------
// --- C4StartupAboutDlg
C4StartupAboutDlg::C4StartupAboutDlg() : C4StartupDlg("")
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// ctor
UpdateSize();
// key bindings: No longer back on any key
pKeyBack = NULL;
//C4CustomKey::CodeList keys;
//keys.push_back(C4KeyCodeEx(KEY_Any)); keys.push_back(C4KeyCodeEx(KEY_JOY_AnyButton));
//pKeyBack = new C4KeyBinding(keys, "StartupAboutBack", KEYSCOPE_Gui,
2010-03-28 18:58:01 +00:00
// new C4GUI::DlgKeyCB<C4StartupAboutDlg>(*this, &C4StartupAboutDlg::KeyBack), C4CustomKey::PRIO_Dlg);
2009-05-08 13:28:41 +00:00
// version and registration info in topright corner
C4Rect rcClient = GetContainedClientRect();
StdStrBuf sVersion; sVersion.Format(LoadResStr("IDS_DLG_VERSION"), C4VERSION);
CStdFont &rUseFont = ::GraphicsResource.TextFont;
2009-05-08 13:28:41 +00:00
int32_t iInfoWdt = Min<int32_t>(rcClient.Wdt/2, rUseFont.GetTextWidth("General info text width")*2);
C4GUI::ComponentAligner caInfo(C4Rect(rcClient.x + rcClient.Wdt - iInfoWdt, rcClient.y, iInfoWdt, rcClient.Hgt/8), 0,0, false);
AddElement(new C4GUI::Label(sVersion.getData(), caInfo.GetGridCell(0,1,0,4), ARight));
StdStrBuf sRegStr, sKeyFile;
Application.Add(this);
OnSec1Timer();
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;
2010-04-18 21:13:37 +00:00
#ifdef HAVE_FMOD
AddElement(new C4GUI::Label("Using FMOD Sound System, copyright (c) Firelight Technologies Pty, Ltd., 1994-2010.",
caMain.GetFromBottom(rUseFont.GetLineHeight())));
#endif
2009-05-08 13:28:41 +00:00
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"));
#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"));
#endif
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
C4StartupAboutDlg::~C4StartupAboutDlg()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
Application.Remove(this);
delete pKeyBack;
2010-03-28 18:58:01 +00:00
}
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::OnSec1Timer()
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
// draw background - do not use bg drawing proc, because it stretches
// pre-clear background instead to prevent blinking borders
2011-10-03 14:30:18 +00:00
if (!IsFading()) pDraw->FillBG();
C4Startup::Get()->Graphics.fctAboutBG.Draw(cgo, false);
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
void C4StartupAboutDlg::MouseInput(C4GUI::CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
// back on any mouse button? Better not, because mouse input is required
/*if (iButton == C4MC_Button_LeftDown || iButton == C4MC_Button_RightDown || iButton == C4MC_Button_MiddleDown)
2010-03-28 18:58:01 +00:00
DoBack();
2009-05-08 13:28:41 +00:00
else*/
2010-03-28 18:58:01 +00:00
// otherwise, inherited for tooltips
C4StartupDlg::MouseInput(rMouse, iButton, iX, iY, dwKeyParam);
}
2009-05-08 13:28:41 +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
}
#endif