Example #1
0
    void CellGUI(Rect cellRect, TreeViewItem <DsgVarsTreeElement> item, Columns column, ref RowGUIArgs args)
    {
        // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
        CenterRectUsingSingleLineHeight(ref cellRect);
        switch (column)
        {
        case Columns.Icon:
            DsgVarType type = item.data.entry.Type;
            if (item.data.arrayIndex.HasValue)
            {
                type = DsgVarInfoEntry.GetDsgVarTypeFromArrayType(type);
            }
            if (icons.ContainsKey(type))
            {
                GUI.Label(cellRect, icons[type], CenteredLabel);
            }
            break;

        case Columns.Name:
            if (item.data.arrayIndex.HasValue)
            {
                Rect  indentedRect = cellRect;
                float indentValue  = Mathf.Min(10f, indentedRect.width);
                indentedRect.x     += indentValue;
                indentedRect.width -= indentValue;
                GUI.Label(indentedRect, new GUIContent("[" + item.data.arrayIndex.Value + "]"), EditorStyles.miniLabel);
            }
            else
            {
                GUI.Label(cellRect, new GUIContent(item.data.entry.Name), EditorStyles.miniLabel);
            }
            break;

        case Columns.CurrentValue:
            DsgVarComponentEditor.DrawDsgVarCurrent(cellRect, item.data.entry, item.data.arrayIndex);
            break;

        case Columns.InitialValue:
            DsgVarComponentEditor.DrawDsgVarInitial(cellRect, item.data.entry, item.data.arrayIndex);
            break;

        case Columns.ModelValue:
            DsgVarComponentEditor.DrawDsgVarModel(cellRect, item.data.entry, item.data.arrayIndex);
            break;
        }
    }
Example #2
0
            private void Parse(Reader reader)
            {
                ushort typeNumber = type;
                ushort usedParam  = param;

                dsgVarType = DsgVarType.None;
                if ((type & ((ushort)FATEntry.Flag.Fix)) == (ushort)FATEntry.Flag.Fix)
                {
                    paramEntry = new Reference <DsgVarEntry>(param, reader, true);
                    typeNumber = (ushort)(typeNumber & 0x7FFF);
                    usedParam  = paramEntry.Value.param;
                }
                if (Settings.s.aiTypes != null)
                {
                    dsgVarType = Settings.s.aiTypes.GetDsgVarType(typeNumber);
                }
                if (paramEntry == null)
                {
                    // If paramEntry exists, all params <= 4 bytes, so until float, should be read from paramEntry.
                    // eg. instead of using paramUInt, you use paramEntry.Value.paramUInt
                    // If paramEntry doesn't exist, all params <= 2 bytes should be read from the dsgvar info
                    switch (dsgVarType)
                    {
                    case DsgVarType.UInt:
                        paramUInt = new Reference <Dsg_UInt>(usedParam, reader, true);
                        break;

                    case DsgVarType.Int:
                        paramInt = new Reference <Dsg_Int>(usedParam, reader, true);
                        break;

                    case DsgVarType.Float:
                        paramFloat = new Reference <Dsg_Real>(usedParam, reader, true);
                        break;
                    }
                }
                switch (dsgVarType)
                {
                case DsgVarType.Vector:
                    paramVector3 = new Reference <Dsg_Vector3>(usedParam, reader, true);
                    break;

                case DsgVarType.Graph:
                    paramGraph = new Reference <Graph>(usedParam, reader, true);
                    break;

                case DsgVarType.Waypoint:
                    paramWaypoint = new Reference <WayPoint>(usedParam, reader, true);
                    break;

                case DsgVarType.Comport:
                    paramComport = new Reference <Comport>(usedParam, reader, true);
                    break;

                case DsgVarType.Action:
                    paramState = new Reference <State>(usedParam, reader, true);
                    break;

                case DsgVarType.GameMaterial:
                    paramGameMaterial = new Reference <GameMaterial>(usedParam, reader, true);
                    break;

                case DsgVarType.Perso:
                    paramPerso = new Reference <Perso>(usedParam, reader, true);
                    break;
                }
            }