[game-baker commit] r295 - in trunk/trunk: . GUI

0 views
Skip to first unread message

codesite...@google.com

unread,
Feb 17, 2009, 5:08:18 AM2/17/09
to game-ba...@googlegroups.com
Author: timwintle
Date: Tue Feb 17 02:06:26 2009
New Revision: 295

Modified:
trunk/trunk/CHANGELOG
trunk/trunk/GUI/gblayout.py
trunk/trunk/GUI/main_window_events.py

Log:

couple of bugs with the new gamescreen editor:

* Images are loaded for sprites (still not correct, but they are
displayed)
* pygame.font.init() is called on __init__ of window to allow for
multiple uses of the window

Modified: trunk/trunk/CHANGELOG
==============================================================================
--- trunk/trunk/CHANGELOG (original)
+++ trunk/trunk/CHANGELOG Tue Feb 17 02:06:26 2009
@@ -1,3 +1,4 @@
+Feb 17 Fixed reference to image for sprites in visual GameScreen
layout (TimWintle)
Feb 16 Issue 54 - Visual GameScreen layout. Very buggy, but
functional. (johngunderman)

Version 0.2.1 ============

Modified: trunk/trunk/GUI/gblayout.py
==============================================================================
--- trunk/trunk/GUI/gblayout.py (original)
+++ trunk/trunk/GUI/gblayout.py Tue Feb 17 02:06:26 2009
@@ -1,13 +1,12 @@
#!/usr/bin/python2.5


-import pygame, pygame.font, sys, time
+import pygame, pygame.font, sys, time, os
from pygame.locals import *

sys.path.append("../")
import game
pygame.init()
-pygame.font.init()

@@ -20,7 +19,9 @@
A graphical window, in which all else is displayed.
Initialized with a GameScreen object.
"""
- def __init__(self, gamescreen):
+ def __init__(self, game, gamescreen, path):
+ self.filepath = path
+ self.game = game
self.gamescreen = gamescreen
self.height = self.gamescreen.dimensions[1] + 15
self.width = self.gamescreen.dimensions[0]
@@ -32,6 +33,12 @@

self.background = pygame.Surface([self.width, self.height])
#make me a display
+ try:
+ # Have to do this here or we get errors the
+ # second time you open a window
+ pygame.font.init()
+ except: pass
+
pygame.display.set_mode([self.width, self.height])
pygame.display.set_caption('Game-Baker GameScreen Editor')
self.screen = pygame.display.get_surface()
@@ -43,7 +50,7 @@
"""Wraps each gameobject in the Element class"""
wrapped = []
for obj in objects:
- wrapped.append(Element(obj))
+ wrapped.append(Element(obj,main_wnd = self))
return wrapped

def save_layout(self):
@@ -113,10 +120,14 @@

class Element(object):
"""A wrapper for gameobjects to be placed in the Window class."""
- def __init__(self, gameobject):
+ def __init__(self, gameobject, main_wnd):
self.backup_go = gameobject
+
self.x = gameobject.x
self.y = gameobject.y
+
+ game = main_wnd.game
+ filepath = main_wnd.filepath

if gameobject.sprite is None:
#default height and width. Should be changed at some point.
@@ -125,9 +136,22 @@
self.image = pygame.Surface([self.width, self.height])
self.image.fill(111)
else:
- self.image =
pygame.image.load(gameobject.sprite.image_files[0]).convert()
- self.width = self.image.get_width()
- self.height = self.image.get_height()
+ sprite = game.sprites[gameobject.sprite]
+ spriteimage = sprite.imagefiles[0]
+ imagepath = os.path.join(filepath,spriteimage["filename"])
+
+ print imagepath
+
+ self.image = pygame.image.load(imagepath)
+ try:
+ # I'm getting an exception here because the video mode
hasn't been set
+ # (TimWintle)
+ self.image = self.image.convert()
+ except:
+ print "exception - video mode not set"
+
+ self.width = spriteimage["bottomright"][0] -
spriteimage["topleft"][0]
+ self.height = spriteimage["bottomright"][1] -
spriteimage["topleft"][1]


def move(self, x, y):

Modified: trunk/trunk/GUI/main_window_events.py
==============================================================================
--- trunk/trunk/GUI/main_window_events.py (original)
+++ trunk/trunk/GUI/main_window_events.py Tue Feb 17 02:06:26 2009
@@ -243,7 +243,9 @@
self.get_widget("wnd_Object").hide()

def open_layout_editor(self, widget=None):
- w = gblayout.Window(self.selectedgamescreen)
+ w = gblayout.Window(game = self.game, gamescreen =
self.selectedgamescreen, \
+ path = self.filepath)
+
self.selectedgamescreen.startobjects = w.run()


@@ -585,7 +587,9 @@
self.treeviewhelp.clear()
self.treeviewhelp.populate_from_game(self.game)
self.filename = filename
- os.chdir(os.path.split(filename)[0])
+ filepath = os.path.split(filename)[0]
+ self.filepath = filepath
+ os.chdir(filepath)
self.get_widget("wnd_main").set_title(self.game.title + " -
Game Baker")

def closegame(self,widget=None):

Reply all
Reply to author
Forward
0 new messages