Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
[GUI] FormationStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
SharpnelXu committed Nov 5, 2022
1 parent 7c2120b commit 1121b6c
Show file tree
Hide file tree
Showing 12 changed files with 595 additions and 109 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ Also, this simulator supports translations. If you are interested, you can put y
## 使用说明

### 下载
在Release页面中下载当前版本的压缩包解压就好:[传送门](https://github.com/SharpnelXu/FGOSimulator/releases/tag/v1.04)
在Release页面中下载当前版本的压缩包解压就好:[传送门](https://github.com/SharpnelXu/FGOSimulator/releases/tag/v1.05)

#### 注意
如果你的电脑安装了Java 15以上,可以直接下载标注为`.jar``zip`压缩包解压。

如果没有或者不确定的话,Windows用户可以尝试下载标注为`.exe``zip`压缩包解压。这个压缩包包含了程序需求的运行环境,所以会大一点。

当前版本:v1.04,数据版本:v1.04.1(更新至108人的万圣节·反抗! ~小龙娘水浒演义~)
当前版本:v1.05,数据版本:v1.05.0(更新至108人的万圣节·反抗! ~小龙娘水浒演义~)

![下载程序](./ReadmePic/System/download1.png)

### 更新

目前有一次数据更新(v1.04.1),如果有之前的数据版本,可以直接下快速补丁,即标记为Quick Patch的zip文件然后在本地解压替换掉数据就好。
目前有一次数据更新(v1.05.0),如果有之前的数据版本,可以直接下快速补丁,即标记为Quick Patch的zip文件然后在本地解压替换掉数据就好。

![下载数据](./ReadmePic/System/download2.png)

Expand Down Expand Up @@ -460,6 +460,7 @@ java -p <path to javafx sdk>/lib --add-modules=javafx.controls,javafx.graphics,
- 系统:
- 选择卡色从下拉菜单改为按钮
- 取消特殊发动目标这一设置,原本的特殊目标现在只需要在效果编辑器内列出即可
- 新增编队储存功能
- 效果相关:
- 新增宝具随机效果(尺芬奇)
- 删除最大HP改变(并未删除Buff),其原本功能由付与状态继承。此改动应无实际效果除了读取旧数据时可能会报错
Expand Down
2 changes: 0 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
预定制作:
编队储存
随机效果、选卡色、换人重做
条件添加大于小于等于

8 changes: 8 additions & 0 deletions Translations/zh_CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ Craft Essence Selector = 概念礼装选择器
Any Rarity=任意稀有度
Mystic Code Selector=魔术礼装选择器

Formation Viewer=编队选择器
Select Formation=选择编队
Delete Formation=删除编队
Formation name is empty=编队名为空
Formation is empty=编队为空

In Formation=队伍
Support=助战
No servant selected=未选择从者
Expand Down Expand Up @@ -275,6 +281,8 @@ Random Value=随机数
Start Simulation=开始模拟
Details=详细信息
COST=
Load Formation=加载编队
Save Formation=保存编队

Simulation Window=战斗模拟
%s Enter Field=%s入场
Expand Down
235 changes: 147 additions & 88 deletions src/main/java/yome/fgo/simulator/gui/components/FormationSelector.java

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions src/main/java/yome/fgo/simulator/gui/creators/EntitySelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,56 @@
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
import yome.fgo.data.proto.FgoStorageData.Formation;
import yome.fgo.data.proto.FgoStorageData.Gender;
import yome.fgo.simulator.gui.components.CraftEssenceDataAnchorPane;
import yome.fgo.simulator.gui.components.MysticCodeDataAnchorPane;
import yome.fgo.simulator.gui.components.ServantDataAnchorPane;
import yome.fgo.simulator.translation.TranslationManager;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import static yome.fgo.simulator.translation.TranslationManager.APPLICATION_SECTION;

public class EntitySelector {

public static Formation selectFormation(
final Window window,
final List<Formation> formationList,
final Map<Integer, ServantDataAnchorPane> servantDataMap,
final Map<Integer, CraftEssenceDataAnchorPane> ceDataMap,
final Map<Integer, MysticCodeDataAnchorPane> mcDataMap
) throws IOException {
final Formation.Builder selection = Formation.newBuilder();

final Stage newStage = new Stage();
newStage.initModality(Modality.APPLICATION_MODAL);
newStage.initOwner(window);

final FXMLLoader fxmlLoader = new FXMLLoader(BuffBuilder.class.getResource("formationViewer.fxml"));
final Parent root = fxmlLoader.load();
final FormationFXMLController controller = fxmlLoader.getController();
controller.fillFormations(
formationList,
servantDataMap,
ceDataMap,
mcDataMap,
selection
);

final Scene scene = new Scene(root);
scene.getStylesheets().add(BuffBuilder.class.getResource("style.css").toExternalForm());

newStage.setTitle(TranslationManager.getTranslation(APPLICATION_SECTION, "Formation Viewer"));
newStage.setScene(scene);

newStage.showAndWait();

return selection.getName().isEmpty() ? null : selection.build();
}

public static ServantDataAnchorPane selectServant(
final Window window,
final Map<Integer, ServantDataAnchorPane> servantDataMap
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package yome.fgo.simulator.gui.creators;

import com.google.common.collect.Lists;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.image.Image;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import yome.fgo.data.proto.FgoStorageData;
import yome.fgo.data.proto.FgoStorageData.CraftEssencePreference;
import yome.fgo.data.proto.FgoStorageData.Formation;
import yome.fgo.data.proto.FgoStorageData.MysticCodePreference;
import yome.fgo.data.proto.FgoStorageData.ServantPreference;
import yome.fgo.simulator.gui.components.CraftEssenceDataAnchorPane;
import yome.fgo.simulator.gui.components.MysticCodeDataAnchorPane;
import yome.fgo.simulator.gui.components.ServantDataAnchorPane;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;

import static yome.fgo.simulator.ResourceManager.getUnknownServantThumbnail;
import static yome.fgo.simulator.gui.helpers.ComponentUtils.LIST_ITEM_STYLE;
import static yome.fgo.simulator.translation.TranslationManager.APPLICATION_SECTION;
import static yome.fgo.simulator.translation.TranslationManager.getTranslation;

public class FormationFXMLController implements Initializable {
@FXML
private VBox formationVBox;

@Override
public void initialize(final URL location, final ResourceBundle resources) {
}

public void fillFormations(
final List<Formation> formationList,
final Map<Integer, ServantDataAnchorPane> servantDataMap,
final Map<Integer, CraftEssenceDataAnchorPane> ceDataMap,
final Map<Integer, MysticCodeDataAnchorPane> mcDataMap,
final Formation.Builder builder
) {
Image unknown = null;
try {
unknown = new Image(new FileInputStream(getUnknownServantThumbnail()));
} catch (final FileNotFoundException ignored) {
}

for (int h = 0; h < formationList.size(); h += 1) {
final Formation formation = formationList.get(h);

final HBox nameHBox = new HBox(20);
nameHBox.setAlignment(Pos.CENTER_LEFT);
final Button selectButton = new Button(getTranslation(APPLICATION_SECTION, "Select Formation"));
selectButton.setFont(new Font(18));
final Button deleteButton = new Button(getTranslation(APPLICATION_SECTION, "Delete Formation"));
deleteButton.setFont(new Font(18));
final Label formationName = new Label(formation.getName());
formationName.setFont(new Font(18));
nameHBox.getChildren().addAll(selectButton, deleteButton, formationName);

final HBox partyHBox = new HBox(15);
final List<ServantPreference> servantPreferences = formation.getServantsList();
final List<CraftEssencePreference> craftEssencePreferences = formation.getCraftEssencesList();
for (int i = 0; i < formation.getServantsCount(); i += 1) {
final VBox memberVBox = new VBox(20);
final ServantPreference servantPreference = servantPreferences.get(i);
final ServantDataAnchorPane servant;
final int servantNo = servantPreference.getServantNo();
if (servantDataMap.containsKey(servantNo)) {
final ServantDataAnchorPane reference = servantDataMap.get(servantNo);
servant = new ServantDataAnchorPane(reference.getServantData(), reference.getAscensionImages());
servant.getImageView().setImage(servant.getAscensionImages().get(servantPreference.getOption().getAscension() - 1));
} else {
servant = new ServantDataAnchorPane(null, Lists.newArrayList(unknown));
}

final CraftEssenceDataAnchorPane craftEssence;
final int ceNo = craftEssencePreferences.get(i).getCraftEssenceNo();
if (ceDataMap.containsKey(ceNo)) {
final CraftEssenceDataAnchorPane reference = ceDataMap.get(ceNo);
craftEssence = new CraftEssenceDataAnchorPane(reference.getCraftEssenceData(), reference.getImage());
} else {
craftEssence = new CraftEssenceDataAnchorPane(null, unknown);
}

memberVBox.getChildren().addAll(servant, craftEssence);
partyHBox.getChildren().add(memberVBox);
}

partyHBox.getChildren().add(new Separator(Orientation.VERTICAL));

final MysticCodePreference mysticCodePreference = formation.getMysticCode();
final MysticCodeDataAnchorPane mysticCode = new MysticCodeDataAnchorPane();
final MysticCodeDataAnchorPane reference = mcDataMap.get(mysticCodePreference.getMysticCodeNo());
mysticCode.setFrom(reference.getMysticCodeData(), reference.getImages(), mysticCodePreference.getOption().getGender());

partyHBox.getChildren().add(mysticCode);

final VBox itemVBox = new VBox(10);
itemVBox.setPadding(new Insets(20));
itemVBox.setStyle(LIST_ITEM_STYLE);
itemVBox.getChildren().addAll(nameHBox, partyHBox);
formationVBox.getChildren().add(itemVBox);

selectButton.setOnAction(e -> {
builder.mergeFrom(formation);
final Stage stage = (Stage) formationVBox.getScene().getWindow();
stage.close();
});
deleteButton.setOnAction(e -> {
formationVBox.getChildren().remove(itemVBox);
formationList.remove(formation);
});
}
}
}
Loading

0 comments on commit 1121b6c

Please sign in to comment.