mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-10 20:37:30 -04:00
add lite mod description in mod panel.
This commit is contained in:
parent
73a9fbb1c4
commit
b6cb5f0bee
@ -26,6 +26,7 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
import org.jackhuang.hellominecraft.C;
|
import org.jackhuang.hellominecraft.C;
|
||||||
import org.jackhuang.hellominecraft.HMCLog;
|
import org.jackhuang.hellominecraft.HMCLog;
|
||||||
|
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +36,7 @@ import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
|||||||
public class ModInfo implements Comparable<ModInfo> {
|
public class ModInfo implements Comparable<ModInfo> {
|
||||||
|
|
||||||
public File location;
|
public File location;
|
||||||
public String modid, name, description, version, mcversion, url, updateUrl, credits;
|
public String modid, name, description, author, version, mcversion, url, updateUrl, credits;
|
||||||
public String[] authorList;
|
public String[] authorList;
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
@ -50,6 +51,14 @@ public class ModInfo implements Comparable<ModInfo> {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return name == null ? FileUtils.removeExtension(location.getName()) : name;
|
return name == null ? FileUtils.removeExtension(location.getName()) : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAuthor() {
|
||||||
|
if (authorList != null && authorList.length > 0)
|
||||||
|
return StrUtils.parseParams("", authorList, ", ");
|
||||||
|
else if (StrUtils.isNotBlank(author))
|
||||||
|
return author;
|
||||||
|
else return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
@ -82,10 +91,13 @@ public class ModInfo implements Comparable<ModInfo> {
|
|||||||
try {
|
try {
|
||||||
ZipFile jar = new ZipFile(f);
|
ZipFile jar = new ZipFile(f);
|
||||||
ZipEntry entry = jar.getEntry("mcmod.info");
|
ZipEntry entry = jar.getEntry("mcmod.info");
|
||||||
|
if (entry == null)
|
||||||
|
entry = jar.getEntry("litemod.json");
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return i;
|
return i;
|
||||||
else {
|
else {
|
||||||
List<ModInfo> m = C.gson.fromJson(new InputStreamReader(jar.getInputStream(entry)), new TypeToken<List<ModInfo>>() {
|
List<ModInfo> m = C.gson.fromJson(new InputStreamReader(jar.getInputStream(entry)),
|
||||||
|
new TypeToken<List<ModInfo>>() {
|
||||||
}.getType());
|
}.getType());
|
||||||
if (m != null && m.size() > 0) {
|
if (m != null && m.size() > 0) {
|
||||||
i = m.get(0);
|
i = m.get(0);
|
||||||
@ -93,12 +105,10 @@ public class ModInfo implements Comparable<ModInfo> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
jar.close();
|
jar.close();
|
||||||
return i;
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
HMCLog.warn("File " + f + " is not a jar.", ex);
|
HMCLog.warn("File " + f + " is not a jar.", ex);
|
||||||
return i;
|
} catch (JsonSyntaxException ignore) {
|
||||||
} catch (JsonSyntaxException e) {
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,7 @@ public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetL
|
|||||||
ModInfo m = mods.get(row);
|
ModInfo m = mods.get(row);
|
||||||
boolean hasLink = m.url != null;
|
boolean hasLink = m.url != null;
|
||||||
String text = "<html>" + (hasLink ? "<a href=\"" + m.url + "\">" : "") + m.getName() + (hasLink ? "</a>" : "");
|
String text = "<html>" + (hasLink ? "<a href=\"" + m.url + "\">" : "") + m.getName() + (hasLink ? "</a>" : "");
|
||||||
if (m.authorList != null && m.authorList.length > 0)
|
text += " by " + m.getAuthor();
|
||||||
text += " by " + StrUtils.parseParams("", m.authorList, ", ");
|
|
||||||
text += "<br>" + (m.description == null ? "No mcmod.info found" : SwingUtils.getParsedJPanelText(lblModInfo, m.description));
|
text += "<br>" + (m.description == null ? "No mcmod.info found" : SwingUtils.getParsedJPanelText(lblModInfo, m.description));
|
||||||
lblModInfo.setText(text);
|
lblModInfo.setText(text);
|
||||||
lblModInfo.setCursor(new java.awt.Cursor(hasLink ? java.awt.Cursor.HAND_CURSOR : java.awt.Cursor.DEFAULT_CURSOR));
|
lblModInfo.setCursor(new java.awt.Cursor(hasLink ? java.awt.Cursor.HAND_CURSOR : java.awt.Cursor.DEFAULT_CURSOR));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user