mirror of
https://github.com/dborth/fceugx.git
synced 2024-12-04 14:24:16 +01:00
add ability to externally load fonts and activate japanese/korean
translations.
This commit is contained in:
parent
a49567d4b2
commit
f490574b9e
BIN
fonts/jp.ttf
Normal file
BIN
fonts/jp.ttf
Normal file
Binary file not shown.
BIN
fonts/ko.ttf
Normal file
BIN
fonts/ko.ttf
Normal file
Binary file not shown.
@ -38,6 +38,13 @@ https://github.com/dborth/fceugx/releases
|
||||
|0O×øo· UPDATE HISTORY ·oø×O0|
|
||||
`¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨'
|
||||
|
||||
[3.4.2]
|
||||
|
||||
* Fixed GameCube controllers not working
|
||||
* Added ability to load external fonts and activated Japanese/Korean
|
||||
translations. Simply put the ko.ttf or jp.ttf in the app directory
|
||||
* Added ability to change preview image source with + button (thanks Zalo!)
|
||||
|
||||
[3.4.1 - January 4, 2019]
|
||||
|
||||
* Improved WiiFlow integration
|
||||
|
@ -41,6 +41,9 @@
|
||||
#include "gui/gui.h"
|
||||
#include "utils/wiidrc.h"
|
||||
#include "utils/FreeTypeGX.h"
|
||||
#ifdef HW_RVL
|
||||
#include "mem2.h"
|
||||
#endif
|
||||
#ifdef USE_VM
|
||||
#include "vmalloc.h"
|
||||
#endif
|
||||
@ -400,6 +403,8 @@ int main(int argc, char *argv[])
|
||||
// store path app was loaded from
|
||||
if(argc > 0 && argv[0] != NULL)
|
||||
CreateAppPath(argv[0]);
|
||||
|
||||
InitMem2Manager();
|
||||
#endif
|
||||
|
||||
DefaultSettings(); // Set defaults
|
||||
|
@ -35,9 +35,14 @@
|
||||
#include "filebrowser.h"
|
||||
#include "gui/gui.h"
|
||||
|
||||
#ifdef HW_RVL
|
||||
#include "mem2.h"
|
||||
#endif
|
||||
|
||||
#define THREAD_SLEEP 100
|
||||
|
||||
unsigned char *savebuffer = NULL;
|
||||
u8 *ext_font_ttf = NULL;
|
||||
static mutex_t bufferLock = LWP_MUTEX_NULL;
|
||||
FILE * file; // file pointer - the only one we should ever use!
|
||||
bool unmountRequired[7] = { false, false, false, false, false, false, false };
|
||||
@ -854,6 +859,43 @@ size_t LoadFile(char * filepath, bool silent)
|
||||
return LoadFile((char *)savebuffer, filepath, 0, SAVEBUFFERSIZE, silent);
|
||||
}
|
||||
|
||||
#ifdef HW_RVL
|
||||
size_t LoadFont(char * filepath)
|
||||
{
|
||||
FILE *file = fopen (filepath, "rb");
|
||||
|
||||
if(!file) {
|
||||
ErrorPrompt("Font file not found!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseeko(file,0,SEEK_END);
|
||||
size_t loadSize = ftello(file);
|
||||
|
||||
if(loadSize == 0) {
|
||||
ErrorPrompt("Error loading font!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ext_font_ttf) {
|
||||
mem2_free(ext_font_ttf);
|
||||
}
|
||||
|
||||
ext_font_ttf = (u8 *)mem2_malloc(loadSize);
|
||||
|
||||
if(!ext_font_ttf) {
|
||||
ErrorPrompt("Font file is too large!");
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseeko(file,0,SEEK_SET);
|
||||
fread (ext_font_ttf, 1, loadSize, file);
|
||||
fclose(file);
|
||||
return loadSize;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* SaveFile
|
||||
* Write buffer to file
|
||||
|
@ -37,10 +37,12 @@ void FreeSaveBuffer();
|
||||
size_t LoadFile(char * rbuffer, char *filepath, size_t length, size_t buffersize, bool silent);
|
||||
size_t LoadFile(char * filepath, bool silent);
|
||||
size_t LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||
size_t LoadFont(char *filepath);
|
||||
size_t SaveFile(char * buffer, char *filepath, size_t datasize, bool silent);
|
||||
size_t SaveFile(char * filepath, size_t datasize, bool silent);
|
||||
|
||||
extern unsigned char *savebuffer;
|
||||
extern u8 *ext_font_ttf;
|
||||
extern FILE * file;
|
||||
extern bool unmountRequired[];
|
||||
extern bool isMounted[];
|
||||
|
44
source/mem2.cpp
Normal file
44
source/mem2.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric 2010
|
||||
*
|
||||
* mem2.cpp
|
||||
*
|
||||
* MEM2 memory allocator
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
#include <ogc/machine/asm.h>
|
||||
#include <ogc/lwp_heap.h>
|
||||
#include <ogc/system.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
|
||||
static heap_cntrl mem2_heap;
|
||||
|
||||
u32 InitMem2Manager ()
|
||||
{
|
||||
int size = (10*1024*1024);
|
||||
u32 level;
|
||||
_CPU_ISR_Disable(level);
|
||||
size &= ~0x1f; // round down, because otherwise we may exceed the area
|
||||
void *mem2_heap_ptr = (void *)((u32)SYS_GetArena2Hi()-size);
|
||||
SYS_SetArena2Hi(mem2_heap_ptr);
|
||||
_CPU_ISR_Restore(level);
|
||||
size = __lwp_heap_init(&mem2_heap, mem2_heap_ptr, size, 32);
|
||||
return size;
|
||||
}
|
||||
|
||||
void* mem2_malloc(u32 size)
|
||||
{
|
||||
return __lwp_heap_allocate(&mem2_heap, size);
|
||||
}
|
||||
|
||||
bool mem2_free(void *ptr)
|
||||
{
|
||||
return __lwp_heap_free(&mem2_heap, ptr);
|
||||
}
|
||||
|
||||
#endif
|
23
source/mem2.h
Normal file
23
source/mem2.h
Normal file
@ -0,0 +1,23 @@
|
||||
/****************************************************************************
|
||||
* FCE Ultra
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric 2010
|
||||
*
|
||||
* mem2.h
|
||||
*
|
||||
* MEM2 memory allocator
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
#ifndef _MEM2MANAGER_H_
|
||||
#define _MEM2MANAGER_H_
|
||||
|
||||
u32 InitMem2Manager ();
|
||||
void* mem2_malloc(u32 size);
|
||||
bool mem2_free(void *ptr);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -41,6 +41,7 @@
|
||||
#include "cheatmgr.h"
|
||||
#include "gui/gui.h"
|
||||
#include "utils/gettext.h"
|
||||
#include "utils/FreeTypeGX.h"
|
||||
|
||||
#define THREAD_SLEEP 100
|
||||
|
||||
@ -48,6 +49,10 @@
|
||||
static GuiImageData * pointer[4];
|
||||
#endif
|
||||
|
||||
#ifdef HW_RVL
|
||||
#include "mem2.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_VM
|
||||
#include "vmalloc.h"
|
||||
#define MEM_ALLOC(A) (u8*)vm_malloc(A)
|
||||
@ -126,7 +131,7 @@ HaltGui()
|
||||
usleep(THREAD_SLEEP);
|
||||
}
|
||||
|
||||
void ResetText()
|
||||
static void ResetText()
|
||||
{
|
||||
LoadLanguage();
|
||||
|
||||
@ -134,6 +139,58 @@ void ResetText()
|
||||
mainWindow->ResetText();
|
||||
}
|
||||
|
||||
static int currentLanguage = -1;
|
||||
|
||||
void ChangeLanguage() {
|
||||
if(currentLanguage == GCSettings.language) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(GCSettings.language == LANG_JAPANESE || GCSettings.language == LANG_KOREAN) {
|
||||
#ifdef HW_RVL
|
||||
char filepath[MAXPATHLEN];
|
||||
|
||||
switch(GCSettings.language) {
|
||||
case LANG_KOREAN:
|
||||
sprintf(filepath, "%s/ko.ttf", appPath);
|
||||
break;
|
||||
case LANG_JAPANESE:
|
||||
sprintf(filepath, "%s/jp.ttf", appPath);
|
||||
break;
|
||||
}
|
||||
|
||||
size_t fontSize = LoadFont(filepath);
|
||||
|
||||
if(fontSize > 0) {
|
||||
HaltGui();
|
||||
DeinitFreeType();
|
||||
InitFreeType((u8*)ext_font_ttf, fontSize);
|
||||
}
|
||||
else {
|
||||
GCSettings.language = currentLanguage;
|
||||
}
|
||||
#else
|
||||
GCSettings.language = currentLanguage;
|
||||
ErrorPrompt("Unsupported language!");
|
||||
#endif
|
||||
}
|
||||
#ifdef HW_RVL
|
||||
else {
|
||||
if(ext_font_ttf != NULL) {
|
||||
HaltGui();
|
||||
DeinitFreeType();
|
||||
mem2_free(ext_font_ttf);
|
||||
ext_font_ttf = NULL;
|
||||
InitFreeType((u8*)font_ttf, font_ttf_size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
HaltGui();
|
||||
ResetText();
|
||||
currentLanguage = GCSettings.language;
|
||||
ResumeGui();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* WindowPrompt
|
||||
*
|
||||
@ -3735,6 +3792,7 @@ static int MenuSettingsMenu()
|
||||
int i = 0;
|
||||
bool firstRun = true;
|
||||
OptionList options;
|
||||
currentLanguage = GCSettings.language;
|
||||
|
||||
sprintf(options.name[i++], "Exit Action");
|
||||
sprintf(options.name[i++], "Wiimote Orientation");
|
||||
@ -3822,9 +3880,7 @@ static int MenuSettingsMenu()
|
||||
GCSettings.language = LANG_JAPANESE;
|
||||
|
||||
if(GCSettings.language == LANG_SIMP_CHINESE)
|
||||
GCSettings.language = LANG_PORTUGUESE;
|
||||
else if(GCSettings.language == LANG_JAPANESE)
|
||||
GCSettings.language = LANG_ENGLISH;
|
||||
GCSettings.language = LANG_KOREAN;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
@ -3920,11 +3976,11 @@ static int MenuSettingsMenu()
|
||||
menu = MENU_SETTINGS;
|
||||
}
|
||||
}
|
||||
ChangeLanguage();
|
||||
HaltGui();
|
||||
mainWindow->Remove(&optionBrowser);
|
||||
mainWindow->Remove(&w);
|
||||
mainWindow->Remove(&titleTxt);
|
||||
ResetText();
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ void InfoPrompt(const char * msg);
|
||||
void ShowAction (const char *msg);
|
||||
void CancelAction();
|
||||
void ShowProgress (const char *msg, int done, int total);
|
||||
void ResetText();
|
||||
void ChangeLanguage();
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -624,6 +624,6 @@ bool LoadPrefs()
|
||||
|
||||
}
|
||||
|
||||
ResetText();
|
||||
ChangeLanguage();
|
||||
return prefFound;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user