/// <summary> Initialize a new instance with the passed mapping. /// **NOTE** This will reset value to default. </summary> public void Init(SMVmapping mapping, SMView.OnUpdateEvent updateEvent) { this.mapping = mapping; SetupMappings(); //if(mapping != SMVmapping.undefined) // SetValue(SMV.Instance.GetDefault(DataType)); value = SMV.Instance.GetDefault(DataType); onUpdateEvent = updateEvent; }
/// <summary> /// Event handler for the SMV Simple Model View system. /// This handles events that are generated when an SMV-mapped state is /// changed, either from UI or from code, so it acts like a method that /// you normally would call from both your UI event handler and from /// your code when a particular value is changed. /// </summary> /// <param name="mapping">SMVmapping identifier</param> public void SMV_OnUpdateEvent(SMVmapping mapping) { switch (mapping) { case SMVmapping.GraphHeightFrac: Graph.I.UpdateGraphHeight(); break; case SMVmapping.VRdesktopViewMode: VRManager.I.OnDesktopViewDropdown(SMV.I.GetValueInt(SMVmapping.VRdesktopViewMode)); break; case SMVmapping.VarMapHeight: case SMVmapping.VarMapSide: case SMVmapping.VarMapTop: visualMappingUIHandler.OnLabelValueChange(); break; default: //Debug.LogError("Unrecognized SMVmapping in event handler: " + mapping.ToString()); break; } }
////////////////////////////////////////////////// // Event handler for SMV OnUpdate events. // /// <summary> Optional event handler that gets called whenever an SMV-handled value is changed, /// whether via UI element or directly from code via SetValue(). /// This handler must be assigned once to the event in the SMV object in editor. /// </summary> public void OnSVMUpdate(SMVmapping mapping) { //Log when we get an event for demo purposes, but skip the TimeLabel update since they're each frame if (mapping != SMVmapping.TimeLabel) { Debug.Log("*** OnSVMUpdate called with mapping " + mapping.ToString()); } switch ((int)mapping) { case (int)SMVmapping.RotatingTextCount: SetupRotatingTextObjects(); break; case (int)SMVmapping.TextColor: UpdateRotatingTextColor(); break; default: //ignore this mapping break; } }
/// <summary> /// Assign a value for the mapping. /// User must pass value of appropriate type for the mapping. /// If value is the wrong type, an error gets logged and state and view are not changed. /// </summary> /// <param name="mapping"></param> /// <param name="val"></param> public void SetValue(SMVmapping mapping, object val) { controls[(int)mapping].SetValue(val); }
public bool GetValueBool(SMVmapping mapping) { return(controls[(int)mapping].GetValueBool()); }
public string GetValueString(SMVmapping mapping) { return(controls[(int)mapping].GetValueString()); }
public int GetValueInt(SMVmapping mapping) { return(controls[(int)mapping].GetValueInt()); }
/// <summary> /// Get the state value for the passed mapping. /// </summary> /// <returns></returns> public float GetValueFloat(SMVmapping mapping) { return(controls[(int)mapping].GetValueFloat()); }
/// <summary> /// Pass an object containing ui-specific special item. /// Each view will check for proper type and convert, and ignore if not proper. /// e.g. for Dropdown UI, this is list of items to populate the dropdown /// </summary> /// <param name="options"></param> public void SetSpecial(SMVmapping mapping, object obj) { controls[(int)mapping].SetSpecial(obj); }
// ctor public SMVcontrol() { views = new List <SMVviewBase>(); this.mapping = SMVmapping.undefined; value = null; }