|
|
@ -16,17 +16,15 @@ import javafx.scene.layout.Pane; |
|
|
|
import javafx.stage.Stage; |
|
|
|
import javafx.stage.Stage; |
|
|
|
import javafx.stage.StageStyle; |
|
|
|
import javafx.stage.StageStyle; |
|
|
|
import me.lensferno.dogename.configs.ConfigLoader; |
|
|
|
import me.lensferno.dogename.configs.ConfigLoader; |
|
|
|
|
|
|
|
import me.lensferno.dogename.configs.GlobalConfig; |
|
|
|
import me.lensferno.dogename.configs.MainConfig; |
|
|
|
import me.lensferno.dogename.configs.MainConfig; |
|
|
|
import me.lensferno.dogename.configs.VoiceConfig; |
|
|
|
|
|
|
|
import me.lensferno.dogename.data.Data; |
|
|
|
import me.lensferno.dogename.data.Data; |
|
|
|
import me.lensferno.dogename.data.History; |
|
|
|
import me.lensferno.dogename.data.History; |
|
|
|
import me.lensferno.dogename.select.Selector; |
|
|
|
import me.lensferno.dogename.select.Selector; |
|
|
|
import me.lensferno.dogename.utils.DialogMaker; |
|
|
|
import me.lensferno.dogename.utils.DialogMaker; |
|
|
|
import me.lensferno.dogename.utils.FilePath; |
|
|
|
import me.lensferno.dogename.utils.FilePath; |
|
|
|
import me.lensferno.dogename.utils.ocr.OcrTool; |
|
|
|
import me.lensferno.dogename.utils.ocr.OcrTool; |
|
|
|
import me.lensferno.dogename.voice.VoicePlayer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.util.Random; |
|
|
|
import java.util.Random; |
|
|
@ -38,7 +36,6 @@ public final class MainInterfaceController { |
|
|
|
OcrTool ocrTool = null; |
|
|
|
OcrTool ocrTool = null; |
|
|
|
|
|
|
|
|
|
|
|
History history = new History(); |
|
|
|
History history = new History(); |
|
|
|
MainConfig mainConfig; |
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
Random random = new Random(); |
|
|
|
Data data = new Data(); |
|
|
|
Data data = new Data(); |
|
|
|
Selector selector = new Selector(); |
|
|
|
Selector selector = new Selector(); |
|
|
@ -72,14 +69,15 @@ public final class MainInterfaceController { |
|
|
|
history.loadHistory(); |
|
|
|
history.loadHistory(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ToggleGroup toggleGroup = new ToggleGroup(); |
|
|
|
public void bindProperties() { |
|
|
|
public void bindProperties() { |
|
|
|
nameChoose.selectedProperty().bindBidirectional(mainConfig.nameChooseProperty()); |
|
|
|
nameChoose.setToggleGroup(toggleGroup); |
|
|
|
|
|
|
|
numbChoose.setToggleGroup(toggleGroup); |
|
|
|
numbChoose.selectedProperty().bind(mainConfig.nameChooseProperty().not()); |
|
|
|
|
|
|
|
numbChoose.selectedProperty().unbind(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainConfig.nameChooseProperty().addListener((observable, oldValue, newValue) -> { |
|
|
|
toggleGroup.selectToggle(GlobalConfig.mainConfig.getChooseMethod() == MainConfig.METHOD_NAME ? nameChoose : numbChoose); |
|
|
|
mainConfig.setChooseMethod(mainConfig.getNameChoose() ? MainConfig.METHOD_NAME : MainConfig.METHOD_NUMBER); |
|
|
|
toggleGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> { |
|
|
|
|
|
|
|
GlobalConfig.mainConfig.setChooseMethod(newValue == nameChoose ? MainConfig.METHOD_NAME : MainConfig.METHOD_NUMBER); |
|
|
|
|
|
|
|
System.out.println("change!"+(newValue == nameChoose)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -88,8 +86,8 @@ public final class MainInterfaceController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setUpConfig(ConfigLoader configLoader) { |
|
|
|
public void setUpConfig(ConfigLoader configLoader) { |
|
|
|
mainConfig = configLoader.readConfigFromFile(FilePath.toSpecificPathForm("files/Config.json")); |
|
|
|
configLoader.readMainConfig(FilePath.toSpecificPathForm("files/Config.json")); |
|
|
|
VoicePlayer.voiceConfig = configLoader.readVoiceConfigFromFile(FilePath.toSpecificPathForm("files/VoiceConfig.json")); |
|
|
|
configLoader.loadVoiceConfig(FilePath.toSpecificPathForm("files/VoiceConfig.json")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
@FXML |
|
|
@ -116,9 +114,8 @@ public final class MainInterfaceController { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
NumberSettingsPaneController numberSettingsPaneController = new NumberSettingsPaneController(data); |
|
|
|
NumberSettingsPaneController numberSettingsPaneController = new NumberSettingsPaneController(data); |
|
|
|
numberSettingsPaneController.bindProperties(mainConfig); |
|
|
|
numberSettingsPaneController.bindProperties(GlobalConfig.mainConfig); |
|
|
|
new DialogMaker(rootPane).createDialogWithOneBtn("调整数字", numberSettingsPaneController); |
|
|
|
new DialogMaker(rootPane).createDialogWithOneBtn("调整数字", numberSettingsPaneController); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
@FXML |
|
|
@ -138,7 +135,7 @@ public final class MainInterfaceController { |
|
|
|
miniStage.initStyle(StageStyle.UNDECORATED); |
|
|
|
miniStage.initStyle(StageStyle.UNDECORATED); |
|
|
|
|
|
|
|
|
|
|
|
MiniPaneController miniPaneController = loader.getController(); |
|
|
|
MiniPaneController miniPaneController = loader.getController(); |
|
|
|
miniPaneController.setBase(data, mainConfig, selector); |
|
|
|
miniPaneController.setBase(data, selector); |
|
|
|
|
|
|
|
|
|
|
|
Stage currentStage = (Stage) anPaiBtn.getScene().getWindow(); |
|
|
|
Stage currentStage = (Stage) anPaiBtn.getScene().getWindow(); |
|
|
|
miniPaneController.setOldStage(currentStage); |
|
|
|
miniPaneController.setOldStage(currentStage); |
|
|
@ -154,11 +151,10 @@ public final class MainInterfaceController { |
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
@FXML |
|
|
|
void showSettings(ActionEvent event) { |
|
|
|
void showSettings(ActionEvent event) { |
|
|
|
|
|
|
|
|
|
|
|
SettingsPaneController settingsPaneController = new SettingsPaneController(); |
|
|
|
SettingsPaneController settingsPaneController = new SettingsPaneController(); |
|
|
|
|
|
|
|
|
|
|
|
settingsPaneController.setToggleGroup(); |
|
|
|
settingsPaneController.setToggleGroup(); |
|
|
|
settingsPaneController.bindProperties(mainConfig); |
|
|
|
settingsPaneController.bindProperties(); |
|
|
|
|
|
|
|
|
|
|
|
settingsPaneController.setRootPane(rootPane); |
|
|
|
settingsPaneController.setRootPane(rootPane); |
|
|
|
|
|
|
|
|
|
|
@ -177,7 +173,7 @@ public final class MainInterfaceController { |
|
|
|
|
|
|
|
|
|
|
|
public void init() { |
|
|
|
public void init() { |
|
|
|
|
|
|
|
|
|
|
|
selector.initialVariable(mainConfig, data, history, upperLabel.textProperty(), downLabel.textProperty()); |
|
|
|
selector.initialVariable(data, history, upperLabel.textProperty(), downLabel.textProperty()); |
|
|
|
selector.addStoppedEventListener((observableValue, oldValue, stop) -> { |
|
|
|
selector.addStoppedEventListener((observableValue, oldValue, stop) -> { |
|
|
|
if (stop) { |
|
|
|
if (stop) { |
|
|
|
anPaiBtn.setText("安排一下"); |
|
|
|
anPaiBtn.setText("安排一下"); |
|
|
@ -200,11 +196,11 @@ public final class MainInterfaceController { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mainConfig.getRandomCount()) { |
|
|
|
if (GlobalConfig.mainConfig.getRandomCount()) { |
|
|
|
mainConfig.setMaxTotalCount(100 + random.nextInt(151)); |
|
|
|
GlobalConfig.mainConfig.setMaxTotalCount(100 + random.nextInt(151)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mainConfig.getNameChoose()) { |
|
|
|
if (GlobalConfig.mainConfig.getChooseMethod() == MainConfig.METHOD_NAME) { |
|
|
|
runNameMode(); |
|
|
|
runNameMode(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
runNumberMode(); |
|
|
|
runNumberMode(); |
|
|
@ -225,9 +221,9 @@ public final class MainInterfaceController { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (data.compareNameIgnoreList() && mainConfig.getPassSelectedResult()) { |
|
|
|
if (data.compareNameIgnoreList() && GlobalConfig.mainConfig.getIgnoreSelectedResult()) { |
|
|
|
|
|
|
|
|
|
|
|
if (mainConfig.getEqualMode()) { |
|
|
|
if (GlobalConfig.mainConfig.getEqualMode()) { |
|
|
|
new DialogMaker(rootPane).createDialogWithOKAndCancel("啊?", "全部名字都被点完啦!\n要把名字的忽略列表重置吗?", e -> data.clearNameIgnoreList()); |
|
|
|
new DialogMaker(rootPane).createDialogWithOKAndCancel("啊?", "全部名字都被点完啦!\n要把名字的忽略列表重置吗?", e -> data.clearNameIgnoreList()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
new DialogMaker(rootPane).createMessageDialog("啊?", "全部名字都被点完啦!\n请多添加几个名字 或 点击“机会均等”的“重置”按钮。"); |
|
|
|
new DialogMaker(rootPane).createMessageDialog("啊?", "全部名字都被点完啦!\n请多添加几个名字 或 点击“机会均等”的“重置”按钮。"); |
|
|
@ -244,16 +240,16 @@ public final class MainInterfaceController { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
int minNumber = Integer.parseInt(mainConfig.getMinNumber()); |
|
|
|
int minNumber = Integer.parseInt(GlobalConfig.mainConfig.getMinNumber()); |
|
|
|
int maxNumber = Integer.parseInt(mainConfig.getMaxNumber()); |
|
|
|
int maxNumber = Integer.parseInt(GlobalConfig.mainConfig.getMaxNumber()); |
|
|
|
|
|
|
|
|
|
|
|
if (maxNumber - minNumber <= 0) { |
|
|
|
if (maxNumber - minNumber <= 0) { |
|
|
|
new DialogMaker(rootPane).createMessageDialog("嗯哼?", "数字要前小后大啊~"); |
|
|
|
new DialogMaker(rootPane).createMessageDialog("嗯哼?", "数字要前小后大啊~"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (data.getNumberIgnoreListSize() >= (maxNumber - minNumber + 1) && mainConfig.getPassSelectedResult()) { |
|
|
|
if (data.getNumberIgnoreListSize() >= (maxNumber - minNumber + 1) && GlobalConfig.mainConfig.getIgnoreSelectedResult()) { |
|
|
|
if (mainConfig.getEqualMode()) { |
|
|
|
if (GlobalConfig.mainConfig.getEqualMode()) { |
|
|
|
new DialogMaker(rootPane).createDialogWithOKAndCancel("啊?", "全部数字都被点完啦!\n要把数字的忽略列表重置吗?", e -> data.clearNumberIgnoreList()); |
|
|
|
new DialogMaker(rootPane).createDialogWithOKAndCancel("啊?", "全部数字都被点完啦!\n要把数字的忽略列表重置吗?", e -> data.clearNumberIgnoreList()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
new DialogMaker(rootPane).createMessageDialog("啊?", "全部数字都被点完啦!\n请扩大数字范围 或 点击“机会均等”的“重置”按钮。"); |
|
|
|
new DialogMaker(rootPane).createMessageDialog("啊?", "全部数字都被点完啦!\n请扩大数字范围 或 点击“机会均等”的“重置”按钮。"); |
|
|
@ -280,6 +276,6 @@ public final class MainInterfaceController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public MainConfig getMainConfig() { |
|
|
|
public MainConfig getMainConfig() { |
|
|
|
return mainConfig; |
|
|
|
return GlobalConfig.mainConfig; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|