ch.sahits.game.graphic.display.gameplay
Class MainView

java.lang.Object
  extended by ch.sahits.game.rendering.AbstractRenderPart
      extended by ch.sahits.game.graphic.display.gameplay.MainView
All Implemented Interfaces:
IEventListener, IUpdatableDialog, Renderable, RenderablePart

public class MainView
extends AbstractRenderPart
implements IEventListener, IUpdatableDialog

This represents the main game screen

Author:
Andi Hotz, (c) Sahits GmbH, 2011 Created on Sep 30, 2011

Field Summary
private  CityPlayerProxy city
          Model of the city currently displayed.
private  OpenPatricianGameDialog dialog
           
private static String[] imageNames
           
private  IImageUtilities imageUtils
           
private  BufferedImage img
          This image holds the background of the currently rendered View
private  IImageLoader loader
           
private static org.apache.log4j.Logger logger
           
private  EScene viewState
          Use low level byte to indicate what is displayed instead of an enum.
private  IDataImageLoader xmlLoader
           
 
Fields inherited from class ch.sahits.game.rendering.AbstractRenderPart
rect
 
Constructor Summary
MainView(Rectangle rect, IImageLoader loader, IClient cl)
          Instantiate the main view with the port scene of the players home town
 
Method Summary
private  boolean canDelegateToSceneHandler(Event e, Object eventNotice)
          Check if the event can be delegated to the scene handler.
 void gameRender(Graphics gScr)
           
 void gameUpdate(Event e, Object eventNotice)
           
 BufferedImage getDialogFringe()
          Retrieve the fringe of the dialog
private  void handleDialogChange(ENoticeItem noticeItem)
          Update the dialog according to the indicated selection
private  void handleViewChange(EScene newScene)
          Hanlde method for changing the main view image
private  boolean isDialogChange(Event e, Object eventNotice)
          Check if this as a view change due to selecting something on the notice board
private  void replaceImage(String imgName, Dimension targetDim)
          Scale an image down to target dimension and replace it in the loader cache
private  void resetDialog()
          Scale the dialog so it has the correct proportions
 void updateDialog(OpenPatricianGameDialog dialog)
          Pass the dialog with that should be updated
 
Methods inherited from class ch.sahits.game.rendering.AbstractRenderPart
getBounds, isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.log4j.Logger logger

img

private BufferedImage img
This image holds the background of the currently rendered View


dialog

private OpenPatricianGameDialog dialog

imageNames

private static final String[] imageNames

viewState

private EScene viewState
Use low level byte to indicate what is displayed instead of an enum.


city

private CityPlayerProxy city
Model of the city currently displayed. May be null if no city is displayed


imageUtils

private final IImageUtilities imageUtils

xmlLoader

private final IDataImageLoader xmlLoader

loader

private final IImageLoader loader
Constructor Detail

MainView

public MainView(Rectangle rect,
                IImageLoader loader,
                IClient cl)
Instantiate the main view with the port scene of the players home town

Parameters:
rect -
loader -
cl -
Method Detail

resetDialog

private void resetDialog()
Scale the dialog so it has the correct proportions


replaceImage

private void replaceImage(String imgName,
                          Dimension targetDim)
Scale an image down to target dimension and replace it in the loader cache

Parameters:
imgName -
targetDim -

gameRender

public void gameRender(Graphics gScr)
Specified by:
gameRender in interface Renderable

gameUpdate

public void gameUpdate(Event e,
                       Object eventNotice)
Specified by:
gameUpdate in interface IEventListener
Specified by:
gameUpdate in interface Renderable

handleDialogChange

private void handleDialogChange(ENoticeItem noticeItem)
Update the dialog according to the indicated selection

Parameters:
noticeItem -

isDialogChange

private boolean isDialogChange(Event e,
                               Object eventNotice)
Check if this as a view change due to selecting something on the notice board

Parameters:
e -
eventNotice -
Returns:

canDelegateToSceneHandler

private boolean canDelegateToSceneHandler(Event e,
                                          Object eventNotice)
Check if the event can be delegated to the scene handler. If there is a dialog active and the event does not concerne the closing of the dialog, the event is not propagated

Parameters:
e -
eventNotice -
Returns:

handleViewChange

private void handleViewChange(EScene newScene)
Hanlde method for changing the main view image

Parameters:
newScene -

updateDialog

public void updateDialog(OpenPatricianGameDialog dialog)
Pass the dialog with that should be updated Replace the internal dialog with the passed dialog

Specified by:
updateDialog in interface IUpdatableDialog

getDialogFringe

public BufferedImage getDialogFringe()
Description copied from interface: IUpdatableDialog
Retrieve the fringe of the dialog

Specified by:
getDialogFringe in interface IUpdatableDialog
Returns:


Copyright © 2011-2012 Sahits GmbH. All Rights Reserved.