$treeview $search $mathjax
Stratagus  2.2.6
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
           Stratagus - A free fantasy real time strategy game engine

src/unit/unit_draw.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include <vector>
#include "video.h"
#include "sound.h"
#include "unitsound.h"
#include "editor.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "tileset.h"
#include "map.h"
#include "construct.h"
#include "cursor.h"
#include "interface.h"
#include "font.h"
#include "ui.h"
#include "script.h"

Classes

class  Decoration
class  DecoSpriteType

unit_draw.cpp - The draw routines for units.

static DecoSpriteType DecoSprite
unsigned long ShowOrdersCount
 All sprite's infos.
void(* DrawSelection )(Uint32 color, int x1, int y1, int x2, int y2) = DrawSelectionNone
 Show orders for some time.
const CViewportCurrentViewport
 Config: reveal attacker enabled.
static int s_min (int a, int b)
static int s_max (int a, int b)
void DrawUnitSelection (const CViewport *vp, const CUnit &unit)
 FIXME: quick hack for split screen.
void DrawSelectionNone (Uint32, int, int, int, int)
 Draw nothing around unit.
void DrawSelectionCircle (Uint32 color, int x1, int y1, int x2, int y2)
 Draw circle around unit.
void DrawSelectionCircleWithTrans (Uint32 color, int x1, int y1, int x2, int y2)
 Draw circle filled with alpha around unit.
void DrawSelectionRectangle (Uint32 color, int x1, int y1, int x2, int y2)
 Draw rectangle around unit.
void DrawSelectionRectangleWithTrans (Uint32 color, int x1, int y1, int x2, int y2)
 Draw rectangle filled with alpha around unit.
void DrawSelectionCorners (Uint32 color, int x1, int y1, int x2, int y2)
 Draw corners around unit.
int GetSpriteIndex (const char *SpriteName)
static int CclDefineSprites (lua_State *l)
void DecorationCclRegister ()
 Register CCL decorations features.
void LoadDecorations ()
 Load the decorations (health,mana) of units.
void CleanDecorations ()
 Clean the decorations (health,mana) of units.
void UpdateUnitVariables (const CUnit &unit)
 Update custom Variables with other variable (like Hp, ...).
static void DrawDecoration (const CUnit &unit, const CUnitType *type, int x, int y)
void DrawShadow (const CUnitType &type, int frame, int x, int y)
 Draw unit's shadow.
static void GetOrderPosition (const CUnit &unit, const COrderPtr order, int *x, int *y)
static void ShowSingleOrder (const CUnit &unit, int x1, int y1, const COrderPtr order)
void ShowOrder (const CUnit &unit)
 Show a unit's orders.
static void DrawInformations (const CUnit &unit, const CUnitType *type, int x, int y)
static void DrawConstructionShadow (const CUnitType &type, const CConstructionFrame *cframe, int frame, int x, int y)
static void DrawConstruction (const int player, const CConstructionFrame *cframe, const CUnitType &type, int frame, int x, int y)
static bool DrawLevelCompare (const CUnit *c1, const CUnit *c2)
int FindAndSortUnits (const CViewport *vp, CUnit *table[])
 Draw all units visible on map in viewport.
int FindAndSortUnits (const CViewport *vp, CUnitDrawProxy table[])

Defines

#define CORNER_PIXELS   6

Define Documentation

#define CORNER_PIXELS   6


Function Documentation

static int CclDefineSprites ( lua_State *  l  )  [static]

Define the sprite to show variables.

Parameters:
l Lua_state

void CleanDecorations (  ) 

Clean the decorations (health,mana) of units.

Clean decorations.

void DecorationCclRegister (  ) 

Register CCL decorations features.

Register CCL features for decorations.

static void DrawConstruction ( const int  player,
const CConstructionFrame cframe,
const CUnitType type,
int  frame,
int  x,
int  y 
) [static]

Draw construction.

Parameters:
unit Unit pointer.
cframe Construction frame to draw.
type Unit type.
frame Frame number.
x X position.
y Y position.

static void DrawConstructionShadow ( const CUnitType type,
const CConstructionFrame cframe,
int  frame,
int  x,
int  y 
) [static]

Draw construction shadow.

Parameters:
unit Unit pointer.
cframe Construction frame
frame Frame number to draw.
x X position.
y Y position.

static void DrawDecoration ( const CUnit unit,
const CUnitType type,
int  x,
int  y 
) [static]

Draw decoration (invis, for the unit.)

Parameters:
unit Pointer to the unit.
type Type of the unit.
x Screen X position of the unit.
y Screen Y position of the unit.

static void DrawInformations ( const CUnit unit,
const CUnitType type,
int  x,
int  y 
) [static]

Draw additional informations of a unit.

Parameters:
unit Unit pointer of drawn unit.
type Unit-type pointer.
x X screen pixel position of unit.
y Y screen pixel position of unit.
Todo:
FIXME: The different styles should become a function call.

static bool DrawLevelCompare ( const CUnit c1,
const CUnit c2 
) [inline, static]

Compare what order 2 units should be drawn on the map

Parameters:
c1 First Unit to compare (*Unit)
c2 Second Unit to compare (*Unit)

void DrawSelectionCircle ( Uint32  color,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draw circle around unit.

Show selected units with circle.

Parameters:
color Color to draw circle
x1,y1 Coordinates of the top left corner.
x2,y2 Coordinates of the bottom right corner.

void DrawSelectionCircleWithTrans ( Uint32  color,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draw circle filled with alpha around unit.

Show selected units with circle.

Parameters:
color Color to draw and fill circle.
x1,y1 Coordinates of the top left corner.
x2,y2 Coordinates of the bottom right corner.

void DrawSelectionCorners ( Uint32  color,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draw corners around unit.

Draw selected corners around the unit.

Parameters:
color Color to draw corners.
x1,y1 Coordinates of the top left corner.
x2,y2 Coordinates of the bottom right corner.

void DrawSelectionNone ( Uint32  ,
int  ,
int  ,
int  ,
int   
)

Draw nothing around unit.

Don't show selected units.

Parameters:
color Color to draw, nothing in this case.
x1,y1 Coordinates of the top left corner.
x2,y2 Coordinates of the bottom right corner.

void DrawSelectionRectangle ( Uint32  color,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draw rectangle around unit.

Draw selected rectangle around the unit.

Parameters:
color Color to draw rectangle.
x1,y1 Coordinates of the top left corner.
x2,y2 Coordinates of the bottom right corner.

void DrawSelectionRectangleWithTrans ( Uint32  color,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draw rectangle filled with alpha around unit.

Draw selected rectangle around the unit.

Parameters:
color Color to draw and fill rectangle.
x1,y1 Coordinates of the top left corner.
x2,y2 Coordinates of the bottom right corner.

void DrawShadow ( const CUnitType type,
int  frame,
int  x,
int  y 
)

Draw unit's shadow.

Draw unit's shadow.

Parameters:
type Pointer to the unit type.
frame Frame number
x Screen X position of the unit.
y Screen Y position of the unit.
Todo:
FIXME: combine new shadow code with old shadow code.

void DrawUnitSelection ( const CViewport vp,
const CUnit unit 
)

FIXME: quick hack for split screen.

CurrentViewport.

Show selection marker around a unit.

Parameters:
unit Pointer to unit.

int FindAndSortUnits ( const CViewport vp,
CUnitDrawProxy  table[] 
)

int FindAndSortUnits ( const CViewport vp,
CUnit table[] 
)

Draw all units visible on map in viewport.

Find all units to draw in viewport.

Parameters:
vp Viewport to be drawn.
table Table of units to return in sorted order

static void GetOrderPosition ( const CUnit unit,
const COrderPtr  order,
int *  x,
int *  y 
) [static]

Get the location of a unit's order.

Parameters:
unit Pointer to unit.
order Pointer to order.
x Resulting screen X cordinate.
y Resulting screen Y cordinate.

int GetSpriteIndex ( const char *  SpriteName  ) 

Return the index of the sprite named SpriteName.

Parameters:
SpriteName Name of the sprite.
Returns:
Index of the sprite. -1 if not found.

void LoadDecorations (  ) 

Load the decorations (health,mana) of units.

Load decoration.

static int s_max ( int  a,
int  b 
) [inline, static]

static int s_min ( int  a,
int  b 
) [inline, static]

void ShowOrder ( const CUnit unit  ) 

Show a unit's orders.

Show the current order of a unit.

Parameters:
unit Pointer to the unit.

static void ShowSingleOrder ( const CUnit unit,
int  x1,
int  y1,
const COrderPtr  order 
) [static]

Show the order on map.

Parameters:
unit Unit pointer.
x1 X pixel coordinate.
y1 Y pixel coordinate.
order Order to display.

void UpdateUnitVariables ( const CUnit unit  ) 

Update custom Variables with other variable (like Hp, ...).

Update unit variables which are not user defined.


Variable Documentation

Config: reveal attacker enabled.

void(* DrawSelection)(Uint32 color, int x1, int y1, int x2, int y2) = DrawSelectionNone

Show orders for some time.

Show that units are selected.

Parameters:
color FIXME
x1,y1 Coordinates of the top left corner.
x2,y2 Coordinates of the bottom right corner.

unsigned long ShowOrdersCount

All sprite's infos.

Number of units used.

(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.