2012-07-10 10:20:45 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.Data {
|
2012-07-12 22:34:12 +00:00
|
|
|
|
internal sealed class ScriptItem : Object {
|
2012-07-10 10:20:45 +00:00
|
|
|
|
private string name;
|
|
|
|
|
private int index;
|
|
|
|
|
private int selectionStart;
|
|
|
|
|
private int selectionEnd;
|
|
|
|
|
|
2012-07-12 22:34:12 +00:00
|
|
|
|
internal string Name { get { return name; } }
|
|
|
|
|
internal int Index { get { return index; } }
|
|
|
|
|
internal int SelectionStart { get { return selectionStart; } }
|
|
|
|
|
internal int SelectionEnd { get { return selectionEnd; } }
|
2012-07-10 10:20:45 +00:00
|
|
|
|
|
2012-07-12 22:34:12 +00:00
|
|
|
|
internal ScriptItem(int index, string name, int selectionStart, int selectionEnd) {
|
2012-07-10 10:20:45 +00:00
|
|
|
|
this.name = name;
|
|
|
|
|
this.index = index;
|
|
|
|
|
this.selectionStart = selectionStart;
|
|
|
|
|
this.selectionEnd = selectionEnd;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 22:34:12 +00:00
|
|
|
|
internal ScriptItem(int index, string name) {
|
2012-07-10 10:20:45 +00:00
|
|
|
|
this.name = name;
|
|
|
|
|
this.index = index;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 22:34:12 +00:00
|
|
|
|
internal static int SortByIndex(ScriptItem i1, ScriptItem i2) {
|
|
|
|
|
if (i1.Index > i2.Index) return 1;
|
|
|
|
|
if (i1.Index == i2.Index) return 0;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static int SortByName(ScriptItem i1, ScriptItem i2) {
|
2012-07-16 09:45:21 +00:00
|
|
|
|
if (i1.Name == i2.Name) return 0;
|
|
|
|
|
|
2012-07-12 22:34:12 +00:00
|
|
|
|
if (i1.Name.ToUpper()[0] > i2.Name.ToUpper()[0]) return 1;
|
2012-07-16 09:45:21 +00:00
|
|
|
|
if (i1.Name.ToUpper()[0] == i2.Name.ToUpper()[0]) {
|
|
|
|
|
int len = Math.Min(i1.Name.Length, i2.Name.Length);
|
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
|
if (i1.Name.ToUpper()[i] > i2.Name.ToUpper()[i]) return 1;
|
|
|
|
|
if (i1.Name.ToUpper()[i] < i2.Name.ToUpper()[i]) return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i1.Name.Length > i2.Name.Length) return 1;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2012-07-12 22:34:12 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-10 10:20:45 +00:00
|
|
|
|
public override string ToString() {
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|