[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src clone/construct.c clone/unit_draw...
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src clone/construct.c clone/unit_draw... |
Date: |
Wed, 22 Oct 2003 14:02:38 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/10/22 14:02:36
Modified files:
src/clone : construct.c unit_draw.c
src/include : unit.h
src/video : cursor.c
Log message:
Fixed construction shadows
Patches:
Index: stratagus/src/clone/construct.c
diff -u stratagus/src/clone/construct.c:1.36
stratagus/src/clone/construct.c:1.37
--- stratagus/src/clone/construct.c:1.36 Fri Oct 17 15:01:11 2003
+++ stratagus/src/clone/construct.c Wed Oct 22 14:02:33 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: construct.c,v 1.36 2003/10/17 19:01:11 jsalmon3 Exp $
+// $Id: construct.c,v 1.37 2003/10/22 18:02:33 jsalmon3 Exp $
//@{
@@ -101,7 +101,7 @@
(*cop)->Width = (*cop)->File[0].Width;
(*cop)->Height = (*cop)->File[0].Height;
}
- if (*file) {
+ if (file && *file) {
char* buf;
buf = alloca(strlen(file) + 9 + 1);
@@ -147,7 +147,7 @@
ConstructionFrame* cframe;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: constructions $Id: construct.c,v 1.36
2003/10/17 19:01:11 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: constructions $Id: construct.c,v 1.37
2003/10/22 18:02:33 jsalmon3 Exp $\n\n");
// FIXME: needed?
Index: stratagus/src/clone/unit_draw.c
diff -u stratagus/src/clone/unit_draw.c:1.170
stratagus/src/clone/unit_draw.c:1.171
--- stratagus/src/clone/unit_draw.c:1.170 Tue Oct 21 22:42:12 2003
+++ stratagus/src/clone/unit_draw.c Wed Oct 22 14:02:34 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit_draw.c,v 1.170 2003/10/22 02:42:12 jsalmon3 Exp $
+// $Id: unit_draw.c,v 1.171 2003/10/22 18:02:34 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.170
2003/10/22 02:42:12 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.171
2003/10/22 18:02:34 jsalmon3 Exp $\n\n");
CLprintf(file, "(mana-sprite \"%s\" %d %d %d %d)\n",
ManaSprite.File, ManaSprite.HotX, ManaSprite.HotY,
@@ -1118,7 +1118,8 @@
**
** @todo FIXME: combine new shadow code with old shadow code.
*/
-global void DrawShadow(const Unit* unit, const UnitType* type, int x, int y)
+global void DrawShadow(const Unit* unit, const UnitType* type, int frame,
+ int x, int y)
{
if (!type) {
DebugCheck(!unit);
@@ -1131,26 +1132,6 @@
// frames.
//
if (type->Building) {
- // What constrution shadow must be drawn?
- 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;
- x += type->ShadowOffsetX;
- y += type->ShadowOffsetY;
- if (unit->Frame < 0) {
- VideoDrawShadowClipX(type->Construction->
- ShadowSprite, -unit->Frame, x, y);
- } else {
- VideoDrawShadowClip(type->Construction->ShadowSprite,
- unit->Frame, x, y);
- }
- }
- return;
- }
// Draw normal shadow
if (type->ShadowSprite) {
// FIXME: this can be combined with the unit else part.
@@ -1160,18 +1141,10 @@
type->TileHeight * TileSizeY) / 2;
x += type->ShadowOffsetX;
y += type->ShadowOffsetY;
- if (unit) {
- if (unit->Frame < 0) {
- VideoDrawShadowClipX(type->ShadowSprite, -unit->Frame, x,
y);
- } else {
- VideoDrawShadowClip(type->ShadowSprite, unit->Frame, x, y);
- }
+ if (frame < 0) {
+ VideoDrawShadowClipX(type->ShadowSprite, -frame, x, y);
} else {
- // FIXME: correct frame? taken from DrawBuildingCursor
- VideoDrawShadowClip(type->ShadowSprite,
- CursorBuilding->Animations->Still[0].Frame +
- (CursorBuilding->Building ? 0 :
CursorBuilding->NumDirections / 2 + 1 - 1),
- x, y);
+ VideoDrawShadowClip(type->ShadowSprite, frame, x, y);
}
}
return;
@@ -1190,18 +1163,10 @@
x += type->ShadowOffsetX;
y += type->ShadowOffsetY;
- if (unit) {
- if (unit->Frame < 0) {
- VideoDrawShadowClipX(type->ShadowSprite, -unit->Frame, x, y);
- } else {
- VideoDrawShadowClip(type->ShadowSprite, unit->Frame, x, y);
- }
+ if (frame < 0) {
+ VideoDrawShadowClipX(type->ShadowSprite, -frame, x, y);
} else {
- // FIXME: correct frame? taken from DrawBuildingCursor
- VideoDrawShadowClip(type->ShadowSprite,
- CursorBuilding->Animations->Still[0].Frame +
- (CursorBuilding->Building ? 0 :
CursorBuilding->NumDirections / 2 + 1 - 1),
- x, y);
+ VideoDrawShadowClip(type->ShadowSprite, frame, x, y);
}
return;
}
@@ -1710,6 +1675,44 @@
#endif
/**
+** Draw construction shadow.
+**
+** @param unit Unit pointer.
+** @param frame Frame number to draw.
+** @param x X position.
+** @param y Y position.
+*/
+local void DrawConstructionShadow(const Unit* unit, int frame, int x, int y)
+{
+ ConstructionFrame* cframe;
+
+ cframe = unit->Data.Builded.Frame;
+ if (cframe->File == ConstructionFileConstruction) {
+ x -= (unit->Type->Construction->Width - unit->Type->TileWidth *
TileSizeX) / 2;
+ y -= (unit->Type->Construction->Height - unit->Type->TileHeight *
TileSizeY )/ 2;
+// x += type->ShadowOffsetX;
+// y += type->ShadowOffsetY;
+ if (frame < 0) {
+ VideoDrawShadowClipX(unit->Type->Construction->ShadowSprite,
+ -frame, x, y);
+ } else {
+ VideoDrawShadowClip(unit->Type->Construction->ShadowSprite,
+ frame, x, y);
+ }
+ } else {
+ x -= (unit->Type->ShadowWidth - unit->Type->TileWidth * TileSizeX) / 2;
+ y -= (unit->Type->ShadowHeight - unit->Type->TileHeight * TileSizeY) /
2;
+ x += unit->Type->ShadowOffsetX;
+ y += unit->Type->ShadowOffsetY;
+ if (frame < 0) {
+ VideoDrawShadowClipX(unit->Type->ShadowSprite, -frame, x, y);
+ } else {
+ VideoDrawShadowClip(unit->Type->ShadowSprite, frame, x, y);
+ }
+ }
+}
+
+/**
** Draw construction.
**
** @param unit Unit pointer.
@@ -1796,7 +1799,11 @@
return;
}
- DrawShadow(unit, NULL, x, y);
+ if (state == 1 && constructed) {
+ DrawConstructionShadow(unit, frame, x, y);
+ } else {
+ DrawShadow(unit, NULL, frame, x, y);
+ }
//
// Show that the unit is selected
@@ -1860,7 +1867,7 @@
type = unit->Type;
- DrawShadow(unit, NULL, x, y);
+ DrawShadow(unit, NULL, unit->Frame, x, y);
//
// Show that the unit is selected
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.220 stratagus/src/include/unit.h:1.221
--- stratagus/src/include/unit.h:1.220 Tue Oct 21 00:27:58 2003
+++ stratagus/src/include/unit.h Wed Oct 22 14:02:35 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit.h,v 1.220 2003/10/21 04:27:58 jsalmon3 Exp $
+// $Id: unit.h,v 1.221 2003/10/22 18:02:35 jsalmon3 Exp $
#ifndef __UNIT_H__
#define __UNIT_H__
@@ -928,7 +928,8 @@
extern void CleanDecorations(void);
/// Draw unit's shadow
-extern void DrawShadow(const Unit* unit, const UnitType* type, int x, int y);
+extern void DrawShadow(const Unit* unit, const UnitType* type, int frame,
+ 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.73 stratagus/src/video/cursor.c:1.74
--- stratagus/src/video/cursor.c:1.73 Tue Oct 21 17:33:53 2003
+++ stratagus/src/video/cursor.c Wed Oct 22 14:02:35 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: cursor.c,v 1.73 2003/10/21 21:33:53 jsalmon3 Exp $
+// $Id: cursor.c,v 1.74 2003/10/22 18:02:35 jsalmon3 Exp $
//@{
@@ -709,6 +709,7 @@
int h;
int mask;
const Viewport* vp;
+ int frame;
// Align to grid
vp = TheUI.MouseViewport;
@@ -720,14 +721,13 @@
//
// Draw building
//
+ frame = CursorBuilding->Animations->Still[0].Frame +
+ (CursorBuilding->Building ? 0 : CursorBuilding->NumDirections / 2 + 1 -
1);
PushClipping();
SetClipping(vp->X, vp->Y, vp->EndX, vp->EndY);
- DrawShadow(NULL, CursorBuilding, x, y);
+ DrawShadow(NULL, CursorBuilding, frame, x, y);
GraphicPlayerPixels(ThisPlayer, CursorBuilding->Sprite);
- DrawUnitType(CursorBuilding,
- CursorBuilding->Animations->Still[0].Frame +
- (CursorBuilding->Building ? 0 : CursorBuilding->NumDirections / 2 +
1 - 1),
- x, y);
+ DrawUnitType(CursorBuilding, frame, x, y);
PopClipping();
//
@@ -1121,7 +1121,7 @@
int i;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.73 2003/10/21
21:33:53 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.74 2003/10/22
18:02:35 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/construct.c clone/unit_draw...,
Jimmy Salmon <=