Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var buttonWindow;
- var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
- var BitmapFactory = android.graphics.BitmapFactory;
- var BitmapDrawable = android.graphics.drawable.BitmapDrawable;
- let imgSlot = new BitmapFactory.decodeFile("mnt/sdcard/download/Offhand/offhand.png");
- let iconSlot = new BitmapDrawable(imgSlot);
- const DENSITY = ctx.getResources().getDisplayMetrics().density;
- function px2dip(px){
- return Math.floor(px / DENSITY);
- }
- function newLevel() {
- ctx.runOnUiThread(new java.lang.Runnable({
- run: function() {
- try {
- buttonWindow = new android.widget.PopupWindow();
- var layout = new android.widget.RelativeLayout(ctx);
- var button = new android.widget.Button(ctx);
- button.setText("Offhand");
- button.setOnClickListener(new android.view.View.OnClickListener({
- onClick: function(viewarg) {
- clientMessage("Block Placed");
- }
- }));
- layout.addView(button);
- buttonWindow.setContentView(layout);
- buttonWindow.setWidth(110);
- buttonWindow.setHeight(110);
- buttonWindow.setBackgroundDrawable(iconSlot);
- buttonWindow.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.LEFT | android.view.Gravity.BOTTOM, 200, 0);
- } catch (problem) {
- print("Button could not be displayed: " + problem);
- }
- }
- }));
- }
- function leaveGame() {
- ctx.runOnUiThread(new java.lang.Runnable({
- run: function() {
- if (buttonWindow != null) {
- buttonWindow.dismiss();
- buttonwindow = null;
- }
- }
- }));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement