mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-27 02:40:51 +01:00
only display 'play'-button in extensions view if its used
This commit is contained in:
parent
86c546adc6
commit
4b6ad8fd05
@ -86,7 +86,8 @@ public abstract class Extension {
|
|||||||
response.appendString(getTitle())
|
response.appendString(getTitle())
|
||||||
.appendString(getAuthor())
|
.appendString(getAuthor())
|
||||||
.appendString(getVersion())
|
.appendString(getVersion())
|
||||||
.appendString(getDescription());
|
.appendString(getDescription())
|
||||||
|
.appendBoolean(isOnClickMethodUsed());
|
||||||
writeToStream(response.toBytes());
|
writeToStream(response.toBytes());
|
||||||
}
|
}
|
||||||
else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.CONNECTIONSTART) {
|
else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.CONNECTIONSTART) {
|
||||||
@ -255,6 +256,16 @@ public abstract class Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isOnClickMethodUsed() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return !getClass().getDeclaredMethod("onClick").getDeclaringClass().equals(Extension.class);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets called when a connection has been established with G-Earth.
|
* Gets called when a connection has been established with G-Earth.
|
||||||
* This does not imply a connection with Habbo is setup.
|
* This does not imply a connection with Habbo is setup.
|
||||||
|
@ -40,10 +40,10 @@ public class AdminOnConnect extends Extension {
|
|||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected void onClick() {
|
// protected void onClick() {
|
||||||
System.out.println("clicked");
|
// System.out.println("clicked");
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected String getTitle() {
|
protected String getTitle() {
|
||||||
return "Always admin!";
|
return "Always admin!";
|
||||||
|
@ -69,11 +69,13 @@ public class ExtensionItemContainer extends GridPane {
|
|||||||
deleteButton.show();
|
deleteButton.show();
|
||||||
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
|
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
|
||||||
SimpleClickButton clickButton = new SimpleClickButton();
|
SimpleClickButton clickButton = new SimpleClickButton();
|
||||||
clickButton.show();
|
if (item.isFireButtonUsed()) {
|
||||||
|
clickButton.show();
|
||||||
|
}
|
||||||
clickButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isClickTrigger());
|
clickButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isClickTrigger());
|
||||||
|
|
||||||
HBox buttonsBox = new HBox(clickButton, deleteButton);
|
HBox buttonsBox = new HBox(clickButton, deleteButton);
|
||||||
buttonsBox.setSpacing(10);
|
buttonsBox.setSpacing(item.isFireButtonUsed() ? 10 : 0);
|
||||||
buttonsBox.setAlignment(Pos.CENTER);
|
buttonsBox.setAlignment(Pos.CENTER);
|
||||||
GridPane.setMargin(buttonsBox, new Insets(0, 5, 0, 5));
|
GridPane.setMargin(buttonsBox, new Insets(0, 5, 0, 5));
|
||||||
add(buttonsBox, 4, 0);
|
add(buttonsBox, 4, 0);
|
||||||
|
@ -23,6 +23,7 @@ public class GEarthExtension {
|
|||||||
private String author;
|
private String author;
|
||||||
private String version;
|
private String version;
|
||||||
private String description;
|
private String description;
|
||||||
|
private boolean fireEventButtonVisible;
|
||||||
|
|
||||||
private Socket connection;
|
private Socket connection;
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ public class GEarthExtension {
|
|||||||
packet.readString(),
|
packet.readString(),
|
||||||
packet.readString(),
|
packet.readString(),
|
||||||
packet.readString(),
|
packet.readString(),
|
||||||
|
packet.readBoolean(),
|
||||||
connection,
|
connection,
|
||||||
onDisconnectedCallback
|
onDisconnectedCallback
|
||||||
);
|
);
|
||||||
@ -70,11 +72,12 @@ public class GEarthExtension {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private GEarthExtension(String title, String author, String version, String description, Socket connection, OnDisconnectedCallback onDisconnectedCallback) {
|
private GEarthExtension(String title, String author, String version, String description, boolean fireEventButtonVisible, Socket connection, OnDisconnectedCallback onDisconnectedCallback) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.author = author;
|
this.author = author;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.fireEventButtonVisible = fireEventButtonVisible;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
|
||||||
GEarthExtension selff = this;
|
GEarthExtension selff = this;
|
||||||
@ -139,6 +142,10 @@ public class GEarthExtension {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFireButtonUsed() {
|
||||||
|
return fireEventButtonVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean closeConnection() {
|
public boolean closeConnection() {
|
||||||
|
Loading…
Reference in New Issue
Block a user