Skip to content

Commit

Permalink
Enhancements to Collection UI
Browse files Browse the repository at this point in the history
  • Loading branch information
gmoromisato committed Dec 16, 2018
1 parent 7e36e92 commit e3fea15
Show file tree
Hide file tree
Showing 17 changed files with 295 additions and 184 deletions.
8 changes: 4 additions & 4 deletions Include/CloudInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ICIService
virtual ALERROR InitFromXML (CXMLElement *pDesc, bool *retbModified) { *retbModified = false; return NOERROR; }
virtual ALERROR InitPrivateData (void) { return NOERROR; }
virtual ALERROR LoadNews (ITaskProcessor *pProcessor, CMultiverseModel &Multiverse, const SFileVersionInfo &AppVersion, const CString &sCacheFilespec, CString *retsResult = NULL) { return NOERROR; }
virtual ALERROR LoadUserCollection (ITaskProcessor *pProcessor, CMultiverseModel &Multiverse, CString *retsResult = NULL) { return NOERROR; }
virtual ALERROR LoadUserCollection (ITaskProcessor *pProcessor, CExtensionCollection &Extensions, CMultiverseModel &Multiverse, CString *retsResult = NULL) { return NOERROR; }
virtual ALERROR PostCrashReport (ITaskProcessor *pProcessor, const CString &sCrash, CString *retsResult = NULL) { return NOERROR; }
virtual ALERROR PostGameRecord (ITaskProcessor *pProcessor, const CGameRecord &Record, const CGameStats &Stats, CString *retsResult = NULL) { return NOERROR; }
virtual ALERROR ProcessDownloads (ITaskProcessor *pProcessor, CString *retsResult = NULL) { return NOERROR; }
Expand Down Expand Up @@ -116,7 +116,7 @@ class CCloudService
ALERROR DownloadUpgrade (ITaskProcessor *pProcessor, const CString &sUpgradeURL, CString *retsResult = NULL);
ALERROR Housekeeping (ITaskProcessor *pProcessor);
ALERROR LoadNews (ITaskProcessor *pProcessor, CMultiverseModel &Multiverse, const SFileVersionInfo &AppVersion, const CString &sCacheFilespec, CString *retsResult = NULL);
ALERROR LoadUserCollection (ITaskProcessor *pProcessor, CMultiverseModel &Multiverse, CString *retsResult = NULL);
ALERROR LoadUserCollection (ITaskProcessor *pProcessor, CExtensionCollection &Extensions, CMultiverseModel &Multiverse, CString *retsResult = NULL);
ALERROR PostCrashReport (ITaskProcessor *pProcessor, const CString &sCrash, CString *retsResult = NULL);
ALERROR PostGameRecord (ITaskProcessor *pProcessor, const CGameRecord &Record, const CGameStats &Stats, CString *retsResult = NULL);
ALERROR ProcessDownloads (ITaskProcessor *pProcessor, CString *retsResult = NULL);
Expand All @@ -141,12 +141,12 @@ class CCloudService
class CHexarcServiceFactory : public ICIServiceFactory
{
public:
virtual ICIService *Create (CHumanInterface &HI);
virtual ICIService *Create (CHumanInterface &HI) override;
};

class CXelerusServiceFactory : public ICIServiceFactory
{
public:
virtual ICIService *Create (CHumanInterface &HI);
virtual ICIService *Create (CHumanInterface &HI) override;
};

2 changes: 1 addition & 1 deletion Include/SteamUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CSteamService : public ICIService
virtual CString GetUsername (void) override { return m_sUsername; }
virtual bool HasCapability (DWORD dwCapability) override;
virtual ALERROR InitFromXML (CXMLElement *pDesc, bool *retbModified) override;
virtual ALERROR LoadUserCollection (ITaskProcessor *pProcessor, CMultiverseModel &Multiverse, CString *retsResult = NULL) override;
virtual ALERROR LoadUserCollection (ITaskProcessor *pProcessor, CExtensionCollection &Extensions, CMultiverseModel &Multiverse, CString *retsResult = NULL) override;
virtual ALERROR PostGameRecord (ITaskProcessor *pProcessor, const CGameRecord &Record, const CGameStats &Stats, CString *retsResult = NULL) override;
virtual ALERROR ReadHighScoreList (ITaskProcessor *pProcessor, DWORD dwAdventure, CAdventureHighScoreList *retHighScores, CString *retsResult = NULL) override;
virtual ALERROR SignInUser (ITaskProcessor *pProcessor, const CString &sUsername, const CString &sPassword, bool bAutoSignIn, CString *retsResult = NULL) override;
Expand Down
5 changes: 3 additions & 2 deletions Include/TSEDesign.h
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,10 @@ class CExtensionCollection
inline bool LoadedInDebugMode (void) { return m_bLoadedInDebugMode; }
ALERROR LoadNewExtension (const CString &sFilespec, const CIntegerIP &FileDigest, CString *retsError);
inline void SetCollectionFolder (const CString &sFilespec) { m_sCollectionFolder = sFilespec; }
void SetRegisteredExtensions (const CMultiverseCollection &Collection);
void SetExtensionEnabled (DWORD dwUNID, bool bEnabled);
void SweepImages (void);
void UpdateCollectionStatus (CMultiverseCollection &Collection, int cxIconSize, int cyIconSize);
void UpdateCollectionStatus (TArray<CMultiverseCatalogEntry *> &Collection, int cxIconSize, int cyIconSize);
void UpdateRegistrationStatus (const TArray<CMultiverseCatalogEntry *> &Collection);

static int Compare (CExtension *pExt1, CExtension *pExt2, bool bDebugMode);

Expand Down
46 changes: 23 additions & 23 deletions Include/TSEMultiverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,17 @@ class CMultiverseCatalogEntry
CString sDesc;
};

CMultiverseCatalogEntry (const CMultiverseCatalogEntry &Src);
~CMultiverseCatalogEntry (void);
~CMultiverseCatalogEntry (void)
{
char *pPos = NULL;
}

static ALERROR CreateBasicEntry (const SEntryCreate &Create, CMultiverseCatalogEntry **retpEntry);
static ALERROR CreateFromJSON (const CJSONValue &Entry, CMultiverseCatalogEntry **retpEntry, CString *retsResult);

inline const CString &GetDesc (void) const { return m_sDesc; }
inline CG32bitImage *GetIcon (void) const { return m_pIcon; }
inline CG32bitImage *GetIconHandoff (void) { CG32bitImage *pIcon = m_pIcon; m_pIcon = NULL; return pIcon; }
inline CG32bitImage *GetIconHandoff (void) { return (m_pIcon ? new CG32bitImage(*m_pIcon) : new CG32bitImage()); }
inline ELicenseTypes GetLicenseType (void) const { return m_iLicenseType; }
inline const CString &GetName (void) const { return m_sName; }
inline DWORD GetRelease (void) const { return m_dwRelease; }
Expand All @@ -86,34 +89,29 @@ class CMultiverseCatalogEntry
inline DWORD GetUNID (void) const { return m_dwUNID; }
inline const CString &GetVersion (void) const { return m_sVersion; }
bool IsValid (void);
void SetIcon (CG32bitImage *pImage);
void SetIcon (CG32bitImage *&pImage);
inline void SetStatus (ELocalStatus iStatus, const CString &sStatus = NULL_STR) { m_iStatus = iStatus; m_sStatus = sStatus; }
inline void SetVersion (const CString &sVersion) { m_sVersion = sVersion; }

private:
CMultiverseCatalogEntry (void) :
m_iLicenseType(licenseUnknown),
m_iStatus(statusUnknown),
m_pIcon(NULL)
{ }

CString m_sUNID; // Fully qualified UNID
DWORD m_dwRelease; // Catalog entry release
DWORD m_dwVersion; // Catalog entry version
CString m_sVersion; // User-visible version
EExtensionTypes m_iType; // Type of extension
CString m_sUNID; // Fully qualified UNID
DWORD m_dwRelease = 0; // Catalog entry release
DWORD m_dwVersion = 0; // Catalog entry version
CString m_sVersion; // User-visible version
EExtensionTypes m_iType = extUnknown; // Type of extension

CString m_sName; // Name of extension
CString m_sDesc; // Description
CMultiverseFileRef m_TDBFile; // Reference to TDB file.
ELicenseTypes m_iLicenseType; // Type of license
CString m_sName; // Name of extension
CString m_sDesc; // Description
CMultiverseFileRef m_TDBFile; // Reference to TDB file.
ELicenseTypes m_iLicenseType = licenseUnknown; // Type of license

TArray<CMultiverseFileRef> m_Resources;

DWORD m_dwUNID; // UNID
ELocalStatus m_iStatus; // Current status
CString m_sStatus; // Status message
CG32bitImage *m_pIcon; // 200x100 image
DWORD m_dwUNID = 0; // UNID
ELocalStatus m_iStatus = statusUnknown; // Current status
CString m_sStatus; // Status message
TSharedPtr<CG32bitImage> m_pIcon; // 200x100 image
};

class CMultiverseCollection
Expand Down Expand Up @@ -235,6 +233,7 @@ class CMultiverseModel

CMultiverseModel (void);

bool FindEntry (DWORD dwUNID, CMultiverseCatalogEntry *retEntry = NULL) const;
ALERROR GetCollection (CMultiverseCollection *retCollection) const;
ALERROR GetEntry (DWORD dwUNID, DWORD dwRelease, CMultiverseCollection *retCollection) const;
CMultiverseNewsEntry *GetNextNewsEntry (void);
Expand All @@ -250,7 +249,7 @@ class CMultiverseModel
void OnUserSignedIn (const CString &sUsername);
void OnUserSignedOut (void);
ALERROR Save (const CString &sCacheFilespec, CString *retsResult = NULL) { return m_News.Save(sCacheFilespec, retsResult); }
ALERROR SetCollection (const CJSONValue &Data, CString *retsResult);
ALERROR SetCollection (const CJSONValue &Data, CExtensionCollection &Extensions, CString *retsResult);
ALERROR SetCollection (const TArray<CMultiverseCatalogEntry *> &NewCollection);
void SetDisabled (void);
ALERROR SetNews (const CJSONValue &Data, const CString &sCacheFilespec, TSortMap<CString, CString> *retDownloads, CString *retsResult);
Expand All @@ -269,6 +268,7 @@ class CMultiverseModel

void AddResources (const CMultiverseCatalogEntry &Entry);
void DeleteCollection (void);
bool LockCollection (void) const;
void SetUpgradeVersion (const CJSONValue &Entry);

mutable CCriticalSection m_cs; // Protects access to all data
Expand Down
4 changes: 2 additions & 2 deletions Include/TSUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class IHISession : public IHICommand, public IAniCommand
// Reanimator interface
inline void AddPerformance (IAnimatron *pAni, const CString &sID) { m_Reanimator.AddPerformance(pAni, sID); }
inline void DeleteElement (const CString &sID) { m_Reanimator.DeleteElement(sID); }
inline IAnimatron *GetElement (const CString &sID) { return m_Reanimator.GetElement(sID); }
inline IAnimatron *GetElement (const CString &sID) const { return m_Reanimator.GetElement(sID); }
inline IAnimatron *GetPerformance (const CString &sID, int *retiFrame = NULL) { return m_Reanimator.GetPerformance(sID, retiFrame); }
inline bool GetPropertyBool (const CString &sID, const CString &sProp) { return m_Reanimator.GetPropertyBool(sID, sProp); }
inline CG32bitPixel GetPropertyColor (const CString &sID, const CString &sProp) { return m_Reanimator.GetPropertyColor(sID, sProp); }
Expand Down Expand Up @@ -593,7 +593,7 @@ class CVisualPalette : public IFontTable
const CG32bitImage *pImage,
DWORD dwOptions,
IAnimatron **retpControl) const;
void CreateLink (CAniSequencer *pContainer,
void CreateLink (IAnimatron *pContainer,
const CString &sID,
int x,
int y,
Expand Down
1 change: 1 addition & 0 deletions Include/TSUISettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CExtensionListMap
inline const TSortMap<DWORD, bool> &GetDisabledExtensionList (void) const { return m_Disabled; }
void GetList (DWORD dwAdventure, bool bDebugMode, TArray<DWORD> *retList) const;
void GetList (DWORD dwAdventure, const TArray<CExtension *> &Available, bool bDebugMode, TArray<DWORD> *retList) const;
void SetExtensionEnabled (DWORD dwUNID, bool bEnabled);
void SetList (DWORD dwAdventure, const TArray<CExtension *> &Available, bool bDebugMode, const TArray<DWORD> &List);
ALERROR ReadFromXML (CXMLElement *pDesc);
ALERROR WriteAsXML (IWriteStream *pOutput);
Expand Down
12 changes: 10 additions & 2 deletions Include/UIHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ class CItemDataAnimatron : public IAnimatron
class CListCollectionTask : public IHITask
{
public:
static constexpr DWORD FLAG_NO_COLLECTION_REFRESH = 0x00000001;
static constexpr DWORD FLAG_LOAD_EXTENSIONS = 0x00000002;
static constexpr DWORD FLAG_DEBUG_MODE = 0x00000004;

CListCollectionTask (CHumanInterface &HI,
CExtensionCollection &Extensions,
CMultiverseModel &Multiverse,
CCloudService &Service,
int cxWidth,
bool bNoCollectionRefresh = false,
bool bDebugMode = false);
DWORD dwFlags = 0);
~CListCollectionTask (void);

inline IAnimatron *GetListHandoff (void) { IAnimatron *pResult = m_pList; m_pList = NULL; return pResult; }
Expand All @@ -52,12 +55,14 @@ class CListCollectionTask : public IHITask

private:
void CreateEntry (CMultiverseCatalogEntry *pCatalogEntry, int yStart, IAnimatron **retpEntry, int *retcyHeight);
void LoadCollectionExtensions (void);

CExtensionCollection &m_Extensions;
CMultiverseModel &m_Multiverse;
CCloudService &m_Service;
int m_cxWidth;
bool m_bNoCollectionRefresh;
bool m_bLoadExtensions;
bool m_bDebugMode;

CAniListBox *m_pList;
Expand Down Expand Up @@ -145,6 +150,8 @@ class CUIHelper
static constexpr DWORD MENU_ALIGN_CENTER = 0x00000002; // Align center
static constexpr DWORD MENU_ALIGN_LEFT = 0x00000004; // Align left
static constexpr DWORD MENU_ALIGN_RIGHT = 0x00000008; // Align right
static constexpr DWORD MENU_HIDDEN = 0x00000010;
static constexpr DWORD MENU_DISABLED = 0x00000020;

struct SMenuEntry
{
Expand Down Expand Up @@ -209,6 +216,7 @@ class CUIHelper
void PaintItemEntry (CG32bitImage &Dest, CSpaceObject *pSource, const CItem &Item, const RECT &rcRect, CG32bitPixel rgbText, DWORD dwOptions) const;
void PaintReferenceDamageAdj (CG32bitImage &Dest, int x, int y, int iLevel, int iHP, const int *iDamageAdj, CG32bitPixel rgbText) const;
void PaintReferenceDamageType (CG32bitImage &Dest, int x, int y, int iDamageType, const CString &sRef, CG32bitPixel rgbText) const;
void RefreshMenu (IHISession *pSession, IAnimatron *pRoot, const TArray<SMenuEntry> &Menu) const;

static int ScrollAnimationDecay (int iOffset);

Expand Down
2 changes: 1 addition & 1 deletion SteamUtil/CSteamService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ ALERROR CSteamService::InitFromXML (CXMLElement *pDesc, bool *retbModified)
return NOERROR;
}

ALERROR CSteamService::LoadUserCollection (ITaskProcessor *pProcessor, CMultiverseModel &Multiverse, CString *retsResult)
ALERROR CSteamService::LoadUserCollection (ITaskProcessor *pProcessor, CExtensionCollection &Extensions, CMultiverseModel &Multiverse, CString *retsResult)

// LoadUserCollection
//
Expand Down
116 changes: 63 additions & 53 deletions TSE/CExtensionCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,15 +1906,12 @@ ALERROR CExtensionCollection::LoadFolderStubsOnly (const CString &sFilespec, CEx

if (iFolder == CExtension::folderCollection
&& m_DisabledExtensions.Find(pExtension->GetUNID()))
{
delete pExtension;
continue;
}
pExtension->SetDisabled(CONSTLIT("Disabled"));

// If this extension requires an API beyond our base file, then we disable it.
// This can happen when we do TransData on older Transcendence.tdb.

if (!pExtension->IsDisabled()
else if (!pExtension->IsDisabled()
&& pExtension->GetAPIVersion() > m_pBase->GetAPIVersion())
pExtension->SetDisabled(CONSTLIT("Requires a newer version of Transcendence.tdb"));

Expand Down Expand Up @@ -2048,56 +2045,17 @@ bool CExtensionCollection::ReloadDisabledExtensions (DWORD dwFlags)
return bSuccess;
}

void CExtensionCollection::SetRegisteredExtensions (const CMultiverseCollection &Collection)
void CExtensionCollection::SetExtensionEnabled (DWORD dwUNID, bool bEnabled)

// SetRegisteredExtensions
// SetExtensionEnabled
//
// Given the user's collection, set the registered bit on all appropriate
// extensions and return a list of extensions that need to be downloaded.
// Add or removes an extension from the disabled list.

{
CSmartLock Lock(m_cs);
int i;

for (i = 0; i < Collection.GetCount(); i++)
{
CMultiverseCatalogEntry *pEntry = Collection.GetEntry(i);

// Skip core entries

if (pEntry->GetLicenseType() == CMultiverseCatalogEntry::licenseCore)
continue;

// Skip Steam UGC

if (pEntry->GetLicenseType() == CMultiverseCatalogEntry::licenseSteamUGC)
continue;

// Look for this extension in our list. If we found it then compare
// the signature to make sure that we have the right version.

CExtension *pExtension;
if (FindExtension(pEntry->GetUNID(), pEntry->GetRelease(), CExtension::folderCollection, &pExtension))
{
// Steam versions are always verified

if (pEntry->GetLicenseType() == CMultiverseCatalogEntry::licenseSteam)
pExtension->SetVerified();

// Compare the digests. If they match, then this is a registered
// extension.

else if (pEntry->GetTDBFileRef().GetDigest() == pExtension->GetDigest())
pExtension->SetVerified();

// If this is an unregistered version, then check to see if the version
// number is the same. If not, the we re-download.

else if (!pExtension->IsRegistered()
&& strEquals(pEntry->GetTDBFileRef().GetVersion(), pExtension->GetVersion()))
{ }
}
}
if (bEnabled)
m_DisabledExtensions.DeleteAt(dwUNID);
else
m_DisabledExtensions.SetAt(dwUNID, true);
}

void CExtensionCollection::SweepImages (void)
Expand All @@ -2118,7 +2076,7 @@ void CExtensionCollection::SweepImages (void)
DEBUG_CATCH
}

void CExtensionCollection::UpdateCollectionStatus (CMultiverseCollection &Collection, int cxIconSize, int cyIconSize)
void CExtensionCollection::UpdateCollectionStatus (TArray<CMultiverseCatalogEntry *> &Collection, int cxIconSize, int cyIconSize)

// UpdateCollectionStatus
//
Expand All @@ -2130,7 +2088,7 @@ void CExtensionCollection::UpdateCollectionStatus (CMultiverseCollection &Collec

for (i = 0; i < Collection.GetCount(); i++)
{
CMultiverseCatalogEntry *pEntry = Collection.GetEntry(i);
CMultiverseCatalogEntry *pEntry = Collection[i];
CExtension *pExtension;

// Figure out which folder to look in
Expand Down Expand Up @@ -2177,6 +2135,58 @@ void CExtensionCollection::UpdateCollectionStatus (CMultiverseCollection &Collec
}
}

void CExtensionCollection::UpdateRegistrationStatus (const TArray<CMultiverseCatalogEntry *> &Collection)

// UpdateRegistrationStatus
//
// Given the user's collection, set the registered bit on all appropriate
// extensions and return a list of extensions that need to be downloaded.

{
CSmartLock Lock(m_cs);
int i;

for (i = 0; i < Collection.GetCount(); i++)
{
CMultiverseCatalogEntry *pEntry = Collection[i];

// Skip core entries

if (pEntry->GetLicenseType() == CMultiverseCatalogEntry::licenseCore)
continue;

// Skip Steam UGC

if (pEntry->GetLicenseType() == CMultiverseCatalogEntry::licenseSteamUGC)
continue;

// Look for this extension in our list. If we found it then compare
// the signature to make sure that we have the right version.

CExtension *pExtension;
if (FindExtension(pEntry->GetUNID(), pEntry->GetRelease(), CExtension::folderCollection, &pExtension))
{
// Steam versions are always verified

if (pEntry->GetLicenseType() == CMultiverseCatalogEntry::licenseSteam)
pExtension->SetVerified();

// Compare the digests. If they match, then this is a registered
// extension.

else if (pEntry->GetTDBFileRef().GetDigest() == pExtension->GetDigest())
pExtension->SetVerified();

// If this is an unregistered version, then check to see if the version
// number is the same. If not, the we re-download.

else if (!pExtension->IsRegistered()
&& strEquals(pEntry->GetTDBFileRef().GetVersion(), pExtension->GetVersion()))
{ }
}
}
}

// CLibraryResolver -----------------------------------------------------------

void CLibraryResolver::AddDefaults (CExtension *pExtension)
Expand Down
Loading

0 comments on commit e3fea15

Please sign in to comment.