コード例 #1
0
        /// <summary>
        /// A default constructor.
        /// </summary>
        /// <param name="messageSink">The test message sink.</param>
        public IntegrationTestFixture(IMessageSink messageSink)
        {
            MessageSink = messageSink;

            //Sets this to testing environment if not in "Production".
            const string AspNetCoreEnvironment = "ASPNETCORE_ENVIRONMENT";

            if (Environment.GetEnvironmentVariable(AspNetCoreEnvironment) == null)
            {
                Environment.SetEnvironmentVariable(AspNetCoreEnvironment, "Development");
            }

            var environmentName = Environment.GetEnvironmentVariable(AspNetCoreEnvironment);
            var configuration   = new ConfigurationBuilder()
                                  .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                  .AddJsonFile($"appsettings.{environmentName}.json", optional: true, reloadOnChange: true)
                                  .AddEnvironmentVariables()
                                  .Build();

            //Collect the database names.
            DatabaseConnectionString = configuration.GetValue <string>($"ConnectionStrings:{DatabaseName}");
            DatabaseSnapshotName     = $"{DatabaseName}_Snapshot_{DateTime.UtcNow.ToString("O")}";

            //The API test server is started in a random free port in order to avoid collisions with the already running APIs,
            //identity or other services. Also connects to the identity server in the right ports.
            int freeEphemeralApiPort = PlatformUtilities.GetFreePortFromEphemeralRange();

            DefaultApiRootUrl = $"http://localhost:{freeEphemeralApiPort}/";
            int freeEphemeralIdentityPort = PlatformUtilities.GetFreePortFromEphemeralRange();

            DefaultIdentityRootUrl = $"http://localhost:{freeEphemeralIdentityPort}/";

            void onBreak(DelegateResult <HttpResponseMessage> handledFault, TimeSpan duration) => Console.WriteLine("temp"); /* Logger.LogError($"Circuit breaking for {duration} due to {handledFault.Exception?.Message ?? handledFault.Result.StatusCode.ToString()}"); */

            void onReset() /* etc */ }
コード例 #2
0
        private void ControllerUpdate()
        {
            AbstractController controller = PlatformUtilities.GetController();

            if (controller != null)
            {
                List <DataPoint> inputs = new List <DataPoint>();

                controller.Update();
                if (controller.IsActive())
                {
                    inputs.AddRange(controller.GetInputs());
                }

                //Collect all touches


                //Making fingers for all touches
                if (inputs.Count > 0)
                {
                    Transform[] fingers = FingerPool.GetFingerCount(inputs.Count);
                    for (int i = 0; i < inputs.Count; i++)
                    {
                        SetFingerToPoint(fingers[i], inputs[i].Postion);
                    }
                }
                else
                {
                    FingerPool.AllToSleep();
                }
            }
        }
コード例 #3
0
ファイル: CygwinFileMapper.cs プロジェクト: optikos/MIEngine
        public string MapCygwinToWindows(string origCygwinPath)
        {
            if (!(_debuggedProcess.LaunchOptions is LocalLaunchOptions))
            {
                return(origCygwinPath);
            }

            LocalLaunchOptions localLaunchOptions = (LocalLaunchOptions)_debuggedProcess.LaunchOptions;

            string cygwinPath = PlatformUtilities.WindowsPathToUnixPath(origCygwinPath);

            string windowsPath = cygwinPath;

            lock (_cygwinToWindows)
            {
                if (!_cygwinToWindows.TryGetValue(cygwinPath, out windowsPath))
                {
                    if (!LaunchCygPathAndReadResult(cygwinPath, localLaunchOptions.MIDebuggerPath, out windowsPath))
                    {
                        return(origCygwinPath);
                    }

                    _cygwinToWindows.Add(cygwinPath, windowsPath);
                }
            }

            return(windowsPath);
        }
コード例 #4
0
        internal override Transaction GetActivationTransaction()
        {
            var transaction = new Transaction($"Activation transaction for unit {UnitName}");

            transaction.Add(new SetUnitStateTask(this, UnitState.Activating, UnitState.Inactive | UnitState.Failed));

            var working_dir = File.WorkingDirectory;
            var user        = (File.Group == null && File.User == null ? null : PlatformUtilities.GetImplementation <IUserIdentifier>(File.Group, File.User));

            switch (File.ServiceType)
            {
            case ServiceType.Simple:
                if (File.ExecStart == null)
                {
                    Log.Error($"Unit {UnitName} has no ExecStart directives.");
                    SetState(UnitState.Failed);
                    return(null);
                }

                if (File.ExecStart.Count != 1)
                {
                    Log.Error($"Service type \"simple\" only supports one ExecStart value, {UnitName} has {File.ExecStart.Count}");
                    SetState(UnitState.Failed);
                    return(null);
                }

                if (File.ExecStartPre.Any())
                {
                    foreach (var line in File.ExecStartPre)
                    {
                        transaction.Add(new RunUnregisteredProcessTask(ServiceManager.ProcessHandler, ProcessStartInfo.FromCommandLine(line, working_dir, user), 5000));
                    }
                }

                transaction.Add(new RunRegisteredProcessTask(ProcessStartInfo.FromCommandLine(File.ExecStart.Single(), working_dir, user), this));

                if (File.ExecStartPost.Any())
                {
                    foreach (var line in File.ExecStartPost)
                    {
                        transaction.Add(new RunUnregisteredProcessTask(ServiceManager.ProcessHandler, ProcessStartInfo.FromCommandLine(line, working_dir, user), 5000));
                    }
                }
                break;

            default:
                Log.Error($"Only the \"simple\" service type is supported for now, {UnitName} has type {File.ServiceType}");
                SetState(UnitState.Failed);
                break;
            }

            transaction.Add(new SetUnitStateTask(this, UnitState.Active, UnitState.Activating));
            transaction.Add(new UpdateUnitActivationTimeTask(this));

            transaction.OnFailure = new SetUnitStateTask(this, UnitState.Failed);

            return(transaction);
        }
コード例 #5
0
        public static void ClassInitialize(TestContext value)
        {
            PlatformUtilities.RegisterImplementations();
            PlatformUtilities.GetImplementation <IPlatformInitialization>().Initialize();
            UnitRegistry.InitializeTypes();
            UnitRegistry.ScanDefaultDirectories();

            File.WriteAllText(path, contents);
        }
コード例 #6
0
        public static string?ReadError()
        {
            var saveFolder = PlatformUtilities.AppDataFolder();
            var saveFile   = Path.Combine(saveFolder, ErrorLogFileName);

            if (!File.Exists(saveFile))
            {
                return(null);
            }

            return(File.ReadAllText(saveFile));
        }
コード例 #7
0
        static void Main(string[] args)
        {
            Log.Info("SharpInit starting");

            PlatformUtilities.RegisterImplementations();
            PlatformUtilities.GetImplementation <IPlatformInitialization>().Initialize();

            Log.Info("Platform initialization complete");

            UnitRegistry.InitializeTypes();
            UnitRegistry.ScanDefaultDirectories();

            Log.Info($"Loaded {UnitRegistry.Units.Count} units");

            UnitRegistry.UnitStateChange += StateChangeHandler;

            Log.Info("Registering IPC context...");

            var context = new ServerIpcContext();

            IpcFunctionRegistry.AddFunction(DynamicIpcFunction.FromContext(context));

            Log.Info("Starting IPC listener...");

            var ipc_listener = new IpcListener();

            ipc_listener.StartListening();

            Log.Info($"Listening on {ipc_listener.SocketEndPoint}");

            if (UnitRegistry.GetUnit("default.target") != null)
            {
                Log.Info("Activating default.target...");
                var result = UnitRegistry.CreateActivationTransaction("default.target").Execute();

                if (result.Type == Tasks.ResultType.Success)
                {
                    Log.Info("Successfully activated default.target.");
                }
                else
                {
                    Log.Info($"Error while activating default.target: {result.Type}, {result.Message}");
                }
            }

            Console.CancelKeyPress += (s, e) =>
            {
                ipc_listener.StopListening();
            };

            Thread.Sleep(-1);
        }
コード例 #8
0
 /// <summary>
 /// Synchronously complete the async operation.
 /// </summary>
 public void WaitForCompletion()
 {
     if (PlatformUtilities.PlatformUsesMultiThreading(Application.platform))
     {
         while (!InvokeWaitForCompletion())
         {
         }
     }
     else
     {
         throw new Exception($"{Application.platform} does not support synchronous Addressable loading.  Please do not use WaitForCompletion on the {Application.platform} platform.");
     }
 }
コード例 #9
0
        /// <summary>
        /// Provisions the app for People app integration if it is supported
        /// by the current platform.
        /// </summary>
        /// <returns>An awaitable Task for social provisioning</returns>
        private async Task _SocialInfoProvisionAsync()
        {
            // Use the SocialInfoProviderManager to provision this app
            if (PlatformUtilities.IsSocialInfoApiAvailable())
            {
                bool isProvisionSuccessful = await SocialInfoProviderManager.ProvisionAsync();

                // Throw an exception if the app could not be provisioned
                if (!isProvisionSuccessful)
                {
                    throw new Exception("Could not provision the app with the SocialInfoProviderManager.");
                }
            }
        }
コード例 #10
0
 private static void WriteError(Exception error)
 {
     try
     {
         var saveFolder = PlatformUtilities.AppDataFolder();
         var saveFile   = Path.Combine(saveFolder, ErrorLogFileName);
         File.WriteAllText(saveFile, error.ToString());
     }
     catch (Exception t)
     {
         Log.Warning(t, "Failed to log error.");
         Log.Error(error, "Original error.");
     }
 }
コード例 #11
0
        public static void ClassInitialize(TestContext value)
        {
            PlatformUtilities.RegisterImplementations();
            PlatformUtilities.GetImplementation <IPlatformInitialization>().Initialize();
            UnitRegistry.InitializeTypes();

            Random rnd           = new Random();
            var    random_buffer = new byte[8];

            rnd.NextBytes(random_buffer);
            DirectoryName = BitConverter.ToString(random_buffer).Replace("-", "").ToLower();
            Directory.CreateDirectory(DirectoryName);

            File.WriteAllText(TestUnitPath, TestUnitContents);
        }
コード例 #12
0
        public static MITextPosition TryParse(DebuggedProcess process, TupleValue miTuple)
        {
            string filename = process.GetMappedFileFromTuple(miTuple);

            if (string.IsNullOrWhiteSpace(filename))
            {
                return(null);
            }

            filename = PlatformUtilities.PathToHostOSPath(filename);

            uint?line = miTuple.TryFindUint("line");

            if (!line.HasValue || line.Value == 0)
            {
                return(null);
            }

            uint lineValue = line.Value;

            Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION startPosition = new Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION();
            startPosition.dwLine   = lineValue - 1;
            startPosition.dwColumn = 0;

            uint?startColumn = miTuple.TryFindUint("col");

            if (startColumn > 0)
            {
                startPosition.dwColumn = startColumn.Value - 1;
            }

            Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION endPosition = startPosition;
            uint?endLine = miTuple.TryFindUint("end-line");

            if (endLine > 0)
            {
                endPosition.dwLine = endLine.Value - 1;

                uint?endCol = miTuple.TryFindUint("end-col");
                if (endCol > 0)
                {
                    endPosition.dwColumn = endCol.Value - 1;
                }
            }

            return(new MITextPosition(filename, startPosition, endPosition));
        }
コード例 #13
0
        /// <summary>
        /// Downloads the feed asynchronously
        /// </summary>
        /// <returns>An awaitable Task</returns>
        public override async Task DownloadFeedAsync()
        {
            // Query the "database" for the home feeds
            IEnumerable <FeedItem> homeFeedItems =
                InMemorySocialCache.Instance.GetHomeFeeds(OwnerRemoteId, ItemCount);

            // Check if the platform supports the SocialInfo APIs
            if (!PlatformUtilities.IsSocialInfoApiAvailable())
            {
                return;
            }

            // Create the social feed updater
            SocialFeedUpdater feedUpdater = await SocialInfoProviderManager.CreateSocialFeedUpdaterAsync(
                SocialFeedKind.HomeFeed,
                SocialFeedUpdateMode.Replace,
                OwnerRemoteId);

            // Generate each of the feed items
            foreach (FeedItem fi in homeFeedItems)
            {
                SocialFeedItem item = new SocialFeedItem();

                item.Timestamp              = fi.Timestamp;
                item.RemoteId               = fi.Id;
                item.TargetUri              = fi.TargetUri;
                item.Author.DisplayName     = fi.AuthorDisplayName;
                item.Author.RemoteId        = fi.AuthorId;
                item.PrimaryContent.Title   = fi.Title;
                item.PrimaryContent.Message = fi.Message;

                if (fi.ImageUri != null)
                {
                    item.Thumbnails.Add(new SocialItemThumbnail()
                    {
                        TargetUri = fi.TargetUri,
                        ImageUri  = fi.ImageUri
                    });
                }

                feedUpdater.Items.Add(item);
            }

            await feedUpdater.CommitAsync();
        }
コード例 #14
0
        public override Transaction GetReloadTransaction()
        {
            var transaction = new Transaction();

            transaction.Add(new SetUnitStateTask(this, UnitState.Reloading, UnitState.Active));

            var working_dir = File.WorkingDirectory;
            var user        = (File.Group == null && File.User == null ? null : PlatformUtilities.GetImplementation <IUserIdentifier>(File.Group, File.User));

            if (!File.ExecReload.Any())
            {
                throw new Exception($"Unit {UnitName} has no ExecReload directives.");
            }

            foreach (var reload_cmd in File.ExecReload)
            {
                transaction.Add(new RunUnregisteredProcessTask(ServiceManager.ProcessHandler, ProcessStartInfo.FromCommandLine(reload_cmd, working_dir, user), 5000));
            }

            transaction.Add(new SetUnitStateTask(this, UnitState.Active, UnitState.Reloading));

            return(transaction);
        }
コード例 #15
0
        /// <summary>
        /// Handler for the user clicking the LogOut button
        /// </summary>
        public async void LogOut_Button_Click(object sender, RoutedEventArgs e)
        {
            // Get the ContactList and ContactAnnotationList
            ContactList contactList = await _GetContactListAsync();

            // Delete the contact list to remove all of the information that was
            // inserted by this app
            await contactList.DeleteAsync();

            // Use the SocialInfoProviderManager to deprovision this app.
            // In build 10240, this API is only present in the Mobile SDK extension.
            if (PlatformUtilities.IsSocialInfoApiAvailable())
            {
                await SocialInfoProviderManager.DeprovisionAsync();
            }

            // Mark the user as no longer logged in
            ApplicationSettings.SaveIsUserLoggedIn(false);

            // Update the state of the buttons
            LogInButton.IsEnabled  = true;
            LogOutButton.IsEnabled = !LogInButton.IsEnabled;
        }
コード例 #16
0
        /// <summary>
        /// Downloads the feed asynchronously
        /// </summary>
        /// <returns>An awaitable Task</returns>
        public override async Task DownloadFeedAsync()
        {
            // Get the dashboard feed item from the database
            FeedItem dashboardFeedItem = InMemorySocialCache.Instance.GetDashboardFeed(OwnerRemoteId);

            if (dashboardFeedItem != null)
            {
                // Check if the platform supports the SocialInfo APIs
                if (!PlatformUtilities.IsSocialInfoApiAvailable())
                {
                    return;
                }

                SocialDashboardItemUpdater dashboard =
                    await SocialInfoProviderManager.CreateDashboardItemUpdaterAsync(OwnerRemoteId);

                dashboard.Content.Message = dashboardFeedItem.Message;
                dashboard.Content.Title   = dashboardFeedItem.Title;
                dashboard.Timestamp       = dashboardFeedItem.Timestamp;

                // The TargetUri of the dashboard always has to be set
                dashboard.TargetUri = dashboardFeedItem.TargetUri;

                // For a thumbnail, there must always be a TargetUri.
                if ((dashboardFeedItem.ImageUri != null) && (dashboardFeedItem.TargetUri != null))
                {
                    dashboard.Thumbnail = new SocialItemThumbnail()
                    {
                        ImageUri  = dashboardFeedItem.ImageUri,
                        TargetUri = dashboardFeedItem.TargetUri
                    };
                }

                await dashboard.CommitAsync();
            }
        }
コード例 #17
0
        internal static void DrawPatreon(SpriteBatch sb, int num109, int num110, int num111, bool hasFocus, Color color12)
        {
            string patreonShortURL = !vanillaMode ? "Switch to vanilla mode" : "Switch to TML";
            string tmlModeString   = liteMode ? "Disable lite mode" : "Enable lite mode";
            bool   showPatreon     = Main.menuMode == 0;
            string architecture    = $"(Running in {(Environment.Is64BitProcess ? 64.ToString() : 32.ToString())} bit mode)";
            string GoG             = GoGVerifier.IsGoG ? "GoG" : "Steam";
            string drawVersion;

            if (vanillaMode)
            {
                drawVersion = Main.versionNumber;
            }
            else
            {
                drawVersion = Main.versionNumber + Environment.NewLine + ModLoader.versionedName + $" - {architecture} {GoG} {PlatformUtilities.RunningPlatform()}";
            }

            Vector2 origin3 = Main.fontMouseText.MeasureString(drawVersion);

            origin3.X *= 0.5f;
            origin3.Y *= 0.5f;
            Main.spriteBatch.DrawString(Main.fontMouseText, drawVersion, new Vector2(origin3.X + num110 + 10f, Main.screenHeight - origin3.Y - num111 + 2f), color12, 0f, origin3, 1f, SpriteEffects.None, 0f);
            if (num109 == 4)
            {
                color12 = new Microsoft.Xna.Framework.Color(127, 191, 191, 76);
            }

            if (Main.menuMode == 10002 && vanillaMode)
            {
                Main.menuMode = 0;
            }

            if (showPatreon)
            {
                Vector2 urlSize = Main.fontMouseText.MeasureString(patreonShortURL);
                Main.spriteBatch.DrawString(Main.fontMouseText, patreonShortURL, new Vector2(num110 + 10f, Main.screenHeight - origin3.Y - 50f - num111 + 2f), color12, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                if (num109 == 4 && Main.mouseLeftRelease && Main.mouseLeft && new Microsoft.Xna.Framework.Rectangle((int)(num110 + 10f), (int)(Main.screenHeight - origin3.Y - 50f - num111 + 2f), (int)urlSize.X, (int)origin3.Y).Contains(new Microsoft.Xna.Framework.Point(Main.mouseX, Main.mouseY)) && hasFocus)
                {
                    Main.PlaySound(SoundID.MenuOpen);
                    //vanillaMode = !vanillaMode;
                    //Main.SaveSettings();
                    //Interface.infoMessage.Show("You'll need to restart the game so that the necessary change can apply.", 0, null, "Restart", () => Environment.Exit(0));
                    Interface.infoMessage.Show("This feature is note completely done and will be released at a further time.\n\n\n-Dradonhunter11", 0);
                }

                if (!vanillaMode)
                {
                    urlSize = Main.fontMouseText.MeasureString(tmlModeString);
                    Main.spriteBatch.DrawString(Main.fontMouseText, tmlModeString, new Vector2(num110 + 10f, Main.screenHeight - origin3.Y - 72f - num111 + 2f), color12, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    if (num109 == 4 && Main.mouseLeftRelease && Main.mouseLeft && new Microsoft.Xna.Framework.Rectangle((int)(num110 + 10f), (int)(Main.screenHeight - origin3.Y - 72f - num111 + 2f), (int)urlSize.X, (int)origin3.Y).Contains(new Microsoft.Xna.Framework.Point(Main.mouseX, Main.mouseY)) && hasFocus)
                    {
                        string message = liteMode ? "Your game will be switched to the full tML 64bit version, for that you'll need to restart your game completely to have the effect applied.\n" +
                                         "In this mode you can generate XL world and have an expended chest limit, however you can't play with 32bit anymore unless you switch back to tML64bit lite mode" :
                                         "Your game will be switched to the tML 64bit lite mode, for that you'll need to restart your game completely to have the effect applied.\n" +
                                         "In this mode, you can play with other 32bit client and lite user, but cannot play with the full tML64bit user, however you can switch back to the full tML64bit.";

                        Main.PlaySound(SoundID.MenuOpen);
                        Interface.infoMessage.SpecialShow(message, 0, null, "Go back", "Apply", () => {
                            liteMode = !liteMode;
                            Main.SaveSettings();
                            Environment.Exit(0);
                        });
                    }
                }
            }
        }
コード例 #18
0
ファイル: UIWorldListItem.cs プロジェクト: PhelixSky/TeDW
 private void SeedButtonClick(UIMouseEvent evt, UIElement listeningElement)
 {
     PlatformUtilities.SetClipboard(this._data.SeedText);
     this._buttonLabel.SetText(Language.GetTextValue("UI.SeedCopied"));
 }
コード例 #19
0
        static void EmbedAssetBundles(List <FileInfo> assemblies, IEnumerable <BuiltAssetBundle> builtBundles)
        {
            Debug.Log("Embedding Asset Bundles");
            var assemblyReplacements = new Dictionary <string, string>
            {
                { "Assembly-CSharp", Data.ModName },
                { "HollowKnight", "Assembly-CSharp" }
            };

            /*foreach (var assembly in assemblies)
             * {
             *      Debug.Log("Built Assembly = " + assembly.FullName);
             * }
             * foreach (var bundle in builtBundles)
             * {
             *      Debug.Log("Built Bundle = " + bundle.File.FullName);
             * }*/
            var bundlePairs = GetBundleToAssemblyPairs(assemblyReplacements);

            /*foreach (var pair in bundlePairs)
             * {
             *      Debug.Log($"Bundle Pair = {pair.Key} - {pair.Value.Name}");
             * }*/
            foreach (var bundle in builtBundles)
            {
                if (bundlePairs.ContainsKey(bundle.File.Name))
                {
                    var asmName = bundlePairs[bundle.File.Name];
                    //Debug.Log("A_ NAME = " + asmName.Name);

                    var asmDllName = asmName.Name + ".dll";
                    //Debug.Log("ASMDLLNAME = " + asmDllName);

                    var asmFile = assemblies.FirstOrDefault(a => a.Name == asmDllName);
                    //Debug.Log("ASM FILE = " + asmFile?.FullName);

                    if (asmFile != null)
                    {
                        var processedBundleLocation = PostProcessBundle(bundle, assemblyReplacements);
                        //Debug.Log($"Embedding {processedBundleLocation} into {asmFile.FullName}");
                        lock (embedLock)
                        {
                            EmbedResourceCMD.EmbedResource(asmFile.FullName, processedBundleLocation, bundle.File.Name + PlatformUtilities.GetBuildTargetExtension(bundle.Target), compression: WeaverBuildTools.Enums.CompressionMethod.NoCompression);
                        }
                    }
                }
                //var assembly = assemblies.FirstOrDefault(a => a.Name == bundle.)
            }
        }
コード例 #20
0
        static void BeginBundleProcess()
        {
            UnboundCoroutine.Start(BundleRoutine());
            IEnumerator BundleRoutine()
            {
                yield return(new WaitForSeconds(1f));

                try
                {
                    //Debug.Log("E_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
                    Debug.Log("Beginning Bundle Process");
#if !MULTI_THREADED_EMBEDDING
                    var builtAssetBundles = new List <BuiltAssetBundle>();
#else
                    List <Task> embeddingTasks = new List <Task>();
#endif
                    var assemblies = new List <FileInfo>
                    {
                        new FileInfo(Data.WeaverCoreDLL)
                    };

                    if (!Data.WeaverCoreOnly)
                    {
                        assemblies.Add(new FileInfo(Data.ModDLL));
                    }

                    //BuildSettings settings = new BuildSettings();
                    //settings.GetStoredSettings();

                    var temp         = Path.GetTempPath();
                    var bundleBuilds = new DirectoryInfo(temp + "BundleBuilds\\");

                    if (bundleBuilds.Exists)
                    {
                        bundleBuilds.Delete(true);
                    }

                    bundleBuilds.Create();

                    foreach (var target in BuildScreen.BuildSettings.GetBuildModes())
                    {
                        if (!PlatformUtilities.IsPlatformSupportLoaded(target))
                        {
                            continue;
                        }
                        var targetFolder = bundleBuilds.CreateSubdirectory(target.ToString());

                        targetFolder.Create();



                        BuildAssetBundles(target, BuildTargetGroup.Standalone, targetFolder);
#if !MULTI_THREADED_EMBEDDING
                        foreach (var bundleFile in targetFolder.GetFiles())
                        {
                            if (bundleFile.Extension == "" && !bundleFile.Name.Contains("BundleBuilds"))
                            {
                                builtAssetBundles.Add(new BuiltAssetBundle
                                {
                                    File   = bundleFile,
                                    Target = target
                                });
                            }
                        }
#else
                        List <BuiltAssetBundle> builtBundles = new List <BuiltAssetBundle>();
                        foreach (var bundleFile in targetFolder.GetFiles())
                        {
                            if (bundleFile.Extension == "" && !bundleFile.Name.Contains("BundleBuilds"))
                            {
                                builtBundles.Add(new BuiltAssetBundle
                                {
                                    File   = bundleFile,
                                    Target = target
                                });
                            }
                        }
                        embeddingTasks.Add(Task.Run(() =>
                        {
                            if (Data.WeaverCoreOnly)
                            {
                                EmbedAssetBundles(assemblies, builtBundles.Where(a => a.File.Name.ToLower().Contains("weavercore_bundle")));
                            }
                            else
                            {
                                EmbedAssetBundles(assemblies, builtBundles);
                            }
                        }));
#endif
                    }

#if !MULTI_THREADED_EMBEDDING
                    if (Data.WeaverCoreOnly)
                    {
                        EmbedAssetBundles(assemblies, builtAssetBundles.Where(a => a.File.Name.ToLower().Contains("weavercore_bundle")));
                    }
                    else
                    {
                        EmbedAssetBundles(assemblies, builtAssetBundles);
                    }
#else
                    Task.WaitAll(embeddingTasks.ToArray());
#endif
                    EmbedWeaverCoreResources();
                    Data.BundlingSuccessful = true;
                }
                catch (Exception e)
                {
                    Debug.LogError("Error creating Asset Bundles");
                    Debug.LogException(e);
                }
                finally
                {
                    if (!Data.BundlingSuccessful)
                    {
                        Debug.LogError("Error creating Asset Bundles");
                    }
                    //Debug.Log("POST_4_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
                    //UnboundCoroutine.Start(Delay());
                    //IEnumerator Delay()
                    //{
                    //Debug.Log("POST_5_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
                    //yield return new WaitForSeconds(0.5f);
                    //Debug.Log("F_Editor File Locked = " + IsFileLocked(new FileInfo("Library\\ScriptAssemblies\\WeaverCore.Editor.dll")));
                    DoneWithAssetBundling(typeof(BundleTools).GetMethod(nameof(CompleteBundlingProcess), BindingFlags.Static | BindingFlags.NonPublic));
                    //}
                }
            }

            //Debug.Log("Beginning Bundle Process!!!");
        }
コード例 #21
0
 public ServiceManager() :
     this(PlatformUtilities.GetImplementation <IProcessHandler>())
 {
 }
コード例 #22
0
 public void CanIdentifyMultiThreadedPlatforms(RuntimePlatform platform, bool usesMultiThreading)
 {
     Assert.AreEqual(usesMultiThreading, PlatformUtilities.PlatformUsesMultiThreading(platform));
 }
コード例 #23
0
        internal static void DrawPatreon(SpriteBatch sb, int loopNum, int offsetX, int offsetY, bool hasFocus, Color color12)
        {
            // TODO: Localization for vanilla, tml, and lite modes when they're actually used
            string patreonShortURL = "";
            string tmlModeString   = "";
            bool   showPatreon     = Main.menuMode == 0;
            string architecture    = Language.GetTextValue("tModLoader.RunningBitMode", Environment.Is64BitProcess ? 64.ToString() : 32.ToString());
            string GoG             = InstallVerifier.IsGoG ? Language.GetTextValue("tModLoader.GoG") : Language.GetTextValue("tModLoader.Steam");
            string drawVersion;

            if (vanillaMode)
            {
                drawVersion = Main.versionNumber;
            }
            else
            {
                drawVersion = Main.versionNumber + Environment.NewLine + ModLoader.versionedName + $" - {architecture} {GoG} {PlatformUtilities.RunningPlatform()}";
            }

            Vector2 origin3 = Main.fontMouseText.MeasureString(drawVersion);

            origin3.X *= 0.5f;
            origin3.Y *= 0.5f;

            Main.spriteBatch.DrawString(Main.fontMouseText, drawVersion, new Vector2(origin3.X + offsetX + 10f, Main.screenHeight - origin3.Y - offsetY + 2f), color12, 0f, origin3, 1f, SpriteEffects.None, 0f);

            if (loopNum == 4)
            {
                color12 = new Color(127, 191, 191, 76);
            }

            if (Main.menuMode == 10002 && vanillaMode)
            {
                Main.menuMode = 0;
            }

            if (showPatreon)
            {
                Vector2 urlSize = Main.fontMouseText.MeasureString(patreonShortURL);
                Main.spriteBatch.DrawString(Main.fontMouseText, patreonShortURL, new Vector2(offsetX + 10f, Main.screenHeight - origin3.Y - 50f - offsetY + 2f), color12, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                if (loopNum == 4 && Main.mouseLeftRelease && Main.mouseLeft && new Rectangle((int)(offsetX + 10f), (int)(Main.screenHeight - origin3.Y - 50f - offsetY + 2f), (int)urlSize.X, (int)origin3.Y).Contains(new Point(Main.mouseX, Main.mouseY)) && hasFocus)
                {
                    Main.PlaySound(SoundID.MenuOpen);

                    /*vanillaMode = !vanillaMode;
                     * Main.SaveSettings();
                     * Interface.infoMessage.Show("You'll need to restart the game so that the necessary change can apply.", 0, null, "Restart", () => Environment.Exit(0));*/
                    Interface.infoMessage.Show(Language.GetTextValue("tModLoader.UnfinishedFeature"), 0);
                }

                if (!vanillaMode)
                {
                    urlSize = Main.fontMouseText.MeasureString(tmlModeString);
                    Main.spriteBatch.DrawString(Main.fontMouseText, tmlModeString, new Vector2(offsetX + 10f, Main.screenHeight - origin3.Y - 72f - offsetY + 2f), color12, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    if (loopNum == 4 && Main.mouseLeftRelease && Main.mouseLeft && new Microsoft.Xna.Framework.Rectangle((int)(offsetX + 10f), (int)(Main.screenHeight - origin3.Y - 72f - offsetY + 2f), (int)urlSize.X, (int)origin3.Y).Contains(new Microsoft.Xna.Framework.Point(Main.mouseX, Main.mouseY)) && hasFocus)
                    {
                        string message = liteMode ? Language.GetTextValue("tModLoader.SwitchFromLite") : Language.GetTextValue("tModLoader.SwitchToLite");

                        Main.PlaySound(SoundID.MenuOpen);
                        Interface.infoMessage.SpecialShow(message, 0, null, Language.GetTextValue("UI.Back"), Language.GetTextValue("LegacyMenu.134"), () => {                         // 134: Apply
                            liteMode = !liteMode;
                            Main.SaveSettings();
                            Environment.Exit(0);
                        });
                    }
                }
            }
        }
コード例 #24
0
 public CleanBundleCacheOperation(AddressablesImpl aa, bool forceSingleThreading)
 {
     m_Addressables      = aa;
     m_UseMultiThreading = forceSingleThreading ? false : PlatformUtilities.PlatformUsesMultiThreading(Application.platform);
 }
コード例 #25
0
 public ProcessEntry32(uint?size) : this()
 {
     this.size = size ?? (uint)PlatformUtilities.MarshalSizeOf <ProcessEntry32>();
 }
コード例 #26
0
        public static string GetInputText(string oldString)
        {
            if (!Main.hasFocus)
            {
                return(oldString);
            }
            inputTextEnter  = false;
            inputTextEscape = false;
            string text    = oldString;
            string newKeys = "";

            if (text == null)
            {
                text = "";
            }
            bool flag = false;

            if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl) || inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl))
            {
                if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Z) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Z))
                {
                    text = "";
                }
                else if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X))
                {
                    PlatformUtilities.SetClipboard(oldString);
                    text = "";
                }
                else if ((inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C)) || (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert)))
                {
                    PlatformUtilities.SetClipboard(oldString);
                }
                else if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V))
                {
                    newKeys += PlatformUtilities.GetClipboard();
                }
            }
            else
            {
                if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) || inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift))
                {
                    if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Delete) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Delete))
                    {
                        Thread thread = new Thread((ThreadStart) delegate
                        {
                            if (oldString.Length > 0)
                            {
                                Clipboard.SetText(oldString);
                            }
                        });
                        thread.SetApartmentState(ApartmentState.STA);
                        thread.Start();
                        while (thread.IsAlive)
                        {
                        }
                        text = "";
                    }
                    if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert))
                    {
                        Thread thread2 = new Thread((ThreadStart) delegate
                        {
                            string text2 = Clipboard.GetText();
                            for (int l = 0; l < text2.Length; l++)
                            {
                                if (text2[l] < ' ' || text2[l] == '\u007f')
                                {
                                    text2 = text2.Replace(string.Concat(text2[l--]), "");
                                }
                            }
                            newKeys += text2;
                        });
                        thread2.SetApartmentState(ApartmentState.STA);
                        thread2.Start();
                        while (thread2.IsAlive)
                        {
                        }
                    }
                }
                for (int i = 0; i < Main.keyCount; i++)
                {
                    int    num = Main.keyInt[i];
                    string str = Main.keyString[i];
                    if (num == 13)
                    {
                        inputTextEnter = true;
                    }
                    else if (num == 27)
                    {
                        inputTextEscape = true;
                    }
                    else if (num >= 32 && num != 127)
                    {
                        newKeys += str;
                    }
                }
            }
            Main.keyCount = 0;
            text         += newKeys;
            oldInputText  = inputText;
            inputText     = Keyboard.GetState();
            Microsoft.Xna.Framework.Input.Keys[] pressedKeys  = inputText.GetPressedKeys();
            Microsoft.Xna.Framework.Input.Keys[] pressedKeys2 = oldInputText.GetPressedKeys();
            if (inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back) && oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back))
            {
                if (backSpaceCount == 0)
                {
                    backSpaceCount = 7;
                    flag           = true;
                }
                backSpaceCount--;
            }
            else
            {
                backSpaceCount = 15;
            }
            for (int j = 0; j < pressedKeys.Length; j++)
            {
                bool flag2 = true;
                for (int k = 0; k < pressedKeys2.Length; k++)
                {
                    if (pressedKeys[j] == pressedKeys2[k])
                    {
                        flag2 = false;
                    }
                }
                string a = string.Concat(pressedKeys[j]);
                if (a == "Back" && (flag2 || flag) && text.Length > 0)
                {
                    TextSnippet[] array = ChatManager.ParseMessage(text, Microsoft.Xna.Framework.Color.White);
                    if (array[array.Length - 1].DeleteWhole)
                    {
                        text = text.Substring(0, text.Length - array[array.Length - 1].TextOriginal.Length);
                    }
                    else
                    {
                        text = text.Substring(0, text.Length - 1);
                    }
                }
            }
            return(text);
        }