Search results list rigged to add cheats when double-clicked. UI for side panels is vastly improved and ready for use.

This commit is contained in:
Brendan Robert 2015-08-23 23:55:56 -05:00
parent 926485ac38
commit 8ff0987801
3 changed files with 194 additions and 186 deletions

View File

@ -49,6 +49,10 @@ public class MetaCheat extends Cheats {
public String toString() { public String toString() {
return Integer.toHexString(address) + ": " + lastObservedValue + " (" + Integer.toHexString(lastObservedValue) + ")"; return Integer.toHexString(address) + ": " + lastObservedValue + " (" + Integer.toHexString(lastObservedValue) + ")";
} }
public int getAddress() {
return address;
}
} }
MetacheatUI ui; MetacheatUI ui;

View File

@ -6,6 +6,7 @@ import jace.cheat.DynamicCheat;
import jace.cheat.MemoryCell; import jace.cheat.MemoryCell;
import jace.cheat.MetaCheat; import jace.cheat.MetaCheat;
import jace.cheat.MetaCheat.SearchChangeType; import jace.cheat.MetaCheat.SearchChangeType;
import jace.cheat.MetaCheat.SearchResult;
import jace.cheat.MetaCheat.SearchType; import jace.cheat.MetaCheat.SearchType;
import jace.core.RAMListener; import jace.core.RAMListener;
import jace.state.State; import jace.state.State;
@ -125,21 +126,11 @@ public class MetacheatUI {
@FXML @FXML
private TableView<DynamicCheat> cheatsTableView; private TableView<DynamicCheat> cheatsTableView;
@FXML
void addCheat(ActionEvent event) {
cheatEngine.addCheat(new DynamicCheat(0, "?"));
}
@FXML @FXML
void createSnapshot(ActionEvent event) { void createSnapshot(ActionEvent event) {
} }
@FXML
void deleteCheat(ActionEvent event) {
cheatsTableView.getSelectionModel().getSelectedItems().forEach(cheatEngine::removeCheat);
}
@FXML @FXML
void deleteSnapshot(ActionEvent event) { void deleteSnapshot(ActionEvent event) {
@ -150,11 +141,26 @@ public class MetacheatUI {
} }
@FXML
void addCheat(ActionEvent event) {
cheatEngine.addCheat(new DynamicCheat(0, "?"));
}
@FXML
void deleteCheat(ActionEvent event) {
cheatsTableView.getSelectionModel().getSelectedItems().forEach(cheatEngine::removeCheat);
}
@FXML @FXML
void loadCheats(ActionEvent event) { void loadCheats(ActionEvent event) {
} }
@FXML
void saveCheats(ActionEvent event) {
}
@FXML @FXML
void newSearch(ActionEvent event) { void newSearch(ActionEvent event) {
Platform.runLater(() -> { Platform.runLater(() -> {
@ -174,11 +180,6 @@ public class MetacheatUI {
}); });
} }
@FXML
void saveCheats(ActionEvent event) {
}
@FXML @FXML
void search(ActionEvent event) { void search(ActionEvent event) {
Platform.runLater(() -> { Platform.runLater(() -> {
@ -252,6 +253,13 @@ public class MetacheatUI {
} }
}); });
searchResultsListView.setEditable(true);
searchResultsListView.setOnEditStart((editEvent) -> {
editEvent.consume();
SearchResult result = cheatEngine.getSearchResults().get(editEvent.getIndex());
addWatch(result.getAddress());
});
memoryViewCanvas.setMouseTransparent(false); memoryViewCanvas.setMouseTransparent(false);
memoryViewCanvas.addEventFilter(MouseEvent.MOUSE_CLICKED, this::memoryViewClicked); memoryViewCanvas.addEventFilter(MouseEvent.MOUSE_CLICKED, this::memoryViewClicked);
showValuesCheckbox.selectedProperty().addListener((prop, oldVal, newVal) -> { showValuesCheckbox.selectedProperty().addListener((prop, oldVal, newVal) -> {
@ -268,8 +276,6 @@ public class MetacheatUI {
searchStartAddressField.textProperty().addListener(addressRangeListener); searchStartAddressField.textProperty().addListener(addressRangeListener);
searchEndAddressField.textProperty().addListener(addressRangeListener); searchEndAddressField.textProperty().addListener(addressRangeListener);
RAMListener l;
TableColumn<DynamicCheat, Boolean> activeColumn = (TableColumn<DynamicCheat, Boolean>) cheatsTableView.getColumns().get(0); TableColumn<DynamicCheat, Boolean> activeColumn = (TableColumn<DynamicCheat, Boolean>) cheatsTableView.getColumns().get(0);
activeColumn.setCellValueFactory(new PropertyValueFactory<>("active")); activeColumn.setCellValueFactory(new PropertyValueFactory<>("active"));
activeColumn.setCellFactory((TableColumn<DynamicCheat, Boolean> param) -> new CheckBoxTableCell<>()); activeColumn.setCellFactory((TableColumn<DynamicCheat, Boolean> param) -> new CheckBoxTableCell<>());
@ -326,8 +332,6 @@ public class MetacheatUI {
public static Set<MemoryCell> redrawNodes = new ConcurrentSkipListSet<>(); public static Set<MemoryCell> redrawNodes = new ConcurrentSkipListSet<>();
ScheduledExecutorService animationTimer = null; ScheduledExecutorService animationTimer = null;
ScheduledFuture animationFuture = null; ScheduledFuture animationFuture = null;
StackPane pane = new StackPane();
Tooltip memoryWatchTooltip = new Tooltip(); Tooltip memoryWatchTooltip = new Tooltip();
private void memoryViewClicked(MouseEvent e) { private void memoryViewClicked(MouseEvent e) {
@ -356,7 +360,7 @@ public class MetacheatUI {
Label addCheat = new Label("Cheat >>"); Label addCheat = new Label("Cheat >>");
addCheat.setOnMouseClicked((mouseEvent) -> { addCheat.setOnMouseClicked((mouseEvent) -> {
addCheat(addr, watch.getValue()); Platform.runLater(() -> addCheat(addr, watch.getValue()));
}); });
watch.getChildren().add(addCheat); watch.getChildren().add(addCheat);
@ -406,7 +410,7 @@ public class MetacheatUI {
animationFuture.cancel(false); animationFuture.cancel(false);
} }
animationFuture = animationTimer.scheduleAtFixedRate(this::processMemoryViewUpdates, FRAME_RATE, 1000 / 60, TimeUnit.MILLISECONDS); animationFuture = animationTimer.scheduleAtFixedRate(this::processMemoryViewUpdates, FRAME_RATE, FRAME_RATE, TimeUnit.MILLISECONDS);
cheatEngine.initMemoryView(); cheatEngine.initMemoryView();
int pixelsPerBlock = 16 * MEMORY_BOX_TOTAL_SIZE; int pixelsPerBlock = 16 * MEMORY_BOX_TOTAL_SIZE;
@ -492,5 +496,4 @@ public class MetacheatUI {
private void addCheat(int addr, int val) { private void addCheat(int addr, int val) {
cheatEngine.addCheat(new DynamicCheat(addr, String.valueOf(val))); cheatEngine.addCheat(new DynamicCheat(addr, String.valueOf(val)));
} }
} }

View File

@ -7,7 +7,7 @@
<?import java.lang.*?> <?import java.lang.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="492.0" prefWidth="702.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="jace.ui.MetacheatUI"> <VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="520.0" prefWidth="710.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="jace.ui.MetacheatUI">
<children> <children>
<ToolBar prefHeight="40.0" prefWidth="200.0" VBox.vgrow="NEVER"> <ToolBar prefHeight="40.0" prefWidth="200.0" VBox.vgrow="NEVER">
<items> <items>
@ -31,190 +31,191 @@
</children> </children>
</StackPane> </StackPane>
</content></ScrollPane> </content></ScrollPane>
<Accordion centerShape="false" scaleShape="false"> <ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="200.0" prefWidth="200.0">
<panes> <content>
<TitledPane prefHeight="200.0" prefWidth="200.0" text="Search"> <VBox>
<content> <children>
<VBox prefHeight="200.0" prefWidth="100.0"> <TitledPane expanded="false" minHeight="-Infinity" prefWidth="200.0" text="Search" VBox.vgrow="NEVER">
<children> <content>
<TabPane fx:id="searchTypesTabPane" prefHeight="147.0" prefWidth="233.0" tabClosingPolicy="UNAVAILABLE" VBox.vgrow="NEVER"> <VBox>
<tabs> <children>
<Tab text="Value"> <TabPane fx:id="searchTypesTabPane" prefWidth="233.0" tabClosingPolicy="UNAVAILABLE" VBox.vgrow="NEVER">
<content> <tabs>
<VBox prefHeight="200.0" prefWidth="100.0"> <Tab text="Value">
<children> <content>
<FlowPane prefHeight="43.0" prefWidth="233.0"> <VBox prefWidth="100.0">
<children> <children>
<Label text="Search for value:"> <FlowPane prefHeight="43.0" prefWidth="233.0">
<children>
<Label text="Search for value:">
<padding>
<Insets right="3.0" />
</padding>
</Label>
<TextField fx:id="searchValueField" prefHeight="26.0" prefWidth="75.0" />
</children>
<padding> <padding>
<Insets right="3.0" /> <Insets top="3.0" />
</padding> </padding>
<VBox.margin>
<Insets bottom="4.0" />
</VBox.margin>
</FlowPane>
<Separator prefWidth="200.0" />
<Label text="These affect Change searches also.">
<font>
<Font name="System Italic" size="13.0" />
</font>
</Label> </Label>
<TextField fx:id="searchValueField" prefHeight="26.0" prefWidth="75.0" /> <HBox prefWidth="200.0" VBox.vgrow="NEVER">
<children>
<RadioButton fx:id="searchTypeByte" mnemonicParsing="false" selected="true" text="Byte">
<HBox.margin>
<Insets left="2.0" />
</HBox.margin>
<toggleGroup>
<ToggleGroup fx:id="searchSize" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="searchTypeWord" mnemonicParsing="false" text="Word" toggleGroup="$searchSize">
<HBox.margin>
<Insets />
</HBox.margin>
<padding>
<Insets left="2.0" right="2.0" />
</padding>
</RadioButton>
<CheckBox fx:id="searchTypeSigned" mnemonicParsing="false" text="Signed" />
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets bottom="3.0" top="3.0" />
</padding>
</HBox>
</children> </children>
<padding> <padding>
<Insets top="3.0" /> <Insets left="5.0" />
</padding> </padding>
<VBox.margin> </VBox>
<Insets bottom="4.0" /> </content>
</VBox.margin> </Tab>
</FlowPane> <Tab text="Change">
<Separator prefWidth="200.0" /> <content>
<Label text="These affect Change searches also."> <VBox nodeOrientation="LEFT_TO_RIGHT" prefHeight="112.0" prefWidth="217.0">
<font>
<Font name="System Italic" size="13.0" />
</font>
</Label>
<HBox prefHeight="100.0" prefWidth="200.0">
<children> <children>
<RadioButton fx:id="searchTypeByte" mnemonicParsing="false" selected="true" text="Byte"> <RadioButton fx:id="searchChangeNoneOption" mnemonicParsing="false" text="No changes since last search">
<HBox.margin> <opaqueInsets>
<Insets left="2.0" /> <Insets />
</HBox.margin> </opaqueInsets>
<padding>
<Insets bottom="3.0" top="2.0" />
</padding>
<toggleGroup> <toggleGroup>
<ToggleGroup fx:id="searchSize" /> <ToggleGroup fx:id="changeSearchType" />
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<RadioButton fx:id="searchTypeWord" mnemonicParsing="false" text="Word" toggleGroup="$searchSize"> <RadioButton fx:id="searchChangeAnyOption" mnemonicParsing="false" text="Any changes since last search" toggleGroup="$changeSearchType">
<HBox.margin>
<Insets />
</HBox.margin>
<padding> <padding>
<Insets left="2.0" right="2.0" /> <Insets bottom="3.0" />
</padding> </padding>
</RadioButton> </RadioButton>
<CheckBox fx:id="searchTypeSigned" mnemonicParsing="false" text="Signed" /> <RadioButton fx:id="searchChangeLessOption" mnemonicParsing="false" text="Less than last search" toggleGroup="$changeSearchType">
<padding>
<Insets bottom="3.0" />
</padding>
</RadioButton>
<RadioButton fx:id="searchChangeGreaterOption" mnemonicParsing="false" text="Greater than last search" toggleGroup="$changeSearchType" />
<FlowPane prefWidth="200.0">
<children>
<RadioButton fx:id="searchChangeByOption" mnemonicParsing="false" text="Change by: " toggleGroup="$changeSearchType" />
<TextField fx:id="searchChangeByField" prefHeight="26.0" prefWidth="76.0" />
</children>
</FlowPane>
</children> </children>
<opaqueInsets> <opaqueInsets>
<Insets /> <Insets />
</opaqueInsets> </opaqueInsets>
<padding> <padding>
<Insets bottom="3.0" top="3.0" /> <Insets left="2.0" />
</padding> </padding>
</HBox> </VBox>
</children> </content>
<padding> </Tab>
<Insets left="5.0" /> <Tab text="Text" />
</padding> </tabs>
</VBox> </TabPane>
</content> <ToolBar prefHeight="40.0" prefWidth="200.0" VBox.vgrow="NEVER">
</Tab> <items>
<Tab text="Change"> <Button mnemonicParsing="false" onAction="#newSearch" text="New Search" />
<content> <Button mnemonicParsing="false" onAction="#search" text="Search" />
<VBox nodeOrientation="LEFT_TO_RIGHT" prefHeight="200.0" prefWidth="100.0"> </items>
<children> </ToolBar>
<RadioButton fx:id="searchChangeNoneOption" mnemonicParsing="false" text="No changes since last search"> <HBox prefHeight="19.0" prefWidth="235.0">
<opaqueInsets> <children>
<Insets /> <Label prefWidth="80.0" text="Results:" HBox.hgrow="NEVER" />
</opaqueInsets> <Label fx:id="searchStatusLabel" prefHeight="16.0" prefWidth="181.0" textAlignment="RIGHT" wrapText="true" HBox.hgrow="ALWAYS" />
<padding> </children>
<Insets bottom="3.0" top="2.0" /> </HBox>
</padding> <ListView fx:id="searchResultsListView" minHeight="25.0" prefHeight="75.0" VBox.vgrow="ALWAYS" />
<toggleGroup>
<ToggleGroup fx:id="changeSearchType" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="searchChangeAnyOption" mnemonicParsing="false" text="Any changes since last search" toggleGroup="$changeSearchType">
<padding>
<Insets bottom="3.0" />
</padding>
</RadioButton>
<RadioButton fx:id="searchChangeLessOption" mnemonicParsing="false" text="Less than last search" toggleGroup="$changeSearchType">
<padding>
<Insets bottom="3.0" />
</padding>
</RadioButton>
<RadioButton fx:id="searchChangeGreaterOption" mnemonicParsing="false" text="Greater than last search" toggleGroup="$changeSearchType" />
<FlowPane prefHeight="200.0" prefWidth="200.0">
<children>
<RadioButton fx:id="searchChangeByOption" mnemonicParsing="false" text="Change by: " toggleGroup="$changeSearchType" />
<TextField fx:id="searchChangeByField" prefHeight="26.0" prefWidth="76.0" />
</children>
</FlowPane>
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets left="2.0" />
</padding>
</VBox>
</content>
</Tab>
<Tab text="Text" />
</tabs>
</TabPane>
<ToolBar prefHeight="40.0" prefWidth="200.0" VBox.vgrow="NEVER">
<items>
<Button mnemonicParsing="false" onAction="#newSearch" text="New Search" />
<Button mnemonicParsing="false" onAction="#search" text="Search" />
</items>
</ToolBar>
<HBox prefHeight="19.0" prefWidth="235.0">
<children>
<Label text="Results:" HBox.hgrow="NEVER" />
<Label fx:id="searchStatusLabel" prefHeight="16.0" prefWidth="181.0" textAlignment="RIGHT" wrapText="true" HBox.hgrow="ALWAYS" />
</children> </children>
</HBox> </VBox>
<ListView fx:id="searchResultsListView" prefHeight="125.0" prefWidth="233.0" VBox.vgrow="ALWAYS" /> </content>
</children> </TitledPane>
</VBox> <TitledPane text="Watches" VBox.vgrow="NEVER">
</content> <content>
</TitledPane> <TilePane fx:id="watchesPane" alignment="TOP_CENTER" hgap="5.0" prefTileHeight="120.0" prefTileWidth="65.0" prefWidth="200.0" tileAlignment="TOP_CENTER" vgap="5.0" />
<TitledPane animated="false" text="Watches"> </content>
<content> </TitledPane>
<TilePane fx:id="watchesPane" prefHeight="200.0" prefWidth="200.0" /> <TitledPane text="Cheats" VBox.vgrow="NEVER">
</content> <content>
</TitledPane> <BorderPane>
<TitledPane animated="false" text="Snapshots"> <bottom>
<content> <ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<BorderPane minWidth="-Infinity"> <items>
<bottom> <Button mnemonicParsing="false" onAction="#addCheat" text="Add" />
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER"> <Button mnemonicParsing="false" onAction="#deleteCheat" text="Delete" />
<items> <Button mnemonicParsing="false" onAction="#loadCheats" text="Load" />
<Button mnemonicParsing="false" onAction="#createSnapshot" text="Create" /> <Button mnemonicParsing="false" onAction="#saveCheats" text="Save" />
<Button mnemonicParsing="false" onAction="#deleteSnapshot" text="Delete" /> </items>
<Button mnemonicParsing="false" onAction="#diffSnapshots" text="Diff" /> </ToolBar>
</items> </bottom>
</ToolBar> <center>
</bottom> <TableView fx:id="cheatsTableView" editable="true" minHeight="75.0" BorderPane.alignment="CENTER">
<center> <columns>
<ListView fx:id="snapshotsListView" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" /> <TableColumn prefWidth="28.0" sortable="false" text="On" />
</center> <TableColumn prefWidth="77.0" text="Name" />
</BorderPane> <TableColumn minWidth="9.0" prefWidth="42.0" text="Addr" />
</content> <TableColumn prefWidth="88.0" text="Effect" />
</TitledPane> </columns>
<TitledPane animated="false" text="Cheats"> </TableView>
<content> </center>
<BorderPane prefHeight="200.0" prefWidth="200.0"> </BorderPane>
<bottom> </content>
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER"> </TitledPane>
<items> <TitledPane expanded="false" text="Snapshots" VBox.vgrow="NEVER">
<Button mnemonicParsing="false" onAction="#addCheat" text="Add" /> <content>
<Button mnemonicParsing="false" onAction="#deleteCheat" text="Delete" /> <BorderPane minWidth="-Infinity">
<Button mnemonicParsing="false" onAction="#loadCheats" text="Load" /> <bottom>
<Button mnemonicParsing="false" onAction="#saveCheats" text="Save" /> <ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
</items> <items>
</ToolBar> <Button mnemonicParsing="false" onAction="#createSnapshot" text="Create" />
</bottom> <Button mnemonicParsing="false" onAction="#deleteSnapshot" text="Delete" />
<center> <Button mnemonicParsing="false" onAction="#diffSnapshots" text="Diff" />
<TableView fx:id="cheatsTableView" editable="true" prefHeight="321.0" prefWidth="207.0" BorderPane.alignment="CENTER"> </items>
<columns> </ToolBar>
<TableColumn prefWidth="26.0" sortable="false" text="On" /> </bottom>
<TableColumn prefWidth="74.0" text="Name" /> <center>
<TableColumn prefWidth="50.0" text="Addr" /> <ListView fx:id="snapshotsListView" minHeight="25.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
<TableColumn prefWidth="84.0" text="Effect" /> </center>
</columns> </BorderPane>
<columnResizePolicy> </content>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> </TitledPane>
</columnResizePolicy> </children>
</TableView> </VBox>
</center> </content>
</BorderPane> </ScrollPane>
</content>
</TitledPane>
</panes>
</Accordion>
</items> </items>
</SplitPane> </SplitPane>
</children> </children>