Skip to content

Commit 9213854

Browse files
committed
Fix #2163: Remove all flags and use The Language Icon
Thank you to The Language Icon for making their icon available for people to use. Attribution has been added into our credits menu as described by The Language Icon project website. Attribute to: A’ Design Award & Competition, Onur Müştak Çobanlı and Farhat Datta with URL http://www.languageicon.org for non-internet usage. Fixes #2162 Fixes #2155 Fixes #2163
1 parent 97d270d commit 9213854

File tree

47 files changed

+67
-63
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+67
-63
lines changed

Client/core/CCredits.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* FILE: core/CCredits.cpp
66
* PURPOSE: In-game credits window implementation
77
*
8-
* Multi Theft Auto is available from https://www.multitheftauto.com/
8+
* Multi Theft Auto is available from https://multitheftauto.com/
99
*
1010
*****************************************************************************/
1111

@@ -301,6 +301,7 @@ CCredits::CCredits()
301301
"SQLite (https://www.sqlite.org/)\n"
302302
"TeamCity by JetBrains (https://www.jetbrains.com/teamcity/)\n"
303303
"Teleport (https://goteleport.com/)\n"
304+
"The Language Icon by A’ Design Award & Competition, Onur Müştak Çobanlı and\nFarhat Datta (https://www.languageicon.org)\n"
304305
"tinygettext (https://github.com/tinygettext/tinygettext/)\n"
305306
"tinyxml (https://sourceforge.net/projects/tinyxml/)\n"
306307
"UnRAR (https://www.rarlab.com/)\n"
@@ -345,7 +346,7 @@ CCredits::CCredits()
345346
// Create the label
346347
m_pLabels[uiLabelIndex] = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(m_pWindow, strBuffer.c_str()));
347348
m_pLabels[uiLabelIndex]->SetPosition(CVector2D(0.022f, fStartPosition), true);
348-
m_pLabels[uiLabelIndex]->SetSize(CVector2D(532.0f, 1200.0f)); // relative 0.95, 6.0
349+
m_pLabels[uiLabelIndex]->SetSize(CVector2D(532.0f, 1500.0f)); // relative 0.95, 6.0
349350
m_pLabels[uiLabelIndex]->SetHorizontalAlign(CGUI_ALIGN_HORIZONTALCENTER);
350351
++uiLabelIndex;
351352

@@ -411,7 +412,7 @@ void CCredits::Update()
411412
float fCurrentTop = 1.0f - 0.0001f * static_cast<float>(clock() - m_clkStart);
412413

413414
// If we're too far down or up, make sure we restart next pulse
414-
if (fCurrentTop <= -11.0f || fCurrentTop >= 1.0f)
415+
if (fCurrentTop <= -12.3f || fCurrentTop >= 1.0f)
415416
{
416417
m_clkStart = clock();
417418
}

Client/core/CLanguageSelector.cpp

+59-55
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
3+
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: core/CLanguageSelector.cpp
66
*
7-
* Multi Theft Auto is available from http://www.multitheftauto.com/
7+
* Multi Theft Auto is available from https://multitheftauto.com/
88
*
99
*****************************************************************************/
1010

1111
#include "StdInc.h"
1212
#include "CLanguageSelector.h"
1313

14-
#define FLAG_SIZE_X 26
15-
#define FLAG_SIZE_Y 16
16-
#define FLAG_LABEL_GAP_X 10 // Gap between flag and label
17-
#define FLAG_ZOOM_SCALE 0.75f
18-
#define LABEL_SIZE_X 95
19-
#define LABEL_SIZE_Y 16
20-
#define LABEL_OFFSET_Y ((FLAG_SIZE_Y - LABEL_SIZE_Y) / 2)
14+
#define LANGUAGE_ICON_SIZE_X 20
15+
#define LANGUAGE_ICON_SIZE_Y 24
16+
#define LANGUAGE_ICON_LABEL_GAP_X 10 // Gap between language icon and label
2117

22-
// Flag 'n' label combo
23-
#define ITEM_SIZE_X 145
24-
#define ITEM_SIZE_Y 30
18+
#define LABEL_SIZE_X 165
19+
#define LABEL_SIZE_Y 16
20+
21+
#define LANGUAGE_ICON_LABEL_OFFSET_Y ((LANGUAGE_ICON_SIZE_Y - LABEL_SIZE_Y) / 2)
22+
23+
// Language icon and label combo
24+
#define ITEM_SIZE_X 165
25+
#define ITEM_SIZE_Y 24
2526

2627
// Current language button
27-
#define BUTTON_MARGIN_X 20
28-
#define BUTTON_MARGIN_Y 5
28+
#define BUTTON_MARGIN_X 20
29+
#define BUTTON_MARGIN_Y 5
2930

3031
// All languages list
31-
#define LIST_MARGIN_X 22
32-
#define LIST_MARGIN_Y 13
33-
#define LIST_ITEM_SPACING_X 12
34-
#define LIST_ITEM_SPACING_Y 1
32+
#define LIST_MARGIN_X 20
33+
#define LIST_MARGIN_Y 18
34+
#define LIST_ITEM_SPACING_X 10
35+
#define LIST_ITEM_SPACING_Y 1
3536

3637
///////////////////////////////////////////////////////////////
3738
//
@@ -57,12 +58,12 @@ CLanguageSelector::~CLanguageSelector()
5758
SAFE_DELETE(m_pButtonWindow);
5859
SAFE_DELETE(m_pListWindow);
5960
SAFE_DELETE(m_ButtonItem.pContainerPane);
60-
SAFE_DELETE(m_ButtonItem.pFlag);
61+
SAFE_DELETE(m_ButtonItem.pIcon);
6162
SAFE_DELETE(m_ButtonItem.pLabel);
6263
for (CLangListItem& item : m_ListItems)
6364
{
6465
SAFE_DELETE(item.pContainerPane);
65-
SAFE_DELETE(item.pFlag);
66+
SAFE_DELETE(item.pIcon);
6667
SAFE_DELETE(item.pLabel);
6768
}
6869
}
@@ -92,7 +93,40 @@ void CLanguageSelector::CreateGUI(CGUIElement* pMainMenuCanvas)
9293
m_pButtonWindow->SetVisible(true);
9394

9495
CVector2D vecItemPosition(BUTTON_MARGIN_X, BUTTON_MARGIN_Y);
95-
m_ButtonItem = CreateGUILangItem(m_pButtonWindow, vecItemPosition);
96+
97+
CVector2D vecPaneSize(ITEM_SIZE_X, ITEM_SIZE_Y);
98+
CVector2D vecIconPos = vecItemPosition + CVector2D(LANGUAGE_ICON_SIZE_X / 2, (vecPaneSize.fY - LANGUAGE_ICON_SIZE_Y) / 2);
99+
CVector2D vecLabelPos = vecIconPos + CVector2D(LANGUAGE_ICON_SIZE_X + LANGUAGE_ICON_LABEL_GAP_X, LANGUAGE_ICON_LABEL_OFFSET_Y);
100+
101+
CGUIScrollPane* pContainerPane = reinterpret_cast<CGUIScrollPane*>(g_pCore->GetGUI()->CreateScrollPane(m_pButtonWindow));
102+
pContainerPane->SetProperty("ContentPaneAutoSized", "False");
103+
pContainerPane->SetPosition(vecItemPosition);
104+
pContainerPane->SetSize(vecPaneSize);
105+
pContainerPane->SetZOrderingEnabled(false);
106+
pContainerPane->SetAlwaysOnTop(true);
107+
pContainerPane->SetVisible(true);
108+
109+
CGUIStaticImage* pIcon = reinterpret_cast<CGUIStaticImage*>(g_pCore->GetGUI()->CreateStaticImage(m_pButtonWindow));
110+
pIcon->SetPosition(vecIconPos);
111+
pIcon->SetSize(CVector2D(LANGUAGE_ICON_SIZE_X, LANGUAGE_ICON_SIZE_Y));
112+
pIcon->SetZOrderingEnabled(false);
113+
pIcon->LoadFromFile(CalcMTASAPath("MTA\\cgui\\images\\the_language_icon.png"));
114+
115+
CGUILabel* pLabel = reinterpret_cast<CGUILabel*>(g_pCore->GetGUI()->CreateLabel(m_pButtonWindow));
116+
pLabel->SetPosition(vecLabelPos);
117+
pLabel->SetSize(CVector2D(LABEL_SIZE_X, LABEL_SIZE_Y));
118+
pLabel->SetZOrderingEnabled(false);
119+
pLabel->SetText(g_pLocalization->GetLanguageNativeName());
120+
121+
CLangListItem m_ButtonItem;
122+
m_ButtonItem.strLocale = "";
123+
m_ButtonItem.pContainerPane = pContainerPane;
124+
m_ButtonItem.pIcon = pIcon;
125+
m_ButtonItem.vecIconInitialPos = pIcon->GetPosition();
126+
m_ButtonItem.vecIconInitialSize = pIcon->GetSize();
127+
m_ButtonItem.pLabel = pLabel;
128+
m_ButtonItem.vecLabelInitialPos = pLabel->GetPosition();
129+
m_ButtonItem.vecLabelInitialSize = pLabel->GetSize();
96130
m_ButtonItem.pContainerPane->SetMouseButtonDownHandler(GUI_CALLBACK(&CLanguageSelector::OnButtonClick, this));
97131
m_ButtonItem.pContainerPane->SetMouseEnterHandler(GUI_CALLBACK(&CLanguageSelector::OnButtonEnter, this));
98132
m_ButtonItem.pContainerPane->SetMouseLeaveHandler(GUI_CALLBACK(&CLanguageSelector::OnButtonLeave, this));
@@ -151,15 +185,14 @@ void CLanguageSelector::CreateGUI(CGUIElement* pMainMenuCanvas)
151185
//
152186
// CLanguageSelector::CreateGUILangItem
153187
//
154-
// Create GUI items for one flag with language name.
188+
// Create GUI items for a language.
155189
// ContainerPane is used to handle mouse interaction
156190
//
157191
///////////////////////////////////////////////////////////////
158192
CLangListItem CLanguageSelector::CreateGUILangItem(CGUIElement* pGUIParent, const CVector2D& vecPanePosition, const SString& strLocale)
159193
{
160194
CVector2D vecPaneSize(ITEM_SIZE_X, ITEM_SIZE_Y);
161-
CVector2D vecFlagPos = vecPanePosition + CVector2D((FLAG_SIZE_X * FLAG_ZOOM_SCALE) / 2, (vecPaneSize.fY - FLAG_SIZE_Y) / 2);
162-
CVector2D vecLabelPos = vecFlagPos + CVector2D(FLAG_SIZE_X + FLAG_LABEL_GAP_X, LABEL_OFFSET_Y);
195+
CVector2D vecLabelPos = vecPanePosition;
163196

164197
CGUIScrollPane* pContainerPane = reinterpret_cast<CGUIScrollPane*>(g_pCore->GetGUI()->CreateScrollPane(pGUIParent));
165198
pContainerPane->SetProperty("ContentPaneAutoSized", "False");
@@ -169,12 +202,6 @@ CLangListItem CLanguageSelector::CreateGUILangItem(CGUIElement* pGUIParent, cons
169202
pContainerPane->SetAlwaysOnTop(true);
170203
pContainerPane->SetVisible(true);
171204

172-
CGUIStaticImage* pFlag = reinterpret_cast<CGUIStaticImage*>(g_pCore->GetGUI()->CreateStaticImage(pGUIParent));
173-
pFlag->SetPosition(vecFlagPos);
174-
pFlag->SetSize(CVector2D(FLAG_SIZE_X, FLAG_SIZE_Y));
175-
pFlag->SetZOrderingEnabled(false);
176-
pFlag->LoadFromFile(GetFlagFilename(strLocale));
177-
178205
CGUILabel* pLabel = reinterpret_cast<CGUILabel*>(g_pCore->GetGUI()->CreateLabel(pGUIParent));
179206
pLabel->SetPosition(vecLabelPos);
180207
pLabel->SetSize(CVector2D(LABEL_SIZE_X, LABEL_SIZE_Y));
@@ -184,9 +211,6 @@ CLangListItem CLanguageSelector::CreateGUILangItem(CGUIElement* pGUIParent, cons
184211
CLangListItem item;
185212
item.strLocale = strLocale;
186213
item.pContainerPane = pContainerPane;
187-
item.pFlag = pFlag;
188-
item.vecFlagInitialPos = pFlag->GetPosition();
189-
item.vecFlagInitialSize = pFlag->GetSize();
190214
item.pLabel = pLabel;
191215
item.vecLabelInitialPos = pLabel->GetPosition();
192216
item.vecLabelInitialSize = pLabel->GetSize();
@@ -231,16 +255,10 @@ void CLanguageSelector::DoPulse()
231255
// Update animation position
232256
float fMaxAmount = fDeltaSeconds * 16.0f;
233257
pItem->fFocusEffectPos += Clamp(-fMaxAmount, pItem->fFocusEffectTarget - pItem->fFocusEffectPos, fMaxAmount);
234-
float fFlagScale = 1 + pItem->fFocusEffectPos * FLAG_ZOOM_SCALE;
235258

236-
// Scale flag
237-
CVector2D vecFlagZoomPos = pItem->vecFlagInitialPos - (pItem->vecFlagInitialSize * pItem->fFocusEffectPos * FLAG_ZOOM_SCALE * 0.5f);
238-
pItem->pFlag->SetPosition(vecFlagZoomPos);
239-
pItem->pFlag->SetSize(CVector2D(FLAG_SIZE_X * fFlagScale, FLAG_SIZE_Y * fFlagScale));
240-
241-
// Move label to accommodate scaled flag
259+
// Move label
242260
CVector2D vecLabelZoomPos =
243-
pItem->vecLabelInitialPos + CVector2D(pItem->vecFlagInitialSize.fX * pItem->fFocusEffectPos * FLAG_ZOOM_SCALE * 0.5f, 0);
261+
pItem->vecLabelInitialPos + CVector2D(pItem->vecLabelInitialSize.fX * pItem->fFocusEffectPos * 0.05f, 0);
244262
pItem->pLabel->SetPosition(vecLabelZoomPos);
245263
}
246264
}
@@ -264,20 +282,6 @@ void CLanguageSelector::SetLanguageListVisible(bool bVisible)
264282
m_pListWindow->SetVisible(bVisible);
265283
}
266284

267-
///////////////////////////////////////////////////////////////
268-
//
269-
// CLanguageSelector::GetFlagFilename
270-
//
271-
// Get image filename for supplied locale, or the current locale
272-
//
273-
///////////////////////////////////////////////////////////////
274-
SString CLanguageSelector::GetFlagFilename(SString strLocale)
275-
{
276-
if (strLocale.empty())
277-
strLocale = CVARS_GET_VALUE<SString>("locale");
278-
return CalcMTASAPath(SString(MTA_LOCALE_DIR "%s\\flag.png", *strLocale));
279-
}
280-
281285
///////////////////////////////////////////////////////////////
282286
//
283287
// CLanguageSelector::GetListItemByIndex

Client/core/CLanguageSelector.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
struct CLangListItem
1212
{
13-
CLangListItem() : fFocusEffectPos(0), fFocusEffectTarget(0), pContainerPane(nullptr), pFlag(nullptr), pLabel(nullptr) {}
13+
CLangListItem() : fFocusEffectPos(0), fFocusEffectTarget(0), pContainerPane(nullptr), pIcon(nullptr), pLabel(nullptr) {}
1414
float fFocusEffectPos;
1515
float fFocusEffectTarget;
1616
SString strLocale;
1717
CGUIElement* pContainerPane;
18-
CGUIStaticImage* pFlag;
19-
CVector2D vecFlagInitialPos;
20-
CVector2D vecFlagInitialSize;
18+
CGUIStaticImage* pIcon;
19+
CVector2D vecIconInitialPos;
20+
CVector2D vecIconInitialSize;
2121
CGUILabel* pLabel;
2222
CVector2D vecLabelInitialPos;
2323
CVector2D vecLabelInitialSize;
@@ -35,7 +35,6 @@ class CLanguageSelector
3535
void CreateGUI(CGUIElement* pMainMenuCanvas);
3636
CLangListItem CreateGUILangItem(CGUIElement* pGUIParent, const CVector2D& vecPanePosition, const SString& strLocale = "");
3737
void SetLanguageListVisible(bool bVisible);
38-
SString GetFlagFilename(SString strLocale = "");
3938
CLangListItem* GetListItemByIndex(uint uiIndex);
4039
bool OnButtonEnter(CGUIElement* pElement);
4140
bool OnButtonLeave(CGUIElement* pElement);
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)