mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 08:24:16 +00:00
Implement AddPresenter, RemovePresenter, StopPresenters (#124)
* Add MxList, MxPresenterList, add to MxMediaManager * Match ~MxList<T> * Implement AddPresenter, RemovePresenter, StopPresenters * Initial implementation of RemovePresenter/Find/Detach * Implement/match MxMediaManager::StopPresenters * Move definitions out of class body * Match RemovePresenter/Detach * Fix style * Fix merge error * Fix merge error * Fix merge error * Remove space
This commit is contained in:

committed by
GitHub

parent
253538feed
commit
b819657bd8
118
LEGO1/mxlist.h
118
LEGO1/mxlist.h
@@ -5,13 +5,14 @@
|
||||
#include "mxcore.h"
|
||||
|
||||
template <class T>
|
||||
// SIZE 0xc
|
||||
class MxListEntry
|
||||
{
|
||||
public:
|
||||
MxListEntry<T>() {}
|
||||
MxListEntry<T>(T *p_obj) {
|
||||
MxListEntry() {}
|
||||
MxListEntry(T *p_obj, MxListEntry *p_prev) {
|
||||
m_obj = p_obj;
|
||||
m_prev = NULL;
|
||||
m_prev = p_prev;
|
||||
m_next = NULL;
|
||||
}
|
||||
|
||||
@@ -56,9 +57,54 @@ public:
|
||||
}
|
||||
|
||||
virtual ~MxList();
|
||||
|
||||
void Append(T*);
|
||||
|
||||
friend class MxListCursor<T>;
|
||||
|
||||
protected:
|
||||
MxListEntry<T> *m_first; // +0x10
|
||||
MxListEntry<T> *m_last; // +0x14
|
||||
|
||||
private:
|
||||
void _DeleteEntry(MxListEntry<T> *match);
|
||||
};
|
||||
|
||||
// VTABLE 0x100d6488
|
||||
template <class T>
|
||||
class MxListCursor : public MxCore
|
||||
{
|
||||
public:
|
||||
MxListCursor(MxList<T> *p_list) {
|
||||
m_list = p_list;
|
||||
m_match = NULL;
|
||||
}
|
||||
|
||||
MxBool Find(T *p_obj);
|
||||
void Detach();
|
||||
MxBool Next(T*& p_obj);
|
||||
|
||||
private:
|
||||
MxList<T> *m_list;
|
||||
MxListEntry<T> *m_match;
|
||||
};
|
||||
|
||||
// Unclear purpose
|
||||
// VTABLE 0x100d6530
|
||||
template <class T>
|
||||
class MxListCursorChild : public MxListCursor<T>
|
||||
{
|
||||
public:
|
||||
MxListCursorChild(MxList<T> *p_list) : MxListCursor<T>(p_list) {}
|
||||
};
|
||||
|
||||
// Unclear purpose
|
||||
// VTABLE 0x100d6470
|
||||
template <class T>
|
||||
class MxListCursorChildChild : public MxListCursorChild<T>
|
||||
{
|
||||
public:
|
||||
MxListCursorChildChild(MxList<T> *p_list) : MxListCursorChild<T>(p_list) {}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@@ -80,4 +126,70 @@ MxList<T>::~MxList()
|
||||
m_first = NULL;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void MxList<T>::Append(T *p_newobj)
|
||||
{
|
||||
MxListEntry<T> *currentLast = this->m_last;
|
||||
MxListEntry<T> *newEntry = new MxListEntry<T>(p_newobj, currentLast);
|
||||
|
||||
if (currentLast)
|
||||
currentLast->m_next = newEntry;
|
||||
else
|
||||
this->m_first = newEntry;
|
||||
|
||||
this->m_last = newEntry;
|
||||
this->m_count++;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void MxList<T>::_DeleteEntry(MxListEntry<T> *match)
|
||||
{
|
||||
MxListEntry<T> **pPrev = &match->m_prev;
|
||||
MxListEntry<T> **pNext = &match->m_next;
|
||||
|
||||
if (match->m_prev)
|
||||
match->m_prev->m_next = *pNext;
|
||||
else
|
||||
m_first = *pNext;
|
||||
|
||||
if (*pNext)
|
||||
(*pNext)->m_prev = *pPrev;
|
||||
else
|
||||
m_last = *pPrev;
|
||||
|
||||
delete match;
|
||||
m_count--;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline MxBool MxListCursor<T>::Find(T *p_obj)
|
||||
{
|
||||
for (m_match = m_list->m_first;
|
||||
m_match && m_list->Compare(m_match->m_obj, p_obj);
|
||||
m_match = m_match->m_next);
|
||||
|
||||
return m_match != NULL;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void MxListCursor<T>::Detach()
|
||||
{
|
||||
m_list->_DeleteEntry(m_match);
|
||||
m_match = NULL;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline MxBool MxListCursor<T>::Next(T*& p_obj)
|
||||
{
|
||||
if (!m_match)
|
||||
m_match = m_list->m_first;
|
||||
else
|
||||
m_match = m_match->m_next;
|
||||
|
||||
if (m_match)
|
||||
p_obj = m_match->m_obj;
|
||||
|
||||
return m_match != NULL;
|
||||
}
|
||||
|
||||
#endif // MXLIST_H
|
Reference in New Issue
Block a user