Skip to content

Commit

Permalink
Change weird behavior in prop editor autocomplete. Now it only trigge…
Browse files Browse the repository at this point in the history
…rs on click and pressing Enter, LEFT and RIGHT arrows move the caret, and the popup hides when exiting the word.

Display animation names in RW model viewer.
  • Loading branch information
emd4600 committed Jul 5, 2024
1 parent ad4a74f commit b76c6ad
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 34 deletions.
12 changes: 6 additions & 6 deletions config.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#Wed Jun 07 17:03:46 CEST 2023
fxcFile=AUTO
dontAskAgain_saveAsMod=false
#Wed Feb 21 20:23:40 CET 2024
gameToExecute=GALACTIC_ADVENTURES
dontAskAgain_removeItem=false
hasSelectedStyle=true
pathSpore=AUTO
gameCommandLine=
pathGA=AUTO
selectedStyle=Dark
dontAskAgain_saveAsMod=false
fxcFile=C\:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22621.0\\x86\\fxc.exe
isFirstTime=false
dontAskAgain_removeItem=false
pathCustom=
gameCommandLine=
selectedStyle=Dark
2 changes: 1 addition & 1 deletion src/sporemodder/ProjectManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ public void unpackPresets(List<ProjectPreset> presets, List<Converter> converter
if (failedPackages.isEmpty()) {
infoLabel.setText("Finished! All presets were unpacked successfully. Below you can check a list of all the packages they include:");
} else {
infoLabel.setText("Finished! Some packages could not be unpaked; below there is a list with the packages the presets contains, the ones in red were missing:");
infoLabel.setText("Finished! Some packages could not be unpacked; below there is a list with the packages the presets contains, the ones in red were missing:");
}

boolean openedByDefault = true;
Expand Down
17 changes: 16 additions & 1 deletion src/sporemodder/view/editors/PropEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.stage.Popup;
import org.fxmisc.richtext.NavigationActions;
import sporemodder.DocumentationManager;
import sporemodder.HashManager;
import sporemodder.file.TextUtils;
import sporemodder.file.argscript.ArgScriptStream.HyperlinkData;
import sporemodder.file.prop.PropertyList;
import sporemodder.view.UserInterface;

import java.util.Set;

public class PropEditor extends ArgScriptEditor<PropertyList> {

private static final int AUTOCOMPLETE_WIDTH = 400;
Expand Down Expand Up @@ -107,6 +110,18 @@ public PropEditor() {
hideAutocomplete();
}
});
autocompleteList.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
Set<KeyCode> discardedKeys = Set.of(KeyCode.SPACE, KeyCode.UP, KeyCode.LEFT, KeyCode.RIGHT, KeyCode.DOWN);
if (discardedKeys.contains(event.getCode())) {
event.consume();

if (event.getCode() == KeyCode.LEFT) {
getCodeArea().moveTo(getCodeArea().getCaretPosition() - 1);
} else if (event.getCode() == KeyCode.RIGHT) {
getCodeArea().moveTo(getCodeArea().getCaretPosition() + 1);
}
}
});

final CodeArea codeArea = getCodeArea();

Expand All @@ -116,7 +131,7 @@ public PropEditor() {

codeArea.caretPositionProperty().addListener((obs, oldValue, newValue) -> {
// The caret also moves when typing, but we don't want to close the popup there
if (caretMouseEvent && autocompletePopup.isShowing()) {
if (autocompletePopup.isShowing()) {
if (newValue > currentWordEnd || newValue < currentWordStart) {
hideAutocomplete();
}
Expand Down
56 changes: 30 additions & 26 deletions src/sporemodder/view/editors/RWModelViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Map;
import java.util.Stack;

import javafx.scene.control.*;
import sporemodder.file.filestructures.FileStream;
import sporemodder.file.filestructures.MemoryStream;
import sporemodder.file.filestructures.StreamReader;
Expand All @@ -39,13 +40,6 @@
import javafx.scene.PerspectiveCamera;
import javafx.scene.SceneAntialiasing;
import javafx.scene.SubScene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Dialog;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelReader;
Expand All @@ -72,23 +66,9 @@
import sporemodder.UIManager;
import sporemodder.file.BoundingBox;
import sporemodder.file.dds.DDSTexture;
import sporemodder.file.rw4.*;
import sporemodder.file.rw4.Direct3DEnums.RWDECLUSAGE;
import sporemodder.file.rw4.MaterialStateCompiler;
import sporemodder.file.rw4.RWBBox;
import sporemodder.file.rw4.RWBaseResource;
import sporemodder.file.rw4.RWBlendShapeBuffer;
import sporemodder.file.rw4.RWCompiledState;
import sporemodder.file.rw4.RWHeader.RenderWareType;
import sporemodder.file.rw4.RWIndexBuffer;
import sporemodder.file.rw4.RWMesh;
import sporemodder.file.rw4.RWMeshCompiledStateLink;
import sporemodder.file.rw4.RWMorphHandle;
import sporemodder.file.rw4.RWObject;
import sporemodder.file.rw4.RWRaster;
import sporemodder.file.rw4.RWTextureOverride;
import sporemodder.file.rw4.RWVertexBuffer;
import sporemodder.file.rw4.RWVertexElement;
import sporemodder.file.rw4.RenderWare;
import sporemodder.file.shaders.MaterialStateLink;
import sporemodder.util.ProjectItem;
import sporemodder.util.Vector3;
Expand Down Expand Up @@ -213,7 +193,8 @@ public Node getIcon(ProjectItem item) {
private final ScrollPane propertiesContainer = new ScrollPane();
private final TreeView<String> treeView = new TreeView<>();
private final CheckBox cbIgnoreAlpha = new CheckBox("Ignore alpha");


private final TreeItem<String> tiAnimations = new TreeItem<String>("Animations");
private final TreeItem<String> tiMorphs = new TreeItem<String>("Morph Handles");
private final TreeItem<String> tiTextures = new TreeItem<String>("Textures");
private final TreeItem<String> tiExternalTextures = new TreeItem<String>("External Textures");
Expand Down Expand Up @@ -242,8 +223,9 @@ private RWModelViewer() {
treeView.setRoot(rootItem);
treeView.setShowRoot(false);
treeView.setMaxHeight(TREE_VIEW_HEIGHT);

rootItem.getChildren().add(tiMorphs);

rootItem.getChildren().add(tiAnimations);
rootItem.getChildren().add(tiMorphs);
rootItem.getChildren().add(tiTextures);
rootItem.getChildren().add(tiExternalTextures);
rootItem.getChildren().add(tiCompiledStates);
Expand Down Expand Up @@ -734,6 +716,12 @@ private void fillTreeView() {
itemsMap.put(name, item);
tiMorphs.getChildren().add(item);
}

List<RWAnimations> animations = renderWare.getObjects(RWAnimations.class);
if (!animations.isEmpty()) {
nameMap.put("Animations", animations.get(0));
itemsMap.put("Animations", tiAnimations);
}
}
}

Expand Down Expand Up @@ -802,7 +790,7 @@ public boolean supportsEditHistory() {

private void fillPropertiesPane(TreeItem<String> item, String selectedName) {
RWObject object = nameMap.get(selectedName);

if (object instanceof RWMorphHandle) {
fillMorphPane(item, selectedName, (RWMorphHandle) object);
return;
Expand All @@ -821,9 +809,25 @@ else if (object instanceof RWCompiledState) {
}, "Error with compiled state.");
// We don't return because we want to empty the properties container
}
else if (object instanceof RWAnimations) {
fillAnimationsPane(item, (RWAnimations) object);
return;
}

propertiesContainer.setContent(null);
}

private void fillAnimationsPane(TreeItem<String> item, RWAnimations animations) {
PropertyPane pane = new PropertyPane();

for (int animationID : animations.animations.keySet()) {
Label label = new Label(HashManager.get().getFileName(animationID));
label.getStyleClass().add("inspector-value-label");
pane.add(label);
}

propertiesContainer.setContent(pane.getNode());
}

private void fillExternalTexturePane(TreeItem<String> item, String name, RWTextureOverride texture) {
PropertyPane pane = new PropertyPane();
Expand Down

0 comments on commit b76c6ad

Please sign in to comment.