Skip to content

Commit

Permalink
fixup! (C) 新制mod页面
Browse files Browse the repository at this point in the history
  • Loading branch information
MinRi2 committed Apr 20, 2024
1 parent f8562b1 commit 0c246aa
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 33 deletions.
43 changes: 23 additions & 20 deletions core/assets/bundles/bundle-mdtx.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
#UI
join.addressCopyHint = 复制服务器地址:[accent]{0}
join.addressCopySuccessfully = 复制地址成功:[accent]{0}
join.addServerHint = 添加服务器: [accent]{0}
join.addServerSuccessfully = 添加服务器成功: [accent]{0}

mods.disable = 禁用Mod

mods.recommend = [accent]MdtX[]推荐辅助模组列表
mods.recommend.lastUpdated = 推荐列表更新时间:{0}
mods.recommend.info = 经过精选的辅助模组
mods.recommend.mod.description = 经过精选的推荐模组
mods.recommend.mod.name = 模组:{0}
mods.recommend.mod.author = 作者: {0}
mods.recommend.mod.minGameVersion = 最低支持游戏版本:{0}
mods.recommend.mod.lastUpdated = 上次更新时间:{0}
mods.recommend.mod.stars = Github收藏数:{0}

alphaLoading = {jump}[gray]加载中...
alphaLoadFailed = {sick}[gray]加载失败...
#end UI

status.slow.name = 缓慢
status.shielded.name = 保护
status.corroded.name = 腐蚀
Expand Down Expand Up @@ -588,23 +610,4 @@ marker.attack.description = 标记攻击位置
marker.defense.description = 标记守护位置
marker.question.description = 问号

settings.maxMsgRecorded.name = 最大聊天记录数

join.addressCopyHint = 复制服务器地址:[accent]{0}
join.addressCopySuccessfully = 复制地址成功:[accent]{0}
join.addServerHint = 添加服务器: [accent]{0}
join.addServerSuccessfully = 添加服务器成功: [accent]{0}

mods.disable = 禁用Mod

mods.recommend = [accent]MdtX[]推荐辅助模组列表
mods.recommend.lastUpdated = 推荐列表更新时间:{0}
mods.recommend.info = 经过精选的辅助模组
mods.recommend.mod.description = 经过精选的推荐模组
mods.recommend.mod.name = 模组:{0}
mods.recommend.mod.author = 作者: {0}
mods.recommend.mod.minGameVersion = 最低支持游戏版本:{0}
mods.recommend.mod.lastUpdated = 上次更新时间:{0}
mods.recommend.mod.stars = Github收藏数:{0}

alphaLoading = {jump}[gray]加载中...
settings.maxMsgRecorded.name = 最大聊天记录数
41 changes: 28 additions & 13 deletions core/src/mindustryX/features/ui/ModsRecommendDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ModsRecommendDialog extends BaseDialog{

private ObjectMap<String, TextureRegion> textureCache;
private RecommendMeta meta;
private boolean fetchModList;

public ModsRecommendDialog(){
super("");
Expand All @@ -54,26 +55,36 @@ private void rebuild(){
textureCache = Reflect.get(Vars.ui.mods, "textureCache");
}

if(meta != null){
rebuildCont();
return;
if(meta == null){
String json = Core.files.internal("recommendMods.json").readString();

meta = JsonIO.json.fromJson(RecommendMeta.class, json);
}

String json = Core.files.internal("recommendMods.json").readString();
if(!fetchModList){
ElementX.setLoading(cont);

meta = JsonIO.json.fromJson(RecommendMeta.class, json);
Reflect.invoke(Vars.ui.mods, "getModList", new Cons[]{listings -> {
Seq<ModListing> modListings = (Seq<ModListing>)listings;

ElementX.setLoading(cont);
// ???
if(modListings == null){
ElementX.setLoadFailed(cont);
return;
}

Reflect.invoke(Vars.ui.mods, "getModList", new Cons[]{listings -> {
Seq<ModListing> modListings = (Seq<ModListing>)listings;
for(RecommendModMeta modMeta : meta.modRecommend){
modMeta.listing = modListings.find(modListing -> modMeta.repo.equals(modListing.repo));
}

for(RecommendModMeta modMeta : meta.modRecommend){
modMeta.listing = modListings.find(modListing -> modMeta.repo.equals(modListing.repo));
}
fetchModList = true;
rebuildCont();
}}, Cons.class);

rebuildCont();
}}, Cons.class);
return;
}

rebuildCont();
}

private void rebuildCont(){
Expand Down Expand Up @@ -123,6 +134,10 @@ private void setupModCard(Table table, RecommendModMeta modMeta){
table.defaults().growX();

ModListing modListing = modMeta.listing;
if(modListing == null){
Log.warn("Recommend Mod '@' not found in github.", modMeta.repo);
return;
}

table.table(title -> {
title.add(new Card(Pal.gray, StylesX.grayOuterDark, info -> {
Expand Down
5 changes: 5 additions & 0 deletions core/src/mindustryX/utils/ElementX.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public static void setLoading(Table table){
table.add(new FLabel("@alphaLoading")).style(Styles.outlineLabel).expand().center();
}

public static void setLoadFailed(Table table){
table.clearChildren();
table.add(new FLabel("@alphaLoadFailed")).style(Styles.outlineLabel).expand().center();
}

public static void cardShadow(Table table){
cardShadow(table, 8f, Pal.darkerGray);
}
Expand Down

0 comments on commit 0c246aa

Please sign in to comment.