forked from Apple-2-Tools/jace
Manual add/delete cheats works now. How high is the water, momma? 3 ft. high and rising. W00t!
This commit is contained in:
parent
facd73d345
commit
926485ac38
@ -6,6 +6,7 @@
|
||||
package jace.cheat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
@ -24,6 +25,7 @@ public class MemoryCell implements Comparable<MemoryCell> {
|
||||
public IntegerProperty readCount = new SimpleIntegerProperty();
|
||||
public IntegerProperty execCount = new SimpleIntegerProperty();
|
||||
public IntegerProperty writeCount = new SimpleIntegerProperty();
|
||||
public BooleanBinding hasCount = readCount.add(execCount).add(writeCount).greaterThan(0);
|
||||
public ObservableList<Integer> readInstructions = FXCollections.observableList(new ArrayList<>());
|
||||
public ObservableList<Integer> writeInstructions = FXCollections.observableList(new ArrayList<>());
|
||||
private int x;
|
||||
@ -72,4 +74,8 @@ public class MemoryCell implements Comparable<MemoryCell> {
|
||||
return address - o.address;
|
||||
}
|
||||
|
||||
public boolean hasCounts() {
|
||||
return hasCount.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ public class MetaCheat extends Cheats {
|
||||
NO_CHANGE, ANY_CHANGE, LESS, GREATER, AMOUNT
|
||||
}
|
||||
|
||||
|
||||
public static class SearchResult {
|
||||
|
||||
int address;
|
||||
@ -52,7 +51,6 @@ public class MetaCheat extends Cheats {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MetacheatUI ui;
|
||||
|
||||
public int fadeRate = 1;
|
||||
@ -106,12 +104,7 @@ public class MetaCheat extends Cheats {
|
||||
return Integer.parseInt(s);
|
||||
} else {
|
||||
String upper = s.toUpperCase();
|
||||
boolean positive = true;
|
||||
if (upper.startsWith("-")) {
|
||||
positive = false;
|
||||
upper = upper.substring(1);
|
||||
}
|
||||
|
||||
boolean positive = !upper.startsWith("-");
|
||||
for (int i = 0; i < upper.length(); i++) {
|
||||
char c = upper.charAt(i);
|
||||
if ((c >= '0' && c <= '9') || (c >= 'A' & c <= 'F')) {
|
||||
@ -134,12 +127,18 @@ public class MetaCheat extends Cheats {
|
||||
cheat.activeProperty().set(true);
|
||||
cheatList.add(cheat);
|
||||
computer.getMemory().addListener(cheat);
|
||||
cheat.addressProperty().addListener((prop, oldVal, newVal)->{
|
||||
cheat.addressProperty().addListener((prop, oldVal, newVal) -> {
|
||||
computer.getMemory().removeListener(cheat);
|
||||
cheat.doConfig();
|
||||
computer.getMemory().addListener(cheat);
|
||||
});
|
||||
}
|
||||
|
||||
public void removeCheat(DynamicCheat cheat) {
|
||||
cheat.active.set(false);
|
||||
computer.getMemory().removeListener(cheat);
|
||||
cheatList.remove(cheat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unregisterListeners() {
|
||||
@ -299,24 +298,22 @@ public class MetaCheat extends Cheats {
|
||||
public void tick() {
|
||||
if (fadeCounter-- <= 0) {
|
||||
fadeCounter = FADE_TIMER_VALUE;
|
||||
memoryCells.values().stream().forEach((jace.cheat.MemoryCell cell) -> {
|
||||
boolean change = false;
|
||||
if (cell.execCount.get() > 0) {
|
||||
cell.execCount.set(Math.max(0, cell.execCount.get() - fadeRate));
|
||||
change = true;
|
||||
}
|
||||
if (cell.readCount.get() > 0) {
|
||||
cell.readCount.set(Math.max(0, cell.readCount.get() - fadeRate));
|
||||
change = true;
|
||||
}
|
||||
if (cell.writeCount.get() > 0) {
|
||||
cell.writeCount.set(Math.max(0, cell.writeCount.get() - fadeRate));
|
||||
change = true;
|
||||
}
|
||||
if (change && MemoryCell.listener != null) {
|
||||
MemoryCell.listener.changed(null, cell, cell);
|
||||
}
|
||||
});
|
||||
memoryCells.values().stream()
|
||||
.filter((cell) -> cell.hasCounts())
|
||||
.forEach((cell) -> {
|
||||
if (cell.execCount.get() > 0) {
|
||||
cell.execCount.set(Math.max(0, cell.execCount.get() - fadeRate));
|
||||
}
|
||||
if (cell.readCount.get() > 0) {
|
||||
cell.readCount.set(Math.max(0, cell.readCount.get() - fadeRate));
|
||||
}
|
||||
if (cell.writeCount.get() > 0) {
|
||||
cell.writeCount.set(Math.max(0, cell.writeCount.get() - fadeRate));
|
||||
}
|
||||
if (MemoryCell.listener != null) {
|
||||
MemoryCell.listener.changed(null, cell, cell);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class MetacheatUI {
|
||||
|
||||
@FXML
|
||||
void addCheat(ActionEvent event) {
|
||||
|
||||
cheatEngine.addCheat(new DynamicCheat(0, "?"));
|
||||
}
|
||||
|
||||
@FXML
|
||||
@ -137,7 +137,7 @@ public class MetacheatUI {
|
||||
|
||||
@FXML
|
||||
void deleteCheat(ActionEvent event) {
|
||||
|
||||
cheatsTableView.getSelectionModel().getSelectedItems().forEach(cheatEngine::removeCheat);
|
||||
}
|
||||
|
||||
@FXML
|
||||
@ -281,12 +281,12 @@ public class MetacheatUI {
|
||||
TableColumn<DynamicCheat, Integer> addrColumn = (TableColumn<DynamicCheat, Integer>) cheatsTableView.getColumns().get(2);
|
||||
addrColumn.setCellValueFactory(new PropertyValueFactory<>("address"));
|
||||
addrColumn.setCellFactory((TableColumn<DynamicCheat, Integer> param) -> {
|
||||
return new TextFieldTableCell<>(new IntegerStringConverter(){
|
||||
return new TextFieldTableCell<>(new IntegerStringConverter() {
|
||||
@Override
|
||||
public String toString(Integer value) {
|
||||
return "$"+Integer.toHexString(value);
|
||||
return "$" + Integer.toHexString(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer fromString(String value) {
|
||||
return cheatEngine.parseInt(value);
|
||||
|
Loading…
Reference in New Issue
Block a user