Skip to content

Commit

Permalink
Fixed layer blending (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo Zilkenat committed Jun 23, 2024
1 parent 6221daf commit 85abb76
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 33 deletions.
27 changes: 23 additions & 4 deletions source/GM-TE/GMTETileMatrixLayer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Class {
#superclass : #GMTEStaticCoordinateMatrix,
#instVars : [
'layerIdx',
'visible'
'visible',
'displayName'
],
#category : #'GM-TE-Core'
}
Expand Down Expand Up @@ -31,14 +32,14 @@ GMTETileMatrixLayer >> aboveLayer: aLayer [

{
#category : #adding,
#'squeak_changestamp' : 'jj 6/22/2024 16:23'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 20:18'
}
GMTETileMatrixLayer >> addTile: aTile at: x at: y [
GMTETileMatrixLayer >> addTile: aTile at: y at: x [

aTile ifNotNil: [
aTile morphicLayerNumber: self layerIdx.
aTile visible: self visible].
^ self at: x at: y put: aTile
^ self at: y at: x put: aTile.
]

{
Expand Down Expand Up @@ -69,6 +70,24 @@ GMTETileMatrixLayer >> belowLayer: aLayer [
^ (self aboveLayer: aLayer) not
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 19:47'
}
GMTETileMatrixLayer >> displayName [

^ displayName
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 19:54'
}
GMTETileMatrixLayer >> displayName: anObject [

displayName := anObject
]

{
#category : #enumerating,
#'squeak_changestamp' : 'jj 6/23/2024 13:56'
Expand Down
64 changes: 37 additions & 27 deletions source/GM-TE/GMTETileMatrixStack.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,18 @@ GMTETileMatrixStack class >> morphicLayerOffsetDefault [
^ 100
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 20:23'
}
GMTETileMatrixStack >> basicVisible: aBool [

visible := aBool
]

{
#category : #updating,
#'squeak_changestamp' : 'jj 6/22/2024 16:28'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 20:19'
}
GMTETileMatrixStack >> blendLayer: anIdx1 with: anIdx2 [

Expand All @@ -75,14 +84,15 @@ GMTETileMatrixStack >> blendLayer: anIdx1 with: anIdx2 [
topIdx := anIdx1.
bottomIdx := anIdx2].

1 to: bottomLayer columnCount do: [ :x |
1 to: bottomLayer rowCount do: [ :y |
bottomCell := bottomLayer at: x at: y.
topCell := topLayer at: x at: y.
1 to: bottomLayer columnCount do: [:x |
1 to: bottomLayer rowCount do: [:y |
bottomCell := bottomLayer at: y at: x.
topCell := topLayer at: y at: x.
bottomCell
ifNil: [
newCellEntry := topCell.
bottomLayer addTile: newCellEntry at: x at: y]
newCellEntry := topCell veryDeepCopy.
topCell ifNotNil: [topCell owner addMorph: newCellEntry].
bottomLayer addTile: newCellEntry at: y at: x]
ifNotNil: [
newCellEntry := bottomCell asBlendedWithImageMorph: topCell.
bottomCell updateSprite: newCellEntry image]]].
Expand All @@ -108,31 +118,31 @@ GMTETileMatrixStack >> blendLayers: aSet [

{
#category : #eumerating,
#'squeak_changestamp' : 'Valentin Teutschbein 6/7/2024 21:50'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 19:53'
}
GMTETileMatrixStack >> doLayers: aBlock [

self matrixLayers do: [ :layer | aBlock value: layer]
self matrixLayers do: [:layer | aBlock value: layer]
]

{
#category : #eumerating,
#'squeak_changestamp' : 'Valentin Teutschbein 6/7/2024 21:50'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 19:53'
}
GMTETileMatrixStack >> doTiles: aBlock [

self doLayers: [ :layer | layer doTiles: aBlock]
self doLayers: [:layer | layer doTiles: aBlock]
]

{
#category : #eumerating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 15:28'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 19:53'
}
GMTETileMatrixStack >> doTilesXYLidx: aBlock [

1 to: self width do: [ :x |
1 to: self height do: [ :y |
1 to: self layerCount do: [ :layerIdx |
1 to: self width do: [:x |
1 to: self height do: [:y |
1 to: self layerCount do: [:layerIdx |
aBlock value: x value: y value: layerIdx]]]
]

Expand Down Expand Up @@ -197,20 +207,20 @@ GMTETileMatrixStack >> layer: aLayerIdx [

{
#category : #accessing,
#'squeak_changestamp' : 'jj 6/22/2024 16:29'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 19:58'
}
GMTETileMatrixStack >> layer: aLayerIdx at: x at: y [
GMTETileMatrixStack >> layer: aLayerIdx at: y at: x [

^ (self matrixLayers at: aLayerIdx) at: x at: y
^ (self matrixLayers at: aLayerIdx) at: y at: x
]

{
#category : #accessing,
#'squeak_changestamp' : 'jj 6/22/2024 16:29'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 19:58'
}
GMTETileMatrixStack >> layer: aLayerIdx at: x at: y put: aTile [
GMTETileMatrixStack >> layer: aLayerIdx at: y at: x put: aTile [

^ (self matrixLayers at: aLayerIdx) addTile: aTile at: x at: y
^ (self matrixLayers at: aLayerIdx) addTile: aTile at: y at: x
]

{
Expand All @@ -223,7 +233,7 @@ GMTETileMatrixStack >> layerCount [
]

{
#category : #'as yet unclassified',
#category : #checking,
#'squeak_changestamp' : 'jj 6/22/2024 16:29'
}
GMTETileMatrixStack >> layerVisible: anIdx [
Expand All @@ -233,14 +243,14 @@ GMTETileMatrixStack >> layerVisible: anIdx [

{
#category : #'multiselect-helpers',
#'squeak_changestamp' : 'jj 6/22/2024 16:29'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 19:54'
}
GMTETileMatrixStack >> mapLayers: anOrderedCollection withUnaryBlock: aBlock [

| tmpResult |
tmpResult := OrderedCollection new.

anOrderedCollection do: [ :layerIdx |
anOrderedCollection do: [:layerIdx |
tmpResult add: (aBlock value: layerIdx)].

^ tmpResult
Expand Down Expand Up @@ -477,12 +487,12 @@ GMTETileMatrixStack >> visible [

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 23:10'
#'squeak_changestamp' : 'Ivo Zilkenat 6/23/2024 20:23'
}
GMTETileMatrixStack >> visible: aBool [

visible := aBool.

self basicVisible: aBool.
self doLayers: [ :aLayer |
aLayer visible: aBool]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ as yet unclassified
setUp

self editor ifNil: [self editor: GMTEEditor new].
self fileUUID: nil
self fileUUID: UUID new asString
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
as yet unclassified
setup
self editor: GMTEEditor new
self editor: GMTEEditor new.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"fileUUID:" : "jj 6/22/2024 16:55",
"loadTestMapFileToFileDirectory" : "JS 6/23/2024 18:18",
"setUp" : "jj 6/23/2024 18:55",
"setup" : " 6/23/2024 19:24:16",
"tearDown" : "jj 6/22/2024 20:24",
"testAddLayerButton" : "JS 6/23/2024 18:29",
"testDeleteLayer" : "jj 6/22/2024 20:25",
Expand Down

0 comments on commit 85abb76

Please sign in to comment.