修复“迷你模式”下名字/数字不能正确显示的问题

main
lensfrex 3 years ago
parent d884edbe11
commit 5df2f9c7f6
Signed by: lensfrex
GPG Key ID: 947ADABD8533C476
  1. 21
      Dogename/src/main/java/me/lensferno/dogename/DataReleaser.java
  2. 6
      Dogename/src/main/java/me/lensferno/dogename/Main.java
  3. 2
      Dogename/src/main/java/me/lensferno/dogename/controllers/MainInterfaceController.java
  4. 63
      Dogename/src/main/java/me/lensferno/dogename/controllers/MiniPaneController.java
  5. 10
      Dogename/src/main/java/me/lensferno/dogename/controllers/ProgramInfoPaneController.java
  6. 5
      Dogename/src/main/java/me/lensferno/dogename/resources/MainInterfaceImage.java
  7. 5
      Dogename/src/main/java/me/lensferno/dogename/resources/dogename.java
  8. 8
      Dogename/src/main/java/me/lensferno/dogename/select/Selector.java
  9. 4
      Dogename/src/main/java/me/lensferno/dogename/select/core/Worker.java
  10. BIN
      Dogename/src/main/resources/images/banner.png
  11. BIN
      Dogename/src/main/resources/images/doge.png

@ -1,21 +0,0 @@
package me.lensferno.dogename;
import me.lensferno.dogename.resources.MainInterfaceImage;
import me.lensferno.dogename.resources.dogename;
import org.apache.commons.codec.binary.Base64;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
public class DataReleaser {
public static InputStream getDogenameStream(){
return new ByteArrayInputStream(Base64.decodeBase64(dogename.data));
}
public static InputStream getMainPicStream(){
return new ByteArrayInputStream(Base64.decodeBase64(MainInterfaceImage.data));
}
}

@ -65,7 +65,11 @@ public class Main extends Application {
mainInterfaceController.bindProperties();
mainInterfaceController.setImg(DataReleaser.getMainPicStream());
try {
mainInterfaceController.setImg(getClass().getResourceAsStream("/images/doge.png"));
} catch (Exception e) {
e.printStackTrace();
}
mainInterfaceController.init();

@ -151,7 +151,7 @@ public final class MainInterfaceController {
miniPaneController.setBase(data, mainConfig, selector);
Stage currentStage=(Stage)anPaiBtn.getScene().getWindow();
miniPaneController.setForwStage(currentStage);
miniPaneController.setOldStage(currentStage);
miniPaneController.setCurrentStage(miniStage);
miniPaneController.setCurrentScene(miniScene);

@ -1,6 +1,7 @@
package me.lensferno.dogename.controllers;
import com.jfoenix.controls.JFXButton;
import javafx.beans.property.StringProperty;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
@ -28,17 +29,17 @@ public class MiniPaneController {
@FXML
private JFXButton miniModeBtn;
Stage forwStage;
Stage oldStage;
public Stage getForwStage() {
return forwStage;
public Stage getOldStage() {
return oldStage;
}
public void setForwStage(Stage forwStage) {
this.forwStage = forwStage;
public void setOldStage(Stage oldStage) {
this.oldStage = oldStage;
}
private Random random=new Random();
private Random random = new Random();
private Data data;
Stage currentStage;
@ -52,24 +53,32 @@ public class MiniPaneController {
this.currentStage = currentStage;
}
public void setBase(Data data, MainConfig mainConfig, Selector selector){
StringProperty[] oldTextProperties = null;
public void setBase(Data data, MainConfig mainConfig, Selector selector) {
this.data = data;
this.mainConfig=mainConfig;
this.mainConfig = mainConfig;
this.selector = selector;
this.selector.setLabelTexts(chosenNameLabel.textProperty());
this.oldTextProperties = oldTextProperties;
}
@FXML
void recoverMode(ActionEvent event) {
this.forwStage.show();
this.oldStage.setOnShown((e) -> {
selector.setLabelTexts(oldTextProperties);
});
this.oldStage.show();
currentStage.close();
}
public void setListeners(){
EventHandler<MouseEvent> mouseHandler=new MoveWindowByMouse(currentStage);
public void setListeners() {
EventHandler<MouseEvent> mouseHandler = new MoveWindowByMouse(currentStage);
chosenNameLabel.setOnMousePressed(mouseHandler);
chosenNameLabel.setOnMouseDragged(mouseHandler);
EventHandler<TouchEvent> touchHandler=new MoveWindowByTouch(currentStage);
EventHandler<TouchEvent> touchHandler = new MoveWindowByTouch(currentStage);
chosenNameLabel.setOnTouchPressed(touchHandler);
chosenNameLabel.setOnTouchMoved(touchHandler);
@ -87,22 +96,22 @@ public class MiniPaneController {
}
private MainConfig mainConfig;
private Selector selector =new Selector();
private Selector selector = new Selector();
@FXML
void anPai() {
if(selector.isWorkerRunning()){
if (selector.isWorkerRunning()) {
selector.forceStop();
anPaiBtn.setText("安排一下");
return;
}
if(mainConfig.getRandomCount()) {
mainConfig.setMaxTotalCount(100+random.nextInt(151));
if (mainConfig.getRandomCount()) {
mainConfig.setMaxTotalCount(100 + random.nextInt(151));
}
if(mainConfig.getNameChoose()){
if (mainConfig.getNameChoose()) {
runNameMode();
} else {
runNumberMode();
@ -110,13 +119,13 @@ public class MiniPaneController {
}
private void runNameMode(){
private void runNameMode() {
if(data.isEmpty()){
if (data.isEmpty()) {
return;
}
if(data.compareNameIgnoreList()&&mainConfig.getPassSelectedResult()){
if (data.compareNameIgnoreList() && mainConfig.getPassSelectedResult()) {
return;
}
@ -125,22 +134,22 @@ public class MiniPaneController {
selector.run();
}
private void runNumberMode(){
private void runNumberMode() {
try{
try {
int minNumber=Integer.parseInt(mainConfig.getMinNumber());
int maxNumber=Integer.parseInt(mainConfig.getMaxNumber());
int minNumber = Integer.parseInt(mainConfig.getMinNumber());
int maxNumber = Integer.parseInt(mainConfig.getMaxNumber());
if(maxNumber-minNumber<=0){
if (maxNumber - minNumber <= 0) {
return;
}
if(data.getNumberIgnoreListSize()>=(maxNumber-minNumber+1) && mainConfig.getPassSelectedResult()){
if (data.getNumberIgnoreListSize() >= (maxNumber - minNumber + 1) && mainConfig.getPassSelectedResult()) {
return;
}
}catch (Exception e){
} catch (Exception e) {
return;
}

@ -12,7 +12,6 @@ import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import me.lensferno.dogename.DataReleaser;
import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.utils.IOUtil;
@ -38,8 +37,13 @@ public class ProgramInfoPaneController extends VBox {
}catch(Exception e){
e.printStackTrace();
}
Image dogeImage=new Image(DataReleaser.getDogenameStream());
dogeView.setImage(dogeImage);
try {
dogeView.setImage(new Image(getClass().getResourceAsStream("/images/banner.png")));
} catch (Exception e) {
e.printStackTrace();
}
this.rootPane=rootPane;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -55,6 +55,10 @@ public final class Selector {
processor.stoppedIndicatorProperty().addListener(listener);
}
public void setLabelTexts(StringProperty... labelTexts) {
processor.setWorkerLabelTexts(labelTexts);
}
// ---------------------------------------------------
static class Processor extends AnimationTimer {
@ -67,6 +71,10 @@ public final class Selector {
this.config = config;
}
protected void setWorkerLabelTexts(StringProperty... labelTexts) {
coreWorker.setLabelTexts(labelTexts);
}
protected void updateNewValue() {
coreWorker.setSpeed(100 - config.getSpeed());
coreWorker.setMaxTotalCount(config.getMaxTotalCount());

@ -60,6 +60,10 @@ public final class Worker {
this.voicePlayer = voicePlayer;
}
public void setLabelTexts(StringProperty[] labelTexts) {
this.labelTexts = labelTexts;
}
private void select() {
// try的位置待定(前面or后面)
// 延时用,用于调整挑选速度

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Loading…
Cancel
Save