mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-15 19:10:10 -07:00
More working at custom controls
This commit is contained in:
parent
ebb1cd9c7b
commit
08f5897cc1
11 changed files with 138 additions and 17 deletions
|
|
@ -44,8 +44,7 @@ public class CustomControlsActivity extends AppCompatActivity
|
||||||
ctrlBtn.name = "New";
|
ctrlBtn.name = "New";
|
||||||
ctrlBtn.x = 100;
|
ctrlBtn.x = 100;
|
||||||
ctrlBtn.y = 100;
|
ctrlBtn.y = 100;
|
||||||
mCtrl.button.add(ctrlBtn);
|
ctrlLayout.addControlButton(ctrlBtn);
|
||||||
ctrlLayout.refreshLayout();
|
|
||||||
break;
|
break;
|
||||||
case R.id.menu_ctrl_edit: // openLogOutput();
|
case R.id.menu_ctrl_edit: // openLogOutput();
|
||||||
break;
|
break;
|
||||||
|
|
@ -60,14 +59,14 @@ public class CustomControlsActivity extends AppCompatActivity
|
||||||
});
|
});
|
||||||
|
|
||||||
mCtrl = new CustomControls();
|
mCtrl = new CustomControls();
|
||||||
|
/*
|
||||||
ControlButton ctrlEx = new ControlButton();
|
ControlButton ctrlEx = new ControlButton();
|
||||||
ctrlEx.name = "Test";
|
ctrlEx.name = "Test";
|
||||||
ctrlEx.x = 100;
|
ctrlEx.x = 100;
|
||||||
ctrlEx.y = 100;
|
ctrlEx.y = 100;
|
||||||
|
|
||||||
mCtrl.button.add(ctrlEx);
|
mCtrl.button.add(ctrlEx);
|
||||||
|
*/
|
||||||
ctrlLayout = (ControlsLayout) findViewById(R.id.customctrl_controllayout);
|
ctrlLayout = (ControlsLayout) findViewById(R.id.customctrl_controllayout);
|
||||||
ctrlLayout.loadLayout(mCtrl);
|
ctrlLayout.loadLayout(mCtrl);
|
||||||
ctrlLayout.setCanMove(true);
|
ctrlLayout.setCanMove(true);
|
||||||
|
|
|
||||||
|
|
@ -843,7 +843,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
||||||
checkUpdate();
|
checkUpdate();
|
||||||
} break;
|
} break;
|
||||||
case 3:{ // Custom controls
|
case 3:{ // Custom controls
|
||||||
// startActivity(new Intent(MCLauncherActivity.this, CustomControlsActivity.class));
|
startActivity(new Intent(MCLauncherActivity.this, CustomControlsActivity.class));
|
||||||
} break;
|
} break;
|
||||||
case 4:{ // Settings
|
case 4:{ // Settings
|
||||||
startActivity(new Intent(MCLauncherActivity.this, PojavPreferenceActivity.class));
|
startActivity(new Intent(MCLauncherActivity.this, PojavPreferenceActivity.class));
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import org.lwjgl.util.glu.tessellation.*;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements OnTouchListener, OnClickListener
|
public class MainActivity extends AppCompatActivity implements OnTouchListener, OnClickListener
|
||||||
{
|
{
|
||||||
|
|
@ -275,6 +276,27 @@ public class MainActivity extends AppCompatActivity implements OnTouchListener,
|
||||||
|
|
||||||
this.glSurfaceView = (MinecraftGLView) findViewById(R.id.main_game_render_view);
|
this.glSurfaceView = (MinecraftGLView) findViewById(R.id.main_game_render_view);
|
||||||
|
|
||||||
|
ControlButton[] specialButtons = ControlButton.getSpecialButtons();
|
||||||
|
specialButtons[0].specialButtonListener = new View.OnClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View p1)
|
||||||
|
{
|
||||||
|
showKeyboard();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
specialButtons[1].specialButtonListener = new View.OnClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View p1)
|
||||||
|
{
|
||||||
|
switch(overlayView.getVisibility()){
|
||||||
|
case View.VISIBLE: overlayView.setVisibility(View.GONE);
|
||||||
|
break;
|
||||||
|
case View.GONE: overlayView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// toggleGui(null);
|
// toggleGui(null);
|
||||||
onClick(toggleControlButton);
|
onClick(toggleControlButton);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import android.os.*;
|
||||||
import android.content.pm.PackageManager.*;
|
import android.content.pm.PackageManager.*;
|
||||||
import android.content.pm.*;
|
import android.content.pm.*;
|
||||||
import net.kdt.pojavlaunch.prefs.*;
|
import net.kdt.pojavlaunch.prefs.*;
|
||||||
|
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||||
|
|
||||||
public class PojavApplication extends Application
|
public class PojavApplication extends Application
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +23,11 @@ public class PojavApplication extends Application
|
||||||
Tools.datapath = getDir("files", MODE_PRIVATE).getParent();
|
Tools.datapath = getDir("files", MODE_PRIVATE).getParent();
|
||||||
|
|
||||||
PojavPreferenceActivity.loadPreferences(this);
|
PojavPreferenceActivity.loadPreferences(this);
|
||||||
|
|
||||||
|
ControlButton.pixelOf50dp = (int) Tools.dpToPx(this, 50);
|
||||||
|
ControlButton[] specialButtons = ControlButton.getSpecialButtons();
|
||||||
|
specialButtons[0].name = getString(R.string.control_keyboard);
|
||||||
|
specialButtons[1].name = getString(R.string.control_toggle);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,41 @@
|
||||||
package net.kdt.pojavlaunch.value.customcontrols;
|
package net.kdt.pojavlaunch.value.customcontrols;
|
||||||
import net.kdt.pojavlaunch.*;
|
import net.kdt.pojavlaunch.*;
|
||||||
|
import android.view.*;
|
||||||
|
|
||||||
public class ControlButton
|
public class ControlButton
|
||||||
{
|
{
|
||||||
|
public static int pixelOf50dp;
|
||||||
|
|
||||||
|
public static int SPECIALBTN_KEYBOARD = 0;
|
||||||
|
public static int SPECIALBTN_TOGGLECTRL = 1;
|
||||||
|
|
||||||
|
private static ControlButton[] SPECIAL_BUTTONS;
|
||||||
|
|
||||||
|
public static ControlButton[] getSpecialButtons(){
|
||||||
|
if (SPECIAL_BUTTONS == null) {
|
||||||
|
ControlButton keyboardBtn = new ControlButton();
|
||||||
|
ControlButton toggleCtrlBtn = new ControlButton();
|
||||||
|
|
||||||
|
SPECIAL_BUTTONS = new ControlButton[]{
|
||||||
|
keyboardBtn,
|
||||||
|
toggleCtrlBtn
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return SPECIAL_BUTTONS;
|
||||||
|
}
|
||||||
|
|
||||||
// Concept...
|
// Concept...
|
||||||
public String name;
|
public String name;
|
||||||
public float x;
|
public float x;
|
||||||
public float y;
|
public float y;
|
||||||
|
public int width = pixelOf50dp;
|
||||||
|
public int height = pixelOf50dp;
|
||||||
public int lwjglKeycode;
|
public int lwjglKeycode;
|
||||||
public boolean holdCtrl;
|
public boolean holdCtrl;
|
||||||
public boolean holdAlt;
|
public boolean holdAlt;
|
||||||
public boolean holdShift;
|
public boolean holdShift;
|
||||||
|
public View.OnClickListener specialButtonListener;
|
||||||
// public boolean hold
|
// public boolean hold
|
||||||
|
|
||||||
public void execute(MainActivity act, boolean isDown) {
|
public void execute(MainActivity act, boolean isDown) {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ public class ControlView extends Button implements OnTouchListener
|
||||||
setText(properties.name);
|
setText(properties.name);
|
||||||
setTranslationX(moveX = properties.x);
|
setTranslationX(moveX = properties.x);
|
||||||
setTranslationY(moveY = properties.y);
|
setTranslationY(moveY = properties.y);
|
||||||
|
|
||||||
|
setLayoutParams(new FrameLayout.LayoutParams(properties.width, properties.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ public class ControlsLayout extends FrameLayout
|
||||||
|
|
||||||
public void loadLayout(CustomControls controlLayout) {
|
public void loadLayout(CustomControls controlLayout) {
|
||||||
mLayout = controlLayout;
|
mLayout = controlLayout;
|
||||||
|
removeAllViews();
|
||||||
for (ControlButton button : controlLayout.button) {
|
for (ControlButton button : controlLayout.button) {
|
||||||
final ControlView view = new ControlView(getContext(), button);
|
final ControlView view = new ControlView(getContext(), button);
|
||||||
view.setOnClickListener(new View.OnClickListener(){
|
view.setOnClickListener(new View.OnClickListener(){
|
||||||
|
|
@ -39,9 +40,22 @@ public class ControlsLayout extends FrameLayout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshLayout(/* CustomControls controlLayout */) {
|
public void addControlButton(ControlButton controlButton) {
|
||||||
removeAllViews();
|
mLayout.button.add(controlButton);
|
||||||
loadLayout(mLayout);
|
|
||||||
|
final ControlView view = new ControlView(getContext(), controlButton);
|
||||||
|
view.setOnClickListener(new View.OnClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View p1) {
|
||||||
|
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||||
|
alert.setTitle(getResources().getString(R.string.global_edit) + " " + view.getText());
|
||||||
|
// alert.setView(edit);
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
view.setCanMove(mCanMove);
|
||||||
|
addView(view);
|
||||||
|
|
||||||
// loadLayout(controlLayout);
|
// loadLayout(controlLayout);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,24 @@
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:id="@+id/customctrl_drawerlayout">
|
android:id="@+id/customctrl_drawerlayout">
|
||||||
|
|
||||||
<net.kdt.pojavlaunch.value.customcontrols.ControlsLayout
|
<RelativeLayout
|
||||||
android:id="@+id/customctrl_controllayout"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content">
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
</net.kdt.pojavlaunch.value.customcontrols.ControlsLayout>
|
<TextView
|
||||||
|
android:text="@string/hint_control_mapping"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"/>
|
||||||
|
|
||||||
|
<net.kdt.pojavlaunch.value.customcontrols.ControlsLayout
|
||||||
|
android:id="@+id/customctrl_controllayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
</net.kdt.pojavlaunch.value.customcontrols.ControlsLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<android.support.design.widget.NavigationView
|
<android.support.design.widget.NavigationView
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
|
|
@ -21,6 +33,6 @@
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
app:menu="@menu/menu_customctrl"
|
app:menu="@menu/menu_customctrl"
|
||||||
android:id="@+id/customctrl_navigation_view"/>
|
android:id="@+id/customctrl_navigation_view"/>
|
||||||
|
|
||||||
</android.support.v4.widget.DrawerLayout>
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
||||||
|
|
|
||||||
36
app/src/main/res/layout/control_setting.xml
Normal file
36
app/src/main/res/layout/control_setting.xml
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/global_name"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:id="@+id/controlsetting_edit_name"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/customctrl_keyname"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:id="@+id/controlsetting_spinner_lwjglkeycode"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:text="@string/customctrl_hidden"
|
||||||
|
android:id="@+id/controlsetting_checkbox_hidden"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
android:background="@drawable/control_button"
|
android:background="@drawable/control_button"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:text="GUI"
|
android:text="@string/control_toggle"
|
||||||
android:layout_marginBottom="14dp"
|
android:layout_marginBottom="14dp"
|
||||||
android:layout_marginLeft="14dp"
|
android:layout_marginLeft="14dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
<!-- Hint -->
|
<!-- Hint -->
|
||||||
<string name="hint_select_account">To select, click it. To delete an account, hold it.</string>
|
<string name="hint_select_account">To select, click it. To delete an account, hold it.</string>
|
||||||
|
<string name="hint_control_mapping">Swipe from right to left to open menu\n◀</string>
|
||||||
|
|
||||||
<!-- Warning -->
|
<!-- Warning -->
|
||||||
<string name="warning_title">Warning</string>
|
<string name="warning_title">Warning</string>
|
||||||
|
|
@ -95,6 +96,7 @@
|
||||||
<!-- Global strings -->
|
<!-- Global strings -->
|
||||||
<string name="global_add">Add</string>
|
<string name="global_add">Add</string>
|
||||||
<string name="global_edit">Edit</string>
|
<string name="global_edit">Edit</string>
|
||||||
|
<string name="global_name">Name</string>
|
||||||
<string name="global_remove">Remove</string>
|
<string name="global_remove">Remove</string>
|
||||||
<string name="global_save">Save</string>
|
<string name="global_save">Save</string>
|
||||||
<string name="global_error_field_empty">This field can\'t be empty</string>
|
<string name="global_error_field_empty">This field can\'t be empty</string>
|
||||||
|
|
@ -131,6 +133,7 @@
|
||||||
|
|
||||||
<!-- MainActivity: Control buttons -->
|
<!-- MainActivity: Control buttons -->
|
||||||
<string name="controls">Controls</string>
|
<string name="controls">Controls</string>
|
||||||
|
<string name="control_toggle">GUI</string>
|
||||||
<string name="control_keyboard">Keyboard</string>
|
<string name="control_keyboard">Keyboard</string>
|
||||||
<string name="control_chat">Chat</string>
|
<string name="control_chat">Chat</string>
|
||||||
<string name="control_debug">Debug</string>
|
<string name="control_debug">Debug</string>
|
||||||
|
|
@ -154,11 +157,13 @@
|
||||||
<string name="control_viewout">Log output</string>
|
<string name="control_viewout">Log output</string>
|
||||||
<string name="control_adebug">PointerCapture Debug</string>
|
<string name="control_adebug">PointerCapture Debug</string>
|
||||||
<string name="control_customkey">Send custom keycode</string>
|
<string name="control_customkey">Send custom keycode</string>
|
||||||
|
|
||||||
<!--PointerCapture debug</string>-->
|
|
||||||
<string name="control_more3"></string>
|
<string name="control_more3"></string>
|
||||||
<string name="control_more4"></string>
|
<string name="control_more4"></string>
|
||||||
|
|
||||||
|
<string name="customctrl_keyname">LWJGL Keycode</string>
|
||||||
|
<string name="customctrl_hidden">Hidden</string>
|
||||||
|
|
||||||
<!-- Update part (unused now) -->
|
<!-- Update part (unused now) -->
|
||||||
<string name="update_console">Update console</string>
|
<string name="update_console">Update console</string>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue