Manual add/delete cheats works now. How high is the water, momma? 3 ft. high and rising. W00t!

This commit is contained in:
Brendan Robert 2015-08-23 21:54:43 -05:00
parent facd73d345
commit 926485ac38
3 changed files with 35 additions and 32 deletions

View File

@ -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();
}
}

View File

@ -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')) {
@ -141,6 +134,12 @@ public class MetaCheat extends Cheats {
});
}
public void removeCheat(DynamicCheat cheat) {
cheat.active.set(false);
computer.getMemory().removeListener(cheat);
cheatList.remove(cheat);
}
@Override
protected void unregisterListeners() {
super.unregisterListeners();
@ -299,21 +298,19 @@ 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;
memoryCells.values().stream()
.filter((cell) -> cell.hasCounts())
.forEach((cell) -> {
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) {
if (MemoryCell.listener != null) {
MemoryCell.listener.changed(null, cell, cell);
}
});

View File

@ -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