com.blackledge.david.tivo.solitaire
Class TivoSolitaireMulti

java.lang.Object
  extended by com.tivo.hme.sdk.HmeObject
      extended by com.tivo.hme.sdk.Resource
          extended by com.tivo.hme.sdk.StreamResource
              extended by com.tivo.hme.sdk.Application
                  extended by com.tivo.hme.bananas.BApplication
                      extended by com.blackledge.david.tivo.multitasker.MultiTaskerApplication
                          extended by com.blackledge.david.tivo.solitaire.TivoSolitaireMulti
All Implemented Interfaces:
LocalOptionProvider, com.tivo.hme.bananas.IBananas, com.tivo.hme.interfaces.IApplication, com.tivo.hme.sdk.IHmeEventHandler, com.tivo.hme.sdk.IHmeProtocol
Direct Known Subclasses:
TivoFreeCellMulti

public class TivoSolitaireMulti
extends MultiTaskerApplication

Applies a TiVo interface to SolitaireGame

Version:
$Revision: 1.2 $
Author:
David Blackledge

Nested Class Summary
 
Nested classes/interfaces inherited from class com.blackledge.david.tivo.multitasker.MultiTaskerApplication
MultiTaskerApplication.CallbackChain, MultiTaskerApplication.ICallback
 
Nested classes/interfaces inherited from class com.tivo.hme.sdk.Resource
com.tivo.hme.sdk.Resource.FontResource
 
Field Summary
protected  List cardsInCursorView
          list of cards included in handCardViews
protected  HashMap cardViews
           
protected static int FIRST_ROW_Y
           
protected  com.tivo.hme.bananas.BView[] goalPlaceHolder
           
protected static String GUIDE_FONT
           
static String OPTION_CARD_BACK_IMAGE
           
static String OPTION_CARD_CLUB_IMAGE
           
static String OPTION_CARD_DIAMOND_IMAGE
           
static String OPTION_CARD_HEART_IMAGE
           
static String OPTION_CARD_SPADE_IMAGE
           
protected  com.tivo.hme.bananas.BView[] playPlaceHolder
           
static String TITLE
           
 
Fields inherited from class com.blackledge.david.tivo.multitasker.MultiTaskerApplication
LIMIT_TEXT_RENDER_HEIGHT, LIMIT_TEXT_RENDER_WIDTH, OPTION_AUDIO_CLASS, OPTION_AUDIO_HANDLE_CONTROLS, OPTION_AUDIO_HANDLE_CONTROLS_NEXT, OPTION_AUDIO_HANDLE_CONTROLS_PAUSE, OPTION_AUDIO_ON, OPTION_AUDIO_RANDOM, OPTION_AUDIO_STATUS_SHOW, OPTION_BACKGROUND_IMAGE_CLASS, OPTION_BACKGROUND_IMAGE_DELAY, OPTION_BACKGROUND_IMAGE_HANDLE_CONTROLS, OPTION_BACKGROUND_IMAGE_HANDLE_CONTROLS_NEXT, OPTION_BACKGROUND_IMAGE_HANDLE_CONTROLS_PAUSE, OPTION_BACKGROUND_IMAGE_HANDLE_CONTROLS_PUPD, OPTION_BACKGROUND_IMAGE_HISTORY, OPTION_BACKGROUND_IMAGE_ON, OPTION_BACKGROUND_IMAGE_PLANE, OPTION_BACKGROUND_IMAGE_RANDOM, OPTION_BACKGROUND_IMAGE_SIZE, OPTION_BACKGROUND_IMAGE_TRANSITION, OPTION_BACKGROUND_IMAGE_TRANSITION_DELAY, OPTION_BRAND_CLASS, OPTION_BRAND_HEIGHT, OPTION_BRAND_ON, OPTION_BRAND_TIME, OPTION_BRAND_TRANSITION_TIME, OPTION_BRAND_TRANSPARENCY, OPTION_BRAND_WIDTH, OPTION_HANDLE_CONTROLS_CLEAR, OPTION_IDLE, OPTION_LOCAL_FILE_ROOT, OPTION_MEDIA_KEY, OPTION_TICKER_TAPE_BACKGROUND, OPTION_TICKER_TAPE_CLASS, OPTION_TICKER_TAPE_FONT_FAMILY, OPTION_TICKER_TAPE_FOREGROUND, OPTION_TICKER_TAPE_HANDLE_CONTROLS, OPTION_TICKER_TAPE_HANDLE_CONTROLS_NEXT, OPTION_TICKER_TAPE_HANDLE_CONTROLS_PAUSE, OPTION_TICKER_TAPE_HANDLE_CONTROLS_RWFF, OPTION_TICKER_TAPE_HEADING, OPTION_TICKER_TAPE_HEIGHT, OPTION_TICKER_TAPE_ON, OPTION_TICKER_TAPE_RANDOM, OPTION_TICKER_TAPE_TIME, OPTION_TICKER_TAPE_TRANSPARENCY, OPTION_ZIP_CODE, RSRC_STATUS_BUFFER_OVERFLOW, RSRC_STATUS_END
 
Fields inherited from class com.tivo.hme.bananas.BApplication
FADE_ANIM, SLIDE_ANIM
 
Fields inherited from class com.tivo.hme.sdk.Resource
EVT_RSRC_STATUS, status
 
Fields inherited from interface com.blackledge.david.tivo.multitasker.LocalOptionProvider
TYPE_BOOLEAN, TYPE_CLASS, TYPE_COLOR, TYPE_FILE, TYPE_FLOAT, TYPE_FOLDER, TYPE_IMAGE, TYPE_INTEGER, TYPE_STRING, TYPE_URL
 
Fields inherited from interface com.tivo.hme.bananas.IBananas
A_ANCHOR_MASK, A_BOTTOM, A_CENTER, A_DELTA_MASK, A_LEFT, A_NEGATIVE_MASK, A_RIGHT, A_TOP, ARROW_NAMES, BAR_DEFAULT, BAR_HANG, BEVT_ACTION, BEVT_FOCUS, BEVT_SCREEN_ENTER, BEVT_SCREEN_EXIT, H_BAR, H_DOWN, H_KEYBOARD, H_LEFT, H_PAGEDOWN, H_PAGEUP, H_RIGHT, H_UP, H_VIS_FALSE, H_VIS_FOCUS, H_VIS_TRUE, TRANSITION_FADE, TRANSITION_LEFT, TRANSITION_NONE
 
Fields inherited from interface com.tivo.hme.sdk.IHmeProtocol
APP_ERROR_BAD_ARGUMENT, APP_ERROR_BAD_COMMAND, APP_ERROR_OTHER, APP_ERROR_OUT_OF_MEMORY, APP_ERROR_RSRC_NOT_FOUND, APP_ERROR_UNKNOWN, APP_ERROR_VIEW_NOT_FOUND, CMD_RECEIVER_ACKNOWLEDGE_IDLE, CMD_RECEIVER_TRANSITION, CMD_RESERVED, CMD_RSRC_ADD_ANIM, CMD_RSRC_ADD_COLOR, CMD_RSRC_ADD_FONT, CMD_RSRC_ADD_IMAGE, CMD_RSRC_ADD_SOUND, CMD_RSRC_ADD_STREAM, CMD_RSRC_ADD_TEXT, CMD_RSRC_ADD_TTF, CMD_RSRC_CLOSE, CMD_RSRC_REMOVE, CMD_RSRC_SEND_EVENT, CMD_RSRC_SET_ACTIVE, CMD_RSRC_SET_POSITION, CMD_RSRC_SET_SPEED, CMD_VIEW_ADD, CMD_VIEW_REMOVE, CMD_VIEW_SET_BOUNDS, CMD_VIEW_SET_PAINTING, CMD_VIEW_SET_RESOURCE, CMD_VIEW_SET_SCALE, CMD_VIEW_SET_TRANSLATION, CMD_VIEW_SET_TRANSPARENCY, CMD_VIEW_SET_VISIBLE, EVT_APP_INFO, EVT_DEVICE_INFO, EVT_FONT_INFO, EVT_IDLE, EVT_INIT_INFO, EVT_KEY, EVT_RESERVED, EVT_RSRC_INFO, FONT_BOLD, FONT_BOLDITALIC, FONT_ITALIC, FONT_METRICS_BASIC, FONT_METRICS_GLYPH, FONT_PLAIN, ID_ALERT_SOUND, ID_BONK_SOUND, ID_CLIENT, ID_CLIENT_PRE_0_38, ID_DEFAULT_TTF, ID_DESELECT_SOUND, ID_ERROR_SOUND, ID_LEFT_SOUND, ID_NULL, ID_PAGEDOWN_SOUND, ID_PAGEUP_SOUND, ID_RESERVED, ID_RIGHT_SOUND, ID_ROOT_STREAM, ID_ROOT_VIEW, ID_SELECT_SOUND, ID_SLOWDOWN1_SOUND, ID_SPEEDUP1_SOUND, ID_SPEEDUP2_SOUND, ID_SPEEDUP3_SOUND, ID_SYSTEM_TTF, ID_THUMBSDOWN_SOUND, ID_THUMBSUP_SOUND, ID_TIVO_SOUND, ID_UPDOWN_SOUND, KEY_ADVANCE, KEY_CHANNELDOWN, KEY_CHANNELUP, KEY_CLEAR, KEY_DISPLAY, KEY_DOWN, KEY_ENTER, KEY_FORWARD, KEY_INFO, KEY_LEFT, KEY_LIVETV, KEY_MUTE, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_OPT_ANGLE, KEY_OPT_ASPECT, KEY_OPT_DVD, KEY_OPT_EXIT, KEY_OPT_GUIDE, KEY_OPT_LIST, KEY_OPT_MENU, KEY_OPT_PIP, KEY_OPT_STOP, KEY_OPT_TOP_MENU, KEY_OPT_WINDOW, KEY_PAUSE, KEY_PLAY, KEY_PRESS, KEY_RECORD, KEY_RELEASE, KEY_REPEAT, KEY_REPLAY, KEY_REVERSE, KEY_RIGHT, KEY_SELECT, KEY_SLOW, KEY_THUMBSDOWN, KEY_THUMBSUP, KEY_TIVO, KEY_UNKNOWN, KEY_UP, KEY_VOLUMEDOWN, KEY_VOLUMEUP, LIMIT_CMD_NBYTES, LIMIT_EVENT_NBYTES, LIMIT_FONT_POINT_SIZE, LIMIT_IMAGE_HEIGHT, LIMIT_IMAGE_NBYTES, LIMIT_IMAGE_WIDTH, LIMIT_SOUND_NBYTES, LIMIT_TEXT_NBYTES, LIMIT_URL_NBYTES, LIMIT_VIEW_DEPTH, MAGIC, RSRC_ERROR_BAD_ARGUMENT, RSRC_ERROR_BAD_DATA, RSRC_ERROR_BAD_MAGIC, RSRC_ERROR_BAD_STATE, RSRC_ERROR_BAD_VERSION, RSRC_ERROR_CONNECT_FAILED, RSRC_ERROR_CONNECTION_LOST, RSRC_ERROR_CONNECTION_TIMEOUT, RSRC_ERROR_HOST_NOT_FOUND, RSRC_ERROR_INCOMPATIBLE, RSRC_ERROR_NOT_SUPPORTED, RSRC_ERROR_OTHER, RSRC_ERROR_UNKNOWN, RSRC_HALIGN_CENTER, RSRC_HALIGN_LEFT, RSRC_HALIGN_MASK, RSRC_HALIGN_RIGHT, RSRC_IMAGE_BESTFIT, RSRC_IMAGE_HFIT, RSRC_IMAGE_MASK, RSRC_IMAGE_VFIT, RSRC_STATUS_CLOSED, RSRC_STATUS_COMPLETE, RSRC_STATUS_CONNECTED, RSRC_STATUS_CONNECTING, RSRC_STATUS_ERROR, RSRC_STATUS_LOADING, RSRC_STATUS_PAUSED, RSRC_STATUS_PLAYING, RSRC_STATUS_READY, RSRC_STATUS_SEEKING, RSRC_STATUS_UNKNOWN, RSRC_TEXT_MASK, RSRC_TEXT_WRAP, RSRC_VALIGN_BOTTOM, RSRC_VALIGN_CENTER, RSRC_VALIGN_MASK, RSRC_VALIGN_TOP, SAFE_ACTION_H, SAFE_ACTION_V, SAFE_TITLE_H, SAFE_TITLE_V, TRANSITION_BACK, TRANSITION_FORWARD, TRANSITION_TELEPORT, VERSION, VERSION_0_38, VERSION_0_40, VERSION_MAJOR, VERSION_MINOR, VERSION_STRING
 
Constructor Summary
TivoSolitaireMulti()
           
 
Method Summary
protected  boolean afterLayout()
          Whatever you might have to do after layout of a completed move e.g.
protected  boolean bestFit(com.tivo.hme.bananas.BView view)
           
protected  boolean bestFitGetACardFirstRow(com.tivo.hme.bananas.BView view)
           
protected  boolean canAutoWin()
           
protected  void checkWon()
           
protected  void finishAutoWin()
           
protected  void firstRowSelectAction(com.tivo.hme.bananas.BView view)
           
protected  boolean gameActionGoalStack(int goalStackNum)
           
protected  boolean gameActionPlayStack(int i, int j)
           
protected  CardStack gameHandStack()
           
protected  void gameInitNewGame()
           
protected  void gameNewGame()
          game.newGame() and focus on right place.
protected  boolean gamePlayHand()
           
protected  CardStack[] gamePlayStack()
           
protected  boolean gameUndo()
           
protected  boolean gameWonInternal()
           
protected  int getCardHeight()
           
protected  int getCardWidth()
           
protected  int getCursorBorder()
           
protected  com.tivo.hme.bananas.BView getCursorViewAndFocus(com.tivo.hme.bananas.BView cardParent)
           
protected  int getCursorWidth()
           
protected  String getGameTitle()
           
 Map getLocalOptionPreferences()
          LocalOptionProvider default implementation - returns null(?an empty map).
 String getOptionDefault(String key)
          MultiTaskerApplication hard-coded options.
 String getOptionOverride(String key)
          Override this method to override options with no ability for the user to change them for your app.
protected  com.tivo.hme.bananas.BView getViewOfPlayStackToFocus(CardStack[] gameStack, CardStack playStack)
           
protected  int goalStackNumToX(int j)
           
 boolean handleAction(com.tivo.hme.bananas.BView view, Object action)
           
 boolean handleKeyPress(int code, long rawcode)
           
 boolean handleKeyRelease(int code, long rawcode)
           
 boolean handleKeyRepeat(int code, long rawcode)
           
protected  void helpScreen()
           
 void init(com.tivo.hme.interfaces.IContext context)
          Make sure you call super.init(context) if you override this method.
protected  void layoutCards()
           
protected  void layoutGoalStacks(com.tivo.hme.sdk.Resource cardMoveAnimation, CardStack[] goalStacks)
           
protected  void layoutPlayStacks(com.tivo.hme.sdk.Resource cardMoveAnimation, CardStack[] playStacks)
           
protected  com.tivo.hme.bananas.BView makeGoalPlaceHolder(com.tivo.hme.bananas.BView cardParent, int x, int y)
           
protected  com.tivo.hme.bananas.BView makePlaceHolder(com.tivo.hme.bananas.BView cardParent, int x, int y)
           
protected  CardDeck newGameDeck()
           
protected  int playStackNumToX(int j)
           
protected  int playStackPositionToY(com.tivo.hme.sdk.View cardParent, int i)
          0 is BOTTOM card here.
protected  void setUpPlaceholders()
           
protected  void updateCursor()
           
protected  int viewXToGoalStackNum(int x)
           
protected  int viewXToPlayStackNum(int x)
           
 
Methods inherited from class com.blackledge.david.tivo.multitasker.MultiTaskerApplication
addCallback, cancelCallback, createImageStream, createStream, destroy, fixPoorUrl, getAppFactory, getAudioView, getBackgroundView, getBooleanOption, getBooleanOption, getBrandView, getColorOption, getColorOption, getCurrentAudioStream, getCurrentImage, getFloatOption, getFloatOption, getHostAddress, getIntegerOption, getIntegerOption, getLocalOptionDefault, getLocalOptionNames, getLocalRoot, getOption, getOption, getOptionSetting, getScaledImageByHeight, getScaledImageByWidth, getTickerView, getUrlContent, handleApplicationError, handleEvent, handleIdle, handleMultiStreamSource, handleRedirect, hideAudio, hideBackgroundImage, hideBrand, hideTickerTape, openMultiTaskerMenu, parseQuery, postEvent, showAudio, showBackgroundImage, showBrand, showTickerTape, silenceAudio, toggleAudio, toggleBackgroundImage, toggleBrand, toggleTickerTape, validUrl
 
Methods inherited from class com.tivo.hme.bananas.BApplication
dispatchEvent, dispatchKeyEvent, getAbove, getBelow, getCurrentScreen, getNormal, getSkin, getStackDepth, play, playSoundForKey, pop, pop, push, push, setSkin
 
Methods inherited from class com.tivo.hme.sdk.Application
acknowledgeIdle, close, flush, getContext, getFactory, getFocus, getHeight, getResource, getResources, getRoot, getStream, getWidth, handleActive, handleApplicationError, handleChunk, handlePing, isAChunk, isApplicationClosing, log, open, setContext, setFactory, setFocus, transitionBack, transitionForward
 
Methods inherited from class com.tivo.hme.sdk.StreamResource
getContentType, getSpeed, getStatus, getURI, isPaused, pause, play, setPosition, setSpeed, toString
 
Methods inherited from class com.tivo.hme.sdk.Resource
addHandler, dump, finalize, remove, removeHandler, sendEvent, sendEvent, setActive
 
Methods inherited from class com.tivo.hme.sdk.HmeObject
createAnimation, createAnimation, createColor, createFont, createFont, createImage, createImage, createImage, createImage, createSound, createSound, createSound, createStream, createStream, createText, createTrueType, getApp, getID, rsrcFlagsToString, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TITLE

public static final String TITLE
See Also:
Constant Field Values

OPTION_CARD_BACK_IMAGE

public static final String OPTION_CARD_BACK_IMAGE
See Also:
Constant Field Values

OPTION_CARD_DIAMOND_IMAGE

public static final String OPTION_CARD_DIAMOND_IMAGE
See Also:
Constant Field Values

OPTION_CARD_SPADE_IMAGE

public static final String OPTION_CARD_SPADE_IMAGE
See Also:
Constant Field Values

OPTION_CARD_CLUB_IMAGE

public static final String OPTION_CARD_CLUB_IMAGE
See Also:
Constant Field Values

OPTION_CARD_HEART_IMAGE

public static final String OPTION_CARD_HEART_IMAGE
See Also:
Constant Field Values

FIRST_ROW_Y

protected static final int FIRST_ROW_Y
See Also:
Constant Field Values

GUIDE_FONT

protected static final String GUIDE_FONT
See Also:
Constant Field Values

cardViews

protected final HashMap cardViews

cardsInCursorView

protected final List cardsInCursorView
list of cards included in handCardViews


playPlaceHolder

protected com.tivo.hme.bananas.BView[] playPlaceHolder

goalPlaceHolder

protected com.tivo.hme.bananas.BView[] goalPlaceHolder
Constructor Detail

TivoSolitaireMulti

public TivoSolitaireMulti()
Method Detail

getOptionDefault

public String getOptionDefault(String key)
MultiTaskerApplication hard-coded options. Override this method to provide your own default values for some options (return super implementation for things you're not providing a default for) (public just so preferences screen can use it). By default, just returns what MultiTaskerApplication.getLocalOptionDefault(String) returns.

Overrides:
getOptionDefault in class MultiTaskerApplication
Returns:
See Also:
MultiTaskerApplication.getOption(java.lang.String)

getOptionOverride

public String getOptionOverride(String key)
Description copied from class: MultiTaskerApplication
Override this method to override options with no ability for the user to change them for your app. (public just so preferences screen can use it)

Overrides:
getOptionOverride in class MultiTaskerApplication
Returns:
the override value for this key. null if there is no override for this key.

getLocalOptionPreferences

public Map getLocalOptionPreferences()
Description copied from class: MultiTaskerApplication
LocalOptionProvider default implementation - returns null(?an empty map). Override to provide Option Preferences settings for your Application's local options.

Specified by:
getLocalOptionPreferences in interface LocalOptionProvider
Overrides:
getLocalOptionPreferences in class MultiTaskerApplication
Returns:
null(?empty map).

init

public void init(com.tivo.hme.interfaces.IContext context)
          throws Exception
Description copied from class: MultiTaskerApplication
Make sure you call super.init(context) if you override this method.

Overrides:
init in class MultiTaskerApplication
Throws:
Exception
See Also:
BApplication.init(com.tivo.hme.interfaces.IContext)

getGameTitle

protected String getGameTitle()

handleAction

public boolean handleAction(com.tivo.hme.bananas.BView view,
                            Object action)
Overrides:
handleAction in class com.tivo.hme.bananas.BApplication

afterLayout

protected boolean afterLayout()
Whatever you might have to do after layout of a completed move e.g. in FreeCell, it's time to play all the obvious moves automatically.

Returns:
true if something was changed.

getCursorViewAndFocus

protected com.tivo.hme.bananas.BView getCursorViewAndFocus(com.tivo.hme.bananas.BView cardParent)

getCardHeight

protected int getCardHeight()

getCardWidth

protected int getCardWidth()

getCursorWidth

protected int getCursorWidth()

getCursorBorder

protected int getCursorBorder()

newGameDeck

protected CardDeck newGameDeck()

gameNewGame

protected void gameNewGame()
game.newGame() and focus on right place.


gameInitNewGame

protected void gameInitNewGame()

setUpPlaceholders

protected void setUpPlaceholders()

makePlaceHolder

protected final com.tivo.hme.bananas.BView makePlaceHolder(com.tivo.hme.bananas.BView cardParent,
                                                           int x,
                                                           int y)

makeGoalPlaceHolder

protected final com.tivo.hme.bananas.BView makeGoalPlaceHolder(com.tivo.hme.bananas.BView cardParent,
                                                               int x,
                                                               int y)

layoutCards

protected void layoutCards()

layoutGoalStacks

protected final void layoutGoalStacks(com.tivo.hme.sdk.Resource cardMoveAnimation,
                                      CardStack[] goalStacks)

layoutPlayStacks

protected final void layoutPlayStacks(com.tivo.hme.sdk.Resource cardMoveAnimation,
                                      CardStack[] playStacks)

gameHandStack

protected CardStack gameHandStack()

updateCursor

protected final void updateCursor()

playStackPositionToY

protected final int playStackPositionToY(com.tivo.hme.sdk.View cardParent,
                                         int i)
0 is BOTTOM card here.

Parameters:
cardParent -
i -
Returns:

playStackNumToX

protected int playStackNumToX(int j)

viewXToPlayStackNum

protected int viewXToPlayStackNum(int x)

goalStackNumToX

protected int goalStackNumToX(int j)

viewXToGoalStackNum

protected int viewXToGoalStackNum(int x)

handleKeyPress

public boolean handleKeyPress(int code,
                              long rawcode)
Overrides:
handleKeyPress in class com.tivo.hme.sdk.HmeObject

gameUndo

protected boolean gameUndo()

gameWonInternal

protected boolean gameWonInternal()

handleKeyRelease

public boolean handleKeyRelease(int code,
                                long rawcode)
Overrides:
handleKeyRelease in class com.tivo.hme.sdk.HmeObject

handleKeyRepeat

public boolean handleKeyRepeat(int code,
                               long rawcode)
Overrides:
handleKeyRepeat in class com.tivo.hme.sdk.HmeObject

helpScreen

protected void helpScreen()

checkWon

protected final void checkWon()

bestFit

protected final boolean bestFit(com.tivo.hme.bananas.BView view)

canAutoWin

protected boolean canAutoWin()

finishAutoWin

protected final void finishAutoWin()

gamePlayHand

protected boolean gamePlayHand()

gameActionPlayStack

protected boolean gameActionPlayStack(int i,
                                      int j)

gamePlayStack

protected CardStack[] gamePlayStack()

bestFitGetACardFirstRow

protected boolean bestFitGetACardFirstRow(com.tivo.hme.bananas.BView view)

firstRowSelectAction

protected void firstRowSelectAction(com.tivo.hme.bananas.BView view)

gameActionGoalStack

protected boolean gameActionGoalStack(int goalStackNum)

getViewOfPlayStackToFocus

protected com.tivo.hme.bananas.BView getViewOfPlayStackToFocus(CardStack[] gameStack,
                                                               CardStack playStack)