mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-15 11:00:09 -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.x = 100;
|
||||
ctrlBtn.y = 100;
|
||||
mCtrl.button.add(ctrlBtn);
|
||||
ctrlLayout.refreshLayout();
|
||||
ctrlLayout.addControlButton(ctrlBtn);
|
||||
break;
|
||||
case R.id.menu_ctrl_edit: // openLogOutput();
|
||||
break;
|
||||
|
|
@ -60,14 +59,14 @@ public class CustomControlsActivity extends AppCompatActivity
|
|||
});
|
||||
|
||||
mCtrl = new CustomControls();
|
||||
|
||||
/*
|
||||
ControlButton ctrlEx = new ControlButton();
|
||||
ctrlEx.name = "Test";
|
||||
ctrlEx.x = 100;
|
||||
ctrlEx.y = 100;
|
||||
|
||||
mCtrl.button.add(ctrlEx);
|
||||
|
||||
*/
|
||||
ctrlLayout = (ControlsLayout) findViewById(R.id.customctrl_controllayout);
|
||||
ctrlLayout.loadLayout(mCtrl);
|
||||
ctrlLayout.setCanMove(true);
|
||||
|
|
|
|||
|
|
@ -843,7 +843,7 @@ public class MCLauncherActivity extends AppCompatActivity
|
|||
checkUpdate();
|
||||
} break;
|
||||
case 3:{ // Custom controls
|
||||
// startActivity(new Intent(MCLauncherActivity.this, CustomControlsActivity.class));
|
||||
startActivity(new Intent(MCLauncherActivity.this, CustomControlsActivity.class));
|
||||
} break;
|
||||
case 4:{ // Settings
|
||||
startActivity(new Intent(MCLauncherActivity.this, PojavPreferenceActivity.class));
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.lwjgl.util.glu.tessellation.*;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
onClick(toggleControlButton);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.os.*;
|
|||
import android.content.pm.PackageManager.*;
|
||||
import android.content.pm.*;
|
||||
import net.kdt.pojavlaunch.prefs.*;
|
||||
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||
|
||||
public class PojavApplication extends Application
|
||||
{
|
||||
|
|
@ -22,6 +23,11 @@ public class PojavApplication extends Application
|
|||
Tools.datapath = getDir("files", MODE_PRIVATE).getParent();
|
||||
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,41 @@
|
|||
package net.kdt.pojavlaunch.value.customcontrols;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import android.view.*;
|
||||
|
||||
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...
|
||||
public String name;
|
||||
public float x;
|
||||
public float y;
|
||||
public int width = pixelOf50dp;
|
||||
public int height = pixelOf50dp;
|
||||
public int lwjglKeycode;
|
||||
public boolean holdCtrl;
|
||||
public boolean holdAlt;
|
||||
public boolean holdShift;
|
||||
public View.OnClickListener specialButtonListener;
|
||||
// public boolean hold
|
||||
|
||||
public void execute(MainActivity act, boolean isDown) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ public class ControlView extends Button implements OnTouchListener
|
|||
setText(properties.name);
|
||||
setTranslationX(moveX = properties.x);
|
||||
setTranslationY(moveY = properties.y);
|
||||
|
||||
setLayoutParams(new FrameLayout.LayoutParams(properties.width, properties.height));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public class ControlsLayout extends FrameLayout
|
|||
|
||||
public void loadLayout(CustomControls controlLayout) {
|
||||
mLayout = controlLayout;
|
||||
removeAllViews();
|
||||
for (ControlButton button : controlLayout.button) {
|
||||
final ControlView view = new ControlView(getContext(), button);
|
||||
view.setOnClickListener(new View.OnClickListener(){
|
||||
|
|
@ -39,9 +40,22 @@ public class ControlsLayout extends FrameLayout
|
|||
}
|
||||
}
|
||||
|
||||
public void refreshLayout(/* CustomControls controlLayout */) {
|
||||
removeAllViews();
|
||||
loadLayout(mLayout);
|
||||
public void addControlButton(ControlButton controlButton) {
|
||||
mLayout.button.add(controlButton);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,24 @@
|
|||
android:layout_alignParentRight="true"
|
||||
android:id="@+id/customctrl_drawerlayout">
|
||||
|
||||
<net.kdt.pojavlaunch.value.customcontrols.ControlsLayout
|
||||
android:id="@+id/customctrl_controllayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content">
|
||||
|
||||
</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:layout_width="200dp"
|
||||
|
|
@ -21,6 +33,6 @@
|
|||
android:fitsSystemWindows="true"
|
||||
app:menu="@menu/menu_customctrl"
|
||||
android:id="@+id/customctrl_navigation_view"/>
|
||||
|
||||
|
||||
</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:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:text="GUI"
|
||||
android:text="@string/control_toggle"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:layout_marginLeft="14dp"
|
||||
android:layout_gravity="bottom"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
<!-- Hint -->
|
||||
<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 -->
|
||||
<string name="warning_title">Warning</string>
|
||||
|
|
@ -95,6 +96,7 @@
|
|||
<!-- Global strings -->
|
||||
<string name="global_add">Add</string>
|
||||
<string name="global_edit">Edit</string>
|
||||
<string name="global_name">Name</string>
|
||||
<string name="global_remove">Remove</string>
|
||||
<string name="global_save">Save</string>
|
||||
<string name="global_error_field_empty">This field can\'t be empty</string>
|
||||
|
|
@ -131,6 +133,7 @@
|
|||
|
||||
<!-- MainActivity: Control buttons -->
|
||||
<string name="controls">Controls</string>
|
||||
<string name="control_toggle">GUI</string>
|
||||
<string name="control_keyboard">Keyboard</string>
|
||||
<string name="control_chat">Chat</string>
|
||||
<string name="control_debug">Debug</string>
|
||||
|
|
@ -154,11 +157,13 @@
|
|||
<string name="control_viewout">Log output</string>
|
||||
<string name="control_adebug">PointerCapture Debug</string>
|
||||
<string name="control_customkey">Send custom keycode</string>
|
||||
|
||||
<!--PointerCapture debug</string>-->
|
||||
|
||||
<string name="control_more3"></string>
|
||||
<string name="control_more4"></string>
|
||||
|
||||
<string name="customctrl_keyname">LWJGL Keycode</string>
|
||||
<string name="customctrl_hidden">Hidden</string>
|
||||
|
||||
<!-- Update part (unused now) -->
|
||||
<string name="update_console">Update console</string>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue