Class UnboundedViewport<T>
Class like Viewport<T>, however the view area is in no way bounded to the edges of the underlying map. Instead, if you access a position that cannot map to any valid position in the underlying map view, a (specified) default value is returned.
Inheritance
Implements
Inherited Members
Namespace: GoRogue.MapViews
Assembly: GoRogue.dll
Syntax
public class UnboundedViewport<T> : IMapView<T>
Type Parameters
Name | Description |
---|---|
T | The type being exposed by the UnboundedViewport. |
Constructors
| Improve this Doc View SourceUnboundedViewport(IMapView<T>, T)
Constructor. Takes the map view to represent. The viewport will represent the entire given map view.
Declaration
public UnboundedViewport(IMapView<T> mapView, T defaultValue = null)
Parameters
Type | Name | Description |
---|---|---|
IMapView<T> | mapView | The map view to represent. |
T | defaultValue | The value to return if a position is accessed that is outside the actual underlying map view. |
UnboundedViewport(IMapView<T>, Rectangle, T)
Constructor. Takes the parent map view, and the initial subsection of that map view to represent.
Declaration
public UnboundedViewport(IMapView<T> mapView, Rectangle viewArea, T defaultValue = null)
Parameters
Type | Name | Description |
---|---|---|
IMapView<T> | mapView | The map view being represented. |
Rectangle | viewArea | The initial subsection of that map to represent. |
T | defaultValue | The value to return if a position is accessed that is outside the actual underlying map view. |
Fields
| Improve this Doc View SourceDefaultValue
The value to return if a position is accessed that is outside the actual underlying map view.
Declaration
public readonly T DefaultValue
Field Value
Type | Description |
---|---|
T |
Properties
| Improve this Doc View SourceHeight
The height of the area being represented.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Coord]
Given a position in relative coordinates, returns the "value" associated with that location in absolute coordinates.
Declaration
public virtual T this[Coord relativePosition] { get; }
Parameters
Type | Name | Description |
---|---|---|
Coord | relativePosition | Viewport-relative position of the location to retrieve the value for. |
Property Value
Type | Description |
---|---|
T | The "value" associated with the absolute location represented on the underlying map view, or DefaultValue if the absolute position does not exist in the underlying map view. |
Item[Int32]
Given a position in relative 1d-array-index style, returns the "value" associated with that location in absolute coordinates.
Declaration
public T this[int relativeIndex1D] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | relativeIndex1D | Viewport-relative position of the location to retrieve the value for, as a 1D array index. |
Property Value
Type | Description |
---|---|
T | The "value" associated with the absolute location represented on the underlying map view, or DefaultValue if the absolute position does not exist in the underlying map view. |
Item[Int32, Int32]
Given an X and Y value in relative coordinates, returns the "value" associated with that location in absolute coordinates.
Declaration
public virtual T this[int relativeX, int relativeY] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | relativeX | Viewport-relative X-value of location. |
System.Int32 | relativeY | Viewport-relative Y-value of location. |
Property Value
Type | Description |
---|---|
T | The "value" associated with the absolute location represented on the underlying map view, or DefaultValue if the absolute position does not exist in the underlying map view. |
MapView
The map view that this UnboundedViewport is exposing values from.
Declaration
public IMapView<T> MapView { get; }
Property Value
Type | Description |
---|---|
IMapView<T> |
ViewArea
The area of the base MapView that this Viewport is exposing. Although this property does not explicitly expose a set accessor, it is returning a reference and as such may be assigned to. This viewport is NOT bounded to base map edges -- for this functionality, see the Viewport<T> class.
Declaration
public Rectangle ViewArea { get; }
Property Value
Type | Description |
---|---|
Rectangle |
Width
The height of the area being represented.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceToString()
Returns a string representation of the UnboundedViewport.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation of the UnboundedViewport. |
Overrides
ToString(Func<T, String>)
Returns a string representation of the map view, using elementStringifier
to determine what string represents each value.
Declaration
public string ToString(Func<T, string> elementStringifier)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.String> | elementStringifier | Function determining the string representation of each element. |
Returns
Type | Description |
---|---|
System.String | A string representation of the UnboundedViewport. |
Remarks
This could be used, for example, on an UnboundedViewport of boolean values, to output '#' for false values, and '.' for true values.
ToString(Int32, Func<T, String>)
Prints the values in the UnboundedViewport, using the function specified to turn elements into strings, and using the "field length" specified.
Declaration
public string ToString(int fieldSize, Func<T, string> elementStringifier = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fieldSize | The size of the field to give each value. A positive-number right-aligns the text within the field, while a negative number left-aligns the text. |
System.Func<T, System.String> | elementStringifier | Function to use to convert each element to a string. null defaults to the ToString function of type T. |
Returns
Type | Description |
---|---|
System.String | A string representation of the UnboundedViewport. |
Remarks
Each element of type T will have spaces added to cause it to take up exactly
fieldSize
characters, provided fieldSize
is less than the length of the element's string represention.