mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Updated to mkxp-z 2.1.2, added def inspect to some classes
This commit is contained in:
@@ -96,106 +96,6 @@ module Enumerable
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# class ByteWriter (used by def save_to_png below)
|
||||
#===============================================================================
|
||||
class ByteWriter
|
||||
def initialize(filename)
|
||||
@file = File.new(filename, "wb")
|
||||
end
|
||||
|
||||
def <<(*data)
|
||||
write(*data)
|
||||
end
|
||||
|
||||
def write(*data)
|
||||
data.each do |e|
|
||||
if e.is_a?(Array)
|
||||
e.each { |item| write(item) }
|
||||
elsif e.is_a?(Numeric)
|
||||
@file.putc e
|
||||
else
|
||||
raise "Invalid data for writing."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def write_int(int)
|
||||
self << ByteWriter.to_bytes(int)
|
||||
end
|
||||
|
||||
def close
|
||||
@file.close
|
||||
@file = nil
|
||||
end
|
||||
|
||||
def self.to_bytes(int)
|
||||
return [
|
||||
(int >> 24) & 0xFF,
|
||||
(int >> 16) & 0xFF,
|
||||
(int >> 8) & 0xFF,
|
||||
int & 0xFF
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# class Bitmap
|
||||
#===============================================================================
|
||||
class Bitmap
|
||||
def save_to_png(filename)
|
||||
f = ByteWriter.new(filename)
|
||||
#============================= Writing header =============================#
|
||||
# PNG signature
|
||||
f << [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]
|
||||
# Header length
|
||||
f << [0x00, 0x00, 0x00, 0x0D]
|
||||
# IHDR
|
||||
headertype = [0x49, 0x48, 0x44, 0x52]
|
||||
f << headertype
|
||||
# Width, height, compression, filter, interlacing
|
||||
headerdata = ByteWriter.to_bytes(self.width).
|
||||
concat(ByteWriter.to_bytes(self.height)).
|
||||
concat([0x08, 0x06, 0x00, 0x00, 0x00])
|
||||
f << headerdata
|
||||
# CRC32 checksum
|
||||
sum = headertype.concat(headerdata)
|
||||
f.write_int Zlib::crc32(sum.pack("C*"))
|
||||
#============================== Writing data ==============================#
|
||||
data = []
|
||||
for y in 0...self.height
|
||||
# Start scanline
|
||||
data << 0x00 # Filter: None
|
||||
for x in 0...self.width
|
||||
px = self.get_pixel(x, y)
|
||||
# Write raw RGBA pixels
|
||||
data << px.red
|
||||
data << px.green
|
||||
data << px.blue
|
||||
data << px.alpha
|
||||
end
|
||||
end
|
||||
# Zlib deflation
|
||||
smoldata = Zlib::Deflate.deflate(data.pack("C*")).bytes
|
||||
# data chunk length
|
||||
f.write_int smoldata.size
|
||||
# IDAT
|
||||
f << [0x49, 0x44, 0x41, 0x54]
|
||||
f << smoldata
|
||||
# CRC32 checksum
|
||||
f.write_int Zlib::crc32([0x49, 0x44, 0x41, 0x54].concat(smoldata).pack("C*"))
|
||||
#============================== End Of File ===============================#
|
||||
# Empty chunk
|
||||
f << [0x00, 0x00, 0x00, 0x00]
|
||||
# IEND
|
||||
f << [0x49, 0x45, 0x4E, 0x44]
|
||||
# CRC32 checksum
|
||||
f.write_int Zlib::crc32([0x49, 0x45, 0x4E, 0x44].pack("C*"))
|
||||
f.close
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Kernel methods
|
||||
#===============================================================================
|
||||
|
||||
@@ -20,6 +20,12 @@ class Interpreter
|
||||
clear
|
||||
end
|
||||
|
||||
def inspect
|
||||
str = self.to_s.chop
|
||||
str << format(' event ID: %d>', @event_id)
|
||||
return str
|
||||
end
|
||||
|
||||
def clear
|
||||
@map_id = 0 # map ID when starting up
|
||||
@event_id = 0 # event ID
|
||||
|
||||
@@ -92,6 +92,12 @@ class Pokemon
|
||||
# Maximum number of moves a Pokémon can know at once
|
||||
MAX_MOVES = 4
|
||||
|
||||
def inspect
|
||||
str = self.to_s.chop
|
||||
str << format(' %s Lv.%s>', @species, @level.to_s || '???')
|
||||
return str
|
||||
end
|
||||
|
||||
def species_data
|
||||
return GameData::Species.get_species_form(@species, form_simple)
|
||||
end
|
||||
|
||||
@@ -8,6 +8,13 @@ class Trainer
|
||||
attr_accessor :language
|
||||
attr_accessor :party
|
||||
|
||||
def inspect
|
||||
str = self.to_s.chop
|
||||
party_str = @party.map { |p| p.species_data.species }.inspect
|
||||
str << format(' %s @party=%s>', self.full_name, party_str)
|
||||
return str
|
||||
end
|
||||
|
||||
def full_name
|
||||
return _INTL("{1} {2}", trainer_type_name, @name)
|
||||
end
|
||||
|
||||
@@ -31,13 +31,6 @@ class Player < Trainer
|
||||
# @return [Array<Array>] downloaded Mystery Gift data
|
||||
attr_accessor :mystery_gifts
|
||||
|
||||
def inspect
|
||||
str = self.to_s.chop
|
||||
party_str = @party.map { |p| p.species_data.species }.inspect
|
||||
str << format(' %s @party=%s>', self.full_name, party_str)
|
||||
return str
|
||||
end
|
||||
|
||||
# Sets the player's money. It can not exceed {Settings::MAX_MONEY}.
|
||||
# @param value [Integer] new money value
|
||||
def money=(value)
|
||||
|
||||
@@ -591,9 +591,7 @@ end
|
||||
def pbScreenCapture
|
||||
t = pbGetTimeNow
|
||||
filestart = t.strftime("[%Y-%m-%d] %H_%M_%S.%L")
|
||||
# capturefile = RTP.getSaveFileName(sprintf("%s.png", filestart))
|
||||
# Graphics.snap_to_bitmap.save_to_png(capturefile)
|
||||
capturefile = RTP.getSaveFileName(sprintf("%s.bmp", filestart))
|
||||
capturefile = RTP.getSaveFileName(sprintf("%s.png", filestart))
|
||||
Graphics.screenshot(capturefile)
|
||||
pbSEPlay("Pkmn exp full") if FileTest.audio_exist?("Audio/SE/Pkmn exp full")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user