|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.event.WindowAdapter
sarj.GUI
public class GUI
The GUI class contains all the Swing components that comprise the SARJ Graphical User Interface
Field Summary | |
---|---|
static boolean |
STATE_CONNECTED
|
static boolean |
STATE_DISCONNECTED
|
Constructor Summary | |
---|---|
GUI(java.lang.String configFilePath,
java.lang.String scriptSettingsFilePath,
java.lang.String scriptButtonSettingsFileLocation,
GUIListener listener)
Creates a new GUI object. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Called as a result of implementing ActionListener |
void |
addPlayer(java.lang.String name,
int score,
int deaths,
java.lang.String ratio,
int ping,
int team,
java.lang.String ip,
int num)
Adds details of a player to the player table. |
void |
addScriptButton(java.lang.String name,
java.lang.String command)
Adds a new button to the ScriptButton panel |
void |
addTeam(java.lang.String name,
int score,
int kills,
int deaths,
int ping)
Adds details of a team to the team table. |
java.lang.String[] |
checkTimedScripts(long timePassed)
Checks all of the timed scripts to see if any should run |
void |
clearConsole()
Clears the connection console |
void |
clearPlayerTable()
Clears the table containing the list of currently connected players |
void |
clearTeamTable()
Clears the table containing details of each team |
void |
connected()
Updates the GUI components to show that the user is connected. |
void |
disconnected()
Updates the GUI components to show that the user is disconnected. |
java.lang.String |
getCommandBox()
Returns the value of the command combo box field on the main window |
java.lang.String |
getFilenameForEvent(java.lang.String eventName)
Returns the name of the file to execute for the specified event |
java.lang.String |
getIPField()
Returns the current value stored in the IP address field on the main window |
javax.swing.JFrame |
getMainFrame()
Returns the GUI's main window frame |
java.lang.String |
getPasswordField()
Returns the current value stored in the password field on the main window |
java.lang.Object[][] |
getPlayerData()
Returns all the data in the player table |
java.lang.Object[] |
getPlayerData(java.lang.String playerName)
Returns the row of the player table with the player name matching that provided |
java.lang.String |
getPortField()
Returns the current value stored in the port field on the main window |
ScriptButton[] |
getScriptButtons()
Returns the buttons on the ScriptButton panel |
java.lang.Object[][] |
getTeamData()
Returns all the data in the team table |
java.lang.Object[] |
getTeamData(java.lang.String teamName)
Returns the row of the team table with the team name matching that provided |
void |
hide()
Hide the GUI |
boolean |
isEventEnabled(java.lang.String eventName)
Returns whether or not the specified event is enabled |
void |
keyPressed(java.awt.event.KeyEvent e)
Called as a result of implementing KeyListener |
void |
keyReleased(java.awt.event.KeyEvent e)
Called as a result of implementing KeyListener |
void |
keyTyped(java.awt.event.KeyEvent e)
Called as a result of implementing KeyListener |
void |
mouseClicked(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
static void |
printError(java.lang.String errorString)
Displays error messages in the log console |
void |
removeScriptButton(java.lang.String name)
Removes a button from the ScriptButton panel |
void |
setAutoRefresh(boolean refresh)
Sets the automatic refresh timer to on or off |
void |
setCommandBox(java.lang.String command)
Sets the command combo box field on the main window to the specified string |
void |
setGameType(java.lang.String gameType)
Sets the game type label on the main window to the one specified |
void |
setIPField(java.lang.String ip)
Sets the server address text field on the main window to the one specified |
void |
setMapName(java.lang.String mapName)
Sets the map name label on the main window to the one specified |
void |
setPasswordField(java.lang.String password)
Sets the password field on the main window to the specified string |
void |
setPortField(java.lang.String port)
Sets the port number text field on the main window to the one specified |
void |
setRefreshDelay(int delay)
Sets the delay of the refresh timer for refreshing the player details |
void |
setScoreLimit(java.lang.String scoreLimit)
Sets the score limit label on the main window to the one specified |
void |
setTimeLeft(java.lang.String timeLeft)
Sets the time left label on the main window to the one specified |
void |
setTimeLimit(java.lang.String timeLimit)
Sets the time limit label on the main window to the one specified |
void |
setTitle(java.lang.String title)
Sets the window title of the GUI |
void |
show()
Display the GUI |
void |
startRefreshTimer(int delay)
Starts the automatic refresh timer with the specified millisecond delay |
void |
stopRefreshTimer()
Stops the automatic refresh timer |
void |
windowClosing(java.awt.event.WindowEvent e)
Called when the main window is being closed |
void |
writeToConsole(java.lang.String text)
Writes the specified string of text to the main console |
Methods inherited from class java.awt.event.WindowAdapter |
---|
windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean STATE_CONNECTED
public static final boolean STATE_DISCONNECTED
Constructor Detail |
---|
public GUI(java.lang.String configFilePath, java.lang.String scriptSettingsFilePath, java.lang.String scriptButtonSettingsFileLocation, GUIListener listener)
configFilePath
- the path of the SARJ configuration file
(e.g. config.txt)listener
- the object to receive events generated by the GUIMethod Detail |
---|
public void show()
public void hide()
public static void printError(java.lang.String errorString)
errorString
- the error message to displaypublic void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- the object containing details of the eventpublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
e
- object containing details of the key eventpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
e
- object containing details of the key eventpublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
e
- object containing details of the key eventpublic void setRefreshDelay(int delay)
delay
- the time to delay, in millisecondspublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void setTitle(java.lang.String title)
title
- the name of the new title for the windowpublic void setIPField(java.lang.String ip)
ip
- the server address to set the text field topublic void setPortField(java.lang.String port)
port
- the port number to set the text field topublic void setPasswordField(java.lang.String password)
password
- the password to setpublic void setCommandBox(java.lang.String command)
command
- the command to set the combo box topublic java.lang.String getCommandBox()
public void setAutoRefresh(boolean refresh)
refresh
- true or false to set the timer to on or off, respectivelypublic void setMapName(java.lang.String mapName)
mapName
- the name of the map to set the field topublic void setGameType(java.lang.String gameType)
gameType
- the name of the game type to set the field to
(e.g. Deathmatch, CTF, etc)public void setScoreLimit(java.lang.String scoreLimit)
scoreLimit
- the score limit to set the field topublic void setTimeLimit(java.lang.String timeLimit)
timeLimit
- the time limit to set the field topublic void setTimeLeft(java.lang.String timeLeft)
timeLeft
- the time to set the field topublic void clearConsole()
public void clearPlayerTable()
public void clearTeamTable()
public void addPlayer(java.lang.String name, int score, int deaths, java.lang.String ratio, int ping, int team, java.lang.String ip, int num)
name
- the name of the playerscore
- the player's scoredeaths
- the player's number of deathsratio
- the player's kill-to-death ratio (Infinity should be
represented as '*'ping
- the player's pingteam
- the player's current team number, where 1 = alpha, 2 = beta,
3 = charlie and 4 = deltaip
- the player's IP addressnum
- the player's unique in-game ID, as assigned by the serverclearPlayerTable()
public void addTeam(java.lang.String name, int score, int kills, int deaths, int ping)
name
- the name of the team (e.g. Alpha, Beta, Charlie, Delta)score
- the team's total scorekills
- the total number of kills made by players on the teamdeaths
- the total number of deaths made by the players on the teamping
- the average player ping of the teampublic javax.swing.JFrame getMainFrame()
public java.lang.String getIPField()
public java.lang.String getPortField()
public java.lang.String getPasswordField()
public void windowClosing(java.awt.event.WindowEvent e)
windowClosing
in interface java.awt.event.WindowListener
windowClosing
in class java.awt.event.WindowAdapter
e
- the object containing data of the activating window eventpublic void writeToConsole(java.lang.String text)
text
- the string of text to be printedpublic void startRefreshTimer(int delay)
delay
- the timer delay, in millisecondspublic void stopRefreshTimer()
public void connected()
public void disconnected()
public void addScriptButton(java.lang.String name, java.lang.String command)
name
- the name of the button. This will also appear as the button
captioncommand
- the command string associated with the button, to be
executed when it is activatedpublic void removeScriptButton(java.lang.String name)
name
- the name of the button to remove (the caption of the button)public ScriptButton[] getScriptButtons()
ScriptButton
objects currently on the panelpublic java.lang.String getFilenameForEvent(java.lang.String eventName) throws EventNotFoundException
eventName
- the name of the event
EventNotFoundException
- if the event isn't foundpublic boolean isEventEnabled(java.lang.String eventName) throws EventNotFoundException
eventName
- the name of the event
EventNotFoundException
- if the event isn't foundpublic java.lang.Object[] getPlayerData(java.lang.String playerName)
playerName
- the name of the player to match
public java.lang.Object[][] getPlayerData()
public java.lang.Object[] getTeamData(java.lang.String teamName)
teamName
- the name of the team to match
public java.lang.Object[][] getTeamData()
public java.lang.String[] checkTimedScripts(long timePassed)
timePassed
- the time passed, in milliseconds, since the last call
to this function
String
objects containing the filenames of the
scripts to be executed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |