Ergebnis 1 bis 19 von 19

Thema: Projekt Box (VX): Script Umschreiben - Hilfe gesucht!

Hybrid-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    @Cornix:
    Vielen, vielen Dank Cornix. Es funktioniert wunderbar

    Du hattest zwar den Switch-Part noch weggelassen, aber das hab ich schnell noch gefixt und nun passts!

    Hier nochmal den Code falls ihn jemand anderes auch benutzen möchte: Credit an Jet, Zeus81 und Cornix

    Code:
    #===============================================================================
    # 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 = false
      
      # What SE would you like played?
      SCREENSHOT_SE_FILE = "Decision2"
      
      # 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
        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

    Gude Nacht

  2. #2
    Credits sind nicht nötig, das waren 2 Zeilen Code.

  3. #3
    Hallo Zusammen,

    muss das Thema doch nochmal aufgreifen, da ich gerne noch ein paar Dinge umgeschrieben hätte (wenn möglich).
    Es handelt sich um ein Screenshot-Script für mein Highscorebild.

    Die Funktion das man erst nach einem Switch ein Bild machen kann wurde bereits hinzugefügt und nun bräuchte ich
    zum Einen noch die Angabe einer Variablen darin (die sich nach Benutzung immer um 1 erhöht)
    und wenn möglich eine andere Eingabe-Taste für die Screenshot Funktion (derzeit F5) - hätte das gerne
    über die Abfrage eines bestimmten Buchstaben (P).

    Könnte mir hierbei nochmals jemand helfen?
    Hab` halt keinen Plan vom Scripten und hier sind ja fähige Leute unterwegs

    Vorab vielen Dank!

    Hier der Code:

    Code:
    #===============================================================================
    # 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 = false
      
      # What SE would you like played?
      SCREENSHOT_SE_FILE = "Decision2"
      
      # 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
        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
    .

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •