Skip to content

Commit

Permalink
Merge pull request #16 from Shemplo/shemplo
Browse files Browse the repository at this point in the history
Game layout fixed
  • Loading branch information
Shemplo authored Sep 6, 2017
2 parents f6a1aeb + 9d4d9cd commit 7fd3079
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package me.shemplo.game.mankals.engine;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;

import javafx.scene.Scene;
import javafx.scene.control.Button;
Expand All @@ -27,7 +24,6 @@ public class GameRulesScene {
private MankalsMain _main;
private Scene _gameScene;

@SuppressWarnings ("unused")
private ScrollPane rulesScrollPane;
private BorderPane rootBorderPane;
private HBox windowTopMenuBox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class MankalsEngine {
private GraphicsContext context;
private HBox windowTopMenuBox;
private BorderPane borderPane;
@SuppressWarnings ("unused")
private StackPane stackPane;
private Canvas canvas;
private Button stopGameButton,
Expand Down Expand Up @@ -68,7 +67,7 @@ public MankalsEngine (Scene scene, MankalsMain main) {
}

@SuppressWarnings ("unchecked")
private void _init () {
private void _init () {
this.borderPane = (BorderPane) _gameScene.lookup ("#game_border_pane");
this.stackPane = (StackPane) _gameScene.lookup ("#game_stack_pane");

Expand All @@ -93,12 +92,14 @@ private void _init () {
});

this.gameLogList = (ListView <String>) _gameScene.lookup ("#game_log_list");
gameLogList.setMaxSize (200, stackPane.getHeight () - 10);
gameLogList.setFocusTraversable (false);

this.canvas = (Canvas) _gameScene.lookup ("#game_canvas");
canvas.setWidth (canvasWidth = (MankalsMain.GAME_FRAME_WIDTH * 3 / 4 - 10));
canvas.setWidth (MankalsMain.GAME_FRAME_WIDTH - 205 - horzOffset * 2);
canvas.setHeight (canvasHeight = MankalsMain.GAME_FRAME_HEIGHT);
this.context = canvas.getGraphicsContext2D ();
canvasWidth = canvas.getWidth ();

this.stopGameButton = (Button) _gameScene.lookup ("#game_stop_button");
stopGameButton.setOnMouseClicked (me -> {
Expand Down Expand Up @@ -155,7 +156,7 @@ public void startNewGame (int length, int mankals) {
gameLogList.getItems ().add (message);
}

private final double horzOffset = 50,
private final double horzOffset = 25,
vertOffset = 75;
private double cellWidth,
cellHeight;
Expand Down Expand Up @@ -322,8 +323,7 @@ private void _clearScreen () {
public void updateMouse (MouseEvent me) {
if (isGameFinished) { return; }

int cell = _fetchCell (me.getSceneX (),
me.getSceneY ());
int cell = _fetchCell (me.getX () - 25, me.getY ());

if (me.getClickCount () > 0) {
if (cell != -1) { _cellSelected (cell); }
Expand All @@ -346,7 +346,7 @@ public void updateMouse (MouseEvent me) {

private int _fetchCell (double x, double y) {
if (isAnimation) { return -1; }

double borderHeight = 33;
if (x >= horzOffset + cellWidth
&& x < horzOffset + cellWidth * (deskLength + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<Button
fx:id="exit_button"
styleClass="top_menu_button"
text="">
text=""
disable="true">
<HBox.margin>
<Insets top="0" right="0" bottom="5" left="0" />
</HBox.margin>
Expand Down Expand Up @@ -66,7 +67,11 @@
</StackPane>
</center>
<right>
<ListView fx:id="game_log_list" />
<ListView fx:id="game_log_list">
<BorderPane.margin>
<Insets bottom="5" left="0" right="5" top="5" />
</BorderPane.margin>
</ListView>
</right>
</BorderPane>

0 comments on commit 7fd3079

Please sign in to comment.