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

Classes
unit_draw.cpp File Reference
#include <vector>
#include "stratagus.h"
#include "actions.h"
#include "action/action_build.h"
#include "action/action_built.h"
#include "action/action_upgradeto.h"
#include "construct.h"
#include "cursor.h"
#include "editor.h"
#include "font.h"
#include "interface.h"
#include "map.h"
#include "player.h"
#include "script.h"
#include "settings.h"
#include "sound.h"
#include "translate.h"
#include "unit.h"
#include "unit_find.h"
#include "unitsound.h"
#include "unittype.h"
#include "ui.h"
#include "video.h"

Classes

class  Decoration
 
class  DecoSpriteType
 

unit_draw.cpp - The draw routines for units.

static DecoSpriteType DecoSprite
 
unsigned long ShowOrdersCount
 All sprite's infos. More...
 
unsigned long ShowNameDelay
 Show orders for some time. More...
 
unsigned long ShowNameTime
 Delay to show unit's name. More...
 
void(* DrawSelection )(IntColor color, int x1, int y1, int x2, int y2) = DrawSelectionNone
 Show unit's name for some time. More...
 
const CViewportCurrentViewport
 Config: spend resources for building with multiple workers. More...
 
static float DrawSelectionEllipseFactor = 0.0f
 
void(*)(IntColor, int, int, int, int) DrawSelectionEllipse (float factor)
 Draw ellipse around unit. More...
 
void DrawUnitSelection (const CViewport &vp, const CUnit &unit)
 FIXME: quick hack for split screen. More...
 
void DrawSelectionNone (IntColor, int, int, int, int)
 Draw nothing around unit. More...
 
void DrawSelectionCircle (IntColor color, int x1, int y1, int x2, int y2)
 Draw circle around unit. More...
 
void DrawSelectionCircleWithTrans (IntColor color, int x1, int y1, int x2, int y2)
 Draw circle filled with alpha around unit. More...
 
void DrawSelectionRectangle (IntColor color, int x1, int y1, int x2, int y2)
 Draw rectangle around unit. More...
 
void DrawSelectionRectangleWithTrans (IntColor color, int x1, int y1, int x2, int y2)
 Draw rectangle filled with alpha around unit. More...
 
void DrawSelectionCorners (IntColor color, int x1, int y1, int x2, int y2)
 Draw corners around unit. More...
 
void DrawSelectionEllipseFunc (IntColor color, int x1, int y1, int x2, int y2)
 
int GetSpriteIndex (const char *SpriteName)
 
static int CclDefineSprites (lua_State *l)
 
void DecorationCclRegister ()
 Register CCL decorations features. More...
 
void LoadDecorations ()
 Load the decorations (health,mana) of units. More...
 
void CleanDecorations ()
 Clean the decorations (health,mana) of units. More...
 
static void DrawDecoration (const CUnit &unit, const CUnitType &type, const PixelPos &screenPos)
 
void DrawShadow (const CUnitType &type, int frame, const PixelPos &screenPos)
 Draw unit's shadow. More...
 
void ShowOrder (const CUnit &unit)
 Show a unit's orders. More...
 
static void DrawInformations (const CUnit &unit, const CUnitType &type, const PixelPos &screenPos)
 
static void DrawConstructionShadow (const CUnitType &type, const CConstructionFrame *cframe, int frame, const PixelPos &screenPos)
 
static void DrawConstruction (const int player, const CConstructionFrame *cframe, const CUnitType &type, int frame, const PixelPos &screenPos)
 
static bool DrawLevelCompare (const CUnit *c1, const CUnit *c2)
 
int FindAndSortUnits (const CViewport &vp, std::vector< CUnit * > &table)
 Draw all units visible on map in viewport. More...
 

Function Documentation

◆ CclDefineSprites()

static int CclDefineSprites ( lua_State *  l)
static

Define the sprite to show variables.

Parameters
lLua_state

◆ CleanDecorations()

void CleanDecorations ( )

Clean the decorations (health,mana) of units.

Clean decorations.

◆ DecorationCclRegister()

void DecorationCclRegister ( )

Register CCL decorations features.

Register CCL features for decorations.

◆ DrawConstruction()

static void DrawConstruction ( const int  player,
const CConstructionFrame cframe,
const CUnitType type,
int  frame,
const PixelPos screenPos 
)
static

Draw construction.

Parameters
unitUnit pointer.
cframeConstruction frame to draw.
typeUnit type.
frameFrame number.
screenPosscreen (top left) position of the unit.

◆ DrawConstructionShadow()

static void DrawConstructionShadow ( const CUnitType type,
const CConstructionFrame cframe,
int  frame,
const PixelPos screenPos 
)
static

Draw construction shadow.

Parameters
unitUnit pointer.
cframeConstruction frame
frameFrame number to draw.
screenPosscreen (top left) position of the unit.

◆ DrawDecoration()

static void DrawDecoration ( const CUnit unit,
const CUnitType type,
const PixelPos screenPos 
)
static

Draw decoration (invis, for the unit.)

Parameters
unitPointer to the unit.
typeType of the unit.
screenPosScreen position of the unit.

◆ DrawInformations()

static void DrawInformations ( const CUnit unit,
const CUnitType type,
const PixelPos screenPos 
)
static

Draw additional informations of a unit.

Parameters
unitUnit pointer of drawn unit.
typeUnit-type pointer.
screenPosscreen pixel (top left) position of unit.
Todo:
FIXME: The different styles should become a function call.

◆ DrawLevelCompare()

static bool DrawLevelCompare ( const CUnit c1,
const CUnit c2 
)
inlinestatic

Compare what order 2 units should be drawn on the map

Parameters
c1First Unit to compare (*Unit)
c2Second Unit to compare (*Unit)

◆ DrawSelectionCircle()

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

Draw circle around unit.

Show selected units with circle.

Parameters
colorColor to draw circle
x1,y1Coordinates of the top left corner.
x2,y2Coordinates of the bottom right corner.

◆ DrawSelectionCircleWithTrans()

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

Draw circle filled with alpha around unit.

Show selected units with circle.

Parameters
colorColor to draw and fill circle.
x1,y1Coordinates of the top left corner.
x2,y2Coordinates of the bottom right corner.

◆ DrawSelectionCorners()

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

Draw corners around unit.

Draw selected corners around the unit.

Parameters
colorColor to draw corners.
x1,y1Coordinates of the top left corner.
x2,y2Coordinates of the bottom right corner.

◆ DrawSelectionEllipseFunc()

void DrawSelectionEllipseFunc ( IntColor  color,
int  x1,
int  y1,
int  x2,
int  y2 
)

◆ DrawSelectionNone()

void DrawSelectionNone ( IntColor  ,
int  ,
int  ,
int  ,
int   
)

Draw nothing around unit.

Don't show selected units.

Parameters
colorColor to draw, nothing in this case.
x1,y1Coordinates of the top left corner.
x2,y2Coordinates of the bottom right corner.

◆ DrawSelectionRectangle()

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

Draw rectangle around unit.

Draw selected rectangle around the unit.

Parameters
colorColor to draw rectangle.
x1,y1Coordinates of the top left corner.
x2,y2Coordinates of the bottom right corner.

◆ DrawSelectionRectangleWithTrans()

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

Draw rectangle filled with alpha around unit.

Draw selected rectangle around the unit.

Parameters
colorColor to draw and fill rectangle.
x1,y1Coordinates of the top left corner.
x2,y2Coordinates of the bottom right corner.

◆ DrawShadow()

void DrawShadow ( const CUnitType type,
int  frame,
const PixelPos screenPos 
)

Draw unit's shadow.

Draw unit's shadow.

Parameters
typePointer to the unit type.
frameFrame number
screenPosScreen position of the unit.
Todo:
FIXME: combine new shadow code with old shadow code.

◆ DrawUnitSelection()

void DrawUnitSelection ( const CViewport vp,
const CUnit unit 
)

FIXME: quick hack for split screen.

CurrentViewport.

Show selection marker around a unit.

Parameters
unitPointer to unit.

◆ FindAndSortUnits()

int FindAndSortUnits ( const CViewport vp,
std::vector< CUnit * > &  table 
)

Draw all units visible on map in viewport.

Find all units to draw in viewport.

Parameters
vpViewport to be drawn.
tableTable of units to return in sorted order

◆ GetSpriteIndex()

int GetSpriteIndex ( const char *  SpriteName)

Return the index of the sprite named SpriteName.

Parameters
SpriteNameName of the sprite.
Returns
Index of the sprite. -1 if not found.

◆ LoadDecorations()

void LoadDecorations ( )

Load the decorations (health,mana) of units.

Load decoration.

◆ ShowOrder()

void ShowOrder ( const CUnit unit)

Show a unit's orders.

Show the current order of a unit.

Parameters
unitPointer to the unit.

Variable Documentation

◆ CurrentViewport

const CViewport* CurrentViewport

Config: spend resources for building with multiple workers.

◆ DecoSprite

DecoSpriteType DecoSprite
static

◆ DrawSelection

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

Show unit's name for some time.

Show that units are selected.

Parameters
colorFIXME
x1,y1Coordinates of the top left corner.
x2,y2Coordinates of the bottom right corner.

◆ DrawSelectionEllipse

void(*)(IntColor, int, int, int, int) DrawSelectionEllipse(float factor)

Draw ellipse around unit.

◆ DrawSelectionEllipseFactor

float DrawSelectionEllipseFactor = 0.0f
static

Show selected units with ellipse. (Useful for fake-isometric views)

Parameters
colorColor to draw circle
x1,y1Coordinates of the top left corner.
x2,y2Coordinates of the bottom right corner.
factorStretch factor in horizontal direction

◆ ShowNameDelay

unsigned long ShowNameDelay

Show orders for some time.

◆ ShowNameTime

unsigned long ShowNameTime

Delay to show unit's name.

◆ ShowOrdersCount

unsigned long ShowOrdersCount

All sprite's infos.

Todo:
could be moved into the user interface ?
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.