From e082379433ad6245c9566ea81d3eb373e42d04eb Mon Sep 17 00:00:00 2001 From: Le_dahut Date: Thu, 12 Jun 2014 20:32:05 +0200 Subject: [PATCH] -Correction du bogue qui empeche le lien entre plusieurs mondes -Centrage du nom des niveaux -Positionnement du point chaud des curseurs. --- WireChem.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/WireChem.py b/WireChem.py index 41c48b8..c1cd621 100644 --- a/WireChem.py +++ b/WireChem.py @@ -189,12 +189,12 @@ class atext(object): self.text=text self.color=color self.document = pyglet.text.document.UnformattedDocument(text) - self.document.set_style(0, len(self.document.text),dict(font_name=font,font_size=size,color=color,background_color=(200, 200, 200,0))) + self.document.set_style(0, len(self.document.text),dict(font_name=font,font_size=size,color=color,align="center",background_color=(200, 200, 200,0))) font = self.document.get_font() height = font.ascent - font.descent self.window=window - self.layout = pyglet.text.layout.IncrementalTextLayout(self.document, width, height, multiline=False, batch=self.window.batch, group=self.window.p3) - self.layout.register_event_type('self.on_layout_update') + self.layout = pyglet.text.layout.IncrementalTextLayout(self.document, width, height, multiline=True, batch=self.window.batch, group=self.window.p3) + self.layout.document.register_event_type('self.on_insert_text') self.caret = pyglet.text.caret.Caret(self.layout) self.caret.visible = False self.layout.x = self.x @@ -208,10 +208,10 @@ class atext(object): self.layout.document.set_style(0, len(self.layout.document.text),dict(color=self.color)) self.layout.end_update() - def on_layout_update(self): - print "**************************" + def on_insert_text(self,start, text): + print "*********************" if self.loaded!='': - eval(self.loaded+"="+self.text) + exec(self.loaded+"='"+self.text+"p'") def hit_test(self, x, y): return (0 < x - self.layout.x < self.layout.width and 0 < y - self.layout.y < self.layout.height) @@ -317,7 +317,7 @@ class abutton(object): name=self.name.split('_') if len(name)>1 and hasattr(self.window, "on_mouse_"+state['event']+"_"+name[0]) and callable(eval("self.window.on_mouse_"+state['event']+"_"+name[0])): eval("self.window.on_mouse_"+state['event']+"_"+name[0]+"("+str(name[1])+","+str(state)+")") - if debug>0: print state,self.name + #if debug>0: print state,self.name if hasattr(self.window, "on_mouse_"+state['event']+"_"+self.name) and callable(eval("self.window.on_mouse_"+state['event']+"_"+self.name)): if self.typeof=='multicon': self.index+=1 @@ -325,7 +325,7 @@ class abutton(object): self.index=0 self.update(0) eval("self.window.on_mouse_"+state['event']+"_"+self.name+"("+str(state)+")") - if debug>0: print state,self.name + #if debug>0: print state,self.name def on_mouse_press(self, x, y, button, modifiers): if x>self.x and y>self.y and x1024-20 and world+1