예제 #1
0
        private void ReadSection()
        {
            int ch = -1;

            iniType = enItemType.Section;
            ch      = ReadChar(); // consume "["

            while (true)
            {
                ch = PeekChar();
                if (ch == ']')
                {
                    break;
                }
                if (EndOfLine(ch))
                {
                    throw new IniException(this, "Expected section end (])");
                }

                this.name.Append((char)ReadChar());
            }

            ConsumeToEnd(); // all after '[' is garbage
            RemoveTrailingWhitespace(this.name);
        }
예제 #2
0
 internal protected IniItem(string name, string value, enItemType type, string comment)
 {
     m_name    = name;
     m_value   = value;
     m_type    = type;
     m_comment = comment;
 }
예제 #3
0
        private void ReadKey()
        {
            int ch = -1;

            iniType = enItemType.Key;

            while (true)
            {
                ch = PeekChar();

                if (IsAssign(ch))
                {
                    ReadChar();
                    break;
                }

                if (EndOfLine(ch))
                {
                    if (acceptNoAssignmentOperator)
                    {
                        break;
                    }
                    throw new IniException(this,
                                           String.Format("Expected assignment operator ({0})",
                                                         assignDelimiters[0]));
                }

                this.name.Append((char)ReadChar());
            }

            ReadKeyValue();
            SearchForComment();
            RemoveTrailingWhitespace(this.name);
        }
예제 #4
0
 private void Reset()
 {
     this.name.Remove(0, this.name.Length);
     this.value.Remove(0, this.value.Length);
     this.comment.Remove(0, this.comment.Length);
     iniType    = enItemType.Empty;
     hasComment = false;
 }
예제 #5
0
    public void ClearBasicFields()
    {
        // Sets all the values in the Basic Tab to initial states
        sName        = "";
        eType        = enItemType.NONE;
        sDescription = "";
        tDescription = null;
        iPrice       = 0;
        iValue       = 0;
        bCanSell     = true;
        sprImage     = null;

        GUIUtility.keyboardControl = 0;
    }
예제 #6
0
 // The constructor
 public Item(string aName,
             enItemType aType,
             string aDescription,
             int aPrice,
             int aValue,
             bool aCanSell,
             Sprite aImage)
 {
     Name        = aName;
     Type        = aType;
     Description = aDescription;
     Price       = aPrice;
     Value       = aValue;
     CanSell     = aCanSell;
     Image       = aImage;
 }
예제 #7
0
        private bool ReadNext()
        {
            bool result = true;
            int  ch     = PeekChar();

            Reset();

            if (IsComment(ch))
            {
                iniType = enItemType.Empty;
                ReadChar(); // consume comment character
                ReadComment();

                return(result);
            }

            switch (ch)
            {
            case ' ':
            case '\t':
            case '\r':
                SkipWhitespace();
                ReadNext();
                break;

            case '\n':
                ReadChar();
                break;

            case '[':
                ReadSection();
                break;

            case -1:
                readState = enIniReadState.EndOfFile;
                result    = false;
                break;

            default:
                ReadKey();
                break;
            }

            return(result);
        }
예제 #8
0
 public Equipment(string aName, enItemType aType, string aDescription, int aPrice, int aValue, bool aCanSell, Sprite aImage) :
     base(aName, aType, aDescription, aPrice, aValue, aCanSell, aImage)
 {
 }
예제 #9
0
    public void BasicTab()
    {
        // The setup for everything needed in the Basic Tab
        GUILayout.Label("Basic Information", EditorStyles.boldLabel);

        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        // Item Name
        GUILayout.Label("Item Name");
        sName = EditorGUILayout.TextField("", sName);

        GUILayout.EndVertical();
        GUILayout.BeginVertical();

        // Item Type
        GUILayout.Label("Item Type");
        eType = (enItemType)EditorGUILayout.EnumPopup("", eType);

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        // Description Text
        GUILayout.Label("Description Text");
        sDescription = GUILayout.TextArea(sDescription, GUI.skin.textArea, GUILayout.MinHeight(100));

        EditorGUILayout.Space();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        // Clear Text button
        if (GUILayout.Button("Clear Description Text", buttonHW))
        {
            sDescription = "";
            GUIUtility.keyboardControl = 0;
        }

        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();

        // Item Price
        GUILayout.Label("Item Price");
        iPrice = EditorGUILayout.IntField(iPrice);

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();

        // Item Value
        GUILayout.Label("Item Value");
        iValue = EditorGUILayout.IntField(iValue);

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        // Is the Item Sellable?
        bCanSell = EditorGUILayout.Toggle("Can Sell? :", bCanSell);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();

        // Item Image
        GUILayout.Label("Item Image");
        sprImage = (Sprite)EditorGUILayout.ObjectField(sprImage, typeof(Sprite), false);

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();

        // Desciriotn Text File Variant
        GUILayout.Label("Description Text (Text File)");
        tDescription = (TextAsset)EditorGUILayout.ObjectField(tDescription, typeof(TextAsset), false);

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        // Clear Fields buttons
        if (GUILayout.Button("Clear Basic Fields", buttonHW))
        {
            ClearBasicFields();
        }

        if (GUILayout.Button("Clear All Fields", buttonHW))
        {
            ClearAllFields();
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
    }