Beispiel #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;
}
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;
}