#!/usr/bin/ruby require File.dirname(__FILE__) + "/../lib/add_any_bundled_gems_to_load_path.rb" require 'sane' Thread.abort_on_exception=true # gah for file in ['overlayer', 'keyboard_input', 'screen_tracker', 'mouse', 'file_chooser', 'ocr', 'vlc_programmer'] require_relative '../lib/' + file end def go_sc(args) $VERBOSE = 1 if args.delete('-v') $DEBUG = 1 if args.delete('-d') if args.delete('--clear-cache') OCR.clear_cache! puts 'cleared cache' end $stderr.puts 'warning: currently windows only for certain parts currently' unless ENV['OS'] == 'Windows_NT' if args.detect{|arg| arg == '-h' || arg == '--help'} puts <<-END syntax: [player_description.yml|test] edit_decision_list.txt [-t -v --clear-cache] (or nothing at all--it will prompt) END for file in Dir[__dir__ + '../zamples/mute*/*'] puts "\n", "Example file:", file + "\n\n", File.read(file) end exit 1 else # allow for command line filenames player_description = args.shift.to_s if !File.exist?(player_description) puts 'Please Select Computer Player' player_description = FileChooser.choose_file(" SELECT COMPUTER PLAYER", __dir__ + "/../zamples/players") end edit_decision_list = args.shift.to_s if edit_decision_list == 'test' overlay = nil p 'got test...just doing screen dump' $VERBOSE=true # adds some extra output else if !File.exist? edit_decision_list puts 'Select Edit Decision List' edit_decision_list = FileChooser.choose_file(" SELECT EDIT DECISION LIST", __dir__ + "/../zamples/edit_decision_lists") end if !edit_decision_list puts "error: have to specify a scene descriptions file\n or specify \"test\" on the command line if you just want to snapshot your player" exit 1 end puts 'Selected scene descriptions file ' + File.basename(edit_decision_list) + "\n\t(full path: #{edit_decision_list})" Blanker.startup # todo start it late as it has an annoying startup blip overlay = OverLayer.new(edit_decision_list ) end if File.exist? player_description.to_s puts 'Selected player ' + File.basename(player_description) + "\n\t(full path: #{player_description})" # this one doesn't use any updates, so just pass in file contents, not filename screen_tracker = ScreenTracker.new_from_yaml File.binread(player_description), overlay Mouse.jitter_forever_in_own_thread # when this ends you know a snapshot was taken... # exit early if we just wanted a screen dump...a little kludgey... unless overlay puts 'warning--only doing screen dump in t-minus 4s...' sleep 4 puts 'snap!' screen_tracker.dump_bmp exit 1 end screen_tracker.process_forever_in_thread else puts 'warning--not using any screen tracking...' end OCR.unserialize_cache_from_disk # do this every time so we don't delete it if they don't have one... puts "Opening the curtains... (please play in your other player now)" overlay.start_thread true key_input = KeyboardInput.new overlay key_input.start_thread # status thread at_exit { Blanker.shutdown # lodo move this and the 'q' key to within overlayer OCR.serialize_cache_to_disk } puts "syntax from command line: \"#{player_description}\" \"#{edit_decision_list}\"" key_input.handle_keystrokes_forever # blocking... end end if __FILE__ == $0 puts 'Welcome to Sensible Cinema...' go_sc ARGV end