Modified:
trunk/trunk/CHANGELOG
trunk/trunk/GUI/msgbox.py
trunk/trunk/gamebaker.py
trunk/trunk/runtime/__init__.py
trunk/trunk/runtime/script_objects.py
Log:
minor code cleaning and added fset to scriptGameObject.name
Modified: trunk/trunk/CHANGELOG
==============================================================================
--- trunk/trunk/CHANGELOG (original)
+++ trunk/trunk/CHANGELOG Sat Mar 7 08:49:58 2009
@@ -1,4 +1,6 @@
Mar 7 Added Syntax Highlighting (TimWintle)
+ Minor code clean ups (TimWintle)
+ Allow setting of name on gameobjects (TimWintle)
Mar 1 Updated Restaurant Demo (Kurt Woloch)
Feb 21 Added icon to the about dialog (TimWintle)
Changed file version to 1 and allowed importing of games
made in the old format. (TimWintle)
Modified: trunk/trunk/GUI/msgbox.py
==============================================================================
--- trunk/trunk/GUI/msgbox.py (original)
+++ trunk/trunk/GUI/msgbox.py Sat Mar 7 08:49:58 2009
@@ -27,9 +27,32 @@
self.run = self.msg.run
self.destroy = self.msg.destroy
+class gbDebugMsgbox(object):
+ def __init__(self, ex, error, workstate, event, modal=False, parent =
None, show_code = False):
+ buttons = (gtk.BUTTONS_CLOSE,gtk.BUTTONS_OK_CANCEL)[show_code]
+ self.msg = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
buttons=buttons, parent = None)
+
+ def set_focus(widget,msg):
+ pass
+
+ message = """<b>Exception:</b> %s \n<b>Error:</b> %s
\n<b>Event:</b>%s""" \
+ %(ex,error,workstate + ":" + event )
+
+ if show_code is True:
+ message = message + "\nShow Event?"
+
+ self.msg.set_markup(message)
+
+ if modal:
+ self.msg.set_modal(True)
+ self.msg.connect("focus-out-event", set_focus )
+
+ self.run = self.msg.run
+ self.destroy = self.msg.destroy
+
class gbConfirmMsgbox(object):
- def __init__(self,message,modal=False):
+ def __init__(self, message, modal=False):
self.msg =
gtk.MessageDialog(type=gtk.MESSAGE_WARNING,buttons=(gtk.BUTTONS_OK_CANCEL))
def set_focus(widget,msg):
@@ -46,7 +69,7 @@
class gbYesNoMsgbox(object):
- def __init__(self,message,modal=False):
+ def __init__(self, message, modal=False):
self.msg =
gtk.MessageDialog(type=gtk.MESSAGE_WARNING,buttons=(gtk.BUTTONS_YES_NO))
def set_focus(widget,msg):
Modified: trunk/trunk/gamebaker.py
==============================================================================
--- trunk/trunk/gamebaker.py (original)
+++ trunk/trunk/gamebaker.py Sat Mar 7 08:49:58 2009
@@ -214,7 +214,7 @@
"""Runs a game"""
path = self.filename
path = os.path.join(os.path.split(path)[:-1])
- debug(self.game,path[0])
+ debug(self.game,path[0],self)
#runtime.run_game(self.game)
def import_external_sprite(self,filename):
@@ -234,13 +234,14 @@
-def debug(game,path_to_game):
+def debug(game,path_to_game,gbWindow=None):
print sys.path
if not path_to_game in sys.path:
sys.path.append(path_to_game)
- try:
- try:
- runtime.run_game(game)
+ #try:
+ #try:
+ runtime.run_game(game)
+ """
except runtime.gb_runtime_exception, inst:
print inst
@@ -249,15 +250,24 @@
workstate = inst.workstate
if workstate is None:
workstate = ""
- errormessage = """<b>Exception:</b> %s \n<b>Error:</b> %s
\n<b>Event:</b>%s""" \
- %(inst.log,orig_str,workstate + ":" +
GUI.constants.event_names.get(inst.event,"Unknown") )
- msg = GUI.msgbox.gbErrorMsgbox(errormessage, modal=True)
- msg.run()
+ msg = GUI.msgbox.gbDebugMsgbox( inst.log,orig_str,workstate, \
+
GUI.constants.event_names.get(inst.event,"Unknown"), modal = True,
+ show_code = False)#(gbWindow
is not None) ) <-not working yet
+ show_ws = msg.run()
msg.destroy()
+ if show_ws == gtk.RESPONSE_OK:
+ # Try to show the worstate
+ try:
+ #TODO
+ pass
+ except:
+ pass
except Exception, inst:
print inst,str(inst)
+
+ """
if __name__ == "__main__":
Modified: trunk/trunk/runtime/__init__.py
==============================================================================
--- trunk/trunk/runtime/__init__.py (original)
+++ trunk/trunk/runtime/__init__.py Sat Mar 7 08:49:58 2009
@@ -167,10 +167,11 @@
pygame.quit()
raise
- except Exception, inst:
+ """except Exception, inst:
print inst
pygame.quit()
raise gb_runtime_exception(log=str(inst),orig_except=inst)
+ """
pygame.quit()
@@ -416,6 +417,11 @@
if len(l) > 0:
return l[0]
# Should raise an appropriate exception here
+
+ def set_game_object_name(self,gameobject,new_name):
+ old_name = self.get_game_object_name(gameobject)
+ self.gameobjects[new_name] = self.gameobjects[old_name]
+ del self.gameobjects[old_name]
Modified: trunk/trunk/runtime/script_objects.py
==============================================================================
--- trunk/trunk/runtime/script_objects.py (original)
+++ trunk/trunk/runtime/script_objects.py Sat Mar 7 08:49:58 2009
@@ -24,7 +24,7 @@
"""
class scriptobject(object):
- def __init__():
+ def __init__(self):
pass
@@ -311,7 +311,9 @@
self.path = script_path(self)
self.__gameobject = go
- name = property(fget=lambda x:
x.gamescreenobj.get_game_object_name(x.__gameobject))
+ name = property( \
+ fget=lambda x:
x.gamescreenobj.get_game_object_name(x.__gameobject),
+ fset=lambda x,new_name:
x.gamescreenobj.set_game_object_name(x.__gameobject,new_name))
def move_velocity(self):