____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

mainscr.cpp File Reference

The main screen. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include <sstream>
#include "stratagus.h"
#include "video.h"
#include "font.h"
#include "sound.h"
#include "unitsound.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "upgrade.h"
#include "icons.h"
#include "interface.h"
#include "ui.h"
#include "map.h"
#include "trigger.h"
#include "network.h"
#include "menus.h"
#include "spells.h"

Go to the source code of this file.

Classes

class  MessagesDisplay

Defines

#define MESSAGES_MAX   10
 How many can be displayed.

Functions

void DrawMenuButtonArea (void)
 Update messages.
static void UiDrawLifeBar (const CUnit *unit, int x, int y)
static void UiDrawManaBar (const CUnit *unit, int x, int y)
static void DrawUnitStats (const CUnit *unit)
static void DrawTrainingUnits (const CUnit *unit)
static void DrawTransportingUnits (const CUnit *unit)
static void DrawUnitInfo (CUnit *unit)
void DrawResources (void)
 Set message to display.
void UpdateMessages ()
 Draw messages as overlay over of the map.
void CleanMessages ()
 Draw costs in status line.
void DrawMessages ()
 Draw the player resource in resource line.
void SetMessage (const char *fmt,...)
 Set message to display with event point.
void ShiftMessagesEvent (void)
void SetMessageEvent (int x, int y, const char *fmt,...)
 Center view-point on last event message.
void CenterOnMessage (void)
 Cleanup all messages.
void DrawCosts (void)
 Set costs to be displayed in status line.
void SetCosts (int mana, const int *costs)
 Clear the costs displayed in status line (undisplay!).
void ClearCosts (void)
 Draw the timer.
static void DrawInfoPanelMultipleSelected ()
static void DrawInfoPanelSingleSelected ()
static void DrawInfoPanelNoneSelected ()
void DrawTimer (void)
 Update the timer.
void UpdateTimer (void)
 Update the status line with hints from the button.

Variables

static char MessagesEvent [MESSAGES_MAX][64]
 Array of event messages.
static int MessagesEventX [MESSAGES_MAX]
 X coordinate of event.
static int MessagesEventY [MESSAGES_MAX]
 Y coordinate of event.
static int MessagesEventCount
 Number of event messages.
static int MessagesEventIndex
 Current event index.
static MessagesDisplay allmessages
static int CostsMana
 mana cost to display in status line
static int Costs [MaxCosts]
 costs to display in status line


Detailed Description

The main screen.

Definition in file mainscr.cpp.


Define Documentation

#define MESSAGES_MAX   10

How many can be displayed.

Definition at line 405 of file mainscr.cpp.

Referenced by MessagesDisplay::AddMessage(), and SetMessageEvent().


Function Documentation

void CenterOnMessage ( void   ) 

Cleanup all messages.

Goto message origin.

Definition at line 722 of file mainscr.cpp.

References _, CViewport::Center(), MessagesEvent, MessagesEventCount, MessagesEventIndex, MessagesEventX, MessagesEventY, CUserInterface::SelectedViewport, SetMessage(), TileSizeX, TileSizeY, and UI.

Referenced by CommandKey().

void CleanMessages ( void   ) 

Draw costs in status line.

Clean messages

Definition at line 643 of file mainscr.cpp.

References MessagesDisplay::CleanMessages().

Referenced by CleanGame(), and CleanModules().

void ClearCosts ( void   ) 

void DrawCosts ( void   ) 

Set costs to be displayed in status line.

Draw costs in status line.

Todo:
FIXME: make DrawCosts more configurable.

Definition at line 791 of file mainscr.cpp.

References Costs, CostsMana, CYCLES_PER_SECOND, CGraphic::DrawFrameClip(), EnergyCost, CResourceInfo::G, GameFont, CResourceInfo::IconFrame, MaxCosts, CUserInterface::Resources, CUserInterface::StatusLine, CStatusLine::TextX, CStatusLine::TextY, UI, Video, VideoDrawNumber(), and CVideo::Width.

Referenced by UpdateDisplay().

static void DrawInfoPanelMultipleSelected (  )  [static]

static void DrawInfoPanelNoneSelected (  )  [static]

static void DrawInfoPanelSingleSelected (  )  [static]

Draw info panel with one unit selected

Definition at line 878 of file mainscr.cpp.

References ButtonAreaSelected, ButtonAreaUnderCursor, ButtonUnderCursor, DrawUnitInfo(), Selected, CStatusLine::Set(), CUserInterface::StatusLine, and UI.

Referenced by CInfoPanel::Draw().

void DrawMenuButtonArea ( void   ) 

void DrawMessages ( void   ) 

Draw the player resource in resource line.

Draw messages

Definition at line 651 of file mainscr.cpp.

References MessagesDisplay::DrawMessages().

Referenced by UpdateDisplay().

void DrawResources ( void   ) 

Set message to display.

Draw the player resource in top line.

Todo:
FIXME: make DrawResources more configurable (format, font).

Definition at line 373 of file mainscr.cpp.

References _, CYCLES_PER_SECOND, GameFont, MaxCosts, CPlayer::ProductionRate, CPlayer::RequestedUtilizationRate, sprintf_s(), CPlayer::StorageCapacity, CPlayer::StoredResources, ThisPlayer, and VideoDrawText().

Referenced by UpdateDisplay().

void DrawTimer ( void   ) 

Update the timer.

Draw the timer

Definition at line 955 of file mainscr.cpp.

References CTimer::Cycles, CYCLES_PER_SECOND, CUITimer::Font, GameTimer, CTimer::Init, sprintf_s(), CUserInterface::Timer, UI, VideoDrawText(), CUITimer::X, and CUITimer::Y.

Referenced by UpdateDisplay().

static void DrawTrainingUnits ( const CUnit unit  )  [static]

static void DrawTransportingUnits ( const CUnit unit  )  [static]

static void DrawUnitInfo ( CUnit unit  )  [static]

static void DrawUnitStats ( const CUnit unit  )  [static]

void SetCosts ( int  mana,
const int *  costs 
)

Clear the costs displayed in status line (undisplay!).

Set costs in status line.

Parameters:
mana Mana costs.
costs Resource costs, NULL pointer if all are zero.

Definition at line 823 of file mainscr.cpp.

References Costs, CostsMana, and MaxCosts.

Referenced by ClearCosts(), and UpdateStatusLineForButton().

void SetMessage ( const char *  fmt,
  ... 
)

Set message to display with event point.

Set message to display.

Parameters:
fmt To be displayed in text overlay.

Definition at line 661 of file mainscr.cpp.

References MessagesDisplay::AddUniqueMessage().

Referenced by CclAddMessage(), CenterOnMessage(), CommandQuit(), HandleCheats(), HandleKeyModifiersDown(), NetworkEvent(), NetworkRecover(), ParseNetworkCommand(), and ReplayEachCycle().

void SetMessageEvent ( int  x,
int  y,
const char *  fmt,
  ... 
)

Center view-point on last event message.

Set message to display.

Parameters:
x Message X map origin.
y Message Y map origin.
fmt To be displayed in text overlay.

Definition at line 695 of file mainscr.cpp.

References MessagesDisplay::AddUniqueMessage(), MESSAGES_MAX, MessagesEvent, MessagesEventCount, MessagesEventIndex, MessagesEventX, MessagesEventY, ShiftMessagesEvent(), and strcpy_s().

Referenced by CPlayer::Notify().

void ShiftMessagesEvent ( void   ) 

Shift messages events array by one.

Definition at line 676 of file mainscr.cpp.

References MessagesEvent, MessagesEventCount, MessagesEventX, MessagesEventY, and strcpy_s().

Referenced by SetMessageEvent().

static void UiDrawLifeBar ( const CUnit unit,
int  x,
int  y 
) [static]

Draw life bar of a unit at x,y. Placed under icons on top-panel.

Parameters:
unit Pointer to unit.
x Screen X postion of icon
y Screen Y postion of icon

Definition at line 111 of file mainscr.cpp.

References ColorBlack, ColorDarkGreen, ColorOrange, ColorRed, ColorYellow, CVideo::FillRectangleClip(), CIcon::G, CGraphic::Height, HP_INDEX, IconConfig::Icon, CUnitType::Icon, CVariable::Max, CUnit::Type, CVariable::Value, CUnit::Variable, Video, and CGraphic::Width.

Referenced by DrawInfoPanelMultipleSelected(), DrawTransportingUnits(), and DrawUnitInfo().

static void UiDrawManaBar ( const CUnit unit,
int  x,
int  y 
) [static]

Draw mana bar of a unit at x,y. Placed under icons on top-panel.

Parameters:
unit Pointer to unit.
x Screen X postion of icon
y Screen Y postion of icon

Definition at line 145 of file mainscr.cpp.

References ColorBlack, ColorBlue, CVideo::FillRectangleClip(), CIcon::G, CGraphic::Height, IconConfig::Icon, CUnitType::Icon, MANA_INDEX, CVariable::Max, CUnit::Stats, CUnit::Type, CVariable::Value, CUnit::Variable, CUnitStats::Variables, Video, and CGraphic::Width.

Referenced by DrawTransportingUnits().

void UpdateMessages ( void   ) 

Draw messages as overlay over of the map.

Update messages

Definition at line 636 of file mainscr.cpp.

References MessagesDisplay::UpdateMessages().

Referenced by GameMainLoop().

void UpdateTimer ( void   ) 

Update the status line with hints from the button.

Update the timer

Definition at line 978 of file mainscr.cpp.

References CTimer::Cycles, GameCycle, GameTimer, CTimer::Increasing, CTimer::LastUpdate, and CTimer::Running.

Referenced by GameMainLoop().


Variable Documentation

Definition at line 631 of file mainscr.cpp.

int Costs[MaxCosts] [static]

costs to display in status line

Definition at line 784 of file mainscr.cpp.

Referenced by DrawCosts(), and SetCosts().

int CostsMana [static]

mana cost to display in status line

Definition at line 783 of file mainscr.cpp.

Referenced by DrawCosts(), and SetCosts().

char MessagesEvent[MESSAGES_MAX][64] [static]

Array of event messages.

Definition at line 407 of file mainscr.cpp.

Referenced by CenterOnMessage(), SetMessageEvent(), and ShiftMessagesEvent().

int MessagesEventCount [static]

Number of event messages.

Definition at line 410 of file mainscr.cpp.

Referenced by CenterOnMessage(), MessagesDisplay::CleanMessages(), SetMessageEvent(), and ShiftMessagesEvent().

int MessagesEventIndex [static]

Current event index.

Definition at line 411 of file mainscr.cpp.

Referenced by CenterOnMessage(), MessagesDisplay::CleanMessages(), and SetMessageEvent().

int MessagesEventX[MESSAGES_MAX] [static]

X coordinate of event.

Definition at line 408 of file mainscr.cpp.

Referenced by CenterOnMessage(), SetMessageEvent(), and ShiftMessagesEvent().

int MessagesEventY[MESSAGES_MAX] [static]

Y coordinate of event.

Definition at line 409 of file mainscr.cpp.

Referenced by CenterOnMessage(), SetMessageEvent(), and ShiftMessagesEvent().


Generated on Sat Feb 21 00:28:17 2009 for Bos Wars by  doxygen 1.5.6