|
@@ -121,78 +121,89 @@ DecoratorDataHandle DecoratorTiledBox::GenerateElementData(Element* element) con
|
|
|
|
|
|
|
|
Vector2f padded_size = element->GetBox().GetSize(Box::PADDING);
|
|
Vector2f padded_size = element->GetBox().GetSize(Box::PADDING);
|
|
|
|
|
|
|
|
- // Calculate the size for the top row of tiles.
|
|
|
|
|
- Vector2f top_left_dimensions = tiles[TOP_LEFT_CORNER].GetDimensions(element);
|
|
|
|
|
- Vector2f top_dimensions = tiles[TOP_EDGE].GetDimensions(element);
|
|
|
|
|
- Vector2f top_right_dimensions = tiles[TOP_RIGHT_CORNER].GetDimensions(element);
|
|
|
|
|
|
|
|
|
|
- // Calculate the size for the bottom row of tiles.
|
|
|
|
|
- Vector2f bottom_left_dimensions = tiles[BOTTOM_LEFT_CORNER].GetDimensions(element);
|
|
|
|
|
- Vector2f bottom_dimensions = tiles[BOTTOM_EDGE].GetDimensions(element);
|
|
|
|
|
- Vector2f bottom_right_dimensions = tiles[BOTTOM_RIGHT_CORNER].GetDimensions(element);
|
|
|
|
|
|
|
+ // Calculate the natural dimensions of tile corners and edges.
|
|
|
|
|
+ const Vector2f natural_top_left = tiles[TOP_LEFT_CORNER].GetNaturalDimensions(element);
|
|
|
|
|
+ const Vector2f natural_top = tiles[TOP_EDGE].GetNaturalDimensions(element);
|
|
|
|
|
+ const Vector2f natural_top_right = tiles[TOP_RIGHT_CORNER].GetNaturalDimensions(element);
|
|
|
|
|
|
|
|
- // The size of the left and right tiles.
|
|
|
|
|
- Vector2f left_dimensions = tiles[LEFT_EDGE].GetDimensions(element);
|
|
|
|
|
- Vector2f right_dimensions = tiles[RIGHT_EDGE].GetDimensions(element);
|
|
|
|
|
|
|
+ const Vector2f natural_bottom_left = tiles[BOTTOM_LEFT_CORNER].GetNaturalDimensions(element);
|
|
|
|
|
+ const Vector2f natural_bottom = tiles[BOTTOM_EDGE].GetNaturalDimensions(element);
|
|
|
|
|
+ const Vector2f natural_bottom_right = tiles[BOTTOM_RIGHT_CORNER].GetNaturalDimensions(element);
|
|
|
|
|
+
|
|
|
|
|
+ const Vector2f natural_left = tiles[LEFT_EDGE].GetNaturalDimensions(element);
|
|
|
|
|
+ const Vector2f natural_right = tiles[RIGHT_EDGE].GetNaturalDimensions(element);
|
|
|
|
|
+
|
|
|
|
|
+ // Initialize the to-be-determined dimensions of the tiles.
|
|
|
|
|
+ Vector2f top_left = natural_top_left;
|
|
|
|
|
+ Vector2f top = natural_top;
|
|
|
|
|
+ Vector2f top_right = natural_top_right;
|
|
|
|
|
+
|
|
|
|
|
+ Vector2f bottom_left = natural_bottom_left;
|
|
|
|
|
+ Vector2f bottom = natural_bottom;
|
|
|
|
|
+ Vector2f bottom_right = natural_bottom_right;
|
|
|
|
|
+
|
|
|
|
|
+ Vector2f left = natural_left;
|
|
|
|
|
+ Vector2f right = natural_right;
|
|
|
|
|
|
|
|
// Scale the top corners down if appropriate. If they are scaled, then the left and right edges are also scaled
|
|
// Scale the top corners down if appropriate. If they are scaled, then the left and right edges are also scaled
|
|
|
// if they shared a width with their corner. Best solution? Don't know.
|
|
// if they shared a width with their corner. Best solution? Don't know.
|
|
|
- if (padded_size.x < top_left_dimensions.x + top_right_dimensions.x)
|
|
|
|
|
|
|
+ if (padded_size.x < top_left.x + top_right.x)
|
|
|
{
|
|
{
|
|
|
- float minimum_width = top_left_dimensions.x + top_right_dimensions.x;
|
|
|
|
|
|
|
+ float minimum_width = top_left.x + top_right.x;
|
|
|
|
|
|
|
|
- top_left_dimensions.x = padded_size.x * (top_left_dimensions.x / minimum_width);
|
|
|
|
|
- if (tiles[TOP_LEFT_CORNER].GetDimensions(element).x == tiles[LEFT_EDGE].GetDimensions(element).x)
|
|
|
|
|
- left_dimensions.x = top_left_dimensions.x;
|
|
|
|
|
|
|
+ top_left.x = padded_size.x * (top_left.x / minimum_width);
|
|
|
|
|
+ if (natural_top_left.x == natural_left.x)
|
|
|
|
|
+ left.x = top_left.x;
|
|
|
|
|
|
|
|
- top_right_dimensions.x = padded_size.x * (top_right_dimensions.x / minimum_width);
|
|
|
|
|
- if (tiles[TOP_RIGHT_CORNER].GetDimensions(element).x == tiles[RIGHT_EDGE].GetDimensions(element).x)
|
|
|
|
|
- right_dimensions.x = top_right_dimensions.x;
|
|
|
|
|
|
|
+ top_right.x = padded_size.x * (top_right.x / minimum_width);
|
|
|
|
|
+ if (natural_top_right.x == natural_right.x)
|
|
|
|
|
+ right.x = top_right.x;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Scale the bottom corners down if appropriate. If they are scaled, then the left and right edges are also scaled
|
|
// Scale the bottom corners down if appropriate. If they are scaled, then the left and right edges are also scaled
|
|
|
// if they shared a width with their corner. Best solution? Don't know.
|
|
// if they shared a width with their corner. Best solution? Don't know.
|
|
|
- if (padded_size.x < bottom_left_dimensions.x + bottom_right_dimensions.x)
|
|
|
|
|
|
|
+ if (padded_size.x < bottom_left.x + bottom_right.x)
|
|
|
{
|
|
{
|
|
|
- float minimum_width = bottom_left_dimensions.x + bottom_right_dimensions.x;
|
|
|
|
|
|
|
+ float minimum_width = bottom_left.x + bottom_right.x;
|
|
|
|
|
|
|
|
- bottom_left_dimensions.x = padded_size.x * (bottom_left_dimensions.x / minimum_width);
|
|
|
|
|
- if (tiles[BOTTOM_LEFT_CORNER].GetDimensions(element).x == tiles[LEFT_EDGE].GetDimensions(element).x)
|
|
|
|
|
- left_dimensions.x = bottom_left_dimensions.x;
|
|
|
|
|
|
|
+ bottom_left.x = padded_size.x * (bottom_left.x / minimum_width);
|
|
|
|
|
+ if (natural_bottom_left.x == natural_left.x)
|
|
|
|
|
+ left.x = bottom_left.x;
|
|
|
|
|
|
|
|
- bottom_right_dimensions.x = padded_size.x * (bottom_right_dimensions.x / minimum_width);
|
|
|
|
|
- if (tiles[BOTTOM_RIGHT_CORNER].GetDimensions(element).x == tiles[RIGHT_EDGE].GetDimensions(element).x)
|
|
|
|
|
- right_dimensions.x = bottom_right_dimensions.x;
|
|
|
|
|
|
|
+ bottom_right.x = padded_size.x * (bottom_right.x / minimum_width);
|
|
|
|
|
+ if (natural_bottom_right.x == natural_right.x)
|
|
|
|
|
+ right.x = bottom_right.x;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Scale the left corners down if appropriate. If they are scaled, then the top and bottom edges are also scaled
|
|
// Scale the left corners down if appropriate. If they are scaled, then the top and bottom edges are also scaled
|
|
|
// if they shared a width with their corner. Best solution? Don't know.
|
|
// if they shared a width with their corner. Best solution? Don't know.
|
|
|
- if (padded_size.y < top_left_dimensions.y + bottom_left_dimensions.y)
|
|
|
|
|
|
|
+ if (padded_size.y < top_left.y + bottom_left.y)
|
|
|
{
|
|
{
|
|
|
- float minimum_height = top_left_dimensions.y + bottom_left_dimensions.y;
|
|
|
|
|
|
|
+ float minimum_height = top_left.y + bottom_left.y;
|
|
|
|
|
|
|
|
- top_left_dimensions.y = padded_size.y * (top_left_dimensions.y / minimum_height);
|
|
|
|
|
- if (tiles[TOP_LEFT_CORNER].GetDimensions(element).y == tiles[TOP_EDGE].GetDimensions(element).y)
|
|
|
|
|
- top_dimensions.y = top_left_dimensions.y;
|
|
|
|
|
|
|
+ top_left.y = padded_size.y * (top_left.y / minimum_height);
|
|
|
|
|
+ if (natural_top_left.y == natural_top.y)
|
|
|
|
|
+ top.y = top_left.y;
|
|
|
|
|
|
|
|
- bottom_left_dimensions.y = padded_size.y * (bottom_left_dimensions.y / minimum_height);
|
|
|
|
|
- if (tiles[BOTTOM_LEFT_CORNER].GetDimensions(element).y == tiles[BOTTOM_EDGE].GetDimensions(element).y)
|
|
|
|
|
- bottom_dimensions.y = bottom_left_dimensions.y;
|
|
|
|
|
|
|
+ bottom_left.y = padded_size.y * (bottom_left.y / minimum_height);
|
|
|
|
|
+ if (natural_bottom_left.y == natural_bottom.y)
|
|
|
|
|
+ bottom.y = bottom_left.y;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Scale the right corners down if appropriate. If they are scaled, then the top and bottom edges are also scaled
|
|
// Scale the right corners down if appropriate. If they are scaled, then the top and bottom edges are also scaled
|
|
|
// if they shared a width with their corner. Best solution? Don't know.
|
|
// if they shared a width with their corner. Best solution? Don't know.
|
|
|
- if (padded_size.y < top_right_dimensions.y + bottom_right_dimensions.y)
|
|
|
|
|
|
|
+ if (padded_size.y < top_right.y + bottom_right.y)
|
|
|
{
|
|
{
|
|
|
- float minimum_height = top_right_dimensions.y + bottom_right_dimensions.y;
|
|
|
|
|
|
|
+ float minimum_height = top_right.y + bottom_right.y;
|
|
|
|
|
|
|
|
- top_right_dimensions.y = padded_size.y * (top_right_dimensions.y / minimum_height);
|
|
|
|
|
- if (tiles[TOP_RIGHT_CORNER].GetDimensions(element).y == tiles[TOP_EDGE].GetDimensions(element).y)
|
|
|
|
|
- top_dimensions.y = top_right_dimensions.y;
|
|
|
|
|
|
|
+ top_right.y = padded_size.y * (top_right.y / minimum_height);
|
|
|
|
|
+ if (natural_top_right.y == natural_top.y)
|
|
|
|
|
+ top.y = top_right.y;
|
|
|
|
|
|
|
|
- bottom_right_dimensions.y = padded_size.y * (bottom_right_dimensions.y / minimum_height);
|
|
|
|
|
- if (tiles[BOTTOM_RIGHT_CORNER].GetDimensions(element).y == tiles[BOTTOM_EDGE].GetDimensions(element).y)
|
|
|
|
|
- bottom_dimensions.y = bottom_right_dimensions.y;
|
|
|
|
|
|
|
+ bottom_right.y = padded_size.y * (bottom_right.y / minimum_height);
|
|
|
|
|
+ if (natural_bottom_right.y == natural_bottom.y)
|
|
|
|
|
+ bottom.y = bottom_right.y;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const int num_textures = GetNumTextures();
|
|
const int num_textures = GetNumTextures();
|
|
@@ -203,70 +214,70 @@ DecoratorDataHandle DecoratorTiledBox::GenerateElementData(Element* element) con
|
|
|
data->geometry[tiles[TOP_LEFT_CORNER].texture_index].GetIndices(),
|
|
data->geometry[tiles[TOP_LEFT_CORNER].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
Vector2f(0, 0),
|
|
Vector2f(0, 0),
|
|
|
- top_left_dimensions,
|
|
|
|
|
- top_left_dimensions);
|
|
|
|
|
|
|
+ top_left,
|
|
|
|
|
+ top_left);
|
|
|
// Generate the geometry for the top edge tiles.
|
|
// Generate the geometry for the top edge tiles.
|
|
|
tiles[TOP_EDGE].GenerateGeometry(data->geometry[tiles[TOP_EDGE].texture_index].GetVertices(),
|
|
tiles[TOP_EDGE].GenerateGeometry(data->geometry[tiles[TOP_EDGE].texture_index].GetVertices(),
|
|
|
data->geometry[tiles[TOP_EDGE].texture_index].GetIndices(),
|
|
data->geometry[tiles[TOP_EDGE].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
- Vector2f(top_left_dimensions.x, 0),
|
|
|
|
|
- Vector2f(padded_size.x - (top_left_dimensions.x + top_right_dimensions.x), top_dimensions.y),
|
|
|
|
|
- top_dimensions);
|
|
|
|
|
|
|
+ Vector2f(top_left.x, 0),
|
|
|
|
|
+ Vector2f(padded_size.x - (top_left.x + top_right.x), top.y),
|
|
|
|
|
+ top);
|
|
|
// Generate the geometry for the top-right tile.
|
|
// Generate the geometry for the top-right tile.
|
|
|
tiles[TOP_RIGHT_CORNER].GenerateGeometry(data->geometry[tiles[TOP_RIGHT_CORNER].texture_index].GetVertices(),
|
|
tiles[TOP_RIGHT_CORNER].GenerateGeometry(data->geometry[tiles[TOP_RIGHT_CORNER].texture_index].GetVertices(),
|
|
|
data->geometry[tiles[TOP_RIGHT_CORNER].texture_index].GetIndices(),
|
|
data->geometry[tiles[TOP_RIGHT_CORNER].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
- Vector2f(padded_size.x - top_right_dimensions.x, 0),
|
|
|
|
|
- top_right_dimensions,
|
|
|
|
|
- top_right_dimensions);
|
|
|
|
|
|
|
+ Vector2f(padded_size.x - top_right.x, 0),
|
|
|
|
|
+ top_right,
|
|
|
|
|
+ top_right);
|
|
|
|
|
|
|
|
// Generate the geometry for the left side.
|
|
// Generate the geometry for the left side.
|
|
|
tiles[LEFT_EDGE].GenerateGeometry(data->geometry[tiles[LEFT_EDGE].texture_index].GetVertices(),
|
|
tiles[LEFT_EDGE].GenerateGeometry(data->geometry[tiles[LEFT_EDGE].texture_index].GetVertices(),
|
|
|
data->geometry[tiles[LEFT_EDGE].texture_index].GetIndices(),
|
|
data->geometry[tiles[LEFT_EDGE].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
- Vector2f(0, top_left_dimensions.y),
|
|
|
|
|
- Vector2f(left_dimensions.x, padded_size.y - (top_left_dimensions.y + bottom_left_dimensions.y)),
|
|
|
|
|
- left_dimensions);
|
|
|
|
|
|
|
+ Vector2f(0, top_left.y),
|
|
|
|
|
+ Vector2f(left.x, padded_size.y - (top_left.y + bottom_left.y)),
|
|
|
|
|
+ left);
|
|
|
|
|
|
|
|
// Generate the geometry for the right side.
|
|
// Generate the geometry for the right side.
|
|
|
tiles[RIGHT_EDGE].GenerateGeometry(data->geometry[tiles[RIGHT_EDGE].texture_index].GetVertices(),
|
|
tiles[RIGHT_EDGE].GenerateGeometry(data->geometry[tiles[RIGHT_EDGE].texture_index].GetVertices(),
|
|
|
data->geometry[tiles[RIGHT_EDGE].texture_index].GetIndices(),
|
|
data->geometry[tiles[RIGHT_EDGE].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
- Vector2f((padded_size.x - right_dimensions.x), top_right_dimensions.y),
|
|
|
|
|
- Vector2f(right_dimensions.x, padded_size.y - (top_right_dimensions.y + bottom_right_dimensions.y)),
|
|
|
|
|
- right_dimensions);
|
|
|
|
|
|
|
+ Vector2f((padded_size.x - right.x), top_right.y),
|
|
|
|
|
+ Vector2f(right.x, padded_size.y - (top_right.y + bottom_right.y)),
|
|
|
|
|
+ right);
|
|
|
|
|
|
|
|
// Generate the geometry for the bottom-left tile.
|
|
// Generate the geometry for the bottom-left tile.
|
|
|
tiles[BOTTOM_LEFT_CORNER].GenerateGeometry(data->geometry[tiles[BOTTOM_LEFT_CORNER].texture_index].GetVertices(),
|
|
tiles[BOTTOM_LEFT_CORNER].GenerateGeometry(data->geometry[tiles[BOTTOM_LEFT_CORNER].texture_index].GetVertices(),
|
|
|
data->geometry[tiles[BOTTOM_LEFT_CORNER].texture_index].GetIndices(),
|
|
data->geometry[tiles[BOTTOM_LEFT_CORNER].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
- Vector2f(0, padded_size.y - bottom_left_dimensions.y),
|
|
|
|
|
- bottom_left_dimensions,
|
|
|
|
|
- bottom_left_dimensions);
|
|
|
|
|
|
|
+ Vector2f(0, padded_size.y - bottom_left.y),
|
|
|
|
|
+ bottom_left,
|
|
|
|
|
+ bottom_left);
|
|
|
// Generate the geometry for the bottom edge tiles.
|
|
// Generate the geometry for the bottom edge tiles.
|
|
|
tiles[BOTTOM_EDGE].GenerateGeometry(data->geometry[tiles[BOTTOM_EDGE].texture_index].GetVertices(),
|
|
tiles[BOTTOM_EDGE].GenerateGeometry(data->geometry[tiles[BOTTOM_EDGE].texture_index].GetVertices(),
|
|
|
data->geometry[tiles[BOTTOM_EDGE].texture_index].GetIndices(),
|
|
data->geometry[tiles[BOTTOM_EDGE].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
- Vector2f(bottom_left_dimensions.x, padded_size.y - bottom_dimensions.y),
|
|
|
|
|
- Vector2f(padded_size.x - (bottom_left_dimensions.x + bottom_right_dimensions.x), bottom_dimensions.y),
|
|
|
|
|
- bottom_dimensions);
|
|
|
|
|
|
|
+ Vector2f(bottom_left.x, padded_size.y - bottom.y),
|
|
|
|
|
+ Vector2f(padded_size.x - (bottom_left.x + bottom_right.x), bottom.y),
|
|
|
|
|
+ bottom);
|
|
|
// Generate the geometry for the bottom-right tile.
|
|
// Generate the geometry for the bottom-right tile.
|
|
|
tiles[BOTTOM_RIGHT_CORNER].GenerateGeometry(data->geometry[tiles[BOTTOM_RIGHT_CORNER].texture_index].GetVertices(),
|
|
tiles[BOTTOM_RIGHT_CORNER].GenerateGeometry(data->geometry[tiles[BOTTOM_RIGHT_CORNER].texture_index].GetVertices(),
|
|
|
data->geometry[tiles[BOTTOM_RIGHT_CORNER].texture_index].GetIndices(),
|
|
data->geometry[tiles[BOTTOM_RIGHT_CORNER].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
- Vector2f(padded_size.x - bottom_right_dimensions.x, padded_size.y - bottom_right_dimensions.y),
|
|
|
|
|
- bottom_right_dimensions,
|
|
|
|
|
- bottom_right_dimensions);
|
|
|
|
|
|
|
+ Vector2f(padded_size.x - bottom_right.x, padded_size.y - bottom_right.y),
|
|
|
|
|
+ bottom_right,
|
|
|
|
|
+ bottom_right);
|
|
|
|
|
|
|
|
// Generate the centre geometry.
|
|
// Generate the centre geometry.
|
|
|
- Vector2f centre_dimensions = tiles[CENTRE].GetDimensions(element);
|
|
|
|
|
- Vector2f centre_surface_dimensions(padded_size.x - (left_dimensions.x + right_dimensions.x),
|
|
|
|
|
- padded_size.y - (top_dimensions.y + bottom_dimensions.y));
|
|
|
|
|
|
|
+ Vector2f centre_dimensions = tiles[CENTRE].GetNaturalDimensions(element);
|
|
|
|
|
+ Vector2f centre_surface_dimensions(padded_size.x - (left.x + right.x),
|
|
|
|
|
+ padded_size.y - (top.y + bottom.y));
|
|
|
|
|
|
|
|
tiles[CENTRE].GenerateGeometry(data->geometry[tiles[CENTRE].texture_index].GetVertices(),
|
|
tiles[CENTRE].GenerateGeometry(data->geometry[tiles[CENTRE].texture_index].GetVertices(),
|
|
|
data->geometry[tiles[CENTRE].texture_index].GetIndices(),
|
|
data->geometry[tiles[CENTRE].texture_index].GetIndices(),
|
|
|
element,
|
|
element,
|
|
|
- Vector2f(left_dimensions.x, top_dimensions.y),
|
|
|
|
|
|
|
+ Vector2f(left.x, top.y),
|
|
|
centre_surface_dimensions,
|
|
centre_surface_dimensions,
|
|
|
centre_dimensions);
|
|
centre_dimensions);
|
|
|
|
|
|