From 3cff8727b518545e0010f63cd8df204b60379b34 Mon Sep 17 00:00:00 2001 From: longjunyu2 <877730493@qq.com> Date: Mon, 4 Jan 2021 01:37:32 +0800 Subject: [PATCH] =?UTF-8?q?[app]=201.=E4=BF=AE=E5=A4=8D=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E9=94=AE=E7=9B=98=E6=A8=A1=E6=9D=BF=E6=97=B6=E5=9B=A0=E9=94=AE?= =?UTF-8?q?=E5=80=BC=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=AF=BC=E8=87=B4=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84map=E5=85=83=E7=B4=A0=E6=98=AFnull=E8=80=8C?= =?UTF-8?q?=E9=80=A0=E6=88=90=E7=9A=84=E9=94=AE=E5=80=BC=E8=BD=AC=E5=8C=96?= =?UTF-8?q?=E6=97=B6=E5=8F=91=E7=94=9F=E7=9A=84=E5=B4=A9=E6=BA=83=E3=80=82?= =?UTF-8?q?2.=E4=BF=AE=E5=A4=8D=E8=BD=AC=E6=8D=A2=E6=97=A7=E7=89=88?= =?UTF-8?q?=E9=94=AE=E7=9B=98=E6=A8=A1=E6=9D=BF=E6=97=B6=EF=BC=8C=E5=9B=A0?= =?UTF-8?q?=E6=97=A7=E7=89=88=E7=9A=84=E9=A2=9C=E8=89=B2Hex=E5=80=BC?= =?UTF-8?q?=E4=B8=AD=E5=AD=98=E5=9C=A8=E9=80=8F=E6=98=8E=E5=BA=A6=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=8C=89=E9=94=AE=E9=80=8F=E6=98=8E=E5=BA=A6?= =?UTF-8?q?=E5=B7=AE=E5=BC=82=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=823.?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E8=BD=AC=E6=8D=A2=E6=97=A7=E7=89=88?= =?UTF-8?q?=E6=8C=89=E9=94=AE=E7=9A=84=E9=80=8F=E6=98=8E=E5=BA=A6=E5=88=B0?= =?UTF-8?q?=E6=96=B0=E7=89=88=E6=8C=89=E9=94=AE=E4=B8=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ckb/support/GameButtonConverter.java | 30 +++++++++---------- .../com/aof/mcinabox/utils/ColorUtils.java | 15 ++++++++++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/aof/mcinabox/gamecontroller/ckb/support/GameButtonConverter.java b/app/src/main/java/com/aof/mcinabox/gamecontroller/ckb/support/GameButtonConverter.java index bf15ffe6..e11cb3f8 100644 --- a/app/src/main/java/com/aof/mcinabox/gamecontroller/ckb/support/GameButtonConverter.java +++ b/app/src/main/java/com/aof/mcinabox/gamecontroller/ckb/support/GameButtonConverter.java @@ -1,11 +1,13 @@ package com.aof.mcinabox.gamecontroller.ckb.support; import android.content.Context; +import android.util.Log; import com.aof.mcinabox.gamecontroller.ckb.achieve.CkbManager; import com.aof.mcinabox.gamecontroller.ckb.button.GameButton; import com.aof.mcinabox.gamecontroller.ckb.button.GameButtonOld; import com.aof.mcinabox.gamecontroller.definitions.map.MouseMap; +import com.aof.mcinabox.utils.ColorUtils; import com.google.gson.Gson; import java.io.File; @@ -20,6 +22,7 @@ public class GameButtonConverter { private final Context mContext; + private final static String TAG = "GameButtonConverter"; public GameButtonConverter(Context context){ this.mContext = context; @@ -84,7 +87,8 @@ private GameButtonRecorder getGameButtonRecoderFromOldKeyboardModel(GameButtonOl gbr.keyChars = ""; gbr.keySize = new float[]{gbo.getKeySizeW(), gbo.getKeySizeH()}; gbr.isChars = false; - gbr.alphaSize = GameButton.DEFAULT_ALPHA_SIZE_PT; //透明度采用默认值 + Log.e(TAG, "透明度" + ColorUtils.int2rgba(ColorUtils.hex2Int(gbo.getColorhex()))[3]); + gbr.alphaSize = (int)((ColorUtils.int2rgba(ColorUtils.hex2Int(gbo.getColorhex()))[3]) / 255f * 100); //透明度从颜色值Hex中取出,然后转为不透明度的百分比 gbr.cornerRadius = (gbo.getCornerRadius() / 180) * 100; //圆角值转化为百分比 gbr.designIndex = GameButton.DEFAULT_DESIGN_INDEX; //主题采用默认值 gbr.isHide = gbo.isHide(); @@ -92,42 +96,38 @@ private GameButtonRecorder getGameButtonRecoderFromOldKeyboardModel(GameButtonOl gbr.isViewerFollow = false; //视角跟随默认关闭 String[] keyMap = new String[GameButton.MAX_KEYMAP_SIZE]; + Arrays.fill(keyMap, ""); + int[] keyTypes = new int[GameButton.MAX_KEYMAP_SIZE]; - if (gbo.getKeyMain().equals("空")){ - //nothing - }else if (gbo.getKeyMain().equals(OLD_MOUSE_PRI)){ + if (gbo.getKeyMain().equals(OLD_MOUSE_PRI)){ keyMap[0] = MouseMap.MOUSEMAP_BUTTON_LEFT; keyTypes[0] = GameButton.MOUSE_TYPE; }else if (gbo.getKeyMain().equals(OLD_MOUSE_SEC)){ keyMap[0] = MouseMap.MOUSEMAP_BUTTON_RIGHT; keyTypes[0] = GameButton.MOUSE_TYPE; - }else{ + }else if(!gbo.getKeyMain().equals("空")){ keyMap[0] = gbo.getKeyMain(); keyTypes[0] = GameButton.KEY_TYPE; } - if(gbo.isMult()){ - if (gbo.getSpecialOne().equals("空")){ - //nothing - }else if (gbo.getSpecialOne().equals(OLD_MOUSE_PRI)){ + if (gbo.isMult()){ + if (gbo.getSpecialOne().equals(OLD_MOUSE_PRI)){ keyMap[1] = MouseMap.MOUSEMAP_BUTTON_LEFT; keyTypes[1] = GameButton.MOUSE_TYPE; }else if (gbo.getSpecialOne().equals(OLD_MOUSE_SEC)){ keyMap[1] = MouseMap.MOUSEMAP_BUTTON_RIGHT; keyTypes[1] = GameButton.MOUSE_TYPE; - }else{ + }else if (!gbo.getSpecialOne().equals("空")){ keyMap[1] = gbo.getKeyMain(); keyTypes[1] = GameButton.KEY_TYPE; } - if (gbo.getSpecialTwo().equals("空")){ - //nothing - }else if (gbo.getSpecialTwo().equals(OLD_MOUSE_PRI)){ + if (gbo.getSpecialTwo().equals(OLD_MOUSE_PRI)){ keyMap[2] = MouseMap.MOUSEMAP_BUTTON_LEFT; keyTypes[2] = GameButton.MOUSE_TYPE; }else if (gbo.getSpecialOne().equals(OLD_MOUSE_SEC)){ keyMap[2] = MouseMap.MOUSEMAP_BUTTON_RIGHT; keyTypes[2] = GameButton.MOUSE_TYPE; - }else{ + }else if (!gbo.getSpecialTwo().equals("空")){ keyMap[2] = gbo.getKeyMain(); keyTypes[2] = GameButton.KEY_TYPE; } @@ -139,7 +139,7 @@ private GameButtonRecorder getGameButtonRecoderFromOldKeyboardModel(GameButtonOl gbr.show = GameButton.SHOW_ALL; //默认全局显示 gbr.textColor = gbo.getTextColorHex(); gbr.themeColors = new String[CkbThemeRecorder.COLOR_INDEX_LENGTH]; - gbr.themeColors[0] = gbo.getColorhex(); //默认只给主题的第一个颜色为赋值 + gbr.themeColors[0] = new StringBuilder(gbo.getColorhex().substring(3)).insert(0, '#').toString(); //截掉原来的透明度 gbr.textSize = GameButton.DEFAULT_TEXT_SIZE_SP; //文字大小采用默认值 return gbr; diff --git a/app/src/main/java/com/aof/mcinabox/utils/ColorUtils.java b/app/src/main/java/com/aof/mcinabox/utils/ColorUtils.java index 0cf9ff2a..bb329fcd 100644 --- a/app/src/main/java/com/aof/mcinabox/utils/ColorUtils.java +++ b/app/src/main/java/com/aof/mcinabox/utils/ColorUtils.java @@ -132,4 +132,19 @@ public static int rgb2Int(int[] rgb){ return colorInt; } + public static int[] int2rgba(int colorInt){ + int[] rgba = new int[4]; + + int red = Color.red(colorInt); + int green = Color.green(colorInt); + int blue = Color.blue(colorInt); + int alpha = Color.alpha(colorInt); + rgba[0] = red; + rgba[1] = green; + rgba[2] = blue; + rgba[3] = alpha; + + return rgba; + } + }