
Now , that we have walked more than 10 lessons of our course, did you understand the "global idea" of the Squeak-Croquet environment?
Look this schema of our imaginary - not commited by developers - sugestion for a Squeak-Croquet "standard system" and try to explain it for yourself:
We will try to talk - at future lessons - only under this patern.
At this lesson, by example, the exercice will be to "install" a new application (a project) inside your Squeak-Croquet system.
Until now, the only thing that you know about programming of Squeak projects is to write an string (we will have many lessons about Squeak programming of applications soon at this course). So, the application you will install - I made it and it is at the DMU web server - only write a message:
Imagine that you have downloaded Croquet today. The "main page" of our "standard system" appears when you run Croquet for the first time.
To install your first webobject you need to open a Package Browser - we have explained how to do this - over the "main page" and select the Category: MyCroquet and the Class: Private.
You will create a new "make function" for this Class. You know the address of the application - someone said for you that it's a marvelous application - http://www.dmu.com/TeaLand/HelloPrivate.001.pr.
You know also the relative-size of the "form" of the application: 800 x 600 - the usual...
Like your space is empty you don't have problems to find a position for the 3D window for this application: x=8, y=0, z=-20, in the Cartesian system. It's a good idea to have a map with the positions of all the windows installed in all the spaces of your Croquet 3D environment, to facilitate new installations of applications.
You need to write a new "make function". It's easy :
makeHelloPrivate: sp | win3D teaWorld tm url | url := 'http://www.dmu.com/TeaLand/HelloPrivate.001.pr'. self loadURL: url. tm := TMorphic new initializeOpaque: true extent: 800@600. teaWorld := TMorphMonitor new initializeWithWorld: 'HelloPrivate' extent: 800@600. teaWorld eventsTo: tm. win3D := TWindow new. win3D translationX: 8 y: 0 z:-20. "win3D rotationAroundY: 135.0." win3D contents: tm. win3D closeContents. sp addChild: win3D. ^ win3D.
CODE COMMENTS
You have the Package Browser overed and - in the case of our sugested "standard system" - in the Category: My croquet and at the Class: Private you will find the function initializeDefaultSpace. You need only to add a line (bolded) to call the new "make function" :
initializeDefaultSpace | space | "Create a new space" space := TSpace new. "Make a light" self makeLight: space. "Make a floor" self makeFloor: space fileName:'lawn.BMP'. "Create the webobjects for this space here:" self makeHelloPrivate: space. "Create Portals here:" "without Portals until now" ^space.
CODE COMMENTS
In some place of the "main-page" of our imaginary system, you will find, minimized, the Workspace having the script for to install applications on the "Private" area. You don't need to change anything:
pV:= Private new. win2D:= SystemWindow new. lf:= LayoutFrame new. lf leftFraction:0. lf rightFraction:1. lf topFraction:0. lf bottomFraction:1. win2D setLabel: 'PRIVATE'. win2D addMorph: pV fullFrame:lf. win2D openInWorldExtent: 350@500. pV requestInitialSpace.
CODE COMMENTS
Close the existent "Private" 2D window of the "main page". "Doit-izing" the script, it will be recreated atualized, having the new application + 3D window inside. Look:
Oops! There are a bug in the system (it's beta-time folks!) and sometimes the project is not loaded.
If this occurs:
We hope that, soon, this eventual bug will be fixed.
Like we said, the file HelloPrivate.001.pr is downloaded in the "Croquet Internet cache" - a little differently of the webobjects that are models ( .TEA files).
ATENTION: Remember that the web server needs to accept to transmit files having the extention: .pr. If you are having some problems (not with our project because our server accepts then), talk to your webserver manager about "mime types". Web servers not Windows can have some problems because for then: .pr is different from .PR etc.
The user can modify the size of the 3D window and the size of the 2D window, dragging it or using the button of "fullscreen mode", to have a better view of the application.
Like all is OK, now you do a "big save": close all the auxiliary windows, resize the "PRIVATE" etc., save the project and, finally, "save and quit".
When you open the Squeak-Croquet system in the future you will see the 3D window of the installed application in the "Private" space.
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE
