Ejemplo n.º 1
0
 public TemplateItem(TemplateItem source)
     : base(source)
 {
     _include  = source._include;
     _itemType = source._itemType;
     _metadata = source._metadata;
 }
Ejemplo n.º 2
0
        // load Code and Info files into the cache
        // unfortunately this will recompress files individually which were previously decompressed, but that'll have to do
        private void Upgrade()
        {
            Interface.loadMods.SubProgressText = $"Upgrading: {Path.GetFileName(path)}";
            Logging.tML.InfoFormat("Upgrading: {0}", Path.GetFileName(path));

            using (var deflateStream = new DeflateStream(fileStream, CompressionMode.Decompress))
                using (var reader = new BinaryReader(deflateStream))
                {
                    name    = reader.ReadString();
                    version = new Version(reader.ReadString());

                    int count = reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        AddFile(reader.ReadString(), reader.ReadBytes(reader.ReadInt32()));
                    }
                }

            // update buildVersion
            var info = BuildProperties.ReadModFile(this);

            info.buildVersion = tModLoaderVersion;
            AddFile("Info", info.ToBytes());

            Save();
            Read();
        }
        public virtual string PublishMultimediaComponent(string uri, BuildProperties buildProperties)
        {
            if (buildProperties.ECLEnabled)
            {
                string url = GetECLUrl(uri);
                if (!string.IsNullOrEmpty(url))
                {
                    return(url);
                }
            }
            string itemName = "PublishMultimedia_" + uri;
            TcmUri tcmuri   = new TcmUri(uri);
            Item   mmItem   = package.GetByName(itemName);

            if (mmItem == null)
            {
                mmItem = package.CreateMultimediaItem(tcmuri);
                package.PushItem(itemName, mmItem);
                log.Debug(string.Format("Image {0} ({1}) unique, adding to package", itemName, uri));
                if (!mmItem.Properties.ContainsKey(Item.ItemPropertyPublishedPath))
                {
                    log.Debug(string.Format("Publish Image {0} ({1}).", itemName, uri));
                    PublishItem(mmItem, tcmuri);
                }
            }
            else
            {
                log.Debug(string.Format("Image {0} ({1}) already present in package, not adding again", itemName, tcmuri));
            }
            return(GetReferencePath(mmItem, uri));
        }
Ejemplo n.º 4
0
 public TemplateFile()
 {
     _fileName  = String.Empty;
     _sourceDir = String.Empty;
     _content   = String.Empty;
     _metadata  = new BuildProperties();
 }
Ejemplo n.º 5
0
        // load Code and Info files into the cache
        // unfortunately this will recompress files individually which were previously decompressed, but that'll have to do
        private void Upgrade()
        {
            Interface.loadMods.SubProgressText = $"Upgrading: {Path.GetFileName(path)}";
            Logging.tML.InfoFormat("Upgrading: {0}", Path.GetFileName(path));

            using (var deflateStream = new DeflateStream(fileStream, CompressionMode.Decompress))
                using (var reader = new BinaryReader(deflateStream)) {
                    name    = reader.ReadString();
                    version = new Version(reader.ReadString());

                    int count = reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        AddFile(reader.ReadString(), reader.ReadBytes(reader.ReadInt32()));
                    }
                }

            // update buildVersion
            var info = BuildProperties.ReadModFile(this);

            info.buildVersion = tModLoaderVersion;
            AddFile("Info", info.ToBytes());

            // write to the new format (also updates the file offset table)
            Save();
            // clear all the file contents from AddFile
            ResetCache();
            // Save closes the file so re-open it
            fileStream = File.OpenRead(path);
            // Read contract fulfilled
        }
Ejemplo n.º 6
0
        public async Task <IEnumerable <RuntimeDescription> > GetRuntimeIdentifiersAsync()
        {
            await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync();

            var unparsedRuntimeIdentifer = BuildProperties.GetPropertyValue(
                ProjectBuildProperties.RuntimeIdentifier);
            var unparsedRuntimeIdentifers = BuildProperties.GetPropertyValue(
                ProjectBuildProperties.RuntimeIdentifiers);

            var runtimes = Enumerable.Empty <string>();

            if (unparsedRuntimeIdentifer != null)
            {
                runtimes = runtimes.Concat(new[] { unparsedRuntimeIdentifer });
            }

            if (unparsedRuntimeIdentifers != null)
            {
                runtimes = runtimes.Concat(unparsedRuntimeIdentifers.Split(';'));
            }

            runtimes = runtimes
                       .Select(x => x.Trim())
                       .Distinct(StringComparer.Ordinal)
                       .Where(x => !string.IsNullOrEmpty(x));

            return(runtimes
                   .Select(runtime => new RuntimeDescription(runtime)));
        }
Ejemplo n.º 7
0
        private async Task <string> GetTargetFrameworkStringAsync()
        {
            await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync();

            var projectPath        = FullName;
            var platformIdentifier = await BuildProperties.GetPropertyValueAsync(
                ProjectBuildProperties.TargetPlatformIdentifier);

            var platformVersion = await BuildProperties.GetPropertyValueAsync(
                ProjectBuildProperties.TargetPlatformVersion);

            var platformMinVersion = await BuildProperties.GetPropertyValueAsync(
                ProjectBuildProperties.TargetPlatformMinVersion);

            var targetFrameworkMoniker = await BuildProperties.GetPropertyValueAsync(
                ProjectBuildProperties.TargetFrameworkMoniker);

            // Projects supporting TargetFramework and TargetFrameworks are detected before
            // this check. The values can be passed as null here.
            var frameworkStrings = MSBuildProjectFrameworkUtility.GetProjectFrameworkStrings(
                projectFilePath: projectPath,
                targetFrameworks: null,
                targetFramework: null,
                targetFrameworkMoniker: targetFrameworkMoniker,
                targetPlatformIdentifier: platformIdentifier,
                targetPlatformVersion: platformVersion,
                targetPlatformMinVersion: platformMinVersion);

            return(frameworkStrings.FirstOrDefault());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// This reads and sets its state or attributes stored in a <c>XML</c> format
        /// with the given reader.
        /// </summary>
        /// <param name="reader">
        /// The reader with which the <c>XML</c> attributes of this object are accessed.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="reader"/> is <see langword="null"/>.
        /// </exception>
        public override void ReadXml(XmlReader reader)
        {
            BuildExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }

            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            if (_arguments == null || _arguments.Count != 0)
            {
                _arguments = new BuildProperties();
            }
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    _arguments[reader.Name] = reader.Value;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Publishes the Binary Data of a Multimedia Component and sets it Multimedia URL (and ExtensionData for ECL).
        /// </summary>
        /// <param name="mmComponent">The (DD4T) Multimedia Component to Publish.</param>
        /// <param name="buildProperties">The DD4T Build Properties</param>
        public void PublishMultimediaComponent(Dynamic.Component mmComponent, BuildProperties buildProperties)
        {
            Dynamic.Multimedia multimedia = mmComponent.Multimedia;
            if (multimedia == null)
            {
                log.Warning("PublishMultimediaComponent called with a non-Multimedia Component: " + mmComponent.Id);
                return;
            }

            if (multimedia.MimeType == EclMimeType && buildProperties.ECLEnabled && mmComponent.EclId == null)
            {
                using (EclProcessor eclProcessor = new EclProcessor(engine, targetStructureGroupUri))
                {
                    eclProcessor.ProcessEclStubComponent(mmComponent);
                }
            }
            else if (mmComponent.EclId != null)
            {
                log.Debug(string.Format("ECL Stub Component '{0}' has already been processed (ECL ID: '{1}') ", mmComponent.Id, mmComponent.EclId));
            }
            else
            {
                multimedia.Url = PublishMultimediaComponent(mmComponent.Id, buildProperties);
            }
        }
Ejemplo n.º 10
0
        public UIModItem(string mod)
        {
            this.mod               = mod;
            this.BorderColor       = new Color(89, 116, 213) * 0.7f;
            this.dividerTexture    = TextureManager.Load("Images/UI/Divider");
            this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            this.Height.Set(90f, 0f);
            this.Width.Set(0f, 1f);
            base.SetPadding(6f);
            base.OnClick += new UIElement.MouseEvent(this.ToggleEnabled);
            BuildProperties properties = ModLoader.LoadBuildProperties(mod);
            string          text       = properties.displayName.Length > 0 ? properties.displayName : Path.GetFileNameWithoutExtension(mod);

            if (properties.version.Length > 0)
            {
                text += " " + properties.version;
            }
            if (properties.author.Length > 0)
            {
                text += " - by " + properties.author;
            }
            this.modName = new UIText(text, 1f, false);
            this.modName.Left.Set(10f, 0f);
            this.modName.Top.Set(5f, 0f);
            base.Append(this.modName);
            this.enabled = ModLoader.IsEnabled(mod);
        }
Ejemplo n.º 11
0
 public FormatChmEncoding(FormatChmOptions options)
 {
     _options        = options;
     _listEncoders   = new List <FormatChmEncoder>();
     _outputEncoding = Encoding.UTF8;
     _appSettings    = new BuildProperties();
 }
Ejemplo n.º 12
0
        public async Task <IEnumerable <RuntimeDescription> > GetRuntimeIdentifiersAsync()
        {
            _threadingService.ThrowIfNotOnUIThread();

            var unparsedRuntimeIdentifer = await BuildProperties.GetPropertyValueAsync(
                ProjectBuildProperties.RuntimeIdentifier);

            var unparsedRuntimeIdentifers = await BuildProperties.GetPropertyValueAsync(
                ProjectBuildProperties.RuntimeIdentifiers);

            var runtimes = Enumerable.Empty <string>();

            if (unparsedRuntimeIdentifer != null)
            {
                runtimes = runtimes.Concat(new[] { unparsedRuntimeIdentifer });
            }

            if (unparsedRuntimeIdentifers != null)
            {
                runtimes = runtimes.Concat(unparsedRuntimeIdentifers.Split(';'));
            }

            runtimes = runtimes
                       .Select(x => x.Trim())
                       .Where(x => !string.IsNullOrEmpty(x));

            return(runtimes
                   .Select(runtime => new RuntimeDescription(runtime)));
        }
Ejemplo n.º 13
0
 public TemplatePropertyGroup(TemplatePropertyGroup source)
     : base(source)
 {
     _condition     = source._condition;
     _properties    = source._properties;
     _frameworkType = source._frameworkType;
 }
Ejemplo n.º 14
0
        protected ProjectRunner(string projectFile, LoggerVerbosity verbosity)
        {
            BuildExceptions.PathMustExist(projectFile, "projectFile");

            _verbosity   = verbosity;
            _projectFile = projectFile;
            _properties  = new BuildProperties();
        }
Ejemplo n.º 15
0
        public async Task <bool> IsRestoreLockedAsync()
        {
            await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync();

            var value = await BuildProperties.GetPropertyValueAsync(ProjectBuildProperties.RestoreLockedMode);

            return(MSBuildStringUtility.IsTrue(value));
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblerConfigurator"/> class.
 /// </summary>
 protected AssemblerConfigurator()
 {
     _reIsConfigValue = new Regex(@"^\$\(([^\$\(\)]*)\)$",
                                  RegexOptions.Compiled);
     // Create the dictionary for mapping the handlers...
     _dicConfigMap  = new BuildProperties();
     _configContent = new ConfiguratorContent();
 }
Ejemplo n.º 17
0
        public virtual void PostProcess(BuildPostProcessArgs args, out BuildProperties outProperties)
        {
            PostProcess(args);

            // NOTE: For some reason, calling PostProcess seems like it can trigger this object to be GC'd
            //  so create is just before returning
            outProperties = ScriptableObject.CreateInstance <DefaultBuildProperties>();
        }
Ejemplo n.º 18
0
 public TemplateFile(TemplateFile source)
     : base(source)
 {
     _content   = source._content;
     _fileName  = source._fileName;
     _sourceDir = source._sourceDir;
     _metadata  = source._metadata;
 }
Ejemplo n.º 19
0
        public async Task <string> GetRestorePackagesWithLockFileAsync()
        {
            await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync();

            var value = await BuildProperties.GetPropertyValueAsync(ProjectBuildProperties.RestorePackagesWithLockFile);

            return(value);
        }
Ejemplo n.º 20
0
        public Task <string> GetPropertyValueAsync(string propertyName)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException(nameof(propertyName));
            }

            return(BuildProperties.GetPropertyValueAsync(propertyName));
        }
Ejemplo n.º 21
0
 private void Publish(UIMouseEvent evt, UIElement listeningElement)
 {
     Main.PlaySound(10, -1, -1, 1);
     try
     {
         TmodFile[] modFiles    = ModLoader.FindMods();
         bool       ok          = false;
         TmodFile   theTModFile = null;
         foreach (TmodFile tModFile in modFiles)
         {
             if (Path.GetFileName(tModFile.Name).Equals(@Path.GetFileName(mod) + @".tmod"))
             {
                 ok          = true;
                 theTModFile = tModFile;
             }
         }
         if (!ok)
         {
             throw new Exception();
         }
         System.Net.ServicePointManager.Expect100Continue = false;
         string filename = @ModLoader.ModPath + @Path.DirectorySeparatorChar + @Path.GetFileName(mod) + @".tmod";
         string url      = "http://javid.ddns.net/tModLoader/publishmod.php";
         using (var stream = File.Open(filename, FileMode.Open))
         {
             var files = new[]
             {
                 new IO.UploadFile
                 {
                     Name     = "file",
                     Filename = Path.GetFileName(filename),
                     //    ContentType = "text/plain",
                     Stream = stream
                 }
             };
             BuildProperties bp     = BuildProperties.ReadModFile(theTModFile);
             var             values = new NameValueCollection
             {
                 { "displayname", bp.displayName },
                 { "name", Path.GetFileNameWithoutExtension(filename) },
                 { "version", bp.version },
                 { "author", bp.author },
                 { "homepage", bp.homepage },
                 { "description", bp.description },
                 { "steamid64", Steamworks.SteamUser.GetSteamID().ToString() },
                 { "modloaderversion", bp.modBuildVersion },
             };
             byte[] result = IO.UploadFile.UploadFiles(url, files, values);
             string s      = System.Text.Encoding.UTF8.GetString(result, 0, result.Length);
             ErrorLogger.LogModPublish(s);
         }
     }
     catch (WebException e)
     {
         ErrorLogger.LogModBrowserException(e);
     }
 }
Ejemplo n.º 22
0
        public async Task <string> GetPropertyValueAsync(string propertyName)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException(nameof(propertyName));
            }

            await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync();

            return(await BuildProperties.GetPropertyValueAsync(propertyName));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// This reads and sets its state or attributes stored in a <c>XML</c> format
        /// with the given reader.
        /// </summary>
        /// <param name="reader">
        /// The reader with which the <c>XML</c> attributes of this object are accessed.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="reader"/> is <see langword="null"/>.
        /// </exception>
        public override void ReadXml(XmlReader reader)
        {
            BuildExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }

            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            string tempText = reader.GetAttribute("FrameworkType");

            if (!String.IsNullOrEmpty(tempText))
            {
                _frameworkType = (TemplateFrameworkType)Enum.Parse(
                    typeof(TemplateFrameworkType), tempText, true);
            }
            _condition = reader.GetAttribute("Condition");

            if (reader.IsEmptyElement)
            {
                return;
            }

            if (_properties == null || _properties.Count != 0)
            {
                _properties = new BuildProperties();
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    tempText = reader.ReadString();
                    if (!String.IsNullOrEmpty(tempText))
                    {
                        _properties[reader.Name] = tempText;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, TagName, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 24
0
        public async Task <string> GetMSBuildProjectExtensionsPathAsync()
        {
            var msbuildProjectExtensionsPath = await BuildProperties.GetPropertyValueAsync(ProjectBuildProperties.MSBuildProjectExtensionsPath);

            if (string.IsNullOrEmpty(msbuildProjectExtensionsPath))
            {
                return(null);
            }

            return(Path.Combine(await GetProjectDirectoryAsync(), msbuildProjectExtensionsPath));
        }
Ejemplo n.º 25
0
        private Task <string> GetTargetFrameworkStringAsync()
        {
            var frameworkStrings = MSBuildProjectFrameworkUtility.GetProjectFrameworkStrings(
                projectFilePath: ProjectFilePath,
                targetFrameworks: BuildProperties.GetPropertyValue("TargetFrameworks"),
                targetFramework: BuildProperties.GetPropertyValue("TargetFramework"),
                targetFrameworkMoniker: BuildProperties.GetPropertyValue("TargetFrameworkMoniker"),
                targetPlatformIdentifier: BuildProperties.GetPropertyValue("TargetPlatformIdentifier"),
                targetPlatformVersion: BuildProperties.GetPropertyValue("TargetPlatformVersion"),
                targetPlatformMinVersion: BuildProperties.GetPropertyValue("TargetPlatformMinVersion"));

            return(Task.FromResult(frameworkStrings.FirstOrDefault()));
        }
Ejemplo n.º 26
0
        public UIModItem(TmodFile mod)
        {
            this.mod               = mod.Name;
            this.BorderColor       = new Color(89, 116, 213) * 0.7f;
            this.dividerTexture    = TextureManager.Load("Images/UI/Divider");
            this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            this.Height.Set(90f, 0f);
            this.Width.Set(0f, 1f);
            base.SetPadding(6f);
            //base.OnClick += new UIElement.MouseEvent(this.ToggleEnabled);
            properties = BuildProperties.ReadModFile(mod);
            string text = properties.displayName.Length > 0 ? properties.displayName : Path.GetFileNameWithoutExtension(mod.Name);

            if (properties.version.Length > 0)
            {
                text += " " + properties.version;
            }
            if (properties.author.Length > 0)
            {
                text += " - by " + properties.author;
            }
            this.modName = new UIText(text, 1f, false);
            this.modName.Left.Set(10f, 0f);
            this.modName.Top.Set(5f, 0f);
            base.Append(this.modName);
            this.enabled = ModLoader.IsEnabled(mod.Name);
            UITextPanel button = new UITextPanel("More info", 1f, false);

            button.Width.Set(100f, 0f);
            button.Height.Set(30f, 0f);
            button.Left.Set(430f, 0f);
            button.Top.Set(40f, 0f);
            button.PaddingTop    -= 2f;
            button.PaddingBottom -= 2f;
            button.OnMouseOver   += new UIElement.MouseEvent(FadedMouseOver);
            button.OnMouseOut    += new UIElement.MouseEvent(FadedMouseOut);
            button.OnClick       += new UIElement.MouseEvent(this.Moreinfo);
            base.Append(button);
            button2 = new UITextPanel(this.enabled ? "Click to Disable" : "Click to Enable", 1f, false);
            button2.Width.Set(100f, 0f);
            button2.Height.Set(30f, 0f);
            button2.Left.Set(275f, 0f);
            button2.Top.Set(40f, 0f);
            button2.PaddingTop    -= 2f;
            button2.PaddingBottom -= 2f;
            button2.OnMouseOver   += new UIElement.MouseEvent(FadedMouseOver);
            button2.OnMouseOut    += new UIElement.MouseEvent(FadedMouseOut);
            button2.OnClick       += new UIElement.MouseEvent(this.ToggleEnabled);
            base.Append(button2);
        }
Ejemplo n.º 27
0
        private void DumpBuildProperties()
        {
            var infoData = _mod.GetFile(TmodFile.InfoFileName);

            var properties = BuildProperties.ReadBytes(infoData);

            using (var fs = new FileStream(GetPath(DefaultConfigurations.LocalizerFiles.InfoConfigurationFile), FileMode.Create))
            {
                using (var sw = new StreamWriter(fs))
                {
                    sw.Write(JsonConvert.SerializeObject(properties, Formatting.Indented));
                }
            }
        }
Ejemplo n.º 28
0
        public bool TryGetPropertyValue(string propertyName, out string value)
        {
            var property = BuildProperties.FirstOrDefault(
                p => p.Name.Equals(propertyName, System.StringComparison.OrdinalIgnoreCase));

            if (property == null)
            {
                value = null;
                return(false);
            }

            value = property.Value;
            return(true);
        }
Ejemplo n.º 29
0
 public void TestParsing()
 {
     var properties = new BuildProperties();
     properties.SetProperty(BuildProperties.StackCorruptionDetectionEnabledString, "False");
     Assert.AreEqual(
         false, 
         properties.GetProperty<bool>(BuildProperties.StackCorruptionDetectionEnabledString, true));
     Assert.AreEqual(
         false,
         properties.StackCorruptionDetectionEnabled);
     Assert.AreEqual(
         "False",
         properties.GetProperty(BuildProperties.StackCorruptionDetectionEnabledString));
 }
Ejemplo n.º 30
0
    public static Module GetRandomBuilding(BuildProperties buildProps)
    {
        List <Module> tempList = buildings.FindAll(b => b.buildProperties.Match(buildProps));

        if (tempList.Count <= 0)
        {
            Debug.LogError("Building list is empty for this filters combination : " + buildProps.ToString());
            return(null);
        }
        else
        {
            int r = Random.Range(0, tempList.Count);
            return(tempList[r]);
        }
    }
Ejemplo n.º 31
0
        public void TestParsing()
        {
            var properties = new BuildProperties();

            properties.SetProperty(BuildProperties.StackCorruptionDetectionEnabledString, "False");
            Assert.AreEqual(
                false,
                properties.GetProperty <bool>(BuildProperties.StackCorruptionDetectionEnabledString, true));
            Assert.AreEqual(
                false,
                properties.StackCorruptionDetectionEnabled);
            Assert.AreEqual(
                "False",
                properties.GetProperty(BuildProperties.StackCorruptionDetectionEnabledString));
        }
Ejemplo n.º 32
0
		public UIModItem(TmodFile mod)
		{
			this.mod = mod.Name;
			this.BorderColor = new Color(89, 116, 213) * 0.7f;
			this.dividerTexture = TextureManager.Load("Images/UI/Divider");
			this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
			this.Height.Set(90f, 0f);
			this.Width.Set(0f, 1f);
			base.SetPadding(6f);
			//base.OnClick += new UIElement.MouseEvent(this.ToggleEnabled);
			properties = BuildProperties.ReadModFile(mod);
			string text = properties.displayName.Length > 0 ? properties.displayName : Path.GetFileNameWithoutExtension(mod.Name);
			if (properties.version.Length > 0)
			{
				text += " " + properties.version;
			}
			if (properties.author.Length > 0)
			{
				text += " - by " + properties.author;
			}
			this.modName = new UIText(text, 1f, false);
			this.modName.Left.Set(10f, 0f);
			this.modName.Top.Set(5f, 0f);
			base.Append(this.modName);
			this.enabled = ModLoader.IsEnabled(mod.Name);
			UITextPanel button = new UITextPanel("More info", 1f, false);
			button.Width.Set(100f, 0f);
			button.Height.Set(30f, 0f);
			button.Left.Set(430f, 0f);
			button.Top.Set(40f, 0f);
			button.PaddingTop -= 2f;
			button.PaddingBottom -= 2f;
			button.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver);
			button.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut);
			button.OnClick += new UIElement.MouseEvent(this.Moreinfo);
			base.Append(button);
			button2 = new UITextPanel(this.enabled ? "Click to Disable" : "Click to Enable", 1f, false);
			button2.Width.Set(100f, 0f);
			button2.Height.Set(30f, 0f);
			button2.Left.Set(275f, 0f);
			button2.Top.Set(40f, 0f);
			button2.PaddingTop -= 2f;
			button2.PaddingBottom -= 2f;
			button2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver);
			button2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut);
			button2.OnClick += new UIElement.MouseEvent(this.ToggleEnabled);
			base.Append(button2);
		}
Ejemplo n.º 33
0
		public UIModItem(TmodFile mod)
		{
			this.mod = mod;
			this.BorderColor = new Color(89, 116, 213) * 0.7f;
			this.dividerTexture = TextureManager.Load("Images/UI/Divider");
			this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
			this.Height.Set(90f, 0f);
			this.Width.Set(0f, 1f);
			base.SetPadding(6f);
			//base.OnClick += new UIElement.MouseEvent(this.ToggleEnabled);
			properties = BuildProperties.ReadModFile(mod);
			string text = properties.displayName.Length > 0 ? properties.displayName : mod.name;
			text += " v" + mod.version;
			if (properties.author.Length > 0)
			{
				text += " - by " + properties.author;
			}
			this.modName = new UIText(text, 1f, false);
			this.modName.Left.Set(10f, 0f);
			this.modName.Top.Set(5f, 0f);
			base.Append(this.modName);
			this.enabled = ModLoader.IsEnabled(mod);
			UITextPanel button = new UITextPanel("More info", 1f, false);
			button.Width.Set(100f, 0f);
			button.Height.Set(30f, 0f);
			button.Left.Set(430f, 0f);
			button.Top.Set(40f, 0f);
			button.PaddingTop -= 2f;
			button.PaddingBottom -= 2f;
			button.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver);
			button.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut);
			button.OnClick += new UIElement.MouseEvent(this.Moreinfo);
			base.Append(button);
			button2 = new UITextPanel(this.enabled ? "Click to Disable" : "Click to Enable", 1f, false);
			button2.Width.Set(100f, 0f);
			button2.Height.Set(30f, 0f);
			button2.Left.Set(275f, 0f);
			button2.Top.Set(40f, 0f);
			button2.PaddingTop -= 2f;
			button2.PaddingBottom -= 2f;
			button2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver);
			button2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut);
			button2.OnClick += new UIElement.MouseEvent(this.ToggleEnabled);
			base.Append(button2);
			if (mod.ValidModBrowserSignature)
			{
				keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.GoldenKey], "This mod originated from the Mod Browser");
				keyImage.Left.Set(-20, 1f);
				base.Append(keyImage);
			}
			if (ModLoader.ModLoaded(mod.name))
			{
				Mod loadedMod = ModLoader.GetMod(mod.name);
				int[] values = { loadedMod.items.Count, loadedMod.npcs.Count, loadedMod.tiles.Count, loadedMod.walls.Count, loadedMod.buffs.Count, loadedMod.mountDatas.Count	};
				string[] strings = { " items", " NPCs", " tiles", " walls", " buffs", " mounts"};
				int xOffset = -40;
				for (int i = 0; i < values.Length; i++)
				{
					if(values[i] > 0)
					{
						Texture2D iconTexture = ModLoader.GetTexture("Terraria/UI" + Path.DirectorySeparatorChar + "InfoIcon_" + i);
						keyImage = new UIHoverImage(iconTexture, values[i] + strings[i]);
						keyImage.Left.Set(xOffset, 1f);
						base.Append(keyImage);
						xOffset -= 18;
					}
				}
			}
		}
Ejemplo n.º 34
0
        List<KeyValuePair<PrecedenceRelation, int>> DiscoverPrecedence(InstanceDB db, BuildProperties buildP, ListProperties listP1, ListProperties listP2)
        {
            Dictionary<PrecedenceProperty, Dictionary<PrecedenceRelation, int>> good = new Dictionary<PrecedenceProperty, Dictionary<PrecedenceRelation, int>>();
            for (int i = 0; i < db.Count; i++)
            {
                LDAModel ldaDoc = (LDAModel)db[i];
                HashSet<PrecedenceProperty> p1List = PrecedenceProperty.Convert(listP1(db, i));
                List<PrecedenceProperty> p2List = buildP((List<int>)listP2(db, i));

                // clear bad
                if (good.Count > 0)
                {
                    List<PrecedenceRelation> removed = new List<PrecedenceRelation>();
                    for (int j1 = 0; j1 < p2List.Count; j1++)
                    {
                        Dictionary<PrecedenceRelation, int> pps = null;
                        PrecedenceProperty p2 = p2List[j1];
                        if (good.TryGetValue(p2, out pps))
                        {
                            foreach (KeyValuePair<PrecedenceRelation, int> kvp in pps)
                            {
                                PrecedenceProperty p1 = kvp.Key.P1;
                                if (!p1List.Contains(p1))
                                {
                                    removed.Add(kvp.Key);
                                }
                            }
                            for (int l = 0; l < removed.Count; l++)
                            {
                                pps.Remove(removed[l]);
                            }
                            removed.Clear();
                        }
                    }
                    removed = null;
                }

                // add new
                for (int j1 = 0; j1 < p2List.Count; j1++)
                {
                    PrecedenceProperty p2 = p2List[j1];
                    Dictionary<PrecedenceRelation, int> pps = null;
                    if (good.TryGetValue(p2, out pps)) // there exist some instances having p2 may or may not not have p1
                    {
                        foreach (PrecedenceProperty p1 in p1List)
                        {
                            PrecedenceRelation pp = new PrecedenceRelation(p1, p2);
                            int count = 0;
                            if (pps.TryGetValue(pp, out count))
                            {
                                pps[pp] = count + 1;
                            }
                        }
                    }
                    else // p2 not exists
                    {
                        pps = new Dictionary<PrecedenceRelation, int>();
                        foreach (PrecedenceProperty p1 in p1List)
                        {
                            PrecedenceRelation pp = new PrecedenceRelation(p1, p2);
                            pps.Add(pp, 1);
                        }
                        good.Add(p2, pps);
                    }
                }
            }
            return ToPrecedences(good);
        }