Decodes a texture 'set bytes' operation
(chr: char, texture_id: TextureId, param: String, bytes: DecodeBytes)
| 1481 | /// Decodes a texture 'set bytes' operation |
| 1482 | /// |
| 1483 | fn decode_texture_set_bytes(chr: char, texture_id: TextureId, param: String, bytes: DecodeBytes) -> Result<(DecoderState, Option<Draw>), DecoderError> { |
| 1484 | // 4 u32s and some data |
| 1485 | if param.len() < 24 { |
| 1486 | let mut param = param; |
| 1487 | param.push(chr); |
| 1488 | return Ok((DecoderState::TextureOpSetBytes(texture_id, param, bytes), None)); |
| 1489 | } |
| 1490 | |
| 1491 | let bytes = bytes.decode(chr)?; |
| 1492 | |
| 1493 | if !bytes.ready() { |
| 1494 | return Ok((DecoderState::TextureOpSetBytes(texture_id, param, bytes), None)); |
| 1495 | } |
| 1496 | |
| 1497 | // Decode the data |
| 1498 | let mut chars = param.chars(); |
| 1499 | let x = Self::decode_u32(&mut chars)?; |
| 1500 | let y = Self::decode_u32(&mut chars)?; |
| 1501 | let w = Self::decode_u32(&mut chars)?; |
| 1502 | let h = Self::decode_u32(&mut chars)?; |
| 1503 | |
| 1504 | Ok((DecoderState::None, Some(Draw::Texture(texture_id, TextureOp::SetBytes(x, y, w, h, Arc::new(bytes.to_bytes()?)))))) |
| 1505 | } |
| 1506 | |
| 1507 | /// |
| 1508 | /// Decodes a texture 'set fill transparency' |