Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 31 lines (27 sloc) 1.075 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
class MainController < NSWindowController
  attr_writer :main_view

  def applicationWillFinishLaunching(notification)
    @game = Game.new
    @main_view.game = @game
    @main_view.setNeedsDisplay(true)
    MIDIUtility.setup
  end

  def awakeFromNib
    NSNotificationCenter.defaultCenter.addObserver(self, selector: "midiKeyDown:", name: "MIDIKeyDownNotification", object: nil)
    NSNotificationCenter.defaultCenter.addObserver(self, selector: "midiKeyUp:", name: "MIDIKeyUpNotification", object: nil)
  end

  def midiKeyDown(notification)
    @game.key_down(notification.object)
    @main_view.setNeedsDisplay(true)
  rescue Exception => e
    NSLog([e.message, *e.backtrace].join("\n"))
    NSRunAlertPanel("Ruby Exception", [e.message, *e.backtrace].join("\n"), "OK", nil, nil);
  end

  def midiKeyUp(notification)
    @game.key_up(notification.object)
    @main_view.setNeedsDisplay(true)
  rescue Exception => e
    NSLog([e.message, *e.backtrace].join("\n"))
    NSRunAlertPanel("Ruby Exception", [e.message, *e.backtrace].join("\n"), "OK", nil, nil);
  end
end
Something went wrong with that request. Please try again.