commit
b44b24acd3
@ -0,0 +1,315 @@
|
|||||||
|
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "stdmisc.h"
|
||||||
|
#include "nel/misc/bitmap.h"
|
||||||
|
|
||||||
|
#ifdef USE_GIF
|
||||||
|
#include <gif_lib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace NLMISC
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef USE_GIF
|
||||||
|
|
||||||
|
// GIFLIB_MAJOR is defined from version 5
|
||||||
|
#ifndef GIFLIB_MAJOR
|
||||||
|
#define GIFLIB_MAJOR 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static uint8 GIF_TRANSPARENT_MASK = 0x01;
|
||||||
|
static uint8 GIF_DISPOSE_MASK = 0x07;
|
||||||
|
static sint8 GIF_NOT_TRANSPARENT = -1;
|
||||||
|
|
||||||
|
static uint8 GIF_DISPOSE_NONE = 0;
|
||||||
|
static uint8 GIF_DISPOSE_LEAVE = 1;
|
||||||
|
static uint8 GIF_DISPOSE_BACKGROUND = 2;
|
||||||
|
static uint8 GIF_DISPOSE_RESTORE = 3;
|
||||||
|
|
||||||
|
static NLMISC::IStream *GIFStream = NULL;
|
||||||
|
|
||||||
|
#if GIFLIB_MAJOR < 5
|
||||||
|
static uint8 INTERLACED_OFFSET[] = { 0, 4, 2, 1 };
|
||||||
|
static uint8 INTERLACED_JUMP[] = { 8, 8, 4, 2 };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int readGIFData(GifFileType *gif, GifByteType *data, int length){
|
||||||
|
NLMISC::IStream *f = static_cast<NLMISC::IStream *>(gif->UserData);
|
||||||
|
|
||||||
|
if(!f->isReading()) return 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
f->serialBuffer((uint8*) data, length);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
nlwarning("error while reading JPEG image");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------*\
|
||||||
|
readGIF
|
||||||
|
\*-------------------------------------------------------------------*/
|
||||||
|
uint8 CBitmap::readGIF( NLMISC::IStream &f )
|
||||||
|
{
|
||||||
|
if(!f.isReading()) return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
// check gif canvas dimension
|
||||||
|
uint16 ver;
|
||||||
|
uint16 width;
|
||||||
|
uint16 height;
|
||||||
|
|
||||||
|
f.serial(ver);
|
||||||
|
f.serial(width);
|
||||||
|
f.serial(height);
|
||||||
|
|
||||||
|
// limit image size as we are using 32bit pixels
|
||||||
|
// 4000x4000x4 ~ 61MiB
|
||||||
|
if (width*height > 4000*4000)
|
||||||
|
{
|
||||||
|
nlwarning("GIF image size is too big (width=%d, height=%d)", width, height);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// rewind for gif decoder
|
||||||
|
f.seek(-10, IStream::current);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if GIFLIB_MAJOR >= 5
|
||||||
|
sint32 errorCode;
|
||||||
|
GifFileType *gif = DGifOpen(&f, readGIFData, &errorCode);
|
||||||
|
if (gif == NULL)
|
||||||
|
{
|
||||||
|
nlwarning("failed to open gif, error=%d", errorCode);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
GifFileType *gif = DGifOpen(&f, readGIFData);
|
||||||
|
if (gif == NULL)
|
||||||
|
{
|
||||||
|
nlwarning("failed to open gif, error=%d", GifLastError());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// this will read and decode all frames
|
||||||
|
sint32 ret = DGifSlurp(gif);
|
||||||
|
if (ret != GIF_OK)
|
||||||
|
{
|
||||||
|
nlwarning("failed to read gif, error=%d", ret);
|
||||||
|
#if GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
|
||||||
|
DGifCloseFile(gif, &errorCode);
|
||||||
|
#else
|
||||||
|
DGifCloseFile(gif);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resize target buffer
|
||||||
|
uint32 dstChannels = 4; // RGBA
|
||||||
|
resize (gif->SWidth, gif->SHeight, RGBA);
|
||||||
|
|
||||||
|
// make transparent
|
||||||
|
_Data[0].fill(0);
|
||||||
|
|
||||||
|
// make sure background color index exists in global colormap
|
||||||
|
if (gif->SColorMap && gif->SColorMap->ColorCount < gif->SBackGroundColor)
|
||||||
|
{
|
||||||
|
gif->SBackGroundColor = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge all frames one by one into single target
|
||||||
|
ColorMapObject *ColorMap;
|
||||||
|
sint32 transparency = GIF_NOT_TRANSPARENT;
|
||||||
|
uint8 r, g, b, a;
|
||||||
|
uint32 offset_x, offset_y, width, height;
|
||||||
|
|
||||||
|
// disable loop as we only interested in first frame
|
||||||
|
// for (uint32 frame = 0; frame < gif->ImageCount; frame++)
|
||||||
|
{
|
||||||
|
uint32 frame = 0;
|
||||||
|
SavedImage *curFrame = &gif->SavedImages[frame];
|
||||||
|
|
||||||
|
if (curFrame->ExtensionBlockCount > 0)
|
||||||
|
{
|
||||||
|
for(uint e=0; e<curFrame->ExtensionBlockCount; e++){
|
||||||
|
ExtensionBlock *ext = &curFrame->ExtensionBlocks[e];
|
||||||
|
|
||||||
|
if (ext->Function == GRAPHICS_EXT_FUNC_CODE) {
|
||||||
|
uint8 flag = ext->Bytes[0];
|
||||||
|
//delay = (ext.Bytes[1] << 8) | ext.Bytes[2];
|
||||||
|
transparency = (flag & GIF_TRANSPARENT_MASK) ? ext->Bytes[3] : GIF_NOT_TRANSPARENT;
|
||||||
|
//dispose = ((flag >> 2) & GIF_DISPOSE_MASK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// select color map for frame
|
||||||
|
if (curFrame->ImageDesc.ColorMap)
|
||||||
|
{
|
||||||
|
ColorMap = curFrame->ImageDesc.ColorMap;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (gif->SColorMap)
|
||||||
|
{
|
||||||
|
ColorMap = gif->SColorMap;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nlwarning("GIF has no global or local color map");
|
||||||
|
ColorMap = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy frame to canvas
|
||||||
|
offset_x = curFrame->ImageDesc.Left;
|
||||||
|
offset_y = curFrame->ImageDesc.Top;
|
||||||
|
width = curFrame->ImageDesc.Width;
|
||||||
|
height = curFrame->ImageDesc.Height;
|
||||||
|
|
||||||
|
#if GIFLIB_MAJOR < 5
|
||||||
|
// giflib 4 does not handle interlaced images, so we must do it
|
||||||
|
if (curFrame->ImageDesc.Interlace)
|
||||||
|
{
|
||||||
|
uint32 srcOffset = 0;
|
||||||
|
for (uint8 pass = 0; pass < 4; pass++)
|
||||||
|
{
|
||||||
|
uint32 nextLine = INTERLACED_OFFSET[pass];
|
||||||
|
|
||||||
|
// y is destination row
|
||||||
|
for (uint32 y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
if (y != nextLine)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uint32 dstOffset = (y + offset_y)*gif->SWidth*dstChannels + offset_x*dstChannels;
|
||||||
|
nextLine += INTERLACED_JUMP[pass];
|
||||||
|
|
||||||
|
for (uint32 x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
srcOffset++;
|
||||||
|
dstOffset+= dstChannels;
|
||||||
|
|
||||||
|
uint32 index = curFrame->RasterBits[srcOffset];
|
||||||
|
if (index != transparency)
|
||||||
|
{
|
||||||
|
// make sure color index is not outside colormap
|
||||||
|
if (ColorMap)
|
||||||
|
{
|
||||||
|
if (index > ColorMap->ColorCount)
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
r = ColorMap->Colors[index].Red;
|
||||||
|
g = ColorMap->Colors[index].Green;
|
||||||
|
b = ColorMap->Colors[index].Blue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// broken gif, no colormap
|
||||||
|
r = g = b = 0;
|
||||||
|
}
|
||||||
|
a = 255;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// transparent
|
||||||
|
r = g = b = a = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Data[0][dstOffset] = r;
|
||||||
|
_Data[0][dstOffset+1] = g;
|
||||||
|
_Data[0][dstOffset+2] = b;
|
||||||
|
_Data[0][dstOffset+3] = a;
|
||||||
|
} // x loop
|
||||||
|
} // y loop
|
||||||
|
} // pass loop
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
for (uint32 y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
uint32 srcOffset = y*width;
|
||||||
|
uint32 dstOffset = (y + offset_y)*gif->SWidth*dstChannels + offset_x*dstChannels;
|
||||||
|
for (uint32 x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
srcOffset++;
|
||||||
|
dstOffset+= dstChannels;
|
||||||
|
|
||||||
|
uint32 index = curFrame->RasterBits[srcOffset];
|
||||||
|
if (index != transparency)
|
||||||
|
{
|
||||||
|
// make sure color index is not outside colormap
|
||||||
|
if (ColorMap)
|
||||||
|
{
|
||||||
|
if (index > ColorMap->ColorCount)
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
r = ColorMap->Colors[index].Red;
|
||||||
|
g = ColorMap->Colors[index].Green;
|
||||||
|
b = ColorMap->Colors[index].Blue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// broken gif, no colormap
|
||||||
|
r = g = b = 0;
|
||||||
|
}
|
||||||
|
a = 255;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// transparent
|
||||||
|
r = g = b = a = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Data[0][dstOffset] = r;
|
||||||
|
_Data[0][dstOffset+1] = g;
|
||||||
|
_Data[0][dstOffset+2] = b;
|
||||||
|
_Data[0][dstOffset+3] = a;
|
||||||
|
} // x loop
|
||||||
|
} // y loop
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up after the read, and free any memory allocated
|
||||||
|
#if GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
|
||||||
|
DGifCloseFile(gif, &errorCode);
|
||||||
|
#else
|
||||||
|
DGifCloseFile(gif);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//return the size of a pixel as 32bits
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
uint8 CBitmap::readGIF( NLMISC::IStream &/* f */)
|
||||||
|
{
|
||||||
|
nlwarning ("You must compile NLMISC with USE_GIF if you want gif support");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}//namespace
|
@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
echo Generating words diff...
|
||||||
|
bin\translation_tools make_words_diff
|
||||||
|
echo Done.
|
||||||
|
pause
|
@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
echo Merging words diff...
|
||||||
|
bin\translation_tools merge_words_diff
|
||||||
|
echo Done.
|
||||||
|
pause
|
@ -0,0 +1,16 @@
|
|||||||
|
@echo off
|
||||||
|
echo Installing translation file into ryzom...
|
||||||
|
|
||||||
|
REM Copy translated files in client directory...
|
||||||
|
xcopy /Y translated\*.uxt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\skill_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\item_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\creature_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\sbrick_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\sphrase_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\place_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\faction_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\title_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
xcopy /Y translated\outpost_*.txt ..\..\client\data\gamedev\language\
|
||||||
|
|
||||||
|
echo Done.
|
@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
echo Cleaning string diff...
|
||||||
|
bin\translation_tools clean_string_diff
|
||||||
|
echo Done.
|
||||||
|
pause
|
@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
echo Generating string diff...
|
||||||
|
bin\translation_tools make_string_diff
|
||||||
|
echo Done.
|
||||||
|
pause
|
@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
echo Merging string diff...
|
||||||
|
bin\translation_tools merge_string_diff
|
||||||
|
echo Done.
|
||||||
|
pause
|
@ -0,0 +1,6 @@
|
|||||||
|
wk
|
||||||
|
fr
|
||||||
|
en
|
||||||
|
de
|
||||||
|
ru
|
||||||
|
es
|
@ -0,0 +1,24 @@
|
|||||||
|
Please don't update files in "translated" directly!
|
||||||
|
|
||||||
|
First, be sure you put "translation_tools" in "bin" directory.
|
||||||
|
|
||||||
|
How to update translations in UXT files :
|
||||||
|
|
||||||
|
1. Update original texts in "work/wk.uxt"
|
||||||
|
2. Launch A_make_string_diff script
|
||||||
|
3. Open files in "diff" directory
|
||||||
|
4. Replace original text with translation between [ and ]
|
||||||
|
5. The 2 last lines : // REMOVE THE FOLOWING LINE WHEN TRANSLATION IS DONE and // DIFF NOT TRANSLATED
|
||||||
|
6. Save files
|
||||||
|
7. Launch AA_clean_string_diff to delete translations help (old values)
|
||||||
|
8. Launch B_merge_string_diff to merge your translations in "translated"
|
||||||
|
|
||||||
|
How to update translations in words files :
|
||||||
|
|
||||||
|
1. Update original texts in "work" directory
|
||||||
|
2. Launch 5_make_words_diff script
|
||||||
|
3. Open files in "diff" directory
|
||||||
|
4. Replace original text with translation (separators are <tab>)
|
||||||
|
5. The 2 last lines : REMOVE THE FOLOWING TWO LINE WHEN TRANSLATION IS DONE and DIFF NOT TRANSLATED
|
||||||
|
6. Save files
|
||||||
|
7. Launch 6_merge_words_diff to merge your translations in "translated"
|
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.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
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.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue