Ejemplo n.º 1
0
 internal static DataLevelrank _create(Config.Stream os)
 {
     var self = new DataLevelrank();
     self.Level = os.ReadInt32();
     self.Rank = os.ReadInt32();
     return self;
 }
Ejemplo n.º 2
0
 internal static DataRange _create(Config.Stream os)
 {
     var self = new DataRange();
     self.Min = os.ReadInt32();
     self.Max = os.ReadInt32();
     return self;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 设置任务状态UI
        /// </summary>
        /// <param name="status">任务状态</param>
        private void SetTaskStatusUi(Config.Action status) {
            #region 根据任务状态设置UI
            this.tolAddTask.Enabled = true;
            this.tolEditTask.Enabled = true;
            this.tolDeleteTask.Enabled = true;
            switch (status) {
                case Config.Action.Finish:
                case Config.Action.Ready:
                case Config.Action.Stop:   //停止状态
                    this.tolStartTask.Enabled = true;
                    this.tolPauseTask.Enabled = false;
                    this.tolStopTask.Enabled = false;
                    break;
                case Config.Action.Start:  //运行状态
                    this.tolStartTask.Enabled = false;
                    this.tolPauseTask.Enabled = true;
                    this.tolStopTask.Enabled = true;

                    this.tolEditTask.Enabled = false;
                    this.tolDeleteTask.Enabled = false;
                    break;
                case Config.Action.Pause:  //暂停状态
                    this.tolStartTask.Enabled = true;
                    this.tolPauseTask.Enabled = false;
                    this.tolStopTask.Enabled = true;
                    break;
            }
            #endregion
        }
Ejemplo n.º 4
0
 internal static DataPosition _create(Config.Stream os)
 {
     var self = new DataPosition();
     self.X = os.ReadInt32();
     self.Y = os.ReadInt32();
     self.Z = os.ReadInt32();
     return self;
 }
Ejemplo n.º 5
0
 internal static void Initialize(Config.Stream os, Config.LoadErrors errors)
 {
     all = new Config.KeyedList<int, DataMonster>();
     for (var c = os.ReadSize(); c > 0; c--) {
         var self = _create(os);
         all.Add(self.Id, self);
     }
 }
Ejemplo n.º 6
0
 internal static DataMonster _create(Config.Stream os)
 {
     var self = new DataMonster();
     self.Id = os.ReadInt32();
     self.PosList = new List<Config.DataPosition>();
     for (var c = (int)os.ReadSize(); c > 0; c--)
         self.PosList.Add(Config.DataPosition._create(os));
     return self;
 }
Ejemplo n.º 7
0
 private void LoadConfig()
 {
     try
     {
         _config = Import.LoadConfigFromXmlFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.xml"));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
    public DebugBoot(string modDirectory, string configDirectory, IReloadedHooks hooks)
    {
        // Setup Config
        _configurator = new Configurator(configDirectory);
        _configurator.Migrate(modDirectory, _configurator.ConfigFolder);
        _config = _configurator.GetConfiguration <Config.Config>(0);
        _config.ConfigurationUpdated += configurable =>
        {
            _config = (Config.Config)configurable;
            ConfigToPinnable(_config);
            Console.WriteLine($"Debug Boot Configuration Updated. Set new main menu mode.");
        };

        ConfigToPinnable(_config);

        // Apply Boot Time Constants
        *_stageId   = _config.BootOptions.Stage;
        *_teamOne   = _config.BootOptions.TeamP1;
        *_teamTwo   = _config.BootOptions.TeamP2;
        *_teamThree = _config.BootOptions.TeamP3;
        *_teamFour  = _config.BootOptions.TeamP4;

        // Setup mid function hooks.
        // Disasm name: Main::Loop
        string[] asmHookSetMainMenu =
        {
            $"use32",
            $"mov ecx, dword [{(IntPtr)_mainMenuSystemMode.Pointer}]", // New line, sacrificing ECX.
            $"mov [eax + 0x38], ecx",
            $"mov ecx, [esi]",
            $"mov [esi + 4], edi",
        };

        string[] asmHookStartGame =
        {
            $"use32",
            $"mov [{(IntPtr)_ediBackup.Pointer}], edi",            // Backup EDI
            $"mov edi, dword [{(IntPtr)_bootSystemMode.Pointer}]", // Replace EDI
            $"mov [0xA82034], ebp",
            $"mov [eax + 0x38], edi",                              // Set SystemMode
            $"mov edi, dword [{(IntPtr)_ediBackup.Pointer}]",      // Restore EDI
        };

        _loadMainMenuHook = hooks.CreateAsmHook(asmHookSetMainMenu, 0x427342, AsmHookBehaviour.DoNotExecuteOriginal).Activate();
        _bootHook         = hooks.CreateAsmHook(asmHookStartGame, 0x00427138, AsmHookBehaviour.DoNotExecuteOriginal).Activate();
    }
Ejemplo n.º 9
0
    private static void ValidateConfig(Config.Config config)
    {
        var v = new Config.Validator("init");

        v.AddIfEmpty(config.PackageMeta.Namespace, "Package Namespace");
        v.AddIfEmpty(config.PackageMeta.Name, "Package Name");
        v.AddIfNotSemver(config.PackageMeta.VersionNumber, "Package VersionNumber");
        v.AddIfNull(config.PackageMeta.Description, "Package Description");
        v.AddIfNull(config.PackageMeta.WebsiteUrl, "Package WebsiteUrl");
        v.AddIfNull(config.PackageMeta.ContainsNsfwContent, "Package ContainsNsfwContent");
        v.AddIfNull(config.PackageMeta.Dependencies, "Package Dependencies");
        v.AddIfEmpty(config.BuildConfig.IconPath, "Build IconPath");
        v.AddIfEmpty(config.BuildConfig.ReadmePath, "Build ReadmePath");
        v.AddIfEmpty(config.BuildConfig.OutDir, "Build OutDir");
        v.AddIfEmpty(config.PublishConfig.Repository, "Publish Repository");
        v.ThrowIfErrors();
    }
Ejemplo n.º 10
0
        public void GetCabinetConfig()
        {
            IConfig _config = new Config.Config();

            _config.CabinetName().Should().Be("Default");
            _config.CabinetHeight().Should().Be(720);
            _config.CabinetWidth().Should().Be(600);
            _config.CabinetDepth().Should().Be(510);
            _config.CabinetSizeElement().Should().Be(18);
            _config.CabinetBack().Should().Be(3);
            _config.SlotsLeft().Should().Be(3);
            _config.SlotsRight().Should().Be(3);
            _config.SlotsBottom().Should().Be(3);
            _config.SlotsTop().Should().Be(3);
            _config.SlotsBetweenCabinet().Should().Be(2);
            _config.SlotsBetweenHorizontally().Should().Be(3);
            _config.SlotsBetweenVertically().Should().Be(3);
        }
Ejemplo n.º 11
0
    private static UploadInitiateData InitiateUploadRequest(Config.Config config, string filepath)
    {
        var response = HttpClient.Send(config.Api.StartUploadMedia(filepath));

        HandleRequestError("initializing the upload", response, HttpStatusCode.Created);

        using var responseReader = new StreamReader(response.Content.ReadAsStream());
        var responseContent = responseReader.ReadToEnd();
        var uploadData      = UploadInitiateData.Deserialize(responseContent);

        if (uploadData is null)
        {
            Write.ErrorExit("Undeserializable InitiateUploadRequest response:", Dim(responseContent));
            throw new PublishCommandException();
        }

        if (uploadData.Metadata?.Filename is null || uploadData.Metadata?.UUID is null)
        {
            Write.ErrorExit("No valid Metadata found in InitiateUploadRequest response:", Dim(responseContent));
            throw new PublishCommandException();
        }

        if (uploadData.UploadUrls is null)
        {
            Write.ErrorExit("No valid UploadUrls found in InitiateUploadRequest response:", Dim(responseContent));
            throw new PublishCommandException();
        }

        string[] suffixes    = { "B", "KB", "MB", "GB", "TB" };
        int      suffixIndex = 0;
        long     size        = uploadData.Metadata.Size;

        while (size >= 1024 && suffixIndex < suffixes.Length)
        {
            size /= 1024;
            suffixIndex++;
        }

        var details = $"({size}{suffixes[suffixIndex]}) in {uploadData.UploadUrls.Length} chunks...";

        Write.WithNL($"Uploading {Cyan(uploadData.Metadata.Filename)} {details}", after: true);

        return(uploadData);
    }
Ejemplo n.º 12
0
    private static void PublishPackageRequest(Config.Config config, string uploadUuid)
    {
        var response = HttpClient.Send(config.Api.SubmitPackage(uploadUuid));

        HandleRequestError("publishing package", response);

        using var responseReader = new StreamReader(response.Content.ReadAsStream());
        var responseContent = responseReader.ReadToEnd();
        var jsonData        = PublishData.Deserialize(responseContent);

        if (jsonData?.PackageVersion?.DownloadUrl is null)
        {
            Write.ErrorExit(
                "Field package_version.download_url missing from PublishPackageRequest response:",
                Dim(responseContent)
                );
            throw new PublishCommandException();
        }

        Write.Success($"Successfully published {Cyan($"{config.PackageMeta.Namespace}-{config.PackageMeta.Name}")}");
        Write.Line($"It's available at {Cyan(jsonData.PackageVersion.DownloadUrl)}");
    }
 public void SetUp()
 {
     _config = new Config();
 }
Ejemplo n.º 14
0
 internal void _resolve(Config.LoadErrors errors)
 {
     RefRank = Config.Equip.DataRank.Get(Rank);
     if (RefRank == null) errors.RefNull("LevelRank", ToString(), "Rank", Rank);
 }
Ejemplo n.º 15
0
 internal static void Resolve(Config.LoadErrors errors)
 {
     foreach (var v in All())
         v._resolve(errors);
 }
Ejemplo n.º 16
0
 internal static DataLoot _create(Config.Stream os)
 {
     var self = new DataLoot();
     self.Lootid = os.ReadInt32();
     self.Ename = os.ReadString();
     self.Name = os.ReadString();
     self.ChanceList = new List<int>();
     for (var c = (int)os.ReadSize(); c > 0; c--)
         self.ChanceList.Add(os.ReadInt32());
     return self;
 }
 private void ConfigToPinnable(Config.Config config)
 {
     _mainMenuSystemMode.Value = (int)config.MainMenuMode;
     _bootSystemMode.Value     = (int)config.BootMode;
 }
Ejemplo n.º 18
0
 internal void _resolve(Config.LoadErrors errors)
 {
     ListRefLootid = new List<Config.DataLootitem>();
     foreach (var v in Config.DataLootitem.All())
     {
     if (v.Lootid.Equals(Lootid))
         ListRefLootid.Add(v);
     }
 }
Ejemplo n.º 19
0
    public static int PublishFile(Config.Config config, string filepath)
    {
        Write.WithNL($"Publishing {Cyan(filepath)}", before: true, after: true);

        if (!File.Exists(filepath))
        {
            Write.ErrorExit(
                "File selected for publish was not found",
                $"Looked from: {White(Dim(filepath))}"
                );
            return(1);
        }

        UploadInitiateData uploadData;

        try
        {
            uploadData = InitiateUploadRequest(config, filepath);
        }
        catch (PublishCommandException)
        {
            return(1);
        }

        Task <CompletedUpload.CompletedPartData>[] uploadTasks;

        try
        {
            uploadTasks = uploadData.UploadUrls !.Select(  // Validated in InitiateUploadRequest
                partData => UploadChunk(partData, filepath)
                ).ToArray();
        }
        catch (PublishCommandException)
        {
            return(1);
        }

        string uploadUuid = uploadData.Metadata?.UUID !;  // Validated in InitiateUploadRequest

        try
        {
            var spinner = new ProgressSpinner("chunks uploaded", uploadTasks);
            spinner.Start().GetAwaiter().GetResult();
        }
        catch (SpinnerException)
        {
            HttpClient.Send(config.Api.AbortUploadMedia(uploadUuid));
            return(1);
        }

        var uploadedParts = uploadTasks.Select(x => x.Result).ToArray();

        try
        {
            var response = HttpClient.Send(
                config.Api.FinishUploadMedia(
                    new CompletedUpload
            {
                Parts = uploadedParts
            },
                    uploadUuid
                    )
                );

            HandleRequestError("Finishing usermedia upload", response);
            Write.Success("Successfully finalized the upload");
        }
        catch (PublishCommandException)
        {
            return(1);
        }

        try
        {
            PublishPackageRequest(config, uploadUuid);
        }
        catch (PublishCommandException)
        {
            return(1);
        }

        return(0);
    }
Ejemplo n.º 20
0
    public static int DoBuild(Config.Config config)
    {
        var packageId = config.GetPackageId();

        Write.WithNL($"Building {Cyan(packageId)}", after: true);

        var readmePath = config.GetPackageReadmePath();

        if (!File.Exists(readmePath))
        {
            Write.ErrorExit($"Readme not found from the declared path: {White(Dim(readmePath))}");
            return(1);
        }

        var iconPath = config.GetPackageIconPath();

        if (!File.Exists(iconPath))
        {
            Write.ErrorExit($"Icon not found from the declared path: {White(Dim(iconPath))}");
            return(1);
        }

        var outDir = config.GetBuildOutputDir();

        if (!Directory.Exists(outDir))
        {
            Directory.CreateDirectory(outDir);
        }
        var filename = config.GetBuildOutputFile();

        Write.Line($"Output path {Cyan(filename)}");

        var encounteredIssues = false;

        var plan = new ArchivePlan(config);

        Write.Header("Planning for files to include in build");

        plan.AddPlan("icon.png", () => File.ReadAllBytes(iconPath));
        plan.AddPlan("README.md", () => File.ReadAllBytes(readmePath));
        plan.AddPlan("manifest.json", () => Encoding.UTF8.GetBytes(SerializeManifest(config)));

        if (config.BuildConfig.CopyPaths is not null)
        {
            foreach (var pathMap in config.BuildConfig.CopyPaths)
            {
                Write.WithNL($"Mapping {Dim(pathMap.From)} to {Dim($"/{pathMap.To}")}", before: true);
                encounteredIssues |= !AddPathToArchivePlan(plan, pathMap.From, pathMap.To);
            }
        }

        if (plan.HasErrors)
        {
            Write.Empty();
            Write.ErrorExit(
                "Build was aborted due to errors identified in planning phase",
                "Adjust your configuration so no issues are present"
                );
            return(1);
        }

        Write.Header("Writing configured files");

        using (var outputFile = File.Open(filename, FileMode.Create))
        {
            using (var archive = new ZipArchive(outputFile, ZipArchiveMode.Create))
            {
                var isWindows = OperatingSystem.IsWindows();
                foreach (var entry in plan)
                {
                    Write.Light($"Writing /{entry.Key}");
                    var archiveEntry = archive.CreateEntry(entry.Key, CompressionLevel.Optimal);
                    if (!isWindows)
                    {
                        // https://github.com/dotnet/runtime/issues/17912#issuecomment-641594638
                        // modifed solution to use a constant instead of a string conversion
                        archiveEntry.ExternalAttributes |= 0b110110100 << 16; // rw-rw-r-- permissions
                    }
                    using (var writer = new BinaryWriter(archiveEntry.Open()))
                    {
                        writer.Write(entry.Value());
                    }
                }
            }
        }

        Write.Empty();

        if (encounteredIssues || plan.HasWarnings)
        {
            Write.Note("Some issues were encountered when building, see output for more details");
            return(1);
        }
        else
        {
            Write.Success($"Successfully built {Cyan(packageId)}");
            return(0);
        }
    }
Ejemplo n.º 21
0
 internal static DataSignin _create(Config.Stream os)
 {
     var self = new DataSignin();
     self.Id = os.ReadInt32();
     self.Item2countMap = new KeyedList<int, int>();
     for (var c = (int)os.ReadSize(); c > 0; c--)
         self.Item2countMap.Add(os.ReadInt32(), os.ReadInt32());
     self.Vipitem2vipcountMap = new KeyedList<int, int>();
     for (var c = (int)os.ReadSize(); c > 0; c--)
         self.Vipitem2vipcountMap.Add(os.ReadInt32(), os.ReadInt32());
     self.Viplevel = os.ReadInt32();
     self.IconFile = os.ReadString();
     return self;
 }
Ejemplo n.º 22
0
        public void GetDirectoryConfig()
        {
            IConfig _config = new Config.Config();

            _config.CabinetFilesDirectory().Should().Be(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), _appName));
        }
Ejemplo n.º 23
0
 internal static void Initialize(Config.Stream os, Config.LoadErrors errors)
 {
     all = new Config.KeyedList<int, DataLoot>();
     for (var c = os.ReadSize(); c > 0; c--) {
         var self = _create(os);
         all.Add(self.Lootid, self);
         if (self.Ename.Trim().Length == 0)
             continue;
         switch(self.Ename.Trim())
         {
             case "combo1":
                 if (Combo1 != null)
                     errors.EnumDup("loot", self.ToString());
                 Combo1 = self;
                 break;
             case "combo2":
                 if (Combo2 != null)
                     errors.EnumDup("loot", self.ToString());
                 Combo2 = self;
                 break;
             case "combo3":
                 if (Combo3 != null)
                     errors.EnumDup("loot", self.ToString());
                 Combo3 = self;
                 break;
             default:
                 errors.EnumDataAdd("loot", self.ToString());
                 break;
         }
     }
     if (Combo1 == null)
         errors.EnumNull("loot", "combo1");
     if (Combo2 == null)
         errors.EnumNull("loot", "combo2");
     if (Combo3 == null)
         errors.EnumNull("loot", "combo3");
 }
Ejemplo n.º 24
0
 public static void Process(Config.Stream os)
 {
     var configNulls = new List<string>
     {
         "equip.ability",
         "equip.jewelry",
         "equip.jewelryrandom",
         "equip.jewelrysuit",
         "equip.jewelrytype",
         "equip.rank",
         "loot",
         "lootitem",
         "monster",
         "signin",
         "task.completeconditiontype",
         "task.task",
     };
     for(;;)
     {
         var csv = os.ReadCfg();
         if (csv == null)
             break;
         switch(csv)
         {
             case "equip.ability":
                 configNulls.Remove(csv);
                 Config.Equip.DataAbility.Initialize(os, Errors);
                 break;
             case "equip.jewelry":
                 configNulls.Remove(csv);
                 Config.Equip.DataJewelry.Initialize(os, Errors);
                 break;
             case "equip.jewelryrandom":
                 configNulls.Remove(csv);
                 Config.Equip.DataJewelryrandom.Initialize(os, Errors);
                 break;
             case "equip.jewelrysuit":
                 configNulls.Remove(csv);
                 Config.Equip.DataJewelrysuit.Initialize(os, Errors);
                 break;
             case "equip.jewelrytype":
                 configNulls.Remove(csv);
                 Config.Equip.DataJewelrytype.Initialize(os, Errors);
                 break;
             case "equip.rank":
                 configNulls.Remove(csv);
                 Config.Equip.DataRank.Initialize(os, Errors);
                 break;
             case "loot":
                 configNulls.Remove(csv);
                 Config.DataLoot.Initialize(os, Errors);
                 break;
             case "lootitem":
                 configNulls.Remove(csv);
                 Config.DataLootitem.Initialize(os, Errors);
                 break;
             case "monster":
                 configNulls.Remove(csv);
                 Config.DataMonster.Initialize(os, Errors);
                 break;
             case "signin":
                 configNulls.Remove(csv);
                 Config.DataSignin.Initialize(os, Errors);
                 break;
             case "task.completeconditiontype":
                 configNulls.Remove(csv);
                 Config.Task.DataCompleteconditiontype.Initialize(os, Errors);
                 break;
             case "task.task":
                 configNulls.Remove(csv);
                 Config.Task.DataTask.Initialize(os, Errors);
                 break;
             default:
                 Errors.ConfigDataAdd(csv);
                 break;
         }
     }
     foreach (var csv in configNulls)
         Errors.ConfigNull(csv);
     Config.Equip.DataJewelry.Resolve(Errors);
     Config.Equip.DataJewelryrandom.Resolve(Errors);
     Config.DataLoot.Resolve(Errors);
     Config.Task.DataTask.Resolve(Errors);
 }
    public GraphicsEssentials(string modFolder, string configDirectory, IReloadedHooks hooks)
    {
        _configurator = new Configurator(configDirectory);
        _configurator.Migrate(modFolder, configDirectory);

        _config = _configurator.GetConfiguration <Config.Config>(0);
        _defaultSettingsHook = new DefaultSettingsHook(_config.DefaultSettings);

        NativeResolutionPatcher.Patch(_config.Width, _config.Height);
        WindowStylePatcher.Patch(_config.BorderlessWindowed, _config.ResizableWindowed);

        if (_config.StupidlyFastLoadTimes)
        {
            LoadTimeHack.Patch();
        }

        if (_config.Disable2PFrameskip)
        {
            DisableFrameskipPatch.Patch();
        }

        if (_config.HighAspectRatioCrashFix)
        {
            _crashPatch = new StageLoadCrashPatch();
        }

        if (_config.DontSlowdownOnFocusLost)
        {
            DontSlowdownOnFocusLoss.Patch();
        }

        _clippingPlanesHook = new ClippingPlanesHook(_config.AspectRatioLimit);
        _aspectRatioHook    = new AspectRatioHook(_config.AspectRatioLimit);

        _resolutionVariablePatcher = new ResolutionVariablePatcher();
        _renderHooks = new RenderHooks(_config.AspectRatioLimit, hooks);

        Task.Run(MessagePump);
        Task.Run(async() =>
        {
            while (Window.WindowHandle == IntPtr.Zero)
            {
                await Task.Delay(32);
            }

            int left = 0;
            int top  = 0;

            if (_config.CenterWindow)
            {
                var monitor = User32.MonitorFromWindow(Window.WindowHandle, User32.MonitorFlags.MONITOR_DEFAULTTONEAREST);
                var info    = new User32.MONITORINFO {
                    cbSize = (uint)Struct.GetSize <User32.MONITORINFO>()
                };
                if (User32.GetMonitorInfo(monitor, ref info))
                {
                    left += (info.rcMonitor.Width - _config.Width) / 2;
                    top  += (info.rcMonitor.Height - _config.Height) / 2;
                }
            }

            User32.MoveWindow(Window.WindowHandle, left, top, _config.Width, _config.Height, false);

            await Task.Delay(32);
            _resizeEventHook.ForceSizeChangeCheck();
        }).ConfigureAwait(false);
    }