public ResourcePack LoadFromFile([NotNull] string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } ResourcePack result = null; try { using (var fs = File.Open(path, FileMode.Open)) { result = Serializer.Read <ResourcePack>(fs); if (result != null && result.Images != null) { result.Images.ForEach(image => { image.Index = image.IndexString.HexStringToInt(); image.Data = ReadImageFromAsciiString(image.Width, image.Height, image.DataString); }); } } } catch (Exception ex) { InfoBox.Show("Unable to import images.\n" + ex.Message); } return(result); }
public AssetComponent(OctoGame game) : base(game) { settings = game.Settings; Ready = false; textures = new Dictionary <string, Texture2D>(); bitmaps = new Dictionary <string, Bitmap>(); ScanForResourcePacks(); // Load list of active Resource Packs List <ResourcePack> toLoad = new List <ResourcePack>(); if (settings.KeyExists(SETTINGSKEY)) { string activePackPathes = settings.Get <string>(SETTINGSKEY); if (!string.IsNullOrEmpty(activePackPathes)) { string[] packPathes = activePackPathes.Split(';'); foreach (var packPath in packPathes) { ResourcePack resourcePack = loadedPacks.FirstOrDefault(p => p.Path.Equals(packPath)); if (resourcePack != null) { toLoad.Add(resourcePack); } } } } ApplyResourcePacks(toLoad); }
private UIElement CreatePackToggleButton(ResourcePack resourcePack) { Language.GetText(resourcePack.IsEnabled ? "GameUI.Enabled" : "GameUI.Disabled"); GroupOptionButton <bool> groupOptionButton = new GroupOptionButton <bool>(option: true, null, null, Color.White, null, 0.8f); groupOptionButton.Left = StyleDimension.FromPercent(0.5f); groupOptionButton.Width = StyleDimension.FromPixelsAndPercent(0f, 0.5f); groupOptionButton.Height = StyleDimension.Fill; groupOptionButton.SetColorsBasedOnSelectionState(Color.LightGreen, Color.PaleVioletRed, 0.7f, 0.7f); groupOptionButton.SetCurrentOption(resourcePack.IsEnabled); groupOptionButton.ShowHighlightWhenSelected = false; groupOptionButton.SetPadding(0f); Asset <Texture2D> obj = Main.Assets.Request <Texture2D>("Images/UI/TexturePackButtons", (AssetRequestMode)1); UIImageFramed element = new UIImageFramed(obj, obj.Frame(2, 2, (!resourcePack.IsEnabled) ? 1 : 0, 1)) { HAlign = 0.5f, VAlign = 0.5f, IgnoresMouseInteraction = true }; groupOptionButton.Append(element); groupOptionButton.OnMouseOver += delegate { SoundEngine.PlaySound(12); }; groupOptionButton.OnClick += delegate { SoundEngine.PlaySound(12); resourcePack.IsEnabled = !resourcePack.IsEnabled; SetResourcePackAsTopPriority(resourcePack); PopulatePackList(); Main.instance.TilePaintSystem.Reset(); }; return(groupOptionButton); }
public void ScanForResourcePacks() { loadedPacks.Clear(); if (Directory.Exists(RESOURCEPATH)) { foreach (var directory in Directory.GetDirectories(RESOURCEPATH)) { DirectoryInfo info = new DirectoryInfo(directory); if (File.Exists(Path.Combine(directory, INFOFILENAME))) { // Scan info File XmlSerializer serializer = new XmlSerializer(typeof(ResourcePack)); using (Stream stream = File.OpenRead(Path.Combine(directory, INFOFILENAME))) { ResourcePack pack = (ResourcePack)serializer.Deserialize(stream); pack.Path = info.FullName; loadedPacks.Add(pack); } } else { ResourcePack pack = new ResourcePack() { Path = info.FullName, Name = info.Name }; loadedPacks.Add(pack); } } } }
// todo: remove source param public static IFlexibleModel CreateSimple(IResourceSource source, VertexPosNormTex[] vertices, int[] indices, FlexibleModelPrimitiveTopology primitiveTopology) { var pack = new ResourcePack(ResourceVolatility.Immutable); //pack.Source = source; RawDataResource vertexDataRes; fixed(VertexPosNormTex *pVertices = vertices) vertexDataRes = new RawDataResource(ResourceVolatility.Immutable, (IntPtr)pVertices, vertices.Length * sizeof(VertexPosNormTex)); pack.AddSubresource("VertexArray", vertexDataRes); var hasIndices = indices != null; RawDataResource indexDataRes = null; if (hasIndices) { fixed(int *pIndices = indices) indexDataRes = new RawDataResource(ResourceVolatility.Immutable, (IntPtr)pIndices, indices.Length * sizeof(int)); pack.AddSubresource("IndexArray", indexDataRes); } var arraySubranges = hasIndices ? new[] { vertexDataRes.GetSubrange(0), indexDataRes.GetSubrange(0) } : new[] { vertexDataRes.GetSubrange(0) }; var elementInfos = VertexPosNormTex.GetElementsInfos(0); var indicesInfo = hasIndices ? new VertexIndicesInfo(1, CommonFormat.R32_UINT) : null; var vertexSet = new FlexibleModelVertexSet(ResourceVolatility.Immutable, arraySubranges, elementInfos, indicesInfo); pack.AddSubresource("VertexSet", vertexSet); var modelPart = new FlexibleModelPart { ModelMaterialName = "MainMaterial", VertexSetIndex = 0, PrimitiveTopology = primitiveTopology, IndexCount = hasIndices ? indices.Length : vertices.Length, FirstIndex = 0, VertexOffset = 0 }; var sphere = Sphere.BoundingSphere(vertices, x => x.Position); var model = new FlexibleModel(ResourceVolatility.Immutable, new[] { vertexSet }, new[] { modelPart }, sphere); pack.AddSubresource("Model", model); model.Source = source; return(model); }
private void PreviewResourcePack([NotNull] ResourcePack resourcePack) { if (resourcePack == null) { throw new ArgumentNullException("resourcePack"); } if (resourcePack.Images == null || resourcePack.Images.Count == 0) { return; } var originalImageIndices = new List <int>(); var importedImages = new List <bool[, ]>(); foreach (var exportedImage in resourcePack.Images) { originalImageIndices.Add(exportedImage.Index); importedImages.Add(exportedImage.Data); } using (var importWindow = new PreviewResourcePackWindow(m_firmware, originalImageIndices, importedImages, true)) { importWindow.Text = Consts.ApplicationTitleWoVersion + @" - Resource Pack Preview"; importWindow.ImportButtonText = "Import"; if (importWindow.ShowDialog() != DialogResult.OK) { return; } ImportResourcePack(originalImageIndices, importedImages); } }
/// <summary> /// Try Buying Item form Hero from Market. Recieves item to Try Buying Returns: 0 - ResourcePack not found. 1 - Item found in market, not enough gold. 2 - Item bought. /// </summary> /// <param name="itemtobuy"></param> /// <returns></returns> public int TryBuyResourcePack(ResourcePack packToBuy) { int buyState = 0; List <Market> globalMarket = markets.All().ToList(); if (globalMarket[0].ResourcePacks.Contains(packToBuy)) { if (CurrentCrafter.Resources.Gold > packToBuy.Price) { CurrentCrafter.Resources.Gold -= packToBuy.Price; packToBuy.Seller.Gatherer.Resources.Gold += packToBuy.Price; globalMarket[0].ResourcePacks.Remove(packToBuy); CurrentCrafter.Resources.ResourcePacks.Add(packToBuy); crafters.Update(CurrentCrafter); crafters.SaveChanges(); IRepository <Gatherer> gatherers = new EfRepository <Gatherer>(); gatherers.Update(packToBuy.Seller.Gatherer); gatherers.SaveChanges(); markets.Update(globalMarket[0]); markets.SaveChanges(); buyState = 2; } else { buyState = 1; } } return(buyState); }
public void SaveToFile([NotNull] string path, [NotNull] ResourcePack pack) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } if (pack == null) { throw new ArgumentNullException("pack"); } if (pack.Images == null || pack.Images.Count == 0) { return; } try { using (var fs = File.Open(path, FileMode.Create)) { pack.Images.ForEach(image => { image.IndexString = image.Index.ToString("X2"); image.DataString = WriteImageToAsciiString(image.Width, image.Height, image.Data); }); Serializer.Write(pack, fs); } } catch (Exception ex) { InfoBox.Show("Unable to export resource pack.\n" + ex.Message); } }
public virtual void Initialize() { context = Mock.Of <ITypeDescriptorContext>(); solution = new Solution(); project = new Project { Name = "project", PhysicalPath = @"c:\projects\solution\project\project.csproj" }; folder = new Folder(); item = new Item { Data = { CustomTool = "", IncludeInVSIX = "false", CopyToOutputDirectory = CopyToOutput.DoNotCopy, ItemType = "None" }, PhysicalPath = @"c:\projects\solution\project\assets\icon.ico" }; folder.Items.Add(item); project.Items.Add(folder); project.Data.AssemblyName = "project"; solution.Items.Add(project); serviceProvider = new Mock <IServiceProvider>(); componentModel = new Mock <IComponentModel>(); picker = new Mock <ISolutionPicker>(); var uriProvider = new PackUriProvider(); var pack = new ResourcePack(item); var uriService = new Mock <IUriReferenceService>(); uriService.Setup(u => u.CreateUri <ResourcePack>(It.IsAny <ResourcePack>(), "pack")).Returns(uriProvider.CreateUri(pack)); serviceProvider.Setup(s => s.GetService(typeof(SComponentModel))).Returns(componentModel.Object); serviceProvider.Setup(s => s.GetService(typeof(ISolution))).Returns(solution); serviceProvider.Setup(s => s.GetService(typeof(IUriReferenceService))).Returns(uriService.Object); componentModel.Setup(c => c.GetService <Func <ISolutionPicker> >()).Returns(new Func <ISolutionPicker>(() => { return(picker.Object); })); picker.Setup(p => p.Filter).Returns(Mock.Of <IPickerFilter>()); }
private UIElement CreatePackToggleButton(ResourcePack resourcePack) { Language.GetText(resourcePack.IsEnabled ? "GameUI.Enabled" : "GameUI.Disabled"); GroupOptionButton <bool> groupOptionButton = new GroupOptionButton <bool>(true, (LocalizedText)null, (LocalizedText)null, Color.White, (string)null, 0.8f, 0.5f, 10f); groupOptionButton.Left = StyleDimension.FromPercent(0.5f); groupOptionButton.Width = StyleDimension.FromPixelsAndPercent(0.0f, 0.5f); groupOptionButton.Height = StyleDimension.Fill; groupOptionButton.SetColorsBasedOnSelectionState(Color.LightGreen, Color.PaleVioletRed, 0.7f, 0.7f); groupOptionButton.SetCurrentOption(resourcePack.IsEnabled); groupOptionButton.ShowHighlightWhenSelected = false; groupOptionButton.SetPadding(0.0f); Asset <M0> asset = Main.Assets.Request <Texture2D>("Images/UI/TexturePackButtons", (AssetRequestMode)1); UIImageFramed uiImageFramed = new UIImageFramed((Asset <Texture2D>)asset, ((Asset <Texture2D>)asset).Frame(2, 2, resourcePack.IsEnabled ? 0 : 1, 1, 0, 0)); uiImageFramed.HAlign = 0.5f; uiImageFramed.VAlign = 0.5f; uiImageFramed.IgnoresMouseInteraction = true; groupOptionButton.Append((UIElement)uiImageFramed); groupOptionButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f)); groupOptionButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f); resourcePack.IsEnabled = !resourcePack.IsEnabled; this.SetResourcePackAsTopPriority(resourcePack); this.PopulatePackList(); }); return((UIElement)groupOptionButton); }
public override void Encode() { base.Encode(); this.WriteBool(this.MustAccept); this.WriteShort((short)this.BehaviourPackEntries.Length); for (int i = 0; i < this.BehaviourPackEntries.Length; ++i) { ResourcePack entry = this.BehaviourPackEntries[i]; this.WriteString(entry.GetPackId()); this.WriteString(entry.GetPackVersion()); this.WriteLLong((ulong)entry.GetPackSize()); this.WriteString(""); //TODO: this.WriteString(""); //TODO: } this.WriteShort((short)this.ResourcePackEntries.Length); for (int i = 0; i < this.ResourcePackEntries.Length; ++i) { ResourcePack entry = this.ResourcePackEntries[i]; this.WriteString(entry.GetPackId()); this.WriteString(entry.GetPackVersion()); this.WriteLLong((ulong)entry.GetPackSize()); this.WriteString(""); //TODO: this.WriteString(""); //TODO: } }
private void OkButton_Click(object sender, EventArgs e) { string fileName; using (var sf = new SaveFileDialog { Filter = Consts.ExportResourcePackFilter, FileName = NameTextBox.Text.Nvl("new_resource_pack") + Consts.ResourcePackFileExtensionWoAsterisk }) { if (sf.ShowDialog() != DialogResult.OK) { return; } fileName = sf.FileName; } var resourcePack = new ResourcePack(m_definition, m_exportedImages) { Name = NameTextBox.Text, Author = AuthorTextBox.Text, Version = VersionTextBox.Text, Description = DescriptionTextBox.Text }; try { m_resourcePackManager.SaveToFile(fileName, resourcePack); DialogResult = DialogResult.OK; } catch (Exception ex) { InfoBox.Show("An error occured during saving resource pack\n" + ex.Message); } }
public ResourcePackViewModel([NotNull] ResourcePack model) { Assert.IsNotNull(model, nameof(model)); _model = model; _resources = new ReactiveDictionary <string, ResourceViewModel>( _model.Content .ToDictionary(r => r.Name, r => new ResourceViewModel(r))); }
public void Scrambled_WhenInvokedOnce_ReturnsDifferentString() { ResourcePack pack = new ResourcePack(); string actualString = pack.scramble("This is a test", "mykey"); Assert.IsFalse("This is a test".Equals(actualString)); }
private Control ListTemplateGenerator(ResourcePack pack) { return(new Label(ScreenManager) { Text = pack.Name, HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalTextAlignment = HorizontalAlignment.Left }); }
private void Start() { ResourcePack.Load(); rigidbody = GetComponent <Rigidbody>(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; }
public static void AddBaseDevPackToXml(XElement devpackPartToResourcePack, ResourcePack resourcePack) { if (resourcePack != null) { devpackPartToResourcePack.SetAttributeValue("ResourcePackName", resourcePack.ResourcePackName); devpackPartToResourcePack.SetAttributeValue("ResourcePackDesc", resourcePack.ResourcePackDesc); } }
private BlockModel ModelResolver(string arg) { if (ResourcePack.TryGetBlockModel(arg, out var model)) { return(model); } return(null); }
/// <summary> /// Convert a Beat Saber Zip file into a Minecraft Resourcepack and Datapack /// </summary> /// <param name="zipPath">file path to beat saber zip file</param> /// <param name="datapackOutputPath">folder path that minecraft zips will be generated</param> /// <param name="uuid">Unique number that determines song value</param> /// <param name="cancellationToken">Token that allows async function to be canceled</param> /// <returns>-1 on Success</returns> public static async Task <ConversionError> ConvertAsync(string zipPath, string datapackOutputPath, int uuid, IProgress <ConversionProgress> progress, CancellationToken cancellationToken) { if (!File.Exists(zipPath) || !Directory.Exists(datapackOutputPath)) { return(ConversionError.MissingInfo); } progress.Report(new ConversionProgress(0.1f, "Loading beat map file")); var beatSaberMap = await MapLoader.GetDataFromMapZip(zipPath, ProcessManager.temporaryPath, cancellationToken); if (beatSaberMap == null) { return(ConversionError.InvalidBeatMap); } cancellationToken.ThrowIfCancellationRequested(); var tempFolder = beatSaberMap.ExtractedFilePath; try { beatSaberMap = ConvertFilesEggToOgg(beatSaberMap); beatSaberMap = ConvertFilesJpgToPng(beatSaberMap); if (beatSaberMap.InfoData.DifficultyBeatmapSets.Length == 0) { return(ConversionError.NoMapData); } cancellationToken.ThrowIfCancellationRequested(); // Generating Resource pack progress.Report(new ConversionProgress(0.2f, "Generating resource pack")); var resourcepackError = await ResourcePack.FromBeatSaberData(datapackOutputPath, beatSaberMap); if (resourcepackError != ConversionError.None) { return(resourcepackError); } cancellationToken.ThrowIfCancellationRequested(); // Generating Data pack progress.Report(new ConversionProgress(0.3f, "Generating datapack")); var datapackError = await DataPack.FromBeatSaberData(datapackOutputPath, beatSaberMap, progress, cancellationToken); if (datapackError != ConversionError.None) { return(datapackError); } } catch (OperationCanceledException e) { SafeFileManagement.DeleteDirectory(tempFolder); throw (e); } catch (ObjectDisposedException) { SafeFileManagement.DeleteDirectory(tempFolder); } // Successfully converted map SafeFileManagement.DeleteDirectory(tempFolder); return(ConversionError.None); }
public void Scrambled_WhenInvokedTwice_ReturnsSameString() { ResourcePack pack = new ResourcePack(); string scrambledString = pack.scramble("This is a test", "mykey"); string actualString = pack.scramble(scrambledString, "mykey"); Assert.IsTrue("This is a test".Equals(actualString)); }
private UIElement CreateOffsetButton(ResourcePack resourcePack, int offset) { GroupOptionButton <bool> groupOptionButton = new GroupOptionButton <bool>(option: true, null, null, Color.White, null, 0.8f) { Left = StyleDimension.FromPercent(0.5f), Width = StyleDimension.FromPixelsAndPercent(0f, 0.5f), Height = StyleDimension.Fill }; bool num = (offset == -1 && resourcePack.SortingOrder == 0) | (offset == 1 && resourcePack.SortingOrder == _packsList.EnabledPacks.Count() - 1); Color lightCyan = Color.LightCyan; groupOptionButton.SetColorsBasedOnSelectionState(lightCyan, lightCyan, 0.7f, 0.7f); groupOptionButton.ShowHighlightWhenSelected = false; groupOptionButton.SetPadding(0f); Asset <Texture2D> obj = Main.Assets.Request <Texture2D>("Images/UI/TexturePackButtons", Main.content, (AssetRequestMode)1); UIImageFramed element = new UIImageFramed(obj, obj.Frame(2, 2, (offset == 1) ? 1 : 0)) { HAlign = 0.5f, VAlign = 0.5f, IgnoresMouseInteraction = true }; groupOptionButton.Append(element); groupOptionButton.OnMouseOver += delegate { SoundEngine.PlaySound(12); }; int offsetLocalForLambda = offset; if (num) { groupOptionButton.OnClick += delegate { SoundEngine.PlaySound(12); }; } else { groupOptionButton.OnClick += delegate { SoundEngine.PlaySound(12); OffsetResourcePackPriority(resourcePack, offsetLocalForLambda); PopulatePackList(); Main.instance.TilePaintSystem.Reset(); }; } if (offset == 1) { groupOptionButton.OnUpdate += OffsetFrontwardUpdate; } else { groupOptionButton.OnUpdate += OffsetBackwardUpdate; } return(groupOptionButton); }
public void MoveDown(ResourcePack pack) { int index = EnabledPacks.IndexOf(pack); if (index != EnabledPacks.Count - 1) { EnabledPacks.Remove(pack); EnabledPacks.Insert(index + 1, pack); } }
public void MoveUp(ResourcePack pack) { int index = EnabledPacks.IndexOf(pack); if (index != 0) { EnabledPacks.Remove(pack); EnabledPacks.Insert(index - 1, pack); } }
private void SetPackInfo(ResourcePack pack) { if (pack != null) { infoLabel.Text = string.Format("{0} ({1})\r\n{2}\r\n{3}", pack.Name, pack.Version, pack.Author, pack.Description); } else { infoLabel.Text = string.Empty; } }
internal void ValidateIcon(ValidationContext context) { try { if (!string.IsNullOrEmpty(this.Icon)) { var uriService = ((IServiceProvider)this.Store).GetService <IUriReferenceService>(); ResourcePack resolvedIcon = null; try { resolvedIcon = uriService.ResolveUri <ResourcePack>(new Uri(this.Icon)); } catch (UriFormatException) { context.LogError( string.Format(CultureInfo.CurrentCulture, Resources.Validate_NamedElementIconDoesNotPointToAValidFile, this.Name), Resources.Validate_NamedElementIconDoesNotPointToAValidFileCode, this); return; } if (resolvedIcon == null) { context.LogError( string.Format(CultureInfo.CurrentCulture, Resources.Validate_NamedElementIconDoesNotPointToAValidFile, this.Name), Resources.Validate_NamedElementIconDoesNotPointToAValidFileCode, this); return; } if (resolvedIcon.Type == ResourcePackType.ProjectItem) { var item = resolvedIcon.GetItem(); if (item.Data.ItemType != @"Resource") { context.LogError( string.Format(CultureInfo.CurrentCulture, Resources.Validate_NamedElementIconIsNotAResource, this.Name, item.Name), Resources.Validate_NamedElementIconIsNotAResource, this); } } } } catch (Exception ex) { tracer.Error( ex, Resources.ValidationMethodFailed_Error, Reflector <PatternElementSchema> .GetMethod(n => n.ValidateIcon(context)).Name); throw; } }
public void IsResourcesSerialized() { var resources = new ResourcePack(new ResourceModel("ResourceName", 100)); var sourceGame = new GameModel(resources, Array.Empty <UnitModel>()); var targetGame = Serialize(sourceGame); var source = sourceGame.Resources.Content; var target = targetGame.Resources.Content; Assert.AreEqual(source.Count, target.Count); Assert.AreEqual(source[0], target[0]); }
// Example of loading a resource pack private void loadTestAnimation() { rp = new ResourcePack(); rp.LoadPack("./assets1.pack", "AReallyGoodKeyShouldBeUsed"); for (int i = 0; i < 10; i++) { string file = $"./assets/Walking_00{i}.png"; testAnimation[i] = new Sprite(file, rp); testAnimationDecal[i] = new Decal(testAnimation[i], serviceProvider.GetService <IRenderer>()); } }
private UIElement CreateOffsetButton(ResourcePack resourcePack, int offset) { GroupOptionButton <bool> groupOptionButton1 = new GroupOptionButton <bool>(true, (LocalizedText)null, (LocalizedText)null, Color.White, (string)null, 0.8f, 0.5f, 10f); groupOptionButton1.Left = StyleDimension.FromPercent(0.5f); groupOptionButton1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 0.5f); groupOptionButton1.Height = StyleDimension.Fill; GroupOptionButton <bool> groupOptionButton2 = groupOptionButton1; int num = (offset != -1 ? 0 : (resourcePack.SortingOrder == 0 ? 1 : 0)) | (offset != 1 ? 0 : (resourcePack.SortingOrder == this._packsList.EnabledPacks.Count <ResourcePack>() - 1 ? 1 : 0)); Color lightCyan = Color.LightCyan; groupOptionButton2.SetColorsBasedOnSelectionState(lightCyan, lightCyan, 0.7f, 0.7f); groupOptionButton2.ShowHighlightWhenSelected = false; groupOptionButton2.SetPadding(0.0f); Asset <Texture2D> asset = Main.Assets.Request <Texture2D>("Images/UI/TexturePackButtons", (AssetRequestMode)1); UIImageFramed uiImageFramed1 = new UIImageFramed((Asset <Texture2D>)asset, ((Asset <Texture2D>)asset).Frame(2, 2, offset == 1 ? 1 : 0, 0, 0, 0)); uiImageFramed1.HAlign = 0.5f; uiImageFramed1.VAlign = 0.5f; uiImageFramed1.IgnoresMouseInteraction = true; UIImageFramed uiImageFramed2 = uiImageFramed1; groupOptionButton2.Append((UIElement)uiImageFramed2); groupOptionButton2.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f)); int offsetLocalForLambda = offset; if (num != 0) { groupOptionButton2.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f)); } else { groupOptionButton2.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f); this.OffsetResourcePackPriority(resourcePack, offsetLocalForLambda); this.PopulatePackList(); Main.instance.TilePaintSystem.Reset(); }); } if (offset == 1) { groupOptionButton2.OnUpdate += new UIElement.ElementEvent(this.OffsetFrontwardUpdate); } else { groupOptionButton2.OnUpdate += new UIElement.ElementEvent(this.OffsetBackwardUpdate); } return((UIElement)groupOptionButton2); }
public void Scrambled_WhenInvokedOnceWithByteArray_ReturnsDifferentByteArray() { ResourcePack pack = new ResourcePack(); byte[] testBytes = (from c in "This is a test" select(byte) c).ToArray(); byte[] actualBytes = pack.scramble(testBytes, "mykey"); string actualString = Encoding.Default.GetString(actualBytes); string testString = Encoding.Default.GetString(testBytes); Assert.IsFalse(testString.Equals(actualString)); }
private void OffsetResourcePackPriority(ResourcePack resourcePack, int offset) { if (resourcePack.IsEnabled) { List <ResourcePack> list = _packsList.EnabledPacks.ToList(); int num = list.IndexOf(resourcePack); int num2 = Utils.Clamp(num + offset, 0, list.Count - 1); if (num2 != num) { int sortingOrder = list[num].SortingOrder; list[num].SortingOrder = list[num2].SortingOrder; list[num2].SortingOrder = sortingOrder; } } }
private void SetPackInfo(ResourcePack pack) { if (pack != null) infoLabel.Text = string.Format("{0} ({1})\r\n{2}\r\n{3}", pack.Name, pack.Version, pack.Author, pack.Description); else infoLabel.Text = string.Empty; }
private Control ListTemplateGenerator(ResourcePack pack) { return new Label(ScreenManager) { Text = pack.Name, HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalTextAlignment = HorizontalAlignment.Left }; }