130 lines
2.8 KiB
C#
130 lines
2.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class auto_search_class
|
|
{
|
|
public string path_full;
|
|
|
|
public string path;
|
|
|
|
public bool foldout;
|
|
|
|
public bool custom;
|
|
|
|
public int digits;
|
|
|
|
public string format;
|
|
|
|
public string filename;
|
|
|
|
public string fullname;
|
|
|
|
public string name;
|
|
|
|
public string extension;
|
|
|
|
public int start_x;
|
|
|
|
public int start_y;
|
|
|
|
public int start_n;
|
|
|
|
public int count_x;
|
|
|
|
public int count_y;
|
|
|
|
public bool display;
|
|
|
|
public int select_index;
|
|
|
|
public Rect menu_rect;
|
|
|
|
public string output_format;
|
|
|
|
public auto_search_class()
|
|
{
|
|
path_full = string.Empty;
|
|
path = string.Empty;
|
|
digits = 1;
|
|
format = "%n";
|
|
filename = "tile";
|
|
extension = ".raw";
|
|
start_n = 1;
|
|
count_x = 1;
|
|
count_y = 1;
|
|
select_index = -1;
|
|
output_format = "1";
|
|
}
|
|
|
|
public virtual void set_output_format()
|
|
{
|
|
if (digits < 1)
|
|
{
|
|
digits = 1;
|
|
}
|
|
string text = new string("0"[0], digits);
|
|
output_format = format.Replace("%x", start_x.ToString(text));
|
|
output_format = output_format.Replace("%y", start_y.ToString(text));
|
|
output_format = output_format.Replace("%n", start_n.ToString(text));
|
|
}
|
|
|
|
public virtual bool strip_file()
|
|
{
|
|
string text = new string("0"[0], digits);
|
|
string text2 = format.Replace("%x", start_x.ToString(text));
|
|
text2 = text2.Replace("%y", start_y.ToString(text));
|
|
text2 = text2.Replace("%n", start_n.ToString(text));
|
|
int result;
|
|
if (path_full.Length == 0)
|
|
{
|
|
result = 0;
|
|
}
|
|
else
|
|
{
|
|
path = Path.GetDirectoryName(path_full);
|
|
filename = Path.GetFileNameWithoutExtension(path_full);
|
|
filename = filename.Replace(text2, string.Empty);
|
|
extension = Path.GetExtension(path_full);
|
|
result = 1;
|
|
}
|
|
return (byte)result != 0;
|
|
}
|
|
|
|
public virtual void strip_name()
|
|
{
|
|
string text = new string("0"[0], digits);
|
|
string text2 = format.Replace("%x", start_x.ToString(text));
|
|
text2 = text2.Replace("%y", start_y.ToString(text));
|
|
text2 = text2.Replace("%n", start_n.ToString(text));
|
|
name = fullname;
|
|
if (text2.Length > 0)
|
|
{
|
|
name = name.Replace(text2, string.Empty);
|
|
}
|
|
}
|
|
|
|
public virtual string get_file(int count_x, int count_y, int count_n)
|
|
{
|
|
string text = null;
|
|
string text2 = new string("0"[0], digits);
|
|
string text3 = null;
|
|
text = format.Replace("%x", (count_x + start_x).ToString(text2));
|
|
text = text.Replace("%y", (count_y + start_y).ToString(text2));
|
|
text = text.Replace("%n", (count_n + start_n).ToString(text2));
|
|
return path + "/" + filename + text + extension;
|
|
}
|
|
|
|
public virtual string get_name(int count_x, int count_y, int count_n)
|
|
{
|
|
string text = null;
|
|
string text2 = new string("0"[0], digits);
|
|
string text3 = null;
|
|
text = format.Replace("%x", (count_x + start_x).ToString(text2));
|
|
text = text.Replace("%y", (count_y + start_y).ToString(text2));
|
|
text = text.Replace("%n", (count_n + start_n).ToString(text2));
|
|
return name + text;
|
|
}
|
|
}
|