mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-04 12:48:00 +03:00
Make MyRectangle an alias of SDL_Rect
This commit is contained in:
@@ -77,8 +77,8 @@ static int sp_draw_wall(sprite_t *sp) {
|
||||
|
||||
sx = sact.updaterect.x;
|
||||
sy = sact.updaterect.y;
|
||||
w = sact.updaterect.width;
|
||||
h = sact.updaterect.height;
|
||||
w = sact.updaterect.w;
|
||||
h = sact.updaterect.h;
|
||||
gr_fill(sf0, sx, sy, w, h, 0, 0, 0);
|
||||
|
||||
SACT_DEBUG("do update no=%d, sx=%d, sy=%d, w=%d, h=%d, \n",
|
||||
|
||||
@@ -101,8 +101,8 @@ int sp_draw2(sprite_t *sp, cginfo_t *cg) {
|
||||
if (cg->sf == NULL) return NG;
|
||||
|
||||
// 更新領域の確定
|
||||
update.width = sact.updaterect.width;
|
||||
update.height = sact.updaterect.height;
|
||||
update.width = sact.updaterect.w;
|
||||
update.height = sact.updaterect.h;
|
||||
sx = 0;
|
||||
sy = 0;
|
||||
dx = sp->cur.x - sact.updaterect.x;
|
||||
|
||||
@@ -336,9 +336,9 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
|
||||
|
||||
// Waitなしの出力は最後にupdate
|
||||
if (needupdate) {
|
||||
uparea.width = sp->cursize.width;
|
||||
uparea.height = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace + wRSize);
|
||||
sp_updateme_part(sp, uparea.x, uparea.y, uparea.width, uparea.height);
|
||||
uparea.w = sp->cursize.width;
|
||||
uparea.h = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace + wRSize);
|
||||
sp_updateme_part(sp, uparea.x, uparea.y, uparea.w, uparea.h);
|
||||
}
|
||||
|
||||
// ????
|
||||
@@ -438,8 +438,8 @@ int smsg_update(sprite_t *sp) {
|
||||
// -> 説明スプライトのように、SetShowされたときに対応できないからだめ
|
||||
//if (sact.msgbufempty) return OK;
|
||||
|
||||
update.width = sact.updaterect.width;
|
||||
update.height = sact.updaterect.height;
|
||||
update.width = sact.updaterect.w;
|
||||
update.height = sact.updaterect.h;
|
||||
|
||||
dx = sp->cur.x - sact.updaterect.x;
|
||||
dy = sp->cur.y - sact.updaterect.y;
|
||||
|
||||
@@ -70,8 +70,8 @@ static boolean sp_is_insprite2(sprite_t *sp, int x, int y, int margin) {
|
||||
|
||||
r.x = sp->cur.x + margin;
|
||||
r.y = sp->cur.y + margin;
|
||||
r.width = curcg->sf->width - 2 * margin;
|
||||
r.height = curcg->sf->height - 2 * margin;
|
||||
r.w = curcg->sf->width - 2 * margin;
|
||||
r.h = curcg->sf->height - 2 * margin;
|
||||
return ags_regionContains(&r, x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,46 +39,15 @@
|
||||
// スプライト再描画間の間に変更のあったスプライトの領域の和
|
||||
static SList *updatearea;
|
||||
|
||||
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst);
|
||||
static void disjunction(void* region, void* data);
|
||||
static void get_updatearea();
|
||||
static void do_update_each(void* data, void* userdata);
|
||||
|
||||
// 領域1と領域2の積を計算
|
||||
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst) {
|
||||
int x1 = max(r1->x, r2->x);
|
||||
int x2 = min(r1->x + r1->width, r2->x + r2->width);
|
||||
int y1 = max(r1->y, r2->y);
|
||||
int y2 = min(r1->y + r1->height, r2->y + r2->height);
|
||||
|
||||
rst->x = x1;
|
||||
rst->y = y1;
|
||||
rst->width = x2 - x1;
|
||||
rst->height = y2 - y1;
|
||||
}
|
||||
|
||||
// 領域1と領域2をすべて含む矩形領域を計算
|
||||
static void disjunction(void* region, void* data) {
|
||||
MyRectangle *r1 = (MyRectangle *)region;
|
||||
MyRectangle *r2 = (MyRectangle *)data;
|
||||
int x1, x2, y1, y2;
|
||||
|
||||
if (r2->width == 0) {
|
||||
r2->x = r1->x;
|
||||
r2->y = r1->y;
|
||||
r2->width = r1->width;
|
||||
r2->height = r1->height;
|
||||
} else {
|
||||
x1 = min(r1->x, r2->x);
|
||||
x2 = max(r1->x + r1->width, r2->x + r2->width);
|
||||
y1 = min(r1->y, r2->y);
|
||||
y2 = max(r1->y + r1->height, r2->y + r2->height);
|
||||
|
||||
r2->x = x1;
|
||||
r2->y = y1;
|
||||
r2->width = x2 - x1;
|
||||
r2->height = y2 - y1;
|
||||
}
|
||||
SDL_UnionRect(r1, r2, r2);
|
||||
free(r1);
|
||||
}
|
||||
|
||||
@@ -93,11 +62,11 @@ static void get_updatearea() {
|
||||
updatearea = NULL;
|
||||
|
||||
// surface0との領域の積をとる
|
||||
intersection(&rsf0, &clip, &sact.updaterect);
|
||||
SDL_IntersectRect(&rsf0, &clip, &sact.updaterect);
|
||||
|
||||
SACT_DEBUG("clipped area x=%d y=%d w=%d h=%d\n",
|
||||
sact.updaterect.x, sact.updaterect.y,
|
||||
sact.updaterect.width, sact.updaterect.height);
|
||||
sact.updaterect.w, sact.updaterect.h);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -135,8 +104,8 @@ int sp_update_all(boolean syncscreen) {
|
||||
// 画面全体を更新領域に
|
||||
sact.updaterect.x = 0;
|
||||
sact.updaterect.y = 0;
|
||||
sact.updaterect.width = sf0->width;
|
||||
sact.updaterect.height = sf0->height;
|
||||
sact.updaterect.w = sf0->width;
|
||||
sact.updaterect.h = sf0->height;
|
||||
|
||||
// updatelistに登録してあるスプライトを再描画
|
||||
// updatelistはスプライトの番号順に並んでいる
|
||||
@@ -164,10 +133,8 @@ int sp_update_clipped() {
|
||||
// 更新領域の確定
|
||||
get_updatearea();
|
||||
|
||||
// 幅または高さが 0 の時はなにもしない
|
||||
if (sact.updaterect.width == 0 || sact.updaterect.height == 0) {
|
||||
if (SDL_RectEmpty(&sact.updaterect))
|
||||
return OK;
|
||||
}
|
||||
|
||||
// 更新領域に入っているスプライトの再描画
|
||||
slist_foreach(sact.updatelist, do_update_each, NULL);
|
||||
@@ -178,7 +145,7 @@ int sp_update_clipped() {
|
||||
}
|
||||
|
||||
// 更新領域を Window に転送
|
||||
ags_updateArea(sact.updaterect.x, sact.updaterect.y, sact.updaterect.width, sact.updaterect.height);
|
||||
ags_updateArea(sact.updaterect.x, sact.updaterect.y, sact.updaterect.w, sact.updaterect.h);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -196,13 +163,13 @@ int sp_updateme(sprite_t *sp) {
|
||||
r = malloc(sizeof(MyRectangle));
|
||||
r->x = sp->cur.x;
|
||||
r->y = sp->cur.y;
|
||||
r->width = sp->cursize.width;
|
||||
r->height = sp->cursize.height;
|
||||
r->w = sp->cursize.width;
|
||||
r->h = sp->cursize.height;
|
||||
|
||||
updatearea = slist_append(updatearea, r);
|
||||
|
||||
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
|
||||
r->x, r->y, sp->no, r->width, r->height);
|
||||
r->x, r->y, sp->no, r->w, r->h);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -224,13 +191,13 @@ int sp_updateme_part(sprite_t *sp, int x, int y, int w, int h) {
|
||||
r = malloc(sizeof(MyRectangle));
|
||||
r->x = sp->cur.x + x;
|
||||
r->y = sp->cur.y + y;
|
||||
r->width = w;
|
||||
r->height = h;
|
||||
r->w = w;
|
||||
r->h = h;
|
||||
|
||||
updatearea = slist_append(updatearea, r);
|
||||
|
||||
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
|
||||
r->x, r->y, sp->no, r->width, r->height);
|
||||
r->x, r->y, sp->no, r->w, r->h);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user