[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src clone/unit_draw.c include/unit.h ...
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src clone/unit_draw.c include/unit.h ... |
Date: |
Tue, 21 Oct 2003 00:27:58 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/10/21 00:27:58
Modified files:
src/clone : unit_draw.c
src/include : unit.h
src/video : cursor.c
Log message:
Draw shadow in building cursor
Patches:
Index: stratagus/src/clone/unit_draw.c
diff -u stratagus/src/clone/unit_draw.c:1.167
stratagus/src/clone/unit_draw.c:1.168
--- stratagus/src/clone/unit_draw.c:1.167 Mon Oct 13 00:38:37 2003
+++ stratagus/src/clone/unit_draw.c Tue Oct 21 00:27:57 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit_draw.c,v 1.167 2003/10/13 04:38:37 jsalmon3 Exp $
+// $Id: unit_draw.c,v 1.168 2003/10/21 04:27:57 jsalmon3 Exp $
//@{
@@ -577,7 +577,7 @@
global void SaveDecorations(CLFile* file)
{
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.167
2003/10/13 04:38:37 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.168
2003/10/21 04:27:57 jsalmon3 Exp $\n\n");
CLprintf(file, "(mana-sprite \"%s\" %d %d %d %d)\n",
ManaSprite.File, ManaSprite.HotX, ManaSprite.HotY,
@@ -1109,85 +1109,110 @@
}
/**
-** Draw flying units shadow.
+** Draw unit's shadow.
**
** @param unit Pointer to the unit.
+** @param type Pointer to the unit type.
** @param x Screen X position of the unit.
** @param y Screen Y position of the unit.
**
** @todo FIXME: combine new shadow code with old shadow code.
*/
-local void DrawShadow(const Unit* unit, int x, int y)
+global void DrawShadow(const Unit* unit, const UnitType* type, int x, int y)
{
+ if (!type) {
+ DebugCheck(!unit);
+ type = unit->Type;
+ }
+ DebugCheck(unit && type && unit->Type != type);
+
//
// A building can be under construction and is drawn with construction
// frames.
//
- if (unit->Type->Building) {
+ if (type->Building) {
// What constrution shadow must be drawn?
- if (unit->Orders[0].Action == UnitActionBuilded && (unit->Constructed
- || VideoGraphicFrames(unit->Type->Sprite) <= 1)) {
- if (unit->Type->Construction->ShadowSprite) {
- x -= (unit->Type->Construction->ShadowWidth -
- unit->Type->TileWidth * TileSizeX) / 2;
- y -= (unit->Type->Construction->ShadowHeight -
- unit->Type->TileHeight * TileSizeY) / 2;
- y += unit->Type->ShadowOffset;
+ if (unit && unit->Orders[0].Action == UnitActionBuilded &&
+ (unit->Constructed || VideoGraphicFrames(type->Sprite) <= 1)) {
+ if (type->Construction->ShadowSprite) {
+ x -= (type->Construction->ShadowWidth -
+ type->TileWidth * TileSizeX) / 2;
+ y -= (type->Construction->ShadowHeight -
+ type->TileHeight * TileSizeY) / 2;
+ y += type->ShadowOffset;
if (unit->Frame < 0) {
- VideoDrawShadowClipX(unit->Type->Construction->
+ VideoDrawShadowClipX(type->Construction->
ShadowSprite, -unit->Frame, x, y);
} else {
- VideoDrawShadowClip(unit->Type->Construction->ShadowSprite,
+ VideoDrawShadowClip(type->Construction->ShadowSprite,
unit->Frame, x, y);
}
}
return;
}
// Draw normal shadow
- if (unit->Type->ShadowSprite) {
+ if (type->ShadowSprite) {
// FIXME: this can be combined with the unit else part.
- x -= (unit->Type->ShadowWidth -
- unit->Type->TileWidth * TileSizeX) / 2;
- y -= (unit->Type->ShadowHeight -
- unit->Type->TileHeight * TileSizeY) / 2;
- y += unit->Type->ShadowOffset;
- if (unit->Frame < 0) {
- VideoDrawShadowClipX(unit->Type->ShadowSprite, -unit->Frame, x,
y);
+ x -= (type->ShadowWidth -
+ type->TileWidth * TileSizeX) / 2;
+ y -= (type->ShadowHeight -
+ type->TileHeight * TileSizeY) / 2;
+ y += type->ShadowOffset;
+ if (unit) {
+ if (unit->Frame < 0) {
+ VideoDrawShadowClipX(type->ShadowSprite, -unit->Frame, x,
y);
+ } else {
+ VideoDrawShadowClip(type->ShadowSprite, unit->Frame, x, y);
+ }
} else {
- VideoDrawShadowClip(unit->Type->ShadowSprite, unit->Frame, x,
y);
+ // FIXME: correct frame? taken from DrawBuildingCursor
+ if (VideoGraphicFrames(type->Sprite) > 5) {
+ VideoDrawShadowClip(type->ShadowSprite, 4, x, y);
+ } else {
+ VideoDrawShadowClip(type->ShadowSprite, 0, x, y);
+ }
}
}
return;
}
- if (unit->Orders[0].Action == UnitActionDie) {
+ if (unit && unit->Orders[0].Action == UnitActionDie) {
return;
}
// Draw normal shadow sprite if available
- if (unit->Type->ShadowSprite) {
- x -= (unit->Type->ShadowWidth -
- unit->Type->TileWidth * TileSizeX) / 2;
- y -= (unit->Type->ShadowHeight -
- unit->Type->TileHeight * TileSizeY) / 2;
- y += unit->Type->ShadowOffset;
+ if (type->ShadowSprite) {
+ x -= (type->ShadowWidth -
+ type->TileWidth * TileSizeX) / 2;
+ y -= (type->ShadowHeight -
+ type->TileHeight * TileSizeY) / 2;
+ y += type->ShadowOffset;
- if (unit->Frame < 0) {
- VideoDrawShadowClipX(unit->Type->ShadowSprite, -unit->Frame, x, y);
+ if (unit) {
+ if (unit->Frame < 0) {
+ VideoDrawShadowClipX(type->ShadowSprite, -unit->Frame, x, y);
+ } else {
+ VideoDrawShadowClip(type->ShadowSprite, unit->Frame, x, y);
+ }
} else {
- VideoDrawShadowClip(unit->Type->ShadowSprite, unit->Frame, x, y);
+ // FIXME: correct frame? taken from DrawBuildingCursor
+ if (VideoGraphicFrames(type->Sprite) > 5) {
+ VideoDrawShadowClip(type->ShadowSprite, 4, x, y);
+ } else {
+ VideoDrawShadowClip(type->ShadowSprite, 0, x, y);
+ }
}
return;
}
// Use ShadowSprite if the unit flies
- if (unit->Type->UnitType == UnitTypeFly) {
+ if (type->UnitType == UnitTypeFly) {
int i;
// Shadow size depends on box-size
- if (unit->Type->BoxHeight > 63) {
+ if (type->BoxHeight > 63) {
i = 2;
- } else if (unit->Type->BoxHeight > 32) {
+ } else if (type->BoxHeight > 32) {
i = 1;
} else {
i = 0;
@@ -1770,7 +1795,7 @@
return;
}
- DrawShadow(unit, x, y);
+ DrawShadow(unit, NULL, x, y);
//
// Show that the unit is selected
@@ -1834,7 +1859,7 @@
type = unit->Type;
- DrawShadow(unit, x, y);
+ DrawShadow(unit, NULL, x, y);
//
// Show that the unit is selected
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.219 stratagus/src/include/unit.h:1.220
--- stratagus/src/include/unit.h:1.219 Fri Oct 17 02:04:31 2003
+++ stratagus/src/include/unit.h Tue Oct 21 00:27:58 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit.h,v 1.219 2003/10/17 06:04:31 mr-russ Exp $
+// $Id: unit.h,v 1.220 2003/10/21 04:27:58 jsalmon3 Exp $
#ifndef __UNIT_H__
#define __UNIT_H__
@@ -927,6 +927,8 @@
/// Clean the decorations (health,mana) of units
extern void CleanDecorations(void);
+ /// Draw unit's shadow
+extern void DrawShadow(const Unit* unit, const UnitType* type, int x, int y);
/// Draw A single Unit
extern void DrawUnit(const Unit* unit);
extern void DrawBuilding(const Unit* unit);
Index: stratagus/src/video/cursor.c
diff -u stratagus/src/video/cursor.c:1.71 stratagus/src/video/cursor.c:1.72
--- stratagus/src/video/cursor.c:1.71 Thu Oct 9 19:04:04 2003
+++ stratagus/src/video/cursor.c Tue Oct 21 00:27:58 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: cursor.c,v 1.71 2003/10/09 23:04:04 jsalmon3 Exp $
+// $Id: cursor.c,v 1.72 2003/10/21 04:27:58 jsalmon3 Exp $
//@{
@@ -722,6 +722,7 @@
//
PushClipping();
SetClipping(vp->X, vp->Y, vp->EndX, vp->EndY);
+ DrawShadow(NULL, CursorBuilding, x, y);
GraphicPlayerPixels(ThisPlayer, CursorBuilding->Sprite);
if (VideoGraphicFrames(CursorBuilding->Sprite) > 5) {
DrawUnitType(CursorBuilding, 4, x, y);
@@ -1121,7 +1122,7 @@
int i;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.71 2003/10/09
23:04:04 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.72 2003/10/21
04:27:58 jsalmon3 Exp $\n\n");
for (i = 0; Cursors[i].OType; ++i) {
CLprintf(file, "(define-cursor '%s '%s\n",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src clone/unit_draw.c include/unit.h ...,
Jimmy Salmon <=