[squeak-dev] The Inbox: EToys-kfr.495.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Mar 6 19:39:39 UTC 2023


A new version of EToys was added to project The Inbox:
http://source.squeak.org/inbox/EToys-kfr.495.mcz

==================== Summary ====================

Name: EToys-kfr.495
Author: kfr
Time: 6 March 2023, 8:39:33.579068 pm
UUID: b90257f1-0b79-254b-8ea1-1d77b41688d9
Ancestors: EToys-mt.493

MinesBoard cached a MinesTile in variable protoTile. But this was very slow on older machines because it copied the protoTile. Also in theory you could set protoTile to any morph, but in practice it not possible because the protoTile must implement certain methods.

=============== Diff against EToys-mt.493 ===============

Item was changed:
  AlignmentMorph subclass: #MinesBoard
+ 	instanceVariableNames: 'rows columns flashCount tileCount target actionSelector arguments gameStart gameOver boardSize'
- 	instanceVariableNames: 'protoTile rows columns flashCount tileCount target actionSelector arguments gameStart gameOver boardSize'
  	classVariableNames: 'BoardSizes'
  	poolDictionaries: ''
  	category: 'Etoys-Squeakland-Morphic-Games'!

Item was changed:
  ----- Method: MinesBoard>>adjustTiles (in category 'accessing') -----
  adjustTiles
  	"reset tiles"
  
  	| newSubmorphs count r c |
  
  	submorphs do: "clear out all of the tiles."
  		[:m | m privateOwner: nil].
  
  	newSubmorphs := OrderedCollection new.
  
  	r := 0.
  	c := 0.
  	count := columns * rows.
  
  	1 to: count do:
  				[:m |
  				newSubmorphs add:
+ 					(MinesTile new
+ 						position: self position + (MinesTile new extent * (c @ r));
- 					(protoTile copy
- 						position: self position + (self protoTile extent * (c @ r));
  						actionSelector: #tileClickedAt:newSelection:modifier:;
  						arguments: (Array with: (c+1) @ (r+1));
  						target: self;
  						privateOwner: self).
  				c := c + 1.
  				c >= columns ifTrue: [c := 0. r := r + 1]].
  	submorphs := newSubmorphs asArray.
  
  !

Item was changed:
  ----- Method: MinesBoard>>extent: (in category 'geometry') -----
  extent: aPoint
  	"constrain the extent to be a multiple of the protoTile size during resizing"
+ 	super extent: (aPoint truncateTo: MinesTile new extent).!
- 	super extent: (aPoint truncateTo: protoTile extent).!

Item was changed:
  ----- Method: MinesBoard>>initialize (in category 'initialization') -----
  initialize
  	"initialize the state of the receiver"
  	super initialize.
  	""
  	target := nil.
  	actionSelector := #selection.
  	arguments := #().
  	""
  	self layoutPolicy: nil;
  	  hResizing: #rigid;
  	  vResizing: #rigid.
  	""
  	boardSize := BoardSizes at: 1.
  	
  	columns := self preferredColumns.
  	rows  := self preferredRows.
  	flashCount := 0.
  	""
+ 	self extent: MinesTile new extent * (columns @ rows).
- 	self extent: self protoTile extent * (columns @ rows).
  	self adjustTiles.
  	self resetBoard: 1.!

Item was removed:
- ----- Method: MinesBoard>>protoTile (in category 'accessing') -----
- protoTile
- 
- 	protoTile ifNil: [protoTile := MinesTile new].
- 	^ protoTile!

Item was removed:
- ----- Method: MinesBoard>>protoTile: (in category 'accessing') -----
- protoTile: aTile
- 
- 	protoTile := aTile!

Item was changed:
  ----- Method: MinesBoard>>resetBoard: (in category 'initialization') -----
  resetBoard: aLevel
      
        boardSize := BoardSizes at: aLevel.
        columns := self preferredColumns.
  	rows  := self preferredRows.
  	flashCount := 0.
  	""
+ 	self extent: MinesTile new extent * (columns @ rows).
- 	self extent: self protoTile extent * (columns @ rows).
  	self adjustTiles.
  	
        gameStart := false.
  	gameOver := false.
  	
  	flashCount := 0.
  	tileCount := 0.
  	Collection initialize.  "randomize the Collection class"
  	self purgeAllCommands.
  	self submorphsDo: "set tiles to original state."
  		[:m | m privateOwner: nil.  "Don't propagate all these changes..."
  		m mineFlag: false.
  		m disabled: false.
  		m switchState: false.
  		m isMine: false.
  		m privateOwner: self].
  	self changed  "Now note the change in bulk"!



More information about the Squeak-dev mailing list