1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2004-2009 The Mana World Development Team |
4 |
|
|
* Copyright (C) 2009-2010 The Mana Developers |
5 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
6 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
7 |
|
|
* |
8 |
|
|
* This file is part of The ManaPlus Client. |
9 |
|
|
* |
10 |
|
|
* This program is free software; you can redistribute it and/or modify |
11 |
|
|
* it under the terms of the GNU General Public License as published by |
12 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
13 |
|
|
* any later version. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU General Public License |
21 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
// bool GraphicsX::calcImageRect(ImageVertexes *const vert, |
26 |
|
|
// const int x, const int y, |
27 |
|
|
// const int w, const int h, |
28 |
|
|
// const ImageRect &imgRect) |
29 |
|
|
|
30 |
✓✗ |
167 |
if (!vert) |
31 |
|
|
return; |
32 |
|
|
|
33 |
|
|
BLOCK_START("Graphics::calcImageRect") |
34 |
|
|
|
35 |
|
167 |
const Image *restrict const *restrict const grid = imgRect.grid; |
36 |
|
167 |
const Image *restrict const topLeft = grid[0]; |
37 |
|
167 |
const Image *restrict const topRight = grid[2]; |
38 |
|
167 |
const Image *restrict const bottomLeft = grid[6]; |
39 |
|
167 |
const Image *restrict const bottomRight = grid[8]; |
40 |
|
167 |
const Image *restrict const top = grid[1]; |
41 |
|
167 |
const Image *restrict const right = grid[5]; |
42 |
|
167 |
const Image *restrict const bottom = grid[7]; |
43 |
|
167 |
const Image *restrict const left = grid[3]; |
44 |
|
167 |
const Image *restrict const center = grid[4]; |
45 |
|
|
|
46 |
|
334 |
const bool drawMain = center && topLeft && topRight |
47 |
✓✗✓✓ ✗✓ |
334 |
&& bottomLeft && bottomRight; |
48 |
|
|
|
49 |
|
|
// Draw the center area |
50 |
✓✓ |
167 |
if (center && drawMain) |
51 |
|
|
{ |
52 |
|
156 |
const int tlw = topLeft->getWidth(); |
53 |
|
156 |
const int tlh = topLeft->getHeight(); |
54 |
|
312 |
calcPatternInline(vert, center, tlw + x, tlh + y, |
55 |
|
312 |
w - tlw - topRight->getWidth(), |
56 |
|
312 |
h - tlh - bottomLeft->getHeight()); |
57 |
|
|
} |
58 |
|
|
// Draw the sides |
59 |
✓✓✓✗
|
167 |
if (top && left && bottom && right) |
60 |
|
|
{ |
61 |
|
156 |
const int lw = left->getWidth(); |
62 |
|
156 |
const int rw = right->getWidth(); |
63 |
|
156 |
const int th = top->getHeight(); |
64 |
|
156 |
const int bh = bottom->getHeight(); |
65 |
|
312 |
calcPatternInline(vert, top, x + lw, y, w - lw - rw, th); |
66 |
|
312 |
calcPatternInline(vert, bottom, x + lw, y + h - bh, w - lw - rw, bh); |
67 |
|
312 |
calcPatternInline(vert, left, x, y + th, lw, h - th - bh); |
68 |
✓✗ |
156 |
if (w > rw) |
69 |
|
156 |
calcPatternInline(vert, right, x + w - rw, y + th, rw, h - th - bh); |
70 |
|
|
} |
71 |
|
|
|
72 |
✓✗ |
167 |
if (topLeft) |
73 |
|
|
calcTileVertexesInline(vert, topLeft, x, y); |
74 |
✓✓ |
167 |
if (topRight) |
75 |
|
|
{ |
76 |
|
156 |
const int trw = topRight->getWidth(); |
77 |
✓✗ |
156 |
if (w > trw) |
78 |
|
156 |
calcTileVertexesInline(vert, topRight, x + w - trw, y); |
79 |
|
|
} |
80 |
✓✓ |
167 |
if (bottomLeft) |
81 |
|
|
{ |
82 |
|
156 |
calcTileVertexesInline(vert, bottomLeft, |
83 |
|
312 |
x, y + h - bottomLeft->getHeight()); |
84 |
|
|
} |
85 |
✓✓ |
167 |
if (bottomRight) |
86 |
|
|
{ |
87 |
|
156 |
const int brw = bottomRight->getWidth(); |
88 |
✓✗ |
156 |
if (w > brw) |
89 |
|
|
{ |
90 |
|
156 |
calcTileVertexesInline(vert, bottomRight, x + w - brw, |
91 |
|
312 |
y + h - bottomRight->getHeight()); |
92 |
|
|
} |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
BLOCK_END("Graphics::calcImageRect") |