Пример #1
0
        public void SetLink(string new_file_name, int pTag, string pDstFile, Point pImage_xy, int pImage_width, int pImage_height, string pInput_type)
        {
            //원본 데이터에 ADD할 임시 LINK
            LINK temp_links = new LINK();
            //LINK->link_data에 대입할 임시 link_info 리스트
            List<link_info> list_temp_link_info = new List<link_info>();
            //임시 link_info 리스트에 추가할 내용
            link_info temp_link_info = new link_info();

            temp_links.file_name = new_file_name;
            temp_link_info.bttn = new Button();
            temp_link_info.btn_id = pTag;
            temp_link_info.dst_file = pDstFile;
            temp_link_info.image_xy = pImage_xy;
            temp_link_info.image_width = pImage_width;
            temp_link_info.image_height = pImage_height;
            temp_link_info.input_type = pInput_type;

            //이미 파일 이름이 links에 존재하면 해당 인덱스에 data만 추가
            for (int i = 0; i < links.Count; i++)
            {
                if (links[i].file_name.Equals(new_file_name))
                {
                    links[i].link_data.Add(temp_link_info);
                    return;
                }
            }

            //존재하지 않으면 파일 이름 포함하여 데이터 전체를 새로운 링크로 추가
            //리스트형태의 임시 변수에 temp_link_info를 추가하고 이 변수를 temp_links의 link_data에 대입한다.
            list_temp_link_info.Add(temp_link_info);
            temp_links.link_data = list_temp_link_info;
            links.Add(temp_links);
            return;
        }
Пример #2
0
        private void DistributeGas(ApplicationEngine engine, UInt160 account, AccountState state)
        {
            BigInteger gas = CalculateBonus(engine.Snapshot, state.Balance, state.BalanceHeight, engine.Snapshot.PersistingBlock.Index);

            state.BalanceHeight = engine.Snapshot.PersistingBlock.Index;
            LINK.Mint(engine, account, gas);
            engine.Snapshot.Storages.GetAndChange(CreateAccountKey(account)).Value = state.ToByteArray();
        }
Пример #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            LINK lINK = db.LINKs.Find(id);

            db.LINKs.Remove(lINK);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "URL_ID,URL,FILTER_ID")] LINK lINK)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lINK).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FILTER_ID = new SelectList(db.FILTERs, "FILTER_ID", "FILTER_NAME", lINK.FILTER_ID);
     return(View(lINK));
 }
Пример #5
0
        public ActionResult Create([Bind(Include = "URL_ID,URL,FILTER_ID")] LINK lINK)
        {
            if (ModelState.IsValid)
            {
                db.LINKs.Add(lINK);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FILTER_ID = new SelectList(db.FILTERs, "FILTER_ID", "FILTER_NAME", lINK.FILTER_ID);
            return(View(lINK));
        }
Пример #6
0
        // GET: LINKs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LINK lINK = db.LINKs.Find(id);

            if (lINK == null)
            {
                return(HttpNotFound());
            }
            return(View(lINK));
        }
Пример #7
0
        public void ProcessExportedFiles(string defaultDataFolder, IGraphicsInfo gInfo)
        {
            if (!(gInfo is StlConstants stlInfo))
            {
                return;
            }
            LINK.Unpack(Path.Combine(defaultDataFolder, stlInfo.Link), Path.Combine(defaultDataFolder, stlInfo.LinkFolder), true, 4);
            var    ncer   = NCER.Load(Path.Combine(defaultDataFolder, stlInfo.Ncer));
            string data   = Path.Combine(defaultDataFolder, stlInfo.TexData ?? stlInfo.Data);
            string info   = Path.Combine(defaultDataFolder, stlInfo.TexInfo ?? stlInfo.Info);
            bool   tiled  = stlInfo.TexData == null;
            string pngDir = Path.Combine(defaultDataFolder, stlInfo.PngFolder);

            STLCollection.Load(data, info).SaveAsPngs(pngDir, ncer, tiled);
        }
Пример #8
0
        // GET: LINKs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LINK lINK = db.LINKs.Find(id);

            if (lINK == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FILTER_ID = new SelectList(db.FILTERs, "FILTER_ID", "FILTER_NAME", lINK.FILTER_ID);
            return(View(lINK));
        }
Пример #9
0
        private BigInteger CalculateBonus(Snapshot snapshot, BigInteger value, uint start, uint end)
        {
            if (value.IsZero || start >= end)
            {
                return(BigInteger.Zero);
            }
            if (value.Sign < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(value));
            }
            BigInteger amount = BigInteger.Zero;
            uint       ustart = start / Blockchain.DecrementInterval;

            if (ustart < Blockchain.GenerationAmount.Length)
            {
                uint istart = start % Blockchain.DecrementInterval;
                uint uend   = end / Blockchain.DecrementInterval;
                uint iend   = end % Blockchain.DecrementInterval;
                if (uend >= Blockchain.GenerationAmount.Length)
                {
                    uend = (uint)Blockchain.GenerationAmount.Length;
                    iend = 0;
                }
                if (iend == 0)
                {
                    uend--;
                    iend = Blockchain.DecrementInterval;
                }
                while (ustart < uend)
                {
                    amount += (Blockchain.DecrementInterval - istart) * Blockchain.GenerationAmount[ustart];
                    ustart++;
                    istart = 0;
                }
                amount += (iend - istart) * Blockchain.GenerationAmount[ustart];
            }
            amount += (LINK.GetSysFeeAmount(snapshot, end - 1) - (start == 0 ? 0 : LINK.GetSysFeeAmount(snapshot, start - 1))) / LINK.Factor;
            return(value * amount * LINK.Factor / TotalAmount);
        }
Пример #10
0
    public ValueTask ExecuteAsync(IConsole console)
    {
        LINK.Unpack(FilePath, DestinationFolder);

        return(default);
Пример #11
0
	/// <summary>
	/// Save object header, links and properties to storage.
	/// </summary>
	/// <param name="header">In/Out header value.</param>
	/// <param name="links">Array of modified object links.</param>
	/// <param name="props">Array of modified object properties.</param>
	/// <param name="mlinks">Array of new object links.</param>
	/// <param name="mprops">Array of new object properties.</param>
	public void Save( ref HEADER header, LINK[] links, PROPERTY[] props,
					  out LINK[] mlinks, out PROPERTY[] mprops )
	{
		#region debug info
#if (DEBUG)
		Debug.Print( "-> ODB.Save( {0}, {1}, {2}, {3}, {4} )",
					header.ID, header.Type, 
					header.Stamp, props.GetUpperBound( 0 ),
					links.GetUpperBound( 0 ) );
#endif
		#endregion

		DbCommand cmd = null;			// other puroses
		List<PROPERTY> _props = null;	// list for collecting current object properties
		int objID;						// object ID

		// initialize out parameters
		mlinks = null;
		mprops = null;

		// open connection and start new transaction if required
		TransactionBegin();
		try {
			#region create new object proxy if it is new or check it's stamp
			// assign command which will insert or (check, update) object record in DB
			if( header.ID == 0 ) {
				// this is new object. Creating script for insertion of object
				cmd =
					new SqlCommand(
						"\nINSERT INTO [dbo].[_objects] ( [ObjectName], [ObjectType] ) " +
						"VALUES ( @Name, @Type );\n" +
						/*save inserted object ID*/
						"SET @ID = SCOPE_IDENTITY();");
				cmd.Connection = m_con;
				cmd.Transaction = m_trans;
				// add proxy name parameter
				cmd.Parameters.Add(new SqlParameter("@Name", header.Name));
				// add proxy name parameter
				cmd.Parameters.Add(new SqlParameter("@Type", header.Type));
				// add proxy ID parameter
				cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
				cmd.Parameters["@ID"].Direction = ParameterDirection.Output;
			} else {
				// check object stamp. If it is newer then current -> raise error
				cmd = new SqlCommand( string.Format(
					"DECLARE @_id AS Int; SET @_id = @ID;\n" +
					"IF ((SELECT [TimeStamp] FROM [dbo].[_objects] WHERE [ID] = @_id) > @Stamp) " +
					"RAISERROR( '{0}', 11, 1 );",
					ERROR_CHANGED_OBJECT ) );
				cmd.Connection = m_con;
				cmd.Transaction = m_trans;
				// add proxy ID parameter
				cmd.Parameters.Add(new SqlParameter("@ID", header.ID));
				// add proxy stamp parameter
				cmd.Parameters.Add( new SqlParameter("@Stamp", header.Stamp));
				// proxy name is always updated
				cmd.CommandText += "UPDATE [dbo].[_objects] SET [ObjectName] = @Name WHERE [ID] = @_id";

				// add proxy name parameter
				cmd.Parameters.Add( new SqlParameter( "@Name", header.Name) );
			}

			// execute batch
			cmd.ExecuteNonQuery();
			// get proxy ID returned by batch execution
			objID = Convert.ToInt32( cmd.Parameters["@ID"].Value );
			#endregion

			// create new command
			cmd = new SqlCommand("");
			cmd.Connection = m_con;
			cmd.Transaction = m_trans;
			_props = new List<PROPERTY>();

			// iterate through received properties
			for( int i = 0; i < props.Length; i++ ) {
				// check for property state and type for different processing
				if( props[i].State == PROPERTY.STATE.Deleted ) {
					// just delete property from _properties/_images table
					cmd.CommandText += string.Format(
						"DELETE FROM [dbo].[_properties] WHERE [ObjectID] = {0} AND [Name] = '{1}'; \n" +
						"IF @@ROWCOUNT = 0 BEGIN                                                    \n" + 
						"    DELETE FROM [dbo].[_images] WHERE [ObjectID] = {0} AND [Name] = '{1}'; \n" +
						"END;                                                                       \n",
						objID, props[i].Name );
				} else if( props[i].Value.ToObject() is PersistentStream &&
						   (props[i].Value.ToObject() as PersistentStream).Length > 7900 ) {
					// save large stream property: 7900 is maximum length of sql_variant field in
					// _properties table because SQL Server limits maximum row size to 8060 bytes,
					// so save stream property as blob
					save_blob( objID, props[i].Name, (PersistentStream)props[i].Value,
							   props[i].State == PROPERTY.STATE.New );
				} else {
					// convert property value to sql_variant capable type
					object value;
					if( props[i].Value.ToObject() is PersistentStream ) {
						// this is a little stream, so convert stream value to byte array
						PersistentStream s = props[i].Value.ToObject() as PersistentStream;
						byte[] buffer = new byte[s.Length];
						s.Seek( 0, SeekOrigin.Begin );
						s.Read( buffer, 0, (int)s.Length );
						value = buffer;
					} else if( props[i].Value.ToObject().GetType() == typeof(DateTime) ) {
						// DateTime property must be converted to precision of sql server before save
						value = datetime_to_sql( (DateTime)props[i].Value );
						// add to changed properies list to return to client
						_props.Add( new PROPERTY(props[i].Name, new ValueBox(value), PROPERTY.STATE.Changed) );
					} else {
						// no convertion is needed
						value = props[i].Value.ToObject();
					}

					// compose sql command to update/insert data into _properties table
					if( props[i].State == PROPERTY.STATE.Changed ) {
						// compose UPDATE command (if this is binary property change, add
						// some extra processing: _images can contain this property already)
						cmd.CommandText += string.Format(
							"UPDATE [dbo].[_properties] SET [Value] = @P{2} WHERE [ObjectID] = {0} AND [Name] = '{1}';     \n" +
							(!(props[i].Value.ToObject() is PersistentStream) ? "" :
							"IF @@ROWCOUNT = 0 BEGIN                                                                       \n" +
							"    DELETE FROM [dbo].[_images] WHERE [ObjectID] = {0} AND [Name] = '{1}';                    \n" +
							"    INSERT INTO [dbo].[_properties] ([ObjectID], [Name], [Value]) VALUES ({0}, '{1}', @P{2}); \n" +
							"END;                                                                                          \n"),
							objID, props[i].Name, i );
					} else {
						// compose INSERT command
						cmd.CommandText += string.Format(
							"INSERT INTO [dbo].[_properties] ([ObjectID], [Name], [Value]) VALUES ({0}, '{1}', @P{2}); \n",
							objID, props[i].Name, i );
					}
					cmd.Parameters.Add( new SqlParameter( "@P" + i, value ) );
				}
			}

			// iteration throught links
			foreach( LINK link in links ) {
				// check link action
				if( link.State == LINK.STATE.New ) {
					// add new link to DB
					cmd.CommandText += string.Format(
						"INSERT INTO [dbo].[_links] ([Parent], [Child]) VALUES ({0}, {1}); \n",
						objID, link.Header.ID );
				} else if( link.State == LINK.STATE.Deleted ) {
					// delete link from DB
					cmd.CommandText += string.Format(
						"DELETE FROM [dbo].[_links] WHERE [Parent] = {0} AND [Child] = {1}; \n",
						objID, link.Header.ID );
				}
			}

			// executing batch
			if( cmd.CommandText != "" ) cmd.ExecuteNonQuery();

			// return proxy properties
			header = get_header( objID );
			// and changed properies if exists
			if( _props.Count > 0 )
				mprops = _props.ToArray();
		} catch( Exception ex ) {
			#region debug info
#if (DEBUG)
			Debug.Print( "[ERROR] @ ODB.Save: {0}", ex.ToString() );
#endif
			#endregion
			// rollback failed transaction
			TransactionRollback();
			throw;
		}
		// close connection and commit transaction if required
		TransactionCommit();

		#region debug info
#if (DEBUG)
		Debug.Print( "<- ODB.Save(ID:{0}, Type:'{1}', Name:'{2}', Stamp:'{3}' )",
					header.ID, header.Type, header.Name, header.Stamp );
#endif
		#endregion
	}
Пример #12
0
	/// <summary>
	/// Retrieve object header, links and properties.
	/// </summary>
	/// <param name="header">In/Out header value.</param>
	/// <param name="links">Array of object links.</param>
	/// <param name="props">Array of object properties.</param>
	public void Retrieve( ref HEADER header, out LINK[] links,
						  out PROPERTY[] props )
	{
		#region debug info
#if (DEBUG)
		Debug.Print( "-> ODB.Retrieve( {0}, {1} )", header.ID, header.Type );
#endif
		#endregion

		List<PROPERTY> _props = new List<PROPERTY>();	// list to store properties of object
		List<LINK> _links = new List<LINK>();	// list to store child proxy objects
		DbDataReader dr = null;
		DbCommand cmd = null;
		// init out parameters
		links = null;
		props = null;

		// open connection and start new transaction if required
		TransactionBegin();
		try {
			// get object header
			HEADER newHeader = get_header( header.ID );

			if( header.Stamp == newHeader.Stamp ) {
				header = newHeader;
				// close connection and commit transaction if required
				TransactionCommit();
				return;
			}

			#region retrive props from _properties
			cmd = new SqlCommand( string.Format(
					"SELECT [Name], [Value] FROM [dbo].[_properties] WHERE [ObjectID] = {0}",
					header.ID) );
			cmd.Connection = m_con;
			cmd.Transaction = m_trans;

			dr = cmd.ExecuteReader( CommandBehavior.SingleResult );
			try {
				// read all simple properties of object
				while( dr.Read() ) {
					// read properties from row
					string name = (string) dr["Name"];
					object val	= dr["Value"];

					// convert byte array to memory stream
					if( val.GetType() == typeof(Byte[] ) ) {
						val = new PersistentStream((Byte[])val );
					}
					// build PersistentProperty upon recieved name and value and
					// save property in collection
					_props.Add( new PROPERTY( name, new ValueBox(val), PROPERTY.STATE.New ));
				}
			} finally {
				// Dispose SqlDataReader
				dr.Dispose();
			}
			#endregion

			#region retrive props from _images
			cmd = new SqlCommand( string.Format(
				"SELECT [Name] FROM [dbo].[_images] WHERE [ObjectID] = {0}",
				header.ID) );
			cmd.Connection = m_con;
			cmd.Transaction = m_trans;

			SqlDataAdapter da = new SqlDataAdapter( (SqlCommand)cmd );
			DataTable dt = new DataTable(); // table for object proxy properties

			da.Fill( dt ); // fill table
			DataTableReader dtr = new DataTableReader(dt);
			try {
				while( dtr.Read() ) {
					// save data from SqlDataReader because we need non SequentialAccess in datarow
					string name = (string) dtr["Name"];
					// save property in collection
					_props.Add( new PROPERTY( name,
											  new ValueBox( read_blob( header.ID, name ) ),
											  PROPERTY.STATE.New ));
				}
			} finally {
				dtr.Dispose();
			}
			#endregion

			#region retrive links
			cmd = new SqlCommand( string.Format(
				"SELECT [ID], [ObjectName], [ObjectType], [TimeStamp]\n" +
				"FROM [dbo].[_objects]\n" +
				"WHERE [ID] IN (SELECT Child FROM [dbo].[_links] WHERE Parent = {0})",
				header.ID) );
			cmd.Connection = m_con;
			cmd.Transaction = m_trans;

			dr = cmd.ExecuteReader( CommandBehavior.SingleResult );
			try {
				while( dr.Read() ) {
					// save child header
					_links.Add( new LINK(
						new HEADER((string) dr["ObjectType"],
							Convert.ToInt32( dr["ID"] ),
							Convert.ToDateTime( dr["TimeStamp"] ),
							(string) dr["ObjectName"] ),
							LINK.STATE.New));
				}
			} finally { dr.Dispose(); }
			#endregion

			props = _props.ToArray();
			links = _links.ToArray();
			header = newHeader;
		} catch( Exception ex ) {
			#region debug info
#if (DEBUG)
			Debug.Print( "[ERROR] @ ODB.Retrive: {0}", ex.ToString() );
#endif
			#endregion
			// rollback failed transaction
			TransactionRollback();
			throw;
		}
		// close connection and commit transaction if required
		TransactionCommit();

		#region debug info
#if (DEBUG)
		Debug.Print( "<- ODB.Retrieve({0}, {1})", header.ID, header.Type );
#endif
		#endregion
	}
Пример #13
0
        public void GetFilesToPatch(ConcurrentBag <FileToPatch> filesToPatch, IGraphicsInfo gInfo)
        {
            if (!(gInfo is PkmdlConstants pkmdlInfo))
            {
                return;
            }

            var spriteFiles = _overrideSpriteProvider.GetAllSpriteFiles(pkmdlInfo.Type);

            if (!spriteFiles.Any(i => i.IsOverride))
            {
                return;
            }

            // temporary link files
            string texLink = Path.GetTempFileName();
            string atxLink = Path.GetTempFileName();
            string dtxLink = Path.GetTempFileName();
            string pacLink = Path.GetTempFileName();

            // link files unpacked previously
            string texUnpacked = Path.Combine(_graphicsProviderFolder, pkmdlInfo.TEXLinkFolder);
            string atxUnpacked = Path.Combine(_graphicsProviderFolder, pkmdlInfo.ATXLinkFolder);
            string dtxUnpacked = Path.Combine(_graphicsProviderFolder, pkmdlInfo.DTXLinkFolder);
            string pacUnpacked = Path.Combine(_graphicsProviderFolder, pkmdlInfo.PACLinkFolder);

            var spriteFileDict = spriteFiles.ToDictionary(i => i.Id);

            var texLinkFiles = new string[200];
            var atxLinkFiles = new string[200];
            var dtxLinkFiles = new string[200];
            var pacLinkFiles = new string[200];

            Parallel.For(0, 200, i =>
            {
                string fileName = i.ToString().PadLeft(4, '0');
                var spriteFile  = spriteFileDict[i];
                if (spriteFile.IsOverride)
                {
                    using (var combinedImage = Image.Load <Rgba32>(spriteFile.File))
                    {
                        // populate palette ------------------------------------------------------------------------------------------------------

                        var palette = new List <Rgba32> {
                            Color.Transparent
                        };

                        // TEX ------------------------------------------------------------------------------------------------------

                        string texSource = Path.Combine(texUnpacked, fileName);
                        string texTemp   = Path.GetTempFileName();
                        File.Copy(texSource, texTemp, true);
                        BTX0 btx0  = new BTX0(texSource);
                        int height = btx0.Texture.PixelMap.Length / _pokemonSpriteWidth;
                        using (var texImg = combinedImage.Clone(g =>
                        {
                            g.Crop(new Rectangle(0, 0, _pokemonSpriteWidth, height));
                        }))
                        {
                            btx0.Texture.PixelMap = ImageUtil.FromImage(texImg, palette, PointUtil.GetIndex);
                        }

                        // ATX ------------------------------------------------------------------------------------------------------

                        var atxDecompressedLen = new FileInfo(Path.Combine(atxUnpacked, fileName)).Length * 2;
                        using (var atxImg = combinedImage.Clone(g =>
                        {
                            g.Crop(new Rectangle(_pokemonSpriteWidth, 0, _pokemonSpriteWidth, (int)(atxDecompressedLen / _pokemonSpriteWidth)));
                        }))
                        {
                            string atxTemp = Path.GetTempFileName();
                            File.WriteAllBytes(atxTemp, RawChar.Compress(ImageUtil.FromImage(atxImg, palette, PointUtil.GetIndex)));
                            atxLinkFiles[i] = atxTemp;
                        }


                        // DTX ------------------------------------------------------------------------------------------------------

                        var dtxDecompressedLen = new FileInfo(Path.Combine(atxUnpacked, fileName)).Length * 2;
                        using (var dtxImg = combinedImage.Clone(g =>
                        {
                            g.Crop(new Rectangle(_pokemonSpriteWidth * 2, 0, _pokemonSpriteWidth, (int)(dtxDecompressedLen / _pokemonSpriteWidth)));
                        }))
                        {
                            string dtxTemp = Path.GetTempFileName();
                            File.WriteAllBytes(dtxTemp, RawChar.Compress(ImageUtil.FromImage(dtxImg, palette, PointUtil.GetIndex)));
                            dtxLinkFiles[i] = dtxTemp;
                        }


                        // PAC ------------------------------------------------------------------------------------------------------

                        string pacUnpackedFolder = Path.Combine(pacUnpacked, fileName + "-Unpacked");
                        var pacDecompressedLen   = new FileInfo(Path.Combine(pacUnpackedFolder, "0003")).Length * 2;
                        using (var pacImg = combinedImage.Clone(g =>
                        {
                            g.Crop(new Rectangle(_pokemonSpriteWidth * 3, 0, _pokemonSpriteWidth, (int)(pacDecompressedLen / _pokemonSpriteWidth)));
                        }))
                        {
                            string pacCharTemp = Path.GetTempFileName();
                            File.WriteAllBytes(pacCharTemp, RawChar.Compress(ImageUtil.FromImage(pacImg, palette, PointUtil.GetIndex)));
                            string pacTemp    = Path.GetTempFileName();
                            string[] pacFiles = new string[]
                            {
                                Path.Combine(pacUnpackedFolder, "0000"),
                                Path.Combine(pacUnpackedFolder, "0001"),
                                Path.Combine(pacUnpackedFolder, "0002"),
                                pacCharTemp
                            };
                            PAC.Pack(pacFiles, new[] { 0, 2, 5, 6 }, pacTemp, 1);
                            File.Delete(pacCharTemp);
                            pacLinkFiles[i] = pacTemp;
                        }


                        // TEX Palette -------------------------------------------------------------------------------------------
                        if (palette.Count > 16)
                        {
                            throw new System.Exception($"More than 16 colors in image when building tex file in {nameof(PkmdlPatchBuilder)}. This should have been filtered out by palette simplifier");
                        }

                        var resizedPalette = new Rgba32[16];
                        for (int paletteIndex = 0; paletteIndex < palette.Count; paletteIndex++)
                        {
                            resizedPalette[paletteIndex] = palette[paletteIndex];
                        }
                        resizedPalette[0] = Color.FromRgb(120, 120, 120);

                        var convertedPalette  = RawPalette.From32bitColors(resizedPalette);
                        btx0.Texture.Palette1 = convertedPalette;
                        btx0.Texture.Palette2 = convertedPalette;
                        btx0.WriteTo(texTemp);
                        texLinkFiles[i] = texTemp;
                    }
                }
                else
                {
                    texLinkFiles[i] = Path.Combine(texUnpacked, fileName);
                    atxLinkFiles[i] = Path.Combine(atxUnpacked, fileName);
                    dtxLinkFiles[i] = Path.Combine(dtxUnpacked, fileName);
                    pacLinkFiles[i] = Path.Combine(pacUnpacked, fileName);
                }
            });

            LINK.Pack(texLinkFiles, texLink);
            LINK.Pack(atxLinkFiles, atxLink);
            LINK.Pack(dtxLinkFiles, dtxLink);
            LINK.Pack(pacLinkFiles, pacLink);

            filesToPatch.Add(new FileToPatch(pkmdlInfo.TEXLink, texLink, FilePatchOptions.DeleteSourceWhenDone | FilePatchOptions.VariableLength));
            filesToPatch.Add(new FileToPatch(pkmdlInfo.ATXLink, atxLink, FilePatchOptions.DeleteSourceWhenDone | FilePatchOptions.VariableLength));
            filesToPatch.Add(new FileToPatch(pkmdlInfo.DTXLink, dtxLink, FilePatchOptions.DeleteSourceWhenDone | FilePatchOptions.VariableLength));
            filesToPatch.Add(new FileToPatch(pkmdlInfo.PACLink, pacLink, FilePatchOptions.DeleteSourceWhenDone | FilePatchOptions.VariableLength));
        }
Пример #14
0
        public int AddLink(string image_name, int addIndex, int pTag, string pDstFile, Point pImage_xy, int pImage_width, int pImage_height, string pInput_type)
        {
            link_info plink_info = new link_info();

            plink_info.btn_id = pTag;
            plink_info.bttn = new Button();
            plink_info.dst_file = pDstFile;
            plink_info.image_xy = pImage_xy;
            plink_info.image_width = pImage_width;
            plink_info.image_height = pImage_height;
            plink_info.input_type = pInput_type;

            //해당 이미지에 처음 링크를 설정하는 것이라면 먼저 new LINK를 새로 추가한다.
            try {
                links[addIndex].link_data.Add(plink_info);
            }
            catch (ArgumentOutOfRangeException e)
            {
                //원본 데이터에 ADD할 임시 LINK
                LINK temp_links = new LINK();
                temp_links.file_name = image_name;
                //LINK->link_data에 대입할 임시 link_info 리스트
                List<link_info> list_temp_link_info = new List<link_info>();
                //임시 link_info 리스트에 추가할 내용
                link_info temp_link_info = new link_info();

                temp_link_info.bttn = new Button();
                temp_link_info.btn_id = pTag;
                temp_link_info.dst_file = pDstFile;
                temp_link_info.image_xy = pImage_xy;
                temp_link_info.image_width = pImage_width;
                temp_link_info.image_height = pImage_height;
                temp_link_info.input_type = pInput_type;

                list_temp_link_info.Add(temp_link_info);
                temp_links.link_data = list_temp_link_info;
                links.Add(temp_links);
            }
            return links[addIndex].link_data.Count - 1;
        }
Пример #15
0
        public void ProcessExportedFiles(string defaultDataFolder, IGraphicsInfo gInfo)
        {
            if (!(gInfo is PkmdlConstants pkmdlInfo))
            {
                return;
            }

            string texLink = Path.Combine(defaultDataFolder, pkmdlInfo.TEXLink);
            string atxLink = Path.Combine(defaultDataFolder, pkmdlInfo.ATXLink);
            string dtxLink = Path.Combine(defaultDataFolder, pkmdlInfo.DTXLink);
            string pacLink = Path.Combine(defaultDataFolder, pkmdlInfo.PACLink);

            string texUnpacked = Path.Combine(defaultDataFolder, pkmdlInfo.TEXLinkFolder);
            string atxUnpacked = Path.Combine(defaultDataFolder, pkmdlInfo.ATXLinkFolder);
            string dtxUnpacked = Path.Combine(defaultDataFolder, pkmdlInfo.DTXLinkFolder);
            string pacUnpacked = Path.Combine(defaultDataFolder, pkmdlInfo.PACLinkFolder);

            string outFolderPath = Path.Combine(defaultDataFolder, pkmdlInfo.PngFolder);

            Directory.CreateDirectory(outFolderPath);

            LINK.Unpack(texLink, texUnpacked, false, 4);
            LINK.Unpack(atxLink, atxUnpacked, false, 4);
            LINK.Unpack(dtxLink, dtxUnpacked, false, 4);
            LINK.Unpack(pacLink, pacUnpacked, false, 4);

            int fileCount = Directory.GetFiles(texUnpacked).Length;

            Parallel.For(0, fileCount, i =>
            {
                string fileName    = i.ToString().PadLeft(4, '0');
                string outFilePath = Path.Combine(outFolderPath, fileName + ".png");

                BTX0 btx0 = new BTX0(Path.Combine(texUnpacked, fileName));

                Rgba32[] palette = RawPalette.To32bitColors(btx0.Texture.Palette1);
                palette[0]       = Color.Transparent;

                var texImg = ImageUtil.ToImage(
                    new ImageInfo(btx0.Texture.PixelMap, palette, _pokemonSpriteWidth, btx0.Texture.PixelMap.Length / _pokemonSpriteWidth),
                    PointUtil.GetPoint
                    );

                byte[] atxPixelmap = RawChar.Decompress(File.ReadAllBytes(Path.Combine(atxUnpacked, fileName)));
                var atxImg         = ImageUtil.ToImage(
                    new ImageInfo(atxPixelmap, palette, _pokemonSpriteWidth, atxPixelmap.Length / _pokemonSpriteWidth),
                    PointUtil.GetPoint
                    );

                byte[] dtxPixelmap = RawChar.Decompress(File.ReadAllBytes(Path.Combine(dtxUnpacked, fileName)));
                var dtxImg         = ImageUtil.ToImage(
                    new ImageInfo(dtxPixelmap, palette, _pokemonSpriteWidth, dtxPixelmap.Length / _pokemonSpriteWidth),
                    PointUtil.GetPoint
                    );


                string pacFile           = Path.Combine(pacUnpacked, fileName);
                string pacUnpackedFolder = Path.Combine(pacUnpacked, fileName + "-Unpacked");
                PAC.Unpack(pacFile, pacUnpackedFolder, false, 4);
                byte[] pacPixelmap = RawChar.Decompress(File.ReadAllBytes(Path.Combine(pacUnpackedFolder, "0003")));
                var pacImg         = ImageUtil.ToImage(
                    new ImageInfo(pacPixelmap, palette, _pokemonSpriteWidth, pacPixelmap.Length / _pokemonSpriteWidth),
                    PointUtil.GetPoint
                    );

                var totalWidth    = texImg.Width + atxImg.Width + dtxImg.Width + pacImg.Width;
                var maxHeight     = 1024;
                var combinedImage = new Image <Rgba32>(totalWidth, maxHeight);
                combinedImage.Mutate(g =>
                {
                    g.DrawImage(
                        image: texImg,
                        location: new Point(0, 0),
                        opacity: 1
                        );
                    g.DrawImage(
                        image: atxImg,
                        location: new Point(texImg.Width, 0),
                        opacity: 1
                        );
                    g.DrawImage(
                        image: dtxImg,
                        location: new Point(texImg.Width + atxImg.Width, 0),
                        opacity: 1
                        );
                    g.DrawImage(
                        image: pacImg,
                        location: new Point(texImg.Width + atxImg.Width + dtxImg.Width, 0),
                        opacity: 1
                        );
                });

                texImg.Dispose();
                atxImg.Dispose();
                dtxImg.Dispose();
                pacImg.Dispose();

                combinedImage.SaveAsPng(outFilePath);
                combinedImage.Dispose();
            });
        }
 private void create_ink_Click(object sender, EventArgs e)
 {
     LINK lnk = new LINK();
     lnk.create_ink(path_to_exe.Text, tb_version.Text);
 }