Rework name translation on Android.

Android doesn't support spaces (or anything) in the library names ...
This commit is contained in:
Themaister 2013-01-26 19:05:27 +01:00
parent 71f2ad6664
commit b7c410ba9c
3 changed files with 37 additions and 7 deletions

View File

@ -0,0 +1,15 @@
libretro_mednafen_pce_fast = "Mednafen PCE-fast (PC Engine)"
libretro_mednafen_wswan = "Mednafen WSwan (Wonderswan)"
libretro_fceumm = "FCEUmm (NES)"
libretro_mednafen_vb = "Mednafen VB (Virtual Boy)"
libretro_fba = "Final Burn Alpha (Arcade)"
libretro_mednafen_ngp = "Mednafen NGP (Neo-Geo Pocket)"
libretro_gambatte = "Gambatte (GameBoy)"
libretro_genesis_plus_gx = "Genesis Plus GX (Genesis)"
libretro_vba_next = "VBA Next (GBA)"
libretro_prboom = "PrBoom (DOOM)"
libretro_snes9x_next = "Snes9x-Next (SNES)"
libretro_nestopia = "Nestopia (NES)"
libretro_pcsx_rearmed-neon = "PCSX-reARMed (PSX) [NEON]"
libretro_pcsx_rearmed = "PCSX-reARMed (PSX)"
libretro_nxengine = "NXEngine (Cave Story)"

View File

@ -1,6 +1,7 @@
package org.retroarch.browser;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.FileInputStream;
import java.io.File;
@ -12,9 +13,8 @@ import java.util.Map;
public class ConfigFile {
private HashMap<String, String> map = new HashMap<String, String>();
public void append(File file) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(file.getAbsolutePath())));
public void append(InputStream stream) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
String line;
while ((line = br.readLine()) != null)
@ -25,7 +25,7 @@ public class ConfigFile {
public void open(File file) throws IOException {
clear();
append(file);
append(new FileInputStream(file));
}
public ConfigFile(File file) throws IOException {

View File

@ -19,9 +19,11 @@ import android.graphics.drawable.*;
class ModuleWrapper implements IconAdapterItem {
public final File file;
private ConfigFile config;
public ModuleWrapper(Context aContext, File aFile) throws IOException {
public ModuleWrapper(Context aContext, File aFile, ConfigFile config) throws IOException {
file = aFile;
this.config = config;
}
@Override
@ -31,7 +33,11 @@ class ModuleWrapper implements IconAdapterItem {
@Override
public String getText() {
return file.getName();
String stripped = file.getName().replace(".so", "");
if (config.keyExists(stripped)) {
return config.getString(stripped);
} else
return stripped;
}
@Override
@ -52,6 +58,7 @@ public class RetroArch extends Activity implements
static private String libretro_path;
static private final String TAG = "RetroArch-Phoenix";
private ConfigFile config;
private ConfigFile core_config;
private final double getDisplayRefreshRate() {
final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
@ -151,12 +158,20 @@ public class RetroArch extends Activity implements
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
config = new ConfigFile(new File(getDefaultConfigPath()));
} catch (IOException e) {
config = new ConfigFile();
}
core_config = new ConfigFile();
try {
core_config.append(getAssets().open("libretro_cores.cfg"));
} catch (IOException e) {
Log.e(TAG, "Failed to load libretro_cores.cfg from assets.");
}
String cpuInfo = readCPUInfo();
boolean cpuIsNeon = cpuInfoIsNeon(cpuInfo);
@ -209,7 +224,7 @@ public class RetroArch extends Activity implements
// Allow both libretro-core.so and libretro_core.so.
if (libName.startsWith("libretro") && !libName.startsWith("libretroarch")) {
try {
adapter.add(new ModuleWrapper(this, lib));
adapter.add(new ModuleWrapper(this, lib, core_config));
} catch (IOException e) {
e.printStackTrace();
}