From 000463f491796035b6409f7624fb76a4ac773f8d Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 24 Oct 2001 01:26:54 +0000 Subject: [PATCH] Added a "Go" button to games in progress that can be used to enter those game rooms. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@549 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../micasa/lobby/table/TableItem.java | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/micasa/lobby/table/TableItem.java b/src/java/com/threerings/micasa/lobby/table/TableItem.java index 2c6e7b8e0..be90fec5c 100644 --- a/src/java/com/threerings/micasa/lobby/table/TableItem.java +++ b/src/java/com/threerings/micasa/lobby/table/TableItem.java @@ -1,5 +1,5 @@ // -// $Id: TableItem.java,v 1.2 2001/10/23 23:52:01 mdb Exp $ +// $Id: TableItem.java,v 1.3 2001/10/24 01:26:54 mdb Exp $ package com.threerings.micasa.lobby.table; @@ -47,6 +47,7 @@ public class TableItem { // keep track of these _tdtr = tdtr; + _ctx = ctx; // add ourselves as a seatedness observer _tdtr.addSeatednessObserver(this); @@ -105,6 +106,15 @@ public class TableItem // and add the button with the configured constraints add(_seats[i], gbc); + + // if we just added the first button, add the "go" button + // right after it + if (i == 0) { + _goButton = new JButton("Go"); + _goButton.setActionCommand("go"); + _goButton.addActionListener(this); + add(_goButton, gbc); + } } // and update ourselves based on the contents of the occupants @@ -143,6 +153,9 @@ public class TableItem _seats[i].setEnabled(false); } } + + // show or hide our "go" button appropriately + _goButton.setVisible(table.gameOid != -1); } /** @@ -158,7 +171,8 @@ public class TableItem // documentation inherited public void actionPerformed (ActionEvent event) { - if (event.getActionCommand().equals("join")) { + String cmd = event.getActionCommand(); + if (cmd.equals("join")) { // figure out what position this button is in int position = -1; for (int i = 0; i < _seats.length; i++) { @@ -177,9 +191,16 @@ public class TableItem _tdtr.joinTable(table.getTableId(), position); } - } else { + } else if (cmd.equals("leave")) { // if we're not joining, we're leaving _tdtr.leaveTable(table.getTableId()); + + } else if (cmd.equals("go")) { + // they want to see the game... so go there + _ctx.getLocationDirector().moveTo(table.gameOid); + + } else { + Log.warning("Received unknown action [event=" + event + "]."); } } @@ -188,8 +209,16 @@ public class TableItem { // just update ourselves tableUpdated(table); + + // enable or disable the go button based on our seatedness + if (_goButton.isVisible()) { + _goButton.setEnabled(!isSeated); + } } + /** A reference to our context. */ + protected MiCasaContext _ctx; + /** Our username. */ protected String _self; @@ -202,6 +231,10 @@ public class TableItem /** We have a button for each "seat" at the table. */ protected JButton[] _seats; + /** We have a button for going to games that are already in + * progress. */ + protected JButton _goButton; + /** The text shown for seats at which the user can join. */ protected static final String JOIN_LABEL = "";