Esempio n. 1
0
bool DebugDisplayLabelsHaveChanged(const ExtDebugInfo& l, const ExtDebugInfo& r)
{
	if (l.size() != r.size()) return true;

	// Check for matching labels
	ExtDebugReadIterator iter1 = l.begin();
	ExtDebugReadIterator iter2 = r.begin();

	for ( ; iter1 != l.end(); iter1++, iter2++) {
		// Check the items in the combo are still the same
		if (iter1->combo) {
			if (iter1->value != iter2->value)
				return true;			
		}
		else if (iter1->item != iter2->item)
			return true;
	}

	// They all matched!
	return false;
}
Esempio n. 2
0
void CWatchPage::RefreshWatch()
{
	if (!active || pausedUpdating) return;

	vector<WatchLine> curDisplay;
	ExtDebugInfo curDebug;
	ExpStore* unused;

	// Iterate watch objects
	Watch::iterator i = watch.begin();
	Watch::iterator watch_end = watch.end();

	// Delete destroying objects
	for ( ; i != watch_end; ) {
		bool increment = true;
		switch (i->first.type) {
		case WATCH_INSTANCE:
		case WATCH_INSTANCEPRIVATEVAR:
			if (i->first.obj->info.destroying) {
				i = watch.erase(i);
				increment = false;
			}
		}

		if (increment)
			i++;
	}

	for (i = watch.begin(); i != watch_end; i++) {

		// Get a debug list from this object
		curDebug.resize(0);
		pRuntime->curDebugOutput = &curDebug;

		CString source;

		switch(i->first.type) {
		case WATCH_OBJTYPE:
			source = i->first.objType->Name + " *";
			pRuntime->AddDebuggerItem("Instances", (int)i->first.objType->instances.size(), true);
			break;
		case WATCH_INSTANCE:
			{
			CRunObject* curObj = i->first.obj;
			CRunObjType* curType = curObj->pType;

			if (curObj == &pRuntime->system)
				source = "System";
			else if (curType->movement) {
				source.Format("%s #%d", curType->AuxName, find_index(curType->instances.begin(), curType->instances.end(), curObj) + 1);
			}
			else
				source.Format("%s #%d", curType->Name, find_index(curType->instances.begin(), curType->instances.end(), curObj) + 1);
		
			pObjectsPage->AddCommonInspectItems(curObj);
			curObj->DebuggerUpdateDisplay(unused);
			}
			break;
		case WATCH_INSTANCEPRIVATEVAR:
			{
			CRunObject* curObj = i->first.obj;
			CRunObjType* curType = curObj->pType;

			source.Format("%s #%d", curType->Name, find_index(curType->instances.begin(), curType->instances.end(), curObj) + 1);
		
			pRuntime->AddDebuggerItem(CString("'") + curType->privateVars[i->first.pvIndex].name + "'",
								i->first.pPrivateVars[i->first.pvIndex].GetString(), false);
			}
			break;
		case WATCH_GLOBALVAR:
			{
			int globalIndex = i->first.pvIndex;

			source = "(System)";
			pRuntime->AddDebuggerItem(CString("'") + pRuntime->globalNames[globalIndex] + "'",
								pRuntime->globalVars[globalIndex].GetString(), false);
			}
			break;
		}
		
		// Iterate all keys this object has being watched
		KeyList::iterator k = i->second.begin();
		KeyList::iterator keys_end = i->second.end();

		for ( ; k != keys_end; k++) {

			// Generate a watch line and add it
			curDisplay.push_back(WatchLine());
			WatchLine& wl = curDisplay.back();
			wl.label = k->label;
			wl.objIdent = source;
			ExtDebugInfo::iterator d = find(curDebug.begin(), curDebug.end(), k->label);
			wl.value = d->value;
			wl.readOnly = d->readOnly;

			wl.pItem = k;
			wl.pKey = i;
		}
	}

	// Full refresh
	if (curDisplay.size() != lastDisplay.size()) {
		m_List.SetRedraw(false);
		m_List.DeleteAllItems();

		vector<WatchLine>::iterator w = curDisplay.begin();

		for ( ; w != curDisplay.end(); w++) {
			int curLine = m_List.GetItemCount();
			m_List.InsertItem(curLine, w->objIdent);
			m_List.SetItemText(curLine, 1, w->label);
			m_List.SetItemText(curLine, 2, w->value);

			if (w->readOnly)
				m_List.SetItemColors(curLine, 2, GetSysColor(COLOR_GRAYTEXT), GetSysColor(COLOR_WINDOW));
			else
				m_List.SetEdit(curLine, 2);
		}

		m_List.SetRedraw(true);
		m_List.UpdateWindow();
	}
	// Else item update
	else {
		m_List.SetRedraw(false);

		vector<WatchLine>::iterator w = curDisplay.begin();
		vector<WatchLine>::iterator x = lastDisplay.begin();
		int index = 0;

		for ( ; w != curDisplay.end(); w++, x++, index++) {
			if (w->label != x->label)
				m_List.SetItemText(index, 1, w->label);
			if (w->objIdent != x->objIdent)
				m_List.SetItemText(index, 0, w->objIdent);
			if (w->value != x->value)
				m_List.SetItemText(index, 2, w->value);
		}

		m_List.SetRedraw(true);
		m_List.UpdateWindow();
	}

	lastDisplay = curDisplay;
}
Esempio n. 3
0
void CObjectsPage::RefreshInspection()
{
	// This prevents the updating items glitching over the item edit boxes.
	if (pausedUpdating)
		return;

	ExtDebugInfo oldDisplay = objDebugDisplay;

	// Direct output to this vector
	pRuntime->curDebugOutput = &objDebugDisplay;

	// Inspecting object?
	if (pMyObject) {

		objDebugDisplay.resize(0);

		switch (inspectArea) {
		case INSPECT_COMMON:
			pCurLineOwner = pMyObject;
			AddCommonInspectItems(pMyObject);
			break;
		case INSPECT_PROPERTIES:
			pCurLineOwner = pMyObject;
			pMyObject->DebuggerUpdateDisplay(pCurrentVars);
			break;
		case INSPECT_PRIVATEVARS:
			pCurLineOwner = pMyObject;
			AddPrivateVariableInspectItems();
			break;
		case INSPECT_ALL:

			if (!(pMyObject->pType->pPlugin->ideFlags & OF_NOCOMMONDEBUG)) {
				AddListHeader("Common");

				pCurLineOwner = pMyObject;
				AddCommonInspectItems(pMyObject);

				AddListHeader("");
			}

			AddListHeader("Properties");

			pCurLineOwner = pMyObject;
			pMyObject->DebuggerUpdateDisplay(pCurrentVars);

			if (pCurrentVars) {
				AddListHeader("");
				AddListHeader("Private Variables");

				AddPrivateVariableInspectItems();
			}

			// Get movements and show their props
			if (!pMyObject->siblings.empty()) {
				ObjIterator s = pMyObject->siblings.begin();
				ObjConstIterator siblings_end = pMyObject->siblings.end();

				for ( ; s != siblings_end; s++) {
					if ((*s)->pType->movement && !((*s)->pType->pPlugin->ideFlags & OF_NODEBUG)) {

						// Movement header
						AddListHeader("");
						AddListHeader((*s)->pType->AuxName);

						// Associate these lines with the movement instance instead
						pCurLineOwner = *s;
						(*s)->DebuggerUpdateDisplay(pCurrentVars);
					}
				}
			}
			break;
		}

		// Is destroying?  Don't try to show next frame!
		if (pMyObject->info.destroying)
			pMyObject = NULL;

	}
	// Inspecting type?
	else if (pMyType) {

		objDebugDisplay.resize(0);

		pRuntime->AddDebuggerItem("Instances", (int)pMyType->instances.size(), true);
	}

	// Nothing got added?  Add blank line to trick "DebugDisplayLabelsHaveChanged"
	if (objDebugDisplay.empty())
		AddListHeader("");

	// Check for differences in size or labels: full refresh
	if (DebugDisplayLabelsHaveChanged(oldDisplay, objDebugDisplay)) {

		m_List.SetRedraw(false);
		m_List.DeleteAllItems();
		lineOwners.resize(0);

		ExtDebugIterator i = objDebugDisplay.begin();

		for ( ; i != objDebugDisplay.end(); i++) {
			AddListLine(i->item, i->value, i->readOnly, i->bold, i->combo, i->comboSel);
			lineOwners.push_back(i->pOwner);
		}

		m_List.SetRedraw(true);
		m_List.UpdateWindow();
	}
	// Same labels still: we can just update the item texts of those that have changed
	else {

		m_List.SetRedraw(false);

		ExtDebugIterator i1 = objDebugDisplay.begin();
		ExtDebugIterator i2 = oldDisplay.begin();
		int index = 0;

		for ( ; i1 != objDebugDisplay.end(); i1++, i2++, index++) {

			// Combo differs
			if (i1->combo) {
				//if (i1->comboSel != i2->comboSel)
				//	;//TODO: update combo sel
			}
			// Values differ
			else if (i1->value != i2->value) {

				// Simply update the item text with the new value, or change the combo sel
				m_List.SetItemText(index, 1, i1->value);

			}
		}//for

		m_List.SetRedraw(true);
		m_List.UpdateWindow();

	}//labels changed
}