OpenClonk
C4StartupModsDownloader Class Reference

#include <C4StartupModsDlg.h>

Inheritance diagram for C4StartupModsDownloader:
[legend]
Collaboration diagram for C4StartupModsDownloader:
[legend]

Public Member Functions

 C4StartupModsDownloader (C4StartupModsDlg *parent, const C4StartupModsListEntry *entry)
 
 ~C4StartupModsDownloader ()
 
void AddModToQueue (std::string modID, std::string name)
 
void RequestConfirmation ()
 
void OnConfirmInstallation (C4GUI::Element *element)
 
virtual void OnThreadEvent (C4InteractiveEventType eEvent, void *pEventData)
 

Protected Member Functions

void Set ()
 
void SetDelay (uint32_t inDelay)
 
bool CheckAndReset ()
 
C4TimeMilliseconds GetNextTick (C4TimeMilliseconds tNow) override
 
uint32_t TimerInterval () override
 
void Changed ()
 
bool ExecuteUntil (int iTimeout=-1)
 
virtual void GetFDs (std::vector< struct pollfd > &)
 
bool IsSignaled ()
 
virtual bool IsLowPriority ()
 
virtual bool IsNotify ()
 

Detailed Description

Definition at line 138 of file C4StartupModsDlg.h.

Constructor & Destructor Documentation

◆ C4StartupModsDownloader()

C4StartupModsDownloader::C4StartupModsDownloader ( C4StartupModsDlg parent,
const C4StartupModsListEntry entry 
)

Definition at line 521 of file C4StartupModsDlg.cpp.

521  : CStdTimerProc(30)
522 {
523  this->parent = parent;
524 
525  if (entry != nullptr)
526  items.emplace_back(std::move(std::make_unique<ModInfo>(entry)));
527 
528  // Register timer.
529  Application.Add(this);
530 }
C4Application Application
Definition: C4Globals.cpp:44
CStdTimerProc(uint32_t iDelay)
Definition: StdScheduler.h:94
void Add(StdSchedulerProc *pProc)

References StdScheduler::Add(), and Application.

Here is the call graph for this function:

◆ ~C4StartupModsDownloader()

C4StartupModsDownloader::~C4StartupModsDownloader ( )

Definition at line 540 of file C4StartupModsDlg.cpp.

541 {
542  CStdLock lock(&guiThreadResponse);
543  Application.Remove(this);
544  CancelRequest();
545 }
void Remove(StdSchedulerProc *pProc)

References Application, and StdScheduler::Remove().

Here is the call graph for this function:

Member Function Documentation

◆ AddModToQueue()

void C4StartupModsDownloader::AddModToQueue ( std::string  modID,
std::string  name 
)

Definition at line 532 of file C4StartupModsDlg.cpp.

533 {
534  // Not if already contained.
535  for (auto &mod : items)
536  if (mod->modID == modID) return;
537  items.emplace_back(std::move(std::make_unique<ModInfo>(modID, name)));
538 }

◆ Changed()

void StdSchedulerProc::Changed ( )
protectedinherited

Definition at line 108 of file StdScheduler.cpp.

109 {
110  auto s = scheduler;
111  if (s)
112  s->Changed(this);
113 }
#define s

References s.

Referenced by C4NetIOTCP::Accept(), C4NetIOTCP::AddConnectWait(), C4NetIOUDP::AddPeer(), C4NetIOTCP::Listen(), and CStdTimerProc::SetDelay().

Here is the caller graph for this function:

◆ CheckAndReset()

bool CStdTimerProc::CheckAndReset ( )
inlineinherited

Definition at line 107 of file StdScheduler.h.

108  {
110  if (tTime < tLastTimer + iDelay) return false;
111  // Compensate light drifting
112  int32_t iDrift = tTime - (tLastTimer + iDelay); // a positive time difference because of above check
113  tLastTimer = tTime - std::min(iDrift, (int32_t) iDelay / 2);
114  return true;
115  }
static C4TimeMilliseconds Now()

References C4TimeMilliseconds::Now().

Referenced by C4Network2::InitialConnect::Execute(), and C4ApplicationSec1Timer::Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExecuteUntil()

bool StdSchedulerProc::ExecuteUntil ( int  iTimeout = -1)
inherited

Definition at line 33 of file StdScheduler.cpp.

34 {
35  // Infinite?
36  if (iTimeout < 0)
37  for (;;)
38  if (!Execute())
39  return false;
40  // Calculate endpoint
41  C4TimeMilliseconds tStopTime = C4TimeMilliseconds::Now() + iTimeout;
42  for (;;)
43  {
44  // Call execute with given timeout
45  if (!Execute(std::max(iTimeout, 0)))
46  return false;
47  // Calculate timeout
49  if (tTime >= tStopTime)
50  break;
51  iTimeout = tStopTime - tTime;
52  }
53  // All ok.
54  return true;
55 }
virtual bool Execute(int iTimeout=-1, pollfd *readyfds=nullptr)=0

References StdSchedulerProc::Execute(), and C4TimeMilliseconds::Now().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFDs()

virtual void StdSchedulerProc::GetFDs ( std::vector< struct pollfd > &  )
inlinevirtualinherited

Reimplemented in C4FileMonitor, C4NetIOSimpleUDP, C4NetIOTCP, CStdNotifyProc, C4StdInProc, and C4HTTPClient.

Definition at line 72 of file StdScheduler.h.

72 { }

◆ GetNextTick()

C4TimeMilliseconds CStdTimerProc::GetNextTick ( C4TimeMilliseconds  tNow)
inlineoverridevirtualinherited

Reimplemented from StdSchedulerProc.

Definition at line 118 of file StdScheduler.h.

119  {
120  return tLastTimer + iDelay;
121  }

◆ IsLowPriority()

virtual bool StdSchedulerProc::IsLowPriority ( )
inlinevirtualinherited

Definition at line 82 of file StdScheduler.h.

82 { return false; }

◆ IsNotify()

virtual bool StdSchedulerProc::IsNotify ( )
inlinevirtualinherited

Reimplemented in CStdNotifyProc, and C4NetIO.

Definition at line 83 of file StdScheduler.h.

83 { return false; }

◆ IsSignaled()

bool StdSchedulerProc::IsSignaled ( )
inherited

◆ OnConfirmInstallation()

void C4StartupModsDownloader::OnConfirmInstallation ( C4GUI::Element element)

Definition at line 579 of file C4StartupModsDlg.cpp.

580 {
581  CStdLock lock(&guiThreadResponse);
582 
583  assert(!items.empty());
584  bool hasFile = false;
585  for (auto & item : items)
586  if (!item->files.empty()) hasFile = true;
587  assert(hasFile);
588 
589  GetProgressDialog()->SetTitle(LoadResStr("IDS_MODS_INSTALLANDDOWNLOAD"));
590  GetProgressDialog()->SetMessage("");
591  GetProgressDialog()->SetProgress(0);
592  GetProgressDialog()->SetVisibility(true);
593 
594  progressCallback = std::bind(&C4StartupModsDownloader::ExecuteCheckDownloadProgress, this);
595 }
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void SetVisibility(bool fToValue) override
void SetTitle(const char *szToTitle, bool fShowCloseButton=true)
void SetProgress(int32_t iToProgress)
Definition: C4Gui.h:2379
void SetMessage(const char *szMessage)

References LoadResStr(), C4GUI::ProgressDialog::SetMessage(), C4GUI::ProgressDialog::SetProgress(), C4GUI::Dialog::SetTitle(), and C4GUI::Container::SetVisibility().

Here is the call graph for this function:

◆ OnThreadEvent()

virtual void C4StartupModsDownloader::OnThreadEvent ( C4InteractiveEventType  eEvent,
void *  pEventData 
)
inlinevirtual

Implements C4InteractiveThread::Callback.

Definition at line 245 of file C4StartupModsDlg.h.

245 {}

◆ RequestConfirmation()

void C4StartupModsDownloader::RequestConfirmation ( )

Definition at line 940 of file C4StartupModsDlg.cpp.

941 {
942  progressCallback = std::bind(&C4StartupModsDownloader::ExecutePreRequestChecks, this);
943 }

◆ Set()

void CStdTimerProc::Set ( )
inlineinherited

Definition at line 102 of file StdScheduler.h.

103  {
105  }

References C4TimeMilliseconds::NegativeInfinity.

Referenced by CStdTimerProc::~CStdTimerProc().

Here is the caller graph for this function:

◆ SetDelay()

void CStdTimerProc::SetDelay ( uint32_t  inDelay)
inlineinherited

Definition at line 106 of file StdScheduler.h.

106 { iDelay = inDelay; Changed(); }

References StdSchedulerProc::Changed().

Here is the call graph for this function:

◆ TimerInterval()

uint32_t CStdTimerProc::TimerInterval ( )
inlineoverridevirtualinherited

Reimplemented from StdSchedulerProc.

Definition at line 122 of file StdScheduler.h.

122 { return iDelay; }

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