summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/LibraryEntry.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/LibraryEntry.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/LibraryEntry.java')
-rw-r--r--NET/worlds/scape/LibraryEntry.java141
1 files changed, 141 insertions, 0 deletions
diff --git a/NET/worlds/scape/LibraryEntry.java b/NET/worlds/scape/LibraryEntry.java
new file mode 100644
index 0000000..415c35a
--- /dev/null
+++ b/NET/worlds/scape/LibraryEntry.java
@@ -0,0 +1,141 @@
+package NET.worlds.scape;
+
+import NET.worlds.network.URL;
+import java.io.IOException;
+
+public class LibraryEntry extends SuperRoot implements Iconic {
+ protected URL iconURL;
+ protected URL contentURL;
+ protected String propertyName;
+ private static Object classCookie = new Object();
+
+ public LibraryEntry() {
+ }
+
+ public LibraryEntry(String name, URL iconURL) {
+ this.setName(name);
+ this.iconURL = iconURL;
+ }
+
+ private void changed() {
+ Library owner = (Library)this.getOwner();
+ if (owner != null) {
+ owner.entryChanged(this);
+ }
+ }
+
+ @Override
+ public String getIconCaption() {
+ return this.getName();
+ }
+
+ @Override
+ public URL getIconURL() {
+ return this.iconURL;
+ }
+
+ public URL getContentURL() {
+ return this.contentURL;
+ }
+
+ public String getPropertyName(boolean checkParent) {
+ Library owner;
+ return this.propertyName == null && checkParent && (owner = (Library)this.getOwner()) != null ? owner.getPropertyName() : this.propertyName;
+ }
+
+ @Override
+ public void setName(String s) {
+ super.setName(s);
+ this.changed();
+ }
+
+ public void setIconURL(URL s) {
+ this.iconURL = s;
+ this.changed();
+ }
+
+ public void setContentURL(URL s) {
+ this.contentURL = s;
+ this.changed();
+ }
+
+ public void setPropertyName(String s) {
+ this.propertyName = s;
+ this.changed();
+ }
+
+ @Override
+ public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
+ Object ret = null;
+ switch (index - offset) {
+ case 0:
+ if (mode == 0) {
+ ret = URLPropertyEditor.make(new Property(this, index, "Icon").allowSetNull(), TextureDecoder.getJavaExts());
+ } else if (mode == 1) {
+ ret = this.getIconURL();
+ } else if (mode == 2) {
+ this.setIconURL((URL)value);
+ }
+ break;
+ case 1:
+ if (mode == 0) {
+ ret = URLPropertyEditor.make(new Property(this, index, "Content URL").allowSetNull(), "*wob");
+ } else if (mode == 1) {
+ ret = this.contentURL;
+ } else if (mode == 2) {
+ this.setContentURL((URL)value);
+ }
+ break;
+ case 2:
+ if (mode == 0) {
+ ret = StringPropertyEditor.make(new Property(this, index, "Property Name").allowSetNull());
+ } else if (mode == 1) {
+ ret = this.getPropertyName(false);
+ } else if (mode == 2) {
+ this.setPropertyName((String)value);
+ }
+ break;
+ default:
+ ret = super.properties(index, offset + 3, mode, value);
+ }
+
+ return ret;
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(3, classCookie);
+ super.saveState(s);
+ URL.save(s, this.iconURL);
+ URL.save(s, this.contentURL);
+ s.saveString(this.propertyName);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 1:
+ super.restoreState(r);
+ case 0:
+ this.setName(r.restoreString());
+ this.iconURL = URL.restore(r);
+ this.contentURL = URL.restore(r);
+ r.restoreMaybeNull();
+ break;
+ case 2:
+ super.restoreState(r);
+ this.setName(r.restoreString());
+ this.iconURL = URL.restore(r);
+ this.contentURL = URL.restore(r);
+ break;
+ case 3:
+ super.restoreState(r);
+ this.iconURL = URL.restore(r);
+ this.contentURL = URL.restore(r);
+ this.propertyName = r.restoreString();
+ break;
+ default:
+ throw new TooNewException();
+ }
+ }
+}