Ver Fonte

feat: CocosWindowViewData,增加showGameHeader参数

XiaodongLin há 7 meses atrás
pai
commit
8e8d8c0ef6

+ 17 - 17
app/src/main/java/com/adealink/weparty/module/game/data/GameEntranceData.kt

@@ -10,23 +10,23 @@ import com.opensource.svgaplayer.utils.UriUtil
  */
 
 enum class GameEntranceType(val type: Int, val gameName: String = "") {
-    LUCKY_FRUIT(0, "lucky_fruit"), // 幸运水果
-    RECHARGE_PACKAGE(1, "recharge_package"), // 充值礼包
-    JACKPOT(2, "jackpot"), // 老虎机
-    DAILY_RECHARGE(3, "daily_recharge"), // 每日充值
-    GREEDY_PRO(4, "greedy_pro"), // 贪吃蛇
-    LUCKY_PRO(6, "lucky_pro"),
-    GREEDY_BOX(7, "greedy_box"),
-    JACKPOT_SLOT(8, "jackpot_slot"),
-    TEEN_PATTI(10, "teen_patti"), // 德州扑克
-    RUSSIAN_ROULETTE(11, "russian_roulette"), // 俄罗斯轮盘
-    TEXAS_COWBOY(12, "texas_cowboy"), // 德州牛仔
-    DRAGON_TIGER_FIGHT(13, "dragon_tiger_fight"), // 龙虎斗
-    ROCKET(14, "rocket"), // 火箭
-    GREEDY_PERSONAL(15, "greedy_personal"), // 贪吃蛇个人房
-    MINI_SLOT(16, "mini_slot"), // 小老虎机
-    MORE_GAME(17, "more_game"), // 更多游戏入口
-    GAME_CENTER(18,"game_center"); //游戏中心
+    LUCKY_FRUIT(0, "LUCKY_FRUIT"), // 幸运水果
+    RECHARGE_PACKAGE(1, "RECHARGE_PACKAGE"), // 充值礼包
+    JACKPOT(2, "JACKPOT"), // 老虎机
+    DAILY_RECHARGE(3, "DAILY_RECHARGE"), // 每日充值
+    GREEDY_PRO(4, "GREEDY_PRO"), // 贪吃蛇
+    LUCKY_PRO(6, "LUCKY_PRO"),
+    GREEDY_BOX(7, "GREEDY_BOX"),
+    JACKPOT_SLOT(8, "JACKPOT_SLOT"),
+    TEEN_PATTI(10, "TEEN_PATTI"), // 德州扑克
+    RUSSIAN_ROULETTE(11, "RUSSIAN_ROULETTE"), // 俄罗斯轮盘
+    TEXAS_COWBOY(12, "TEXAS_COWBOY"), // 德州牛仔
+    DRAGON_TIGER_FIGHT(13, "DRAGON_TIGER_FIGHT"), // 龙虎斗
+    ROCKET(14, "ROCKET"), // 火箭
+    GREEDY_PERSONAL(15, "GREEDY_PERSONAL"), // 贪吃蛇个人房
+    MINI_SLOT(16, "MINI_SLOT"), // 小老虎机
+    MORE_GAME(17, "MORE_GAME"), // 更多游戏入口
+    GAME_CENTER(18, "GAME_CENTER"); // 游戏中心
 
     companion object{
         /**

+ 9 - 4
module/webview/src/main/java/com/adealink/weparty/webview/WebViewDialogFragment.kt

@@ -200,7 +200,8 @@ class WebViewDialogFragment : BottomDialogFragment(R.layout.fragment_webview),
             cocosWebGameViewModel.initGame(
                 binding.webView,
                 binding.root,
-                offlineH5GameInfo.gameType
+                offlineH5GameInfo.gameType,
+                offlineH5GameInfo.showGameHeader
             )
             if (offlineH5GameInfo.gameEntrance == GameEntranceType.JACKPOT_SLOT
                 || offlineH5GameInfo.gameEntrance == GameEntranceType.GREEDY_BOX
@@ -331,14 +332,18 @@ class WebViewDialogFragment : BottomDialogFragment(R.layout.fragment_webview),
         loadHeaderUrl(show, game)
     }
 
-    private fun loadHeaderUrl(show: Boolean, configType: String?) {
+    /**
+     * 注意
+     * @param gameType 游戏名称对应的字符串,不是decorType的数字
+     */
+    private fun loadHeaderUrl(show: Boolean, gameType: String?) {
         showGameHeader = show
         if (showGameHeader) {
             binding.webViewTop.show()
             binding.webViewTop.loadUrl(
                 String.format(
                     UrlConfig.gameAggregation,
-                    configType,
+                    gameType,
                     "1"   //这里改成默认展示关闭按钮
                 )
             )
@@ -373,7 +378,7 @@ class WebViewDialogFragment : BottomDialogFragment(R.layout.fragment_webview),
             binding.webView.loadUrl(url)
             return
         }
-        loadHeaderUrl(offlineH5GameInfo.showGameHeader, offlineH5GameInfo.gameType.toString())
+        loadHeaderUrl(offlineH5GameInfo.showGameHeader, offlineH5GameInfo.gameEntrance.gameName)
         val gameType = offlineH5GameInfo.gameType
         gameLoadingComp?.showProgress(0)
         offlineH5ViewModel.getOfflineH5Url(

+ 1 - 0
module/webview/src/main/java/com/adealink/weparty/webview/cocosgame/data/CocosWindowViewData.kt

@@ -25,6 +25,7 @@ data class CocosWindowViewData(
     @SerializedName("baseUrl") val baseUrl: String = "",
     @SerializedName("uid") val uid: Long = ProfileModule.getMyUid(),
     @SerializedName("room_id") val roomId: Long = 0,
+    @SerializedName("show_game_header") val showGameHeader: Boolean,
     @SerializedName("scheme_host") val schemeHost: String = Router.getDeepLink(""),
     @SerializedName("app_name") val appName: String = AppBaseInfo.appName,
 

+ 5 - 2
module/webview/src/main/java/com/adealink/weparty/webview/cocosgame/viewmodel/BaseCocosWebGameViewModel.kt

@@ -45,11 +45,13 @@ abstract class BaseCocosWebGameViewModel : BaseViewModel(), IBaseCocosWebGameVie
     private var gameContainer: WebView? = null
     private var safeView: View? = null
     private var gameType: Int? = null
+    private var showGameHeader: Boolean = false
 
-    override fun initGame(gameContainer: WebView, boardView: View, gameType: Int) {
+    override fun initGame(gameContainer: WebView, boardView: View, gameType: Int, showGameHeader: Boolean) {
         this.gameContainer = gameContainer
         this.safeView = boardView
         this.gameType = gameType
+        this.showGameHeader =showGameHeader
     }
 
     override fun onGameStartLoading() {
@@ -127,7 +129,8 @@ abstract class BaseCocosWebGameViewModel : BaseViewModel(), IBaseCocosWebGameVie
                 AccountModule.token,
                 App.instance.networkService.replaceUrlHost(App.instance.networkService.baseUrl),
                 ProfileModule.getMyUid(),
-                RoomModule.getJoinedRoomId() ?: 0
+                RoomModule.getJoinedRoomId() ?: 0,
+                showGameHeader
             )
         )
     }

+ 1 - 1
module/webview/src/main/java/com/adealink/weparty/webview/cocosgame/viewmodel/IBaseCocosWebGameViewModel.kt

@@ -14,5 +14,5 @@ interface IBaseCocosWebGameViewModel {
     val exitLD: ExtLiveData<Boolean>
     val playedSoundNameLD: ExtLiveData<String>
 
-    fun initGame(gameContainer: WebView, boardView: View, gameType: Int)
+    fun initGame(gameContainer: WebView, boardView: View, gameType: Int,showGameHeader: Boolean)
 }