LexiconEntries now have a getWebLink() function that can be used to have a custom "View Online" button. This removes the need to check for IAddonEntry when adding the button.

This commit is contained in:
Lizbeth Rika committed 2015-04-19 18:10:49 +01:00
1 parent 9fded6170d
commit 8ea997c850
3 files changed
+17 -2

No files matched your search

@@ -92,6 +92,15 @@ public class LexiconEntry implements Comparable<LexiconEntry> {
return this;
}
/**
* Returns the web link for this entry. If this isn't null, looking at this entry will
* show a "View Online" button in the book. The String returned should be the URL to
* open when the button is clicked.
*/
public String getWebLink() {
return null;
}
/**
* Adds a page to the list of pages.
*/
@@ -107,4 +116,5 @@ public class LexiconEntry implements Comparable<LexiconEntry> {
public int compareTo(LexiconEntry o) {
return getNameForSorting().compareTo(o.getNameForSorting());
}
}
@@ -62,7 +62,7 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false));
buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true));
buttonList.add(new GuiButtonShare(3, left + guiWidth - 6, top - 2));
if(!(entry instanceof IAddonEntry))
if(entry.getWebLink() != null)
buttonList.add(new GuiButtonViewOnline(4, left - 8, top + 8));
if(!GuiLexicon.isValidLexiconGui(this)) {
@@ -149,7 +149,7 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
case 4 :
try {
if(Desktop.isDesktopSupported())
Desktop.getDesktop().browse(new URI("http://botaniamod.net/lexicon.php#" + entry.unlocalizedName));
Desktop.getDesktop().browse(new URI(entry.getWebLink()));
} catch(Exception e) {
e.printStackTrace();
}
@@ -45,4 +45,9 @@ public class BLexiconEntry extends LexiconEntry {
return super.getUnlocalizedName();
}
@Override
public String getWebLink() {
return "http://botaniamod.net/lexicon.php#" + unlocalizedName;
}
}