____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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"
#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 | |
Definition in file mainscr.cpp.
| #define MESSAGES_MAX 10 |
How many can be displayed.
Definition at line 405 of file mainscr.cpp.
Referenced by MessagesDisplay::AddMessage(), and SetMessageEvent().
| 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 | ) |
Draw the timer.
Clear costs in status line.
Definition at line 836 of file mainscr.cpp.
References SetCosts().
Referenced by CancelBuildingMode(), CButtonPanel::DoClicked(), DoSelectionButtons(), SelectionChanged(), UiBeginInput(), UiFindIdleWorker(), UIHandleButtonUp(), UISelectStateButtonDown(), and UpdateStatusLineForButton().
| void DrawCosts | ( | void | ) |
Set costs to be displayed in status line.
Draw costs in status line.
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] |
Draw info panel with more than one unit selected
Definition at line 848 of file mainscr.cpp.
References ButtonAreaSelected, ButtonAreaUnderCursor, ButtonUnderCursor, CIcon::DrawUnitIcon(), IconConfig::Icon, CUnitType::Icon, IconActive, LeftButton, CUserInterface::MaxSelectedFont, CUserInterface::MaxSelectedTextX, CUserInterface::MaxSelectedTextY, MouseButtons, NumSelected, Selected, CUserInterface::SelectedButtons, CStatusLine::Set(), CUserInterface::StatusLine, CUIButton::Style, ThisPlayer, CUnit::Type, UI, UiDrawLifeBar(), VideoDrawText(), CUIButton::X, and CUIButton::Y.
Referenced by CInfoPanel::Draw().
| static void DrawInfoPanelNoneSelected | ( | ) | [static] |
Draw info panel with no units selected
Definition at line 889 of file mainscr.cpp.
References CPlayer::Allied, ColorWhite, CYCLES_PER_SECOND, CVideo::DrawRectangle(), DrawUnitInfo(), CPlayer::Enemy, CVideo::FillRectangle(), FontGreen, FontRed, GameCycle, GameFont, GetDefaultTextColors(), CPlayer::Index, CUserInterface::InfoPanel, CUnit::IsVisible(), PlayerMax, PlayerNobody, Players, SetDefaultTextColors(), ThisPlayer, UI, UnitUnderCursor, Video, VideoDrawNumber(), VideoDrawText(), VideoSyncSpeed, CInfoPanel::X, CInfoPanel::Y, and y.
Referenced by CInfoPanel::Draw().
| 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 | ) |
Update messages.
Draw menu button area.
Definition at line 68 of file mainscr.cpp.
References ButtonAreaMenu, ButtonAreaUnderCursor, ButtonUnderCursor, ButtonUnderMenu, ButtonUnderNetworkDiplomacy, ButtonUnderNetworkMenu, DrawMenuButton(), GameDiplomacyButtonClicked, GameMenuButtonClicked, IsNetworkGame, CUserInterface::MenuButton, MI_FLAGS_ACTIVE, MI_FLAGS_CLICKED, CUserInterface::NetworkDiplomacyButton, CUserInterface::NetworkMenuButton, CUIButton::Style, CUIButton::Text, UI, CUIButton::X, and CUIButton::Y.
Referenced by UpdateDisplay().
| 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.
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] |
Draw training units
Definition at line 213 of file mainscr.cpp.
References ButtonAreaTraining, ButtonAreaUnderCursor, ButtonUnderCursor, IconActive, LeftButton, MouseButtons, CUnit::OrderCount, CUnit::Orders, CUnit::Player, CUserInterface::SingleTrainingButton, CUserInterface::SingleTrainingFont, CUserInterface::SingleTrainingText, CUserInterface::SingleTrainingTextX, CUserInterface::SingleTrainingTextY, CUIButton::Style, CUserInterface::TrainingButtons, CUserInterface::TrainingFont, CUserInterface::TrainingText, CUserInterface::TrainingTextX, CUserInterface::TrainingTextY, UI, UnitActionTrain, VideoDrawText(), VideoDrawTextCentered(), CUIButton::X, and CUIButton::Y.
Referenced by DrawUnitInfo().
| static void DrawTransportingUnits | ( | const CUnit * | unit | ) | [static] |
Draw transporting units
Definition at line 255 of file mainscr.cpp.
References ButtonAreaTransporting, ButtonAreaUnderCursor, ButtonUnderCursor, IconActive, CUnit::InsideCount, LeftButton, MANA_INDEX, MouseButtons, CUnit::NextContained, CUnit::Player, CStatusLine::Set(), CUserInterface::StatusLine, CUIButton::Style, CUserInterface::TransportingButtons, UI, UiDrawLifeBar(), UiDrawManaBar(), CUnit::UnitInside, CUIButton::X, and CUIButton::Y.
Referenced by DrawUnitInfo().
| static void DrawUnitInfo | ( | CUnit * | unit | ) | [static] |
Draw the unit info in the info panel. Called when a single unit is selected or the mouse hovers over a unit.
| unit | Pointer to unit. |
Definition at line 290 of file mainscr.cpp.
References CUnit::BoardCount, ButtonAreaSelected, ButtonAreaUnderCursor, ButtonUnderCursor, CUnitType::CanHarvestFrom, CUnitType::CanTransport, CYCLES_PER_SECOND, DefaultResourceNames, DrawTrainingUnits(), DrawTransportingUnits(), CIcon::DrawUnitIcon(), DrawUnitStats(), GameFont, HP_INDEX, IconConfig::Icon, CUnitType::Icon, IconActive, CUserInterface::InfoPanel, CUnit::IsEnemy(), LeftButton, CVariable::Max, MaxCosts, MouseButtons, CUnitType::Name, NumSelected, CUnit::Orders, CUnit::Player, PlayerNeutral, CUnit::ResourcesHeld, Selected, CUserInterface::SingleSelectedButton, SmallFont, CUIButton::Style, ThisPlayer, CUnit::Type, CPlayer::Type, UI, UiDrawLifeBar(), UnitActionBuilt, UnitActionTrain, UpdateUnitVariables(), CVariable::Value, CUnit::Variable, VideoDrawTextCentered(), CUIButton::X, CInfoPanel::X, CUIButton::Y, CInfoPanel::Y, and y.
Referenced by DrawInfoPanelNoneSelected(), and DrawInfoPanelSingleSelected().
| static void DrawUnitStats | ( | const CUnit * | unit | ) | [static] |
Draw unit stats
Definition at line 162 of file mainscr.cpp.
References _, ARMOR_INDEX, ATTACKRANGE_INDEX, BASICDAMAGE_INDEX, CUnitType::CanAttack, GameFont, CUserInterface::InfoPanel, KILL_INDEX, MANA_INDEX, CVariable::Max, PIERCINGDAMAGE_INDEX, RADAR_INDEX, SIGHTRANGE_INDEX, CUnit::Type, UI, CVariable::Value, CUnit::Variable, CUnitType::Variable, VideoDrawText(), VideoDrawTextCentered(), CInfoPanel::X, CInfoPanel::Y, and y.
Referenced by DrawUnitInfo().
| void SetCosts | ( | int | mana, | |
| const int * | costs | |||
| ) |
Clear the costs displayed in status line (undisplay!).
Set costs in status line.
| 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.
| 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.
| 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.
| 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.
| 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().
MessagesDisplay allmessages [static] |
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().
1.5.6