PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Hilfe gesucht! Script umschreiben von VX auf VX Ace



Memorazer
18.08.2015, 20:35
Hallo Zusammen,

ich brauche gaaaanz dringend Hilfe beim Umschreiben eines Screenshot Taker Scripts :O
Es wurde schonmal erweitert und hat beim VX noch prima funktioniert, beim VX Ace klappt es jetzt allerdings nicht.

Es wird aber auch nicht sowas wie eine Fehlermeldung angezeigt. Der Bildschirm friert einfach ein und nichts geht mehr.
Kann mir bitte jemand das Script entsprechend umstellen? Weiß nicht woran es liegt...

Dieses Script wäre jetzt für den vx und soll umgeschrieben werden. Es kann eigentlich nicht viel sein, der Code ist nicht so riesig, ich kann nur leider garnichts damit anfangen...



#===============================================================================
# Screenshot Taker
# By Jet10985 (Jet)
# PNG and BMP saving code by: Zeus81
# Modified by Cornix
#===============================================================================
# This script will allow you to take screenshots of the current gamescreen
# with the push of a button
# This script has: 7 customization options.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Graphics: update
#===============================================================================
=begin
Notes:

All screenshots are saved in a folder in the game directory called "Screenshots"
and they are named sequentially, depending on how many screenshots are in
the folder already.
=end

module JetScreenshotTaker

# Do you want to save the screenshot as a .bmp, or a .png?
# .bmp is basically instant, and is 32-bit but the alpha channel is not
# compatible with every image editing program.
# .png is slightly slower but it is usually smaller than the .bmp
# true is for .png, false if for .bmp
SAVE_AS_PNG = true

# Which button do you have to press to take a screenshot?
SCREENSHOT_BUTTON = Input:: F5

# Which switch must be active to be able to make a screenshot?
# If this value is negative then you can always make screenshots.
SCREENSHOT_SWITCH = 35

# Do you want a pop-up window to appear when a screenshot has been taken?
# The popup window will display how many seconds it took for the screenshot
POPUP_SCREENSHOT_WINDOW = true

# Would you like a sound effect played when a screenshot is taken?
SCREENSHOT_SE = true

# What SE would you like played?
SCREENSHOT_SE_FILE = "Kugelsound1"

# Do you want to add a "Watermark" or some other image ontop of screenshots?
WATERMARK = false

# What is the name of the watermark image name?
# This should be in the Pictures folder
# Watermark image starts at (0, 0) which is top left, so make the image
# screen-sized and place the contents accordingly.
WATERMARK_IMAGE = "Watermark"

end

#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================

# Bitmap export v 3.0 by Zeus81
class Bitmap

RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')

def address
RtlMoveMemory_pi.call(a = "\0" * 4, __id__ * 2 + 16, 4)
RtlMoveMemory_pi.call(a, a.unpack('L')[0] + 8, 4)
RtlMoveMemory_pi.call(a, a.unpack('L')[0] + 16, 4)
a.unpack('L')[0]
end

def export(filename)
jet_file_type = JetScreenshotTaker::SAVE_AS_PNG ? ".png" : ".bmp"
Dir.mkdir("Highscore") unless File.directory?("Highscore")
filename = "Highscore/Highscore #{Dir.entries("Highscore").size - 1}#{jet_file_type}"
file = File.open(filename, 'wb')
case format=File.extname(filename)
when '.bmp'
data, size = String.new, width*height*4
RtlMoveMemory_ip.call(data.__id__*2+8, [size,address].pack('L2'), 8)
file.write(['BM',size+54,0,54,40,width,height,1,32,0,size,0,0,0,0].pack('a2L6S2L6'))
file.write(data)
RtlMoveMemory_ip.call(data.__id__*2+8, "\0"*8, 8)
when '.png'
def file.write_chunk(chunk)
write([chunk.size-4].pack('N'))
write(chunk)
write([Zlib.crc32(chunk)].pack('N'))
end
file.write("\211PNG\r\n\32\n")
file.write_chunk("IHDR#{[width,height,8,6,0,0,0].pack('N2C5')}")
RtlMoveMemory_pi.call(data="\0"*(width*height*4), address, data.size)
(width*height).times {|i| data[i<<=2,3] = data[i,3].reverse!}
deflate, null_char, w4 = Zlib::Deflate.new(9), "\0", width*4
(height-1).downto(0) {|i| deflate << null_char << data[i*w4,w4]}
file.write_chunk("IDAT#{deflate.finish}")
deflate.close
file.write_chunk('IEND')
when ''; print("Export format missing for '#{filename}'.")
else print("Export format '#{format}' not supported.")
end
$game_variables[68] += 1
file.close
end
end

class << Graphics

alias jet9991_update update unless $@
def update(*args)
jet9991_update(*args)
if Input.trigger?(JetScreenshotTaker::SCREENSHOT_BUTTON) && (JetScreenshotTaker::SCREENSHOT_SWITCH < 0 || ($game_switches[JetScreenshotTaker::SCREENSHOT_SWITCH]))
old_time = Time.now
f = Graphics.snap_to_bitmap
if JetScreenshotTaker::WATERMARK
a = Cache.picture(JetScreenshotTaker::WATERMARK_IMAGE)
f.blt(0, 0, a, a.rect)
end
f.export("Image")
if JetScreenshotTaker::SCREENSHOT_SE
RPG::SE.new(JetScreenshotTaker::SCREENSHOT_SE_FILE, 100, 100).play
end
if JetScreenshotTaker::POPUP_SCREENSHOT_WINDOW
time = Time.now
real_time = (time - old_time)
elapsed_time = (real_time * 1000.0).to_i / 1000.0
p "Screenshot taken: #{elapsed_time} seconds"
end
end
end
end



Ich hoffe wirklich jemand kann hier helfen. Ich möchte die Funktion unbedingt in meinem Spiel haben...

Perusa
19.08.2015, 20:36
Kann es auch ein anderes Script sein? Ich habe in einem alten Projekt nachgesehen und zwei Scripts gefunden. Ich weiß nicht ob das das ist was du willst.

Das hier:
http://www.rpgmakervxace.net/topic/15456-gambit-save-game-screenshot/
Und das hier:
http://www.rpgmakervxace.net/topic/3266-map-screenshot/

Memorazer
19.08.2015, 20:49
Danke für eine Antwort, aber das passt leider nicht.
Das eine Script funktioniert nur beim Speichern und das andere hatte ich auch schon gefunden, ist aber fehlerhaft und es fehlen Inhalte...

Es gab wohl mal ein Script von Jet was für den Ace umgeschrieben wurde, der Link ist aber down!!

Mit diesem Script hätte man aber jetzt einen Vergleich:
http://www.rpgmakervxace.net/topic/3266-map-screenshot/

Kann man daraus nicht das andere verändern??!

Perusa
20.08.2015, 07:33
Achsooo. Hmm... ich würde dann vorschlagen das du mal im Ace Forum fragst. Da sind nämlich die ganzen Scripter für den Ace.
Die können dir bestimmt helfen. :)
Ansonsten schaue ich mich mal nach dem Script um.

Linkey
20.08.2015, 14:18
Wenn es bis zum Wochenende noch nicht gelöst ist, schaue ich auch gerne einmal herein. Komme arbeitsbedingt leider aber frühstens Freitag dazu.

Linkey
21.08.2015, 12:36
Hey Memorazer,

habe mir kurz das Script angeschaut und bis zum Schreiben des Files liegt mMn kein Fehler vor. Leider kenne ich mich mit den File-Klassen von Ruby nicht so gut aus, als das ich da direkt auf einen Blick sehen könnte, woran es liegt.

Es gibt aber folgendes Script von cremno: https://gist.github.com/cremno/4148851
Ich habe ein paar wenige Zeilen hinzugefügt/angepasst, damit der Name der Datei so ist wie in deinem Script und damit du die Switch-Funktion verwenden kannst. Ich hoffe es passt.



# ★ Screenshot taker
# ★★★★★★★★★★★★★★★★★★★★★★★
#
# Author/s : cremno
# RGSS ver : 3.0.0, 3.0.1
#
# Update 20150821:
# Author : linkey
# Added switch function, changed filename generation

module Screenshot
# ↓ CONFIGURATION
# key symbol or constant (help file → (Index → ) Input → Constants)
KEY = :F5
# SE file name (Sound Test ♬) (will be played after the image has been saved)
SE = 'Sheep'
# image file format / extension (:bmp, :jpg, :gif, :tiff, :png)
FORMAT = :png
# directory name
DIRECTORY = 'Highscore'
# file name
FILENAME = 'Highscore'
# Switch
SWITCH = 35
# ↑ CONFIGURATION

def self.play_se
RPG::SE.new(Screenshot::SE).play
end

def self.filename
Dir.exist?(DIRECTORY) || Dir.mkdir(DIRECTORY)
"#{DIRECTORY}/#{FILENAME} #{Dir.entries(DIRECTORY).size - 1}.#{FORMAT} "
end

end

class Bitmap

def save(filename)
ext = File.extname(filename)[1..-1]
if ext.empty?
warn "Bitmap#save: filename doesn't have an extension (fallback to PNG)"
ext = :png
filename << '.png'
else
ext = ext.to_sym
end
retval = false
bitmap = Gdiplus::Bitmap.new(:scan0, width, height, scan0)
if bitmap
retval = bitmap.save(:file, filename, ext)
bitmap.dispose
end
retval
end

private

def _data_struct(offset = 0)
@_data_struct ||= (DL::CPtr.new((object_id << 1) + 16).ptr + 8).ptr
(@_data_struct + offset).ptr.to_i
end

def gdidib
@gdidib ||= [_data_struct(8), _data_struct(16)]
end

def hbitmap
@hbitmap ||= _data_struct(44)
end

def scan0
@scan0 ||= _data_struct(12)
end

end

class << Graphics

alias_method :update_wo_screenshot, :update

def update
if($game_switches[Screenshot::SWITCH])
Input.trigger?(Screenshot::KEY) &&
Graphics.snap_to_bitmap.save(Screenshot.filename) &&
Screenshot.play_se
end
update_wo_screenshot
end

end

# ★ Windows Wide Char Management
# ★★★★★★★★★★★★★★★★★★★★★★★
#
# Author/s : cremno
# RGSS ver : 3.0.0, 3.0.1

class Encoding

UTF_8 ||= find('UTF-8')

UTF_16LE ||= find('UTF-16LE')

end

class String

unless method_defined?(:widen)
def widen
(self + "\0").encode(Encoding::UTF_16LE)
end
end

unless method_defined?(:widen!)
def widen!
self << "\0"
encode!(Encoding::UTF_16LE)
end
end

unless method_defined?(:narrow)
def narrow
chomp("\0").encode(Encoding::UTF_8)
end
end

unless method_defined?(:narrow!)
def narrow!
chomp!("\0")
encode!(Encoding::UTF_8)
end
end

end

# ★ GDI+ interface
# ★★★★★★★★★★★★★★★★★★★★★★★
#
# Author/s : cremno
# RGSS ver : 3.0.0, 3.0.1

module Gdiplus

class GdiplusError < StandardError
end

DLL = DL.dlopen('gdiplus')

FUNCTIONS = {}
{
'GdiplusStartup' => DL::TYPE_INT,
'GdiplusShutdown' => DL::TYPE_VOID,
'GdipDisposeImage' => DL::TYPE_INT,
'GdipSaveImageToFile' => DL::TYPE_INT,
'GdipCreateBitmapFromGdiDib' => DL::TYPE_INT,
'GdipCreateBitmapFromHBITMAP' => DL::TYPE_INT,
'GdipCreateBitmapFromScan0' => DL::TYPE_INT
}.each do |name, type|
FUNCTIONS[name.to_sym] = DL::CFunc.new(DLL[name], type, name, :stdcall)
end

CLSIDS = {}
dll = DL.dlopen('ole32')
name = 'CLSIDFromString'
func = DL::CFunc.new(dll[name], DL::TYPE_LONG, name, :stdcall)
{
bmp: '{557cf400-1a04-11d3-9a73-0000f81ef32e}'.widen!,
jpg: '{557cf401-1a04-11d3-9a73-0000f81ef32e}'.widen!,
gif: '{557cf402-1a04-11d3-9a73-0000f81ef32e}'.widen!,
tif: '{557cf405-1a04-11d3-9a73-0000f81ef32e}'.widen!,
png: '{557cf406-1a04-11d3-9a73-0000f81ef32e}'.widen!
}.each do |format, string|
clsid = "\0" * 16
func.call([DL::CPtr[string].to_i, DL::CPtr[clsid].to_i])
CLSIDS[format] = clsid
end
CLSIDS[:jpeg] = CLSIDS[:jpg]
CLSIDS[:tiff] = CLSIDS[:tif]

@token = "\0" * DL::SIZEOF_VOIDP

def self.token
@token
end

# TODO: prepend prefix (Gdip or Gdiplus) automatically
def self.call(*args)
name = args.shift
args.map! { |e| DL::CPtr[e].to_i }
r = FUNCTIONS[name].call(args)
if r && r != 0
fail GdiplusError,
"Status: #{v}\nFunction: #{name}\nArguments: #{args.inspect}"
end
true
end

def self.startup
input = [1].pack('L') # GdiplusVersion
input << "\0" * DL::SIZEOF_VOIDP # DebugEventCallback
input << "\0" * DL::SIZEOF_INT # SuppressBackgroundThread
input << "\0" * DL::SIZEOF_INT # SuppressExternalCodecs
call(:GdiplusStartup, @token, input, 0)
end

def self.shutdown
call(:GdiplusShutdown, @token)
end

class Image

attr_reader :instance

def initialize
@instance = 0
true
end

def save(destination, *args)
case destination
when :file
filename = args.shift.widen!
argv = [:GdipSaveImageToFile, filename, Gdiplus::CLSIDS[args.shift], 0]
else
fail ArgumentError, "unknown GDI+ image destination: #{source}"
end
argv.insert(1, @instance)
Gdiplus.call(*argv)
end

def dispose
Gdiplus.call(:GdipDisposeImage, @instance)
end

end

class Bitmap < Image

def initialize(source, *args)
case source
when :gdidib
argv = [:GdipCreateBitmapFromGdiDib, args.shift, args.shift]
when :hbitmap
argv = [:GdipCreateBitmapFromHBITMAP, args.shift, 0]
when :scan0
w = args.shift
h = args.shift
stride = w * -4 # BGRA, mirrored
format = 0x26200A # PixelFormat32bppARGB
scan0 = args.shift
argv = [:GdipCreateBitmapFromScan0, w, h, stride, format, scan0]
else
fail ArgumentError, "unknown GDI+ bitmap source: #{source}"
end
argv << "\0" * DL::SIZEOF_VOIDP
r = Gdiplus.call(*argv)
@instance = r ? argv[-1].unpack(DL::SIZEOF_VOIDP == 4 ? 'L' : 'Q')[0] : 0
r
end

end

end

Gdiplus.startup
class << SceneManager
alias_method :exit_wo_gdip_shutdown, :exit
def exit
exit_wo_gdip_shutdown
Gdiplus.shutdown
end
end


Beste Grüße,
Linkey

Memorazer
21.08.2015, 14:03
Uuhh, klingt schon mal gut :)
Probiere es aus sobald ich Zuhause bin.

Wenn es funktionieren sollte wäre noch gut zu wissen wie die Nutzungsbedingungen sind. Mal abwarten.

Memorazer
22.08.2015, 10:58
Das Script funktioniert prima. Vielen Dank, Linkey :)

Jetzt muss ich nur mal schauen wie ich es am besten verwende, so dass es userfreulich ist.

Linkey
22.08.2015, 13:48
Wenn du irgendeine Anpassung benötigst, kannst du gerne Bescheid geben. Solange es nicht zu viel Zeit benötigt und ich es hinbekommen kann, kann ich da gerne unterstützen.
Ich freue mich sowieso schon auf deine Vollversion :3