Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Used read parts of http://pastebin.com/mdW8D8fi
- module Utility
- #############
- # DLL STUFF #
- #############
- READ_INI = Win32API.new('kernel32', 'GetPrivateProfileStringA',
- %w(p p p p l p), 'l')
- ##
- # Read from system ini
- # Note: Default app_name changed to 'Launcher'
- #
- def self.read_ini(key_name, app_name = 'Launcher', filename = 'Launcher.ini',
- buffer_size = 256, default = '')
- buffer = "\0" * buffer_size
- READ_INI.call(app_name, key_name, default, buffer, buffer_size - 1,
- ".\\" + filename)
- return buffer.delete("\0")
- end
- end
- def create_sprite
- sprite = Sprite.new
- sprite.bitmap = Bitmap.new(640, 480)
- return sprite
- end
- def update_sprite
- @sprite ||= create_sprite
- @sprite.bitmap.clear
- @sprite.bitmap.draw_text(0, 0, 640, 480, "Loading fonts", 1)
- end
- ##
- # Trying to load too many fonts may lead to "Script is Hanging" error
- # For mitigating that create a thread which will call Graphics.update
- # every second.
- #
- # Note: Each font load call is blocking, so there is still a risk of the
- # error occuring, the likelihood should hopefully be significantly reduced.
- #
- Thread.new {
- loop do
- # Lets the thread sleep for a while to minimize CPU usage
- sleep 1
- update_sprite
- # Update the graphics to reset the "Script is Hanging" timer
- Graphics.update
- end
- }
- # Read all .ttf file from the Fonts folder
- AddFontResource = Win32API.new('Gdi32', 'AddFontResource', 'p', 'l')
- for filename in Dir.glob('Fonts/*.[Tt][Tt][Ff]')
- AddFontResource.call(filename)
- end
- # Run the actual game executable.
- game_name = Utility.read_ini('Game')
- Thread.new {system game_name}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement