Class: GamesAndRpgParadise::GUI::Tk::Gamebook

Inherits:
Object
  • Object
show all
Includes:
Base::Extensions::CommandlineArguments, Base::ExtensionsForAGamebook, Colours
Defined in:
lib/games_and_rpg_paradise/gui/tk/gamebook/gamebook.rb

Overview

< Base # === Foo::Gamebook

Constant Summary collapse

TITLE =
#

TITLE

#
'Gamebook'
NAMESPACE =
#

NAMESPACE

#
inspect

Constants included from Colours

Colours::WHITE

Constants included from Base::ExtensionsForAGamebook

Base::ExtensionsForAGamebook::DIRECTORY_FOR_THE_GAMEBOOKS

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Colours

#brown, #cfile, #convert_colour, convert_colour, #fancy, #normal, #pink, #red, #yel

Methods included from Base::Extensions::CommandlineArguments

#filter_away_commandline_arguments, #first_non_hyphened_argument?

Methods included from Base::ExtensionsForAGamebook

#available_gamebooks?, #io_download, #roll_this_die, use_gtk?, #use_gtk?, #wget, #yaml_gamebooks_dir?

Methods included from CommonExtensions

#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ Gamebook

#

initialize

#


46
47
48
49
50
51
52
53
54
55
# File 'lib/games_and_rpg_paradise/gui/tk/gamebook/gamebook.rb', line 46

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.[](i = '') ⇒ Object

#

RpgParadise::GUI::Tk::Gamebook[]

#


116
117
118
# File 'lib/games_and_rpg_paradise/gui/tk/gamebook/gamebook.rb', line 116

def self.[](i = '')
  new(i)
end

Instance Method Details

#commandline_arguments?Boolean

#

commandline_arguments?

#

Returns:

  • (Boolean)


79
80
81
# File 'lib/games_and_rpg_paradise/gui/tk/gamebook/gamebook.rb', line 79

def commandline_arguments?
  @commandline_arguments
end

#first_argument?Boolean Also known as: first?

#

first_argument?

#

Returns:

  • (Boolean)


86
87
88
# File 'lib/games_and_rpg_paradise/gui/tk/gamebook/gamebook.rb', line 86

def first_argument?
  @commandline_arguments.first
end

#resetObject

#

reset (reset tag)

#


60
61
62
63
64
65
66
# File 'lib/games_and_rpg_paradise/gui/tk/gamebook/gamebook.rb', line 60

def reset
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # infer_the_namespace
end

#runObject

#

run (run tag)

#


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/games_and_rpg_paradise/gui/tk/gamebook/gamebook.rb', line 93

def run
  root = TkRoot.new { title TITLE }
  TkLabel.new(root) {
    text 'Attention!'
  }
  canvas = TkCanvas.new(root)
  canvas.pack
  canvas.bind('1',  proc { |e| 
    p "#{e.x}, #{e.y}"
    TkcRectangle.new(canvas, e.x,e.y,e.x-5, e.y-5)
  })
  root.bind('Any-Key-d',  
    proc { |event| 
      p "#{event.x}, #{event.y}"
      TkcRectangle.new(canvas, event.x, event.y, event.x-5, event.y-5)
    }
  )
  ::Tk.mainloop
end

#set_commandline_arguments(i = '') ⇒ Object

#

set_commandline_arguments

#


71
72
73
74
# File 'lib/games_and_rpg_paradise/gui/tk/gamebook/gamebook.rb', line 71

def set_commandline_arguments(i = '')
  i = [i].flatten.compact
  @commandline_arguments = i
end