Skip to content

Commit

Permalink
Merge branch 'master' into patch-5
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Moris authored Mar 6, 2025
2 parents 8ebc155 + a744cd1 commit f9a66e8
Show file tree
Hide file tree
Showing 134 changed files with 33,837 additions and 11,218 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/run-generate-translators.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Update crowdin-translators.json"

on:
workflow_dispatch:
delete:
branches:
- l10n/master

jobs:
generate_translators:
if: github.event.repository.fork == false
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: master
token: ${{ secrets.POT_CI_PAT }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: latest
cache: 'npm'
cache-dependency-path: ./utils/localization/generate-translators/package-lock.json

- name: Install dependencies
working-directory: ./utils/localization/generate-translators
run: npm clean-install

- name: Generate translators
working-directory: ./utils/localization/generate-translators
env:
CROWDIN_TOKEN: "${{ secrets.CROWDIN_TOKEN }}"
CROWDIN_ORGANIZATION: "multitheftauto"
CROWDIN_PROJECT_ID: "13" # Multi Theft Auto
CROWDIN_IGNORE_USER_ID: "2" # multitheftautoqa
run: npm run ci

- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add ./utils/localization/generate-translators/crowdin-translators.json
if ! git diff-index --quiet HEAD; then
git commit -m "Update crowdin-translators.json" -m "[ci skip]"
git push
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,4 @@ utils/DXFiles/
!*.dll
!*.exe
utils/vswhere.exe
*.generated.h
78 changes: 29 additions & 49 deletions Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,71 +1233,51 @@ void CCore::DoPostFramePulse()
m_pGUI->SelectInputHandlers(INPUT_CORE);
}

if (m_pGame->GetSystemState() == 5) // GS_INIT_ONCE
{
WatchDogCompletedSection("L2"); // gta_sa.set seems ok
WatchDogCompletedSection("L3"); // No hang on startup
}

// This is the first frame in the menu?
if (m_pGame->GetSystemState() == 7) // GS_FRONTEND
{
// Wait 250 frames more than the time it took to get status 7 (fade-out time)
static short WaitForMenu = 0;
if (m_bFirstFrame)
{
m_bFirstFrame = false;

// Do crash dump encryption while the credit screen is displayed
if (WaitForMenu == 0)
WatchDogCompletedSection("L2"); // gta_sa.set seems ok
WatchDogCompletedSection("L3"); // No hang on startup
HandleCrashDumpEncryption();

// Cope with early finish
if (m_pGame->HasCreditScreenFadedOut())
WaitForMenu = 250;
// Disable vsync while it's all dark
m_pGame->DisableVSync();

if (WaitForMenu >= 250)
{
if (m_bFirstFrame)
// Parse the command line
// Does it begin with mtasa://?
if (m_szCommandLineArgs && strnicmp(m_szCommandLineArgs, "mtasa://", 8) == 0)
{
m_bFirstFrame = false;

// Disable vsync while it's all dark
m_pGame->DisableVSync();

// Parse the command line
// Does it begin with mtasa://?
if (m_szCommandLineArgs && strnicmp(m_szCommandLineArgs, "mtasa://", 8) == 0)
SString strArguments = GetConnectCommandFromURI(m_szCommandLineArgs);
// Run the connect command
if (strArguments.length() > 0 && !m_pCommands->Execute(strArguments))
{
SString strArguments = GetConnectCommandFromURI(m_szCommandLineArgs);
// Run the connect command
if (strArguments.length() > 0 && !m_pCommands->Execute(strArguments))
{
ShowMessageBox(_("Error") + _E("CC41"), _("Error executing URL"), MB_BUTTON_OK | MB_ICON_ERROR);
}
ShowMessageBox(_("Error") + _E("CC41"), _("Error executing URL"), MB_BUTTON_OK | MB_ICON_ERROR);
}
else
}
else
{
// We want to load a mod?
const char* szOptionValue;
if (szOptionValue = GetCommandLineOption("l"))
{
// We want to load a mod?
const char* szOptionValue;
if (szOptionValue = GetCommandLineOption("l"))
{
// Try to load the mod
if (!m_pModManager->Load(szOptionValue, m_szCommandLineArgs))
{
SString strTemp(_("Error running mod specified in command line ('%s')"), szOptionValue);
ShowMessageBox(_("Error") + _E("CC42"), strTemp, MB_BUTTON_OK | MB_ICON_ERROR); // Command line Mod load failed
}
}
// We want to connect to a server?
else if (szOptionValue = GetCommandLineOption("c"))
// Try to load the mod
if (!m_pModManager->Load(szOptionValue, m_szCommandLineArgs))
{
CCommandFuncs::Connect(szOptionValue);
SString strTemp(_("Error running mod specified in command line ('%s')"), szOptionValue);
ShowMessageBox(_("Error") + _E("CC42"), strTemp, MB_BUTTON_OK | MB_ICON_ERROR); // Command line Mod load failed
}
}
// We want to connect to a server?
else if (szOptionValue = GetCommandLineOption("c"))
{
CCommandFuncs::Connect(szOptionValue);
}
}
}
else
{
WaitForMenu++;
}

if (m_bWaitToSetNick && GetLocalGUI()->GetMainMenu()->IsVisible() && !GetLocalGUI()->GetMainMenu()->IsFading())
{
Expand Down
24 changes: 2 additions & 22 deletions Client/core/CGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ void CLocalGUI::CreateWindows(bool bGameIsAlreadyLoaded)
m_pLabelVersionTag->SetTextColor(255, 255, 255);
m_pLabelVersionTag->SetZOrderingEnabled(false);
m_pLabelVersionTag->MoveToBack();
m_pLabelVersionTag->SetVisible(false);
if (MTASA_VERSION_TYPE < VERSION_TYPE_RELEASE)
m_pLabelVersionTag->SetAlwaysOnTop(true);

// Create mainmenu
m_pMainMenu = new CMainMenu(pGUI);
Expand Down Expand Up @@ -286,27 +287,6 @@ void CLocalGUI::Draw()
// Update mainmenu stuff
m_pMainMenu->Update();

// Make sure our version labels are always visible
static short WaitForMenu = 0;

// Cope with early finish
if (pGame->HasCreditScreenFadedOut())
WaitForMenu = 250;

if (SystemState == 7 || SystemState == 9)
{
if (WaitForMenu < 250)
{
WaitForMenu++;
}
else
{
m_pLabelVersionTag->SetVisible(true);
if (MTASA_VERSION_TYPE < VERSION_TYPE_RELEASE)
m_pLabelVersionTag->SetAlwaysOnTop(true);
}
}

// If we're ingame, make sure the chatbox is drawn
bool bChatVisible = (SystemState == 9 /* GS_INGAME */ && m_pMainMenu->GetIsIngame() && m_bChatboxVisible && !CCore::GetSingleton().IsOfflineMod());
if (m_pChat->IsVisible() != bChatVisible)
Expand Down
19 changes: 19 additions & 0 deletions Client/core/CLocalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
// TRANSLATORS: Replace with your language native name
#define NATIVE_LANGUAGE_NAME _td("English")

struct NativeLanguageName
{
std::string locale;
std::string name;
} g_nativeLanguageNames[] = {
#include "languages.generated.h"
};

CLocalization::CLocalization(const SString& strLocale, const SString& strLocalePath)
{
// Set log callbacks so we can record problems
Expand Down Expand Up @@ -95,12 +103,23 @@ CLanguage* CLocalization::GetLanguage(SString strLocale)
SString CLocalization::GetLanguageNativeName(SString strLocale)
{
strLocale = ValidateLocale(strLocale);

// Try to find the native language name in our sorted compile-time array first, using binary search.
auto begin = g_nativeLanguageNames;
auto end = g_nativeLanguageNames + _countof(g_nativeLanguageNames);
auto iter = std::lower_bound(begin, end, strLocale, [](const NativeLanguageName& a, const std::string& b) { return a.locale < b; });

if (iter != end && iter->locale == strLocale)
return iter->name;

// If not found, we fall back to the loading the language file and using the name from there.
SString strNativeName = GetLanguage(strLocale)->Translate(NATIVE_LANGUAGE_NAME);
if (strNativeName == "English" && strLocale != "en_US")
{
// If native name not available, use English version
strNativeName = GetLanguage(strLocale)->GetName();
}

return strNativeName;
}

Expand Down
35 changes: 4 additions & 31 deletions Client/core/CMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#define CORE_MTA_FILLER "cgui\\images\\mta_filler.png"
#define CORE_MTA_VERSION "cgui\\images\\version.png"

static int WaitForMenu = 0;
static const SColor headlineColors[] = {SColorRGBA(233, 234, 106, 255), SColorRGBA(233 / 6 * 4, 234 / 6 * 4, 106 / 6 * 4, 255),
SColorRGBA(233 / 7 * 3, 234 / 7 * 3, 106 / 7 * 3, 255)};

Expand All @@ -70,11 +69,10 @@ CMainMenu::CMainMenu(CGUI* pManager)

// Initialize
m_pManager = pManager;
m_bIsVisible = false;
m_bIsVisible = true;
m_bIsFullyVisible = false;
m_bIsIngame = true;
// m_bIsInSubWindow = false;
m_bStarted = false;
m_fFader = 0;
m_ucFade = FADE_INVISIBLE;
m_bCursorAlphaReset = false;
Expand Down Expand Up @@ -656,47 +654,22 @@ void CMainMenu::Update()
// Force the mainmenu on if we're at GTA's mainmenu or not ingame
if ((SystemState == 7 || SystemState == 9) && !m_bIsIngame)
{
// Cope with early finish
if (pGame->HasCreditScreenFadedOut())
WaitForMenu = std::max(WaitForMenu, 250);

// Fade up
if (WaitForMenu >= 250)
if (!m_bStarted)
{
m_bIsVisible = true;
m_bStarted = true;
}

// Create headlines while the screen is still black
if (WaitForMenu == 250)
m_pNewsBrowser->CreateHeadlines();

// Start updater after fade up is complete
if (WaitForMenu == 275)
GetVersionUpdater()->EnableChecking(true);

#if _WIN32_WINNT <= _WIN32_WINNT_WINXP
if (WaitForMenu == 275)
{
CCore::GetSingletonPtr()->ShowErrorMessageBox("", XP_VISTA_WARNING, "au-revoir-xp-vista");
}
#endif

if (WaitForMenu == 299)
{
if (!g_pCore->GetCVars()->GetValue("discord_rpc_share_data_firsttime", false)
&& g_pCore->GetCVars()->GetValue("allow_discord_rpc", false)
&& !g_pCore->GetCVars()->GetValue("discord_rpc_share_data", false))
if (!g_pCore->GetCVars()->GetValue("discord_rpc_share_data_firsttime", false) && g_pCore->GetCVars()->GetValue("allow_discord_rpc", false) &&
!g_pCore->GetCVars()->GetValue("discord_rpc_share_data", false))
{
m_Settings.ShowRichPresenceShareDataQuestionBox();
CVARS_SET("discord_rpc_share_data_firsttime", true);
}
else
CVARS_SET("discord_rpc_share_data_firsttime", true);
}

if (WaitForMenu < 300)
WaitForMenu++;
}

// If we're visible
Expand Down
2 changes: 1 addition & 1 deletion Client/core/CMainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class CMainMenu
int m_menuBY;

CGraphics* m_pGraphics;
bool m_bStarted;
bool m_bStarted{false};
CVector2D m_ScreenSize;

// Fade variables
Expand Down
7 changes: 7 additions & 0 deletions Client/core/ServerBrowser/CServerCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ bool CServerCache::LoadServerCache()

MapSet(m_ServerCachedMap, key, info);
}

delete pNode;
delete m_pConfigFile;

return true;
}

Expand Down Expand Up @@ -302,6 +306,9 @@ void CServerCache::StaticSaveServerCache()
XMLAccess.SetSubNodeValue(CONFIG_NODE_SERVER_INT "11", dataSet);

m_pConfigFile->Write();

delete pNode;
delete m_pConfigFile;
}

///////////////////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions Client/core/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ project "Client Core"
"PNG_SETJMP_NOT_SUPPORTED"
}

prebuildcommands {
"%[%{!wks.location}/../utils/gen_language_list.exe] %[%{!wks.location}/../Shared/data/MTA San Andreas/MTA/locale] %[languages.generated.h]"
}

filter "architecture:not x86"
flags { "ExcludeFromBuild" }

Expand Down
8 changes: 0 additions & 8 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,14 +1041,6 @@ void CGameSA::SetupBrokenModels()
FixModelCol(3553, 3554);
}

// Well, has it?
bool CGameSA::HasCreditScreenFadedOut()
{
BYTE ucAlpha = *(BYTE*)0xBAB320; // CLoadingScreen::m_FadeAlpha
bool bCreditScreenFadedOut = (GetSystemState() >= 7) && (ucAlpha < 6);
return bCreditScreenFadedOut;
}

// Ensure replaced/restored textures for models in the GTA map are correct
void CGameSA::FlushPendingRestreamIPL()
{
Expand Down
2 changes: 0 additions & 2 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ class CGameSA : public CGame
void SuspendASyncLoading(bool bSuspend, uint uiAutoUnsuspendDelay = 0);
bool IsASyncLoadingEnabled(bool bIgnoreSuspend = false);

bool HasCreditScreenFadedOut();

void SetupSpecialCharacters();
void FixModelCol(uint iFixModel, uint iFromModel);
void SetupBrokenModels();
Expand Down
Loading

0 comments on commit f9a66e8

Please sign in to comment.