1 package org.easyrpg.player.button_mapping;
2 
3 import android.content.Context;
4 import android.graphics.Canvas;
5 
6 import org.easyrpg.player.player.EasyRpgPlayerActivity;
7 import org.easyrpg.player.settings.SettingsManager;
8 
9 public class MenuButton extends VirtualButton {
10     public static final int MENU_BUTTON_KEY = -2;
11 
12 
MenuButton(Context context, double posX, double posY, int size)13     public MenuButton(Context context, double posX, double posY, int size) {
14         super(context, MENU_BUTTON_KEY, posX, posY, size);
15     }
16 
17     @Override
onDraw(Canvas canvas)18     protected void onDraw(Canvas canvas) {
19         if (!debug_mode) {
20             painter.setAlpha(255 - SettingsManager.getLayoutTransparency());
21         }
22 
23         // The rectangle
24         int height = realSize / 7;
25         for (int i = 0; i < 7; i++) {
26             if (i % 2 == 1) {
27                 canvas.drawRect(realSize / 6, i * height, (realSize * 5) / 6, (i + 1) * height, painter);
28             }
29         }
30     }
31 
32     @Override
onPressed()33     public void onPressed() {
34         // Vibration
35         if (!debug_mode) {
36             if (!isPressed) {
37                 if (SettingsManager.isVibrationEnabled() && vibrator != null) {
38                     vibrator.vibrate(SettingsManager.getVibrationDuration());
39                 }
40             }
41         }
42     }
43 
44     @Override
onReleased()45     public void onReleased() {
46         // Open the menu
47         if (!debug_mode) {
48             EasyRpgPlayerActivity.staticOpenOrCloseMenu();
49         }
50     }
51 }
52