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); }
internal protected IniItem(string name, string value, enItemType type, string comment) { m_name = name; m_value = value; m_type = type; m_comment = comment; }
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); }
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; }
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; }
// 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; }
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); }
public Equipment(string aName, enItemType aType, string aDescription, int aPrice, int aValue, bool aCanSell, Sprite aImage) : base(aName, aType, aDescription, aPrice, aValue, aCanSell, aImage) { }
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(); }