Commit 198cb4f9 authored by Peter's avatar Peter

Android: Add Language selector in Settings

parent 0826f0c0
package forge.assets;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import forge.model.FModel;
import forge.properties.ForgeConstants;
import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref;
import java.util.ArrayList;
import java.util.List;
public class FLanguage {
public static void changeLanguage(final String languageName) {
final ForgePreferences prefs = FModel.getPreferences();
if (languageName.equals(prefs.getPref(FPref.UI_LANGUAGE))) { return; }
//save language preference
prefs.setPref(FPref.UI_LANGUAGE, languageName);
prefs.save();
}
/**
* Gets the languages.
*
* @return the languages
*/
public static Iterable<String> getAllLanguages() {
final List<String> allLanguages = new ArrayList<String>();
final FileHandle dir = Gdx.files.absolute(ForgeConstants.LANG_DIR);
for (FileHandle languageFile : dir.list()) {
String languageName = languageFile.name();
if (!languageName.endsWith(".properties")) { continue; }
allLanguages.add(languageName.replace(".properties", ""));
}
return allLanguages;
}
}
......@@ -6,6 +6,7 @@ import forge.Graphics;
import forge.MulliganDefs;
import forge.StaticData;
import forge.ai.AiProfileUtil;
import forge.assets.FLanguage;
import forge.assets.FSkin;
import forge.assets.FSkinColor;
import forge.assets.FSkinFont;
......@@ -48,6 +49,14 @@ public class SettingsPage extends TabPage<SettingsScreen> {
lstSettings.addGroup("Sound Options");
//General Settings
lstSettings.addItem(new CustomSelectSetting(FPref.UI_LANGUAGE, "Language",
"Select Language (Excluded Game part. Still a work in progress) (RESTART REQUIRED)",
FLanguage.getAllLanguages()) {
@Override
public void valueChanged(String newValue) {
FLanguage.changeLanguage(newValue);
}
}, 0);
lstSettings.addItem(new CustomSelectSetting(FPref.UI_SKIN, "Theme",
"Sets the theme that determines how display components are skinned.",
FSkin.getAllSkins()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment