Esempio n. 1
0
        // This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called
        protected override void ProcessRecord()
        {
            var          mod  = ModName.Split('@');
            var          name = mod[0];
            SessionState ss   = new SessionState();
            string       p    = ss.Path.CurrentFileSystemLocation.Path;

            Path = p + @"\" + Path;
            Path.Replace('/', '\\');
            if (!Path.EndsWith("\\"))
            {
                Path += "\\";
            }

            Util.createdir(Path);
            var version = mod.Length > 1 ? mod[1] : "1.12.2";

            if (Util.IfNum(name))
            {
                Tasks.DownloadMcmod(name, version, Path);
            }
            else
            {
                var s = Tasks.FindAndDl(name, version, "mcmod").Result;
                WriteObject(s);
                Task.Run(async() =>
                {
                    foreach (var file in s)
                    {
                        Tasks.DownloadMcmod(file, version, Path);
                    }
                });
            }
        }
Esempio n. 2
0
 public override void LoadMenu()
 {
     Config = new Menu("EU - " + ModName, "eu." + ModName.Replace(" ", string.Empty).ToLowerInvariant() + new Random().Next(0, 133333337), true);
     Config.AddItem(new MenuItem("eu.Skin Changer.enabled", "Enabled").SetValue(new StringList(new[] { " Disabled " })));
     Config.AddItem(new MenuItem("version" + new Random().Next(0, 133333337), "Version: " + ModVersion));
     Config.AddItem(new MenuItem("site" + new Random().Next(0, 133333337), "Visit joduska.me!"));
     Config.AddToMainMenu();
 }
Esempio n. 3
0
 public override void LoadMenu()
 {
     Config = new Menu("EU - " + ModName, "eu." + ModName.Replace(" ", string.Empty).ToLowerInvariant() + new Random().Next(0, 133333337), true);
     Config.AddItem(new MenuItem("eu.Anti Flame.enabled", "Enabled [DISABLED FEATURE]"));
     Config.AddItem(new MenuItem("caps", "Filter Caps").SetValue(true));
     Config.AddItem(new MenuItem("version" + new Random().Next(0, 133333337), "Version: " + ModVersion));
     Config.AddItem(new MenuItem("site" + new Random().Next(0, 133333337), "Visit joduska.me!"));
     Config.AddToMainMenu();
 }
Esempio n. 4
0
        public override int GetHashCode()
        {
            string op   = Comparison.Operator;
            int    hash = Type.GetHashCode() ^ ModName.GetHashCode() ^ op.GetHashCode();

            if (!string.IsNullOrEmpty(op))
            {
                hash ^= CompareVersion.GetHashCode();
            }
            return(hash);
        }
Esempio n. 5
0
            public bool Equals(ModDefinitionIdentifier other)
            {
                if (other is null)
                {
                    return(false);
                }

                return(ModName.Equals(other.ModName, StringComparison.InvariantCulture) &&
                       ExportMode == other.ExportMode &&
                       Version == other.Version);
            }
Esempio n. 6
0
        /// <summary>
        ///   Fills in missing info about the mod from the given info.
        /// </summary>
        /// <param name="p_mifInfo">A <see cref="ModInfo" /> describing the info of the mod.</param>
        public void SetMissingInfo(ModInfo p_mifInfo)
        {
            Version mv = null;

            if (p_mifInfo == null)
            {
                return;
            }
            var booUpdated = false;

            if (ModName.Equals(Path.GetFileNameWithoutExtension(filepath)) && !String.IsNullOrEmpty(p_mifInfo.ModName))
            {
                booUpdated = true;
                ModName    = p_mifInfo.ModName;
            }
            if (DEFAULT_AUTHOR.Equals(Author) && !String.IsNullOrEmpty(p_mifInfo.Author))
            {
                booUpdated = true;
                Author     = p_mifInfo.Author;
            }

            if (HumanReadableVersion.Equals(DEFAULT_VERSION) && (MachineVersion == DefaultVersion) &&
                !String.IsNullOrEmpty(p_mifInfo.Version))
            {
                HumanReadableVersion = p_mifInfo.Version;
                var strVersionString = p_mifInfo.Version;
                var rgxCleanVersion  = new Regex(@"[^\d\.]");
                strVersionString = rgxCleanVersion.Replace(strVersionString, "");
                if (String.IsNullOrEmpty(strVersionString))
                {
                    strVersionString = "0.0.0.0";
                }

                if (Version.TryParse(strVersionString, out mv))
                {
                    MachineVersion = mv;
                }
            }

            if (!HasScreenshot && (p_mifInfo.Screenshot != null))
            {
                booUpdated = true;
            }

            if (String.IsNullOrEmpty(Website) && (p_mifInfo.URL != null))
            {
                booUpdated = true;
                Website    = p_mifInfo.URL.ToString();
            }
            if (booUpdated)
            {
                CommitInfo((p_mifInfo.Screenshot != null), p_mifInfo.Screenshot);
            }
        }
Esempio n. 7
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ModId != null ? ModId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModName != null ? ModName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModAuthor != null ? ModAuthor.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModVersion != null ? ModVersion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModDescription != null ? ModDescription.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModDll != null ? ModDll.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModDependencies != null ? ModDependencies.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 8
0
        private void RefreshNameAndImageForDisabledState()
        {
            if (string.IsNullOrEmpty(Mod.ImagePath))
            {
                ModImage = "pack://application:,,,/Titanfall-2-Icepick;component/Images/icepick-logo.png";
            }
            else
            {
                ModImage = Mod.ImagePath;
            }

            if (Mod.Enabled)
            {
                ModName = ModName.Replace("(Disabled) ", "");
            }
            else
            {
                WriteableBitmap iconBitmap = new WriteableBitmap((BitmapImage)ModDisplayImage.Source);

                // convert to grayscale
                unsafe
                {
                    iconBitmap.Lock();

                    // https://dzone.com/articles/how-convert-image-gray-scale
                    // todo: make this use 30% red, 59% green, 11% blue, might look nicer idk
                    byte *pBuff = (byte *)iconBitmap.BackBuffer.ToPointer();
                    for (int y = 0; y < iconBitmap.PixelHeight; y++)
                    {
                        byte *row = pBuff + (y * iconBitmap.BackBufferStride);
                        for (int x = 0; x < iconBitmap.PixelWidth; x++)
                        {
                            byte grayscale = (byte)((row[x * 4 + 1] + row[x * 4 + 2] + row[x * 4 + 3]) / 3);
                            row[x * 4]     = grayscale;
                            row[x * 4 + 1] = grayscale;
                            row[x * 4 + 2] = grayscale;
                            row[x * 4 + 3] = grayscale;
                        }
                    }

                    iconBitmap.AddDirtyRect(new Int32Rect(0, 0, iconBitmap.PixelWidth, iconBitmap.PixelHeight));
                    iconBitmap.Unlock();
                }

                ModDisplayImage.Source = iconBitmap;
                ModName = "(Disabled) " + ModName;
            }
        }
Esempio n. 9
0
        public void CleanupConfig(string thisPath)
        {
            if (String.IsNullOrEmpty(ModName))
            {
                ModName = "Reloaded Application Name";
            }

            if (String.IsNullOrEmpty(ModId))
            {
                ModId = ModName.Replace(" ", ".");
            }

            if (!String.IsNullOrEmpty(thisPath))
            {
                string imagePath = Path.Combine(Path.GetDirectoryName(thisPath), ModImage);
                if (!File.Exists(imagePath))
                {
                    ModImage = "";
                }
            }

            ModDependencies = ConfigCleanupUtility.FilterNonexistingModIds(ModDependencies).ToArray();
        }
Esempio n. 10
0
 public override int GetHashCode()
 {
     return(ModPath.GetHashCode() ^ (ModName != null ? ModName.GetHashCode() : 0));
 }
Esempio n. 11
0
 public override int GetHashCode()
 => ModName.GetHashCode() ^ ExportMode.GetHashCode() ^ Version.GetHashCode();
Esempio n. 12
0
        /// <summary>
        ///   A simple constructor that initializes the object.
        /// </summary>
        /// <param name="path">The path to the fomod file.</param>
        internal fomod(string path, bool p_booUseCache)
        {
            filepath = path;
            ModName  = Path.GetFileNameWithoutExtension(path);

            FomodFile = new Archive(path);
            CachePath = Path.Combine(Program.GameMode.ModInfoCacheDirectory, ModName + ".zip");
            if (p_booUseCache && File.Exists(CachePath))
            {
                m_arcCacheFile = new Archive(CachePath);
            }

            FindPathPrefix();
            FomodFile.FilesChanged += Archive_FilesChanged;
            baseName             = ModName.ToLowerInvariant();
            Author               = DEFAULT_AUTHOR;
            Description          = Email = Website = string.Empty;
            HumanReadableVersion = DEFAULT_VERSION;
            MachineVersion       = DefaultVersion;
            MinFommVersion       = DefaultMinFommVersion;
            Groups               = new string[0];
            isActive             = (InstallLog.Current.GetModKey(baseName) != null);

            //check for script
            foreach (var name in FomodScript.ScriptNames)
            {
                if (ContainsFile("fomod/" + name))
                {
                    m_strScriptPath = "fomod/" + name;
                    break;
                }
            }

            //check for readme
            foreach (var ext in Readme.ValidExtensions)
            {
                if (ContainsFile("readme - " + baseName + ext))
                {
                    m_strReadmePath = "Readme - " + Path.GetFileNameWithoutExtension(path) + ext;
                    break;
                }
            }
            if (String.IsNullOrEmpty(m_strReadmePath))
            {
                foreach (var ext in Readme.ValidExtensions)
                {
                    if (ContainsFile("docs/readme - " + baseName + ext))
                    {
                        m_strReadmePath = "docs/Readme - " + Path.GetFileNameWithoutExtension(path) + ext;
                        break;
                    }
                }
            }

            //check for screenshot
            var extensions = new[]
            {
                ".png", ".jpg", ".bmp"
            };

            foreach (var ext in extensions)
            {
                if (ContainsFile("fomod/screenshot" + ext))
                {
                    m_strScreenshotPath = "fomod/screenshot" + ext;
                    break;
                }
            }

            if (p_booUseCache && !File.Exists(CachePath) && (FomodFile.IsSolid || FomodFile.ReadOnly))
            {
                var strTmpInfo = Program.CreateTempDirectory();
                try
                {
                    Directory.CreateDirectory(Path.Combine(strTmpInfo, GetPrefixAdjustedPath("fomod")));

                    if (ContainsFile("fomod/info.xml"))
                    {
                        File.WriteAllBytes(Path.Combine(strTmpInfo, GetPrefixAdjustedPath("fomod/info.xml")),
                                           GetFileContents("fomod/info.xml"));
                    }
                    else
                    {
                        File.WriteAllText(Path.Combine(strTmpInfo, GetPrefixAdjustedPath("fomod/info.xml")), "<fomod/>");
                    }

                    if (!String.IsNullOrEmpty(m_strReadmePath))
                    {
                        File.WriteAllBytes(Path.Combine(strTmpInfo, GetPrefixAdjustedPath(m_strReadmePath)),
                                           GetFileContents(m_strReadmePath));
                    }

                    if (!String.IsNullOrEmpty(m_strScreenshotPath))
                    {
                        File.WriteAllBytes(Path.Combine(strTmpInfo, GetPrefixAdjustedPath(m_strScreenshotPath)),
                                           GetFileContents(m_strScreenshotPath));
                    }

                    var strFilesToCompress = Directory.GetFiles(strTmpInfo, "*.*", SearchOption.AllDirectories);
                    if (strFilesToCompress.Length > 0)
                    {
                        var szcCompressor = new SevenZipCompressor();
                        szcCompressor.ArchiveFormat    = OutArchiveFormat.Zip;
                        szcCompressor.CompressionLevel = CompressionLevel.Ultra;
                        szcCompressor.CompressDirectory(strTmpInfo, CachePath);
                    }
                }
                finally
                {
                    FileUtil.ForceDelete(strTmpInfo);
                }
                if (File.Exists(CachePath))
                {
                    m_arcCacheFile = new Archive(CachePath);
                }
            }

            LoadInfo();
        }