WooGLE - 0.74 (Final) + "alpha" Mac version

20 replies [Last post]
Joined: 06/19/2009

I've released v0.74 (Final) of WooGLE... PC and Linux folk... get it here

And done some work on a "Mac-friendly" version... calling that 0.75 (alpha)
Source available here

I've not been able to test it on a Mac, so hoping some folks out there will...
However I have tested it on a PC, using the "World of Goo for MAC" File structure and encryption.

I've stuck a whole load of diagnositic output in, just in case things go wrong..
But for anyone who tries it... here's what should happen....

1) Detect you are running on a MAC
Check the Main Window Title bar.. should say "World of Goo Level Editor [darwin]"
The "darwin" is what the python reference says it will give on a MAC.
Check that this is correct... if it displays "[somethingelse]" let me know what it shows an what OS you have.

2) locate the World of Goo Program.
It wants you to find ../World of Goo.app/Contents/MacOS/World of Goo
Providing you can find that file, it should then get the resource folder correct, and display a message about converting .png.binltl to .png
If possible, check the console text output before clicking OK... should read something like...

platform= darwin
_wog_path= D:/World of Goo.app/Contents/MacOS/World of Goo

3) It will convert all the .png.binltl to .png
There's over 1,500 files to do, so this can take a while.
You should see it running through the names of the files in the Status bar at the bottom... it's also outputing this to the console window.
When it's finished it will display "Conversion Complete. xxxx files processed" in the Status Bar.

4) It opens all the "Global" resource and xml files
Console window will show "XOR Decrypting {filename}"

Once that's complete... you should be able to use WooGLE "normally"...
try Editing an existing level.. see if it loads and displays OK.

5) Save and Play...?
I don't know if the Mac version of the game will allow you to play single levels.
I'm also not 100% that the current "process launch" routines will work on Mac.
But give it a go... let me know what happens.

Joined: 05/19/2010
Joined: 11/04/2008

I was going to give this a try for you, since I'm in the rare situation of having a Mac and no PC, but I get a 404 on the Mac source link.

-davidc

Joined: 06/19/2009

Hmm.. Odd. Puzzled
I've put it on the Woogle page.... http://goofans.com/download/utility/world-of-goo-level-editor#tabs

Let me know what you find.

Joined: 11/04/2008

TheBoss:WooGLE-075Mac-alpha2-src david$ ./launch.sh 
src/wogeditor.py:333: Warning: 'with' will become a reserved keyword in Python 2.6
  File "src/wogeditor.py", line 333
    with file( input_path, 'rb' ) as f:
            ^
SyntaxError: invalid syntax
TheBoss:WooGLE-075Mac-alpha2-src david$ python --version
Python 2.5.1

Joined: 06/19/2009

All true!
Python 2.6 was "current" when I started... so that's what I'm developing in.

Looks like 2.5 didn't have the "with" statement, but recognises it will be in a future version... so gives this warning whenever it encounters "with" in the code.

That usage of "with" is correct for 2.6, but 2.5 apparently doesn't know that.

"Simplest" solution is install Python 2.6 (if possible)

There are other ways I could do the file access, which would be 2.5 "compatible" but with is now "best practice" because it automatically deals with closing the file, even in the case of an exception.
The "old way" doesn't and you have to "handle" all that yourself... to avoid leaks.

Joined: 11/04/2008

This is the Python version that comes with Mac OS X (at least 10.5). That said, it looks like I'm going to have to install developer tools to install PyQt4 from source anyway...

Joined: 06/19/2009

I've found a possible alternative solution...

Looks like "with" was available in Python 2.5... but it's not a "native keyword" it's an importable statement.

Try this... add the folllowing line to wogeditor.py
Put it near the top, just before all the other import statements.

from __future__ import with_statement

I'd Copy N Paste, but if you don't.. those are 2 underscores before and after future

That should get rid of the warning, and allow the with to operate correctly in 2.5

Joined: 11/04/2008

Yep that seems to work, now just to get qt4 and pyqt4 installed...

Joined: 11/04/2008

OK! Progress is made. To get PyQt4 installed, I needed:

I'm now at the point of selecting the World of Goo executable.

Unfortunately you don't allow selection of the "World of Goo.app" - you want the user to select Contents/Mac OS/World of Goo from inside it. This isn't possible from the file selection dialog, since you can't "show contents" the app from there.

Selecting the app itself causes it to look in the wrong place higher up as a result - see below. Needs more validation here.

TheBoss:WooGLE-075Mac-alpha2-src david$ ./launch.sh 
platform= darwin
_wog_path= /Users/david/World of Goo woogle.app
resdir= /Users/Resources/game/res

Good news is that the GUI looks alright, and it has [darwin] in the title bar. Will need the above problem fixed to progress further though.

-davidc

Joined: 11/04/2008

I renamed my World of Goo.app to just World of Goo, so I could get inside it to progress further.

I think you may be doing the PNG conversion on the event dispatch thread (or whatever the Python equivalent is), as it locks up the GUI while it's doing that.

Once it gets past that though, the editor seems to function just fine.

In answer to your question, no it's not possible to launch a specific level in the Mac version. I confirmed this from the command line. You do have it launching the program correctly, it just doesn't take arguments.

This poses the problem of how to open the level for testing without installing it through GooTool. I suggest you may need to do a merge into chapter 1 in a similar manner to GooTool (but at a different location).

-davidc

Joined: 11/04/2008

Here's a screenshot of it running on the Mac. As you can see the application name is Python and it gets a rocket icon.

I suspect having to install developer tools and manually compile everything to get pyqt4 is going to be problematic for most users. I tried running it through py2app to see if that would help avoid having to install the full Qt4 SDK etc, but I got this error running the resulting app:

18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518] Traceback (most recent call last): 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]   File "/Users/david/Downloads/WooGLE-075Mac-alpha2-src/dist/wogeditor.app/Contents/Resources/__boot__.py", line 137, in <module> 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]     _run('wogeditor.py') 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]   File "/Users/david/Downloads/WooGLE-075Mac-alpha2-src/dist/wogeditor.app/Contents/Resources/__boot__.py", line 134, in _run 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]     execfile(path, globals(), globals()) 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]   File "/Users/david/Downloads/WooGLE-075Mac-alpha2-src/dist/wogeditor.app/Contents/Resources/wogeditor.py", line 29, in <module> 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]     import metaworld 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]   File "metaworld.pyc", line 27, in <module> 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]   File "PyQt4/QtCore.pyc", line 18, in <module> 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518]   File "PyQt4/QtCore.pyc", line 15, in __load 
18/07/2010 23:39:11 [0x0-0x7b57b5].org.pythonmac.unspecified.wogeditor[54518] ImportError: '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload/PyQt4/QtCore.so' not found 
18/07/2010 23:39:11 wogeditor[54518] wogeditor Error 
18/07/2010 23:39:11 wogeditor[54518] wogeditor Error
An unexpected error has occurred during execution of the main script
 
ImportError: '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload/PyQt4/QtCore.so' not found

I don't know enough about OS X to debug this further.

-davidc

Joined: 06/19/2009

Woohoo! Laughing out loud ... at least it "sort of" works.

Changing the "Change Dir" to look for / expect the .app won't be a problem.

The PNG conversion does take a while and is just a "hard loop". I really want it to be complete before the user gets to do anything else. But will look at adding a dialog and/or a progress bar or something.. just so it's OBVIOUS that it's busy doing something. Although it only does it when you change the directory, so for most folk it'll do it on "First run" and that'll be it.

Adding the "Test Level" into the game xml directly shouldn't be too tricky. And with a bit of "jiggery pokery" I ought to be able to test it using an "unpatched" PC install.

I agree completely that a self-contained distributable app would be the "ideal" solution...
to that end... I found these links which talk about solving the QtCore.so problem.
Looks like the "simple" solution (adding a line to __boot__.py) isn't 100%, but seems like it would be worth a shot.
http://www.rkblog.rk.edu.pl/w/p/building-mac-os-x-applications-py2app/
http://aralbalkan.com/1675

At worst though, a complete step-by-step.. "Install this, then this, then run these commands, then..." dummies guide to setting up the environment might "do".

I'll get on with modding the code, let me know if the links solve the QtCore problem.

Joined: 11/04/2008

OK, so, here is a zip with the changes - an icns format icon, and a new setup.py (which you could merge with your py2exe one as described here).

Build process is:

  • python setup.py py2app
  • cd (.app)
  • mv Contents/Resources/files.xml.xml Contents/MacOS/ (really it should be in the Resources directory, but your app_path() function returns the exe's dir).
  • edit Contents/Resources/__boot__.py, in function def _run(*scripts), add after imports this line:
    sys.path = [os.path.join(os.environ['RESOURCEPATH'], 'lib', 'python2.5', 'lib-dynload')] + sys.path
  • Remove huge debug libraries: find . -name *_debug* | xargs rm (halves the app size)
  • mv wogeditor.app "World of Goo Level Editor.app"

I believe the resulting app should now run on any Mac without having to install Qt4 since the libraries are packaged inside app/Framework. The resulting app is 48MB, mostly the Qt libraries. When you sort out the file chooser issue, I'll upload it to the woogle download page for someone with a stock Intel Mac to test out.

With the new icns icon and CFBundleDisplayName plist override, it now shows up with the correct icon and app name.

-davidc

Joined: 06/19/2009

OK, new "beta" source now available from the WooGLE page
http://goofans.com/download/utility/world-of-goo-level-editor

It now expects you to select World of Goo.app when you change dir
You may need to Change Dir first time you run the new one.
Scans for un-converted PNG.BINLTL every time it starts..
but only processes those files that don't already have a PNG version
Save and Play should (might) work.
Adds a button to Chapter 1, then launches the app
Combined Windows/Mac setup.py (in src folder)
Works fine on PC...
Dropped wogedit.icns into the images folder (was pathed to /Users/David....)
Omitted src/ from paths in the Mac bit(I think that's right given where setup.py is now)
"Draft" versions of readme-mac and 3rdparty-mac (but they need work)

Let's see how that goes...

Joined: 11/04/2008

OK that works - just with the setup.py inside src, you end up with the 'build' and 'dist' directories inside 'src' too, but no big deal.

Here's a new "make-woogle-mac.sh" script to automate it (note that this file must have Unix and not DOS line endings):

#!/bin/sh
rm -fr dist build
python setup.py py2app || exit 1
cd "dist/World of Goo Level Editor.app" || exit 1
mv Contents/Resources/files.xml.xml Contents/MacOS || exit 1
echo "--- Contents/Resources/__boot__.py
+++ Contents/Resources/__boot__.py
@@ -122,6 +122,7 @@
 def _run(*scripts):
     global __file__
     import os, sys, site
+    sys.path = [os.path.join(os.environ['RESOURCEPATH'], 'lib', 'python2.5', 'lib-dynload')] + sys.path
     sys.frozen = 'macosx_app'
     base = os.environ['RESOURCEPATH']
     site.addsitedir(base)
" | patch -p0 || exit 1
find . -name *_debug* | xargs rm
cd ..
ls -l

Also a change to the setup.py plist key:

           'plist': {'CFBundleDisplayName': 'World of Goo Level Editor',
                     'CFBundleName': 'World of Goo Level Editor'}

The "save and play" addition to chapter 1 is working fine.

-davidc

Joined: 11/04/2008

I've uploaded a zip to the woogle download page, so Mac users, please give it a whirl and see if it works. It shouldn't require you to download anything else.

-davidc

Joined: 11/04/2008

I just built and made a zip of 0.76 and noticed some odd behaviour. Copying it out of dist and running it works fine, but when I zip it and then unzip it, the resulting copy fails to run with "ImportError: No module named traceback".

This happens when zipping it both with command-line 'zip' and with the Mac built-in zipper. I wonder if it's something funky to do with resource forks?

09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] 'import site' failed; use -v for traceback
09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] Traceback (most recent call last):
09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] File "/Users/david/World of Goo Level Editor.app/Contents/Resources/__boot__.py", line 103, in
09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] _argv_emulation()
09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] File "/Users/david/World of Goo Level Editor.app/Contents/Resources/__boot__.py", line 101, in _argv_emulation
09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] _get_argvemulator().mainloop()
09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] File "/Users/david/World of Goo Level Editor.app/Contents/Resources/__boot__.py", line 7, in _get_argvemulator
09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] import traceback
09/08/2010 22:23:44 [0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752] ImportError: No module named traceback
09/08/2010 22:23:44 wogeditor[41752] wogeditor Error
09/08/2010 22:23:44 wogeditor[41752] wogeditor Error
An unexpected error has occurred during execution of the main script

ImportError: No module named traceback

09/08/2010 22:23:44 wogeditor[41752] wogeditor Error
An unexpected error has occurred during execution of the main script

ImportError: No module named traceback

09/08/2010 22:23:45 com.apple.launchd[16597] ([0x0-0x2dd2dd].org.pythonmac.unspecified.wogeditor[41752]) Exited with exit code: 255

-davidc

Joined: 06/19/2009

Hmmm... Sadly I don't have much experience with trouble-shooting python builds....
'cos I only started using it in April, and everything has worked just fine here! so far....
:prays: please don't jinx it... please don't jinx it Smile

let me get this straight...
You've built 0.76
If you just copy the .app from the dist folder to "somewhere else".. then run it... it works fine
But if you zip "it" (the .app? the entire contents of the dist folder? same thing?).. then unzip it "somewhere else"... then run it.. it produces the errors and "debug" above?

Joined: 11/04/2008

Yep! When it's been zipped and unzipped (either the .app or the dist containing the .app) it miraculously stops working. I guess I'll try making a dmg and see if that has the same problem.

Looking at it, 'traceback' seems to be used by the py2app wrapper code rather than WooGLE, so it's probably something I need to fix.

-davidc

Joined: 06/19/2009

Hum! Puzzled
I agree that the debug output looks like the problem is in __boot__.py, but not 100% sure that it is... might be that's what py2app uses to actual run WooGLE .. then without the "trackback" module it just appears that errors are coming from boot.py... not sure about that either though! Wink

However, the zip thing is VERY weird... the "most likely" thing I can think of is...
When you zip it.. it's not putting EVERYTHING in the zip file, or maybe not taking everything out when you unzip... so you're missing something (maybe lots of things)

Can you compare the contents (all files / paths etc) of the extracted zip with the original dist / .app
I suspect you'll find there's stuff missing / different.