From 0772eb64c7228870aa343c1ecdc94c959b030ae6 Mon Sep 17 00:00:00 2001 From: zxcPandora <1158500986@qq.com> Date: Sun, 15 Oct 2023 22:22:09 +0800 Subject: [PATCH 1/3] Localized language and Better player experience --- .../assets/messages/actors/actors.properties | 17 ++++++- .../custom/testmode/SpawnWeapon.java | 46 +++++++++++-------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/core/src/main/assets/messages/actors/actors.properties b/core/src/main/assets/messages/actors/actors.properties index 8665bbc85..a980ab5f6 100644 --- a/core/src/main/assets/messages/actors/actors.properties +++ b/core/src/main/assets/messages/actors/actors.properties @@ -497,8 +497,21 @@ custom.testmode.mobplacer.elite=精英词缀数量 custom.testmode.spawnweapon.name=武器生成秘卷 custom.testmode.spawnweapon.desc=生成需要的武器以及属性。\n\n原作者:Alexstrasza\n\n复刻者:潘多拉\n\n优化者:KDSALing custom.testmode.spawnweapon.ac_spawn=生成 -name = 请先选择附魔种类,然后会出现对应的编号。\n\n通过下方滑块滑动选择对应的编号即可。 -custom.testmode.spawnweapon$weaponsetting.selected=选择 +custom.testmode.spawnweapon$weaponsetting.weapon_tier=武器阶数 +custom.testmode.spawnweapon$weaponsetting.enchant=附魔 +custom.testmode.spawnweapon$weaponsetting.current_enchant=_当前附魔:%s_ +custom.testmode.spawnweapon$weaponsetting.no_enchant=_无附魔_ +custom.testmode.spawnweapon$weaponsetting.enchant_rarity=附魔种类 +custom.testmode.spawnweapon$weaponsetting.enchant_id=附魔编号 +custom.testmode.spawnweapon$weaponsetting.cursed=诅咒物品 +custom.testmode.spawnweapon$weaponsetting.select_weapon=尚未选择武器 +custom.testmode.spawnweapon$weaponsetting.weapon_level=自定义武器等级 +custom.testmode.spawnweapon$weaponsetting.weapon_level_desc=输入要生成的武器的等级,非数字会被自动处理,同时也不能超过6666级 +custom.testmode.spawnweapon$weaponsetting.weapon_level_error=必须选择武器才能打开等级设定界面! +custom.testmode.spawnweapon$weaponsetting.create=生成武器 +custom.testmode.spawnweapon$weaponsetting.enchant_text = 请先选择附魔种类,然后会出现对应的编号。\n\n通过下方滑块滑动选择对应的编号即可。 +custom.testmode.spawnweapon$weaponsetting.confirm=确定 +custom.testmode.spawnweapon$weaponsetting.cancel=取消 actors.buffs.sanity.bad=我感觉我不太好…… diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java index df836c419..28ede869c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java @@ -45,7 +45,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.WndTextNumberInput; import com.shatteredpixel.shatteredpixeldungeon.windows.WndError; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndSadGhost; import com.watabou.noosa.Game; import com.watabou.noosa.Image; import com.watabou.noosa.audio.Sample; @@ -91,8 +90,6 @@ public class SpawnWeapon extends TestItem{ public void execute(Hero hero, String action) { super.execute(hero, action); if (action.equals(AC_SPAWN)){ - //createWeapon(); - //GLog.i(Messages.get(Dungeon.hero, "you_now_have", Messages.get(getEnchant(1,0),"name",new Object[]{"附魔"}))); GameScene.show(new WeaponSetting()); } } @@ -149,6 +146,8 @@ public class SpawnWeapon extends TestItem{ return Kinetic.class; case 3: return Shocking.class; + default: + return null; } case 2: switch (id){ @@ -164,6 +163,8 @@ public class SpawnWeapon extends TestItem{ return Projecting.class; case 5: return Unstable.class; + default: + return null; } case 3: switch (id){ @@ -177,6 +178,8 @@ public class SpawnWeapon extends TestItem{ return HaloBlazing.class; case 4: return Crushing.class; + default: + return null; } case 4: switch (id){ @@ -196,6 +199,8 @@ public class SpawnWeapon extends TestItem{ return Polarized.class; case 7: return Friendly.class; + default: + return null; } } return null; @@ -259,7 +264,7 @@ public class SpawnWeapon extends TestItem{ createWeaponList(tier); // 创建武器阶数选项滑块 - OptionSlider_Tier = new OptionSlider("武器阶数", "1", "6", 1, 6) { + OptionSlider_Tier = new OptionSlider(Messages.get(this, "weapon_tier"), "1", "6", 1, 6) { @Override protected void onChange() { tier = getSelectedValue(); @@ -268,6 +273,7 @@ public class SpawnWeapon extends TestItem{ createWeaponImage(AllWeapon); } }; + OptionSlider_Tier.setSelectedValue(tier); add(OptionSlider_Tier); // 创建武器图标 @@ -275,11 +281,11 @@ public class SpawnWeapon extends TestItem{ // 创建附魔信息文本块 Text_EnchantInfo = PixelScene.renderTextBlock("", 6); - Text_EnchantInfo.text(getEnchantInfo(getEnchant(enchant_rarity, enchant_id))); + updateEnchantText(); add(Text_EnchantInfo); // 创建附魔种类选项滑块 - OptionSlider_EnchantRarity = new OptionSlider("附魔种类", "1", "5", 0, 4) { + OptionSlider_EnchantRarity = new OptionSlider(Messages.get(this, "enchant_rarity"), "1", "5", 0, 4) { @Override protected void onChange() { enchant_rarity = getSelectedValue(); @@ -290,7 +296,7 @@ public class SpawnWeapon extends TestItem{ add(OptionSlider_EnchantRarity); // 创建附魔编号选项滑块 - OptionSlider_EnchantId = new OptionSlider("附魔编号", "1", "8", 0, 7) { + OptionSlider_EnchantId = new OptionSlider(Messages.get(this, "enchant_id"), "1", "8", 0, 7) { @Override protected void onChange() { enchant_id = getSelectedValue(); @@ -301,7 +307,7 @@ public class SpawnWeapon extends TestItem{ add(OptionSlider_EnchantId); // 创建诅咒物品复选框 - CheckBox_Curse = new CheckBox("诅咒物品") { + CheckBox_Curse = new CheckBox(Messages.get(this, "cursed")) { @Override protected void onClick() { super.onClick(); @@ -312,33 +318,34 @@ public class SpawnWeapon extends TestItem{ add(CheckBox_Curse); // 创建武器等级按钮 - Button_Level = new RedButton("尚未选择武器") { + Button_Level = new RedButton(Messages.get(this, "select_weapon")) { @Override protected void onClick() { - if(!Button_Level.text().equals("尚未选择武器")){ // 修改此行代码 + if(!Button_Level.text().equals(Messages.get(SpawnWeapon.WeaponSetting.class, "select_weapon"))){ Game.runOnRenderThread(() -> ShatteredPixelDungeon.scene().add(new WndTextNumberInput( - "自定义武器等级", "输入要生成的武器的等级,非数字会被自动处理,同时也不能超过9999级", + Messages.get(SpawnWeapon.WeaponSetting.class, "weapon_level"), Messages.get(SpawnWeapon.WeaponSetting.class, "weapon_level_desc"), Integer.toString(weapon_level), - 4, false, Messages.get(WndSadGhost.class, "confirm"), - Messages.get(WndSadGhost.class, "cancel")) { + 4, false, Messages.get(SpawnWeapon.WeaponSetting.class, "confirm"), + Messages.get(SpawnWeapon.WeaponSetting.class, "cancel")) { @Override public void onSelect(boolean check, String text) { if (check && text.matches("\\d+")) { int level = Integer.parseInt(text); - weapon_level = Math.min(level, Integer.MAX_VALUE); + weapon_level = Math.min(level, 6666); } } })); } else { - Game.scene().add( new WndError( "必须选择武器才能打开等级设定界面!" ) ); + Game.scene().add( new WndError( Messages.get(SpawnWeapon.WeaponSetting.class, "weapon_level_error") ) ); } } }; + Button_Level.text(((Weapon) Reflection.newInstance(getWeapon(tier)[weapon_id])).name()); add(Button_Level); // 创建生成武器按钮 - Button_Create = new RedButton("生成武器") { + Button_Create = new RedButton(Messages.get(this, "create")) { @Override protected void onClick() { createWeapon(); @@ -447,7 +454,7 @@ public class SpawnWeapon extends TestItem{ * @param enchant 附魔类 * @return 附魔信息文本 */ private String getEnchantInfo(Class enchant) { - return Messages.get(enchant, "name", "附魔"); + return enchant==null?Messages.get(this, "no_enchant"):Messages.get(enchant, "name", Messages.get(this, "enchant")); } private int maxSlots(int t) { @@ -474,16 +481,17 @@ public class SpawnWeapon extends TestItem{ private void updateEnchantText() { StringBuilder info = new StringBuilder(); if (enchant_rarity == 0) { - info = new StringBuilder("请先选择附魔种类,然后会出现对应的编号。\n\n通过下方滑块滑动选择对应的编号即可。"); + info = new StringBuilder(Messages.get(this, "no_enchant")); } else { for (int i = 0; i < getEnchantCount(enchant_rarity); i++) { info.append(i + 1).append(":").append(getEnchantInfo(getEnchant(enchant_rarity, i))).append(" "); // 添加换行判断 - if ((i + 1) % 4 == 0) { + if ((i + 1) % 4 == 0 || i == (getEnchantCount(enchant_rarity)-1)) { info.append("\n"); } } + info.append(Messages.get(this, "current_enchant",getEnchantInfo(getEnchant(enchant_rarity, enchant_id)))); } Text_EnchantInfo.text(info.toString()); } From 47262359f068bfeebac7dab2c43806025480e69b Mon Sep 17 00:00:00 2001 From: zxcPandora <1158500986@qq.com> Date: Sun, 15 Oct 2023 22:37:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=84=9F=E8=B0=A2=E7=BB=AB=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E7=9A=84=E8=80=81=E9=AD=94=E6=9D=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/testmode/SpawnWeapon.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java index 28ede869c..9ef385d9e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java @@ -8,6 +8,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.custom.messages.M; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Annoying; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Displacing; @@ -32,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projec import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shocking; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Unstable; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Vampiric; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; @@ -104,7 +106,12 @@ public class SpawnWeapon extends TestItem{ } wpn.cursed=cursed; wpn.identify(); - if(wpn.collect()) { + if(wpn instanceof MagesStaff){ + wpn=new MagesStaff(new WandOfMagicMissile()); + wpn.identify(); + GameScene.pickUp(wpn,hero.pos); + Sample.INSTANCE.play(Assets.Sounds.ITEM); + } else if(wpn.collect()) { GameScene.pickUp( wpn, hero.pos ); Sample.INSTANCE.play( Assets.Sounds.ITEM ); GLog.i(Messages.get(hero, "you_now_have", wpn.name())); @@ -321,7 +328,7 @@ public class SpawnWeapon extends TestItem{ Button_Level = new RedButton(Messages.get(this, "select_weapon")) { @Override protected void onClick() { - if(!Button_Level.text().equals(Messages.get(SpawnWeapon.WeaponSetting.class, "select_weapon"))){ + if(!Button_Level.text().equals(Messages.get(SpawnWeapon.WeaponSetting.class, "select_weapon"))){ // 修改此行代码 Game.runOnRenderThread(() -> ShatteredPixelDungeon.scene().add(new WndTextNumberInput( Messages.get(SpawnWeapon.WeaponSetting.class, "weapon_level"), Messages.get(SpawnWeapon.WeaponSetting.class, "weapon_level_desc"), Integer.toString(weapon_level), From c9e8e532cb7a7f6dde6af6db2d5b90e3bfde2dc7 Mon Sep 17 00:00:00 2001 From: zxcPandora <81985226+zxcPandora@users.noreply.github.com> Date: Sun, 15 Oct 2023 22:42:09 +0800 Subject: [PATCH 3/3] Update SpawnWeapon.java --- .../shatteredpixeldungeon/custom/testmode/SpawnWeapon.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java index 9ef385d9e..50ef349fe 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/custom/testmode/SpawnWeapon.java @@ -111,7 +111,8 @@ public class SpawnWeapon extends TestItem{ wpn.identify(); GameScene.pickUp(wpn,hero.pos); Sample.INSTANCE.play(Assets.Sounds.ITEM); - } else if(wpn.collect()) { + } + if(wpn.collect()) { GameScene.pickUp( wpn, hero.pos ); Sample.INSTANCE.play( Assets.Sounds.ITEM ); GLog.i(Messages.get(hero, "you_now_have", wpn.name()));