Added support for http links.

This commit is contained in:
Florian Nücke 2015-04-08 14:42:41 +02:00
parent 6b4e5f0e0d
commit bf9a41e1d2
4 changed files with 22 additions and 1 deletions

View File

@ -171,6 +171,7 @@ oc:gui.Chat.NewVersion=Eine neue Version ist verfügbar: %s
oc:gui.Chat.TextureName=§7Texturname ist §a%s§f.
oc:gui.Chat.WarningClassTransformer=Es gab §cFehler§f beim Ausführen des Class-Transformers. Bitte melde dies, zusammen mit deiner (vollständigen!) FML §alatest.log§f/§afml-server-latest.log§f Log-Datei, danke!
oc:gui.Chat.WarningFingerprint=§cWARNUNG§f - ungültige Signatur! Sollte '§a%s§f' sein, aber war '§e%s§f'. Falls du kein Modder bist und die "deobfuscated"-Version des Mods benutzt, solltest du OpenComputers erneut herunterladen, da die JAR, die du benutzt, vermutlich modifiziert wurde.
oc:gui.Chat.WarningLink=Link konnte nicht geöffnet werden: %s
oc:gui.Chat.WarningLuaFallback=Die native Lua-Implementierung ist nicht verfügbar. Computer können ihren Ausführungszustand nicht speichern. Sie werden automatisch neu starten, sobald ein Chunk neu geladen wird.
oc:gui.Chat.WarningPower=Es ist keine unterstützte, Strom erzeugende Mod verfügbar. Computer, Bildschirme und alle anderen Komponenten werden §lkeine§f Energie benötigen. Installiere eine der folgenden Mods, um Stromnutzung zu ermöglichen: BuildCraft, Electrical Age, IndustrialCraft2, Mekanism oder Thermal Expansion. Deaktiviere Stromverbrauch in der Konfiguration, um diese Warnung zu unterdrücken.
oc:gui.Chat.WarningProjectRed=Die verwendete Version von Project: Red ist nicht mit OpenComputers kompatibel. Aktualisiere bitte deine Version von Project: Red.

View File

@ -171,6 +171,7 @@ oc:gui.Chat.NewVersion=A new version is available: %s
oc:gui.Chat.TextureName=§7Texture name is §a%s§f.
oc:gui.Chat.WarningClassTransformer=There were §cerrors§f running the class transformer. Please report this, together with your (full!) FML §alatest.log§f/§afml-server-latest.log§f logfile, thank you!
oc:gui.Chat.WarningFingerprint=§cWARNING§f - fingerprint mismatch! Expected '§a%s§f' but got '§e%s§f'. Unless you are a modder and are running the deobfuscated version of the mod, it is §lstrongly§f recommended to redownload OpenComputers, because the JAR you are using may have been tampered with.
oc:gui.Chat.WarningLink=Could not open link: %s
oc:gui.Chat.WarningLuaFallback=Native Lua libraries are not available, computers will not be able to persist their state. They will reboot on chunk reloads.
oc:gui.Chat.WarningPower=No supported power providing mod available. Computers, screens and all other components will §lnot§f require energy. Install one of the following mods to enable power: BuildCraft, Electrical Age, IndustrialCraft2, Mekanism or Thermal Expansion. Disable power in the config to suppress this warning.
oc:gui.Chat.WarningProjectRed=You are using a version of Project: Red that is incompatible with OpenComputers. Try updating your version of Project: Red.

View File

@ -89,6 +89,8 @@ object Localization {
def WarningSimpleComponent = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.WarningSimpleComponent"))
def WarningLink(url: String) = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.WarningLink", url))
def InfoNewVersion(version: String) = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.NewVersion", version))
def TextureName(name: String) = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.TextureName", name))

View File

@ -1,9 +1,11 @@
package li.cil.oc.client.gui
import java.io.InputStream
import java.net.URI
import java.util
import com.google.common.base.Charsets
import li.cil.oc.Localization
import li.cil.oc.Settings
import li.cil.oc.client.Textures
import li.cil.oc.util.PseudoMarkdown
@ -146,7 +148,10 @@ class Manual extends GuiScreen {
}
else if (button == 0) {
// Left click, did we hit a link?
hoveredLink.foreach(link => pushPage(link))
hoveredLink.foreach(link => {
if (link.startsWith("http://") || link.startsWith("https://")) handleUrl(link)
else pushPage(link)
})
}
else if (button == 1) {
// Right mouseclick = back.
@ -154,6 +159,18 @@ class Manual extends GuiScreen {
}
}
private def handleUrl(url: String): Unit = {
// Pretty much copy-paste from GuiChat.
try {
val desktop = Class.forName("java.awt.Desktop")
val instance = desktop.getMethod("getDesktop").invoke(null)
desktop.getMethod("browse", classOf[URI]).invoke(instance, new URI(url))
}
catch {
case t: Throwable => Minecraft.getMinecraft.thePlayer.addChatMessage(Localization.Chat.WarningLink(t.toString))
}
}
override protected def mouseClickMove(mouseX: Int, mouseY: Int, lastButtonClicked: Int, timeSinceMouseClick: Long) {
super.mouseClickMove(mouseX, mouseY, lastButtonClicked, timeSinceMouseClick)
if (isDragging) {