Skip to content

Commit

Permalink
export proper mod power tips with modid, export intent images too
Browse files Browse the repository at this point in the history
  • Loading branch information
avolny committed Feb 20, 2020
1 parent 08d1946 commit ed440d7
Showing 1 changed file with 46 additions and 7 deletions.
53 changes: 46 additions & 7 deletions src/main/java/str_exporter/JSONMessageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,27 @@ private void buildMonsterPowers(StringBuilder sb) {
sb.append(']');
}

private static PowerTip createPowerTip(AbstractPower p) {
PowerTip tip;
if (p.region48 != null) {
tip = new PowerTip(p.name, p.description, p.region48);
} else {
tip = new PowerTip(p.name, p.description);
}

String modName = WhatMod.findModName(p.getClass());

if (WhatMod.enabled && modName != null) {
tip.body = FontHelper.colorString(modName, "p") + " NL " + tip.body;
}

return tip;
}

private void buildPowers(StringBuilder sb, ArrayList<AbstractPower> powers, ArrayList<PowerTip> tipsPrefix) {
ArrayList<PowerTip> tips = (ArrayList<PowerTip>) tipsPrefix.clone();
for (AbstractPower p: powers) {
if (p.region48 != null) {
tips.add(new PowerTip(p.name, p.description, p.region48));
} else {
tips.add(new PowerTip(p.name, p.description));
}
tips.add(createPowerTip(p));
}

sb.append('[');
Expand Down Expand Up @@ -226,8 +239,10 @@ private void buildPowerTips(StringBuilder sb) {

private int getPowerTipIndex(PowerTip tip) {
String tipStr = "";
if (tip.imgRegion != null) {
tipStr = powerTipJson(tip.header, tip.body, tip.imgRegion.name);
if (tip.imgRegion != null && tip.imgRegion.name != null) {
tipStr = powerTipJson(tip.header, tip.body, "powers/" + tip.imgRegion.name);
} else if(tip.img != null) {
tipStr = powerTipJson(tip.header, tip.body, getImageCode(tip.img));
} else {
tipStr = powerTipJson(tip.header, tip.body);
}
Expand All @@ -241,6 +256,30 @@ private int getPowerTipIndex(PowerTip tip) {
return index;
}

private static String getImageCode(Texture img) {
if (img.equals(ImageMaster.INTENT_ATK_TIP_1)) return "intents/tip/1";
if (img.equals(ImageMaster.INTENT_ATK_TIP_2)) return "intents/tip/2";
if (img.equals(ImageMaster.INTENT_ATK_TIP_3)) return "intents/tip/3";
if (img.equals(ImageMaster.INTENT_ATK_TIP_4)) return "intents/tip/4";
if (img.equals(ImageMaster.INTENT_ATK_TIP_5)) return "intents/tip/5";
if (img.equals(ImageMaster.INTENT_ATK_TIP_6)) return "intents/tip/6";
if (img.equals(ImageMaster.INTENT_ATK_TIP_7)) return "intents/tip/7";
if (img.equals(ImageMaster.INTENT_BUFF)) return "intents/buff1";
if (img.equals(ImageMaster.INTENT_DEBUFF)) return "intents/debuff1";
if (img.equals(ImageMaster.INTENT_DEBUFF2)) return "intents/debuff2";
if (img.equals(ImageMaster.INTENT_DEFEND)) return "intents/defend";
if (img.equals(ImageMaster.INTENT_DEFEND_BUFF)) return "intents/defendBuff";
if (img.equals(ImageMaster.INTENT_ESCAPE)) return "intents/escape";
if (img.equals(ImageMaster.INTENT_MAGIC)) return "intents/magic";
if (img.equals(ImageMaster.INTENT_SLEEP)) return "intents/sleep";
if (img.equals(ImageMaster.INTENT_STUN)) return "intents/stun";
if (img.equals(ImageMaster.INTENT_UNKNOWN)) return "intents/unknown";
if (img.equals(ImageMaster.INTENT_ATTACK_BUFF)) return "intents/attackBuff";
if (img.equals(ImageMaster.INTENT_ATTACK_DEBUFF)) return "intents/attackDebuff";
if (img.equals(ImageMaster.INTENT_ATTACK_DEFEND)) return "intents/attackDefend";
return "placeholder";
}

private static String powerTipJson(String header, String body) {
return String.format(
"{\"name\": \"%s\", \"description\": \"%s\"}",
Expand Down

0 comments on commit ed440d7

Please sign in to comment.