Merge pull request #39 from zxcPandora/test

Localized language and Better player experience
This commit is contained in:
JDSA Ling 2023-10-15 23:55:13 +08:00 committed by GitHub
commit c812bbbf77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 21 deletions

View File

@ -503,8 +503,21 @@ custom.testmode.mobplacer.elite=精英词缀数量
custom.testmode.spawnweapon.name=武器生成秘卷 custom.testmode.spawnweapon.name=武器生成秘卷
custom.testmode.spawnweapon.desc=生成需要的武器以及属性。\n\n原作者Alexstrasza\n\n复刻者潘多拉\n\n优化者KDSALing custom.testmode.spawnweapon.desc=生成需要的武器以及属性。\n\n原作者Alexstrasza\n\n复刻者潘多拉\n\n优化者KDSALing
custom.testmode.spawnweapon.ac_spawn=生成 custom.testmode.spawnweapon.ac_spawn=生成
name = 请先选择附魔种类,然后会出现对应的编号。\n\n通过下方滑块滑动选择对应的编号即可。 custom.testmode.spawnweapon$weaponsetting.weapon_tier=武器阶数
custom.testmode.spawnweapon$weaponsetting.selected=选择 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=我感觉我不太好…… actors.buffs.sanity.bad=我感觉我不太好……
actors.buffs.sanity.tobad=理智过低了会死吗? actors.buffs.sanity.tobad=理智过低了会死吗?

View File

@ -8,6 +8,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.custom.messages.M; import com.shatteredpixel.shatteredpixeldungeon.custom.messages.M;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; 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.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Annoying; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Annoying;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Displacing; 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.Shocking;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Unstable; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Unstable;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Vampiric; 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.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
@ -45,7 +47,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.WndTextNumberInput; import com.shatteredpixel.shatteredpixeldungeon.utils.WndTextNumberInput;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError; import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndSadGhost;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
@ -91,8 +92,6 @@ public class SpawnWeapon extends TestItem{
public void execute(Hero hero, String action) { public void execute(Hero hero, String action) {
super.execute(hero, action); super.execute(hero, action);
if (action.equals(AC_SPAWN)){ 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()); GameScene.show(new WeaponSetting());
} }
} }
@ -107,6 +106,12 @@ public class SpawnWeapon extends TestItem{
} }
wpn.cursed=cursed; wpn.cursed=cursed;
wpn.identify(); wpn.identify();
if(wpn instanceof MagesStaff){
wpn=new MagesStaff(new WandOfMagicMissile());
wpn.identify();
GameScene.pickUp(wpn,hero.pos);
Sample.INSTANCE.play(Assets.Sounds.ITEM);
}
if(wpn.collect()) { if(wpn.collect()) {
GameScene.pickUp( wpn, hero.pos ); GameScene.pickUp( wpn, hero.pos );
Sample.INSTANCE.play( Assets.Sounds.ITEM ); Sample.INSTANCE.play( Assets.Sounds.ITEM );
@ -149,6 +154,8 @@ public class SpawnWeapon extends TestItem{
return Kinetic.class; return Kinetic.class;
case 3: case 3:
return Shocking.class; return Shocking.class;
default:
return null;
} }
case 2: case 2:
switch (id){ switch (id){
@ -164,6 +171,8 @@ public class SpawnWeapon extends TestItem{
return Projecting.class; return Projecting.class;
case 5: case 5:
return Unstable.class; return Unstable.class;
default:
return null;
} }
case 3: case 3:
switch (id){ switch (id){
@ -177,6 +186,8 @@ public class SpawnWeapon extends TestItem{
return HaloBlazing.class; return HaloBlazing.class;
case 4: case 4:
return Crushing.class; return Crushing.class;
default:
return null;
} }
case 4: case 4:
switch (id){ switch (id){
@ -196,6 +207,8 @@ public class SpawnWeapon extends TestItem{
return Polarized.class; return Polarized.class;
case 7: case 7:
return Friendly.class; return Friendly.class;
default:
return null;
} }
} }
return null; return null;
@ -259,7 +272,7 @@ public class SpawnWeapon extends TestItem{
createWeaponList(tier); createWeaponList(tier);
// 创建武器阶数选项滑块 // 创建武器阶数选项滑块
OptionSlider_Tier = new OptionSlider("武器阶数", "1", "6", 1, 6) { OptionSlider_Tier = new OptionSlider(Messages.get(this, "weapon_tier"), "1", "6", 1, 6) {
@Override @Override
protected void onChange() { protected void onChange() {
tier = getSelectedValue(); tier = getSelectedValue();
@ -268,6 +281,7 @@ public class SpawnWeapon extends TestItem{
createWeaponImage(AllWeapon); createWeaponImage(AllWeapon);
} }
}; };
OptionSlider_Tier.setSelectedValue(tier);
add(OptionSlider_Tier); add(OptionSlider_Tier);
// 创建武器图标 // 创建武器图标
@ -275,11 +289,11 @@ public class SpawnWeapon extends TestItem{
// 创建附魔信息文本块 // 创建附魔信息文本块
Text_EnchantInfo = PixelScene.renderTextBlock("", 6); Text_EnchantInfo = PixelScene.renderTextBlock("", 6);
Text_EnchantInfo.text(getEnchantInfo(getEnchant(enchant_rarity, enchant_id))); updateEnchantText();
add(Text_EnchantInfo); 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 @Override
protected void onChange() { protected void onChange() {
enchant_rarity = getSelectedValue(); enchant_rarity = getSelectedValue();
@ -290,7 +304,7 @@ public class SpawnWeapon extends TestItem{
add(OptionSlider_EnchantRarity); 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 @Override
protected void onChange() { protected void onChange() {
enchant_id = getSelectedValue(); enchant_id = getSelectedValue();
@ -301,7 +315,7 @@ public class SpawnWeapon extends TestItem{
add(OptionSlider_EnchantId); add(OptionSlider_EnchantId);
// 创建诅咒物品复选框 // 创建诅咒物品复选框
CheckBox_Curse = new CheckBox("诅咒物品") { CheckBox_Curse = new CheckBox(Messages.get(this, "cursed")) {
@Override @Override
protected void onClick() { protected void onClick() {
super.onClick(); super.onClick();
@ -312,33 +326,34 @@ public class SpawnWeapon extends TestItem{
add(CheckBox_Curse); add(CheckBox_Curse);
// 创建武器等级按钮 // 创建武器等级按钮
Button_Level = new RedButton("尚未选择武器") { Button_Level = new RedButton(Messages.get(this, "select_weapon")) {
@Override @Override
protected void onClick() { 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( 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), Integer.toString(weapon_level),
4, false, Messages.get(WndSadGhost.class, "confirm"), 4, false, Messages.get(SpawnWeapon.WeaponSetting.class, "confirm"),
Messages.get(WndSadGhost.class, "cancel")) { Messages.get(SpawnWeapon.WeaponSetting.class, "cancel")) {
@Override @Override
public void onSelect(boolean check, String text) { public void onSelect(boolean check, String text) {
if (check && text.matches("\\d+")) { if (check && text.matches("\\d+")) {
int level = Integer.parseInt(text); int level = Integer.parseInt(text);
weapon_level = Math.min(level, Integer.MAX_VALUE); weapon_level = Math.min(level, 6666);
} }
} }
})); }));
} else { } 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); add(Button_Level);
// 创建生成武器按钮 // 创建生成武器按钮
Button_Create = new RedButton("生成武器") { Button_Create = new RedButton(Messages.get(this, "create")) {
@Override @Override
protected void onClick() { protected void onClick() {
createWeapon(); createWeapon();
@ -447,7 +462,7 @@ public class SpawnWeapon extends TestItem{
* @param enchant 附魔类 * @param enchant 附魔类
* @return 附魔信息文本 */ * @return 附魔信息文本 */
private String getEnchantInfo(Class enchant) { 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) { private int maxSlots(int t) {
@ -474,16 +489,17 @@ public class SpawnWeapon extends TestItem{
private void updateEnchantText() { private void updateEnchantText() {
StringBuilder info = new StringBuilder(); StringBuilder info = new StringBuilder();
if (enchant_rarity == 0) { if (enchant_rarity == 0) {
info = new StringBuilder("请先选择附魔种类,然后会出现对应的编号。\n\n通过下方滑块滑动选择对应的编号即可。"); info = new StringBuilder(Messages.get(this, "no_enchant"));
} else { } else {
for (int i = 0; i < getEnchantCount(enchant_rarity); i++) { for (int i = 0; i < getEnchantCount(enchant_rarity); i++) {
info.append(i + 1).append(":").append(getEnchantInfo(getEnchant(enchant_rarity, i))).append(" "); 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("\n");
} }
} }
info.append(Messages.get(this, "current_enchant",getEnchantInfo(getEnchant(enchant_rarity, enchant_id))));
} }
Text_EnchantInfo.text(info.toString()); Text_EnchantInfo.text(info.toString());
} }