Skip to content

Commit

Permalink
Added Spanish and Galician translations by enfeitizador, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Nov 29, 2024
1 parent 89bbdb8 commit a2376eb
Show file tree
Hide file tree
Showing 14 changed files with 4,705 additions and 34 deletions.
Binary file added Content/Translations/es.mo
Binary file not shown.
2,314 changes: 2,314 additions & 0 deletions Content/Translations/es.po

Large diffs are not rendered by default.

Binary file added Content/Translations/gl.mo
Binary file not shown.
2,313 changes: 2,313 additions & 0 deletions Content/Translations/gl.po

Large diffs are not rendered by default.

Binary file modified Content/Translations/pl.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions Content/Translations/pl.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 "
"|| n%100>14) ? 1 : 2);\n"
"X-Generator: Poedit 3.4.2\n"
"X-Generator: Poedit 3.5\n"
"X-Poedit-Basepath: ../..\n"
"X-Poedit-KeywordsList: _;_n:1,2;_x:1c,2;_nx:1c,2,3;_f;_fn:1,2\n"
"X-Poedit-SearchPath-0: Sources/Jazz2\n"
Expand Down Expand Up @@ -1875,7 +1875,7 @@ msgstr "Tabela wyników dla \f[c:#d0705d]gry podstawowej\f[/c]"
#: Sources/Jazz2/UI/Menu/HighscoresSection.cpp:115
#, c-format
msgid "Highscores for \f[c:#d0705d]%s\f[/c]"
msgstr "Tabela wyników dla \f[c:#d0705d]%s\f[/c]"
msgstr "Tabela wyników dla \f[c:#d0705d]%s\f[/c]"

#. TRANSLATORS: Header in Import Episodes section
#: Sources/Jazz2/UI/Menu/ImportSection.cpp:70
Expand Down
7 changes: 6 additions & 1 deletion Sources/Jazz2/UI/Menu/AboutSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ namespace Jazz2::UI::Menu

StringView langName = I18n::GetLanguageName(language);

std::int32_t lineLength = formatString(result, resultLength, "\f[c:#707070]%s\f[/c] \f[h:86](%s)\f[/h]\n", desc.data(), langName.data());
std::int32_t lineLength;
if (langName) {
lineLength = formatString(result, resultLength, "\f[c:#707070]%s\f[/c] \f[h:86](%s)\f[/h]\n", desc.data(), langName.data());
} else {
lineLength = formatString(result, resultLength, "\f[c:#707070]%s\f[/c]\n", desc.data());
}
result += lineLength;
resultLength -= lineLength;
}
Expand Down
46 changes: 36 additions & 10 deletions Sources/Jazz2/UI/Menu/HighscoresSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using namespace Jazz2::UI::Menu::Resources;
namespace Jazz2::UI::Menu
{
HighscoresSection::HighscoresSection()
: _selectedSeries(0), _textCursor(0), _carretAnim(0.0f), _waitForInput(false)
: _selectedSeries(0), _notValidPos(-1), _notValidSeries(-1), _textCursor(0), _carretAnim(0.0f), _waitForInput(false)
{
DeserializeFromFile();
FillDefaultsIfEmpty();
Expand All @@ -32,7 +32,6 @@ namespace Jazz2::UI::Menu
{
if (seriesIndex >= 0 && seriesIndex < (std::int32_t)SeriesName::Count) {
_selectedSeries = seriesIndex;
_waitForInput = true;

String name = TryGetDefaultName();
if (name.size() > MaxNameLength) {
Expand Down Expand Up @@ -81,6 +80,8 @@ namespace Jazz2::UI::Menu
}
}

EnsureVisibleSelected();

_carretAnim += timeMult;
}
}
Expand Down Expand Up @@ -238,14 +239,28 @@ namespace Jazz2::UI::Menu
}

std::int32_t pos = (std::int32_t)(&item - &_items[0] + 1);
if (pos <= MaxItems) {
bool isNotValid = (_notValidPos == pos && _notValidSeries == _selectedSeries);
if (_notValidPos > 0 && _notValidPos < pos && _notValidSeries == _selectedSeries) {
pos--;
}
if (!isNotValid && pos <= MaxItems) {
formatString(stringBuffer, sizeof(stringBuffer), "%i.", pos);
_root->DrawStringShadow(stringBuffer, charOffset, nameX - 16.0f, item.Y, IMenuContainer::MainLayer - 100, Alignment::Right,
(isSelected ? Colorf(0.48f, 0.48f, 0.48f, 0.5f) : Font::DefaultColor), 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f);
}

_root->DrawStringShadow(item.Item->PlayerName, charOffset, nameX, item.Y, IMenuContainer::MainLayer - 100, Alignment::Left,
isSelected && _waitForInput ? Colorf(0.62f, 0.44f, 0.34f, 0.5f) : (isSelected ? Colorf(0.48f, 0.48f, 0.48f, 0.5f) : Font::DefaultColor), 0.8f);
bool cheatsUsed = (item.Item->Flags & HighscoreFlags::CheatsUsed) == HighscoreFlags::CheatsUsed;

Colorf nameColor;
if (isSelected && _waitForInput) {
nameColor = Colorf(0.62f, 0.44f, 0.34f, 0.5f);
} else if (isSelected) {
nameColor = (cheatsUsed ? Colorf(0.6f, 0.43f, 0.43f, 0.5f) : Colorf(0.48f, 0.48f, 0.48f, 0.5f));
} else {
nameColor = (cheatsUsed ? Colorf(0.48f, 0.38f, 0.34f, 0.5f) : Font::DefaultColor);
}

_root->DrawStringShadow(item.Item->PlayerName, charOffset, nameX, item.Y, IMenuContainer::MainLayer - 100, Alignment::Left, nameColor, 0.8f);

if (item.Item->Lives <= 0) {
Vector2f nameSize = _root->MeasureString(item.Item->PlayerName, 0.8f);
Expand Down Expand Up @@ -510,6 +525,11 @@ namespace Jazz2::UI::Menu

void HighscoresSection::SerializeToFile()
{
if (_notValidPos >= 0) {
// Don't save list with invalid items
return;
}

auto configDir = PreferencesCache::GetDirectory();
auto s = fs::Open(fs::CombinePath(configDir, FileName), FileAccess::Write);
if (*s) {
Expand Down Expand Up @@ -563,15 +583,21 @@ namespace Jazz2::UI::Menu
auto* newItem = items.insert(nearestItem, std::move(item));
std::int32_t index = (std::int32_t)(newItem - &items[0]);

// Keep limited number of items
while (items.size() > MaxItems && newItem != &items.back()) {
items.pop_back();
if ((item.Flags & HighscoreFlags::CheatsUsed) == HighscoreFlags::CheatsUsed && PreferencesCache::OverwriteEpisodeEnd != EpisodeEndOverwriteMode::Always) {
_notValidPos = index + 1;
_notValidSeries = _selectedSeries;
} else {
// Keep limited number of items
while (items.size() > MaxItems && newItem != &items.back()) {
items.pop_back();
}

_textCursor = newItem->PlayerName.size();
_waitForInput = true;
}

RefreshList();

_selectedIndex = index;
_textCursor = newItem->PlayerName.size();
}

void HighscoresSection::RefreshList()
Expand Down
2 changes: 2 additions & 0 deletions Sources/Jazz2/UI/Menu/HighscoresSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ namespace Jazz2::UI::Menu

HighscoreSeries _series[(std::int32_t)SeriesName::Count];
std::int32_t _selectedSeries;
std::int32_t _notValidPos;
std::int32_t _notValidSeries;
std::size_t _textCursor;
float _carretAnim;
bool _waitForInput;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,11 +1294,11 @@ void GameEventHandler::RefreshCacheLevels()
}
#if defined(DEATH_DEBUG)
/*else if (extension == "j2s"_s) {
// Episode
// Translations
Compatibility::JJ2Strings strings;
strings.Open(item);
String fullPath = fs::CombinePath({ resolver.GetCachePath(), "Translations"_s, strings.Name + ".h"_s });
String fullPath = fs::CombinePath({ resolver.GetCachePath(), "ExtractedTranslations"_s, String(strings.Name + ".h"_s) });
fs::CreateDirectories(fs::GetDirectoryName(fullPath));
strings.Convert(fullPath, LevelTokenConversion);
}*/
Expand Down
2 changes: 1 addition & 1 deletion Sources/Shared/IO/AndroidAssetStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ namespace Death { namespace IO {

void AndroidAssetStream::Open(FileAccess mode)
{
FileAccess maskedMode = mode & ~FileAccess::Exclusive;
FileAccess maskedMode = mode & FileAccess::ReadWrite;
if (maskedMode != FileAccess::Read) {
LOGE("Can't open file \"%s\" - wrong open mode", _path.data());
return;
Expand Down
5 changes: 4 additions & 1 deletion Sources/Shared/IO/FileAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ namespace Death { namespace IO {
*/
enum struct FileAccess {
None = 0,

Read = 0x01,
Write = 0x02,
ReadWrite = Read | Write,
Exclusive = 0x08

Exclusive = 0x10,
InheritHandle = 0x20
};

DEFINE_ENUM_OPERATORS(FileAccess);
Expand Down
41 changes: 24 additions & 17 deletions Sources/Shared/IO/FileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace Death { namespace IO {
FileStream::FileStream(Containers::String&& path, FileAccess mode, std::int32_t bufferSize)
: _path(std::move(path)), _size(Stream::Invalid), _filePos(0), _readPos(0), _readLength(0), _writePos(0), _bufferLength(bufferSize),
#if defined(DEATH_TARGET_WINDOWS)
_fileHandle(NULL)
_fileHandle(INVALID_HANDLE_VALUE)

#else
_fileDescriptor(-1)
Expand All @@ -64,10 +64,10 @@ namespace Death { namespace IO {
FlushWriteBuffer();

#if defined(DEATH_TARGET_WINDOWS)
if (_fileHandle != NULL) {
if (_fileHandle != INVALID_HANDLE_VALUE) {
if (::CloseHandle(_fileHandle)) {
LOGI("File \"%s\" closed", _path.data());
_fileHandle = NULL;
_fileHandle = INVALID_HANDLE_VALUE;
} else {
LOGW("Can't close the file \"%s\"", _path.data());
}
Expand Down Expand Up @@ -288,7 +288,7 @@ namespace Death { namespace IO {
bool FileStream::IsValid()
{
#if defined(DEATH_TARGET_WINDOWS)
return (_fileHandle != NULL);
return (_fileHandle != INVALID_HANDLE_VALUE);
#else
return (_fileDescriptor >= 0);
#endif
Expand Down Expand Up @@ -337,7 +337,7 @@ namespace Death { namespace IO {
{
#if defined(DEATH_TARGET_WINDOWS)
DWORD desireAccess, creationDisposition, shareMode;
switch (mode & ~FileAccess::Exclusive) {
switch (mode & FileAccess::ReadWrite) {
case FileAccess::Read:
desireAccess = GENERIC_READ;
creationDisposition = OPEN_EXISTING;
Expand All @@ -351,22 +351,26 @@ namespace Death { namespace IO {
case FileAccess::ReadWrite:
desireAccess = GENERIC_READ | GENERIC_WRITE;
creationDisposition = /*OPEN_ALWAYS*/OPEN_EXISTING; // NOTE: File must already exist
shareMode = ((mode & FileAccess::Exclusive) == FileAccess::Exclusive ? 0 : FILE_SHARE_READ);
shareMode = ((mode & FileAccess::Exclusive) == FileAccess::Exclusive ? 0 : FILE_SHARE_READ | FILE_SHARE_WRITE);
break;
default:
LOGE("Can't open file \"%s\" - wrong open mode", _path.data());
return;
}

SECURITY_ATTRIBUTES securityAttribs = { sizeof(SECURITY_ATTRIBUTES) };
securityAttribs.bInheritHandle = (mode & FileAccess::InheritHandle) == FileAccess::InheritHandle;

# if defined(DEATH_TARGET_WINDOWS_RT)
_fileHandle = ::CreateFile2FromAppW(Utf8::ToUtf16(_path), desireAccess, shareMode, creationDisposition, NULL);
CREATEFILE2_EXTENDED_PARAMETERS params = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), FILE_ATTRIBUTE_NORMAL };
params.lpSecurityAttributes = &securityAttribs;
_fileHandle = ::CreateFile2FromAppW(Utf8::ToUtf16(_path), desireAccess, shareMode, creationDisposition, &params);
# else
_fileHandle = ::CreateFile(Utf8::ToUtf16(_path), desireAccess, shareMode, NULL, creationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
_fileHandle = ::CreateFile(Utf8::ToUtf16(_path), desireAccess, shareMode, &securityAttribs, creationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
# endif
if (_fileHandle == NULL || _fileHandle == INVALID_HANDLE_VALUE) {
if (_fileHandle == INVALID_HANDLE_VALUE) {
DWORD error = ::GetLastError();
LOGE("Can't open file \"%s\" - failed with error 0x%08X%s", _path.data(), error, __GetWin32ErrorSuffix(error));
_fileHandle = NULL;
return;
}

Expand All @@ -375,24 +379,27 @@ namespace Death { namespace IO {
_size = fileSize.QuadPart;
}
#else
int openFlag;
switch (mode & ~FileAccess::Exclusive) {
int openFlags;
switch (mode & FileAccess::ReadWrite) {
case FileAccess::Read:
openFlag = O_RDONLY;
openFlags = O_RDONLY;
break;
case FileAccess::Write:
openFlag = O_WRONLY | O_CREAT | O_TRUNC;
openFlags = O_WRONLY | O_CREAT | O_TRUNC;
break;
case FileAccess::ReadWrite:
openFlag = O_RDWR; // NOTE: File must already exist
openFlags = O_RDWR; // NOTE: File must already exist
break;
default:
LOGE("Can't open file \"%s\" - wrong open mode", _path.data());
return;
}
if ((mode & FileAccess::InheritHandle) != FileAccess::InheritHandle) {
openFlags |= O_CLOEXEC;
}

int defaultPermissions = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); // 0666
_fileDescriptor = ::open(_path.data(), openFlag, defaultPermissions);
_fileDescriptor = ::open(_path.data(), openFlags, defaultPermissions);
if (_fileDescriptor < 0) {
LOGE("Can't open file \"%s\" - failed with error %i", _path.data(), errno);
return;
Expand All @@ -405,7 +412,7 @@ namespace Death { namespace IO {
}
#endif

switch (mode & ~FileAccess::Exclusive) {
switch (mode & FileAccess::ReadWrite) {
default: LOGI("File \"%s\" opened", _path.data()); break;
case FileAccess::Write: LOGI("File \"%s\" opened for write", _path.data()); break;
case FileAccess::ReadWrite: LOGI("File \"%s\" opened for read+write", _path.data()); break;
Expand Down
1 change: 1 addition & 0 deletions Sources/nCine/I18n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace nCine
{ "et", "Eesti"_s },
{ "fi", "Suomi"_s },
{ "fr", "Français"_s },
{ "gl", "Galego"_s },
{ "gr", "Greek"_s },
{ "hr", "Hrvatski"_s },
{ "hu", "Magyar"_s },
Expand Down

0 comments on commit a2376eb

Please sign in to comment.