static void RefreshHighlightActivity() { if (mShouldRefreshHighlight) { if (mNextElementToHighlight == null) { if (mCurrentElementHighlight.CurrentElement != null) { mCurrentElementHighlight.CurrentElement = null; } } else if (mCurrentElement != null) { ElementRuntime nextElement = mCurrentElement.GetContainedElementRuntime(mNextElementToHighlight); mCurrentElementHighlight.CurrentElement = nextElement; mCurrentElementHighlight.Color = mCurrentElementHighlight.GetColorVisibleAgainst(SpriteManager.Camera.BackgroundColor); } if (ElementHighlighted != null) { ElementHighlighted(mCurrentElementHighlight.CurrentElement); } mShouldRefreshHighlight = false; } // We want to refresh every frame because elements may change due to plugins, interpolation, script, etc. // This is a little inefficient but it might be okay since we're on a PC. Review this if we have performance // problems (I don't expect we will) mCurrentElementHighlight.CurrentElement = mCurrentElementHighlight.CurrentElement; }
public string GetTypeStringForValue(string leftOfEquals, ElementRuntime elementRuntime, CodeContext codeContext, out Type runtimeType) { // try using the new method: var leftReference = mExpressionParser.EvaluateExpression(leftOfEquals, codeContext, ExpressionParseType.GetReference); if (leftReference != null) { if (leftReference is IAssignableReference) { Type type = ((IAssignableReference)leftReference).TypeOfReference; runtimeType = type; string toReturn = null; if (runtimeType != null) { toReturn = runtimeType.FullName; } return toReturn; } else { runtimeType = null; return null; } } else { string leftSideRaw = leftOfEquals; string leftSideContainer = null; if (leftOfEquals.Contains('.')) { // That means the user is setting a value on a contained object, so let's see what the raw variable is int lastDot = leftOfEquals.LastIndexOf('.'); leftSideRaw = leftOfEquals.Substring(lastDot + 1, leftSideRaw.Length - (lastDot + 1)); leftSideContainer = leftOfEquals.Substring(0, lastDot); } if (leftSideContainer == null) { if (elementRuntime != null) { if (IsStateVariable(leftSideRaw, elementRuntime)) { runtimeType = typeof(string); return "String"; } } FieldInfo fieldInfo = mAllFields.GetFieldByName(leftSideRaw); if (fieldInfo != null) { runtimeType = fieldInfo.FieldType; return fieldInfo.FieldType.ToString(); } PropertyInfo propertyInfo = mAllProperties.GetPropertyByName(leftSideRaw); if (propertyInfo != null) { runtimeType = propertyInfo.PropertyType; return propertyInfo.PropertyType.ToString(); } } // reverse loop so we get the inner-most variables first for (int i = mCallStackVariables.Count - 1; i > -1; i--) { Dictionary<string, object> variableDictionary = mCallStackVariables[i]; if (variableDictionary.ContainsKey(leftSideRaw)) { runtimeType = variableDictionary[leftSideRaw].GetType(); return runtimeType.ToString(); } } if (leftSideContainer != null) { ElementRuntime containerElementRuntime = elementRuntime.GetContainedElementRuntime(leftSideContainer); if (containerElementRuntime != null) { return GetTypeStringForValue(leftSideRaw, containerElementRuntime, codeContext, out runtimeType); } } // If we got this far we should try to get the type through reflection GetTypeFromReflection(leftOfEquals, out runtimeType, null); if (runtimeType != null) { return runtimeType.ToString(); } else { return null; } } }