Skip to content

Commit

Permalink
Merge pull request #53 from KuhakuPixel/feature
Browse files Browse the repository at this point in the history
[ATG] Freeze value improvement and delete address
  • Loading branch information
KuhakuPixel authored Aug 16, 2023
2 parents 32e01f5 + 02f8571 commit 9cd8a6f
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ATG/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dependencies {
def nav_version = "2.5.3"
implementation "androidx.navigation:navigation-compose:$nav_version"
// creating overlay window
def libUberAllesVersion = '0.0.5'
def libUberAllesVersion = '0.0.6'
implementation "com.github.KuhakuPixel:UberAlles:${libUberAllesVersion}"
// ========================= for communication with ACE ===============
// apache commons
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.kuhakupixel.atg.ui

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.Checkbox
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import com.kuhakupixel.atg.ui.util.NumberInputField
import com.kuhakupixel.libuberalles.overlay.OverlayContext
import com.kuhakupixel.libuberalles.overlay.service.dialog.OverlayDialog

class AddressOverlayDialog(
overlayContext: OverlayContext,
alpha: Float = 1.0f,
val onAddressDeleted: () -> Unit
) :
OverlayDialog(overlayContext, alpha = alpha) {
@Composable
override fun DialogBody() {
Row(
modifier = Modifier.fillMaxSize(),
horizontalArrangement = Arrangement.SpaceBetween
) {
Button(onClick = {
onAddressDeleted()
super.close()
}) {
Text("Delete address")
}
}

}

fun show(title: String, onConfirm: () -> Unit) {
super.show(
title = title,
onConfirm = onConfirm,
onClose = {}
)
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
package com.kuhakupixel.atg.ui.menu

import android.graphics.drawable.Icon
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.Button
import androidx.compose.material3.Checkbox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.snapshots.SnapshotStateList
Expand All @@ -24,6 +31,7 @@ import com.kuhakupixel.atg.backend.ACE
import com.kuhakupixel.atg.backend.ACE.MatchInfo
import com.kuhakupixel.atg.backend.ACE.NumType
import com.kuhakupixel.atg.backend.ACEBaseClient
import com.kuhakupixel.atg.ui.AddressOverlayDialog
import com.kuhakupixel.atg.ui.EditAddressOverlayDialog
import com.kuhakupixel.atg.ui.GlobalConf
import com.kuhakupixel.atg.ui.util.CreateTable
Expand All @@ -37,8 +45,7 @@ class AddressInfo(
) {
}

private val savedAddresList = SnapshotStateList<AddressInfo>()

private val savedAddresList = mutableStateListOf<AddressInfo>()
fun AddressTableAddAddress(matchInfo: MatchInfo, numType: NumType) {
savedAddresList.add(AddressInfo(matchInfo, numType))
}
Expand All @@ -48,23 +55,73 @@ fun AddressTableMenu(globalConf: GlobalConf?, overlayContext: OverlayContext?) {

val ace: ACE = globalConf!!.getAce()
Column(
verticalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxSize(),
.fillMaxSize()
.padding(16.dp),
) {
Text("Address Table", modifier = Modifier.weight(0.2f))
Column(
modifier = Modifier.weight(0.2f)
) {
Button(
onClick = {
OverlayInfoDialog(overlayContext!!).show(
title = "Info Dialog",
text = "Delete all addresses?",
onConfirm = {
savedAddresList.clear()
},
)

}) {

Icon(Icons.Filled.Delete, "Delete All Matches")
}
}
SavedAddressesTable(
modifier = Modifier
.weight(0.8f)
.padding(16.dp),
modifier = Modifier.weight(0.8f),
savedAddressList = savedAddresList,
ace = ace,
onValueClicked = { numType: NumType, address: String ->
onAddressClicked = { itemIndex: Int ->
AddressOverlayDialog(
overlayContext = overlayContext!!,
onAddressDeleted = {
savedAddresList.removeAt(index = itemIndex)
}

).show(title = "Address ", onConfirm = {})

},
onValueClicked = { addressInfo: AddressInfo ->
EditAddressOverlayDialog(overlayContext!!).show(
title = "Edit value of $address",
onConfirm = { input: String ->
title = "Edit value of ${addressInfo.matchInfo.address}",
onConfirm = { newValue: String ->
try {
ace.WriteValueAtAddress(numType, address, input)
/* if value already frozen
* we need to first unfreeze it and then freeze the address
* with [newValue] instead of only writing to that value, because it
* will be pointless mimicking cheat engine's behaviour
*
* example when this is useful: if we have already frozen player's y coordinate,
* and we want to fly into higher/lower position
* */
if (addressInfo.isFreezed.value) {
ace.UnFreezeAtAddress(
addressInfo.numType,
addressInfo.matchInfo.address
)
ace.FreezeValueAtAddress(
addressInfo.numType,
addressInfo.matchInfo.address,
newValue
)
} else {

ace.WriteValueAtAddress(
addressInfo.numType,
addressInfo.matchInfo.address,
newValue
)
}
} catch (e: ACEBaseClient.InvalidCommandException) {
OverlayInfoDialog(overlayContext!!).show(
title = "Error",
Expand All @@ -85,7 +142,8 @@ fun SavedAddressesTable(
modifier: Modifier = Modifier,
savedAddressList: SnapshotStateList<AddressInfo>,
ace: ACE,
onValueClicked: (numType: NumType, address: String) -> Unit
onValueClicked: (addressInfo: AddressInfo) -> Unit,
onAddressClicked: (itemIndex: Int) -> Unit
) {

CreateTable(
Expand Down Expand Up @@ -125,7 +183,16 @@ fun SavedAddressesTable(
}
// address
if (colIndex == 1) {
Text(text = savedAddressList[rowIndex].matchInfo.address)

Box(
modifier = Modifier
.fillMaxWidth()
.clickable {
onAddressClicked(rowIndex)
},
) {
Text(text = savedAddressList[rowIndex].matchInfo.address)
}
}
// num type
if (colIndex == 2) {
Expand All @@ -139,8 +206,7 @@ fun SavedAddressesTable(
.fillMaxWidth()
.clickable {
onValueClicked(
savedAddressList[rowIndex].numType,
savedAddressList[rowIndex].matchInfo.address
savedAddressList[rowIndex]
)

},
Expand Down
21 changes: 20 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# ChangeLog

## [0.1.0]

### Fixed
- [APK] error not showing when giving invalid input during scan

### Added
- [APK] freeze value
- [APK] right arrow icon option to add all matches to address table
- [APK] faster scan by only scanning memory region that matters
- [APK] options to delete all (trash icon) or one address in address table
(clicking the address of an entry and click `delete this address`)
- [ACE] `region_level` option to choose which region to scan

### Changed
- [APK] press only the value cell to edit address's value instead of the whole row

### Removed
- [APK] unused binary module (apk's size is smaller now)

## [0.0.9]

### Fixed
Expand All @@ -13,7 +32,6 @@
### Changed
### Removed


## [0.0.8]
Initial Alpha release of ATG apk

Expand Down Expand Up @@ -41,3 +59,4 @@ Initial Alpha release of ATG apk
to scan with/without value

suggestion from [lasnik](https://github.com/lasnikprogram)

0 comments on commit 9cd8a6f

Please sign in to comment.