Skip to content

Commit

Permalink
✨ FEAT. 루미큐브 UI 구현
Browse files Browse the repository at this point in the history
방 만들기 버튼 추가, 위치 변경

Related to : #2
  • Loading branch information
junhaa committed Dec 16, 2023
1 parent e257408 commit b0439b5
Showing 1 changed file with 71 additions and 68 deletions.
139 changes: 71 additions & 68 deletions src/View/GameView.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class GameView {
*/

// 타일 패널 이동 함수
public void moveTileUI(boolean startHand, boolean toHand, int startRow, int startCol, int endRow, int endCol){
public void moveTileUI(boolean startHand, boolean toHand, int startRow, int startCol, int endRow, int endCol) {
// 손패에 있는 타일일 경우
JPanel movePanel = startHand ? hand[startRow][startCol] : board[startRow][startCol];
JPanel desPanel = toHand ? hand[endRow][endCol] : board[endRow][endCol];

if(startHand) hand[startRow][startCol] = desPanel;
if (startHand) hand[startRow][startCol] = desPanel;
else board[startRow][startCol] = desPanel;

if(toHand) hand[endRow][endCol] = movePanel;
if (toHand) hand[endRow][endCol] = movePanel;
else board[endRow][endCol] = movePanel;
}

Expand Down Expand Up @@ -74,62 +74,69 @@ private void initialize() {
frame.getContentPane().setLayout(new CardLayout(0, 0));

// 로그인 패널 구현 부분
JPanel LoginPanel = new JPanel();
frame.getContentPane().add(LoginPanel, "name_1157230094774500");
LoginPanel.setLayout(null);

JPanel panel = new JPanel();
panel.setBounds(0, 0, 1584, 861);
LoginPanel.add(panel);
SpringLayout sl_panel = new SpringLayout();
panel.setLayout(sl_panel);

JLabel addressLabel = new JLabel("IP 주소");
addressLabel.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(addressLabel);

addressTF = new JTextField();
sl_panel.putConstraint(SpringLayout.SOUTH, addressTF, -300, SpringLayout.SOUTH, panel);
sl_panel.putConstraint(SpringLayout.NORTH, addressLabel, 8, SpringLayout.NORTH, addressTF);
sl_panel.putConstraint(SpringLayout.SOUTH, addressLabel, 0, SpringLayout.SOUTH, addressTF);
panel.add(addressTF);
addressTF.setColumns(10);

nameTF = new JTextField();
sl_panel.putConstraint(SpringLayout.NORTH, addressTF, 60, SpringLayout.SOUTH, nameTF);
sl_panel.putConstraint(SpringLayout.NORTH, nameTF, 425, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, nameTF, -400, SpringLayout.SOUTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, addressTF, 0, SpringLayout.WEST, nameTF);
sl_panel.putConstraint(SpringLayout.EAST, addressTF, 0, SpringLayout.EAST, nameTF);
sl_panel.putConstraint(SpringLayout.WEST, nameTF, 500, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.EAST, nameTF, -500, SpringLayout.EAST, panel);
nameTF.setToolTipText("이름을 입력하세요.");
panel.add(nameTF);
nameTF.setColumns(10);

JLabel nameLabel = new JLabel("이름");
sl_panel.putConstraint(SpringLayout.WEST, nameLabel, 350, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.WEST, addressLabel, 0, SpringLayout.WEST, nameLabel);
sl_panel.putConstraint(SpringLayout.EAST, addressLabel, 0, SpringLayout.EAST, nameLabel);
nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
sl_panel.putConstraint(SpringLayout.NORTH, nameLabel, 0, SpringLayout.NORTH, nameTF);
sl_panel.putConstraint(SpringLayout.SOUTH, nameLabel, 0, SpringLayout.SOUTH, nameTF);
sl_panel.putConstraint(SpringLayout.EAST, nameLabel, -50, SpringLayout.WEST, nameTF);
panel.add(nameLabel);

JButton connectButton = new JButton("연결하기");
sl_panel.putConstraint(SpringLayout.NORTH, connectButton, 50, SpringLayout.SOUTH, addressTF);
sl_panel.putConstraint(SpringLayout.WEST, connectButton, 650, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, connectButton, 660, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.EAST, connectButton, -650, SpringLayout.EAST, panel);
panel.add(connectButton);

JPanel LoginImagePanel = new JPanel();
sl_panel.putConstraint(SpringLayout.NORTH, LoginImagePanel, 60, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, LoginImagePanel, 300, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, LoginImagePanel, 320, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.EAST, LoginImagePanel, -300, SpringLayout.EAST, panel);
panel.add(LoginImagePanel);
JPanel LoginPanel = new JPanel();
frame.getContentPane().add(LoginPanel, "name_1157230094774500");
LoginPanel.setLayout(null);

JPanel panel = new JPanel();
panel.setBounds(0, 0, 1584, 861);
LoginPanel.add(panel);
SpringLayout sl_panel = new SpringLayout();
panel.setLayout(sl_panel);

JLabel addressLabel = new JLabel("IP 주소");
addressLabel.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(addressLabel);

addressTF = new JTextField();
sl_panel.putConstraint(SpringLayout.SOUTH, addressTF, -300, SpringLayout.SOUTH, panel);
sl_panel.putConstraint(SpringLayout.NORTH, addressLabel, 8, SpringLayout.NORTH, addressTF);
sl_panel.putConstraint(SpringLayout.SOUTH, addressLabel, 0, SpringLayout.SOUTH, addressTF);
panel.add(addressTF);
addressTF.setColumns(10);

nameTF = new JTextField();
sl_panel.putConstraint(SpringLayout.NORTH, addressTF, 60, SpringLayout.SOUTH, nameTF);
sl_panel.putConstraint(SpringLayout.NORTH, nameTF, 425, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, nameTF, -400, SpringLayout.SOUTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, addressTF, 0, SpringLayout.WEST, nameTF);
sl_panel.putConstraint(SpringLayout.EAST, addressTF, 0, SpringLayout.EAST, nameTF);
sl_panel.putConstraint(SpringLayout.WEST, nameTF, 500, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.EAST, nameTF, -500, SpringLayout.EAST, panel);
nameTF.setToolTipText("이름을 입력하세요.");
panel.add(nameTF);
nameTF.setColumns(10);

JLabel nameLabel = new JLabel("이름");
sl_panel.putConstraint(SpringLayout.WEST, nameLabel, 350, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.WEST, addressLabel, 0, SpringLayout.WEST, nameLabel);
sl_panel.putConstraint(SpringLayout.EAST, addressLabel, 0, SpringLayout.EAST, nameLabel);
nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
sl_panel.putConstraint(SpringLayout.NORTH, nameLabel, 0, SpringLayout.NORTH, nameTF);
sl_panel.putConstraint(SpringLayout.SOUTH, nameLabel, 0, SpringLayout.SOUTH, nameTF);
sl_panel.putConstraint(SpringLayout.EAST, nameLabel, -50, SpringLayout.WEST, nameTF);
panel.add(nameLabel);

JButton makeRoomButton = new JButton("방 만들기");
sl_panel.putConstraint(SpringLayout.NORTH, makeRoomButton, 73, SpringLayout.SOUTH, addressTF);
sl_panel.putConstraint(SpringLayout.WEST, makeRoomButton, 400, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, makeRoomButton, 704, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.EAST, makeRoomButton, -850, SpringLayout.EAST, panel);
panel.add(makeRoomButton);

JPanel LoginImagePanel = new JPanel();
sl_panel.putConstraint(SpringLayout.NORTH, LoginImagePanel, 60, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, LoginImagePanel, 300, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, LoginImagePanel, 320, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.EAST, LoginImagePanel, -300, SpringLayout.EAST, panel);
panel.add(LoginImagePanel);

JButton connectButton = new JButton("참여하기");
sl_panel.putConstraint(SpringLayout.NORTH, connectButton, 73, SpringLayout.SOUTH, addressTF);
sl_panel.putConstraint(SpringLayout.WEST, connectButton, 865, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, connectButton, -157, SpringLayout.SOUTH, panel);
sl_panel.putConstraint(SpringLayout.EAST, connectButton, -385, SpringLayout.EAST, panel);
panel.add(connectButton);

// 게 패널 레이아웃 설정
JPanel GamePanel = new JPanel();
Expand All @@ -143,9 +150,8 @@ private void initialize() {
PlayerIconPanel.setLayout(new BoxLayout(PlayerIconPanel, BoxLayout.Y_AXIS));



// 플레이어 아이콘 패널 추가
for(int i = 0 ; i < MAX_PLAYER_COUNT ; i ++) {
for (int i = 0; i < MAX_PLAYER_COUNT; i++) {
JPanel playerIconBorder = new JPanel();
PlayerIconPanel.add(playerIconBorder);
playerIconBorder.setLayout(new BorderLayout(0, 0));
Expand All @@ -171,7 +177,6 @@ private void initialize() {
}



JPanel panel_3 = new JPanel();
panel_3.setLayout(new BorderLayout(0, 0));
GamePanel.add(panel_3);
Expand Down Expand Up @@ -234,10 +239,10 @@ private void initialize() {
BoardPanel.setLayout(new GridLayout(BOARD_HEIGHT, BOARD_WIDTH, 0, 5));

// board 배열에 패널 추가
for(int i = 0; i < BOARD_HEIGHT; i ++) {
for (int i = 0; i < BOARD_HEIGHT; i++) {
JPanel curRowPanel = new JPanel();
BoardPanel.add(curRowPanel);
for(int j = 0; j < BOARD_WIDTH; j ++) {
for (int j = 0; j < BOARD_WIDTH; j++) {
JPanel tmp = new JPanel();
board[i][j] = tmp;
curRowPanel.add(tmp);
Expand All @@ -247,10 +252,10 @@ private void initialize() {
}

// hand 배열에 패널 추가
for(int i = 0; i < HAND_HEIGHT; i ++) {
for (int i = 0; i < HAND_HEIGHT; i++) {
JPanel curRowPanel = new JPanel();
HandPanel.add(curRowPanel);
for(int j = 0; j < HAND_WIDTH; j ++) {
for (int j = 0; j < HAND_WIDTH; j++) {
JPanel tmp = new JPanel();
hand[i][j] = tmp;
curRowPanel.add(tmp);
Expand All @@ -260,8 +265,6 @@ private void initialize() {
}




// 오른쪽 패널
JPanel MenuPanel = new JPanel();
GamePanel.add(MenuPanel);
Expand Down

0 comments on commit b0439b5

Please sign in to comment.