Skip to content

Commit

Permalink
Added progress dialog to show plugins loading
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Jul 14, 2011
1 parent a387512 commit 727d41e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dialogs/ProgDlg.cpp
Expand Up @@ -27,6 +27,7 @@ CProgressDlg::CProgressDlg(UINT nCaptionID)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bParentDisabled = FALSE;
m_bHideCancel = FALSE;
}

CProgressDlg::~CProgressDlg()
Expand Down Expand Up @@ -212,5 +213,8 @@ BOOL CProgressDlg::OnInitDialog()
m_Progress.SetStep(m_nStep);
m_Progress.SetPos(m_nLower);

if (m_bHideCancel)
GetDlgItem (IDCANCEL)->ShowWindow (SW_HIDE);

return TRUE;
}
2 changes: 2 additions & 0 deletions dialogs/ProgDlg.h
Expand Up @@ -26,6 +26,8 @@ class CProgressDlg : public CDialog
int OffsetPos(int nPos);
int StepIt();

bool m_bHideCancel;

// Dialog Data
//{{AFX_DATA(CProgressDlg)
enum { IDD = CG_IDD_PROGRESS };
Expand Down
39 changes: 39 additions & 0 deletions xml/xml_load_world.cpp
Expand Up @@ -7,6 +7,7 @@
#include "..\MUSHview.h"
#include "..\genprint.h"
#include "..\mainfrm.h"
#include "..\dialogs\ProgDlg.h"

/*
Expand Down Expand Up @@ -594,10 +595,46 @@ POSITION lpos;
for (lpos = m_strCurrentIncludeFileList.GetHeadPosition (); lpos; )
strIncludeList.AddTail (m_strCurrentIncludeFileList.GetNext (lpos));

int iCount = 0;

if (bPlugins)
{
for (POSITION nodepos = (parent).ChildrenList.GetHeadPosition (); nodepos; )
{
CXMLelement * node = (parent).ChildrenList.GetNext (nodepos);
if (node->strName == "include" && !node->bUsed)
iCount++;
}
}

CProgressDlg * pDlg = NULL;

if (iCount)
{
pDlg = new CProgressDlg;
pDlg->m_bHideCancel = true;
pDlg->Create ();
pDlg->SetRange (0, iCount);
pDlg->SetStep (1);
pDlg->SetWindowText (Translate ("Loading plugins ..."));
}

// see if we have "include" tag(s)

LOAD_LOOP (parent, "include", pIncludeElement);

if (pDlg)
{
Get_XML_string (*pIncludeElement, "name", strFileName, false, true);

int iSlash = strFileName.ReverseFind ('\\');
if (iSlash != -1)
strFileName = strFileName.Mid (iSlash + 1);

pDlg->SetStatus (TFormat ("Loading plugin: %s", (LPCTSTR) strFileName));
pDlg->StepIt ();
}

try
{
Load_One_Include_XML (*pIncludeElement,
Expand All @@ -623,6 +660,8 @@ POSITION lpos;

END_LOAD_LOOP;

delete pDlg;

// restore current include list tree
m_strCurrentIncludeFileList.RemoveAll ();
for (lpos = strIncludeList.GetHeadPosition (); lpos; )
Expand Down

0 comments on commit 727d41e

Please sign in to comment.