Skip to content

Commit

Permalink
Added a new icon by NathanX, DPI and disable texture pack options in …
Browse files Browse the repository at this point in the history
…the menu
  • Loading branch information
zhuowei committed Feb 18, 2013
1 parent c936aad commit 87aa8bd
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 8 deletions.
Binary file added Minecraft PE launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Minecraft PE launcher.xcf
Binary file not shown.
2 changes: 0 additions & 2 deletions ant.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

key.store=androidreleasekey.keystore
key.alias=androidreleasekey
Binary file modified res/drawable-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-ldpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<string name="pref_zz_patch_ip_enable_summary">Redirects multiplayer connections to an online server</string>
<string name="pref_zz_patch_ip">Server IP</string>
<string name="pref_zz_patch_ip_summary">The IP address of the online server</string>
<string name="pref_zz_texture_pack_enable">Use texture pack</string>
<string name="pref_zz_custom_dpi">Custom DPI</string>
<string name="pref_zz_custom_dpi_summary">Change the reported screen density to change size of controls - leave blank to disable</string>
<string name="texture_pack_unable_to_load">Unable to load texture pack.</string>
<string name="nerdy_stuff_page">Nerdy stuff</string>
<string name="dump_libminecraftpe">Dump libminecraftpe.so from memory</string>
Expand Down
8 changes: 8 additions & 0 deletions res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
android:title="@string/pref_gfx_lowquality"
android:summary="@string/pref_gfx_lowquality_summary"
android:defaultValue="false"/>

<EditTextPreference
android:key="zz_custom_dpi"
android:title="@string/pref_zz_custom_dpi"
android:summary="@string/pref_zz_custom_dpi_summary"
android:inputType="numberDecimal"
android:defaultValue=""/>

<CheckBoxPreference
android:key="game_difficultypeaceful"
android:title="@string/pref_game_difficultypeaceful"
Expand Down
19 changes: 16 additions & 3 deletions src/com/mojang/minecraftpe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class MainActivity extends NativeActivity

protected TexturePack texturePack;

protected TexturePack originalPack;

protected Context minecraftApkContext;

protected boolean fakePackage = false;
Expand Down Expand Up @@ -122,8 +124,9 @@ public void onCreate(Bundle savedInstanceState) {
setFakePackage(false);

try {
boolean loadTexturePack = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("zz_texture_pack_enable", false);
String filePath = getSharedPreferences(MainMenuOptionsActivity.PREFERENCES_NAME, 0).getString("texturePack", null);
if (filePath != null) {
if (loadTexturePack && filePath != null) {
File file = new File(filePath);
System.out.println("File!! " + file);
if (!file.exists()) {
Expand All @@ -141,7 +144,7 @@ public void onCreate(Bundle savedInstanceState) {
if (this.getPackageName().equals("com.mojang.minecraftpe")) {
minecraftApkContext = this;
} else {
minecraftApkContext = createPackageContext("com.mojang.minecraftpe", 0);
minecraftApkContext = createPackageContext("com.mojang.minecraftpe", Context.CONTEXT_IGNORE_SECURITY);
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -414,7 +417,17 @@ public String[] getOptionStrings() {

public float getPixelsPerMillimeter() {
System.out.println("Pixels per mm");
return ((float) displayMetrics.densityDpi) / 25.4f ;
float val = ((float) displayMetrics.densityDpi) / 25.4f;
String custom = PreferenceManager.getDefaultSharedPreferences(this).getString("zz_custom_dpi", null);
if (custom != null && custom.length() > 0) {
try {
val = Float.parseFloat(custom) / 25.4f;
} catch (Exception e) {
e.printStackTrace();
}
}
return val;

}

public String getPlatformStringVar(int a) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class MainMenuOptionsActivity extends PreferenceActivity implements Prefe
public static final int REQUEST_MANAGE_PATCHES = 6;

private Preference texturePackPreference;
private Preference texturePackEnablePreference;
private Preference managePatchesPreference;
private Preference safeModePreference;
private boolean needsRestart = false;
Expand All @@ -36,7 +37,9 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(net.zhuoweizhang.mcpelauncher.R.xml.preferences);
texturePackPreference = findPreference("zz_texture_pack");
texturePackPreference.setOnPreferenceClickListener(this);
if (texturePackPreference != null) texturePackPreference.setOnPreferenceClickListener(this);
texturePackEnablePreference = findPreference("zz_texture_pack_enable");
if (texturePackEnablePreference != null) texturePackEnablePreference.setOnPreferenceClickListener(this);
managePatchesPreference = findPreference("zz_manage_patches");
managePatchesPreference.setOnPreferenceClickListener(this);
safeModePreference = findPreference("zz_safe_mode");
Expand All @@ -59,7 +62,7 @@ public boolean onPreferenceClick(Preference pref) {
} else if (pref == managePatchesPreference) {
managePatches();
return true;
} else if (pref == safeModePreference) {
} else if (pref == safeModePreference || pref == texturePackEnablePreference) {
needsRestart = true;
return false; //Don't eat it
}
Expand Down Expand Up @@ -94,7 +97,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(this, "Texture pack set! Restarting Minecraft to load texture pack...", Toast.LENGTH_LONG).show();
//Toast.makeText(this, "Texture pack set! Restarting Minecraft to load texture pack...", Toast.LENGTH_LONG).show();
finish();
restartFirstActivity();
//System.exit(0);
Expand Down

0 comments on commit 87aa8bd

Please sign in to comment.