stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src include/stratagus.h unit/unit_draw.c


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src include/stratagus.h unit/unit_draw.c
Date: 17 Jan 2004 05:40:04 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/17 05:40:03

Modified files:
        src/include    : stratagus.h 
        src/unit       : unit_draw.c 

Log message:
        Fixed SelectionColor bug

Patches:
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.35 
stratagus/src/include/stratagus.h:1.36
--- stratagus/src/include/stratagus.h:1.35      Sat Jan 17 05:17:20 2004
+++ stratagus/src/include/stratagus.h   Sat Jan 17 05:40:02 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: stratagus.h,v 1.35 2004/01/16 18:17:20 nobody_ Exp $
+//      $Id: stratagus.h,v 1.36 2004/01/16 18:40:02 nobody_ Exp $
 
 #ifndef __STRATAGUS_H__
 #define __STRATAGUS_H__
@@ -42,6 +42,9 @@
 
 // New unit cache
 #define NEW_UNIT_CACHE
+
+// New Lua scripting.
+// #define META_LUA
 
        //
        //              Default speed for many things, set it higher for faster 
actions.
Index: stratagus/src/unit/unit_draw.c
diff -u stratagus/src/unit/unit_draw.c:1.209 
stratagus/src/unit/unit_draw.c:1.210
--- stratagus/src/unit/unit_draw.c:1.209        Sat Jan 17 05:17:26 2004
+++ stratagus/src/unit/unit_draw.c      Sat Jan 17 05:40:03 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unit_draw.c,v 1.209 2004/01/16 18:17:26 nobody_ Exp $
+//      $Id: unit_draw.c,v 1.210 2004/01/16 18:40:03 nobody_ Exp $
 
 //@{
 
@@ -108,44 +108,6 @@
 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 /**
-**             Choose color for selection.
-**
-**             @param unit             Pointer to the unit.
-**
-**             @return                         Color for selection, or NULL if 
not selected.
-*/
-local Uint32 SelectionColor(const Unit* unit)
-{
-       // FIXME: make these colors customizable with scripts.
-
-       if (EditorRunning && unit == UnitUnderCursor &&
-                       EditorState == EditorSelecting) {
-               return ColorWhite;
-       }
-
-       if (unit->Selected || (unit->Blink & 1)) {
-               if (unit->Player->Player == PlayerNumNeutral) {
-                       return ColorYellow;
-               }
-               // FIXME: better allied?
-               if (unit->Player == ThisPlayer) {
-                       return ColorGreen;
-               }
-               if (IsEnemy(ThisPlayer, unit)) {
-                       return ColorRed;
-               }
-               return unit->Player->Color;
-       }
-
-       // If building mark all own buildings
-       if (CursorBuilding && unit->Type->Building &&
-                       unit->Player == ThisPlayer) {
-               return ColorGray;
-       }
-       return 0;
-}
-
-/**
 **             Show selection marker around an unit.
 **
 **             @param unit             Pointer to unit.
@@ -159,16 +121,36 @@
 
        type = unit->Type;
 
-       color = SelectionColor(unit);
-       if (color) {
-               x = Map2ViewportX(CurrentViewport, unit->X) + unit->IX +
-                       type->TileWidth * TileSizeX / 2 - type->BoxWidth / 2 -
-                       (type->Width - VideoGraphicWidth(type->Sprite)) / 2;
-               y = Map2ViewportY(CurrentViewport, unit->Y) + unit->IY +
-                       type->TileHeight * TileSizeY / 2 - type->BoxHeight/2 -
-                       (type->Height - VideoGraphicHeight(type->Sprite)) / 2;
-               DrawSelection(color, x, y, x + type->BoxWidth, y + 
type->BoxHeight);
+       // FIXME: make these colors customizable with scripts.
+
+       if (EditorRunning && unit == UnitUnderCursor &&
+                       EditorState == EditorSelecting) {
+               color = ColorWhite;
+       } else if (unit->Selected || (unit->Blink & 1)) {
+               if (unit->Player->Player == PlayerNumNeutral) {
+                       color = ColorYellow;
+               } else if (unit->Player == ThisPlayer) {
+                       // FIXME: better allied?
+                       color = ColorGreen;
+               } else if (IsEnemy(ThisPlayer, unit)) {
+                       color = ColorRed;
+               } else {
+                       color = unit->Player->Color;
+               }
+       } else if (CursorBuilding && unit->Type->Building && unit->Player == 
ThisPlayer) {
+               // If building mark all own buildings
+               color = ColorGray;
+       } else {
+               return;
        }
+
+       x = Map2ViewportX(CurrentViewport, unit->X) + unit->IX +
+               type->TileWidth * TileSizeX / 2 - type->BoxWidth / 2 -
+               (type->Width - VideoGraphicWidth(type->Sprite)) / 2;
+       y = Map2ViewportY(CurrentViewport, unit->Y) + unit->IY +
+               type->TileHeight * TileSizeY / 2 - type->BoxHeight/2 -
+               (type->Height - VideoGraphicHeight(type->Sprite)) / 2;
+       DrawSelection(color, x, y, x + type->BoxWidth, y + type->BoxHeight);
 }
 
 /**
@@ -649,7 +631,7 @@
 {
 #if 0
        CLprintf(file, "\n;;; -----------------------------------------\n");
-       CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.209 
2004/01/16 18:17:26 nobody_ Exp $\n\n");
+       CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.210 
2004/01/16 18:40:03 nobody_ Exp $\n\n");
 
        CLprintf(file, "(mana-sprite \"%s\"  %d %d  %d %d)\n",
                ManaSprite.File, ManaSprite.HotX, ManaSprite.HotY,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]