Class: Smagacor::GameView
- Defined in:
- lib/smagacor/smagacor-ui.rb
Constant Summary collapse
- DESCRIPTION =
Small description of Smagacor, for the about view.
"<p><img src=\"smagacor\" /><br /><br /><b>Smagacor #{::Smagacor::VERSION.join('.')}</b><br /> <br /> Smagacor is a collection of some small games.<br /> It provides an easy interface for adding new games and has<br /> a pleasing :-) appearance.<br /> <br /> Select a game from the menu on the left side!<br /> And have fun with Smagacor!!!<br /> <br /> <a href=\"http://smagacor.rubyforge.org\">smagacor.rubyforge.org</a>"
Instance Attribute Summary collapse
-
#cur_game_data ⇒ Object
readonly
Returns the value of attribute cur_game_data.
Instance Method Summary collapse
- #about ⇒ Object
-
#initialize(p) ⇒ GameView
constructor
A new instance of GameView.
- #select_game(item) ⇒ Object
Constructor Details
#initialize(p) ⇒ GameView
Returns a new instance of GameView.
100 101 102 103 104 105 106 107 108 |
# File 'lib/smagacor/smagacor-ui.rb', line 100 def initialize( p ) super( p ) @loaded = {} Qt::MimeSourceFactory.defaultFactory.setImage( 'smagacor', Qt::Image.new( Config.get_file( 'smagacor.png' ) ) ) aboutPage = Qt::Label.new( DESCRIPTION, self ) aboutPage.setAlignment( Qt::AlignVCenter | Qt::AlignCenter ) @aboutId = addWidget( aboutPage ) @cur_game_data = nil end |
Instance Attribute Details
#cur_game_data ⇒ Object (readonly)
Returns the value of attribute cur_game_data.
86 87 88 |
# File 'lib/smagacor/smagacor-ui.rb', line 86 def cur_game_data @cur_game_data end |
Instance Method Details
#about ⇒ Object
149 150 151 |
# File 'lib/smagacor/smagacor-ui.rb', line 149 def about raiseWidget( @aboutId ) end |
#select_game(item) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/smagacor/smagacor-ui.rb', line 110 def select_game( item ) return if item.nil? || item.rtti < 1000 gi = item.game_info if @cur_game_data save_game_state( @cur_game_data ) self.parent.parent..removeItem( @cur_game_data. ) if @cur_game_data. end data = OpenStruct.new unless @loaded.has_key?( gi ) begin require File.join( gi.directory, gi.file ) data.game_info = gi data.game_obj = gi.interface_class.new( self, gi ) data.undo_manager = UndoManager.new data.game_obj.set_undo_manager( data.undo_manager ) data. = data.game_obj. data. = addWidget( data.game_obj. ) @loaded[gi] = data rescue StandardError => e Qt::MessageBox.critical( self, "Error loading game", "Could not load the game #{gi.name}\nError: #{e.}\n#{e.backtrace.join("\n")}", Qt::MessageBox::Ok | Qt::MessageBox::Default, Qt::MessageBox::NoButton ) data = nil end else data = @loaded[gi] end unless data.nil? load_game_state( data ) data. = self.parent.parent..insertItem( data.game_info.name, data. ) if data. self.parent.parent.undoManager = data.undo_manager raiseWidget( @loaded[item.game_info]. ) @cur_game_data = data end end |