Update of /cvsroot/rails/18xx/rails/common
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv3066/rails/common
Added Files:
ServerToClient.java GuiHints.java
Log Message:
New classes for the server-to-client communication
--- NEW FILE: ServerToClient.java ---
package rails.common;
import java.io.Serializable;
/**
* Instances of this class are intended to carry all data that
* (after the foreseen client/server split) would be sent from
* the server (game enigine) to the client (GUI) after completion
* of the processing of each player action.
* All contents of this class must be Serializable.
* <p>This class is still in its infancy. Over time it will probably
* absorb the current PossibleActions and DisplayBuffer classes,
* and also include many details that the GUI now obtains
* via direct calls to server methods.
* @author VosE
*
*/
public class ServerToClient implements Serializable {
public static final long serialVersionUID = 1L;
private GuiHints guiHints = null;
public GuiHints getUiHints() {
return guiHints;
}
public void setUiHints(GuiHints guiHints) {
this.guiHints = guiHints;
}
}
--- NEW FILE: GuiHints.java ---
package rails.common;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import rails.game.RoundI;
/**
* This class contains hints from the server (game engine) to the client (GUI)
* about the preferred visibility of the various window types.
* It is up to the GUI (and its user) to decide what to do with these hints,
* but the current implementation should exactly follow these hints.
* @author VosE
*
*/
public class GuiHints implements Serializable {
public static final long serialVersionUID = 1L;
/** What round type is currently active in the engine? */
private Class<? extends RoundI> currentRoundType = null;
/** Which windows should be visible? */
private List<VisibilityHint> visibilityHints;
/** Which window type is active and should be on top? */
private GuiDef.Panel activePanel;
public Class<? extends RoundI> getCurrentRoundType() {
return currentRoundType;
}
public void setCurrentRoundType(Class<? extends RoundI> currentRoundType) {
this.currentRoundType = currentRoundType;
}
public List<VisibilityHint> getVisibilityHints() {
return visibilityHints;
}
public void setVisibilityHint(GuiDef.Panel type, boolean visibility) {
if (visibilityHints == null) {
visibilityHints = new ArrayList<VisibilityHint>(4);
}
visibilityHints.add (new VisibilityHint(type, visibility));
}
public void clearVisibilityHints () {
if (visibilityHints == null) {
visibilityHints = new ArrayList<VisibilityHint>(4);
} else {
visibilityHints.clear();
}
}
public GuiDef.Panel getActivePanel() {
return activePanel;
}
public void setActivePanel(GuiDef.Panel activePanel) {
this.activePanel = activePanel;
}
public class VisibilityHint {
GuiDef.Panel type;
boolean visibility;
VisibilityHint (GuiDef.Panel type, boolean visibility) {
this.type = type;
this.visibility = visibility;
}
public GuiDef.Panel getType() {
return type;
}
public boolean getVisibility() {
return visibility;
}
}
}
|