From 20a8f192d9f3f146fd16c761bb42a03ab6be5545 Mon Sep 17 00:00:00 2001 From: pelya Date: Tue, 15 Jan 2013 20:41:23 +0200 Subject: [PATCH] Slightly better on-screen key layout customization dialog --- project/java/Settings.java | 38 +++++++++++++++++++++-- project/jni/application/openarena/engine | 2 +- project/res/drawable/rectangle.png | Bin 0 -> 1133 bytes 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 project/res/drawable/rectangle.png diff --git a/project/java/Settings.java b/project/java/Settings.java index b0301669c..9bf56709f 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -66,6 +66,7 @@ import android.app.AlarmManager; import android.util.DisplayMetrics; import android.net.Uri; import java.util.concurrent.Semaphore; +import android.graphics.Color; // TODO: too much code here, split into multiple files, possibly auto-generated menus? class Settings @@ -2194,8 +2195,10 @@ class Settings { MainActivity p; FrameLayout layout = null; - ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length]; + ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length]; Bitmap bmps[] = new Bitmap[Globals.ScreenKbControlsLayout.length]; + ImageView boundary = null; + Bitmap boundaryBmp = null; int currentButton = 0; int buttons[] = { R.drawable.dpad, @@ -2213,6 +2216,12 @@ class Settings p = _p; layout = new FrameLayout(p); p.getVideoLayout().addView(layout); + boundary = new ImageView(p); + boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); + boundary.setScaleType(ImageView.ScaleType.MATRIX); + boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle ); + boundary.setImageBitmap(boundaryBmp); + layout.addView(boundary); currentButton = 0; setupButton(true); } @@ -2240,11 +2249,28 @@ class Settings if( imgs[currentButton] == null ) { imgs[currentButton] = new ImageView(p); - imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); + imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); imgs[currentButton].setScaleType(ImageView.ScaleType.MATRIX); bmps[currentButton] = BitmapFactory.decodeResource( p.getResources(), buttons[currentButton] ); imgs[currentButton].setImageBitmap(bmps[currentButton]); layout.addView(imgs[currentButton]); + boundary.bringToFront(); + } + if( Globals.ScreenKbControlsLayout[currentButton][0] == Globals.ScreenKbControlsLayout[currentButton][2] || + Globals.ScreenKbControlsLayout[currentButton][1] == Globals.ScreenKbControlsLayout[currentButton][3] ) + { + int displayX = 800; + int displayY = 480; + try { + DisplayMetrics dm = new DisplayMetrics(); + p.getWindowManager().getDefaultDisplay().getMetrics(dm); + displayX = dm.widthPixels; + displayY = dm.heightPixels; + } catch (Exception eeeee) {} + Globals.ScreenKbControlsLayout[currentButton][0] = displayX / 2 - displayX / 6; + Globals.ScreenKbControlsLayout[currentButton][2] = displayX / 2 + displayX / 6; + Globals.ScreenKbControlsLayout[currentButton][1] = displayY / 2 - displayY / 4; + Globals.ScreenKbControlsLayout[currentButton][3] = displayY / 2 + displayY / 4; } Matrix m = new Matrix(); RectF src = new RectF(0, 0, bmps[currentButton].getWidth(), bmps[currentButton].getHeight()); @@ -2252,6 +2278,10 @@ class Settings Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]); m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); imgs[currentButton].setImageMatrix(m); + m = new Matrix(); + src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight()); + m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); + boundary.setImageMatrix(m); } public void onTouchEvent(final MotionEvent ev) @@ -2286,6 +2316,10 @@ class Settings Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]); m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); imgs[currentButton].setImageMatrix(m); + m = new Matrix(); + src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight()); + m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); + boundary.setImageMatrix(m); if( ev.getAction() == MotionEvent.ACTION_UP ) setupButton(false); diff --git a/project/jni/application/openarena/engine b/project/jni/application/openarena/engine index 9104eb974..e5f41fe44 160000 --- a/project/jni/application/openarena/engine +++ b/project/jni/application/openarena/engine @@ -1 +1 @@ -Subproject commit 9104eb9749bd9ef21805cc1ac0d5a1840adf46d8 +Subproject commit e5f41fe44f0f9c7d724bd02dd33052eb8688f4a0 diff --git a/project/res/drawable/rectangle.png b/project/res/drawable/rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..1cf77c79bf6f0148947174636ffac88a55511b40 GIT binary patch literal 1133 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}Y)RhkE)4%caKYZ?lNlHo zI14-?iy0WWg+Z8+Vb&Z81_lQ95>H=O_PdPyLeko@@i&VZ7?^)~x;TbJ96mbzV0MhF z%yE0;_h)bWPTuM!wn=lv0?noiH*)wKUB5ixvg}yiz^+~;uKbEDn+@0#yF|L0zL z-TwO=96IL4p?sr>zacD3;_`(y<4 zxma->|2!d&X{n5jzpL4CM~_C99>%rKTR1tj7_BT6Ie4u&IGVVuI088PCr{>*ueCTe zf2ndqIb(|LHGcblXZAkczoYz*Ie+c^dO3SF1GcrgQP~?DpYS#+%f`G^TG~BDNI+uk zMmOOWwqz5>6&ux5IJ9Ks#1}OI24_`}q4m{#}<79U1xX*4FivKbMO8 zZ=Lq1zFwHudcCFp(jXpw{^Q?%{?zy1EBUh}W7IYnG{8 zQ@uWvFf7tzippLh;IV$<$9H#Y8H{G~v^q69EfnbfpmTJ^&)NA!Tv>;1-?@{Ln7A-l zDW^{8*YDrbE*8ed-S6$+@Hm*wPOYt-TVr?r(W4}ujeGarjcaIZ3}0MjWpaffSi0Ta z{VnSb3j>A&@80F*Xp41!eE#m;yKiZS_>0~bf4-JmR#rA+)-0v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