Exemple #1
0
        public (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf)
        {
            _currThread = lf.Thread;

            try
            {
                LuaLibraryBase.SetCurrentThread(lf);

                var execResult = _currThread.Resume(0);
                GuiAPI.ThisIsTheLuaAutounlockHack();

                _lua.RunScheduledDisposes();                 // TODO: I don't think this is needed anymore, we run this regularly anyway

                // not sure how this is going to work out, so do this too
                _currThread.RunScheduledDisposes();

                _currThread = null;
                var result = execResult == 0
                                        ? (WaitForFrame : false, Terminated : true)        // terminated
                             : (WaitForFrame : FrameAdvanceRequested, Terminated : false); // yielded

                FrameAdvanceRequested = false;
                return(result);
            }
            catch (Exception)
            {
                GuiAPI.ThisIsTheLuaAutounlockHack();
                throw;
            }
            finally
            {
                LuaLibraryBase.ClearCurrentThread();
            }
        }
Exemple #2
0
        public ResumeResult ResumeScript(Lua script)
        {
            _currThread = script;

            try
            {
                LuaLibraryBase.SetCurrentThread(_currThread);

                var execResult = script.Resume(0);
                script.Resume(1);
                _lua.RunScheduledDisposes();
                //not sure how this is going to work out, so do this too
                script.RunScheduledDisposes();

                _currThread = null;
                var result = new ResumeResult();
                if (execResult == 0)
                {
                    // terminated
                    result.Terminated = true;
                }
                else
                {
                    // yielded
                    result.WaitForFrame = FrameAdvanceRequested;
                }

                FrameAdvanceRequested = false;
                return(result);
            }
            finally
            {
                LuaLibraryBase.ClearCurrentThread();
            }
        }
Exemple #3
0
 public void DrawIcon([LuaArbitraryStringParam] string path, int x, int y, int?width = null, int?height = null)
 {
     try
     {
         luaPictureBox.DrawIcon(LuaLibraryBase.FixString(path), x, y, width, height);
     }
     catch (Exception ex)
     {
         LogOutputCallback(ex.Message);
     }
 }
Exemple #4
0
 public void DrawText(
     int x,
     int y,
     [LuaArbitraryStringParam] string message,
     [LuaColorParam] object foreColor = null,
     [LuaColorParam] object backColor = null,
     int?fontSize = null,
     [LuaASCIIStringParam] string fontFamily     = null,
     [LuaEnumStringParam] string fontStyle       = null,
     [LuaEnumStringParam] string horizontalAlign = null,
     [LuaEnumStringParam] string verticalAlign   = null)
 {
     luaPictureBox.DrawText(x, y, LuaLibraryBase.FixString(message), _th.SafeParseColor(foreColor), _th.SafeParseColor(backColor), fontSize, fontFamily, fontStyle, horizontalAlign, verticalAlign);
 }
Exemple #5
0
        public void DrawImage(
            [LuaArbitraryStringParam] string path,
            int x,
            int y,
            int?width  = null,
            int?height = null,
            bool cache = true)
        {
            var path1 = LuaLibraryBase.FixString(path);

            if (!File.Exists(path1))
            {
                LogOutputCallback($"File not found: {path1}\nScript Terminated");
                return;
            }
            luaPictureBox.DrawImage(path1, x, y, width, height, cache);
        }
Exemple #6
0
        public void DrawImageRegion(
            [LuaArbitraryStringParam] string path,
            int sourceX,
            int sourceY,
            int sourceWidth,
            int sourceHeight,
            int destX,
            int destY,
            int?destWidth  = null,
            int?destHeight = null)
        {
            var path1 = LuaLibraryBase.FixString(path);

            if (!File.Exists(path1))
            {
                LogOutputCallback($"File not found: {path1}\nScript Terminated");
                return;
            }
            luaPictureBox.DrawImageRegion(path1, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight);
        }
Exemple #7
0
        public override ResumeResult ResumeScript(LuaFile lf)
        {
            _currThread = lf.Thread;

            try
            {
                LuaLibraryBase.SetCurrentThread(lf);

                var execResult = _currThread.Resume(0);

                _lua.RunScheduledDisposes();                 // TODO: I don't think this is needed anymore, we run this regularly anyway

                // not sure how this is going to work out, so do this too
                _currThread.RunScheduledDisposes();

                _currThread = null;
                var result = new ResumeResult();
                if (execResult == 0)
                {
                    // terminated
                    result.Terminated = true;
                }
                else
                {
                    // yielded
                    result.WaitForFrame = FrameAdvanceRequested;
                }

                FrameAdvanceRequested = false;
                return(result);
            }
            finally
            {
                LuaLibraryBase.ClearCurrentThread();
            }
        }
Exemple #8
0
 public void SetTitle([LuaArbitraryStringParam] string title)
 => Text = LuaLibraryBase.FixString(title);
Exemple #9
0
 public void SaveImageToDisk([LuaArbitraryStringParam] string path)
 {
     luaPictureBox.Image.Save(LuaLibraryBase.FixString(path).MakeAbsolute(_emuLib.PathEntries.ScreenshotAbsolutePathFor(_emuLib.GetSystemId())));
 }