Beispiel #1
0
    static int FishDeath(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes <UnityEngine.Transform>(L, 1))
            {
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1);
                LuaTool.FishDeath(arg0);
                return(0);
            }
            else if (count == 1 && TypeChecker.CheckTypes <UnityEngine.GameObject>(L, 1))
            {
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                LuaTool.FishDeath(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaTool.FishDeath"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #2
0
    static int GetTransform(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <UnityEngine.Transform, string>(L, 1))
            {
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1);
                string arg1             = ToLua.ToString(L, 2);
                UnityEngine.Transform o = LuaTool.GetTransform(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <UnityEngine.GameObject, string>(L, 1))
            {
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                string arg1             = ToLua.ToString(L, 2);
                UnityEngine.Transform o = LuaTool.GetTransform(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaTool.GetTransform"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #3
0
    static int AddListener(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 4 && TypeChecker.CheckTypes <UnityEngine.GameObject, LuaInterface.LuaFunction, LuaInterface.LuaFunction, LuaInterface.LuaFunction>(L, 1))
            {
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                LuaFunction            arg1 = ToLua.ToLuaFunction(L, 2);
                LuaFunction            arg2 = ToLua.ToLuaFunction(L, 3);
                LuaFunction            arg3 = ToLua.ToLuaFunction(L, 4);
                LuaTool.AddListener(arg0, arg1, arg2, arg3);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes <UnityEngine.Transform, LuaInterface.LuaFunction, LuaInterface.LuaFunction, LuaInterface.LuaFunction>(L, 1))
            {
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1);
                LuaFunction           arg1 = ToLua.ToLuaFunction(L, 2);
                LuaFunction           arg2 = ToLua.ToLuaFunction(L, 3);
                LuaFunction           arg3 = ToLua.ToLuaFunction(L, 4);
                LuaTool.AddListener(arg0, arg1, arg2, arg3);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaTool.AddListener"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #4
0
    static int SetGameObjectActive(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <UnityEngine.Transform, bool>(L, 1))
            {
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1);
                bool arg1 = LuaDLL.lua_toboolean(L, 2);
                LuaTool.SetGameObjectActive(arg0, arg1);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes <UnityEngine.GameObject, bool>(L, 1))
            {
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                bool arg1 = LuaDLL.lua_toboolean(L, 2);
                LuaTool.SetGameObjectActive(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaTool.SetGameObjectActive"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        public override bool Search(string searchString, string path = "")
        {
            var tempFile = System.IO.Path.GetTempFileName();

            LuaTool.Decompile(Path, tempFile);

            var result = base.Search(EncodeText(searchString), tempFile);

            System.IO.File.Delete(tempFile);

            return(result);
        }
        public override void Rebuild(string outputFolder)
        {
            var outputPath = System.IO.Path.Combine(outputFolder, RelativePath);

            Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath));

            var subtitles = GetSubtitles();

            var inputTempFile = System.IO.Path.GetTempFileName();

            LuaTool.Decompile(Path, inputTempFile);

            var lines = System.IO.File.ReadAllLines(inputTempFile);

            System.IO.File.Delete(inputTempFile);

            var output = new List <string>(lines.Length);

            foreach (var line in lines)
            {
                if (!line.StartsWith("text = {"))
                {
                    output.Add(line);
                    continue;
                }

                var strings = new List <string>();

                var regex = new Regex(
                    @"\[\""(?<Tag>[^""]+)\""\]\s=\s\""(?<Text>[^""]*)\""");
                var match = regex.Match(line);

                while (match.Success)
                {
                    var tag = match.Groups["Tag"].Value;

                    var sub = subtitles.First(x => (x as LuaSubtitle)?.Id == tag);

                    strings.Add($"[\"{tag}\"] = \"{EncodeText(sub.Translation)}\"");
                    match = match.NextMatch();
                }

                output.Add($"text = {{{string.Join(", ", strings)}}}");
            }

            var outputTempFile = System.IO.Path.GetTempFileName();

            System.IO.File.WriteAllLines(outputTempFile, output);

            LuaTool.Compile(outputTempFile, outputPath);
            System.IO.File.Delete(outputTempFile);
        }
        protected override IList <Subtitle> GetSubtitles()
        {
            var tempFile = System.IO.Path.GetTempFileName();

            LuaTool.Decompile(Path, tempFile);

            var result = new List <Subtitle>();

            if (System.IO.File.Exists(tempFile))
            {
                var lines = System.IO.File.ReadAllLines(tempFile);
                System.IO.File.Delete(tempFile);

                foreach (var line in lines)
                {
                    if (!line.StartsWith("text = {"))
                    {
                        continue;
                    }

                    var regex = new Regex(
                        @"\[\""(?<Tag>[^""]+)\""\]\s=\s\""(?<Text>[^""]*)\""");
                    var match = regex.Match(line);

                    while (match.Success)
                    {
                        var tag  = match.Groups["Tag"].Value;
                        var text = DecodeText(match.Groups["Text"].Value);

                        var sub = new LuaSubtitle
                        {
                            Id          = tag,
                            Text        = text,
                            Loaded      = text,
                            Translation = text,
                            Offset      = 0,
                        };
                        sub.PropertyChanged += SubtitlePropertyChanged;

                        result.Add(sub);

                        match = match.NextMatch();
                    }
                }

                LoadChanges(result);
            }

            return(result);
        }
Beispiel #8
0
 static int GetBulletMoveDir(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1);
         UnityEngine.Vector2 o    = LuaTool.GetBulletMoveDir(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #9
0
 static int DebugDrawLine(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1);
         UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 2);
         LuaTool.DebugDrawLine(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #10
0
 static int DebugLog(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         int    arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
         string arg1 = ToLua.CheckString(L, 2);
         LuaTool.DebugLog(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #11
0
 static int WorldToScenePos(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Camera  arg0 = (UnityEngine.Camera)ToLua.CheckObject(L, 1, typeof(UnityEngine.Camera));
         UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 2);
         UnityEngine.Vector3 o    = LuaTool.WorldToScenePos(arg0, arg1);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #12
0
 static int ScreenVectorToLocalVector(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
         UnityEngine.Vector3   arg1 = ToLua.ToVector3(L, 2);
         UnityEngine.Vector2   o    = LuaTool.ScreenVectorToLocalVector(arg0, arg1);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #13
0
 static int InstanceObj(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         UnityEngine.Transform  arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
         LuaFunction            arg2 = ToLua.CheckLuaFunction(L, 3);
         LuaTool.InstanceObj(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #14
0
    static int _CreateLuaTool(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                LuaTool obj = new LuaTool();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: LuaTool.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #15
0
 static void OpenWindow()
 {
     // Get existing open window or if none, make a new one:
     LuaTool.GetWindow(typeof(LuaTool));
 }
Beispiel #16
0
    static void DoIt()
    {
        LuaTool lua = GetWindow <LuaTool>();

        lua.Show();
    }