implement chat bubbles + phone themes

This commit is contained in:
Hiro
2023-11-28 06:09:14 +02:00
parent c23777e397
commit 3f8c7d9554
16 changed files with 2272 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ package emu.lunarcore.data;
import java.lang.reflect.Field;
import java.util.List;
import java.util.ArrayList;
import emu.lunarcore.data.config.FloorInfo;
import emu.lunarcore.data.excel.*;
import emu.lunarcore.game.battle.MazeBuff;
@@ -51,6 +53,8 @@ public class GameData {
private static Int2ObjectMap<EquipmentPromotionExcel> equipmentPromotionExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<MazeBuffExcel> mazeBuffExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<CocoonExcel> cocoonExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<ChatBubbleExcel> chatBubbleExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<PhoneThemeExcel> phoneThemeExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<MonsterDropExcel> monsterDropExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<PlayerLevelExcel> playerLevelExcelMap = new Int2ObjectOpenHashMap<>();
@@ -81,6 +85,28 @@ public class GameData {
return map;
}
public static List<Integer> getAllChatBubbleIds() {
List<Integer> allIds = new ArrayList<>();
for (Int2ObjectMap.Entry<ChatBubbleExcel> entry : chatBubbleExcelMap.int2ObjectEntrySet()) {
ChatBubbleExcel chatBubbleExcel = entry.getValue();
allIds.add(chatBubbleExcel.getId());
}
return allIds;
}
public static List<Integer> getAllPhoneThemes() {
List<Integer> allIds = new ArrayList<>();
for (Int2ObjectMap.Entry<PhoneThemeExcel> entry : phoneThemeExcelMap.int2ObjectEntrySet()) {
PhoneThemeExcel phoneThemeExcel = entry.getValue();
allIds.add(phoneThemeExcel.getId());
}
return allIds;
}
public static AvatarPromotionExcel getAvatarPromotionExcel(int id, int promotion) {
return avatarPromotionExcelMap.get((id << 8) + promotion);
}

View File

@@ -0,0 +1,23 @@
package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameData;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import emu.lunarcore.game.inventory.GameItem;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import lombok.Getter;
@Getter
@ResourceType(name = {"ChatBubbleConfig.json"}, loadPriority = LoadPriority.LOW)
public class ChatBubbleExcel extends GameResource {
private int ID;
private String ShowType;
private int ShowParam;
@Override
public int getId() {
return ID;
}
}

View File

@@ -0,0 +1,21 @@
package emu.lunarcore.data.excel;
import emu.lunarcore.data.GameData;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import emu.lunarcore.game.inventory.GameItem;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import lombok.Getter;
@Getter
@ResourceType(name = {"PhoneThemeConfig.json"}, loadPriority = LoadPriority.LOW)
public class PhoneThemeExcel extends GameResource {
private int ID;
private String ShowType;
@Override
public int getId() {
return ID;
}
}

View File

@@ -75,6 +75,8 @@ public class Player {
private String name;
private String signature;
private int headIcon;
private int phoneTheme;
private int chatBubble;
private int birthday;
private int curBasicType;
@Setter private PlayerGender gender;
@@ -154,6 +156,8 @@ public class Player {
this.name = GameConstants.DEFAULT_NAME;
this.signature = "";
this.headIcon = 200001;
this.phoneTheme = 221000;
this.chatBubble = 220000;
this.level = 1;
this.stamina = GameConstants.MAX_STAMINA;
this.nextStaminaRecover = System.currentTimeMillis();
@@ -230,6 +234,26 @@ public class Player {
this.save();
this.sendPacket(new PacketPlayerSyncScNotify(this));
}
public void setPhoneTheme(int themeId) {
this.phoneTheme = themeId;
this.save();
this.sendPacket(new PacketPlayerSyncScNotify(this));
}
public int getPhoneTheme() {
return this.phoneTheme;
}
public void setChatBubble(int bubbleId) {
this.chatBubble = bubbleId;
this.save();
this.sendPacket(new PacketPlayerSyncScNotify(this));
}
public int getChatBubble() {
return this.chatBubble;
}
public Set<Integer> getUnlockedHeadIcons() {
if (this.unlockedHeadIcons == null) {

View File

@@ -0,0 +1,17 @@
package emu.lunarcore.server.packet.recv;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes;
import emu.lunarcore.server.packet.PacketHandler;
import emu.lunarcore.server.packet.send.PacketGetPhoneDataScRsp;
@Opcodes(CmdId.GetPhoneDataCsReq)
public class HandlerGetPhoneDataCsReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] data) throws Exception {
session.send(new PacketGetPhoneDataScRsp(session.getPlayer()));
}
}

View File

@@ -0,0 +1,23 @@
package emu.lunarcore.server.packet.recv;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes;
import emu.lunarcore.server.packet.PacketHandler;
import emu.lunarcore.proto.SelectChatBubbleCsReqOuterClass.SelectChatBubbleCsReq;
import emu.lunarcore.server.packet.send.PacketSelectChatBubbleScRsp;
@Opcodes(CmdId.SelectChatBubbleCsReq)
public class HandlerSelectChatBubbleCsReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] data) throws Exception {
var req = SelectChatBubbleCsReq.parseFrom(data);
Player player = session.getPlayer();
session.send(new PacketSelectChatBubbleScRsp(player, req.getBubbleId()));
}
}

View File

@@ -0,0 +1,23 @@
package emu.lunarcore.server.packet.recv;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes;
import emu.lunarcore.server.packet.PacketHandler;
import emu.lunarcore.proto.SelectPhoneThemeCsReqOuterClass.SelectPhoneThemeCsReq;
import emu.lunarcore.server.packet.send.PacketSelectPhoneThemeScRsp;
@Opcodes(CmdId.SelectPhoneThemeCsReq)
public class HandlerSelectPhoneThemeCsReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] data) throws Exception {
var req = SelectPhoneThemeCsReq.parseFrom(data);
Player player = session.getPlayer();
session.send(new PacketSelectPhoneThemeScRsp(player, req.getThemeId()));
}
}

View File

@@ -0,0 +1,32 @@
package emu.lunarcore.server.packet.send;
import emu.lunarcore.proto.GetPhoneDataScRspOuterClass.GetPhoneDataScRsp;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.data.GameData;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.game.player.Player;
public class PacketGetPhoneDataScRsp extends BasePacket {
public PacketGetPhoneDataScRsp(Player player) {
super(CmdId.GetPhoneDataScRsp);
var allChatBubbles = GameData.getAllChatBubbleIds();
var allPhoneThemes = GameData.getAllPhoneThemes();
var data = GetPhoneDataScRsp.newInstance()
.setCurChatBubble(player.getChatBubble())
.setCurPhoneTheme(player.getPhoneTheme());
for (int chatBubbleId : allChatBubbles) {
data.addOwnedChatBubbles(chatBubbleId);
}
for (int phoneThemeId : allPhoneThemes) {
data.addOwnedPhoneThemes(phoneThemeId);
}
this.setData(data);
}
}

View File

@@ -0,0 +1,23 @@
package emu.lunarcore.server.packet.send;
import java.util.Collection;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.game.chat.ChatMessage;
import emu.lunarcore.proto.SelectChatBubbleScRspOuterClass.SelectChatBubbleScRsp;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;
public class PacketSelectChatBubbleScRsp extends BasePacket {
public PacketSelectChatBubbleScRsp(Player player, int bubbleId) {
super(CmdId.SelectChatBubbleScRsp);
player.setChatBubble(bubbleId);
var data = SelectChatBubbleScRsp.newInstance()
.setCurChatBubble(bubbleId);
this.setData(data);
}
}

View File

@@ -0,0 +1,22 @@
package emu.lunarcore.server.packet.send;
import emu.lunarcore.game.rogue.RogueMiracleData;
import emu.lunarcore.game.rogue.RogueMiracleSelectMenu;
import emu.lunarcore.proto.SelectPhoneThemeScRspOuterClass.SelectPhoneThemeScRsp;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.game.player.Player;
public class PacketSelectPhoneThemeScRsp extends BasePacket {
public PacketSelectPhoneThemeScRsp(Player player, int themeId) {
super(CmdId.SelectPhoneThemeScRsp);
player.setPhoneTheme(themeId);
var data = SelectPhoneThemeScRsp.newInstance()
.setCurPhoneTheme(themeId);
this.setData(data);
}
}