summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/LibEntContentEditorDialog.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/LibEntContentEditorDialog.java
downloadworlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz
worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/scape/LibEntContentEditorDialog.java')
-rw-r--r--NET/worlds/scape/LibEntContentEditorDialog.java170
1 files changed, 170 insertions, 0 deletions
diff --git a/NET/worlds/scape/LibEntContentEditorDialog.java b/NET/worlds/scape/LibEntContentEditorDialog.java
new file mode 100644
index 0000000..7b3949a
--- /dev/null
+++ b/NET/worlds/scape/LibEntContentEditorDialog.java
@@ -0,0 +1,170 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.console.Console;
+/* */ import NET.worlds.console.OkCancelDialog;
+/* */ import java.awt.Choice;
+/* */ import java.awt.Event;
+/* */ import java.awt.GridBagConstraints;
+/* */ import java.awt.List;
+/* */ import java.awt.TextField;
+/* */ import java.util.Enumeration;
+/* */ import java.util.StringTokenizer;
+/* */ import java.util.Vector;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ class LibEntContentEditorDialog
+/* */ extends OkCancelDialog
+/* */ {
+/* */ private static final long serialVersionUID = 1L;
+/* */ private Property property;
+/* 32 */ private TextField strField = new TextField(40);
+/* 33 */ private List list = new List();
+/* 34 */ private Choice choice = new Choice();
+/* */
+/* */ private EditTile parent;
+/* 37 */ private static String[] choices = {
+/* 38 */ "WObject files",
+/* 39 */ "Behavior/Action files",
+/* 40 */ "Texture files" };
+/* */
+/* */
+/* 43 */ private static String[] dirs = {
+/* 44 */ LibrariesTile.getLibSubdir(),
+/* 45 */ LibrariesTile.getLibSubdir(),
+/* 46 */ LibrariesTile.getLibSubdir() };
+/* */
+/* */
+/* 49 */ private static String[] exts = {
+/* 50 */ WObject.getSaveExtension(),
+/* 51 */ "class",
+/* 52 */ TextureDecoder.getAllExts() };
+/* */
+/* */
+/* */
+/* */ LibEntContentEditorDialog(EditTile parent, String title, Property property)
+/* */ {
+/* 58 */ super(Console.getFrame(), parent, title);
+/* 59 */ this.property = property;
+/* 60 */ this.parent = parent;
+/* 61 */ ready();
+/* */ }
+/* */
+/* */ private void matchExt(String name)
+/* */ {
+/* 66 */ int lastDot = name.lastIndexOf('.');
+/* 67 */ if (lastDot != -1) {
+/* 68 */ String ext = name.substring(lastDot + 1).toLowerCase();
+/* 69 */ for (int i = 0; i < exts.length; i++) {
+/* 70 */ StringTokenizer t = new StringTokenizer(exts[i], ";");
+/* 71 */ while (t.hasMoreTokens()) {
+/* 72 */ if (ext.equals(t.nextToken())) {
+/* 73 */ this.choice.select(i);
+/* 74 */ return;
+/* */ }
+/* */ }
+/* */ }
+/* */ }
+/* */ }
+/* */
+/* */ protected void build() {
+/* 82 */ for (int i = 0; i < choices.length; i++) {
+/* 83 */ this.choice.addItem(choices[i]);
+/* */ }
+/* 85 */ String name = (String)this.property.get();
+/* 86 */ if (name == null) {
+/* 87 */ name = "";
+/* */ }
+/* 89 */ this.strField.setText(name);
+/* */
+/* 91 */ matchExt(name);
+/* */
+/* 93 */ setListContents();
+/* */
+/* 95 */ GridBagConstraints c = new GridBagConstraints();
+/* 96 */ c.fill = 2;
+/* 97 */ c.weightx = 1.0D;
+/* 98 */ c.weighty = 1.0D;
+/* 99 */ c.gridwidth = 0;
+/* 100 */ add(this.gbag, this.strField, c);
+/* 101 */ c.gridheight = 6;
+/* 102 */ add(this.gbag, this.list, c);
+/* 103 */ c.gridheight = 1;
+/* 104 */ add(this.gbag, this.choice, c);
+/* 105 */ super.build();
+/* */ }
+/* */
+/* */ private void setListContents()
+/* */ {
+/* 110 */ int count = this.list.getItemCount();
+/* 111 */ if (count != 0)
+/* */ {
+/* 113 */ this.list.removeAll();
+/* */ }
+/* 115 */ int chosen = this.choice.getSelectedIndex();
+/* 116 */ Enumeration<String> files = new FileList(dirs[chosen], exts[chosen])
+/* 117 */ .getList().elements();
+/* 118 */ while (files.hasMoreElements()) {
+/* 119 */ this.list.add((String)files.nextElement());
+/* */ }
+/* 121 */ String s = (String)this.property.get();
+/* 122 */ this.strField.setText(s != null ? s : "");
+/* */ }
+/* */
+/* */ @Deprecated
+/* */ public boolean handleEvent(Event event) {
+/* 127 */ if (event.id == 701) {
+/* 128 */ this.strField.setText(this.list.getSelectedItem());
+/* 129 */ this.strField.selectAll();
+/* */ }
+/* 131 */ return super.handleEvent(event);
+/* */ }
+/* */
+/* */ @Deprecated
+/* */ public boolean action(Event event, Object what)
+/* */ {
+/* 137 */ if (event.target == this.list)
+/* 138 */ event.target = this.okButton;
+/* 139 */ if (event.target == this.choice)
+/* 140 */ setListContents();
+/* 141 */ return super.action(event, what);
+/* */ }
+/* */
+/* */ protected boolean setValue()
+/* */ {
+/* 146 */ String text = this.strField.getText().trim();
+/* 147 */ if (text.length() != 0) {
+/* 148 */ this.parent.addUndoableSet(this.property, text);
+/* 149 */ return true;
+/* */ }
+/* 151 */ return false;
+/* */ }
+/* */
+/* */
+/* */
+/* */ public void setVisible(boolean visible)
+/* */ {
+/* 158 */ super.setVisible(visible);
+/* 159 */ if (visible) {
+/* 160 */ this.strField.requestFocus();
+/* 161 */ this.strField.selectAll();
+/* */ }
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\LibEntContentEditorDialog.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file