Package ca.cgjennings.apps.arkham.diy
Class VerbalDesignSupportAdapter
- java.lang.Object
-
- ca.cgjennings.apps.arkham.component.design.AbstractVerbalDesignSupport<GameComponent>
-
- ca.cgjennings.apps.arkham.diy.VerbalDesignSupportAdapter
-
- All Implemented Interfaces:
DesignSupport<GameComponent>
public class VerbalDesignSupportAdapter extends AbstractVerbalDesignSupport<GameComponent>
This class is an adapter for creatingAbstractVerbalDesignSupport
s for DIY components. Instead of having to create a subclass that calls a super constructor with arguments, you simply provide a function that does the work ofAbstractVerbalDesignSupport.analyze(ca.cgjennings.apps.arkham.component.GameComponent, java.lang.StringBuilder)
.To add verbal design support to a component, create an instance of this class supplied your design analysis function and use the editor's
AbstractGameComponentEditor.setDesignSupport(ca.cgjennings.apps.arkham.component.design.DesignSupport<G>)
method to install it in the editor:function designAnalyzer( diy, sb ) { sb.append( 'support text: ' + diy.fullName ); return true; } ... function createInterface( diy, editor ) { ... editor.designSupport = new VerbalDesignSupportAdapter( diy, designAnalyzer ); }
- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
VerbalDesignSupportAdapter.DesignAnalyzer
An interface that represents the script function passed to the adapter.
-
Constructor Summary
Constructors Constructor Description VerbalDesignSupportAdapter(GameComponent gc, VerbalDesignSupportAdapter.DesignAnalyzer scriptFunction)
Creates a new adapter that consults with the specified analyzer function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
analyze(GameComponent gc, java.lang.StringBuilder b)
This method is called when the design needs to reanalyzed.-
Methods inherited from class ca.cgjennings.apps.arkham.component.design.AbstractVerbalDesignSupport
createSupportView, getGameComponent, getReport, isDesignValid, markChanged, updateSupportView
-
-
-
-
Constructor Detail
-
VerbalDesignSupportAdapter
public VerbalDesignSupportAdapter(GameComponent gc, VerbalDesignSupportAdapter.DesignAnalyzer scriptFunction)
Creates a new adapter that consults with the specified analyzer function.- Parameters:
gc
- the component to analyzescriptFunction
- the script function that will handle the analysis
-
-
Method Detail
-
analyze
protected boolean analyze(GameComponent gc, java.lang.StringBuilder b)
This method is called when the design needs to reanalyzed. It creates the new report by appending text to the provided string builder and returns a boolean value to indicate whether or not the design is valid.This subclass will defer the analysis to the
VerbalDesignSupportAdapter.DesignAnalyzer
passed to the constructor.- Specified by:
analyze
in classAbstractVerbalDesignSupport<GameComponent>
- Parameters:
gc
- the game component to analyze (same asAbstractVerbalDesignSupport.getGameComponent()
)b
- a string builder that must be used to build the verbal design report- Returns:
true
if the design is considered valid,false
otherwise
-
-