ProtoBot
Loading...
Searching...
No Matches
TimerManager Class Reference

Public Types

enum  Module {
  All , Economy , Scouting , Build ,
  Combat , Information , Strategy , MapTools ,
  NumModules
}

Public Member Functions

void startTimer (const TimerManager::Module module)
void stopTimer (const TimerManager::Module module)
void displayTimers (int x, int y)
double getTotalElapsed ()

Private Attributes

std::vector< TimermoduleTimers
std::string timerNames [8] = {"All", "Economy", "Scouting", "Build", "Combat", "Information", "Strategy", "MapTools"}
int moduleBarWidth = 0

Detailed Description

Definition at line 8 of file TimerManager.h.

Member Enumeration Documentation

◆ Module

enum TimerManager::Module

Definition at line 15 of file TimerManager.h.

15{All, Economy, Scouting, Build, Combat, Information, Strategy, MapTools, NumModules};

Constructor & Destructor Documentation

◆ TimerManager()

TimerManager::TimerManager ( )

Definition at line 3 of file TimerManager.cpp.

3 : moduleTimers(std::vector<Timer>(NumModules)), moduleBarWidth(40)
4{
5
6}

Member Function Documentation

◆ displayTimers()

void TimerManager::displayTimers ( int x,
int y )

Definition at line 23 of file TimerManager.cpp.

24{
25 BWAPI::Broodwar->drawBoxScreen(x - 5, y - 5, x + 110 + moduleBarWidth, y + 5 + (10 * moduleTimers.size()), BWAPI::Colors::Black, true);
26
27 int yskip = 0;
28 const double total = moduleTimers[0].getElapsedTimeInMilliSec();
29 for (size_t i(0); i < moduleTimers.size(); ++i)
30 {
31 const double elapsed = moduleTimers[i].getElapsedTimeInMilliSec();
32 if (elapsed > 85)
33 {
34 BWAPI::Broodwar->printf("Timer Debug (frame %d): %s %lf", BWAPI::Broodwar->getFrameCount(), timerNames[i].c_str(), elapsed);
35 }
36
37 int width = (int)((elapsed == 0) ? 0 : (moduleBarWidth * (elapsed / total)));
38
39 BWAPI::Broodwar->drawTextScreen(x, y + yskip - 3, "\x04 %s", timerNames[i].c_str());
40 BWAPI::Broodwar->drawBoxScreen(x + 60, y + yskip, x + 60 + width + 1, y + yskip + 8, BWAPI::Colors::White);
41 BWAPI::Broodwar->drawTextScreen(x + 70 + moduleBarWidth, y + yskip - 3, "%.4lf", elapsed);
42 yskip += 10;
43 }
44}

◆ getTotalElapsed()

double TimerManager::getTotalElapsed ( )

Definition at line 18 of file TimerManager.cpp.

19{
20 return moduleTimers[0].getElapsedTimeInMilliSec();
21}

◆ startTimer()

void TimerManager::startTimer ( const TimerManager::Module module)

Definition at line 8 of file TimerManager.cpp.

9{
10 moduleTimers[module].start();
11}

◆ stopTimer()

void TimerManager::stopTimer ( const TimerManager::Module module)

Definition at line 13 of file TimerManager.cpp.

14{
15 moduleTimers[module].stop();
16}

Member Data Documentation

◆ moduleBarWidth

int TimerManager::moduleBarWidth = 0
private

Definition at line 12 of file TimerManager.h.

◆ moduleTimers

std::vector<Timer> TimerManager::moduleTimers
private

Definition at line 10 of file TimerManager.h.

◆ timerNames

std::string TimerManager::timerNames[8] = {"All", "Economy", "Scouting", "Build", "Combat", "Information", "Strategy", "MapTools"}
private

Definition at line 11 of file TimerManager.h.

11{"All", "Economy", "Scouting", "Build", "Combat", "Information", "Strategy", "MapTools"};

The documentation for this class was generated from the following files: