Skip to content

Commit 743371f

Browse files
committed
add File History and mod for Static Content
1 parent 1ee689b commit 743371f

12 files changed

Lines changed: 40 additions & 21 deletions

File tree

23.9 KB
Binary file not shown.
0 Bytes
Binary file not shown.
550 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
72 Bytes
Binary file not shown.

graphics/src/main/java/com/ndsl/graphics/GraphicsMain.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,23 @@
1818

1919
public class GraphicsMain {
2020
public static final Color Default_Color=new Color(0, 0, 0);
21-
public static final File BunFaceFile=new File("graphics\\src\\main\\java\\com\\ndsl\\graphics\\display\\drawable\\img\\bun_face.jpg");
22-
public static Image BunFace = null;
21+
public final File BunFaceFile=new File("graphics\\src\\main\\java\\com\\ndsl\\graphics\\display\\drawable\\img\\bun_face.jpg");
22+
public Image BunFace = null;
2323

24-
static {
25-
try {
26-
BunFace = ImageIO.read(BunFaceFile);
27-
} catch (IOException e) {
28-
e.printStackTrace();
29-
}
30-
}
24+
public Display display;
3125

32-
public static Display display;
26+
public static void main(String[] args){
27+
new GraphicsMain().onRun();
28+
}
3329

34-
static {
30+
public void onRun(){
31+
display = new Display("NDSL/Graphics",3,new Rect(new Pos(100,100),new Pos(600,600)));
3532
try {
36-
display = new Display("NDSL/Graphics",3,new Rect(new Pos(100,100),new Pos(600,600)));
37-
} catch (LineUnavailableException e) {
33+
BunFace = ImageIO.read(BunFaceFile);
34+
} catch (IOException e) {
3835
e.printStackTrace();
3936
}
40-
}
4137

42-
public static void main(String[] args){
4338
/*
4439
drawable remove test
4540
!PASSED!

graphics/src/main/java/com/ndsl/graphics/display/Display.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.ndsl.graphics.display.scene.SceneManager;
1616
import com.ndsl.graphics.pos.Pos;
1717
import com.ndsl.graphics.pos.Rect;
18+
import org.jetbrains.annotations.NotNull;
1819
import org.jetbrains.annotations.Nullable;
1920

2021
import javax.sound.sampled.LineUnavailableException;
@@ -27,21 +28,21 @@
2728
public class Display extends JFrame {
2829

2930
public FPSLimiter limiter =new FPSLimiter(120, FPSAttitude.KEEP_UP_FPS);
30-
31+
public long Start_Time;
3132
public BufferStrategy bufferStrategy;
3233
public KeyInputHandler keyHandler;
3334
public MouseInputHandler mouseInputHandler;
3435
public Debugger debugger;
3536

3637
public SceneManager sceneManager=new SceneManager();
3738

38-
@Deprecated
39-
public AudioInput audioInput=new AudioInput(0);
39+
// @Deprecated
40+
// public AudioInput audioInput=new AudioInput(0);
4041

41-
@Deprecated
42-
public AudioOutput audioOutput=new AudioOutput();
42+
// @Deprecated
43+
// public AudioOutput audioOutput=new AudioOutput();
4344

44-
public Display(String title, int bufferSize, Rect displayBound) throws LineUnavailableException {
45+
public Display(String title, int bufferSize, @NotNull Rect displayBound) {
4546
this.setTitle(title);
4647
this.setBounds(displayBound.left_up.x,displayBound.left_up.y,displayBound.getWidth(),displayBound.getHeight());
4748
this.setVisible(true);
@@ -52,6 +53,11 @@ public Display(String title, int bufferSize, Rect displayBound) throws LineUnava
5253
this.mouseInputHandler=new MouseInputHandler(this);
5354
// this.setAlwaysOnTop(true);
5455
this.debugger=new Debugger(limiter,keyHandler,mouseInputHandler);
56+
Start_Time=System.currentTimeMillis();
57+
}
58+
59+
public long getDeltaTime(){
60+
return System.currentTimeMillis()-Start_Time;
5561
}
5662

5763
public List<Drawable> drawableList=new ArrayList<>();

graphics/src/main/java/com/ndsl/graphics/display/drawable/DrawableUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ndsl.graphics.display.drawable;
22

3+
import com.ndsl.graphics.pos.Pos;
34
import com.ndsl.graphics.pos.Rect;
45
import org.jetbrains.annotations.NotNull;
56

@@ -12,4 +13,8 @@ public static void drawString(@NotNull String data, Graphics g, Rect rect, int f
1213
g.drawString(datas[i],rect.left_up.x,rect.left_up.y+i*fontsize+fontsize);
1314
}
1415
}
16+
17+
public Rect getStringShowingRect(@NotNull String s,Graphics graphics, Font font,int fontsize){
18+
return new Rect(font.getStringBounds("hello world!", ((Graphics2D)graphics).getFontRenderContext()));
19+
}
1520
}

graphics/src/main/java/com/ndsl/graphics/display/mouse/MouseInputHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void mouseReleased(MouseEvent e) {
7676
setDoubleClick(e);
7777
setNow_mouse_pos(e);
7878
setMouseButton(e);
79+
Current_Mouse_Button=0;
7980
register.hook(e,MouseEventType.RELEASE);
8081
isClicking=false;
8182
}

0 commit comments

Comments
 (0)