forked from Apple-2-Tools/jace
Start of cheat creation from watch panels. Cheat editing is still not finished so it's not usable quite yet.
This commit is contained in:
parent
76874ac514
commit
bed635c7fc
@ -33,7 +33,7 @@ public class MetaCheat extends Cheats {
|
||||
NO_CHANGE, ANY_CHANGE, LESS, GREATER, AMOUNT
|
||||
}
|
||||
|
||||
public static class MemoryCell implements Comparable<MemoryCell>{
|
||||
public static class MemoryCell implements Comparable<MemoryCell> {
|
||||
|
||||
public static ChangeListener<MemoryCell> listener;
|
||||
public int address;
|
||||
@ -71,12 +71,15 @@ public class MetaCheat extends Cheats {
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
@ -103,6 +106,43 @@ public class MetaCheat extends Cheats {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cheat extends RAMListener {
|
||||
IntegerProperty addr;
|
||||
IntegerProperty val;
|
||||
BooleanProperty active;
|
||||
|
||||
public Cheat(int address, int value) {
|
||||
super(RAMEvent.TYPE.ANY, RAMEvent.SCOPE.ADDRESS, RAMEvent.VALUE.ANY);
|
||||
addr = new SimpleIntegerProperty(address);
|
||||
val = new SimpleIntegerProperty(value);
|
||||
active = new SimpleBooleanProperty(true);
|
||||
setScopeStart(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doConfig() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doEvent(RAMEvent e) {
|
||||
if (active.get()) {
|
||||
e.setNewValue(val.get());
|
||||
}
|
||||
}
|
||||
|
||||
public BooleanProperty activeProperty() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public IntegerProperty addressProperty() {
|
||||
return addr;
|
||||
}
|
||||
|
||||
public IntegerProperty valueProperty() {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
MetacheatUI ui;
|
||||
|
||||
public int fadeRate = 1;
|
||||
@ -119,7 +159,7 @@ public class MetaCheat extends Cheats {
|
||||
private final BooleanProperty signedProperty = new SimpleBooleanProperty(false);
|
||||
private final StringProperty searchValueProperty = new SimpleStringProperty("0");
|
||||
private final StringProperty changeByProperty = new SimpleStringProperty("0");
|
||||
private final ObservableList<RAMListener> cheatList = FXCollections.observableArrayList();
|
||||
private final ObservableList<Cheat> cheatList = FXCollections.observableArrayList();
|
||||
private final ObservableList<SearchResult> resultList = FXCollections.observableArrayList();
|
||||
private final ObservableList<State> snapshotList = FXCollections.observableArrayList();
|
||||
|
||||
@ -180,6 +220,18 @@ public class MetaCheat extends Cheats {
|
||||
void registerListeners() {
|
||||
}
|
||||
|
||||
public void addCheat(Cheat cheat) {
|
||||
cheat.activeProperty().set(true);
|
||||
cheatList.add(cheat);
|
||||
computer.getMemory().addListener(cheat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unregisterListeners() {
|
||||
super.unregisterListeners();
|
||||
cheatList.stream().forEach(computer.getMemory()::removeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDeviceName() {
|
||||
return "MetaCheat";
|
||||
@ -230,7 +282,7 @@ public class MetaCheat extends Cheats {
|
||||
return changeByProperty;
|
||||
}
|
||||
|
||||
public ObservableList<RAMListener> getCheats() {
|
||||
public ObservableList<Cheat> getCheats() {
|
||||
return cheatList;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package jace.ui;
|
||||
import com.sun.glass.ui.Application;
|
||||
import jace.Emulator;
|
||||
import jace.cheat.MetaCheat;
|
||||
import jace.cheat.MetaCheat.Cheat;
|
||||
import jace.cheat.MetaCheat.SearchChangeType;
|
||||
import jace.cheat.MetaCheat.SearchType;
|
||||
import jace.core.RAMListener;
|
||||
@ -39,6 +40,7 @@ import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.Toggle;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.BackgroundFill;
|
||||
@ -125,7 +127,7 @@ public class MetacheatUI {
|
||||
private ListView<State> snapshotsListView;
|
||||
|
||||
@FXML
|
||||
private TableView<RAMListener> cheatsTableView;
|
||||
private TableView<Cheat> cheatsTableView;
|
||||
|
||||
@FXML
|
||||
void addCheat(ActionEvent event) {
|
||||
@ -266,8 +268,16 @@ public class MetacheatUI {
|
||||
|
||||
watchesPane.setHgap(5);
|
||||
watchesPane.setVgap(5);
|
||||
}
|
||||
|
||||
searchStartAddressField.textProperty().addListener(addressRangeListener);
|
||||
searchEndAddressField.textProperty().addListener(addressRangeListener);
|
||||
|
||||
RAMListener l;
|
||||
|
||||
cheatsTableView.getColumns().get(0).setCellValueFactory(new PropertyValueFactory<>("active"));
|
||||
cheatsTableView.getColumns().get(1).setCellValueFactory(new PropertyValueFactory<>("address"));
|
||||
cheatsTableView.getColumns().get(2).setCellValueFactory(new PropertyValueFactory<>("value"));
|
||||
}
|
||||
MetaCheat cheatEngine = null;
|
||||
|
||||
public void registerMetacheatEngine(MetaCheat engine) {
|
||||
@ -282,9 +292,6 @@ public class MetacheatUI {
|
||||
searchValueField.textProperty().bindBidirectional(cheatEngine.searchValueProperty());
|
||||
searchChangeByField.textProperty().bindBidirectional(cheatEngine.searchChangeByProperty());
|
||||
|
||||
searchStartAddressField.textProperty().addListener(addressRangeListener);
|
||||
searchEndAddressField.textProperty().addListener(addressRangeListener);
|
||||
|
||||
Application.invokeLater(this::redrawMemoryView);
|
||||
}
|
||||
|
||||
@ -463,7 +470,7 @@ public class MetacheatUI {
|
||||
}
|
||||
|
||||
private void addCheat(int addr, int val) {
|
||||
|
||||
cheatEngine.addCheat(new Cheat(addr, val));
|
||||
}
|
||||
|
||||
private static final int GRAPH_WIDTH = 50;
|
||||
|
Loading…
Reference in New Issue
Block a user