Example #1
0
        //public WorkspaceService workspace => desktopRunner.workspaceService;

        public override void ConfigureScript(Script luaScript)
        {
            base.ConfigureScript(luaScript);

            // File APIs
            luaScript.Globals["UniqueFilePath"]  = new Func <WorkspacePath, WorkspacePath>(workspace.UniqueFilePath);
            luaScript.Globals["CreateDirectory"] = new Action <WorkspacePath>(workspace.CreateDirectoryRecursive);
            luaScript.Globals["MoveTo"]          = new Action <WorkspacePath, WorkspacePath>(workspace.Move);
            luaScript.Globals["CopyTo"]          = new Action <WorkspacePath, WorkspacePath>(workspace.Copy);
            luaScript.Globals["Delete"]          = new Action <WorkspacePath>(workspace.Delete);
            luaScript.Globals["PathExists"]      = new Func <WorkspacePath, bool>(workspace.Exists);
            luaScript.Globals["GetEntities"]     = new Func <WorkspacePath, List <WorkspacePath> >(path =>
                                                                                                   workspace.GetEntities(path).OrderBy(o => o.EntityName, StringComparer.OrdinalIgnoreCase).ToList());
            luaScript.Globals["GetEntitiesRecursive"] = new Func <WorkspacePath, List <WorkspacePath> >(path =>
                                                                                                        workspace.GetEntitiesRecursive(path).ToList());

            luaScript.Globals["PlayWav"] = new Action <WorkspacePath>(PlayWav);
            luaScript.Globals["StopWav"] = new Action(StopWav);

            luaScript.Globals["CreateDisk"] =
                new Func <string, WorkspacePath[], WorkspacePath, int, string[], Dictionary <string, object> >(CreateDisk);
            luaScript.Globals["CreateExe"] =
                new Func <string, WorkspacePath[], WorkspacePath, WorkspacePath, string[], Dictionary <string, object> >(
                    CreateExe);
            luaScript.Globals["ClearLog"]     = new Action(workspace.ClearLog);
            luaScript.Globals["ReadLogItems"] = new Func <List <string> >(workspace.ReadLogItems);

            // TODO these are deprecated
            luaScript.Globals["ReadTextFile"]   = new Func <string, string>(ReadTextFile);
            luaScript.Globals["SaveTextToFile"] = (SaveTextToFileDelegator)SaveTextToFile;

            // File helpers
            luaScript.Globals["NewImage"] = new Func <int, int, string[], int[], Image>(NewImage);

            // Read file helpers
            luaScript.Globals["ReadJson"]  = new Func <WorkspacePath, Dictionary <string, object> >(ReadJson);
            luaScript.Globals["ReadText"]  = new Func <WorkspacePath, string>(ReadText);
            luaScript.Globals["ReadImage"] = new Func <WorkspacePath, string, Image>(ReadImage);

            // Save file helpers
            luaScript.Globals["SaveText"]  = new Action <WorkspacePath, string>(SaveText);
            luaScript.Globals["SaveImage"] = new Action <WorkspacePath, Image>(SaveImage);

//
//            // Expose Bios APIs
//            luaScript.Globals["ReadBiosData"] = new Func<string, string, string>((key, defaultValue) =>
//                desktopRunner.bios.ReadBiosData(key, defaultValue));
//            luaScript.Globals["WriteBiosData"] = new Action<string, string>(desktopRunner.bios.UpdateBiosData);

            //            luaScript.Globals["RemapKey"] = new Action<string, int>(RemapKey);

            luaScript.Globals["NewWorkspacePath"] = new Func <string, WorkspacePath>(WorkspacePath.Parse);

            UserData.RegisterType <WorkspacePath>();
            UserData.RegisterType <Image>();

            // Register the game editor with  the lua service
            gameEditor = new GameEditor(desktopRunner, locator);
            UserData.RegisterType <GameEditor>();
            luaScript.Globals["gameEditor"] = gameEditor;
        }
Example #2
0
        public override void ConfigureScript(Script luaScript)
        {
            base.ConfigureScript(luaScript);

            // File APIs
            luaScript.Globals["UniqueFilePath"]  = new Func <WorkspacePath, WorkspacePath>(workspace.UniqueFilePath);
            luaScript.Globals["CreateDirectory"] = new Action <WorkspacePath>(workspace.CreateDirectoryRecursive);
            luaScript.Globals["MoveTo"]          = new Action <WorkspacePath, WorkspacePath>(workspace.Move);
            luaScript.Globals["CopyTo"]          = new Action <WorkspacePath, WorkspacePath>(workspace.Copy);
            luaScript.Globals["Delete"]          = new Action <WorkspacePath>(workspace.Delete);
            luaScript.Globals["PathExists"]      = new Func <WorkspacePath, bool>(workspace.Exists);
            luaScript.Globals["GetEntities"]     = new Func <WorkspacePath, List <WorkspacePath> >(path =>
                                                                                                   workspace.GetEntities(path).OrderBy(o => o.EntityName, StringComparer.OrdinalIgnoreCase).ToList());
            luaScript.Globals["GetEntitiesRecursive"] = new Func <WorkspacePath, List <WorkspacePath> >(path =>
                                                                                                        workspace.GetEntitiesRecursive(path).ToList());

            luaScript.Globals["RunBackgroundScript"]  = new Func <string, string[], bool>(RunBackgroundScript);
            luaScript.Globals["BackgroundScriptData"] = new Func <string, string, string>(BackgroundScriptData);
            luaScript.Globals["CancelExport"]         = new Action(CancelExport);

            luaScript.Globals["PlayWav"] = new Action <WorkspacePath>(PlayWav);
            luaScript.Globals["StopWav"] = new Action(StopWav);

            luaScript.Globals["CreateDisk"] =
                new Func <string, Dictionary <WorkspacePath, WorkspacePath>, WorkspacePath, int, Dictionary <string, object> >(CreateDisk);

            luaScript.Globals["ClearLog"]     = new Action(workspace.ClearLog);
            luaScript.Globals["ReadLogItems"] = new Func <List <string> >(workspace.ReadLogItems);

            // TODO these are deprecated
            luaScript.Globals["ReadTextFile"]   = new Func <string, string>(ReadTextFile);
            luaScript.Globals["SaveTextToFile"] = (SaveTextToFileDelegator)SaveTextToFile;

            // File helpers
            luaScript.Globals["NewImage"] = new Func <int, int, string[], int[], Image>(NewImage);

            // Read file helpers
            luaScript.Globals["ReadJson"]  = new Func <WorkspacePath, Dictionary <string, object> >(ReadJson);
            luaScript.Globals["ReadText"]  = new Func <WorkspacePath, string>(ReadText);
            luaScript.Globals["ReadImage"] = new Func <WorkspacePath, string, string[], Image>(ReadImage);

            // Save file helpers
            luaScript.Globals["SaveText"]  = new Action <WorkspacePath, string>(SaveText);
            luaScript.Globals["SaveImage"] = new Action <WorkspacePath, Image>(SaveImage);

            luaScript.Globals["AddExporter"] = new Action <WorkspacePath, Image>(SaveImage);

            luaScript.Globals["NewWorkspacePath"] = new Func <string, WorkspacePath>(WorkspacePath.Parse);

            UserData.RegisterType <WorkspacePath>();
            UserData.RegisterType <Image>();

            // Experimental
            // luaScript.Globals["DebugLayers"] = new Action<bool>(runner.DebugLayers);
            // luaScript.Globals["ToggleLayers"] = new Action<int>(runner.ToggleLayers);
            luaScript.Globals["ResizeColorMemory"] = new Action <int, int>(ResizeColorMemory);
        }