Skip to content

Commit

Permalink
Fixed merge
Browse files Browse the repository at this point in the history
  • Loading branch information
valteu committed May 20, 2024
1 parent 6d6150a commit 50083a0
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 24 deletions.
72 changes: 58 additions & 14 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ Class {

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/19/2024 17:18'
#'squeak_changestamp' : 'Alex M 5/20/2024 15:46'
}
GMTEEditor class >> createCommandBarWithBuilder: aBuilder [
^aBuilder pluggablePanelSpec new
name: 'command bar';
children: {aBuilder pluggableButtonSpec new
name: 'export';
label: 'Export';
frame: (LayoutFrame fractions: (0 @ 0 corner: 0.3 @ 1) offsets: nil).
aBuilder pluggableButtonSpec new
frame: (LayoutFrame fractions: (0.3 @ 0 corner: 0.6 @ 1) offsets: nil);
action: [GMTEEditor loadTileSetWithDimensions: 16@16];
name: 'import';
label: 'Import'.
aBuilder pluggableButtonSpec new
frame: (LayoutFrame fractions: (0.6 @ 0 corner: 0.9 @ 1) offsets: nil);
name: 'openInWorld';
label: 'Open in World'};
frame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 0.1) offsets: nil);
yourself
Expand All @@ -37,23 +41,23 @@ GMTEEditor class >> createLayersWithBuilder: aBuilder [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'JS 5/19/2024 17:12'
#'squeak_changestamp' : 'Alex M 5/20/2024 15:44'
}
GMTEEditor class >> createTileViewerWithBuilder: aBuilder [
^aBuilder pluggablePanelSpec new
name: 'Tile Viewer';
name: 'tile viewer';
layout: #horizontal;
frame: (LayoutFrame fractions: (0.2 @ 0.1 corner: 0.8 @ 0.8) offsets: nil);
yourself
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/19/2024 17:28'
#'squeak_changestamp' : 'Alex M 5/20/2024 16:46'
}
GMTEEditor class >> createTilestoreWithBuilder: aBuilder [

^aBuilder pluggablePanelSpec new
^aBuilder pluggableScrollPaneSpec new
frame: ((0 @ 0.1) corner: 0.2 @ 1);
name: 'tile store';
layout: #vertical;
Expand All @@ -79,11 +83,48 @@ GMTEEditor class >> createTrayWithBuilder: aBuilder [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 5/20/2024 19:57'
#'squeak_changestamp' : 'Alex M 5/20/2024 17:44'
}
GMTEEditor class >> loadTileSetWithDimensions: aPoint [

"Do we really leaves this here or do we create an extra class for"

| fc stream form tile tile_width tile_height image morphs|

fc := FileChooser new.
fc initializeAsSystemWindowWithCaptionPane.
fc setCaption: 'Select a picture file' translated.
fc setSuffixes: {'png' . 'gif' . 'bmp' . 'jpg' . 'jpeg' }.
stream := fc open.

stream ifNil: [^ nil].

form := Form fromBinaryStream: stream.

morphs := OrderedCollection new.

tile_width := aPoint x.
tile_height := aPoint y.
"TODO: refactor into non C-like code"
0 to: (form height - tile_height) by: tile_height do:[:y|
0 to: (form width - tile_width) by: tile_width do: [:x|
tile := form contentsOfArea: (Rectangle origin: x@y extent: tile_width@tile_height).
image := GMTETileSelector new
image: (tile scaledToWidth: 50).
morphs add: image.
].
].

^ morphs.
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Alex M 5/20/2024 17:43'
}
GMTEEditor class >> new [

|builder spec morph tileMatrixMorph tileStore tileViewer|
|builder spec morph tileMatrixMorph tileStore tileViewer commandBar|
super new.
builder := ToolBuilder default.
spec := builder pluggableWindowSpec new
Expand All @@ -97,15 +138,18 @@ GMTEEditor class >> new [
self createLayersWithBuilder: builder};
yourself.
morph := builder build: spec.
commandBar := morph submorphNamed: 'command bar'.
tileStore := morph submorphNamed: 'tile store'.
tileViewer := (morph submorphNamed: 'Tile Viewer').

tileStore addMorph: Morph new.
tileStore addMorph: (Morph new
color: Color red;
yourself).
tileViewer := morph submorphNamed: 'tile viewer'.

"TODO 16 by 16 is a magic number. Where do we store tile dimensions?"
(commandBar submorphNamed: 'import') action: [
"TODO make multiple sprite sets available?"
tileStore morph removeAllMorphs;
addAllMorphs: (GMTEEditor loadTileSetWithDimensions: 16@16).
].

tileMatrixMorph := GMTETileMap tileWidth: 20 tileHeight: 20 padding: 0.15 sizeRatio: 1.
tileMatrixMorph := GMTETileMap tileWidth: 10 tileHeight: 10 padding: 0.0 sizeRatio: 2.

tileViewer addMorph: tileMatrixMorph.

Expand Down
26 changes: 16 additions & 10 deletions source/GM-TE/GMTETileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,29 @@ GMTETileMap >> borderTileWidth: anObject [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 5/20/2024 19:49'
#'squeak_changestamp' : 'Valentin Teutschbein 5/20/2024 20:30'
}
GMTETileMap >> clearTiles [

self gridTileMatrix do: [:aTile | aTile delete].
self gridTileMatrix do: [:aTile | aTile delete]
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 5/20/2024 19:55'
#category : #'import/export',
#'squeak_changestamp' : 'Alex M 5/20/2024 13:15'
}
GMTETileMap >> exportAsImage [
"Add further options in the future like choosing file format?"
self exportAsPNG
]

{
#category : #accessing,
#'squeak_changestamp' : 'Valentin Teutschbein 5/20/2024 20:10'
}
GMTETileMap >> extent: aPoint [

self gridTileMatrix ifNotNil: [self rescaleMap].

super extent: aPoint.
]

Expand Down Expand Up @@ -334,17 +342,16 @@ GMTETileMap >> processTiles [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 5/20/2024 19:50'
#'squeak_changestamp' : 'Valentin Teutschbein 5/20/2024 20:30'
}
GMTETileMap >> rescaleMap [
"comment stating purpose of message"

self rescaleMapWidth: self tileWidth height: self tileHeight padding: self mapPadding
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 5/20/2024 19:50'
#'squeak_changestamp' : 'Valentin Teutschbein 5/20/2024 20:18'
}
GMTETileMap >> rescaleMapWidth: aWidth height: aHeigth padding: aPadding [
"Rescale map & trigger update"
Expand All @@ -353,8 +360,7 @@ GMTETileMap >> rescaleMapWidth: aWidth height: aHeigth padding: aPadding [

self clearTiles.
self setDimensionsWidth: aWidth height: aHeigth padding: aPadding.
self updateMap.

self updateMap
]

{
Expand Down
15 changes: 15 additions & 0 deletions source/GM-TE/GMTETileSelector.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Class {
#name : #GMTETileSelector,
#superclass : #ImageMorph,
#category : #'GM-TE'
}

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Alex M 5/20/2024 18:29'
}
GMTETileSelector >> handlesMouseDown: evt [
"handlesMouseStillDown: for tiles"
Transcript show: 'test'.
^ true.
]

0 comments on commit 50083a0

Please sign in to comment.