Skip to content

Commit

Permalink
Adjust the background display issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zsalch committed Apr 2, 2019
1 parent 6670831 commit d2c587c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 45 deletions.
6 changes: 3 additions & 3 deletions src/main/java/featurecat/lizzie/gui/BoardPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class BoardPane extends LizziePane {
public static Font winrateFont;

// private final BufferStrategy bs;
private boolean started = false;
private static boolean started = false;

private static final int[] outOfBoundCoordinate = new int[] {-1, -1};
public int[] mouseOverCoordinate = outOfBoundCoordinate;
Expand Down Expand Up @@ -539,8 +539,8 @@ public void onClicked(int x, int y) {
if (Lizzie.board.inAnalysisMode()) Lizzie.board.toggleAnalysis();
if (!isPlayingAgainstLeelaz || (playerIsBlack == Lizzie.board.getData().blackToPlay))
Lizzie.board.place(coords[0], coords[1]);
repaint();
owner.updateStatus();
// repaint();
// owner.updateStatus();
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/featurecat/lizzie/gui/CommentPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,18 @@ public void setDesignMode(boolean mode) {
if (mode) {
remove(scrollPane);
add(dragPane);
this.commentPane.setVisible(false);
this.scrollPane.setVisible(false);
commentPane.setVisible(false);
scrollPane.setVisible(false);
dragPane.setVisible(true);
} else {
remove(dragPane);
add(scrollPane);
this.commentPane.setVisible(true);
this.scrollPane.setVisible(true);
commentPane.setVisible(true);
scrollPane.setVisible(true);
dragPane.setVisible(false);
}
super.setDesignMode(mode);
revalidate();
repaint();
}

Expand Down
83 changes: 45 additions & 38 deletions src/main/java/featurecat/lizzie/gui/LizzieMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
Expand Down Expand Up @@ -263,44 +264,45 @@ public void run() {
* @param g0 not used
*/
// TODO Need Better Background
// public void paint(Graphics g0) {
//// super.paintComponents(g0);
//
// int width = getWidth();
// int height = getHeight();
//
// originX = getX();
// originY = getY();
// originW = width;
// originH = height;
//
// Optional<Graphics2D> backgroundG;
// if (cachedBackgroundWidth != width
// || cachedBackgroundHeight != height
// || redrawBackgroundAnyway) {
// backgroundG = Optional.of(createBackground());
// } else {
// backgroundG = Optional.empty();
// }
//
//// cachedImage = new BufferedImage(width, height, TYPE_INT_ARGB);
//// Graphics2D g = (Graphics2D) cachedImage.getGraphics();
//// g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
//
// // cleanup
//// g.dispose();
//
// // draw the image
// Graphics2D bsGraphics = (Graphics2D) bs.getDrawGraphics();
// bsGraphics.setRenderingHint(RenderingHints.KEY_RENDERING,
// RenderingHints.VALUE_RENDER_QUALITY);
// bsGraphics.drawImage(cachedBackground, 0, 0, null);
//// bsGraphics.drawImage(cachedImage, 0, 0, null);
//
// // cleanup
// bsGraphics.dispose();
// bs.show();
// }
public void paint(Graphics g0) {
super.paintComponents(g0);

// int width = getWidth();
// int height = getHeight();
//
// originX = getX();
// originY = getY();
// originW = width;
// originH = height;
//
// Optional<Graphics2D> backgroundG;
// if (cachedBackgroundWidth != width
// || cachedBackgroundHeight != height
// || redrawBackgroundAnyway) {
// backgroundG = Optional.of(createBackground());
// } else {
// backgroundG = Optional.empty();
// }
//
// // cachedImage = new BufferedImage(width, height, TYPE_INT_ARGB);
// // Graphics2D g = (Graphics2D) cachedImage.getGraphics();
// // g.setRenderingHint(RenderingHints.KEY_RENDERING,
// RenderingHints.VALUE_RENDER_QUALITY);
//
// // cleanup
// // g.dispose();
//
// // draw the image
// Graphics2D bsGraphics = (Graphics2D) bs.getDrawGraphics();
// bsGraphics.setRenderingHint(RenderingHints.KEY_RENDERING,
// RenderingHints.VALUE_RENDER_QUALITY);
// bsGraphics.drawImage(cachedBackground, 0, 0, null);
// // bsGraphics.drawImage(cachedImage, 0, 0, null);
//
// // cleanup
// bsGraphics.dispose();
// bs.show();
}

/**
* temporary measure to refresh background. ideally we shouldn't need this (but we want to release
Expand Down Expand Up @@ -381,9 +383,14 @@ public void repaintSub() {
}

public void updateStatus() {
basicInfoPane.revalidate();
basicInfoPane.repaint();
variationTreePane.revalidate();
variationTreePane.repaint();
commentPane.drawComment();
commentPane.revalidate();
commentPane.repaint();
invalidLayout();
}

public static void openConfigDialog() {
Expand Down

0 comments on commit d2c587c

Please sign in to comment.