Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
4379711 committed Sep 6, 2024
2 parents 5ea8a3d + eee1023 commit a1de3fa
Show file tree
Hide file tree
Showing 18 changed files with 223 additions and 34 deletions.
5 changes: 2 additions & 3 deletions src/main/java/yalong/site/ClientStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ public void listenGameStatus() throws InterruptedException, IOException {
//监听游戏状态
GameStatusEnum gameStatus = api.getGameStatus();
if (!gameStatus.equals(GameStatusEnum.ChampSelect)) {
if (FrameInnerCache.myTeamMatchHistoryPanel != null) {
FrameInnerCache.myTeamMatchHistoryPanel.dispose();
FrameInnerCache.myTeamMatchHistoryPanel = null;
if (FrameInnerCache.myTeamMatchHistoryPanel != null && FrameInnerCache.myTeamMatchHistoryPanel.isVisible()) {
FrameInnerCache.myTeamMatchHistoryPanel.setVisible(false);
}
}
switch (gameStatus) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/yalong/site/bo/GameQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public class GameQueue {
private String name;
private String gameMode;
private Integer mapId;
private String isVisible;
private boolean select;
}
4 changes: 2 additions & 2 deletions src/main/java/yalong/site/cache/FrameInnerCache.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package yalong.site.cache;

import yalong.site.frame.panel.client.MatchPanel;
import yalong.site.frame.panel.client.MyTeamMatchHistoryPanel;
import yalong.site.frame.panel.history.MatchPanel;
import yalong.site.frame.panel.history.MyTeamMatchHistoryPanel;
import yalong.site.frame.panel.key.KeyTextPane;
import yalong.site.frame.panel.result.ResultTextPane;

Expand Down
15 changes: 13 additions & 2 deletions src/main/java/yalong/site/cache/GameDataCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ public class GameDataCache {
/**
* 游戏地图模式信息
*/
public static Map<Integer, GameQueue> gameQueuesList = new HashMap<>();
public static Map<Integer, GameQueue> allGameQueuesList = new LinkedHashMap<>();
/**
* 队友战绩缓存
*/
public static List<TeamSummonerBO> myTeamMatchHistory = new ArrayList<>();

public static Map<Integer, GameQueue> selectGameQueueList = new LinkedHashMap<>();

public static void reset() {
resetScore();
}
Expand Down Expand Up @@ -80,18 +82,27 @@ public static void cacheLcuStatic() {
itemList = AppCache.api.getAllItems();
perkStyleList = AppCache.api.getAllPerkStyleBO();
summonerSpellsList = AppCache.api.getAllSummonerSpells();
gameQueuesList = AppCache.api.getAllQueue();
allGameQueuesList = AppCache.api.getAllQueue();
log.error("获取资源文件成功");
} catch (Exception err) {
log.error("获取资源文件失败", err);
}
}
}

public static void cacheSelectGameMode() {
for (Integer key : allGameQueuesList.keySet()) {
GameQueue value = allGameQueuesList.get(key);
if (value.getIsVisible().equals("true")) {
selectGameQueueList.put(key, value);
}
}
}

public static void cacheLcuAll() {
cacheLcuMe();
cacheLcuChampion();
cacheLcuStatic();
cacheSelectGameMode();
}
}
1 change: 1 addition & 0 deletions src/main/java/yalong/site/enums/GameTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public enum GameTypeEnum {
CUSTOM(0, "自定义"),
RANK_SOLO(420, "单双排位"),
NORMAL(430, "匹配模式"),
RANK_FLEX(440, "灵活排位"),
ARAM(450, "极地大乱斗"),
BOT_INTRO(870, "新·入门人机"),
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/yalong/site/frame/panel/TabPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import yalong.site.frame.panel.about.AboutPanel;
import yalong.site.frame.panel.client.ClientPanel;
import yalong.site.frame.panel.fuckword.FuckPanel;
import yalong.site.frame.panel.history.HistoryPane;
import yalong.site.frame.panel.key.KeyPanel;
import yalong.site.frame.panel.result.ResultPanel;
import yalong.site.frame.ui.MyTabbedPaneUI;
Expand Down Expand Up @@ -34,6 +35,7 @@ public static TabPane builder() {
tabPane.add(KeyPanel.builder());
tabPane.add(FuckPanel.builder());
tabPane.add(ResultPanel.builder());
tabPane.add(HistoryPane.builder());
tabPane.add(AboutPanel.builder());
return tabPane;
}
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/yalong/site/frame/panel/client/ClientPanel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package yalong.site.frame.panel.client;

import yalong.site.frame.panel.base.BasePanel;
import yalong.site.frame.panel.history.GameModeBox;
import yalong.site.frame.panel.history.HistoryButton;

import javax.swing.*;
import java.awt.*;
Expand All @@ -27,20 +29,16 @@ private static ArrayList<Component> loadAllPanel() {
list.add(new AutoPlayAgainCheckBox());

list.add(new AutoKeyCheckBox());
list.add(new SendScoreCheckBox());
list.add(new CommunicateCheckBox());

list.add(new AutoReconnectCheckBox());
list.add(new PickSkinBox());
list.add(new ShowTeamBox());

list.add(new PickSkinBox());
list.add(new GameStatusBox());
list.add(new BanBox());

list.add(new CareerBackgroundBox());
list.add(new CareerBackgroundSkinBox());

list.add(new BanBox());
list.add(new PickBox());
list.add(new HistoryButton());

return list;
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/yalong/site/frame/panel/history/GameModeBox.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package yalong.site.frame.panel.history;

import yalong.site.frame.panel.base.BaseButton;

import java.awt.event.ActionListener;

/**
* @author WuYi
*/
public class GameModeBox extends BaseButton {
private final GameModeBox gameModeBox;

public GameModeBox() {
gameModeBox = this;
this.setText("筛选需要的模式");
this.addActionListener(actionListener());
}

private ActionListener actionListener() {
return e -> {
GameModeSelectFrame selectFrame = new GameModeSelectFrame("选择模式");
selectFrame.setVisible(true);
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package yalong.site.frame.panel.history;

import yalong.site.bo.GameQueue;
import yalong.site.cache.FrameSetting;
import yalong.site.cache.GameDataCache;

import javax.swing.*;
import java.awt.*;

/**
* @author WuYi
*/
public class GameModeSelectFrame extends JFrame {
private final JPanel gameModePanel = new JPanel();

private final JPanel allPanel = new JPanel();

private final JFrame jFrame;

public GameModeSelectFrame(String topic) {
jFrame = this;
Image image = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/assets/logo.png"));
this.setIconImage(image);
this.setSize(FrameSetting.CHAMPION_SELECT_WIDTH, FrameSetting.CHAMPION_SELECT_HEIGHT);
//窗口居中
this.setLocationRelativeTo(null);
this.setName(topic);

createButtons();

gameModePanel.setPreferredSize(new Dimension(FrameSetting.CHAMPION_SELECT_WIDTH, FrameSetting.CHAMPION_SELECT_HEIGHT - 50));
allPanel.add(gameModePanel);
this.add(allPanel);
gameModePanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 2));
}


public void createButtons() {
gameModePanel.removeAll();
for (Integer key : GameDataCache.selectGameQueueList.keySet()) {
GameQueue gameQueue = GameDataCache.selectGameQueueList.get(key);

JCheckBox button = new JCheckBox(gameQueue.getName());
button.setSelected(gameQueue.isSelect());
button.addActionListener(e -> {
gameQueue.setSelect(true);
}
);
button.setPreferredSize(new Dimension(250, 30));
gameModePanel.add(button);
}
gameModePanel.revalidate();
gameModePanel.repaint();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yalong.site.frame.panel.client;
package yalong.site.frame.panel.history;

import lombok.extern.slf4j.Slf4j;
import yalong.site.bo.ProductsMatchHistoryBO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yalong.site.frame.panel.client;
package yalong.site.frame.panel.history;

import lombok.extern.slf4j.Slf4j;
import yalong.site.bo.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yalong.site.frame.panel.client;
package yalong.site.frame.panel.history;

import yalong.site.bo.GameData;
import yalong.site.frame.bo.LocationBO;
Expand Down
71 changes: 71 additions & 0 deletions src/main/java/yalong/site/frame/panel/history/HistoryPane.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package yalong.site.frame.panel.history;

import yalong.site.frame.panel.base.BasePanel;
import yalong.site.frame.panel.client.SendScoreCheckBox;
import yalong.site.frame.panel.client.ShowTeamBox;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

/**
* @author WuYi
*/
public class HistoryPane extends BasePanel {
public HistoryPane() {
this.setName("战绩");
}

private static ArrayList<Component> loadAllPanel() {
ArrayList<Component> list = new ArrayList<>();

list.add(new SendScoreCheckBox());
list.add(new ShowTeamBox());
list.add(new GameModeBox());

list.add(new HistoryButton());
list.add(new JPanel());
list.add(new JPanel());

list.add(new JPanel());
list.add(new JPanel());
list.add(new JPanel());

list.add(new JPanel());
list.add(new JPanel());
list.add(new JPanel());

list.add(new JPanel());
list.add(new JPanel());
list.add(new JPanel());

return list;
}

public static HistoryPane builder() {
HistoryPane historyPane = new HistoryPane();
GridBagLayout layout = new GridBagLayout();
historyPane.setLayout(layout);
ArrayList<Component> list = loadAllPanel();
for (int i = 0; i < list.size(); i++) {
int y = i / 2;
int x = i % 2;
GridBagConstraints grid = new GridBagConstraints(
// 第(0,0)个格子
x, y,
// 占1列,占1行
1, 1,
//横向占100%长度,纵向占100%长度
1, 1,
//居中,组件小的话就两边铺满窗格
GridBagConstraints.CENTER, GridBagConstraints.NONE,
// 窗格之间的距离
new Insets(0, 0, 0, 0),
// 增加组件的首选宽度和高度
0, 0
);
historyPane.add(list.get(i), grid);
}
return historyPane;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yalong.site.frame.panel.client;
package yalong.site.frame.panel.history;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -157,7 +157,7 @@ public void setData(ProductsMatchHistoryBO bo, String puuid) {
private ArrayList<Object> createMatchHistoryBO(GameData data) {
Participants me = data.getParticipants().get(0);
ArrayList<Object> list = new ArrayList<>();
list.add("<html><body>" + GameDataCache.gameQueuesList.get(data.getQueueId()).getName() + "<hr>" + DateUtil.format(data.getGameCreationDate(), "MM-dd HH:mm") + "</body></html>");
list.add("<html><body>" + GameDataCache.allGameQueuesList.get(data.getQueueId()).getName() + "<hr>" + DateUtil.format(data.getGameCreationDate(), "MM-dd HH:mm") + "</body></html>");
list.add(MatchHistoryUtil.getChampionIcon(me.getChampionId(), FrameSetting.CHAMPION_ICON_SIZE, FrameSetting.CHAMPION_ICON_SIZE, ImageEnum.ROUND));
list.add(MatchHistoryUtil.getSummonerSpellImageIcon(me.getSpell1Id(), FrameSetting.ITEM_ICON_SIZE, FrameSetting.ITEM_ICON_SIZE));
list.add(MatchHistoryUtil.getPerkStyleImageIcon(me.getStats().getPerkPrimaryStyle(), FrameSetting.ITEM_ICON_SIZE, FrameSetting.ITEM_ICON_SIZE));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yalong.site.frame.panel.client;
package yalong.site.frame.panel.history;

import yalong.site.bo.ProductsMatchHistoryBO;
import yalong.site.bo.SGPRank;
Expand All @@ -25,7 +25,6 @@ public class MyTeamMatchHistoryLine extends JPanel {
private JPanel panelOne;
private JPanel panelTwo;
private JPanel panelThree;
private JLabel hoverInfoLabel;



Expand Down Expand Up @@ -131,6 +130,11 @@ public void mouseClicked(MouseEvent e) {
panelOne.add(winRateLabel);
panelOne.add(panelThree);

for (ChampionWin championWin : data.getChampionWinList()) {
JLabel jLabel = new JLabel();
jLabel.setIcon(championWin.getIcon());
panelTwo.add(jLabel);
}

this.add(panelOne);
this.add(panelTwo);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yalong.site.frame.panel.client;
package yalong.site.frame.panel.history;

import cn.hutool.core.util.NumberUtil;
import com.sun.jna.platform.win32.WinDef;
Expand All @@ -7,7 +7,6 @@
import yalong.site.bo.TeamSummonerBO;
import yalong.site.cache.FrameInnerCache;
import yalong.site.cache.GameDataCache;
import yalong.site.enums.GameTypeEnum;
import yalong.site.enums.ImageEnum;
import yalong.site.frame.bo.ChampionWin;
import yalong.site.frame.constant.ColorConstant;
Expand Down Expand Up @@ -70,7 +69,9 @@ private TeamSummonerBO buildTeamLineData(TeamSummonerBO data) {
List<SpgParticipants> spgParticipantsList = new ArrayList<>();
//获取自己的所有数据
for (SpgProductsMatchHistoryBO item : data.getMatchHistory()) {
if (item.getJson().getQueueId() == GameTypeEnum.ARAM.getQueueId() || item.getJson().getQueueId() == GameTypeEnum.RANK_SOLO.getQueueId() || item.getJson().getQueueId() == GameTypeEnum.RANK_FLEX.getQueueId()) {
Integer queueId = item.getJson().getQueueId();
if (GameDataCache.allGameQueuesList.get(queueId).getIsVisible().equals("true") &&
GameDataCache.selectGameQueueList.get(queueId).isSelect()) {
SpgParticipants spgParticipants = item.getJson().getParticipants()
.stream()
.filter(line -> line.getPuuid().equals(data.getPuuid()))
Expand Down
Loading

0 comments on commit a1de3fa

Please sign in to comment.