|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.maps.AbstractCamera wyvern.kernel.player.GroundCamera
This class implements a camera that views the ground beneath the player, to update the ground-display on the client.
Ground-cameras are pretty simple beasts. They're only interested in what's under the player. They show everything, in the order the objects appear in the map cell. Whenever the player moves, the camera is completely invalidated. The only tricky thing the ground camera does is to examine the lists of objects being sent, and see if exactly one entry is being added, removed, or modified. If so, it sends a RemoteInventory command to add, remove or modify the index in question. This results in a big speedup for handheld clients.
Field Summary | |
protected java.util.List |
lastFrame_
|
Fields inherited from class wyvern.kernel.maps.AbstractCamera |
bounds_, client_, completelyInvalid_, frame_, hasMoved_, height_, left_, map_, player_, ready_, size_, top_, width_, xoffset_, yoffset_ |
Constructor Summary | |
GroundCamera(RemoteClient client,
Player player)
Constructs a new GroundCamera for the specified player. |
Method Summary | |
protected void |
add(GroundFrame frame,
int index)
Adds an item from the new frame at the specified index. |
boolean |
changesNotVisible(MapDirtyRegions changes)
Returns true if none of the map changes were visible to us. |
void |
clearLastFrame()
Nulls out the lastFrame_ field, which forces the next refresh request to go through, even if the contents haven't changed. |
protected int |
examineChanges(GroundFrame frame)
Figures out what's changed since the last frame. |
java.util.List |
getLastFrame()
Returns the list of objects that were last sent to the client. |
DisplayPolicy |
makeFrame()
Creates an AbstractFrame subclass to use as our DisplayPolicy. |
protected void |
modify(GroundFrame frame,
int index)
Modifies an item in place. |
void |
move(int xoffset,
int yoffset)
Makes sure the GroundCamera is invalidated when it moves. |
protected void |
resendAll(GroundFrame frame)
Resends the entire new frame to the client. |
void |
sendEmptyList()
Sends a blank screen. |
boolean |
sendInfo(GroundFrame frame)
Sends the information gathered by the GroundViewer to the client. |
void |
setMap(GameMap map,
int x,
int y)
Sets the map for the camera. |
void |
setShowingSpells(boolean show)
Turns the display of spells on or off in the Ground View. |
void |
setViewRect(Rectangle r)
Resets the view rectangle; dumps the saved-object list. |
void |
setViewSize(int w,
int h)
Changes the view size; dumps the saved-object list. |
boolean |
showingSpells()
Returns true if we're displaying spells in the ground view. |
protected int |
tryAdd(java.util.List objects,
GroundFrame frame)
The new list has one more item than the previous list. |
protected int |
tryModify(java.util.List objects,
GroundFrame frame)
Looks to see if exactly one item was modified since the last send. |
protected int |
tryRemove(java.util.List objects,
GroundFrame frame)
The new list has one less item than the previous list. |
boolean |
updateClient(DisplayPolicy frame)
Sends the current set of map changes to the client. |
boolean |
updateGroundDisplay(GroundFrame frame)
Shows what's beneath the player. |
void |
validate(MapDirtyRegions changes)
CameraManager tells camera to update itself. |
Methods inherited from class wyvern.kernel.maps.AbstractCamera |
forceInvalidate, getCenter, getFrame, getMap, getOwner, getPosition, getViewRect, getViewSize, hasBeenMoved, invalidate, invalidateNoRayCast, isHandheld, isInvalid, isShutDown, markReady, markValid, moveFrame, setHandheld, setMap, setMoved, setPosition, shutDown, toString, tryUpdate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.List lastFrame_
Constructor Detail |
public GroundCamera(RemoteClient client, Player player) throws java.lang.Exception
Method Detail |
public void validate(MapDirtyRegions changes)
validate
in interface Camera
validate
in class AbstractCamera
public boolean changesNotVisible(MapDirtyRegions changes)
public boolean updateClient(DisplayPolicy frame)
updateClient
in class AbstractCamera
frame
- the frame to gather the data
public DisplayPolicy makeFrame()
public boolean updateGroundDisplay(GroundFrame frame) throws java.lang.Exception
frame
- the frame this camera has opted to use
java.lang.Exception
public boolean sendInfo(GroundFrame frame) throws java.lang.Exception
frame
- the frame we're using
java.lang.Exception
protected void resendAll(GroundFrame frame) throws java.lang.Exception
frame
- the new frame
java.lang.Exception
protected int examineChanges(GroundFrame frame) throws java.lang.Exception
If exactly one item has changed, we just resend that one, and we do it from this method (actually from a helper that knows how to add, remove, or modify an item in the list). This situation happens whenever someone drops something or picks it up, so it greatly increases the refresh speed for buying, selling, repairing, and so on, particularly on handheld devices.
frame
- the GroundFrame to send
java.lang.Exception
protected int tryModify(java.util.List objects, GroundFrame frame) throws java.lang.Exception
objects
- the new list of GroundObjDescriptors in the frame
java.lang.Exception
protected void modify(GroundFrame frame, int index) throws java.lang.Exception
frame
- the frame containing the new objects in the windowindex
- the index of the item to resend
java.lang.Exception
protected int tryAdd(java.util.List objects, GroundFrame frame) throws java.lang.Exception
objects
- the new list of GroundObjDescriptors in the frame
java.lang.Exception
protected void add(GroundFrame frame, int index) throws java.lang.Exception
frame
- the new frameindex
- the index at which to add the item
java.lang.Exception
protected int tryRemove(java.util.List objects, GroundFrame frame) throws java.lang.Exception
objects
- the new list of GroundObjDescriptors in the frame
java.lang.Exception
public void sendEmptyList() throws java.lang.Exception
java.lang.Exception
public void setMap(GameMap map, int x, int y)
setMap
in interface Camera
setMap
in class AbstractCamera
public void move(int xoffset, int yoffset)
move
in interface Camera
move
in class AbstractCamera
xoffset
- the map x offset to move byyoffset
- the map y offset to move bypublic void setViewRect(Rectangle r)
setViewRect
in interface Camera
setViewRect
in class AbstractCamera
r
- the view rectanglepublic void setViewSize(int w, int h)
setViewSize
in interface Camera
setViewSize
in class AbstractCamera
w
- new widthh
- new heightpublic java.util.List getLastFrame()
public void clearLastFrame()
public void setShowingSpells(boolean show)
show
- to show spells in the view.public boolean showingSpells()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |