1 package org.easyrpg.player.button_mapping;
2 
3 import android.content.Context;
4 import android.graphics.Canvas;
5 
6 import org.easyrpg.player.settings.SettingsManager;
7 import org.libsdl.app.SDLActivity;
8 
9 public class FastForwardingButton extends VirtualButton {
10     boolean alreadyActivated;
11 
FastForwardingButton(Context context, int keyCode, double posX, double posY, int size)12     protected FastForwardingButton(Context context, int keyCode, double posX, double posY, int size) {
13         super(context, keyCode, posX, posY, size);
14     }
15 
16     @Override
onPressed()17     public void onPressed() {
18         if (!debug_mode) {
19             if (!isPressed) {
20                 isPressed = true;
21 
22                 SDLActivity.onNativeKeyDown(this.keyCode);
23                 // Vibration
24                 if (SettingsManager.isVibrationEnabled() && vibrator != null) {
25                     vibrator.vibrate(SettingsManager.getVibrationDuration());
26                 }
27             }
28         }
29     }
30 
31     @Override
onReleased()32     public void onReleased() {
33         if (!debug_mode) {
34             if (isPressed) {
35                 isPressed = false;
36 
37                 if (!isTapMode() || (isTapMode() && alreadyActivated)) {
38                     SDLActivity.onNativeKeyUp(this.keyCode);
39                     alreadyActivated = false;
40                 } else {
41                     alreadyActivated = true;
42                 }
43             }
44         }
45 
46     }
47 
48     @Override
onDraw(Canvas canvas)49     protected void onDraw(Canvas canvas) {
50         setProperTransparency(canvas);
51 
52         // Draw the rectangle surrounding the button's letter
53         int border = 5;
54         canvas.drawRect(border, border, realSize - border, realSize - border, painter);
55 
56         // Draw the symbol, centered in the rectangle
57         drawCenter(canvas, painter, String.valueOf(charButton));
58     }
59 
isTapMode()60     private boolean isTapMode() {
61         return (SettingsManager.getFastForwardMode() == 1);
62     }
63 }
64