示例#1
0
 /// <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;
 }
示例#2
0
    /// <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;
        }
    }
示例#3
0
    //////////////////////////////////////////////////
    // 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;
        }
    }
示例#4
0
 /// <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);
 }
示例#5
0
 public bool GetValueBool(SMVmapping mapping)
 {
     return(controls[(int)mapping].GetValueBool());
 }
示例#6
0
 public string GetValueString(SMVmapping mapping)
 {
     return(controls[(int)mapping].GetValueString());
 }
示例#7
0
 public int GetValueInt(SMVmapping mapping)
 {
     return(controls[(int)mapping].GetValueInt());
 }
示例#8
0
 /// <summary>
 /// Get the state value for the passed mapping.
 /// </summary>
 /// <returns></returns>
 public float GetValueFloat(SMVmapping mapping)
 {
     return(controls[(int)mapping].GetValueFloat());
 }
示例#9
0
 /// <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);
 }
示例#10
0
 // ctor
 public SMVcontrol()
 {
     views        = new List <SMVviewBase>();
     this.mapping = SMVmapping.undefined;
     value        = null;
 }