修复了一些BUG优化了一下社区的UI

This commit is contained in:
muqing 2024-04-18 14:11:54 +08:00
parent 0f7c318850
commit bef72863ae
35 changed files with 473 additions and 249 deletions

View File

@ -32,7 +32,7 @@ android {
minSdkVersion 23
targetSdkVersion 33
versionCode 28
versionName "2.1.1 Bata6(2024-2-17)"
versionName "2.1.1 Bata6(2024-4-18)"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -43,6 +43,8 @@
<activity
android:name=".CustomizeEditTextActivity"
android:exported="false"/>
<!-- 模组界面-->
<activity android:name=".fragments.WarehouseFragment" />
<activity
android:name=".SearchActivity"
android:exported="false"/>

View File

@ -1,6 +1,5 @@
package com.coldmint.rust.pro
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
@ -27,7 +26,6 @@ import com.coldmint.rust.core.debug.LogCat
import com.coldmint.rust.core.interfaces.ApiCallBack
import com.coldmint.rust.core.interfaces.UnzipListener
import com.coldmint.rust.core.tool.AppOperator
import com.coldmint.rust.core.tool.DebugHelper
import com.coldmint.rust.core.tool.FileOperator
import com.coldmint.rust.core.web.AppUpdate
import com.coldmint.rust.core.web.ServerConfiguration
@ -42,12 +40,12 @@ import com.google.android.material.color.DynamicColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.google.gson.Gson
//import com.gyf.immersionbar.ImmersionBar
import org.json.JSONObject
import java.io.File
import java.util.concurrent.Executors
import java.util.zip.ZipEntry
class MainActivity : BaseActivity<ActivityMainBinding>() {
private lateinit var appBarConfiguration: AppBarConfiguration
@ -293,9 +291,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
false
}*/
/* template.setOnMenuItemClickListener {
/* template.setOnMenuItemClickListener {
viewBinding.mainButton.postOnAnimationDelayed({
// viewBinding.tabLayout.isVisible = true
// viewBinding.tabLayout.isVisible = true
viewBinding.mainButton.show()
}, hideViewDelay)
false
@ -628,13 +626,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
return true
}
/*不知道干什么的代码
/*不知道干什么的代码
override fun onSupportNavigateUp(): Boolean {
val navController = findNavController(R.id.baseFragment)
return navController.navigateUp(appBarConfiguration)
|| super.onSupportNavigateUp()
}
*/
*/
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.search) {
@ -755,6 +753,4 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
startViewModel.initAllData()
}
}
}

View File

@ -46,7 +46,7 @@ class SearchActivity : BaseActivity<ActivitySearchBinding>() {
viewBinding.hotSearchView2.layoutManager = FlexboxLayoutManager(this)
viewBinding.hotSearchView2.adapter = adapter
viewBinding.deleat.setOnClickListener {
val dialog = MaterialAlertDialogBuilder(this@SearchActivity);
val dialog = MaterialAlertDialogBuilder(this@SearchActivity)
dialog.setTitle(R.string.search_history)
dialog.setMessage(R.string.clear_all_history)
dialog.setPositiveButton(R.string.dialog_ok) { _, _ ->
@ -87,6 +87,9 @@ class SearchActivity : BaseActivity<ActivitySearchBinding>() {
val editor = getSharedPreferences(sharedPreferencesKey, Context.MODE_PRIVATE).edit()
editor.putStringSet("data", list.toSet())
editor.apply()
if (!viewBinding.searchView.isVisible) {
viewBinding.searchLayout.isVisible = true
}
}
fun search(string: String) {
@ -128,7 +131,7 @@ class SearchActivity : BaseActivity<ActivitySearchBinding>() {
override fun getItemCount(): Int {
val empty = list.isEmpty()
viewBinding.textview1Text1.isVisible = empty
viewBinding.searchLayout.isVisible = !empty
viewBinding.deleat.isVisible = !empty
return list.size
}

View File

@ -2,19 +2,22 @@ package com.coldmint.rust.pro
import android.annotation.SuppressLint
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.*
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import com.coldmint.dialog.CoreDialog
import com.coldmint.rust.core.ModClass
import com.coldmint.rust.core.SourceFile
import com.coldmint.rust.core.turret.CoordinateData
import com.coldmint.rust.core.turret.TurretManager
import com.coldmint.rust.pro.adapters.DesignAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityTurretDesignBinding
import com.coldmint.rust.pro.fragments.EditTurretInfoFragment
import com.coldmint.rust.pro.tool.GlobalMethod
import com.google.android.material.snackbar.Snackbar
import java.io.File
/**
@ -24,34 +27,30 @@ class TurretDesignActivity : BaseActivity<ActivityTurretDesignBinding>() {
private lateinit var turretManager: TurretManager
@SuppressLint("RestrictedApi")
@SuppressLint("RestrictedApi", "SetTextI18n")
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) {
setReturnButton()
title = getString(R.string.turret_design)
val modPath = intent.getStringExtra("modPath")
val filePath = intent.getStringExtra("filePath")
if (modPath == null) {
showError("请设置模组路径")
return
}
if (filePath == null) {
showError("请设置文件路径")
return
}
val modClass = ModClass(File(modPath))
val sourceFile = SourceFile(File(filePath), modClass)
val mainImage = sourceFile.findResourceFilesFromSection("image", "graphics", false)
if (mainImage.isNullOrEmpty()) {
showError(getString(R.string.please_set_main_image))
return
} else {
val file = mainImage[0]
if (!file.exists()){
if (!file.exists()) {
showError(getString(R.string.file_not_exist))
return
}
@ -63,58 +62,63 @@ class TurretDesignActivity : BaseActivity<ActivityTurretDesignBinding>() {
viewBinding.turretSketchpadView
)
turretManager
.setCoordinateChangeListener { gameCoordinateData, turretData ->
.setCoordinateChangeListener { gameCoordinateData, _ ->
viewBinding.infoView.text =
"x:${gameCoordinateData.x} y:${gameCoordinateData.y}"
}
//设置自动完成
viewBinding.autoCompleteText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(
s: CharSequence?,
start: Int,
count: Int,
after: Int
) {
}
override fun onTextChanged(
s: CharSequence?,
start: Int,
before: Int,
count: Int
) {
}
override fun afterTextChanged(s: Editable?) {
turretManager.useTurret(s.toString())
}
})
val nameList = ArrayList<String>()
var isFirst = true
val designAdapter = DesignAdapter(object : DesignAdapter.Click {
override fun onclick(str: String) {
turretManager.useTurret(str)
turretManager.turretList.forEach lab@{
if (it.name == str) {
viewBinding.infoView.text =
"x:${it.gameCoordinateData.x} y:${it.gameCoordinateData.y}"
return@lab
}
}
}
override fun onclickImage() {
turretManager.turretList.forEach{
val turretView = turretManager.getTurretView(it.name)
turretView?.invalidate()
}
}
})
turretManager.turretList.forEach {
if (isFirst) {
viewBinding.autoCompleteText.setText(it.name)
designAdapter.string = it
turretManager.useTurret(it.name)
viewBinding.infoView.text =
"x:${it.gameCoordinateData.x} y:${it.gameCoordinateData.y}"
isFirst = false
}
nameList.add(it.name)
}
viewBinding.autoCompleteText.setSimpleItems(nameList.toTypedArray())
}
// viewBinding.autoCompleteText.setSimpleItems(nameList.toTypedArray())
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
viewBinding.recyclerView.isNestedScrollingEnabled = false
designAdapter.list = turretManager.turretList
viewBinding.recyclerView.adapter = designAdapter
viewBinding.button.setOnClickListener {
val data = turretManager.getTurretView(viewBinding.autoCompleteText.text.toString())
val data = turretManager.getTurretView(designAdapter.string.name)
if (data != null) {
val editTurretInfoFragment = EditTurretInfoFragment(data)
val editTurretInfoFragment = EditTurretInfoFragment(data,object :EditTurretInfoFragment.ButtonClick{
override fun onSaveButtonClick(x: Int, y: Int) {
viewBinding.infoView.text = "x:$x y:$y"
}
})
editTurretInfoFragment.show(supportFragmentManager, "Edit")
} else {
Toast.makeText(this, R.string.not_find_turret, Toast.LENGTH_SHORT).show()
}
}
}
}
}
@ -155,7 +159,7 @@ class TurretDesignActivity : BaseActivity<ActivityTurretDesignBinding>() {
/**
* 保存数据
*/
fun saveData() {
private fun saveData() {
turretManager.saveChange()
finish()
}
@ -167,11 +171,13 @@ class TurretDesignActivity : BaseActivity<ActivityTurretDesignBinding>() {
!viewBinding.turretSketchpadView.drawCoordinate
item.isChecked = viewBinding.turretSketchpadView.drawCoordinate
}
R.id.show_guides -> {
viewBinding.turretSketchpadView.drawAuxiliaryLine =
!viewBinding.turretSketchpadView.drawAuxiliaryLine
item.isChecked = viewBinding.turretSketchpadView.drawAuxiliaryLine
}
android.R.id.home -> {
saveData()
}

View File

@ -1,9 +1,13 @@
package com.coldmint.rust.pro.adapters
import android.os.Parcelable
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.coldmint.rust.pro.fragments.*
import com.coldmint.rust.pro.fragments.FollowFragment
import com.coldmint.rust.pro.fragments.NullFragment
import com.coldmint.rust.pro.fragments.RankingFragment
import com.coldmint.rust.pro.fragments.RecommendedFragment
import com.coldmint.rust.pro.fragments.UserInfoFragment
class CommunityAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
override fun getItemCount(): Int {

View File

@ -0,0 +1,71 @@
package com.coldmint.rust.pro.adapters
import android.annotation.SuppressLint
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.coldmint.rust.core.turret.TurretData
import com.coldmint.rust.pro.R
import com.coldmint.rust.pro.databinding.ItemTabBinding
import com.muqing.VH
import com.muqing.gj
/**
* @author Cold Mint
* @date 2022/1/10 8:49
*/
class DesignAdapter(private val onclick: Click) : RecyclerView.Adapter<VH<ItemTabBinding>>() {
var list: ArrayList<TurretData> = arrayListOf()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH<ItemTabBinding> {
return VH(ItemTabBinding.inflate(LayoutInflater.from(parent.context), parent, false))
}
override fun getItemCount(): Int {
return list.size
}
lateinit var string: TurretData
@SuppressLint("NotifyDataSetChanged")
override fun onBindViewHolder(holder: VH<ItemTabBinding>, position: Int) {
holder.binging.button.text = list[position].name
gj.sc(list[position].imageFile)
if (string == list[position]) {
holder.binging.root.isEnabled = false
holder.binging.root.setCardBackgroundColor(ContextCompat.getColor(holder.itemView.context, R.color.material_grey_200))
} else {
holder.binging.root.isEnabled = true
val typedValue = TypedValue()
holder.itemView.context.theme.resolveAttribute(R.attr.colorPrimaryContainer, typedValue, true)
val colorPrimary = typedValue.data
holder.binging.root.setCardBackgroundColor(colorPrimary)
}
holder.binging.root.setOnClickListener {
string = list[holder.absoluteAdapterPosition]
notifyDataSetChanged()
onclick.onclick(string.name)
//todo
}
if (list[holder.absoluteAdapterPosition].isImage) {
holder.binging.imageview.setImageResource(R.drawable.visibility)
}else{
holder.binging.imageview.setImageResource(R.drawable.visibility_off)
}
holder.binging.imageview.setOnClickListener{
list[holder.absoluteAdapterPosition].isImage = !list[holder.absoluteAdapterPosition].isImage
notifyItemChanged(holder.absoluteAdapterPosition)
onclick.onclickImage()
}
}
interface Click {
fun onclick(str: String)
fun onclickImage()
}
}

View File

@ -1,5 +1,6 @@
package com.coldmint.rust.pro.adapters
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.coldmint.rust.pro.fragments.*

View File

@ -56,7 +56,6 @@ abstract class BaseActivity<ViewBingType : ViewBinding> :
finish()
}
dialog.show()
}
}

View File

@ -4,20 +4,13 @@ import android.R
import android.content.Context
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.*
import android.widget.ArrayAdapter
import android.widget.Button
import androidx.appcompat.app.AlertDialog
import androidx.core.view.isVisible
import com.coldmint.dialog.AppDialog
import com.coldmint.dialog.BaseAppDialog
import com.coldmint.dialog.BaseBottomDialog
import com.coldmint.dialog.InputDialog
import com.coldmint.rust.pro.databinding.DialogCommentBinding
import com.coldmint.rust.pro.tool.LinkAutoCompleteHelper
import com.coldmint.rust.pro.tool.TextStyleMaker
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.textfield.TextInputLayout
@ -68,7 +61,7 @@ class CommentDialog(context: Context) : BaseAppDialog<CommentDialog>(context) {
//已闭合{}。
}else{
//正在输入内容
adapter.add(text + '}')
adapter.add("$text}")
}
} else {
//没有指定{开始位置

View File

@ -2,6 +2,7 @@ package com.coldmint.rust.pro.fragments
import android.os.Bundle
import android.view.LayoutInflater
import androidx.viewpager2.widget.ViewPager2
import com.coldmint.rust.pro.R
import com.coldmint.rust.pro.adapters.CommunityAdapter
import com.coldmint.rust.pro.base.BaseFragment
@ -13,26 +14,6 @@ class CommunityFragment : BaseFragment<FragmentCommunityBinding>() {
if (!isAdded) {
return
}
TabLayoutMediator(viewBinding.tabLayout, viewBinding.pager)
{ tab, position ->
when (position) {
0 -> {
tab.text = getText(R.string.recommended)
}
1 -> {
tab.text = getText(R.string.follow)
}
2 -> {
tab.text = getText(R.string.ranking)
}
3 -> {
tab.text = getText(R.string.my)
}
}
}.attach()
/* else {
viewBinding.pager.postDelayed({ loadTab() }, MainActivity.linkInterval)
}*/
@ -46,6 +27,43 @@ class CommunityFragment : BaseFragment<FragmentCommunityBinding>() {
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
viewBinding.pager.adapter = CommunityAdapter(this)
viewBinding.pager.isSaveEnabled = false
viewBinding.pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
when (position) {
0 -> {
viewBinding.bottomnavigationView.selectedItemId = R.id.action_recommended
}
1 -> {
viewBinding.bottomnavigationView.selectedItemId = R.id.action_follow
}
2 -> {
viewBinding.bottomnavigationView.selectedItemId = R.id.action_ranking
}
3 -> {
viewBinding.bottomnavigationView.selectedItemId = R.id.action_my
}
}
}
})
viewBinding.bottomnavigationView.setOnItemSelectedListener {
when (it.itemId) {
R.id.action_recommended -> {
viewBinding.pager.currentItem = 0
}
R.id.action_follow -> {
viewBinding.pager.currentItem = 1
}
R.id.action_ranking -> {
viewBinding.pager.currentItem = 2
}
R.id.action_my -> {
viewBinding.pager.currentItem = 3
}
}
true
}
loadTab()
}
}

View File

@ -7,25 +7,22 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.coldmint.rust.core.turret.CoordinateData
import com.coldmint.rust.core.turret.TurretData
import com.coldmint.rust.core.turret.TurretView
import com.coldmint.rust.pro.R
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentEditTurretInfoBinding
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
/**
* 编辑炮塔信息碎片
* @property fragmentEditTurretInfoBinding FragmentEditTurretInfoBinding
*/
class EditTurretInfoFragment(val turretView: TurretView) : BottomSheetDialogFragment() {
class EditTurretInfoFragment(private val turretView: TurretView, private val buttonclick: ButtonClick) : BottomSheetDialogFragment() {
private lateinit var fragmentEditTurretInfoBinding: FragmentEditTurretInfoBinding
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
fragmentEditTurretInfoBinding =
FragmentEditTurretInfoBinding.inflate(layoutInflater, container, false)
return fragmentEditTurretInfoBinding.root
@ -84,8 +81,12 @@ class EditTurretInfoFragment(val turretView: TurretView) : BottomSheetDialogFrag
val x = fragmentEditTurretInfoBinding.xInputEditText.text.toString().toInt()
val y = fragmentEditTurretInfoBinding.yInputEditText.text.toString().toInt()
turretView.setGameCoordinateData(CoordinateData(x, y))
buttonclick.onSaveButtonClick(x, y)
dialog?.dismiss()
}
}
interface ButtonClick {
fun onSaveButtonClick(x: Int, y: Int)
}
}

View File

@ -1,14 +1,9 @@
package com.coldmint.rust.pro.fragments
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.widget.PopupMenu
import android.widget.Toast
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.coldmint.rust.core.dataBean.mod.WebModListData
import com.coldmint.rust.core.interfaces.ApiCallBack
@ -20,14 +15,13 @@ import com.coldmint.rust.pro.adapters.WebModAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentRankingBinding
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.chip.Chip
import me.zhanghai.android.fastscroll.FastScrollerBuilder
/**
* 排行榜
*/
class RankingFragment : BaseFragment<FragmentRankingBinding>() {
var webModAdapter: WebModAdapter? = null
private var webModAdapter: WebModAdapter? = null
var lastOffset = 0
var lastPosition = 0
var linearLayoutManager: StableLinearLayoutManager? = null
@ -39,7 +33,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
viewBinding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
var layoutManager = viewBinding.recyclerView.layoutManager
val layoutManager = viewBinding.recyclerView.layoutManager
if (layoutManager != null) {
//获取第一个可视视图
val topView = layoutManager.getChildAt(0)
@ -54,25 +48,25 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
loadMods()
viewBinding.swipeRefreshLayout.isRefreshing = false
}
viewBinding.downloadChip.setOnCheckedChangeListener { buttonView, isChecked ->
viewBinding.downloadChip.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
sortMode = WebMod.SortMode.Download_Number
loadMods()
}
}
viewBinding.unitChip.setOnCheckedChangeListener { buttonView, isChecked ->
viewBinding.unitChip.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
sortMode = WebMod.SortMode.Unit_Number
loadMods()
}
}
viewBinding.coinChip.setOnCheckedChangeListener { buttonView, isChecked ->
viewBinding.coinChip.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
sortMode = WebMod.SortMode.Coin_Number
loadMods()
}
}
viewBinding.updateChip.setOnCheckedChangeListener { buttonView, isChecked ->
viewBinding.updateChip.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
sortMode = WebMod.SortMode.Update_Number
loadMods()
@ -82,7 +76,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
}
fun loadMods() {
private fun loadMods() {
viewBinding.progressBar.isVisible = true
viewBinding.textview.isVisible = false
viewBinding.swipeRefreshLayout.isVisible = false
@ -93,7 +87,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
}
if (t.code == ServerConfiguration.Success_Code) {
val list = t.data
if (list != null && list.isNotEmpty()) {
if (!list.isNullOrEmpty()) {
viewBinding.progressBar.isVisible = false
viewBinding.textview.isVisible = false
viewBinding.swipeRefreshLayout.isVisible = true
@ -134,7 +128,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
webModAdapter!!.setNewDataList(dataList)
webModAdapter!!
}
adapter.setItemEvent { i, webModItemBinding, viewHolder, data ->
adapter.setItemEvent { _, webModItemBinding, _, data ->
webModItemBinding.root.setOnClickListener {
val bundle = Bundle()
bundle.putString("modId", data.id)
@ -157,7 +151,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
viewBinding.swipeRefreshLayout.isVisible = false
viewBinding.textview.isVisible = true
if (textRes == null) {
viewBinding.textview.setText(textRes)
viewBinding.textview.text = textRes
} else {
viewBinding.textview.text = text ?: ""
}

View File

@ -37,7 +37,7 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application
*/
var targetFile: File? = null
val codeTranslate by lazy {
private val codeTranslate by lazy {
val c = CodeTranslate(getApplication())
c.setCompileErrorRecordFun {
//将信息上传至FireBase
@ -70,6 +70,7 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application
/**
* 获取当前使用的apk包存放目录
*/
@Suppress("unused")
val apkFolder by lazy {
GameSynchronizer.getPackAgeFolder(
getApplication(), AppSettings.getValue(
@ -97,12 +98,13 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application
* @return String?
*/
fun getNowOpenFilePath(): String {
val temPath = nowFilePath
/* val temPath = nowFilePath
return if (temPath == null) {
""
} else {
temPath
}
}*/
return nowFilePath ?: ""
}
@ -403,7 +405,7 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application
Locale.getDefault().language
)
) + " (" + file.file.name + ")"
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
val historyDao = fileDataBase.getHistoryDao()
val newHistoryRecord = HistoryRecord(
path,

View File

@ -0,0 +1,12 @@
package com.muqing;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewbinding.ViewBinding;
public class VH<Binging extends ViewBinding> extends RecyclerView.ViewHolder {
public Binging binging;
public VH(@NonNull Binging itemView) {
super(itemView.getRoot());
this.binging = itemView;
}
}

View File

@ -20,7 +20,7 @@ import java.util.Collections;
/** @noinspection unused*/
public class gj {
public static String log_TAB = "打印";
public final static String log_TAB = "输出";
public static void ts(Context a, Object b) {
Toast.makeText(a, b.toString(), Toast.LENGTH_SHORT).show();

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M38,706Q38,671 56,642.5Q74,614 106,600Q179,568 237.5,554Q296,540 358,540Q420,540 478,554Q536,568 609,600Q641,614 659.5,642.5Q678,671 678,706L678,740Q678,764.75 660.38,782.38Q642.75,800 618,800L98,800Q73.25,800 55.63,782.38Q38,764.75 38,740L38,706ZM862,800L724,800Q729,785 733.5,770.5Q738,756 738,740L738,706Q738,643 709,604.5Q680,566 622,540Q691,548 752,562Q813,576 851,596Q884,615 903,643Q922,671 922,706L922,740Q922,764.75 904.38,782.38Q886.75,800 862,800ZM358,479Q292,479 250,437Q208,395 208,329Q208,263 250,221Q292,179 358,179Q424,179 466,221Q508,263 508,329Q508,395 466,437Q424,479 358,479ZM718,329Q718,395 676,437Q634,479 568,479Q557,479 543.5,477.5Q530,476 519,472Q543,447 555.5,410.5Q568,374 568,329Q568,284 555.5,249.5Q543,215 519,186Q530,183 543.5,181Q557,179 568,179Q634,179 676,221Q718,263 718,329ZM98,740L618,740L618,706Q618,690 608.5,675Q599,660 585,654Q513,622 464,611Q415,600 358,600Q301,600 251.5,611Q202,622 130,654Q116,660 107,675Q98,690 98,706L98,740ZM358,419Q397,419 422.5,393.5Q448,368 448,329Q448,290 422.5,264.5Q397,239 358,239Q319,239 293.5,264.5Q268,290 268,329Q268,368 293.5,393.5Q319,419 358,419ZM358,740L358,740L358,740Q358,740 358,740Q358,740 358,740Q358,740 358,740Q358,740 358,740Q358,740 358,740Q358,740 358,740Q358,740 358,740Q358,740 358,740L358,740ZM358,329Q358,329 358,329Q358,329 358,329Q358,329 358,329Q358,329 358,329Q358,329 358,329Q358,329 358,329Q358,329 358,329Q358,329 358,329Z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M220,780L370,780L370,560Q370,547.25 378.63,538.63Q387.25,530 400,530L560,530Q572.75,530 581.38,538.63Q590,547.25 590,560L590,780L740,780L740,390Q740,390 740,390Q740,390 740,390L480,195Q480,195 480,195Q480,195 480,195L220,390Q220,390 220,390Q220,390 220,390L220,780ZM160,780L160,390Q160,375.75 166.38,363Q172.75,350.25 184,342L444,147Q459.68,135 479.84,135Q500,135 516,147L776,342Q787.25,350.25 793.63,363Q800,375.75 800,390L800,780Q800,804.75 782.38,822.38Q764.75,840 740,840L560,840Q547.25,840 538.63,831.38Q530,822.75 530,810L530,590Q530,590 530,590Q530,590 530,590L430,590Q430,590 430,590Q430,590 430,590L430,810Q430,822.75 421.38,831.38Q412.75,840 400,840L220,840Q195.25,840 177.63,822.38Q160,804.75 160,780ZM480,487L480,487L480,487Q480,487 480,487Q480,487 480,487L480,487L480,487L480,487L480,487Q480,487 480,487Q480,487 480,487L480,487Q480,487 480,487Q480,487 480,487L480,487L480,487Z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M140,780L327,780Q327,780 327,780Q327,780 327,780L327,420Q327,420 327,420Q327,420 327,420L140,420Q140,420 140,420Q140,420 140,420L140,780Q140,780 140,780Q140,780 140,780ZM387,780L573,780Q573,780 573,780Q573,780 573,780L573,180Q573,180 573,180Q573,180 573,180L387,180Q387,180 387,180Q387,180 387,180L387,780Q387,780 387,780Q387,780 387,780ZM633,780L820,780Q820,780 820,780Q820,780 820,780L820,500Q820,500 820,500Q820,500 820,500L633,500Q633,500 633,500Q633,500 633,500L633,780Q633,780 633,780Q633,780 633,780ZM80,780L80,420Q80,395.25 97.63,377.63Q115.25,360 140,360L327,360L327,180Q327,155.25 344.63,137.63Q362.25,120 387,120L573,120Q597.75,120 615.38,137.63Q633,155.25 633,180L633,440L820,440Q844.75,440 862.38,457.63Q880,475.25 880,500L880,780Q880,804.75 862.38,822.38Q844.75,840 820,840L140,840Q115.25,840 97.63,822.38Q80,804.75 80,780Z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M360,694L590,694Q604,694 613.5,688Q623,682 630,670L708,488Q710,483 711.5,473Q713,463 713,458L713,434Q713,420 706.5,413.5Q700,407 686,407L472,407L501,269Q503,261 501,254Q499,247 494,242L473,220L312,394Q308,402 304,410Q300,418 300,427L300,634Q300,657 318,675.5Q336,694 360,694ZM480,880Q398,880 325,848.5Q252,817 197.5,762.5Q143,708 111.5,635Q80,562 80,480Q80,397 111.5,324Q143,251 197.5,197Q252,143 325,111.5Q398,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,562 848.5,635Q817,708 763,762.5Q709,817 636,848.5Q563,880 480,880ZM480,820Q622,820 721,720.5Q820,621 820,480Q820,338 721,239Q622,140 480,140Q339,140 239.5,239Q140,338 140,480Q140,621 239.5,720.5Q339,820 480,820ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M480.12,630Q551,630 600.5,580.38Q650,530.77 650,459.88Q650,389 600.38,339.5Q550.77,290 479.88,290Q409,290 359.5,339.62Q310,389.23 310,460.12Q310,531 359.62,580.5Q409.23,630 480.12,630ZM479.77,572Q433,572 400.5,539.27Q368,506.53 368,459.77Q368,413 400.73,380.5Q433.47,348 480.23,348Q527,348 559.5,380.73Q592,413.47 592,460.23Q592,507 559.27,539.5Q526.53,572 479.77,572ZM480,760Q345,760 234.5,684Q124,608 57,490Q53,482.88 51,475.35Q49,467.83 49,459.92Q49,452 51,444.54Q53,437.07 57,430Q124,312 234.5,236Q345,160 480,160Q615,160 725.5,236Q836,312 903,430Q907,437.13 909,444.65Q911,452.17 911,460.08Q911,468 909,475.46Q907,482.93 903,490Q836,608 725.5,684Q615,760 480,760ZM480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460ZM479.83,700Q601,700 702.5,634.5Q804,569 857,460Q804,351 702.67,285.5Q601.34,220 480.17,220Q359,220 257.5,285.5Q156,351 102,460Q156,569 257.33,634.5Q358.66,700 479.83,700Z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M600,340Q629,369 642.5,411.5Q656,454 647,496Q647,509 638.5,517.5Q630,526 617,526Q604,526 595.5,517.5Q587,509 587,496Q598,462 589.5,431.5Q581,401 559,380Q538,358 507,350Q476,342 443,353Q430,353 421.5,344.5Q413,336 413,323Q413,310 421.5,301.5Q430,293 443,293Q485,284 528,297.5Q571,311 600,340ZM490,220Q458,220 426,223Q394,226 363,236Q351,240 339,235Q327,230 322,219Q317,208 322,196.5Q327,185 338,181Q373,170 410,165Q447,160 485,160Q622,160 734.5,235.5Q847,311 907,434Q910,440 912,446.5Q914,453 914,460Q914,467 912.5,473.5Q911,480 908,486Q885,535 853,576.5Q821,618 779,653Q770,661 759,658.5Q748,656 741,647Q734,638 735.5,627Q737,616 746,608Q782,578 811,541.5Q840,505 857,460Q808,351 709,285.5Q610,220 490,220ZM480,760Q344,760 232.5,684Q121,608 55,488Q51,481 49.5,474.5Q48,468 48,460Q48,452 50,445.5Q52,439 55,432Q79,384 110.5,341.5Q142,299 182,264L77,159Q68,150 68.5,138Q69,126 77,117Q86,108 98.5,108Q111,108 120,117L836,833Q844,841 844,852.5Q844,864 836,873Q828,883 815.5,883Q803,883 794,874L648,731Q607,746 565,753Q523,760 480,760ZM223,306Q182,335 151,374Q120,413 102,460Q154,572 258.5,636Q363,700 488,700Q517,700 546,698.5Q575,697 601,684L537,620Q523,626 508.5,628Q494,630 480,630Q409,630 359.5,580.5Q310,531 310,460Q310,446 312.5,431.5Q315,417 320,403L223,306ZM528,448L528,448Q528,448 528,448Q528,448 528,448Q528,448 528,448Q528,448 528,448Q528,448 528,448Q528,448 528,448ZM412,506Q412,506 412,506Q412,506 412,506L412,506Q412,506 412,506Q412,506 412,506Q412,506 412,506Q412,506 412,506Z"/>
</vector>

View File

@ -4,8 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:fitsSystemWindows="false"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
@ -32,7 +32,6 @@
<com.google.android.material.navigation.NavigationView
android:id="@+id/navaiagtion"
android:fitsSystemWindows="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"

View File

@ -50,9 +50,11 @@
android:orientation="vertical">
<LinearLayout
android:id="@+id/searchLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:ignore="UseCompoundDrawables">
card_view:ignore="UseCompoundDrawables"
android:layout_marginBottom="9dp">
<TextView
android:id="@+id/textview1"
@ -72,15 +74,6 @@
card_view:ignore="ContentDescription" />
</LinearLayout>
<TextView
android:id="@+id/textview1_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="没有任何记录"
android:textSize="20sp"
card_view:ignore="HardcodedText" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/hotSearchView2"
android:layout_width="match_parent"

View File

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
tools:context=".TurretDesignActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
@ -18,30 +18,31 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
tools:itemCount="1"
android:layout_width="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_height="wrap_content" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:paddingRight="16dp"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/cardView"
android:layout_alignParentTop="true"
android:layout_gravity="center">
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/cardView"
app:layout_constraintTop_toTopOf="parent">
<com.coldmint.rust.core.turret.TurretSketchpadView
android:id="@+id/turretSketchpadView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<com.google.android.material.card.MaterialCardView
@ -50,9 +51,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
app:cardUseCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
@ -68,21 +68,6 @@
android:layout_height="wrap_content"
android:text="@string/control_panel" />
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:hint="@string/turret"
android:layout_height="wrap_content">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:layout_width="match_parent"
android:inputType="none"
android:id="@+id/autoCompleteText"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -103,25 +88,15 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="@string/edit" />
</RelativeLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- <com.google.android.material.floatingactionbutton.FloatingActionButton-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="right|bottom"-->
<!-- android:layout_margin="16dp"-->
<!-- android:src="@drawable/add" />-->
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,15 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"/>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="0dp"
android:layout_weight="1"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomnavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/menu_main_bottom" />
</LinearLayout>

View File

@ -4,11 +4,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Widget.Material3.CardView.Filled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
app:cardBackgroundColor="?attr/colorPrimaryContainer"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="6dp"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search" />
<ImageView
android:id="@+id/imageview"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="6dp"
android:src="@drawable/visibility" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_recommended"
android:icon="@drawable/home"
android:title="@string/recommended" />
<item
android:id="@+id/action_follow"
android:icon="@drawable/group"
android:title="@string/follow" />
<item
android:id="@+id/action_ranking"
android:icon="@drawable/leaderboard"
android:title="@string/ranking" />
<item
android:id="@+id/action_my"
android:icon="@drawable/head_icon"
android:title="@string/my" />
</menu>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:startDestination="@id/mod_item">
<fragment
android:id="@+id/community_item"
android:name="com.coldmint.rust.pro.fragments.CommunityFragment"
android:label="@string/community"
tools:layout="@layout/fragment_community" />
<fragment
android:id="@+id/mod_item"
android:name="com.coldmint.rust.pro.fragments.WarehouseFragment"
android:label="@string/warehouse"
tools:layout="@layout/fragment_mod" />
<fragment
android:id="@+id/database_item"
android:name="com.coldmint.rust.pro.fragments.DatabaseFragment"
android:label="@string/menu_title3"
tools:layout="@layout/fragment_database" />
<fragment
android:id="@+id/template_item"
android:name="com.coldmint.rust.pro.fragments.TemplateFragment"
android:label="@string/template_title"
tools:layout="@layout/fragment_local_template" />
</navigation>

View File

@ -11,5 +11,6 @@ data class TurretData(
val name: String,
var gameCoordinateData: CoordinateData,
var scaleValue: Float = 1f,
var imageFile: File? = null
var imageFile: File? = null,
var isImage: Boolean = true
)

View File

@ -1,6 +1,5 @@
package com.coldmint.rust.core.turret
import android.util.Log
import android.view.ViewGroup
import com.coldmint.rust.core.SourceFile
import com.coldmint.rust.core.debug.LogCat
@ -12,7 +11,7 @@ import java.io.File
* 此类用于管理源文件内的炮塔数据
* @constructor
*/
class TurretManager(val sourceFile: SourceFile) {
class TurretManager(private val sourceFile: SourceFile) {
/**
@ -47,6 +46,7 @@ class TurretManager(val sourceFile: SourceFile) {
}
init {
turretList.clear()
val allSection = sourceFile.allSection
val size = allSection.size
if (size > 0) {
@ -54,7 +54,7 @@ class TurretManager(val sourceFile: SourceFile) {
sourceFile.findResourceFilesFromSection("image_turret", "graphics", false)
var defaultImageFile: File? = null
if (!defaultImageList.isNullOrEmpty()) {
defaultImageFile = defaultImageList.get(0)
defaultImageFile = defaultImageList[0]
LogCat.d("炮塔管理器-默认图像", defaultImageFile.absolutePath)
}
allSection.forEach {
@ -65,17 +65,17 @@ class TurretManager(val sourceFile: SourceFile) {
var x = 0
var y = 0
val xData = sourceFile.readValueFromSection("x", it)
if (xData != null && xData.isNotBlank()) {
if (!xData.isNullOrBlank()) {
x = xData.toFloat().toInt()
}
val yData = sourceFile.readValueFromSection("y", it)
if (yData != null&& yData.isNotBlank()) {
if (!yData.isNullOrBlank()) {
y = yData.toFloat().toInt()
}
val turretData = TurretData(name, CoordinateData(x, y))
val fileList = sourceFile.findResourceFilesFromSection("image", it, false)
if (!fileList.isNullOrEmpty()) {
val file = fileList.get(0)
val file = fileList[0]
turretData.imageFile = file
LogCat.d("炮塔管理器-$name", "设置炮塔图像" + file.absolutePath)
} else {
@ -153,7 +153,7 @@ class TurretManager(val sourceFile: SourceFile) {
* @param frameLayout FrameLayout
* @param sourceFile SourceFile
*/
fun installerTurret(
private fun installerTurret(
viewGroup: ViewGroup,
turretData: TurretData,
turretSketchpadView: TurretSketchpadView

View File

@ -1,13 +1,10 @@
package com.coldmint.rust.core.turret
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.RelativeLayout
import com.coldmint.rust.core.R
import com.coldmint.rust.core.debug.LogCat
@ -15,10 +12,9 @@ import com.coldmint.rust.core.debug.LogCat
* 炮塔画板
* @constructor
*/
@SuppressLint("CustomViewStyleable")
class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null) :
View(context, attributeSet) {
companion object {
/**
* 缩放图像
@ -37,8 +33,8 @@ class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null)
bitmap,
0,
0,
bitmap.getWidth(),
bitmap.getHeight(),
bitmap.width,
bitmap.height,
matrix,
true
)
@ -268,6 +264,17 @@ class TurretSketchpadView(context: Context, attributeSet: AttributeSet? = null)
canvas.drawBitmap(temBitmap, startX.toFloat(), startY.toFloat(), paint)
temBitmap.recycle()
}
/* val canvasWidth = width.toFloat()
val canvasHeight = height.toFloat()
val bitmapW = bitmap.width
val bitmapH = bitmap.height
// 计算图像要在画布上居中的坐标
val centerX = (canvasWidth - bitmapW) / 2
val centerY = (canvasHeight - bitmapH) / 2
// 绘制居中位图
canvas.drawBitmap(bitmap, centerX, centerY, paint)
bitmap.recycle()*/
}
override fun onDraw(canvas: Canvas?) {

View File

@ -3,16 +3,12 @@ package com.coldmint.rust.core.turret
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Bitmap.createBitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.widget.Toast
import com.coldmint.rust.core.R
import com.coldmint.rust.core.debug.LogCat
/**
@ -104,7 +100,7 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) :
* 设置炮塔坐标数据
* @param coordinateData
*/
fun setTurretGameCoordinateData(coordinateData: CoordinateData) {
private fun setTurretGameCoordinateData(coordinateData: CoordinateData) {
if (this::turretData.isInitialized) {
turretData.gameCoordinateData = coordinateData
}
@ -116,6 +112,7 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) :
* @param event MotionEvent
* @return Boolean 返回true已被处理
*/
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent?): Boolean {
if (event != null) {
val action = event.action
@ -123,6 +120,7 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) :
MotionEvent.ACTION_DOWN -> {
return canDrag
}
MotionEvent.ACTION_MOVE -> {
LogCat.d(debugKey, "收到移动${turretData.name} 可拖动状态${canDrag}")
if (canDrag) {
@ -144,6 +142,10 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) :
@SuppressLint("DrawAllocation")
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
if (!turretData.isImage) {
//不可显示图像
return
}
if (this::turretData.isInitialized) {
if (turretSketchpadView == null) {
LogCat.e(debugKey, "未绑定画板,停止绘制。")
@ -159,15 +161,18 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) :
LogCat.e(debugKey, "无法加载炮塔图像。")
return
} else {
if (turretData.scaleValue != 1f) {
/* if (turretData.scaleValue != 1f) {
bitmap = TurretSketchpadView.scaleBitmap(
bitmap, turretData.scaleValue
)
}
}*/
bitmap = TurretSketchpadView.scaleBitmap(
bitmap, 10F
)
val androidCoordinate =
turretSketchpadView!!.toAndroidCoordinate(turretData.gameCoordinateData)
bitmapW = bitmap!!.width
bitmapH = bitmap!!.height
bitmapH = bitmap.height
canvas?.drawBitmap(
bitmap,
(androidCoordinate.x - bitmapW / 2).toFloat(),

View File

@ -1,12 +1,8 @@
package com.coldmint.dialog
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import androidx.viewbinding.ViewBinding
import com.google.android.material.bottomsheet.BottomSheetDialog