Module: BSOD

Defined in:
lib/bsod.rb,
lib/bsod/version.rb,
lib/bsod/windowsnt.rb,
lib/bsod/windowsxp.rb,
lib/bsod/linux-sparc.rb,
lib/bsod/windows2000.rb,
lib/bsod/windowstext.rb

Overview

This is a great container over all Blue Screens of Death (BSOD).

Every BSOD must implement a ‘draw` method, that will render itself over any `SDL::Surface`.

Defined Under Namespace

Classes: LinuxSPARC, Windows2000, WindowsNT, WindowsText, WindowsXP

Constant Summary collapse

ALL =

All currently supported BSODs.

["windowsnt",
"windows2000",
"windowsxp",
"linux-sparc"]
VERSION =
"1.1.0"

Class Method Summary collapse

Class Method Details

.curses_inited?Boolean

TODO Figure out how to actually see if Curses is initialized.

Returns:

  • (Boolean)


54
55
56
# File 'lib/bsod.rb', line 54

def self.curses_inited?
  return true
end

.sdl_inited?Boolean

Tells if SDL has been initialized already, both by us (‘init_sdl`) or by the user.

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
# File 'lib/bsod.rb', line 20

def self.sdl_inited?
  if (SDL::inited_system(SDL::INIT_VIDEO) == 0) or
      (not SDL::TTF::init?)
    return false
  end

  return true
end

.wait_for_curses_key(key = Curses::KEY_F8) ⇒ Object

Waits for a keypress of ‘Curses::Key` `key`, ignoring anything else.

Defaults to F8.

TODO Somehow mix this with ‘wait_for_sdl_key`.



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/bsod.rb', line 64

def self.wait_for_curses_key(key=Curses::KEY_F8)
  loop = true
  while loop

    case Curses::getch
    when key
      loop = false
    end
    # Sleeping a little to avoid high-CPU rates.
    sleep 0.05
  end
end

.wait_for_sdl_key(key = SDL::Key::F8) ⇒ Object

Waits for a keypress of ‘SDL_KEY` `key`, ignoring anything else.

Defaults to F8.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/bsod.rb', line 33

def self.wait_for_sdl_key(key=SDL::Key::F8)
  loop = true
  while loop

    # Get events, exit when a certain key is pressed
    while event = SDL::Event2.poll

      case event
      when SDL::Event2::KeyDown
        SDL::Key.scan
        if SDL::Key.press? key
          loop = false
        end
      end
    end
    # Sleeping a little to avoid high-CPU rates.
    sleep 0.05
  end
end