ch.sahits.game.graphic.display.start
Class NewGameView

java.lang.Object
  extended by ch.sahits.game.rendering.AbstractRenderPart
      extended by ch.sahits.game.graphic.display.OpenPatricianBackgroundView
          extended by ch.sahits.game.graphic.display.start.NewGameView
All Implemented Interfaces:
ch.sahits.game.event.IEventListener, ISahitsContainer, ch.sahits.game.rendering.Renderable, ch.sahits.game.rendering.RenderablePart

public class NewGameView
extends OpenPatricianBackgroundView
implements ISahitsContainer

Rendering view to create a new single player game. This view encompasses the whole screen with a red brick background.

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

Field Summary
private  ch.sahits.game.openpatrician.model.Difficulty difficulity
           
private  Slider difficulty
           
private  RadioButton female
           
private static ch.sahits.game.openpatrician.util.RandomNameLoader firstNameLoader
           
private  Font font
           
private  Spinner home
           
private  TextInput lastName
           
private static ch.sahits.game.openpatrician.util.RandomNameLoader lastNameLoader
           
private  RadioButton male
           
private  Spinner map
           
private  FontMetrics metic
           
private  TextInput name
           
private  Spinner objective
           
private  Slider speed
           
private  Spinner startYear
           
 
Fields inherited from class ch.sahits.game.rendering.AbstractRenderPart
rect
 
Constructor Summary
NewGameView(Rectangle rect, FontMetrics metric)
          Construct the view with the specified dimensions and the font metrics
 
Method Summary
private  Button addButton(String text)
          Create a button with the text label
private  TextInput addInput(String value)
          Create a TextInput field with an optional preset text
private  ISahitsComponent addLabel(String name)
          Creating a label.
private  RadioButton addRadioButton(String label, boolean selected, SelectableGroup group)
          Add a RadioButton to the view.
private  Slider addSlider(List<String> elements)
          Add a slider control to the component.
private  Spinner addSpinner(List<String> elements)
          Add a spinner control to the component.
private  void createComponents()
          Create the form element to specify the start settings of the new game
private  Runnable createStartButtonClickAction()
          Action to be called when the start button is hit.
private  List<String> getDificutlyList()
          Compile a list of the difficulty levels
private  List<String> getGameSpeedList()
          Compile a list of game speeds
private  List<String> getHomeTowns4Map()
          Create a list of town names that are available on the selected map as home towns.
private  List<String> getMapList()
          Retrieve the list of the available maps
private  List<String> getObjectiveList()
          Create a list of objectives to select from
private static String getRandomFirstName()
           
private static String getRandomLastName()
           
private  List<String> getStartYears()
          Initialize the list of start years from 1300 to 1400
 void setDifficulity(ch.sahits.game.openpatrician.model.Difficulty difficulity)
          Set the difficulty
private  void setFont(ISahitsComponent comp)
          Set the font on the component
private  boolean validInput()
          check if the input is valid and one may proceed.
 
Methods inherited from class ch.sahits.game.graphic.display.OpenPatricianBackgroundView
add, gameRender, gameUpdate, get, getComponentCount, getHeight, getInsets, getWidth
 
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
 
Methods inherited from interface ch.sahits.game.graphic.display.ISahitsContainer
add, get, getBounds, getComponentCount, getHeight, getInsets, getWidth
 

Field Detail

font

private Font font

metic

private FontMetrics metic

difficulity

private ch.sahits.game.openpatrician.model.Difficulty difficulity

firstNameLoader

private static ch.sahits.game.openpatrician.util.RandomNameLoader firstNameLoader

lastNameLoader

private static ch.sahits.game.openpatrician.util.RandomNameLoader lastNameLoader

name

private TextInput name

lastName

private TextInput lastName

male

private RadioButton male

female

private RadioButton female

map

private Spinner map

home

private Spinner home

startYear

private Spinner startYear

difficulty

private Slider difficulty

objective

private Spinner objective

speed

private Slider speed
Constructor Detail

NewGameView

public NewGameView(Rectangle rect,
                   FontMetrics metric)
Construct the view with the specified dimensions and the font metrics

Parameters:
rect -
metric -
Method Detail

createComponents

private void createComponents()
Create the form element to specify the start settings of the new game


createStartButtonClickAction

private Runnable createStartButtonClickAction()
Action to be called when the start button is hit.

Returns:

getObjectiveList

private List<String> getObjectiveList()
Create a list of objectives to select from

Returns:

getGameSpeedList

private List<String> getGameSpeedList()
Compile a list of game speeds

Returns:

getDificutlyList

private List<String> getDificutlyList()
Compile a list of the difficulty levels

Returns:

getStartYears

private List<String> getStartYears()
Initialize the list of start years from 1300 to 1400

Returns:

getHomeTowns4Map

private List<String> getHomeTowns4Map()
Create a list of town names that are available on the selected map as home towns.

Returns:

addRadioButton

private RadioButton addRadioButton(String label,
                                   boolean selected,
                                   SelectableGroup group)
Add a RadioButton to the view. There should only on radio button be defined, that is selected in the same group

Parameters:
label - of the radio button
selected - flag indicating if the button is currently selected.
group - the button belongs to
Returns:
created RadioButton

addInput

private TextInput addInput(String value)
Create a TextInput field with an optional preset text

Parameters:
value - optional text of the input field
Returns:
TextInput field

addLabel

private ISahitsComponent addLabel(String name)
Creating a label. The name may be null identifying the label a place holder

Parameters:
name -
Returns:

addSpinner

private Spinner addSpinner(List<String> elements)
Add a spinner control to the component. A spinner is similar to a drop down list in effect only that only the active element is displayed.

Parameters:
elements - List of elements in the spinner
Returns:

addSlider

private Slider addSlider(List<String> elements)
Add a slider control to the component. A slider uses a few values that are placed in a half circle above a steering wheel

Parameters:
elements - List of the selectable values. There should be only a few
Returns:

addButton

private Button addButton(String text)
Create a button with the text label

Parameters:
text - label of the button
Returns:

getMapList

private List<String> getMapList()
Retrieve the list of the available maps

Returns:

setFont

private void setFont(ISahitsComponent comp)
Set the font on the component

Parameters:
comp -

validInput

private boolean validInput()
check if the input is valid and one may proceed.

Returns:

setDifficulity

public void setDifficulity(ch.sahits.game.openpatrician.model.Difficulty difficulity)
Set the difficulty

Parameters:
difficulity -

getRandomFirstName

private static String getRandomFirstName()

getRandomLastName

private static String getRandomLastName()


Copyright © 2011 Sahits GmbH. All Rights Reserved.