forked from Mirrors/openclonk
Merge C4GUI::Resource into C4GraphicsResource
Both classes did the same thing at the same time, with the only difference that C4GUI::Resource was vaguely more associated with GUI stuff. Some time ago, C4GUI::Resource could be freed during the game, but not anymore. This saves some lines of code and one redundant class, but shouldn't change anything besides progress bar being textured a little earlier during startup.stable-5.1
parent
c0ce4d613b
commit
46aa12def4
|
@ -28,6 +28,7 @@
|
|||
#include "C4InputValidation.h"
|
||||
#include "C4Network2IRC.h"
|
||||
#include "C4MessageInput.h"
|
||||
#include "C4GraphicsResource.h"
|
||||
|
||||
void ConvWindowsToUTF8(StdStrBuf &sText)
|
||||
{
|
||||
|
@ -50,7 +51,7 @@ C4ChatControl::ChatSheet::NickItem::NickItem(class C4Network2IRCUser *pByUser) :
|
|||
AddElement(pStatusIcon = new C4GUI::Icon(rcDefault, C4GUI::Ico_None));
|
||||
AddElement(pNameLabel = new C4GUI::Label("", rcDefault, ALeft, C4GUI_CaptionFontClr, NULL, false, false, false));
|
||||
// set height (pos and width set when added to the list)
|
||||
CStdFont *pUseFont = &C4GUI::GetRes()->TextFont;
|
||||
CStdFont *pUseFont = &::GraphicsResource.TextFont;
|
||||
rcBounds.Set(0,0, 100,pUseFont->GetLineHeight());
|
||||
// initial update
|
||||
Update(pByUser);
|
||||
|
@ -121,7 +122,7 @@ C4ChatControl::ChatSheet::ChatSheet(C4ChatControl *pChatControl, const char *szT
|
|||
AddElement(pNickList);
|
||||
}
|
||||
if (eType != CS_Server)
|
||||
pInputLbl = new C4GUI::WoodenLabel(LoadResStr("IDS_DLG_CHAT"), rcDefault, C4GUI_CaptionFontClr, &C4GUI::GetRes()->TextFont);
|
||||
pInputLbl = new C4GUI::WoodenLabel(LoadResStr("IDS_DLG_CHAT"), rcDefault, C4GUI_CaptionFontClr, &::GraphicsResource.TextFont);
|
||||
pInputEdit = new C4GUI::CallbackEdit<C4ChatControl::ChatSheet>(rcDefault, this, &C4ChatControl::ChatSheet::OnChatInput);
|
||||
pInputEdit->SetToolTip(LoadResStr("IDS_DLGTIP_CHAT"));
|
||||
if (pInputLbl)
|
||||
|
@ -224,7 +225,7 @@ void C4ChatControl::ChatSheet::AddTextLine(const char *szText, uint32_t dwClr)
|
|||
// convert incoming Windows-1252
|
||||
ConvWindowsToUTF8(sText);
|
||||
// add text line to chat box
|
||||
CStdFont *pUseFont = &C4GUI::GetRes()->TextFont;
|
||||
CStdFont *pUseFont = &::GraphicsResource.TextFont;
|
||||
pChatBox->AddTextLine(sText.getData(), pUseFont, dwClr, true, false);
|
||||
pChatBox->ScrollToBottom();
|
||||
// sheet now has unread messages if not selected
|
||||
|
@ -364,7 +365,7 @@ C4ChatControl::C4ChatControl(C4Network2IRCClient *pnIRCClient) : C4GUI::Window()
|
|||
C4GUI::Tabular::Sheet *pSheetLogin = pTabMain->AddSheet(NULL);
|
||||
C4GUI::Tabular::Sheet *pSheetChats = pTabMain->AddSheet(NULL);
|
||||
// login sheet
|
||||
CStdFont *pUseFont = &C4GUI::GetRes()->TextFont;
|
||||
CStdFont *pUseFont = &::GraphicsResource.TextFont;
|
||||
pSheetLogin->AddElement(pLblLoginNick = new C4GUI::Label(LoadResStr("IDS_CTL_NICK"), rcDefault, ALeft, C4GUI_CaptionFontClr, pUseFont, false, true));
|
||||
pSheetLogin->AddElement(pEdtLoginNick = new C4GUI::CallbackEdit<C4ChatControl>(rcDefault, this, &C4ChatControl::OnLoginDataEnter));
|
||||
pSheetLogin->AddElement(pLblLoginPass = new C4GUI::Label(LoadResStr("IDS_CTL_PASSWORDOPTIONAL"), rcDefault, ALeft, C4GUI_CaptionFontClr, pUseFont, false, true));
|
||||
|
@ -416,7 +417,7 @@ void C4ChatControl::UpdateSize()
|
|||
pTabChats->SetBounds(pTabChats->GetParent()->GetContainedClientRect());
|
||||
C4GUI::Tabular::Sheet *pSheetLogin = pTabMain->GetSheet(0);
|
||||
C4GUI::ComponentAligner caLoginSheet(pSheetLogin->GetContainedClientRect(), 0,0, false);
|
||||
CStdFont *pUseFont = &C4GUI::GetRes()->TextFont;
|
||||
CStdFont *pUseFont = &::GraphicsResource.TextFont;
|
||||
int32_t iIndent1 = C4GUI_DefDlgSmallIndent/2, iIndent2 = C4GUI_DefDlgIndent/2;
|
||||
int32_t iLoginHgt = pUseFont->GetLineHeight() * 8 + iIndent1*10 + iIndent2*10 + C4GUI_ButtonHgt + 20;
|
||||
int32_t iLoginWdt = iLoginHgt*2/3;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "C4DownloadDlg.h"
|
||||
|
||||
#include "C4Log.h"
|
||||
#include "C4GraphicsResource.h"
|
||||
|
||||
C4Network2HTTPClient HTTPClient;
|
||||
|
||||
|
@ -37,7 +38,7 @@ C4DownloadDlg::C4DownloadDlg(const char *szDLType) : C4GUI::Dialog(C4GUI_Progres
|
|||
#endif
|
||||
// add all elements - will be reposisioned when text is displayed
|
||||
AddElement(pIcon = new C4GUI::Icon(C4Rect(), C4GUI::Ico_NetWait));
|
||||
AddElement(pStatusLabel = new C4GUI::Label("", C4Rect(), ACenter, C4GUI_MessageFontClr, &C4GUI::GetRes()->TextFont, false));
|
||||
AddElement(pStatusLabel = new C4GUI::Label("", C4Rect(), ACenter, C4GUI_MessageFontClr, &::GraphicsResource.TextFont, false));
|
||||
pProgressBar = NULL; // created when necessary
|
||||
AddElement(pCancelBtn = new C4GUI::CancelButton(C4Rect()));
|
||||
}
|
||||
|
@ -58,7 +59,7 @@ void C4DownloadDlg::SetStatus(const char *szNewText, int32_t iProgressPercent)
|
|||
// place message label
|
||||
// use text with line breaks
|
||||
StdStrBuf sMsgBroken;
|
||||
int iMsgHeight = C4GUI::GetRes()->TextFont.BreakMessage(szNewText, caMain.GetInnerWidth(), &sMsgBroken, true);
|
||||
int iMsgHeight = ::GraphicsResource.TextFont.BreakMessage(szNewText, caMain.GetInnerWidth(), &sMsgBroken, true);
|
||||
pStatusLabel->SetBounds(caMain.GetFromTop(iMsgHeight));
|
||||
pStatusLabel->SetText(sMsgBroken.getData());
|
||||
// place progress bar
|
||||
|
|
|
@ -67,7 +67,7 @@ C4FileSelDlg::DefaultListItem::DefaultListItem(const char *szFilename, bool fTru
|
|||
RemoveExtension(szFilename);
|
||||
sLabel.Take(szFilename);
|
||||
}
|
||||
rcBounds.Hgt = C4GUI::GetRes()->TextFont.GetLineHeight();
|
||||
rcBounds.Hgt = ::GraphicsResource.TextFont.GetLineHeight();
|
||||
UpdateSize();
|
||||
C4GUI::ComponentAligner caMain(GetContainedClientRect(),0,0);
|
||||
int32_t iHeight = caMain.GetInnerHeight();
|
||||
|
@ -144,7 +144,7 @@ C4FileSelDlg::C4FileSelDlg(const char *szRootPath, const char *szTitle, C4FileSe
|
|||
void C4FileSelDlg::InitElements()
|
||||
{
|
||||
UpdateSize();
|
||||
CStdFont *pUseFont = &(C4GUI::GetRes()->TextFont);
|
||||
CStdFont *pUseFont = &(::GraphicsResource.TextFont);
|
||||
// main calcs
|
||||
bool fHasOptions = HasExtraOptions();
|
||||
C4GUI::ComponentAligner caMain(GetClientRect(), 0,0, true);
|
||||
|
@ -306,7 +306,7 @@ void C4FileSelDlg::UpdateSelection()
|
|||
if (!pSelection) { pSelectionInfoBox->UpdateHeight(); return; }
|
||||
// add selection description
|
||||
if (pSelection->GetFilename())
|
||||
pSelectionInfoBox->AddTextLine(pSelection->GetFilename(), &C4GUI::GetRes()->TextFont, C4GUI_MessageFontClr, true, false);
|
||||
pSelectionInfoBox->AddTextLine(pSelection->GetFilename(), &::GraphicsResource.TextFont, C4GUI_MessageFontClr, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,7 @@ bool C4DefinitionSelDlg::SelectDefinitions(C4GUI::Screen *pOnScreen, StdStrBuf *
|
|||
C4PortraitSelDlg::ListItem::ListItem(const char *szFilename) : C4FileSelDlg::ListItem(szFilename)
|
||||
, fError(false), fLoaded(false)
|
||||
{
|
||||
CStdFont *pUseFont = &(C4GUI::GetRes()->MiniFont);
|
||||
CStdFont *pUseFont = &(::GraphicsResource.MiniFont);
|
||||
// determine label text
|
||||
StdStrBuf sDisplayLabel;
|
||||
if (szFilename)
|
||||
|
@ -501,7 +501,7 @@ void C4PortraitSelDlg::ListItem::DrawElement(C4TargetFacet &cgo)
|
|||
fctLoadedImage.Clear();
|
||||
}
|
||||
// Draw picture
|
||||
CStdFont *pUseFont = &(C4GUI::GetRes()->MiniFont);
|
||||
CStdFont *pUseFont = &(::GraphicsResource.MiniFont);
|
||||
C4Facet cgoPicture(cgo.Surface, cgo.TargetX+rcBounds.x, cgo.TargetY+rcBounds.y, ImagePreviewSize, ImagePreviewSize);
|
||||
if (fError || !sFilename)
|
||||
{
|
||||
|
@ -513,7 +513,7 @@ void C4PortraitSelDlg::ListItem::DrawElement(C4TargetFacet &cgo)
|
|||
if (!fctImage.Surface)
|
||||
{
|
||||
// not loaded yet
|
||||
lpDDraw->TextOut(LoadResStr("IDS_PRC_INITIALIZE"), C4GUI::GetRes()->MiniFont, 1.0f, cgo.Surface, cgoPicture.X+cgoPicture.Wdt/2, cgoPicture.Y+(cgoPicture.Hgt-C4GUI::GetRes()->MiniFont.GetLineHeight())/2, C4GUI_StatusFontClr, ACenter, false);
|
||||
lpDDraw->TextOut(LoadResStr("IDS_PRC_INITIALIZE"), ::GraphicsResource.MiniFont, 1.0f, cgo.Surface, cgoPicture.X+cgoPicture.Wdt/2, cgoPicture.Y+(cgoPicture.Hgt-::GraphicsResource.MiniFont.GetLineHeight())/2, C4GUI_StatusFontClr, ACenter, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -597,7 +597,7 @@ C4PortraitSelDlg::C4PortraitSelDlg(C4FileSel_BaseCB *pSelCallback, bool fSetPict
|
|||
void C4PortraitSelDlg::AddExtraOptions(const C4Rect &rcOptionsRect)
|
||||
{
|
||||
C4GUI::ComponentAligner caOptions(rcOptionsRect, C4GUI_DefDlgIndent,C4GUI_DefDlgSmallIndent,false);
|
||||
CStdFont *pUseFont = &(C4GUI::GetRes()->TextFont);
|
||||
CStdFont *pUseFont = &(::GraphicsResource.TextFont);
|
||||
AddElement(new C4GUI::Label(LoadResStr("IDS_CTL_IMPORTIMAGEAS"), caOptions.GetGridCell(0,3, 0,1, -1,pUseFont->GetLineHeight(), true), ALeft));
|
||||
AddElement(pCheckSetPicture = new C4GUI::CheckBox(caOptions.GetGridCell(1,3, 0,1, -1,pUseFont->GetLineHeight(), true), LoadResStr("IDS_TEXT_PLAYERIMAGE"), fDefSetPicture));
|
||||
pCheckSetPicture->SetToolTip(LoadResStr("IDS_DESC_CHANGESTHEIMAGEYOUSEEINTH"));
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <C4MessageInput.h>
|
||||
#include <C4Game.h>
|
||||
#include <C4Network2.h>
|
||||
#include "C4GraphicsResource.h"
|
||||
|
||||
namespace C4GameLobby
|
||||
{
|
||||
|
@ -61,7 +62,7 @@ namespace C4GameLobby
|
|||
ScenDesc::ScenDesc(const C4Rect &rcBounds, bool fActive) : C4GUI::Window(), fDescFinished(false)
|
||||
{
|
||||
// build components
|
||||
//CStdFont &rTitleFont = C4GUI::GetRes()->CaptionFont;
|
||||
//CStdFont &rTitleFont = ::GraphicsResource.CaptionFont;
|
||||
SetBounds(rcBounds);
|
||||
C4GUI::ComponentAligner caMain(GetClientRect(), 0,0, true);
|
||||
//AddElement(pTitle = new C4GUI::Label("", caMain.GetFromTop(rTitleFont.GetLineHeight()), ALeft, C4GUI_CaptionFontClr, &rTitleFont, true));
|
||||
|
@ -77,8 +78,8 @@ namespace C4GameLobby
|
|||
// scenario present?
|
||||
C4Network2Res *pRes = Game.Parameters.Scenario.getNetRes();
|
||||
if (!pRes) return; // something's wrong
|
||||
CStdFont &rTitleFont = C4GUI::GetRes()->CaptionFont;
|
||||
CStdFont &rTextFont = C4GUI::GetRes()->TextFont;
|
||||
CStdFont &rTitleFont = ::GraphicsResource.CaptionFont;
|
||||
CStdFont &rTextFont = ::GraphicsResource.TextFont;
|
||||
pDescBox->ClearText(false);
|
||||
if (pRes->isComplete())
|
||||
{
|
||||
|
@ -208,7 +209,7 @@ namespace C4GameLobby
|
|||
|
||||
// players / ressources sidebar
|
||||
C4GUI::ComponentAligner caRight(caMain.GetFromRight(iClientListWdt), iIndentX3,iIndentY4);
|
||||
pRightTabLbl = new C4GUI::WoodenLabel("", caRight.GetFromTop(C4GUI::WoodenLabel::GetDefaultHeight(&(C4GUI::GetRes()->TextFont))), C4GUI_CaptionFontClr, &C4GUI::GetRes()->TextFont, ALeft);
|
||||
pRightTabLbl = new C4GUI::WoodenLabel("", caRight.GetFromTop(C4GUI::WoodenLabel::GetDefaultHeight(&(::GraphicsResource.TextFont))), C4GUI_CaptionFontClr, &::GraphicsResource.TextFont, ALeft);
|
||||
caRight.ExpandTop(iIndentY4*2 + 1); // undo margin, so client list is located directly under label
|
||||
pRightTab = new C4GUI::Tabular(caRight.GetAll(), C4GUI::Tabular::tbNone);
|
||||
C4GUI::Tabular::Sheet *pPlayerSheet = pRightTab->AddSheet(LoadResStr("IDS_DLG_PLAYERS"));
|
||||
|
@ -246,7 +247,7 @@ namespace C4GameLobby
|
|||
C4GUI::ComponentAligner caCenter(caMain.GetAll(), iIndentX2, iIndentY3);
|
||||
// chat input box
|
||||
C4GUI::ComponentAligner caChat(caCenter.GetFromBottom(C4GUI::Edit::GetDefaultEditHeight()), 0,0);
|
||||
pLbl = new C4GUI::WoodenLabel(LoadResStr("IDS_CTL_CHAT"), caChat.GetFromLeft(40), C4GUI_CaptionFontClr, &C4GUI::GetRes()->TextFont);
|
||||
pLbl = new C4GUI::WoodenLabel(LoadResStr("IDS_CTL_CHAT"), caChat.GetFromLeft(40), C4GUI_CaptionFontClr, &::GraphicsResource.TextFont);
|
||||
pEdt = new C4GUI::CallbackEdit<MainDlg>(caChat.GetAll(), this, &MainDlg::OnChatInput);
|
||||
pEdt->SetToolTip(LoadResStr("IDS_DLGTIP_CHAT")); pLbl->SetToolTip(LoadResStr("IDS_DLGTIP_CHAT"));
|
||||
pLbl->SetClickFocusControl(pEdt);
|
||||
|
@ -665,9 +666,9 @@ namespace C4GameLobby
|
|||
// output message should be prefixed with client already
|
||||
const char *szMsgBuf = szMessage;
|
||||
// 2do: log with player colors?
|
||||
if (pChatBox && C4GUI::GetRes() && !pOfClient->IsIgnored())
|
||||
if (pChatBox && !pOfClient->IsIgnored())
|
||||
{
|
||||
pChatBox->AddTextLine(szMsgBuf, &C4GUI::GetRes()->TextFont, ::Network.Players.GetClientChatColor(pOfClient ? pOfClient->getID() : Game.Clients.getLocalID(), true) | C4GUI_MessageFontAlpha, true, true);
|
||||
pChatBox->AddTextLine(szMsgBuf, &::GraphicsResource.TextFont, ::Network.Players.GetClientChatColor(pOfClient ? pOfClient->getID() : Game.Clients.getLocalID(), true) | C4GUI_MessageFontAlpha, true, true);
|
||||
pChatBox->ScrollToBottom();
|
||||
}
|
||||
// log it
|
||||
|
@ -687,19 +688,19 @@ namespace C4GameLobby
|
|||
|
||||
void MainDlg::OnLog(const char *szLogMsg, DWORD dwClr)
|
||||
{
|
||||
if (pChatBox && C4GUI::GetRes())
|
||||
if (pChatBox)
|
||||
{
|
||||
pChatBox->AddTextLine(szLogMsg, &C4GUI::GetRes()->TextFont, dwClr, true, true);
|
||||
pChatBox->AddTextLine(szLogMsg, &::GraphicsResource.TextFont, dwClr, true, true);
|
||||
pChatBox->ScrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
void MainDlg::OnError(const char *szErrMsg)
|
||||
{
|
||||
if (pChatBox && C4GUI::GetRes())
|
||||
if (pChatBox)
|
||||
{
|
||||
StartSoundEffect("Error");
|
||||
pChatBox->AddTextLine(szErrMsg, &C4GUI::GetRes()->TextFont, C4GUI_ErrorFontClr, true, true);
|
||||
pChatBox->AddTextLine(szErrMsg, &::GraphicsResource.TextFont, C4GUI_ErrorFontClr, true, true);
|
||||
pChatBox->ScrollToBottom();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "C4GameOptions.h"
|
||||
#include <C4Game.h>
|
||||
#include <C4GameControl.h>
|
||||
#include "C4GraphicsResource.h"
|
||||
|
||||
// ----------- C4GameOptionsList::Option ----------------------------------------------------------------
|
||||
|
||||
|
@ -45,7 +46,7 @@ void C4GameOptionsList::Option::InitOption(C4GameOptionsList *pForDlg)
|
|||
C4GameOptionsList::OptionDropdown::OptionDropdown(class C4GameOptionsList *pForDlg, const char *szCaption, bool fReadOnly)
|
||||
: Option(pForDlg)
|
||||
{
|
||||
CStdFont &rUseFont = C4GUI::GetRes()->TextFont;
|
||||
CStdFont &rUseFont = ::GraphicsResource.TextFont;
|
||||
// get size of caption label
|
||||
bool fTabular = pForDlg->IsTabular();
|
||||
int32_t iCaptWidth, iCaptHeight;
|
||||
|
|
|
@ -32,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <C4PlayerList.h>
|
||||
#include <C4GameObjects.h>
|
||||
#include <C4GameControl.h>
|
||||
#include "C4GraphicsResource.h"
|
||||
|
||||
|
||||
// ---------------------------------------------------
|
||||
|
@ -149,7 +150,7 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
|
|||
// lower button-area
|
||||
C4GUI::ComponentAligner caBottom(caMain.GetFromBottom(iDefBtnHeight+iIndentY1*2), iIndentX1,0);
|
||||
int32_t iBottomButtonSize = caBottom.GetInnerWidth();
|
||||
iBottomButtonSize = Min<int32_t>(iBottomButtonSize/2-2*iIndentX1, C4GUI::GetRes()->CaptionFont.GetTextWidth("Quit it, baby! And some.")*2);
|
||||
iBottomButtonSize = Min<int32_t>(iBottomButtonSize/2-2*iIndentX1, ::GraphicsResource.CaptionFont.GetTextWidth("Quit it, baby! And some.")*2);
|
||||
// goal display
|
||||
const C4IDList &rGoals = Game.RoundResults.GetGoals();
|
||||
const C4IDList &rFulfilledGoals = Game.RoundResults.GetFulfilledGoals();
|
||||
|
@ -171,7 +172,7 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
|
|||
szNetResult = Game.RoundResults.GetNetResultString();
|
||||
else
|
||||
szNetResult = LoadResStr("IDS_TEXT_LEAGUEWAITINGFOREVALUATIO");
|
||||
pNetResultLabel = new C4GUI::Label("", caMain.GetFromTop(C4GUI::GetRes()->TextFont.GetLineHeight()*2, iMainTextWidth), ACenter, C4GUI_Caption2FontClr, NULL, false, false, true);
|
||||
pNetResultLabel = new C4GUI::Label("", caMain.GetFromTop(::GraphicsResource.TextFont.GetLineHeight()*2, iMainTextWidth), ACenter, C4GUI_Caption2FontClr, NULL, false, false, true);
|
||||
AddElement(pNetResultLabel);
|
||||
// only add label - contents and fIsNetDone will be set in next update
|
||||
}
|
||||
|
@ -186,7 +187,7 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
|
|||
{
|
||||
int32_t iMaxHgt = caMain.GetInnerHeight() / 3; // max 1/3rd of height for extra data
|
||||
C4GUI::MultilineLabel *pCustomStrings = new C4GUI::MultilineLabel(caMain.GetFromTop(0 /* resized later*/, iMainTextWidth), 0,0, " ", true, true);
|
||||
pCustomStrings->AddLine(szCustomEvaluationStrings, &C4GUI::GetRes()->TextFont, C4GUI_MessageFontClr, true, false, NULL);
|
||||
pCustomStrings->AddLine(szCustomEvaluationStrings, &::GraphicsResource.TextFont, C4GUI_MessageFontClr, true, false, NULL);
|
||||
C4Rect rcCustomStringBounds = pCustomStrings->GetBounds();
|
||||
if (rcCustomStringBounds.Hgt > iMaxHgt)
|
||||
{
|
||||
|
@ -195,7 +196,7 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
|
|||
rcCustomStringBounds.Hgt = iMaxHgt;
|
||||
C4GUI::TextWindow *pCustomStringsWin = new C4GUI::TextWindow(rcCustomStringBounds, 0,0,0, 0,0," ",true, NULL,0, true);
|
||||
pCustomStringsWin->SetDecoration(false, false, NULL, false);
|
||||
pCustomStringsWin->AddTextLine(szCustomEvaluationStrings, &C4GUI::GetRes()->TextFont, C4GUI_MessageFontClr, true, false, NULL);
|
||||
pCustomStringsWin->AddTextLine(szCustomEvaluationStrings, &::GraphicsResource.TextFont, C4GUI_MessageFontClr, true, false, NULL);
|
||||
caMain.ExpandTop(-iMaxHgt);
|
||||
AddElement(pCustomStringsWin);
|
||||
}
|
||||
|
@ -293,7 +294,7 @@ void C4GameOverDlg::SetNetResult(const char *szResultString, C4RoundResults::Net
|
|||
}
|
||||
// message linebreak into box
|
||||
StdStrBuf sBrokenResult;
|
||||
C4GUI::GetRes()->TextFont.BreakMessage(sResult.getData(), pNetResultLabel->GetBounds().Wdt, &sBrokenResult, true);
|
||||
::GraphicsResource.TextFont.BreakMessage(sResult.getData(), pNetResultLabel->GetBounds().Wdt, &sBrokenResult, true);
|
||||
pNetResultLabel->SetText(sBrokenResult.getData(), false);
|
||||
// all done?
|
||||
if (eResultType != C4RoundResults::NR_None && !fIsStreaming)
|
||||
|
|
|
@ -723,7 +723,7 @@ namespace C4GUI
|
|||
}
|
||||
}
|
||||
// draw contents (if GUI-gfx are loaded, which is assumed in GUI-drawing-functions)
|
||||
if (IsVisible() && IsResLoaded())
|
||||
if (IsVisible() && ::GraphicsResource.IsInitialized())
|
||||
{
|
||||
Window::Draw(cgo);
|
||||
if (pContext) pContext->Draw(cgo);
|
||||
|
@ -967,7 +967,7 @@ namespace C4GUI
|
|||
|
||||
void Screen::DrawToolTip(const char *szTip, C4TargetFacet &cgo, float x, float y)
|
||||
{
|
||||
CStdFont *pUseFont = &(GetRes()->TooltipFont);
|
||||
CStdFont *pUseFont = &(::GraphicsResource.TooltipFont);
|
||||
StdStrBuf sText;
|
||||
pUseFont->BreakMessage(szTip, Min<int32_t>(C4GUI_MaxToolTipWdt, Max<int32_t>(cgo.Wdt, 50)), &sText, true);
|
||||
// get tooltip rect
|
||||
|
@ -1135,76 +1135,6 @@ namespace C4GUI
|
|||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
// Resource
|
||||
|
||||
bool Resource::Load(C4GroupSet &rFromGroup)
|
||||
{
|
||||
// load gfx - using helper funcs from ::GraphicsResource here...
|
||||
if (!::GraphicsResource.LoadFile(sfcCaption, "GUICaption", rFromGroup, idSfcCaption)) return false;
|
||||
barCaption.SetHorizontal(sfcCaption, sfcCaption.Hgt, 32);
|
||||
if (!::GraphicsResource.LoadFile(sfcButton, "GUIButton", rFromGroup, idSfcButton)) return false;
|
||||
barButton.SetHorizontal(sfcButton);
|
||||
if (!::GraphicsResource.LoadFile(sfcButtonD, "GUIButtonDown", rFromGroup, idSfcButtonD)) return false;
|
||||
barButtonD.SetHorizontal(sfcButtonD);
|
||||
if (!::GraphicsResource.LoadFile(fctButtonHighlight, "GUIButtonHighlight", rFromGroup)) return false;
|
||||
if (!::GraphicsResource.LoadFile(fctIcons, "GUIIcons", rFromGroup)) return false;
|
||||
fctIcons.Set(fctIcons.Surface,0,0,C4GUI_IconWdt,C4GUI_IconHgt);
|
||||
if (!::GraphicsResource.LoadFile(fctIconsEx, "GUIIcons2", rFromGroup)) return false;
|
||||
fctIconsEx.Set(fctIconsEx.Surface,0,0,C4GUI_IconExWdt,C4GUI_IconExHgt);
|
||||
if (!::GraphicsResource.LoadFile(sfcScroll, "GUIScroll", rFromGroup, idSfcScroll)) return false;
|
||||
sfctScroll.Set(C4Facet(&sfcScroll,0,0,32,32));
|
||||
if (!::GraphicsResource.LoadFile(sfcContext, "GUIContext", rFromGroup, idSfcContext)) return false;
|
||||
fctContext.Set(&sfcContext,0,0,16,16);
|
||||
if (!::GraphicsResource.LoadFile(fctSubmenu, "GUISubmenu", rFromGroup)) return false;
|
||||
if (!::GraphicsResource.LoadFile(fctCheckbox, "GUICheckbox", rFromGroup)) return false;
|
||||
fctCheckbox.Set(fctCheckbox.Surface, 0,0,fctCheckbox.Hgt,fctCheckbox.Hgt);
|
||||
if (!::GraphicsResource.LoadFile(fctBigArrows, "GUIBigArrows", rFromGroup)) return false;
|
||||
fctBigArrows.Set(fctBigArrows.Surface, 0,0, fctBigArrows.Wdt/4, fctBigArrows.Hgt);
|
||||
if (!::GraphicsResource.LoadFile(fctProgressBar, "GUIProgress", rFromGroup)) return false;
|
||||
fctProgressBar.Set(fctProgressBar.Surface, 1,0, fctProgressBar.Wdt-2, fctProgressBar.Hgt);
|
||||
// loaded sucessfully
|
||||
pRes = this;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Resource::Clear()
|
||||
{
|
||||
// clear surfaces
|
||||
sfcCaption.Clear(); sfcButton.Clear(); sfcButtonD.Clear(); sfcScroll.Clear(); sfcContext.Clear();
|
||||
idSfcCaption = idSfcButton = idSfcButtonD = idSfcScroll = idSfcContext = 0;
|
||||
barCaption.Clear(); barButton.Clear(); barButtonD.Clear();
|
||||
fctButtonHighlight.Clear(); fctIcons.Clear(); fctIconsEx.Clear();
|
||||
fctSubmenu.Clear();
|
||||
fctCheckbox.Clear();
|
||||
fctBigArrows.Clear();
|
||||
fctProgressBar.Clear();
|
||||
fctContext.Default();
|
||||
// facets are invalid now...doesn't matter anyway, as long as res ptr is not set to this class
|
||||
if (pRes==this) pRes=NULL;
|
||||
}
|
||||
|
||||
CStdFont &Resource::GetFontByHeight(int32_t iHgt, float *pfZoom)
|
||||
{
|
||||
// get optimal font for given control size
|
||||
CStdFont *pUseFont;
|
||||
if (iHgt <= MiniFont.GetLineHeight()) pUseFont = &MiniFont;
|
||||
else if (iHgt <= TextFont.GetLineHeight()) pUseFont = &TextFont;
|
||||
else if (iHgt <= CaptionFont.GetLineHeight()) pUseFont = &CaptionFont;
|
||||
else pUseFont = &TitleFont;
|
||||
// determine zoom
|
||||
if (pfZoom)
|
||||
{
|
||||
int32_t iLineHgt = pUseFont->GetLineHeight();
|
||||
if (iLineHgt)
|
||||
*pfZoom = (float) iHgt / (float) iLineHgt;
|
||||
else
|
||||
*pfZoom = 1.0f; // error
|
||||
}
|
||||
return *pUseFont;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
// Global stuff
|
||||
|
||||
|
@ -1219,7 +1149,6 @@ namespace C4GUI
|
|||
// Static vars
|
||||
|
||||
C4Rect ComponentAligner::rcTemp;
|
||||
Resource *Resource::pRes;
|
||||
Screen *Screen::pScreen;
|
||||
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ namespace C4GUI
|
|||
|
||||
// C4Gui.cpp
|
||||
class Element; class Screen; class CMouse;
|
||||
class Resource; class ComponentAligner;
|
||||
class ComponentAligner;
|
||||
|
||||
// C4GuiLabels.cpp
|
||||
class Label; class WoodenLabel; class MultilineLabel;
|
||||
|
@ -2708,53 +2708,6 @@ namespace C4GUI
|
|||
void LogIt(const char *szName);
|
||||
};
|
||||
|
||||
// graphical resources
|
||||
class Resource
|
||||
{
|
||||
private:
|
||||
static Resource *pRes; // current GUI resources
|
||||
|
||||
protected:
|
||||
C4Surface sfcCaption, sfcButton, sfcButtonD;
|
||||
C4Surface sfcScroll, sfcContext;
|
||||
int32_t idSfcCaption, idSfcButton, idSfcButtonD, idSfcScroll, idSfcContext;
|
||||
public:
|
||||
DynBarFacet barCaption, barButton, barButtonD;
|
||||
C4FacetID fctButtonHighlight;
|
||||
C4FacetID fctIcons, fctIconsEx;
|
||||
C4FacetID fctSubmenu;
|
||||
C4FacetID fctCheckbox;
|
||||
C4FacetID fctBigArrows;
|
||||
C4FacetID fctProgressBar;
|
||||
ScrollBarFacets sfctScroll;
|
||||
C4Facet fctContext;
|
||||
|
||||
CStdFont &CaptionFont; // small, bold font
|
||||
CStdFont &TitleFont; // large, bold font
|
||||
CStdFont &TextFont; // font for normal text
|
||||
CStdFont &MiniFont; // tiny font (logfont)
|
||||
CStdFont &TooltipFont; // same as BookFont
|
||||
|
||||
public:
|
||||
Resource(CStdFont &rCaptionFont, CStdFont &rTitleFont, CStdFont &rTextFont, CStdFont &rMiniFont, CStdFont &rTooltipFont) // ctor
|
||||
: idSfcCaption(0), idSfcButton(0), idSfcButtonD(0), idSfcScroll(0), idSfcContext(0),
|
||||
CaptionFont(rCaptionFont), TitleFont(rTitleFont), TextFont(rTextFont), MiniFont(rMiniFont), TooltipFont(rTooltipFont) {}
|
||||
~Resource() { Clear(); } // dtor
|
||||
|
||||
bool Load(C4GroupSet &rFromGroup); // load resources
|
||||
void Clear(); // clear data
|
||||
|
||||
public:
|
||||
static Resource *Get() { return pRes; } // get res ptr - only set if successfully loaded
|
||||
static void Unload() { if (pRes) delete pRes; } // unload any GUI resources
|
||||
|
||||
CStdFont &GetFontByHeight(int32_t iHgt, float *pfZoom=NULL); // get optimal font for given control size
|
||||
};
|
||||
|
||||
// shortcut for GUI resource gfx
|
||||
inline Resource *GetRes() { return Resource::Get(); }
|
||||
inline bool IsResLoaded() { return Resource::Get() != NULL; }
|
||||
|
||||
// shortcut for check whether GUI is active
|
||||
inline bool IsGUIValid() { return !!Screen::GetScreenS(); }
|
||||
inline bool IsActive() { return Screen::GetScreenS() && Screen::GetScreenS()->IsActive(); }
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <C4LoaderScreen.h>
|
||||
#include <C4Application.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
namespace C4GUI
|
||||
{
|
||||
|
@ -86,10 +87,10 @@ namespace C4GUI
|
|||
// draw base
|
||||
if (fDown)
|
||||
// pressed
|
||||
DrawBar(cgo, pCustomGfxDown ? *pCustomGfxDown : GetRes()->barButtonD);
|
||||
DrawBar(cgo, pCustomGfxDown ? *pCustomGfxDown : ::GraphicsResource.barButtonD);
|
||||
else
|
||||
// released
|
||||
DrawBar(cgo, pCustomGfx ? *pCustomGfx : GetRes()->barButton);
|
||||
DrawBar(cgo, pCustomGfx ? *pCustomGfx : ::GraphicsResource.barButton);
|
||||
// get text pos
|
||||
int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y, x1 = cgo.TargetX + rcBounds.x + rcBounds.Wdt - 1, y1 = cgo.TargetY + rcBounds.y + rcBounds.Hgt - 1;
|
||||
int32_t iTxtOff = fDown ? 1 : 0;
|
||||
|
@ -97,17 +98,17 @@ namespace C4GUI
|
|||
if (fEnabled) if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)))
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0+5, y0+3, rcBounds.Wdt-10, rcBounds.Hgt-6);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0+5, y0+3, rcBounds.Wdt-10, rcBounds.Hgt-6);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
// draw text
|
||||
int32_t iTextHgt = rcBounds.Hgt-2;
|
||||
CStdFont &rUseFont =
|
||||
(GetRes()->TitleFont.GetLineHeight() > iTextHgt ?
|
||||
(GetRes()->CaptionFont.GetLineHeight() > iTextHgt ?
|
||||
GetRes()->TextFont :
|
||||
GetRes()->CaptionFont) :
|
||||
GetRes()->TitleFont);
|
||||
(::GraphicsResource.TitleFont.GetLineHeight() > iTextHgt ?
|
||||
(::GraphicsResource.CaptionFont.GetLineHeight() > iTextHgt ?
|
||||
::GraphicsResource.TextFont :
|
||||
::GraphicsResource.CaptionFont) :
|
||||
::GraphicsResource.TitleFont);
|
||||
iTextHgt = rUseFont.GetLineHeight();
|
||||
//CStdFont &rShadowFont = GetRes()->MiniFont;
|
||||
//lpDDraw->TextOut(Text, rShadowFont, (float) iTextHgt/rShadowFont.GetLineHeight(), cgo.Surface, (x0+x1)/2 + iTxtOff, (y0+y1-iTextHgt)/2 + iTxtOff, C4GUI_ButtonFontShadowClr, ACenter, true);
|
||||
|
@ -218,7 +219,7 @@ namespace C4GUI
|
|||
if (fEnabled) if (fHighlight || HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)))
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
// draw the icon
|
||||
|
@ -228,13 +229,13 @@ namespace C4GUI
|
|||
if (fEnabled) if (fDown || fHighlight)
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
// some icon buttons have captions. draw caption below button
|
||||
if (sText.getLength())
|
||||
{
|
||||
CStdFont &rUseFont = GetRes()->TextFont;
|
||||
CStdFont &rUseFont = ::GraphicsResource.TextFont;
|
||||
lpDDraw->TextOut(sText.getData(), rUseFont, 1.0f, cgo.Surface, x0+rcBounds.Wdt/2, y0+rcBounds.Hgt-rUseFont.GetLineHeight()*4/5, C4GUI_CaptionFontClr, ACenter);
|
||||
}
|
||||
}
|
||||
|
@ -272,26 +273,26 @@ namespace C4GUI
|
|||
if (fEnabled) if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)))
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
// draw the arrow - down if pressed
|
||||
int32_t iFctIdx = eDir;
|
||||
if (fDown) iFctIdx += Down;
|
||||
GetRes()->fctBigArrows.GetPhase(iFctIdx).DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
::GraphicsResource.fctBigArrows.GetPhase(iFctIdx).DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
}
|
||||
|
||||
|
||||
int32_t ArrowButton::GetDefaultWidth()
|
||||
{
|
||||
// default by gfx size
|
||||
return GetRes()->fctBigArrows.Wdt;
|
||||
return ::GraphicsResource.fctBigArrows.Wdt;
|
||||
}
|
||||
|
||||
int32_t ArrowButton::GetDefaultHeight()
|
||||
{
|
||||
// default by gfx size
|
||||
return GetRes()->fctBigArrows.Hgt;
|
||||
return ::GraphicsResource.fctBigArrows.Hgt;
|
||||
}
|
||||
|
||||
|
||||
|
@ -326,7 +327,7 @@ namespace C4GUI
|
|||
// draw caption text
|
||||
if (sText.getLength()>0)
|
||||
{
|
||||
CStdFont *pUseFont = pFont ? pFont : &(GetRes()->GetFontByHeight(rcBounds.Hgt, &fFontZoom));
|
||||
CStdFont *pUseFont = pFont ? pFont : &(::GraphicsResource.GetFontByHeight(rcBounds.Hgt, &fFontZoom));
|
||||
lpDDraw->TextOut(sText.getData(), *pUseFont, fFontZoom, cgo.Surface, (int)(x0+iTxtOffX), (int)(y0+iTxtOffY), dwTextClr, byTxtAlign, true);
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <C4Gui.h>
|
||||
#include <C4FacetEx.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#include <StdWindow.h>
|
||||
|
||||
|
@ -114,9 +115,9 @@ namespace C4GUI
|
|||
// left side: check facet (squared)
|
||||
int x0 = rcBounds.x + cgo.TargetX;
|
||||
int y0 = rcBounds.y + cgo.TargetY;
|
||||
GetRes()->fctCheckbox.GetPhase(fChecked + 2*!fEnabled).DrawX(cgo.Surface, x0, y0, rcBounds.Hgt, rcBounds.Hgt);
|
||||
::GraphicsResource.fctCheckbox.GetPhase(fChecked + 2*!fEnabled).DrawX(cgo.Surface, x0, y0, rcBounds.Hgt, rcBounds.Hgt);
|
||||
// right of it: checkbox text
|
||||
CStdFont *pUseFont = pFont ? pFont : &(GetRes()->TextFont);
|
||||
CStdFont *pUseFont = pFont ? pFont : &(::GraphicsResource.TextFont);
|
||||
int32_t yOff; float fZoom;
|
||||
if (pUseFont->GetLineHeight() <= rcBounds.Hgt)
|
||||
{
|
||||
|
@ -133,7 +134,7 @@ namespace C4GUI
|
|||
if ((fMouseOn && IsInActiveDlg(false)) || HasDrawFocus())
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0+rcBounds.Hgt*1/4, y0+rcBounds.Hgt*1/4, rcBounds.Hgt*1/2, rcBounds.Hgt*1/2);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0+rcBounds.Hgt*1/4, y0+rcBounds.Hgt*1/4, rcBounds.Hgt*1/2, rcBounds.Hgt*1/2);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +148,7 @@ namespace C4GUI
|
|||
bool CheckBox::GetStandardCheckBoxSize(int *piWdt, int *piHgt, const char *szForCaptionText, CStdFont *pUseFont)
|
||||
{
|
||||
// get needed text size
|
||||
if (!pUseFont) pUseFont = &(GetRes()->TextFont);
|
||||
if (!pUseFont) pUseFont = &(::GraphicsResource.TextFont);
|
||||
int32_t iWdt=100, iHgt=32;
|
||||
pUseFont->GetTextExtent(szForCaptionText, iWdt, iHgt, true);
|
||||
// check box height equals text height
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <C4Gui.h>
|
||||
#include <C4FacetEx.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#include <StdWindow.h>
|
||||
|
||||
|
@ -143,13 +144,13 @@ namespace C4GUI
|
|||
|
||||
void ComboBox::DrawElement(C4TargetFacet &cgo)
|
||||
{
|
||||
CStdFont *pUseFont = this->pUseFont ? this->pUseFont : &(GetRes()->TextFont);
|
||||
CStdFont *pUseFont = this->pUseFont ? this->pUseFont : &(::GraphicsResource.TextFont);
|
||||
// recheck open menu
|
||||
Screen *pScr = GetScreen();
|
||||
if (!pScr || (iOpenMenu != pScr->GetContextMenuIndex())) iOpenMenu = 0;
|
||||
// calc drawing bounds
|
||||
int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y;
|
||||
int32_t iRightTextEnd = x0 + rcBounds.Wdt - GetRes()->fctContext.Wdt - 1;
|
||||
int32_t iRightTextEnd = x0 + rcBounds.Wdt - ::GraphicsResource.fctContext.Wdt - 1;
|
||||
if (!fReadOnly && !fSimple)
|
||||
{
|
||||
// draw background
|
||||
|
@ -165,26 +166,26 @@ namespace C4GUI
|
|||
// default frame color
|
||||
Draw3DFrame(cgo);
|
||||
// draw button; down (phase 1) if combo is down
|
||||
(pFctSideArrow ? pFctSideArrow : &(GetRes()->fctContext))->Draw(cgo.Surface, iRightTextEnd, y0 + (rcBounds.Hgt-GetRes()->fctContext.Hgt)/2, iOpenMenu ? 1 : 0);
|
||||
(pFctSideArrow ? pFctSideArrow : &(::GraphicsResource.fctContext))->Draw(cgo.Surface, iRightTextEnd, y0 + (rcBounds.Hgt-::GraphicsResource.fctContext.Hgt)/2, iOpenMenu ? 1 : 0);
|
||||
}
|
||||
else if (!fReadOnly)
|
||||
{
|
||||
// draw button in simple mode: Left of text
|
||||
(pFctSideArrow ? pFctSideArrow : &(GetRes()->fctContext))->Draw(cgo.Surface, x0, y0 + (rcBounds.Hgt-GetRes()->fctContext.Hgt)/2, iOpenMenu ? 1 : 0);
|
||||
(pFctSideArrow ? pFctSideArrow : &(::GraphicsResource.fctContext))->Draw(cgo.Surface, x0, y0 + (rcBounds.Hgt-::GraphicsResource.fctContext.Hgt)/2, iOpenMenu ? 1 : 0);
|
||||
}
|
||||
// draw text
|
||||
if (*Text)
|
||||
{
|
||||
lpDDraw->StorePrimaryClipper();
|
||||
lpDDraw->SubPrimaryClipper(x0,y0,iRightTextEnd-1,y0+rcBounds.Hgt-1);
|
||||
lpDDraw->TextOut(Text, *pUseFont, 1.0f, cgo.Surface, x0 + GetRes()->fctContext.Wdt + 2, y0 + (rcBounds.Hgt-pUseFont->GetLineHeight())/2, dwFontClr, ALeft);
|
||||
lpDDraw->TextOut(Text, *pUseFont, 1.0f, cgo.Surface, x0 + ::GraphicsResource.fctContext.Wdt + 2, y0 + (rcBounds.Hgt-pUseFont->GetLineHeight())/2, dwFontClr, ALeft);
|
||||
lpDDraw->RestorePrimaryClipper();
|
||||
}
|
||||
// draw selection highlight
|
||||
if ((HasDrawFocus() || iOpenMenu || fMouseOver) && !fReadOnly)
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +223,7 @@ namespace C4GUI
|
|||
|
||||
int32_t ComboBox::GetDefaultHeight()
|
||||
{
|
||||
return GetRes()->TextFont.GetLineHeight() + 4;
|
||||
return ::GraphicsResource.TextFont.GetLineHeight() + 4;
|
||||
}
|
||||
|
||||
void ComboBox::SetText(const char *szToText)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <C4LoaderScreen.h>
|
||||
#include <C4Application.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
namespace C4GUI
|
||||
{
|
||||
|
@ -464,7 +465,7 @@ namespace C4GUI
|
|||
if (iScrollPos < GetMaxScroll()) { ++iScrollPos; OnPosChanged(); }
|
||||
}
|
||||
// draw bar
|
||||
ScrollBarFacets &rUseGfx = pCustomGfx ? *pCustomGfx : GetRes()->sfctScroll;
|
||||
ScrollBarFacets &rUseGfx = pCustomGfx ? *pCustomGfx : ::GraphicsResource.sfctScroll;
|
||||
DynBarFacet bar = rUseGfx.barScroll;
|
||||
if (fTopDown) bar.fctBegin = rUseGfx.fctScrollDTop;
|
||||
if (fBottomDown) bar.fctEnd = rUseGfx.fctScrollDBottom;
|
||||
|
@ -641,7 +642,7 @@ namespace C4GUI
|
|||
CStdFont *GroupBox::GetTitleFont() const
|
||||
{
|
||||
// get font; fallback to GUI caption font
|
||||
return pFont ? pFont : &(GetRes()->CaptionFont);
|
||||
return pFont ? pFont : &(::GraphicsResource.CaptionFont);
|
||||
}
|
||||
|
||||
void GroupBox::DrawElement(C4TargetFacet &cgo)
|
||||
|
|
|
@ -522,7 +522,7 @@ namespace C4GUI
|
|||
int32_t Dialog::GetDefaultTitleHeight()
|
||||
{
|
||||
// default title font
|
||||
return Min<int32_t>(GetRes()->TextFont.GetLineHeight(), C4GUI_MinWoodBarHgt);
|
||||
return Min<int32_t>(::GraphicsResource.TextFont.GetLineHeight(), C4GUI_MinWoodBarHgt);
|
||||
}
|
||||
|
||||
void Dialog::SetTitle(const char *szTitle, bool fShowCloseButton)
|
||||
|
@ -538,7 +538,7 @@ namespace C4GUI
|
|||
// set new
|
||||
if (szTitle && *szTitle)
|
||||
{
|
||||
int32_t iTextHgt = WoodenLabel::GetDefaultHeight(&GetRes()->TextFont);
|
||||
int32_t iTextHgt = WoodenLabel::GetDefaultHeight(&::GraphicsResource.TextFont);
|
||||
if (pTitle)
|
||||
{
|
||||
pTitle->GetBounds() = C4Rect(-GetMarginLeft(), -iTextHgt, rcBounds.Wdt, iTextHgt);
|
||||
|
@ -547,7 +547,7 @@ namespace C4GUI
|
|||
pTitle->SetText(szTitle);
|
||||
}
|
||||
else
|
||||
AddElement(pTitle = new WoodenLabel(szTitle, C4Rect(-GetMarginLeft(), -iTextHgt, rcBounds.Wdt, iTextHgt), C4GUI_CaptionFontClr, &GetRes()->TextFont, ALeft, false));
|
||||
AddElement(pTitle = new WoodenLabel(szTitle, C4Rect(-GetMarginLeft(), -iTextHgt, rcBounds.Wdt, iTextHgt), C4GUI_CaptionFontClr, &::GraphicsResource.TextFont, ALeft, false));
|
||||
pTitle->SetToolTip(szTitle);
|
||||
pTitle->SetDragTarget(this);
|
||||
pTitle->SetAutoScrollTime(C4GUI_TitleAutoScrollTime);
|
||||
|
@ -592,7 +592,7 @@ namespace C4GUI
|
|||
// update title bar position
|
||||
if (pTitle)
|
||||
{
|
||||
int32_t iTextHgt = WoodenLabel::GetDefaultHeight(&GetRes()->TextFont);
|
||||
int32_t iTextHgt = WoodenLabel::GetDefaultHeight(&::GraphicsResource.TextFont);
|
||||
pTitle->SetBounds(C4Rect(-GetMarginLeft(), -iTextHgt, rcBounds.Wdt, iTextHgt));
|
||||
if (pCloseBtn) pCloseBtn->SetBounds(pTitle->GetToprightCornerRect(16,16,4,4,0));
|
||||
}
|
||||
|
@ -983,7 +983,7 @@ namespace C4GUI
|
|||
// create subtitle (only with upperboard)
|
||||
if (szSubtitle && *szSubtitle && HasUpperBoard())
|
||||
{
|
||||
AddElement(pSubTitle = new Label(szSubtitle, rcClientRect.Wdt, C4UpperBoardHeight-GetRes()->CaptionFont.GetLineHeight()/2-25-GetMarginTop(), ARight, C4GUI_CaptionFontClr, &GetRes()->TextFont));
|
||||
AddElement(pSubTitle = new Label(szSubtitle, rcClientRect.Wdt, C4UpperBoardHeight-::GraphicsResource.CaptionFont.GetLineHeight()/2-25-GetMarginTop(), ARight, C4GUI_CaptionFontClr, &::GraphicsResource.TextFont));
|
||||
pSubTitle->SetToolTip(szTitle);
|
||||
}
|
||||
else pSubTitle = NULL;
|
||||
|
@ -1009,10 +1009,10 @@ namespace C4GUI
|
|||
{
|
||||
// not using dlg label, which is a wooden label
|
||||
if (HasUpperBoard())
|
||||
pFullscreenTitle = new Label(szTitle, 0, C4UpperBoardHeight/2 - GetRes()->TitleFont.GetLineHeight()/2-GetMarginTop(), ALeft, C4GUI_CaptionFontClr, &GetRes()->TitleFont);
|
||||
pFullscreenTitle = new Label(szTitle, 0, C4UpperBoardHeight/2 - ::GraphicsResource.TitleFont.GetLineHeight()/2-GetMarginTop(), ALeft, C4GUI_CaptionFontClr, &::GraphicsResource.TitleFont);
|
||||
else
|
||||
// non-woodbar: Title is centered and in big font
|
||||
pFullscreenTitle = new Label(szTitle, GetClientRect().Wdt/2, C4UpperBoardHeight/2 - GetRes()->TitleFont.GetLineHeight()/2-GetMarginTop(), ACenter, C4GUI_FullscreenCaptionFontClr, &GetRes()->TitleFont);
|
||||
pFullscreenTitle = new Label(szTitle, GetClientRect().Wdt/2, C4UpperBoardHeight/2 - ::GraphicsResource.TitleFont.GetLineHeight()/2-GetMarginTop(), ACenter, C4GUI_FullscreenCaptionFontClr, &::GraphicsResource.TitleFont);
|
||||
AddElement(pFullscreenTitle);
|
||||
pFullscreenTitle->SetToolTip(szTitle);
|
||||
}
|
||||
|
@ -1062,7 +1062,7 @@ namespace C4GUI
|
|||
MessageDialog::MessageDialog(const char *szMessage, const char *szCaption, DWORD dwButtons, Icons icoIcon, DlgSize eSize, int32_t *piConfigDontShowAgainSetting, bool fDefaultNo)
|
||||
: Dialog(eSize, 100 /* will be resized */, szCaption, false), piConfigDontShowAgainSetting(piConfigDontShowAgainSetting)
|
||||
{
|
||||
CStdFont &rUseFont = GetRes()->TextFont;
|
||||
CStdFont &rUseFont = ::GraphicsResource.TextFont;
|
||||
// get positions
|
||||
ComponentAligner caMain(GetClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent, true);
|
||||
// place icon
|
||||
|
@ -1189,7 +1189,7 @@ namespace C4GUI
|
|||
// ProgressDialog
|
||||
|
||||
ProgressDialog::ProgressDialog(const char *szMessage, const char *szCaption, int32_t iMaxProgress, int32_t iInitialProgress, Icons icoIcon)
|
||||
: Dialog(C4GUI_ProgressDlgWdt, Max(GetRes()->TextFont.BreakMessage(szMessage, C4GUI_ProgressDlgWdt-3*C4GUI_DefDlgIndent-C4GUI_IconWdt, 0, 0, true), C4GUI_IconHgt) + C4GUI_ProgressDlgVRoom, szCaption, false)
|
||||
: Dialog(C4GUI_ProgressDlgWdt, Max(::GraphicsResource.TextFont.BreakMessage(szMessage, C4GUI_ProgressDlgWdt-3*C4GUI_DefDlgIndent-C4GUI_IconWdt, 0, 0, true), C4GUI_IconHgt) + C4GUI_ProgressDlgVRoom, szCaption, false)
|
||||
{
|
||||
// get positions
|
||||
ComponentAligner caMain(GetClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent, true);
|
||||
|
@ -1201,8 +1201,8 @@ namespace C4GUI
|
|||
// place message label
|
||||
// use text with line breaks
|
||||
StdStrBuf str;
|
||||
GetRes()->TextFont.BreakMessage(szMessage, C4GUI_ProgressDlgWdt-3*C4GUI_DefDlgIndent-C4GUI_IconWdt, &str, true);
|
||||
Label *pLblMessage = new Label(str.getData(), caMain.GetAll().GetMiddleX(), caMain.GetAll().y, ACenter, C4GUI_MessageFontClr, &GetRes()->TextFont);
|
||||
::GraphicsResource.TextFont.BreakMessage(szMessage, C4GUI_ProgressDlgWdt-3*C4GUI_DefDlgIndent-C4GUI_IconWdt, &str, true);
|
||||
Label *pLblMessage = new Label(str.getData(), caMain.GetAll().GetMiddleX(), caMain.GetAll().y, ACenter, C4GUI_MessageFontClr, &::GraphicsResource.TextFont);
|
||||
AddElement(pLblMessage);
|
||||
// place progress bar
|
||||
pBar = new ProgressBar(rtProgressBar, iMaxProgress);
|
||||
|
@ -1297,7 +1297,7 @@ namespace C4GUI
|
|||
InputDialog::InputDialog(const char *szMessage, const char *szCaption, Icons icoIcon, BaseInputCallback *pCB, bool fChatLayout)
|
||||
: Dialog(fChatLayout ? C4GUI::GetScreenWdt()*4/5 : C4GUI_InputDlgWdt,
|
||||
fChatLayout ? C4GUI::Edit::GetDefaultEditHeight() + 2 :
|
||||
Max(GetRes()->TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, 0, 0, true),
|
||||
Max(::GraphicsResource.TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, 0, 0, true),
|
||||
C4GUI_IconHgt) + C4GUI_InputDlgVRoom, szCaption, false),
|
||||
pEdit(NULL), pCB(pCB), fChatLayout(fChatLayout), pChatLbl(NULL)
|
||||
{
|
||||
|
@ -1307,8 +1307,8 @@ namespace C4GUI
|
|||
C4GUI::ComponentAligner caChat(GetContainedClientRect(), 1,1);
|
||||
// normal chatbox layout: Left chat label
|
||||
int32_t w=40,h;
|
||||
C4GUI::GetRes()->TextFont.GetTextExtent(szMessage, w,h, true);
|
||||
pChatLbl = new C4GUI::WoodenLabel(szMessage, caChat.GetFromLeft(w+4), C4GUI_CaptionFontClr, &C4GUI::GetRes()->TextFont);
|
||||
::GraphicsResource.TextFont.GetTextExtent(szMessage, w,h, true);
|
||||
pChatLbl = new C4GUI::WoodenLabel(szMessage, caChat.GetFromLeft(w+4), C4GUI_CaptionFontClr, &::GraphicsResource.TextFont);
|
||||
caChat.ExpandLeft(2); // undo margin
|
||||
rcEditBounds = caChat.GetAll();
|
||||
SetCustomEdit(new Edit(rcEditBounds));
|
||||
|
@ -1328,8 +1328,8 @@ namespace C4GUI
|
|||
// place message label
|
||||
// use text with line breaks
|
||||
StdStrBuf str;
|
||||
GetRes()->TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, &str, true);
|
||||
Label *pLblMessage = new Label(str.getData(), caMain.GetAll().GetMiddleX(), caMain.GetAll().y, ACenter, C4GUI_MessageFontClr, &GetRes()->TextFont);
|
||||
::GraphicsResource.TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, &str, true);
|
||||
Label *pLblMessage = new Label(str.getData(), caMain.GetAll().GetMiddleX(), caMain.GetAll().y, ACenter, C4GUI_MessageFontClr, &::GraphicsResource.TextFont);
|
||||
AddElement(pLblMessage);
|
||||
// place input edit
|
||||
SetCustomEdit(new Edit(rcEditBounds));
|
||||
|
@ -1380,7 +1380,7 @@ namespace C4GUI
|
|||
// InfoDialog
|
||||
|
||||
InfoDialog::InfoDialog(const char *szCaption, int32_t iLineCount)
|
||||
: Dialog(C4GUI_InfoDlgWdt, GetRes()->TextFont.GetLineHeight()*iLineCount + C4GUI_InfoDlgVRoom, szCaption, false), iScroll(0)
|
||||
: Dialog(C4GUI_InfoDlgWdt, ::GraphicsResource.TextFont.GetLineHeight()*iLineCount + C4GUI_InfoDlgVRoom, szCaption, false), iScroll(0)
|
||||
{
|
||||
// timer
|
||||
Application.Add(this);
|
||||
|
@ -1388,7 +1388,7 @@ namespace C4GUI
|
|||
}
|
||||
|
||||
InfoDialog::InfoDialog(const char *szCaption, int iLineCount, const StdStrBuf &sText)
|
||||
: Dialog(C4GUI_InfoDlgWdt, GetRes()->TextFont.GetLineHeight()*iLineCount + C4GUI_InfoDlgVRoom, szCaption, false), iScroll(0)
|
||||
: Dialog(C4GUI_InfoDlgWdt, ::GraphicsResource.TextFont.GetLineHeight()*iLineCount + C4GUI_InfoDlgVRoom, szCaption, false), iScroll(0)
|
||||
{
|
||||
// ctor - init w/o timer
|
||||
CreateSubComponents();
|
||||
|
@ -1398,7 +1398,7 @@ namespace C4GUI
|
|||
size_t i0 = i;
|
||||
while (sText[i] != '|' && sText[i]) ++i;
|
||||
StdStrBuf sLine = sText.copyPart(i0, i-i0);
|
||||
pTextWin->AddTextLine(sLine.getData(), &GetRes()->TextFont, C4GUI_MessageFontClr, false, true);
|
||||
pTextWin->AddTextLine(sLine.getData(), &::GraphicsResource.TextFont, C4GUI_MessageFontClr, false, true);
|
||||
}
|
||||
pTextWin->UpdateHeight();
|
||||
//pTextWin->ScrollToBottom();
|
||||
|
@ -1421,7 +1421,7 @@ namespace C4GUI
|
|||
{
|
||||
// add line to text window
|
||||
if (!pTextWin) return;
|
||||
pTextWin->AddTextLine(szText, &GetRes()->TextFont, C4GUI_MessageFontClr, false, true);
|
||||
pTextWin->AddTextLine(szText, &::GraphicsResource.TextFont, C4GUI_MessageFontClr, false, true);
|
||||
}
|
||||
|
||||
void InfoDialog::AddLineFmt(const char *szFmtString, ...)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <C4LoaderScreen.h>
|
||||
#include <C4Application.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
namespace C4GUI
|
||||
{
|
||||
|
@ -45,7 +46,7 @@ namespace C4GUI
|
|||
iMaxTextLength = 255;
|
||||
iCursorPos = iSelectionStart = iSelectionEnd = 0;
|
||||
iXScroll = 0;
|
||||
pFont = &GetRes()->TextFont;
|
||||
pFont = &::GraphicsResource.TextFont;
|
||||
dwBGClr = C4GUI_EditBGColor;
|
||||
dwFontClr = C4GUI_EditFontColor;
|
||||
dwBorderColor = 0; // default border
|
||||
|
@ -104,7 +105,7 @@ namespace C4GUI
|
|||
int32_t Edit::GetDefaultEditHeight()
|
||||
{
|
||||
// edit height for default font
|
||||
return GetCustomEditHeight(&C4GUI::GetRes()->TextFont);
|
||||
return GetCustomEditHeight(&::GraphicsResource.TextFont);
|
||||
}
|
||||
|
||||
int32_t Edit::GetCustomEditHeight(CStdFont *pUseFont)
|
||||
|
@ -818,7 +819,7 @@ namespace C4GUI
|
|||
LabeledEdit::LabeledEdit(const C4Rect &rcBounds, const char *szName, bool fMultiline, const char *szPrefText, CStdFont *pUseFont, uint32_t dwTextClr)
|
||||
: C4GUI::Window()
|
||||
{
|
||||
if (!pUseFont) pUseFont = &(GetRes()->TextFont);
|
||||
if (!pUseFont) pUseFont = &(::GraphicsResource.TextFont);
|
||||
SetBounds(rcBounds);
|
||||
ComponentAligner caMain(GetClientRect(), 0,0, true);
|
||||
int32_t iLabelWdt=100, iLabelHgt=24;
|
||||
|
@ -845,7 +846,7 @@ namespace C4GUI
|
|||
|
||||
bool LabeledEdit::GetControlSize(int *piWdt, int *piHgt, const char *szForText, CStdFont *pForFont, bool fMultiline)
|
||||
{
|
||||
CStdFont *pUseFont = pForFont ? pForFont : &(GetRes()->TextFont);
|
||||
CStdFont *pUseFont = pForFont ? pForFont : &(::GraphicsResource.TextFont);
|
||||
int32_t iLabelWdt=100, iLabelHgt=24;
|
||||
pUseFont->GetTextExtent(szForText, iLabelWdt, iLabelHgt, true);
|
||||
int32_t iEditWdt = 100, iEditHgt = Edit::GetCustomEditHeight(pUseFont);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <C4LoaderScreen.h>
|
||||
#include <C4Application.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
namespace C4GUI
|
||||
{
|
||||
|
@ -44,7 +45,7 @@ namespace C4GUI
|
|||
// make color readable
|
||||
if (fMakeReadableOnBlack) MakeColorReadableOnBlack(dwFgClr);
|
||||
// default font
|
||||
if (!this->pFont) this->pFont = &GetRes()->TextFont;
|
||||
if (!this->pFont) this->pFont = &::GraphicsResource.TextFont;
|
||||
// set top
|
||||
rcBounds.y = iTop;
|
||||
// update text
|
||||
|
@ -58,7 +59,7 @@ namespace C4GUI
|
|||
if (fMakeReadableOnBlack) MakeColorReadableOnBlack(dwFgClr);
|
||||
this->rcBounds = rcBounds;
|
||||
// default font
|
||||
if (!this->pFont) this->pFont = &GetRes()->TextFont;
|
||||
if (!this->pFont) this->pFont = &::GraphicsResource.TextFont;
|
||||
// set x0
|
||||
UpdateOwnPos();
|
||||
// update text
|
||||
|
@ -139,7 +140,7 @@ namespace C4GUI
|
|||
void WoodenLabel::DrawElement(C4TargetFacet &cgo)
|
||||
{
|
||||
// draw wood
|
||||
DrawBar(cgo, GetRes()->barCaption);
|
||||
DrawBar(cgo, ::GraphicsResource.barCaption);
|
||||
// draw symbol
|
||||
if (fctIcon.Surface)
|
||||
{
|
||||
|
@ -180,7 +181,7 @@ namespace C4GUI
|
|||
|
||||
int32_t WoodenLabel::GetDefaultHeight(CStdFont *pUseFont)
|
||||
{
|
||||
if (!pUseFont) pUseFont = &(GetRes()->TextFont);
|
||||
if (!pUseFont) pUseFont = &(::GraphicsResource.TextFont);
|
||||
return Max<int32_t>(pUseFont->GetLineHeight(), C4GUI_MinWoodBarHgt);
|
||||
}
|
||||
|
||||
|
@ -302,14 +303,14 @@ namespace C4GUI
|
|||
{
|
||||
// do not draw in negative progress
|
||||
if (iProgress<0) return;
|
||||
CStdFont &rFont = GetRes()->TextFont;
|
||||
CStdFont &rFont = ::GraphicsResource.TextFont;
|
||||
// draw border
|
||||
Draw3DFrame(cgo);
|
||||
// calc progress width
|
||||
int32_t iProgressWdt = (rcBounds.Wdt-4) * iProgress / iMax;
|
||||
// draw progress
|
||||
//lpDDraw->DrawBoxDw(cgo.Surface, cgo.TargetX+rcBounds.x+2, cgo.TargetY+rcBounds.y+2, cgo.TargetX+rcBounds.x+iProgressWdt, cgo.TargetY+rcBounds.y+rcBounds.Hgt-2, C4GUI_ProgressBarColor);
|
||||
GetRes()->fctProgressBar.DrawX(cgo.Surface, cgo.TargetX+rcBounds.x+2, cgo.TargetY+rcBounds.y+2, iProgressWdt, rcBounds.Hgt-2);
|
||||
::GraphicsResource.fctProgressBar.DrawX(cgo.Surface, cgo.TargetX+rcBounds.x+2, cgo.TargetY+rcBounds.y+2, iProgressWdt, rcBounds.Hgt-2);
|
||||
// print out progress text
|
||||
char szPrg[32+1];
|
||||
sprintf(szPrg, "%i%%", 100 * iProgress / iMax);
|
||||
|
@ -431,7 +432,7 @@ namespace C4GUI
|
|||
C4Facet Icon::GetIconFacet(Icons icoIconIndex)
|
||||
{
|
||||
if (icoIconIndex == Ico_None) return C4Facet();
|
||||
C4Facet &rFacet = (icoIconIndex & Ico_Extended) ? GetRes()->fctIconsEx : GetRes()->fctIcons;
|
||||
C4Facet &rFacet = (icoIconIndex & Ico_Extended) ? ::GraphicsResource.fctIconsEx : ::GraphicsResource.fctIcons;
|
||||
icoIconIndex = Icons(icoIconIndex & (Ico_Extended-1));
|
||||
int32_t iXMax, iYMax;
|
||||
rFacet.GetPhaseNum(iXMax, iYMax);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <C4Gui.h>
|
||||
#include <C4FacetEx.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#include <StdWindow.h>
|
||||
|
||||
|
@ -44,20 +45,20 @@ namespace C4GUI
|
|||
{
|
||||
// get icon counts
|
||||
int32_t iXMax, iYMax;
|
||||
GetRes()->fctIcons.GetPhaseNum(iXMax, iYMax);
|
||||
::GraphicsResource.fctIcons.GetPhaseNum(iXMax, iYMax);
|
||||
if (!iXMax)
|
||||
iXMax = 6;
|
||||
// load icon
|
||||
const C4Facet &rfctIcon = GetRes()->fctIcons.GetPhase(icoIcon % iXMax, icoIcon / iXMax);
|
||||
const C4Facet &rfctIcon = ::GraphicsResource.fctIcons.GetPhase(icoIcon % iXMax, icoIcon / iXMax);
|
||||
rfctIcon.DrawX(cgo.Surface, rcBounds.x + cgo.TargetX, rcBounds.y + cgo.TargetY, rcBounds.Hgt, rcBounds.Hgt);
|
||||
}
|
||||
// print out label
|
||||
if (!!sText)
|
||||
lpDDraw->TextOut(sText.getData(), GetRes()->TextFont, 1.0f, cgo.Surface, cgo.TargetX+rcBounds.x+GetIconIndent(), rcBounds.y + cgo.TargetY, C4GUI_ContextFontClr, ALeft);
|
||||
lpDDraw->TextOut(sText.getData(), ::GraphicsResource.TextFont, 1.0f, cgo.Surface, cgo.TargetX+rcBounds.x+GetIconIndent(), rcBounds.y + cgo.TargetY, C4GUI_ContextFontClr, ALeft);
|
||||
// submenu arrow
|
||||
if (pSubmenuHandler)
|
||||
{
|
||||
C4Facet &rSubFct = GetRes()->fctSubmenu;
|
||||
C4Facet &rSubFct = ::GraphicsResource.fctSubmenu;
|
||||
rSubFct.Draw(cgo.Surface, cgo.TargetX+rcBounds.x+rcBounds.Wdt - rSubFct.Wdt, cgo.TargetY+rcBounds.y+(rcBounds.Hgt - rSubFct.Hgt)/2);
|
||||
}
|
||||
}
|
||||
|
@ -71,17 +72,17 @@ namespace C4GUI
|
|||
sText.Copy(szText);
|
||||
ExpandHotkeyMarkup(sText, cHotkey);
|
||||
// adjust size
|
||||
GetRes()->TextFont.GetTextExtent(sText.getData(), rcBounds.Wdt, rcBounds.Hgt, true);
|
||||
::GraphicsResource.TextFont.GetTextExtent(sText.getData(), rcBounds.Wdt, rcBounds.Hgt, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
rcBounds.Wdt = 40;
|
||||
rcBounds.Hgt = GetRes()->TextFont.GetLineHeight();
|
||||
rcBounds.Hgt = ::GraphicsResource.TextFont.GetLineHeight();
|
||||
}
|
||||
// regard icon
|
||||
rcBounds.Wdt += GetIconIndent();
|
||||
// submenu arrow
|
||||
if (pSubmenuHandler) rcBounds.Wdt += GetRes()->fctSubmenu.Wdt+2;
|
||||
if (pSubmenuHandler) rcBounds.Wdt += ::GraphicsResource.fctSubmenu.Wdt+2;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
|
@ -623,12 +624,12 @@ namespace C4GUI
|
|||
// calc drawing bounds
|
||||
int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y;
|
||||
// draw button; down (phase 1) if a menu is open
|
||||
GetRes()->fctContext.Draw(cgo.Surface, x0, y0, iOpenMenu ? 1 : 0);
|
||||
::GraphicsResource.fctContext.Draw(cgo.Surface, x0, y0, iOpenMenu ? 1 : 0);
|
||||
// draw selection highlight
|
||||
if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)) || iOpenMenu)
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <C4LoaderScreen.h>
|
||||
#include <C4Application.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
namespace C4GUI
|
||||
{
|
||||
|
@ -55,7 +56,7 @@ namespace C4GUI
|
|||
int32_t iTxtHgt, iTxtWdt;
|
||||
GetCaptionSize(&iTxtWdt, &iTxtHgt, fLarge, fActive, pfctClip, pfctIcon, pUseFont);
|
||||
if (pfctClip) iMaxWdt = iTxtWdt;
|
||||
CStdFont &rUseFont = pUseFont ? *pUseFont : (fLarge ? GetRes()->CaptionFont : GetRes()->TextFont);
|
||||
CStdFont &rUseFont = pUseFont ? *pUseFont : (fLarge ? ::GraphicsResource.CaptionFont : ::GraphicsResource.TextFont);
|
||||
if (pfctClip && pfctIcon)
|
||||
{
|
||||
// tab with clip gfx: Icon on top of text
|
||||
|
@ -71,7 +72,7 @@ namespace C4GUI
|
|||
if (fFocus)
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
GetRes()->fctButtonHighlight.DrawX(cgo.Surface, (fLarge ? x : x - iTxtWdt/2)+5, y+3, (fLarge ? iMaxWdt : iTxtWdt)-10, iTxtHgt-6);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, (fLarge ? x : x - iTxtWdt/2)+5, y+3, (fLarge ? iMaxWdt : iTxtWdt)-10, iTxtHgt-6);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
if (!(pfctClip && pfctIcon))
|
||||
|
@ -124,7 +125,7 @@ namespace C4GUI
|
|||
}
|
||||
// caption by text
|
||||
int32_t iWdt, iHgt;
|
||||
CStdFont &rUseFont = pUseFont ? *pUseFont : (fLarge ? GetRes()->CaptionFont : GetRes()->TextFont);
|
||||
CStdFont &rUseFont = pUseFont ? *pUseFont : (fLarge ? ::GraphicsResource.CaptionFont : ::GraphicsResource.TextFont);
|
||||
if (!rUseFont.GetTextExtent(sTitle.getData(), iWdt, iHgt, fTitleMarkup))
|
||||
{
|
||||
iWdt=70; iHgt=rUseFont.GetLineHeight();
|
||||
|
@ -393,7 +394,7 @@ namespace C4GUI
|
|||
// scrolling in captions
|
||||
int32_t iScrollSize = GetTopSize();
|
||||
if (fScrollingLeft) d -= iCaptionScrollPos + iScrollSize;
|
||||
//DrawBar(cgo, GetRes()->fctCaptionLeft, GetRes()->fctCaptionBar, GetRes()->fctCaptionRight);
|
||||
//DrawBar(cgo, ::GraphicsResource.fctCaptionLeft, ::GraphicsResource.fctCaptionBar, ::GraphicsResource.fctCaptionRight);
|
||||
// tabs
|
||||
for (Sheet *pSheet = (Sheet *) GetFirst(); pSheet; pSheet = (Sheet *) pSheet->GetNext())
|
||||
{
|
||||
|
@ -467,8 +468,8 @@ namespace C4GUI
|
|||
pActiveSheet->DrawCaption(cgo, aCptTxX, aCptTxY, iMaxTabWidth, fLeft, true, HasDrawFocus(), pfctClip, pfctIcons, pSheetCaptionFont);
|
||||
}
|
||||
// scrolling
|
||||
if (fScrollingLeft) GetRes()->fctBigArrows.DrawX(cgo.Surface, x0+iSheetOff,y0-iScrollSize, iScrollSize,iScrollSize, fScrollingLeftDown*2);
|
||||
if (fScrollingRight) GetRes()->fctBigArrows.DrawX(cgo.Surface, x1-iScrollSize,y0-iScrollSize, iScrollSize,iScrollSize, 1+fScrollingRightDown*2);
|
||||
if (fScrollingLeft) ::GraphicsResource.fctBigArrows.DrawX(cgo.Surface, x0+iSheetOff,y0-iScrollSize, iScrollSize,iScrollSize, fScrollingLeftDown*2);
|
||||
if (fScrollingRight) ::GraphicsResource.fctBigArrows.DrawX(cgo.Surface, x1-iScrollSize,y0-iScrollSize, iScrollSize,iScrollSize, 1+fScrollingRightDown*2);
|
||||
}
|
||||
|
||||
void Tabular::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
|
||||
|
|
|
@ -167,9 +167,9 @@ void C4LoaderScreen::Draw(C4Facet &cgo, int iProgress, C4LogBuffer *pLog, int Pr
|
|||
// draw progress bar
|
||||
Application.DDraw->DrawBoxDw(cgo.Surface, iHIndent, cgo.Hgt-iVIndent-iLogBoxHgt-iVMargin-iProgressBarHgt, cgo.Wdt-iHIndent, cgo.Hgt-iVIndent-iLogBoxHgt-iVMargin, 0xb0000000);
|
||||
int iProgressBarWdt=cgo.Wdt-iHIndent*2-2;
|
||||
if (C4GUI::IsGUIValid())
|
||||
if (::GraphicsResource.fctProgressBar.Surface)
|
||||
{
|
||||
C4GUI::GetRes()->fctProgressBar.DrawX(cgo.Surface, iHIndent+1, cgo.Hgt-iVIndent-iLogBoxHgt-iVMargin-iProgressBarHgt+1, iProgressBarWdt*iProgress/100, iProgressBarHgt-2);
|
||||
::GraphicsResource.fctProgressBar.DrawX(cgo.Surface, iHIndent+1, cgo.Hgt-iVIndent-iLogBoxHgt-iVMargin-iProgressBarHgt+1, iProgressBarWdt*iProgress/100, iProgressBarHgt-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include <C4GraphicsSystem.h>
|
||||
#include <C4PlayerList.h>
|
||||
#include <C4GameControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#include <cctype>
|
||||
|
||||
// --------------------------------------------------
|
||||
|
@ -51,7 +53,7 @@ bool IsSmallInputQuery(const char *szInputQuery)
|
|||
if (!szInputQuery) return true;
|
||||
int32_t w,h;
|
||||
if (SCharCount('|', szInputQuery)) return false;
|
||||
if (!C4GUI::GetRes()->TextFont.GetTextExtent(szInputQuery, w,h, true))
|
||||
if (!::GraphicsResource.TextFont.GetTextExtent(szInputQuery, w,h, true))
|
||||
return false; // ???
|
||||
return w<C4GUI::GetScreenWdt()/5;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ C4PlayerInfoListBox::PlayerListItem::PlayerListItem(C4PlayerInfoListBox *pForLis
|
|||
// league account name? Overwrite the shown name
|
||||
StdStrBuf sPlayerName(pInfo->GetLobbyName());
|
||||
// calc height
|
||||
int32_t iHeight = C4GUI::GetRes()->TextFont.GetLineHeight() + C4GUI::ComboBox::GetDefaultHeight() + 3 * IconLabelSpacing;
|
||||
int32_t iHeight = ::GraphicsResource.TextFont.GetLineHeight() + C4GUI::ComboBox::GetDefaultHeight() + 3 * IconLabelSpacing;
|
||||
// create subcomponents
|
||||
pIcon = new C4GUI::Icon(C4Rect(0, 0, iHeight, iHeight), C4GUI::Ico_UnknownPlayer);
|
||||
if (Game.Parameters.isLeague())
|
||||
|
@ -139,7 +139,7 @@ C4PlayerInfoListBox::PlayerListItem::PlayerListItem(C4PlayerInfoListBox *pForLis
|
|||
if (szCustomEval && *szCustomEval)
|
||||
{
|
||||
pExtraLabel = new C4GUI::Label(szCustomEval, 0,0, ARight); // positioned later
|
||||
iHeight += C4GUI::GetRes()->TextFont.GetLineHeight();
|
||||
iHeight += ::GraphicsResource.TextFont.GetLineHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ void C4PlayerInfoListBox::PlayerListItem::UpdateOwnPos()
|
|||
if (pTeamPic) caBounds.GetFromLeft(pTeamPic->GetBounds().Wdt - IconLabelSpacing);
|
||||
C4Rect rcExtraDataRect;
|
||||
// extra data label area
|
||||
if (pExtraLabel) rcExtraDataRect = caBounds.GetFromBottom(C4GUI::GetRes()->TextFont.GetLineHeight());
|
||||
if (pExtraLabel) rcExtraDataRect = caBounds.GetFromBottom(::GraphicsResource.TextFont.GetLineHeight());
|
||||
// second line (team+rank)
|
||||
C4GUI::ComponentAligner caTeamArea(caBounds.GetFromBottom(C4GUI::ComboBox::GetDefaultHeight()), 0,0);
|
||||
C4Rect rcRankIcon;
|
||||
|
@ -457,14 +457,14 @@ void C4PlayerInfoListBox::PlayerListItem::UpdateCollapsed()
|
|||
if ((fShownCollapsed = fShouldBeCollapsed))
|
||||
{
|
||||
// calc height
|
||||
iHeight = C4GUI::GetRes()->TextFont.GetLineHeight() + 2 * IconLabelSpacing;
|
||||
iHeight = ::GraphicsResource.TextFont.GetLineHeight() + 2 * IconLabelSpacing;
|
||||
// teamcombo not visible if collapsed
|
||||
if (pTeamCombo) pTeamCombo->SetVisibility(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// calc height
|
||||
iHeight = C4GUI::GetRes()->TextFont.GetLineHeight() + C4GUI::ComboBox::GetDefaultHeight() + 3 * IconLabelSpacing;
|
||||
iHeight = ::GraphicsResource.TextFont.GetLineHeight() + C4GUI::ComboBox::GetDefaultHeight() + 3 * IconLabelSpacing;
|
||||
// teamcombo visible if not collapsed
|
||||
if (pTeamCombo) pTeamCombo->SetVisibility(true);
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ C4PlayerInfoListBox::ClientListItem::ClientListItem(C4PlayerInfoListBox *pForLis
|
|||
idListItemID.idType = ListItem::ID::PLI_CLIENT;
|
||||
idListItemID.id = idClient;
|
||||
// get height
|
||||
int32_t iIconSize = C4GUI::GetRes()->TextFont.GetLineHeight();
|
||||
int32_t iIconSize = ::GraphicsResource.TextFont.GetLineHeight();
|
||||
// create subcomponents
|
||||
pStatusIcon = new C4GUI::Icon(C4Rect(0, 0, iIconSize, iIconSize), GetCurrentStatusIcon());
|
||||
pNameLabel = new C4GUI::Label(rClientInfo.getName(), iIconSize + IconLabelSpacing,0, ALeft, dwClientClr | C4GUI_MessageFontAlpha, NULL, true, false);
|
||||
|
@ -982,12 +982,12 @@ C4PlayerInfoListBox::TeamListItem::TeamListItem(C4PlayerInfoListBox *pForListBox
|
|||
int32_t iIconSize; CStdFont *pFont;
|
||||
if (!fEvaluation)
|
||||
{
|
||||
pFont = &C4GUI::GetRes()->TextFont;
|
||||
pFont = &::GraphicsResource.TextFont;
|
||||
iIconSize = pFont->GetLineHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
pFont = &C4GUI::GetRes()->TitleFont;
|
||||
pFont = &::GraphicsResource.TitleFont;
|
||||
iIconSize = C4SymbolSize; // C4PictureSize doesn't fit...
|
||||
}
|
||||
// create subcomponents
|
||||
|
@ -1030,11 +1030,11 @@ void C4PlayerInfoListBox::TeamListItem::UpdateOwnPos()
|
|||
// evaluation: Center team label
|
||||
if (pList->IsEvaluation())
|
||||
{
|
||||
int32_t iTotalWdt = pIcon->GetBounds().Wdt + IconLabelSpacing + C4GUI::GetRes()->TitleFont.GetTextWidth(pNameLabel->GetText());
|
||||
int32_t iTotalWdt = pIcon->GetBounds().Wdt + IconLabelSpacing + ::GraphicsResource.TitleFont.GetTextWidth(pNameLabel->GetText());
|
||||
C4GUI::ComponentAligner caAll(GetContainedClientRect(), 0,0);
|
||||
C4GUI::ComponentAligner caBounds(caAll.GetCentered(iTotalWdt, caAll.GetInnerHeight()), 0,0);
|
||||
pIcon->SetBounds(caBounds.GetFromLeft(pIcon->GetBounds().Wdt, pIcon->GetBounds().Hgt));
|
||||
pNameLabel->SetBounds(caBounds.GetCentered(caBounds.GetInnerWidth(), C4GUI::GetRes()->TitleFont.GetLineHeight()));
|
||||
pNameLabel->SetBounds(caBounds.GetCentered(caBounds.GetInnerWidth(), ::GraphicsResource.TitleFont.GetLineHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1095,7 +1095,7 @@ C4PlayerInfoListBox::FreeSavegamePlayersListItem::FreeSavegamePlayersListItem(C4
|
|||
idListItemID.idType = ListItem::ID::PLI_SAVEGAMEPLR;
|
||||
idListItemID.id = 0;
|
||||
// get height
|
||||
int32_t iIconSize = C4GUI::GetRes()->TextFont.GetLineHeight();
|
||||
int32_t iIconSize = ::GraphicsResource.TextFont.GetLineHeight();
|
||||
// create subcomponents
|
||||
pIcon = new C4GUI::Icon(C4Rect(0, 0, iIconSize, iIconSize), C4GUI::Ico_SavegamePlayer);
|
||||
pNameLabel = new C4GUI::Label(LoadResStr("IDS_MSG_FREESAVEGAMEPLRS"), iIconSize + IconLabelSpacing,0, ALeft);
|
||||
|
@ -1130,7 +1130,7 @@ C4PlayerInfoListBox::ScriptPlayersListItem::ScriptPlayersListItem(C4PlayerInfoLi
|
|||
idListItemID.idType = ListItem::ID::PLI_SCRIPTPLR;
|
||||
idListItemID.id = 0;
|
||||
// get height
|
||||
int32_t iIconSize = C4GUI::GetRes()->TextFont.GetLineHeight();
|
||||
int32_t iIconSize = ::GraphicsResource.TextFont.GetLineHeight();
|
||||
// create subcomponents
|
||||
pIcon = new C4GUI::Icon(C4Rect(0, 0, iIconSize, iIconSize), C4GUI::Ico_Record);
|
||||
pNameLabel = new C4GUI::Label(LoadResStr("IDS_CTL_SCRIPTPLAYERS"), iIconSize + IconLabelSpacing,0, ALeft);
|
||||
|
@ -1197,7 +1197,7 @@ C4PlayerInfoListBox::ReplayPlayersListItem::ReplayPlayersListItem(C4PlayerInfoLi
|
|||
idListItemID.idType = ListItem::ID::PLI_REPLAY;
|
||||
idListItemID.id = 0;
|
||||
// get height
|
||||
int32_t iIconSize = C4GUI::GetRes()->TextFont.GetLineHeight();
|
||||
int32_t iIconSize = ::GraphicsResource.TextFont.GetLineHeight();
|
||||
// create subcomponents
|
||||
pIcon = new C4GUI::Icon(C4Rect(0, 0, iIconSize, iIconSize), C4GUI::Ico_Record);
|
||||
pNameLabel = new C4GUI::Label(LoadResStr("IDS_MSG_REPLAYPLRS"), iIconSize + IconLabelSpacing,0, ALeft);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <C4Include.h>
|
||||
#include <C4StartupAboutDlg.h>
|
||||
#include <C4UpdateDlg.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#include <C4StartupMainDlg.h>
|
||||
|
||||
|
@ -42,7 +43,7 @@ C4StartupAboutDlg::C4StartupAboutDlg() : C4StartupDlg("")
|
|||
// version and registration info in topright corner
|
||||
C4Rect rcClient = GetContainedClientRect();
|
||||
StdStrBuf sVersion; sVersion.Format(LoadResStr("IDS_DLG_VERSION"), C4VERSION);
|
||||
CStdFont &rUseFont = C4GUI::GetRes()->TextFont;
|
||||
CStdFont &rUseFont = ::GraphicsResource.TextFont;
|
||||
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));
|
||||
|
|
|
@ -70,7 +70,7 @@ C4StartupMainDlg::C4StartupMainDlg() : C4StartupDlg(NULL) // create w/o title; i
|
|||
btn->SetToolTip(LoadResStr("IDS_DLGTIP_EXIT"));
|
||||
btn->SetCustomGraphics(&C4Startup::Get()->Graphics.barMainButtons, &C4Startup::Get()->Graphics.barMainButtonsDown);
|
||||
// list of selected players
|
||||
AddElement(pParticipantsLbl = new C4GUI::Label("test", GetClientRect().Wdt*39/40, GetClientRect().Hgt*9/10, ARight, 0xffffffff, &C4GUI::GetRes()->TitleFont, false));
|
||||
AddElement(pParticipantsLbl = new C4GUI::Label("test", GetClientRect().Wdt*39/40, GetClientRect().Hgt*9/10, ARight, 0xffffffff, &::GraphicsResource.TitleFont, false));
|
||||
pParticipantsLbl->SetToolTip(LoadResStr("IDS_DLGTIP_SELECTEDPLAYERS"));
|
||||
// player selection shortcut - to be made optional
|
||||
UpdateParticipants();
|
||||
|
@ -121,7 +121,7 @@ void C4StartupMainDlg::DrawElement(C4TargetFacet &cgo)
|
|||
// draw version info
|
||||
StdStrBuf sVer;
|
||||
sVer.Format(LoadResStr("IDS_DLG_VERSION"), C4VERSION);
|
||||
lpDDraw->TextOut(sVer.getData(), C4GUI::GetRes()->TextFont, 1.0f, cgo.Surface, rcBounds.Wdt*1/40, rcBounds.Hgt/12 + int32_t(fLogoZoom*fctLogo.Hgt) - 10, 0xffffffff, ALeft, true);
|
||||
lpDDraw->TextOut(sVer.getData(), ::GraphicsResource.TextFont, 1.0f, cgo.Surface, rcBounds.Wdt*1/40, rcBounds.Hgt/12 + int32_t(fLogoZoom*fctLogo.Hgt) - 10, 0xffffffff, ALeft, true);
|
||||
}
|
||||
|
||||
C4GUI::ContextMenu *C4StartupMainDlg::OnPlayerSelContext(C4GUI::Element *pBtn, int32_t iX, int32_t iY)
|
||||
|
|
|
@ -32,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <C4Game.h>
|
||||
#include <C4Log.h>
|
||||
#include "C4ChatDlg.h"
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
|
@ -43,7 +44,7 @@ C4StartupNetListEntry::C4StartupNetListEntry(C4GUI::ListBox *pForListBox, C4GUI:
|
|||
: pNetDlg(pNetDlg), pList(pForListBox), pRefClient(NULL), pRef(NULL), fError(false), eQueryType(NRQT_Unknown), iTimeout(0), iInfoIconCount(0), iSortOrder(0), fIsSmall(false), fIsCollapsed(false), fIsEnabled(true), fIsImportant(false)
|
||||
{
|
||||
// calc height
|
||||
int32_t iLineHgt = C4GUI::GetRes()->TextFont.GetLineHeight(), iHeight = iLineHgt * 2 + 4;
|
||||
int32_t iLineHgt = ::GraphicsResource.TextFont.GetLineHeight(), iHeight = iLineHgt * 2 + 4;
|
||||
// add icons - normal icons use small size, only animated netgetref uses full size
|
||||
rctIconLarge.Set(0, 0, iHeight, iHeight);
|
||||
int32_t iSmallIcon = iHeight * 2 / 3; rctIconSmall.Set((iHeight - iSmallIcon)/2, (iHeight - iSmallIcon)/2, iSmallIcon, iSmallIcon);
|
||||
|
@ -53,7 +54,7 @@ C4StartupNetListEntry::C4StartupNetListEntry(C4GUI::ListBox *pForListBox, C4GUI:
|
|||
// add to listbox (will get resized horizontally and moved)
|
||||
pForListBox->InsertElement(this, pInsertBefore);
|
||||
// add status icons and text labels now that width is known
|
||||
CStdFont *pUseFont = &(C4GUI::GetRes()->TextFont);
|
||||
CStdFont *pUseFont = &(::GraphicsResource.TextFont);
|
||||
int32_t iIconSize = pUseFont->GetLineHeight();
|
||||
C4Rect rcIconRect = GetContainedClientRect();
|
||||
int32_t iThisWdt = rcIconRect.Wdt;
|
||||
|
@ -342,7 +343,7 @@ void C4StartupNetListEntry::UpdateEntrySize()
|
|||
void C4StartupNetListEntry::UpdateText()
|
||||
{
|
||||
bool fRestackElements=false;
|
||||
CStdFont *pUseFont = &(C4GUI::GetRes()->TextFont);
|
||||
CStdFont *pUseFont = &(::GraphicsResource.TextFont);
|
||||
// adjust icons
|
||||
int32_t sx=iInfoIconCount*pUseFont->GetLineHeight();
|
||||
int32_t i;
|
||||
|
@ -591,7 +592,7 @@ C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART")
|
|||
int32_t iIconSize = C4GUI_IconExWdt;
|
||||
int32_t iButtonWidth,iCaptionFontHgt, iSideSize = Max<int32_t>(GetBounds().Wdt/6, iIconSize);
|
||||
int32_t iButtonHeight = C4GUI_ButtonHgt, iButtonIndent = GetBounds().Wdt/40;
|
||||
C4GUI::GetRes()->CaptionFont.GetTextExtent("<< BACK", iButtonWidth, iCaptionFontHgt, true);
|
||||
::GraphicsResource.CaptionFont.GetTextExtent("<< BACK", iButtonWidth, iCaptionFontHgt, true);
|
||||
iButtonWidth *= 3;
|
||||
C4GUI::ComponentAligner caMain(GetClientRect(), 0,0, true);
|
||||
C4GUI::ComponentAligner caButtonArea(caMain.GetFromBottom(caMain.GetHeight()/7),0,0);
|
||||
|
@ -625,8 +626,8 @@ C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART")
|
|||
// main area: game selection sheet
|
||||
C4GUI::Tabular::Sheet *pSheetGameList = pMainTabular->AddSheet(NULL);
|
||||
C4GUI::ComponentAligner caGameList(pSheetGameList->GetContainedClientRect(), 0,0, false);
|
||||
C4GUI::WoodenLabel *pGameListLbl; int32_t iCaptHgt = C4GUI::WoodenLabel::GetDefaultHeight(&C4GUI::GetRes()->TextFont);
|
||||
pGameListLbl = new C4GUI::WoodenLabel(LoadResStr("IDS_NET_GAMELIST"), caGameList.GetFromTop(iCaptHgt), C4GUI_Caption2FontClr, &C4GUI::GetRes()->TextFont, ALeft);
|
||||
C4GUI::WoodenLabel *pGameListLbl; int32_t iCaptHgt = C4GUI::WoodenLabel::GetDefaultHeight(&::GraphicsResource.TextFont);
|
||||
pGameListLbl = new C4GUI::WoodenLabel(LoadResStr("IDS_NET_GAMELIST"), caGameList.GetFromTop(iCaptHgt), C4GUI_Caption2FontClr, &::GraphicsResource.TextFont, ALeft);
|
||||
//const char *szGameSelListTip = LoadResStr("IDS_NET_GAMELIST_INFO"); disabled this tooltip, it's mainly disturbing when browsing the list
|
||||
//pGameListLbl->SetToolTip(szGameSelListTip);
|
||||
pSheetGameList->AddElement(pGameListLbl);
|
||||
|
@ -641,8 +642,8 @@ C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART")
|
|||
C4GUI::WoodenLabel *pIPLbl;
|
||||
const char *szIPLblText = LoadResStr("IDS_NET_IP");
|
||||
int32_t iIPWdt=100, Q;
|
||||
C4GUI::GetRes()->TextFont.GetTextExtent(szIPLblText, iIPWdt, Q, true);
|
||||
pIPLbl = new C4GUI::WoodenLabel(szIPLblText, caIP.GetFromLeft(iIPWdt+10), C4GUI_Caption2FontClr, &C4GUI::GetRes()->TextFont);
|
||||
::GraphicsResource.TextFont.GetTextExtent(szIPLblText, iIPWdt, Q, true);
|
||||
pIPLbl = new C4GUI::WoodenLabel(szIPLblText, caIP.GetFromLeft(iIPWdt+10), C4GUI_Caption2FontClr, &::GraphicsResource.TextFont);
|
||||
const char *szIPTip = LoadResStr("IDS_NET_IP_DESC");
|
||||
pIPLbl->SetToolTip(szIPTip);
|
||||
pSheetGameList->AddElement(pIPLbl);
|
||||
|
@ -655,7 +656,7 @@ C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART")
|
|||
{
|
||||
C4GUI::Tabular::Sheet *pSheetChat = pMainTabular->AddSheet(NULL);
|
||||
C4GUI::ComponentAligner caChat(pSheetChat->GetContainedClientRect(), 0,0, false);
|
||||
pSheetChat->AddElement(pChatTitleLabel = new C4GUI::WoodenLabel("", caChat.GetFromTop(iCaptHgt), C4GUI_Caption2FontClr, &C4GUI::GetRes()->TextFont, ALeft, false));
|
||||
pSheetChat->AddElement(pChatTitleLabel = new C4GUI::WoodenLabel("", caChat.GetFromTop(iCaptHgt), C4GUI_Caption2FontClr, &::GraphicsResource.TextFont, ALeft, false));
|
||||
C4GUI::GroupBox *pChatGroup = new C4GUI::GroupBox(caChat.GetAll());
|
||||
pChatGroup->SetColors(0u, C4GUI_CaptionFontClr, C4GUI_StandardBGColor);
|
||||
pChatGroup->SetMargin(2);
|
||||
|
|
|
@ -63,7 +63,7 @@ void C4StartupOptionsDlg::SmallButton::DrawElement(C4TargetFacet &cgo)
|
|||
if (fEnabled) if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)))
|
||||
{
|
||||
lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
|
||||
C4GUI::GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0+5+iTxtOff, y0+3+iTxtOff, rcBounds.Wdt-10, rcBounds.Hgt-6);
|
||||
::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0+5+iTxtOff, y0+3+iTxtOff, rcBounds.Wdt-10, rcBounds.Hgt-6);
|
||||
lpDDraw->ResetBlitMode();
|
||||
}
|
||||
// draw button text
|
||||
|
@ -101,13 +101,13 @@ C4StartupOptionsDlg::ResChangeConfirmDlg::ResChangeConfirmDlg()
|
|||
// place message labels
|
||||
// use text with line breaks
|
||||
StdStrBuf sMsgBroken;
|
||||
int iMsgHeight = C4GUI::GetRes()->TextFont.BreakMessage(LoadResStr("IDS_MNU_SWITCHRESOLUTION_LIKEIT"), caMain.GetInnerWidth(), &sMsgBroken, true);
|
||||
C4GUI::Label *pLblMessage = new C4GUI::Label(sMsgBroken.getData(), caMain.GetFromTop(iMsgHeight), ACenter, C4GUI_MessageFontClr, &C4GUI::GetRes()->TextFont, false);
|
||||
int iMsgHeight = ::GraphicsResource.TextFont.BreakMessage(LoadResStr("IDS_MNU_SWITCHRESOLUTION_LIKEIT"), caMain.GetInnerWidth(), &sMsgBroken, true);
|
||||
C4GUI::Label *pLblMessage = new C4GUI::Label(sMsgBroken.getData(), caMain.GetFromTop(iMsgHeight), ACenter, C4GUI_MessageFontClr, &::GraphicsResource.TextFont, false);
|
||||
AddElement(pLblMessage);
|
||||
iMsgHeight = C4GUI::GetRes()->TextFont.BreakMessage(FormatString(LoadResStr("IDS_MNU_SWITCHRESOLUTION_UNDO"),
|
||||
iMsgHeight = ::GraphicsResource.TextFont.BreakMessage(FormatString(LoadResStr("IDS_MNU_SWITCHRESOLUTION_UNDO"),
|
||||
(int)iResChangeSwitchTime).getData(),
|
||||
caMain.GetInnerWidth(), &sMsgBroken, true);
|
||||
pOperationCancelLabel = new C4GUI::Label(sMsgBroken.getData(), caMain.GetFromTop(iMsgHeight), ACenter, C4GUI_MessageFontClr, &C4GUI::GetRes()->TextFont, false, false);
|
||||
pOperationCancelLabel = new C4GUI::Label(sMsgBroken.getData(), caMain.GetFromTop(iMsgHeight), ACenter, C4GUI_MessageFontClr, &::GraphicsResource.TextFont, false, false);
|
||||
AddElement(pOperationCancelLabel);
|
||||
// place buttons
|
||||
C4GUI::ComponentAligner caButtonArea(caMain.GetFromTop(C4GUI_ButtonAreaHgt), 0,0);
|
||||
|
@ -141,7 +141,7 @@ void C4StartupOptionsDlg::ResChangeConfirmDlg::OnSec1Timer()
|
|||
}
|
||||
// update timer label
|
||||
StdStrBuf sTimerText;
|
||||
C4GUI::GetRes()->TextFont.BreakMessage(FormatString(LoadResStr("IDS_MNU_SWITCHRESOLUTION_UNDO"),
|
||||
::GraphicsResource.TextFont.BreakMessage(FormatString(LoadResStr("IDS_MNU_SWITCHRESOLUTION_UNDO"),
|
||||
(int)iResChangeSwitchTime).getData(),
|
||||
pOperationCancelLabel->GetBounds().Wdt, &sTimerText, true);
|
||||
pOperationCancelLabel->SetText(sTimerText.getData());
|
||||
|
@ -336,7 +336,7 @@ C4StartupOptionsDlg::ControlConfigArea::ControlConfigArea(const C4Rect &rcArea,
|
|||
// reset button
|
||||
const char *szBtnText = LoadResStr("IDS_BTN_RESETKEYBOARD");
|
||||
int32_t iButtonWidth=100, iButtonHeight=20; C4GUI::Button *btn;
|
||||
C4GUI::GetRes()->CaptionFont.GetTextExtent(szBtnText, iButtonWidth, iButtonHeight, true);
|
||||
::GraphicsResource.CaptionFont.GetTextExtent(szBtnText, iButtonWidth, iButtonHeight, true);
|
||||
C4Rect rcResetBtn = caKeyBottomBtns.GetFromRight(Min<int32_t>(iButtonWidth+iButtonHeight*4, caKeyBottomBtns.GetInnerWidth()));
|
||||
AddElement(btn = new C4GUI::CallbackButton<C4StartupOptionsDlg::ControlConfigArea, SmallButton>(szBtnText, rcResetBtn, &C4StartupOptionsDlg::ControlConfigArea::OnResetKeysBtn, this));
|
||||
btn->SetToolTip(LoadResStr("IDS_MSG_RESETKEYSETS"));
|
||||
|
@ -628,7 +628,7 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D
|
|||
// screen calculations
|
||||
int32_t iButtonWidth,iCaptionFontHgt;
|
||||
int32_t iButtonHeight = C4GUI_ButtonHgt;
|
||||
C4GUI::GetRes()->CaptionFont.GetTextExtent("<< BACK", iButtonWidth, iCaptionFontHgt, true);
|
||||
::GraphicsResource.CaptionFont.GetTextExtent("<< BACK", iButtonWidth, iCaptionFontHgt, true);
|
||||
iButtonWidth *= 3;
|
||||
int iIndentX1, iIndentX2, iIndentY1, iIndentY2;
|
||||
if (fSmall)
|
||||
|
@ -695,7 +695,7 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D
|
|||
pLangCombo->SetFont(pUseFont);
|
||||
pLangCombo->SetDecoration(&(C4Startup::Get()->Graphics.fctContext));
|
||||
pSheetGeneral->AddElement(pLangCombo);
|
||||
pLangInfoLabel = new C4GUI::Label(NULL, caLanguage.GetFromTop(C4GUI::GetRes()->TextFont.GetLineHeight()*3), ALeft, C4StartupFontClr, pUseFont, false);
|
||||
pLangInfoLabel = new C4GUI::Label(NULL, caLanguage.GetFromTop(::GraphicsResource.TextFont.GetLineHeight()*3), ALeft, C4StartupFontClr, pUseFont, false);
|
||||
pLangInfoLabel->SetToolTip(szLangTip);
|
||||
pSheetGeneral->AddElement(pLangInfoLabel);
|
||||
UpdateLanguage();
|
||||
|
@ -758,7 +758,7 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D
|
|||
// reset configuration
|
||||
const char *szBtnText = LoadResStr("IDS_BTN_RESETCONFIG");
|
||||
C4GUI::CallbackButton<C4StartupOptionsDlg, SmallButton> *pSmallBtn;
|
||||
C4GUI::GetRes()->CaptionFont.GetTextExtent(szBtnText, iButtonWidth, iButtonHeight, true);
|
||||
::GraphicsResource.CaptionFont.GetTextExtent(szBtnText, iButtonWidth, iButtonHeight, true);
|
||||
C4Rect rcResetBtn = caSheetProgram.GetGridCell(1,2,6,7, Min<int32_t>(iButtonWidth+iButtonHeight*4, caSheetProgram.GetInnerWidth()*2/5), SmallButton::GetDefaultButtonHeight(), true);
|
||||
pSheetGeneral->AddElement(pSmallBtn = new C4GUI::CallbackButton<C4StartupOptionsDlg, SmallButton>(szBtnText, rcResetBtn, &C4StartupOptionsDlg::OnResetConfigBtn, this));
|
||||
pSmallBtn->SetToolTip(LoadResStr("IDS_DESC_RESETCONFIG"));
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <C4Language.h>
|
||||
#include <C4FileSelDlg.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#include <set>
|
||||
|
||||
|
@ -369,7 +370,7 @@ void C4MapFolderData::CreateGUIElements(C4StartupScenSelDlg *pMainDlg, C4GUI::Wi
|
|||
if (pScen->fTitleBookFont)
|
||||
pUseFont = &(C4Startup::Get()->Graphics.GetBlackFontByHeight(pScen->iTitleFontSize, &fFontZoom));
|
||||
else
|
||||
pUseFont = &(C4GUI::GetRes()->GetFontByHeight(pScen->iTitleFontSize, &fFontZoom));
|
||||
pUseFont = &(::GraphicsResource.GetFontByHeight(pScen->iTitleFontSize, &fFontZoom));
|
||||
if (Inside<float>(fFontZoom, 0.8f, 1.25f)) fFontZoom = 1.0f; // some tolerance for font zoom
|
||||
pBtn->SetTextFont(pUseFont, fFontZoom);
|
||||
}
|
||||
|
@ -1352,7 +1353,7 @@ C4StartupScenSelDlg::C4StartupScenSelDlg(bool fNetwork) : C4StartupDlg(LoadResSt
|
|||
int iBookPageWidth;
|
||||
int iExtraHPadding = rcBounds.Wdt >= 700 ? rcBounds.Wdt/50 : 0;
|
||||
int iExtraVPadding = rcBounds.Hgt >= 540 ? rcBounds.Hgt/20 : 0;
|
||||
C4GUI::GetRes()->CaptionFont.GetTextExtent("<< BACK", iButtonWidth, iCaptionFontHgt, true);
|
||||
::GraphicsResource.CaptionFont.GetTextExtent("<< BACK", iButtonWidth, iCaptionFontHgt, true);
|
||||
iButtonWidth *= 3;
|
||||
C4GUI::ComponentAligner caMain(GetClientRect(), 0,0, true);
|
||||
C4GUI::ComponentAligner caButtonArea(caMain.GetFromBottom(caMain.GetHeight()/8),rcBounds.Wdt/(rcBounds.Wdt >= 700 ? 128 : 256),0);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <C4Include.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#include <C4Gui.h>
|
||||
#include <C4Log.h>
|
||||
#include <C4Game.h>
|
||||
#include <C4GraphicsSystem.h>
|
||||
|
@ -34,7 +33,9 @@
|
|||
|
||||
#include <StdGL.h>
|
||||
|
||||
C4GraphicsResource::C4GraphicsResource()
|
||||
C4GraphicsResource::C4GraphicsResource():
|
||||
idSfcCaption(0), idSfcButton(0), idSfcButtonD(0), idSfcScroll(0), idSfcContext(0),
|
||||
CaptionFont(FontCaption), TitleFont(FontTitle), TextFont(FontRegular), MiniFont(FontTiny), TooltipFont(FontTooltip)
|
||||
{
|
||||
Default();
|
||||
}
|
||||
|
@ -99,8 +100,6 @@ void C4GraphicsResource::Default()
|
|||
void C4GraphicsResource::Clear()
|
||||
{
|
||||
fInitialized = false;
|
||||
// GUI data
|
||||
C4GUI::Resource::Unload();
|
||||
|
||||
sfcControl.Clear();
|
||||
idSfcControl = 0;
|
||||
|
@ -134,6 +133,16 @@ void C4GraphicsResource::Clear()
|
|||
fctHand.Clear();
|
||||
fctGamepad.Clear();
|
||||
fctBuild.Clear();
|
||||
// GUI data
|
||||
sfcCaption.Clear(); sfcButton.Clear(); sfcButtonD.Clear(); sfcScroll.Clear(); sfcContext.Clear();
|
||||
idSfcCaption = idSfcButton = idSfcButtonD = idSfcScroll = idSfcContext = 0;
|
||||
barCaption.Clear(); barButton.Clear(); barButtonD.Clear();
|
||||
fctButtonHighlight.Clear(); fctIcons.Clear(); fctIconsEx.Clear();
|
||||
fctSubmenu.Clear();
|
||||
fctCheckbox.Clear();
|
||||
fctBigArrows.Clear();
|
||||
fctProgressBar.Clear();
|
||||
fctContext.Default();
|
||||
|
||||
// unhook deflist from font
|
||||
FontRegular.SetCustomImages(NULL);
|
||||
|
@ -173,15 +182,15 @@ bool C4GraphicsResource::InitFonts()
|
|||
const char *szFont;
|
||||
if (*Game.C4S.Head.Font) szFont = Game.C4S.Head.Font; else szFont = Config.General.RXFontName;
|
||||
if (!::FontLoader.InitFont(FontRegular, szFont, C4FontLoader::C4FT_Main, Config.General.RXFontSize, &Files)) return false;
|
||||
Game.SetInitProgress(17.0f);
|
||||
Game.SetInitProgress(33.0f);
|
||||
if (!::FontLoader.InitFont(FontTiny, szFont, C4FontLoader::C4FT_Log, Config.General.RXFontSize, &Files)) return false;
|
||||
Game.SetInitProgress(17.5f);
|
||||
Game.SetInitProgress(33.5f);
|
||||
if (!::FontLoader.InitFont(FontTitle, szFont, C4FontLoader::C4FT_Title, Config.General.RXFontSize, &Files)) return false;
|
||||
Game.SetInitProgress(18.0f);
|
||||
Game.SetInitProgress(34.0f);
|
||||
if (!::FontLoader.InitFont(FontCaption, szFont, C4FontLoader::C4FT_Caption, Config.General.RXFontSize, &Files)) return false;
|
||||
Game.SetInitProgress(18.5f);
|
||||
Game.SetInitProgress(34.5f);
|
||||
if (!::FontLoader.InitFont(FontTooltip, szFont, C4FontLoader::C4FT_Main, Config.General.RXFontSize, &Files, false)) return false;
|
||||
Game.SetInitProgress(19.0f);
|
||||
Game.SetInitProgress(35.0f);
|
||||
// assign def list as custom image source
|
||||
FontRegular.SetCustomImages(&::Definitions);
|
||||
return true;
|
||||
|
@ -198,8 +207,6 @@ void C4GraphicsResource::ClearFonts()
|
|||
|
||||
bool C4GraphicsResource::Init()
|
||||
{
|
||||
// (re)init main font
|
||||
if (!InitFonts()) return false;
|
||||
// Game palette - could perhaps be eliminated...
|
||||
int32_t idNewPalGrp;
|
||||
C4Group *pPalGrp=Files.FindEntry("C4.pal", NULL, &idNewPalGrp);
|
||||
|
@ -223,8 +230,33 @@ bool C4GraphicsResource::Init()
|
|||
idPalGrp = idNewPalGrp;
|
||||
}
|
||||
|
||||
Game.SetInitProgress(19.5f);
|
||||
ProgressStart = 20; ProgressIncrement = 0.4;
|
||||
Game.SetInitProgress(16.5f);
|
||||
ProgressStart = 17; ProgressIncrement = 0.4;
|
||||
|
||||
// load GUI files
|
||||
if (!LoadFile(fctProgressBar, "GUIProgress", Files)) return false;
|
||||
fctProgressBar.Set(fctProgressBar.Surface, 1,0, fctProgressBar.Wdt-2, fctProgressBar.Hgt);
|
||||
if (!LoadFile(sfcCaption, "GUICaption", Files, idSfcCaption)) return false;
|
||||
barCaption.SetHorizontal(sfcCaption, sfcCaption.Hgt, 32);
|
||||
if (!LoadFile(sfcButton, "GUIButton", Files, idSfcButton)) return false;
|
||||
barButton.SetHorizontal(sfcButton);
|
||||
if (!LoadFile(sfcButtonD, "GUIButtonDown", Files, idSfcButtonD)) return false;
|
||||
barButtonD.SetHorizontal(sfcButtonD);
|
||||
if (!LoadFile(fctButtonHighlight, "GUIButtonHighlight", Files)) return false;
|
||||
if (!LoadFile(fctIcons, "GUIIcons", Files)) return false;
|
||||
fctIcons.Set(fctIcons.Surface,0,0,C4GUI_IconWdt,C4GUI_IconHgt);
|
||||
if (!LoadFile(fctIconsEx, "GUIIcons2", Files)) return false;
|
||||
fctIconsEx.Set(fctIconsEx.Surface,0,0,C4GUI_IconExWdt,C4GUI_IconExHgt);
|
||||
if (!LoadFile(sfcScroll, "GUIScroll", Files, idSfcScroll)) return false;
|
||||
sfctScroll.Set(C4Facet(&sfcScroll,0,0,32,32));
|
||||
if (!LoadFile(sfcContext, "GUIContext", Files, idSfcContext)) return false;
|
||||
fctContext.Set(&sfcContext,0,0,16,16);
|
||||
if (!LoadFile(fctSubmenu, "GUISubmenu", Files)) return false;
|
||||
if (!LoadFile(fctCheckbox, "GUICheckbox", Files)) return false;
|
||||
fctCheckbox.Set(fctCheckbox.Surface, 0,0,fctCheckbox.Hgt,fctCheckbox.Hgt);
|
||||
if (!LoadFile(fctBigArrows, "GUIBigArrows", Files)) return false;
|
||||
fctBigArrows.Set(fctBigArrows.Surface, 0,0, fctBigArrows.Wdt/4, fctBigArrows.Hgt);
|
||||
|
||||
// Control
|
||||
if (!LoadFile(sfcControl, "Control", Files, idSfcControl)) return false;
|
||||
fctKeyboard.Set(&sfcControl,0,0,80,36);
|
||||
|
@ -292,10 +324,8 @@ bool C4GraphicsResource::Init()
|
|||
int32_t Q; fctRank.GetPhaseNum(iNumRanks, Q);
|
||||
if (!iNumRanks) iNumRanks=1;
|
||||
|
||||
// load GUI files
|
||||
C4GUI::Resource *pRes = C4GUI::GetRes();
|
||||
if (!pRes) pRes = new C4GUI::Resource(FontCaption, FontTitle, FontRegular, FontTiny, FontTooltip);
|
||||
if (!pRes->Load(Files)) { delete pRes; return false; }
|
||||
// (re)init main font
|
||||
if (!InitFonts()) return false;
|
||||
|
||||
// CloseFiles() must not be called now:
|
||||
// The sky still needs to be loaded from the global graphics
|
||||
|
@ -454,6 +484,26 @@ bool C4GraphicsResource::LoadFile(C4Surface& sfc, const char *szName, C4GroupSet
|
|||
return true;
|
||||
}
|
||||
|
||||
CStdFont &C4GraphicsResource::GetFontByHeight(int32_t iHgt, float *pfZoom)
|
||||
{
|
||||
// get optimal font for given control size
|
||||
CStdFont *pUseFont;
|
||||
if (iHgt <= MiniFont.GetLineHeight()) pUseFont = &MiniFont;
|
||||
else if (iHgt <= TextFont.GetLineHeight()) pUseFont = &TextFont;
|
||||
else if (iHgt <= CaptionFont.GetLineHeight()) pUseFont = &CaptionFont;
|
||||
else pUseFont = &TitleFont;
|
||||
// determine zoom
|
||||
if (pfZoom)
|
||||
{
|
||||
int32_t iLineHgt = pUseFont->GetLineHeight();
|
||||
if (iLineHgt)
|
||||
*pfZoom = (float) iHgt / (float) iLineHgt;
|
||||
else
|
||||
*pfZoom = 1.0f; // error
|
||||
}
|
||||
return *pUseFont;
|
||||
}
|
||||
|
||||
int32_t C4GraphicsResource::GetColorIndex(int32_t iColor, bool fLast)
|
||||
{
|
||||
// Returns first or last (hardcoded) index into the clonk color palette.
|
||||
|
@ -490,6 +540,7 @@ int32_t C4GraphicsResource::GetColorIndex(int32_t iColor, bool fLast)
|
|||
|
||||
bool C4GraphicsResource::ReloadResolutionDependantFiles()
|
||||
{
|
||||
if(!fInitialized) return false;
|
||||
// reload any files that depend on the current resolution
|
||||
// reloads the cursor
|
||||
fctMouseCursor.idSourceGroup = 0;
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
#include <C4GroupSet.h>
|
||||
#include <C4Surface.h>
|
||||
#include <C4FacetEx.h>
|
||||
|
||||
namespace C4GUI { class Resource; }
|
||||
#include <C4Gui.h>
|
||||
|
||||
class C4GraphicsResource
|
||||
{
|
||||
|
@ -39,6 +38,9 @@ public:
|
|||
~C4GraphicsResource();
|
||||
protected:
|
||||
C4Surface sfcControl;
|
||||
C4Surface sfcCaption, sfcButton, sfcButtonD;
|
||||
C4Surface sfcScroll, sfcContext;
|
||||
int32_t idSfcCaption, idSfcButton, idSfcButtonD, idSfcScroll, idSfcContext;
|
||||
int32_t idSfcControl; // id of source group of control surface
|
||||
int32_t idPalGrp; // if of source group of pal file
|
||||
// ID of last group in main group set that was already registered into the Files-set
|
||||
|
@ -87,7 +89,22 @@ public:
|
|||
C4FacetID fctPlayerClr; // ColorByOwner-surface of fctPlayer
|
||||
C4FacetID fctPlayerGray; // grayed out version of fctPlayer
|
||||
|
||||
C4GUI::DynBarFacet barCaption, barButton, barButtonD;
|
||||
C4FacetID fctButtonHighlight;
|
||||
C4FacetID fctIcons, fctIconsEx;
|
||||
C4FacetID fctSubmenu;
|
||||
C4FacetID fctCheckbox;
|
||||
C4FacetID fctBigArrows;
|
||||
C4FacetID fctProgressBar;
|
||||
C4GUI::ScrollBarFacets sfctScroll;
|
||||
C4Facet fctContext;
|
||||
|
||||
// fonts
|
||||
CStdFont &CaptionFont; // small, bold font
|
||||
CStdFont &TitleFont; // large, bold font
|
||||
CStdFont &TextFont; // font for normal text
|
||||
CStdFont &MiniFont; // tiny font (logfont)
|
||||
CStdFont &TooltipFont; // same as BookFont
|
||||
CStdFont FontTiny; // used for logs
|
||||
CStdFont FontRegular; // normal font - just refed from graphics system
|
||||
CStdFont FontCaption; // used for title bars
|
||||
|
@ -95,6 +112,7 @@ public:
|
|||
CStdFont FontTooltip; // normal, non-shadowed font (same as BookFont)
|
||||
public:
|
||||
int32_t GetColorIndex(int32_t iColor, bool fLast=false);
|
||||
CStdFont &GetFontByHeight(int32_t iHgt, float *pfZoom=NULL); // get optimal font for given control size
|
||||
void Default();
|
||||
void Clear();
|
||||
bool InitFonts();
|
||||
|
@ -116,7 +134,6 @@ protected:
|
|||
bool FindLoadRes(C4Group *pSecondFile, const char *szName);
|
||||
bool LoadCursorGfx();
|
||||
|
||||
friend class C4GUI::Resource;
|
||||
friend class C4StartupGraphics;
|
||||
};
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <C4Game.h>
|
||||
#include <C4RoundResults.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
// *** C4LeagueRequestHead
|
||||
|
||||
|
@ -520,8 +521,8 @@ C4LeagueSignupDialog::C4LeagueSignupDialog(const char *szPlayerName, const char
|
|||
sMsg.Format(LoadResStr("IDS_MSG_LEAGUE_REGISTRATION"), szPlayerName);
|
||||
else
|
||||
sMsg.Format(LoadResStr("IDS_MSG_PASSWORDFORPLAYER"), szPlayerName);
|
||||
int32_t iLabelHgt = C4GUI::GetRes()->TextFont.BreakMessage(sMsg.getData(), caMain.GetInnerWidth(), &sMsgBroken, true);
|
||||
C4GUI::Label *pLblMessage = new C4GUI::Label(sMsgBroken.getData(), caMain.GetFromTop(iLabelHgt), ALeft, C4GUI_MessageFontClr, &C4GUI::GetRes()->TextFont);
|
||||
int32_t iLabelHgt = ::GraphicsResource.TextFont.BreakMessage(sMsg.getData(), caMain.GetInnerWidth(), &sMsgBroken, true);
|
||||
C4GUI::Label *pLblMessage = new C4GUI::Label(sMsgBroken.getData(), caMain.GetFromTop(iLabelHgt), ALeft, C4GUI_MessageFontClr, &::GraphicsResource.TextFont);
|
||||
AddElement(pLblMessage);
|
||||
// registering and no account pref available
|
||||
if (fRegister && (!szAccountPref || !szAccountPref[0]))
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <C4Game.h>
|
||||
#include <C4PlayerList.h>
|
||||
#include <C4GameControl.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
#ifndef HAVE_WINSOCK
|
||||
#include <sys/socket.h>
|
||||
|
@ -124,7 +125,7 @@ C4Network2ClientListBox::ClientListItem::ClientListItem(class C4Network2ClientLi
|
|||
// get associated client
|
||||
const C4Client *pClient = GetClient();
|
||||
// get size
|
||||
int iIconSize = C4GUI::GetRes()->TextFont.GetLineHeight();
|
||||
int iIconSize = ::GraphicsResource.TextFont.GetLineHeight();
|
||||
if (pForDlg->IsStartup()) iIconSize *= 2;
|
||||
int iWidth = pForDlg->GetItemWidth();
|
||||
int iVerticalIndent = 2;
|
||||
|
@ -279,7 +280,7 @@ C4Network2ClientListBox::ConnectionListItem::ConnectionListItem(class C4Network2
|
|||
: ListItem(pForDlg, iClientID), iConnID(iConnectionID), pDesc(NULL), pPing(NULL), pReconnectBtn(NULL), pDisconnectBtn(NULL)
|
||||
{
|
||||
// get size
|
||||
CStdFont &rUseFont = C4GUI::GetRes()->TextFont;
|
||||
CStdFont &rUseFont = ::GraphicsResource.TextFont;
|
||||
int iIconSize = rUseFont.GetLineHeight();
|
||||
int iWidth = pForDlg->GetItemWidth();
|
||||
int iVerticalIndent = 2;
|
||||
|
@ -460,7 +461,7 @@ C4Network2ClientListDlg::C4Network2ClientListDlg()
|
|||
: Dialog(::pGUI->GetPreferredDlgRect().Wdt*3/4, ::pGUI->GetPreferredDlgRect().Hgt*3/4, LoadResStr("IDS_NET_CAPTION"), false)
|
||||
{
|
||||
// component layout
|
||||
CStdFont *pUseFont = &C4GUI::GetRes()->TextFont;
|
||||
CStdFont *pUseFont = &::GraphicsResource.TextFont;
|
||||
C4GUI::ComponentAligner caAll(GetContainedClientRect(), 0,0);
|
||||
C4Rect rcStatus = caAll.GetFromBottom(pUseFont->GetLineHeight());
|
||||
// create game options; max 1/2 of dialog height
|
||||
|
@ -800,7 +801,7 @@ void C4Chart::DrawElement(C4TargetFacet &cgo)
|
|||
StdStrBuf sbuf;
|
||||
pDisplayGraph->Update(); // update averages, etc.
|
||||
// calc metrics
|
||||
CStdFont &rFont = C4GUI::GetRes()->MiniFont;
|
||||
CStdFont &rFont = ::GraphicsResource.MiniFont;
|
||||
int YAxisWdt = 5,
|
||||
XAxisHgt = 15;
|
||||
const int AxisArrowLen = 6,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "C4PlayerInfo.h"
|
||||
#include "C4Network2Players.h"
|
||||
#include "C4Network2Dialogs.h"
|
||||
#include <C4GraphicsResource.h>
|
||||
|
||||
// ----------- C4Network2ResDlg::ListItem ----------------------------------------------------------------
|
||||
|
||||
|
@ -37,7 +38,7 @@ C4Network2ResDlg::ListItem::ListItem(C4Network2ResDlg *pForResDlg, const C4Netwo
|
|||
iResID = pByRes->getResID();
|
||||
const char *szFilename = GetFilename(pByRes->getCore().getFileName());
|
||||
// get size
|
||||
int iIconSize = C4GUI::GetRes()->TextFont.GetLineHeight();
|
||||
int iIconSize = ::GraphicsResource.TextFont.GetLineHeight();
|
||||
int iWidth = pForResDlg->GetItemWidth();
|
||||
int iVerticalIndent = 2;
|
||||
SetBounds(C4Rect(0, 0, iWidth, iIconSize+2*iVerticalIndent));
|
||||
|
|
Loading…
Reference in New Issue