Skip to content

Commit 90f82bc

Browse files
committed
fixed some stupids
1 parent bbe8c25 commit 90f82bc

File tree

13 files changed

+122
-45
lines changed

13 files changed

+122
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Ignore Gradle project-specific cache directory
22
.gradle
3+
bedrockr.jar
34

45
# Ignore Gradle build output directory
56
build

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"java.configuration.updateBuildConfiguration": "automatic",
3-
"java.compile.nullAnalysis.mode": "automatic"
3+
"java.compile.nullAnalysis.mode": "automatic",
4+
"java.debug.settings.onBuildFailureProceed": true
45
}

app/build.gradle

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ repositories {
1717
mavenCentral()
1818
}
1919

20+
sourceSets {
21+
main {
22+
resources {
23+
srcDirs += ['src/main/java']
24+
includes = ['**/*.properties', '**/*.png', '**/*.otf', '**/*.pdn']
25+
}
26+
}
27+
}
2028

2129

2230
dependencies {
@@ -30,14 +38,8 @@ dependencies {
3038

3139
//gson
3240
implementation 'com.google.code.gson:gson:2.13.1'
33-
//flatlaf
34-
def flatlafVersion = '3.6'
35-
implementation( "com.formdev:flatlaf:${flatlafVersion}" )
36-
//implementation( "com.formdev:flatlaf:${flatlafVersion}" )
37-
//implementation( "com.formdev:flatlaf:${flatlafVersion}:linux-x86_64@so" )
38-
//implementation( "com.formdev:flatlaf:${flatlafVersion}:macos-arm64@dylib" )
39-
//implementation( "com.formdev:flatlaf:${flatlafVersion}:macos-x86_64@dylib" )
40-
//implementation( "com.formdev:flatlaf:${flatlafVersion}:windows-x86_64@dll" )
41+
//flat laf
42+
implementation 'com.formdev:flatlaf:3.6'
4143
}
4244

4345
// Apply a specific Java toolchain to ease working on different environments.

app/src/main/java/fn10/bedrockr/Launcher.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
package fn10.bedrockr;
55

6+
import fn10.bedrockr.utils.ErrorShower;
67
import fn10.bedrockr.utils.RFileOperations;
78
import fn10.bedrockr.utils.logging.RLogFilter;
89
import fn10.bedrockr.utils.logging.RLogFormatter;
@@ -16,7 +17,12 @@
1617
import java.util.logging.*;
1718

1819
import javax.swing.ImageIcon;
20+
import javax.swing.JFrame;
1921
import javax.swing.SwingUtilities;
22+
import javax.swing.UIManager;
23+
import javax.swing.UnsupportedLookAndFeelException;
24+
25+
import com.formdev.flatlaf.FlatLaf;
2026

2127
public class Launcher {
2228

@@ -58,15 +64,20 @@ public static void main(String[] args) {
5864

5965
// setup theme
6066

61-
// FlatLaf.registerCustomDefaultsSource("fn10.bedrockr.windows.laf" );
67+
FlatLaf.registerCustomDefaultsSource("fn10.bedrockr.windows.laf" );
68+
6269
try {
63-
BedrockrDark.setup();
70+
LOG.info(String.valueOf(BedrockrDark.setup()));
6471
} catch (Exception e) {
6572
e.printStackTrace();
73+
ErrorShower.showError(new JFrame(), "failed to load theme " + e.getCause().toString(), "FlatLaf Error", e);
6674
}
75+
LOG.info(UIManager.getLookAndFeel().toString());
76+
6777
// open app
6878
SwingUtilities.invokeLater(() -> {
69-
new RLaunchPage(LAUNCH_WINDOW_SIZE);
79+
var launch = new RLaunchPage(LAUNCH_WINDOW_SIZE);
80+
launch.setVisible(true);
7081
});
7182
}
7283
}

app/src/main/java/fn10/bedrockr/addons/source/SourceItemElement.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ public Object getSerilized() {
6565

6666
@Override
6767
public RElementCreationScreen getBuilderWindow(Frame Parent, ElementCreationListener parent) {
68-
var frame = new RElementCreationScreen(Parent,"Item", parent);
69-
70-
frame.addField(new RElementValue(String.class, "Name", "Name", false, "The name of the item. e.g. \"Diamond\", \"Coal\""));;
68+
var frame = new RElementCreationScreen(Parent, "Item", parent);
7169

70+
frame.addField(new RElementValue(String.class, "Name", "Name", false,
71+
"The name of the item. e.g. \"Diamond\", \"Coal\""));
72+
;
7273

7374
return frame;
7475
}

app/src/main/java/fn10/bedrockr/utils/RFonts.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.awt.*;
44
import java.io.File;
55
import java.io.IOException;
6+
import java.io.InputStream;
67

78
import javax.annotation.Nonnull;
89

@@ -15,13 +16,21 @@ public class RFonts {
1516

1617

1718
protected static Font SetupFont(@Nonnull String Path,int Size) {
18-
File font_file = new File(Launcher.class.getResource(Path).getPath());
19+
InputStream font_file;
20+
try {
21+
font_file = RFonts.class.getResourceAsStream(Path);
22+
} catch (Exception e) {
23+
e.printStackTrace();
24+
ErrorShower.showError(null, "Failed to open font file", "Font Error", e);
25+
return null;
26+
}
1927

2028
Font font = null;
2129
try { // try setting font
2230
font = Font.createFont(Font.TRUETYPE_FONT, font_file).deriveFont(1,Size);
2331
} catch (IOException | FontFormatException e) {
2432
e.printStackTrace();
33+
ErrorShower.showError(null, "Failed to open font file", "Font Error", e);
2534
}
2635

2736
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font); // reg font if not null

app/src/main/java/fn10/bedrockr/windows/RElementCreationScreen.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fn10.bedrockr.windows;
22

3+
import java.awt.FlowLayout;
34
import java.awt.Frame;
45
import java.awt.GridLayout;
56
import java.awt.event.ActionEvent;
@@ -18,8 +19,8 @@
1819
public class RElementCreationScreen extends RDialog implements ActionListener {
1920

2021
private ElementCreationListener Listener;
21-
private JPanel Pane;
22-
private GridLayout PaneLay = new GridLayout(0,2);
22+
private JPanel Pane = new JPanel();
23+
private FlowLayout PaneLay = new FlowLayout(1,8,6);
2324

2425
public RElementCreationScreen(Frame Parent, String elementName, ElementCreationListener listenier) {
2526
super(
@@ -55,7 +56,7 @@ public RElementCreationScreen(Frame Parent, String elementName, ElementCreationL
5556
Lay.putConstraint(SpringLayout.EAST, Sep, -5, SpringLayout.EAST, getContentPane());
5657

5758
Lay.putConstraint(SpringLayout.SOUTH, Pane, -5, SpringLayout.NORTH, Sep);
58-
Lay.putConstraint(SpringLayout.NORTH, Pane, -5, SpringLayout.NORTH, getContentPane());
59+
Lay.putConstraint(SpringLayout.NORTH, Pane, 5, SpringLayout.NORTH, getContentPane());
5960
Lay.putConstraint(SpringLayout.WEST, Pane, 5, SpringLayout.WEST, getContentPane());
6061
Lay.putConstraint(SpringLayout.EAST, Pane, -5, SpringLayout.EAST, getContentPane());
6162

app/src/main/java/fn10/bedrockr/windows/RLaunchPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public RLaunchPage(Dimension Size) {
9595
add(seperater);
9696
setModalExclusionType(ModalExclusionType.NO_EXCLUDE);
9797

98-
setVisible(true);
98+
//setVisible(true);
9999

100100
}
101101

app/src/main/java/fn10/bedrockr/windows/RNewSelector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ public void actionPerformed(ActionEvent e) {
9999
ElementSource instance = Creating.getDeclaredConstructor().newInstance();
100100

101101
RElementCreationScreen screen = (RElementCreationScreen) Creating
102-
.getMethod("getBuilderWindow", Frame.class,ElementCreationListener.class).invoke(instance, this.Parent, (ElementCreationListener)this.Parent);
102+
.getMethod("getBuilderWindow", Frame.class, ElementCreationListener.class)
103+
.invoke(instance, this.Parent, this.Parent);
103104
screen.setVisible(true);
104105
dispose();
105106

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,82 @@
11
package fn10.bedrockr.windows.componets;
22

3-
import javax.swing.ImageIcon;
4-
import javax.swing.JButton;
5-
import javax.swing.JLabel;
3+
import javax.annotation.Nonnull;
64
import javax.annotation.Nullable;
75
import javax.swing.*;
86
import java.awt.*;
7+
import java.awt.event.ItemEvent;
8+
import java.awt.event.ItemListener;
99
import java.lang.reflect.Type;
10-
11-
import javax.swing.SpringLayout;
1210
import javax.swing.border.LineBorder;
11+
import fn10.bedrockr.Launcher;
1312

1413
public class RElementValue extends JPanel {
1514

1615
private SpringLayout Lay = new SpringLayout();
1716
private JLabel Name = new JLabel();
1817
private JButton Help = new JButton(new ImageIcon(getClass().getResource("/ui/Help.png")));
18+
private Component Input;
19+
private JCheckBox EnableDis = new JCheckBox();
1920

20-
private final static Dimension Size = new Dimension(320, 60);
21+
private final static Dimension Size = new Dimension(335, 40);
22+
private String Target = "";
2123

22-
public RElementValue(Type InputType, String TargetField, String DisplayName, Boolean Optional, @Nullable String HelpString ) {
24+
public RElementValue(@Nonnull Type InputType, String TargetField, String DisplayName, Boolean Optional,
25+
@Nullable String HelpString) {
2326
super();
27+
28+
this.Target = TargetField;
29+
2430
setMaximumSize(Size);
2531
setPreferredSize(Size);
32+
setBorder(new LineBorder(Color.DARK_GRAY));
33+
setLayout(Lay);
2634

27-
// for testing
28-
setBorder(new LineBorder(Color.white));
35+
Help.setSize(6, 6);
36+
Help.putClientProperty("JButton.buttonType", "help" );
37+
//Help.setBorder(new FlatLineBorder(new Insets(3, 3, 3, 3), Color.white, 1, 32));
38+
39+
Launcher.LOG.info(InputType.getTypeName());
40+
if (InputType.equals(Boolean.class)) {
41+
String[] vals = { "true", "false" };
42+
Input = new JComboBox<String>(vals);
43+
} else {
44+
Input = new JTextField();
45+
}
46+
47+
EnableDis.addItemListener(new ItemListener() {
48+
49+
@Override
50+
public void itemStateChanged(ItemEvent e) {
51+
EnableDis.setEnabled(e.getStateChange() == e.SELECTED ? true : false);
52+
}
53+
54+
});
2955

30-
Help.setSize(30, 30);
31-
3256
Name.setText(DisplayName);
3357

34-
add(Name);
58+
Lay.putConstraint(SpringLayout.VERTICAL_CENTER, Name, 0, SpringLayout.VERTICAL_CENTER, this);
59+
Lay.putConstraint(SpringLayout.WEST, Name, 13, SpringLayout.WEST, this);
60+
61+
Lay.putConstraint(SpringLayout.WEST, Input, 3, SpringLayout.EAST, Name);
62+
Lay.putConstraint(SpringLayout.NORTH, Input, 3, SpringLayout.NORTH, this);
63+
Lay.putConstraint(SpringLayout.SOUTH, Input, -3, SpringLayout.SOUTH, this);
64+
Lay.putConstraint(SpringLayout.EAST, Input, -3, SpringLayout.WEST, EnableDis);
65+
66+
Lay.putConstraint(SpringLayout.EAST, EnableDis, -3, SpringLayout.EAST, this);
67+
Lay.putConstraint(SpringLayout.VERTICAL_CENTER, EnableDis, 0, SpringLayout.VERTICAL_CENTER, this);
68+
69+
if (!Optional) {
70+
EnableDis.setEnabled(false);
71+
}
72+
73+
Launcher.LOG.info(Input.toString());
3574
add(Help);
75+
add(Name);
76+
add(Input);
77+
add(EnableDis);
78+
79+
80+
3681
}
3782
}

0 commit comments

Comments
 (0)