Refactor - Replaced magic number copies with main_bg_se_copy_rect() (#192)
This commit is contained in:
@@ -113,7 +113,7 @@ void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, int direction);
|
||||
* se_rect dimensions are in number of tiles.
|
||||
* x and y are the coordinates in number of tiles.
|
||||
*/
|
||||
void main_bg_se_copy_rect(Rect se_rect, BG_POINT pos);
|
||||
void main_bg_se_copy_rect(Rect se_rect, BG_POINT dest_pos);
|
||||
|
||||
/* Copies a screen entry to a rect in the main background.
|
||||
* se_rect dimensions are in number of tiles.
|
||||
|
||||
+21
-23
@@ -381,7 +381,10 @@ static const Rect POP_MENU_ANIM_RECT = {9, 7, 24, 31 };
|
||||
// This is because when popping, the target position is blank so we just animate
|
||||
// the whole rect so we don't have to track its position
|
||||
|
||||
static const Rect SINGLE_BLIND_SELECT_RECT = {9, 7, 13, 32 };
|
||||
static const Rect SINGLE_BLIND_SELECT_RECT = {9, 7, 13, 31 };
|
||||
static const Rect BLIND_SKIP_BTN_GRAY_RECT = {0, 24, 4, 27 };
|
||||
static const Rect BLIND_SKIP_BTN_PREANIM_DEST_RECT = {9,29, 19, 31 };
|
||||
// preanim - pre-animation rects for before the pop-up animation
|
||||
|
||||
static const Rect HAND_BG_RECT_SELECTING = {9, 11, 24, 17 };
|
||||
// TODO: Currently unused, remove?
|
||||
@@ -835,39 +838,34 @@ void change_background(int id)
|
||||
|
||||
for (int i = 0; i < BLIND_TYPE_MAX; i++)
|
||||
{
|
||||
if (blinds[i] != BLIND_STATE_CURRENT &&
|
||||
(i == BLIND_TYPE_SMALL || i == BLIND_TYPE_BIG)) // Make the skip button gray
|
||||
Rect curr_blind_rect = SINGLE_BLIND_SELECT_RECT;
|
||||
|
||||
// There's no gap between them
|
||||
curr_blind_rect.left += i * rect_width(&SINGLE_BLIND_SELECT_RECT);
|
||||
curr_blind_rect.right += i * rect_width(&SINGLE_BLIND_SELECT_RECT);
|
||||
|
||||
if (blinds[i] != BLIND_STATE_CURRENT && (i == BLIND_TYPE_SMALL || i == BLIND_TYPE_BIG)) // Make the skip button gray
|
||||
{
|
||||
// TODO: Switch all the copies here to use main_bg_se_copy_rect()
|
||||
// Note, this is difficult as the tiles to copy are not aligned.
|
||||
int x_from = 0;
|
||||
int y_from = 24 + (i * 4);
|
||||
BG_POINT skip_blind_btn_pos_dest = { BLIND_SKIP_BTN_PREANIM_DEST_RECT.left, BLIND_SKIP_BTN_PREANIM_DEST_RECT.top };
|
||||
skip_blind_btn_pos_dest.x = curr_blind_rect.left;
|
||||
|
||||
int x_to = 9 + (i * 5);
|
||||
int y_to = 29;
|
||||
Rect skip_blind_btn_rect_src = BLIND_SKIP_BTN_GRAY_RECT;
|
||||
skip_blind_btn_rect_src.top += i * rect_height(&BLIND_SKIP_BTN_GRAY_RECT);
|
||||
skip_blind_btn_rect_src.bottom += i * rect_height(&BLIND_SKIP_BTN_GRAY_RECT);
|
||||
|
||||
for (int j = 0; j < BLIND_TYPE_MAX; j++)
|
||||
{
|
||||
memcpy16(&se_mem[MAIN_BG_SBB][x_to + 32 * y_to], &se_mem[MAIN_BG_SBB][x_from + 32 * y_from], 5);
|
||||
y_from++;
|
||||
y_to++;
|
||||
}
|
||||
main_bg_se_copy_rect(skip_blind_btn_rect_src, skip_blind_btn_pos_dest);
|
||||
}
|
||||
|
||||
switch(blinds[i]) {
|
||||
case BLIND_STATE_CURRENT: // Raise the blind panel up a bit
|
||||
{
|
||||
// TODO: Replace copies with main_bg_se_copy_rect() of named rects
|
||||
int x_from = 0;
|
||||
int y_from = 27;
|
||||
|
||||
Rect blind_rect = SINGLE_BLIND_SELECT_RECT;
|
||||
main_bg_se_copy_rect_1_tile_vert(curr_blind_rect, SE_UP);
|
||||
|
||||
// There's no gap between them
|
||||
blind_rect.left += i * rect_width(&SINGLE_BLIND_SELECT_RECT);
|
||||
blind_rect.right += i * rect_width(&SINGLE_BLIND_SELECT_RECT);
|
||||
main_bg_se_copy_rect_1_tile_vert(blind_rect, SE_UP);
|
||||
|
||||
int x_to = blind_rect.left;
|
||||
int x_to = curr_blind_rect.left;
|
||||
int y_to = 31;
|
||||
|
||||
if (i == BLIND_TYPE_BIG)
|
||||
@@ -893,7 +891,7 @@ void change_background(int id)
|
||||
int x_from = 0;
|
||||
int y_from = 20;
|
||||
|
||||
int x_to = 10 + (i * 5);
|
||||
int x_to = 10 + (i * rect_width(&SINGLE_BLIND_SELECT_RECT));
|
||||
int y_to = 20;
|
||||
|
||||
memcpy16(&se_mem[MAIN_BG_SBB][x_to + 32 * y_to], &se_mem[MAIN_BG_SBB][x_from + 32 * y_from], 3);
|
||||
|
||||
@@ -112,7 +112,7 @@ void main_bg_se_move_rect_1_tile_vert(Rect se_rect, int direction)
|
||||
main_bg_se_copy_or_move_rect_1_tile_vert(se_rect, direction, true);
|
||||
}
|
||||
|
||||
void main_bg_se_copy_rect(Rect se_rect, BG_POINT pos)
|
||||
void main_bg_se_copy_rect(Rect se_rect, BG_POINT dest_pos)
|
||||
{
|
||||
if (se_rect.left > se_rect.right || se_rect.top > se_rect.bottom)
|
||||
return;
|
||||
@@ -136,7 +136,7 @@ void main_bg_se_copy_rect(Rect se_rect, BG_POINT pos)
|
||||
// Copy the tilemap to the new rect position
|
||||
for (int sy = 0; sy < height; sy++)
|
||||
{
|
||||
memcpy16(&se_mat[MAIN_BG_SBB][pos.y + sy][pos.x],
|
||||
memcpy16(&se_mat[MAIN_BG_SBB][dest_pos.y + sy][dest_pos.x],
|
||||
&tile_map[sy][0],
|
||||
width);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user