From: <ch...@us...> - 2009-02-22 10:59:53
|
Revision: 278 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=278&view=rev Author: chozone Date: 2009-02-22 10:59:48 +0000 (Sun, 22 Feb 2009) Log Message: ----------- You will now see an image when you have multiple lines in your input. Modified Paths: -------------- trunk/VP/modules/input.py Added Paths: ----------- trunk/VP/images/Input/ trunk/VP/images/Input/multiple.png Added: trunk/VP/images/Input/multiple.png =================================================================== (Binary files differ) Property changes on: trunk/VP/images/Input/multiple.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/VP/modules/input.py =================================================================== --- trunk/VP/modules/input.py 2009-02-10 19:17:47 UTC (rev 277) +++ trunk/VP/modules/input.py 2009-02-22 10:59:48 UTC (rev 278) @@ -14,6 +14,7 @@ fontEndObj = pygame.font.Font(getRealDir('fonts', 'Bitstream Vera Sans.ttf'), 15) fontEndObj.set_bold(True) self.textEnd = fontEndObj.render('|', True, (0,130,21)) + self.multipleLines = loadImage('images', 'Input', 'multiple.png')[0] self.inputText = '' @@ -109,16 +110,21 @@ textSurf = self.fontObj.render(visibleLine , True, (0,0,0)) textLength = textSurf.get_width() - - if textLength < 350: + textWidth = 350 if len(self.inputText.split('\n')) == 1 else 340 #So we have 10px more for the icon, when there are multiple lines + + if textLength < textWidth: pos = 0 cursorPos = textLength else: - pos = textLength - 350 - cursorPos = 350 + pos = textLength - textWidth + cursorPos = textWidth - area = (pos, 0, 350, textSurf.get_height()) + area = (pos, 0, textWidth, textSurf.get_height()) + if len(self.inputText.split('\n'))>1: + #Multiple lines, let's show that cool icon! + self.surf.blit(self.multipleLines, (355, 4)) + self.surf.blit(textSurf, (12,4), area) self.surf.blit(self.textEnd, (10+cursorPos, 2)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Blu...@us...> - 2009-03-23 21:54:47
|
Revision: 290 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=290&view=rev Author: BlueWolf_ Date: 2009-03-23 21:54:44 +0000 (Mon, 23 Mar 2009) Log Message: ----------- Updated todo and fixed a bug in forceUpdate with threading Modified Paths: -------------- trunk/VP/TODO trunk/VP/interface.py Modified: trunk/VP/TODO =================================================================== --- trunk/VP/TODO 2009-03-23 21:50:06 UTC (rev 289) +++ trunk/VP/TODO 2009-03-23 21:54:44 UTC (rev 290) @@ -22,14 +22,9 @@ Playground * Creating the avatars (the images) -* Finishing up Static avatar (Z coords) (assigned to chozone) -* Finishing up multidir avatar (Z coords) (assigned to chozone) -* Finishing up multiparts avatar (Z coords) (assigned to chozone) -* Finishing up multidir_parts avatar (Z coords) (assigned to chozone) * Walls * Smooth walking * Jumping -* Running (assigned to chozone) * Walking/running bit slower when walking diagonally (assigned to chozone) * Chat balloons (assigned to K-4U) Modified: trunk/VP/interface.py =================================================================== --- trunk/VP/interface.py 2009-03-23 21:50:06 UTC (rev 289) +++ trunk/VP/interface.py 2009-03-23 21:54:44 UTC (rev 290) @@ -19,6 +19,7 @@ #4 - Menu/tooltips self.lock = threading.Lock() + self.updateLock = threading.Lock() #Lock for forceUpdate self.needUpdate = [] @@ -196,6 +197,8 @@ """This will the interface use to actually update the screen""" if self.needUpdate != []: + self.updateLock.acquire() + #print 'Interface.forceUpdate' + str(self.needUpdate) if self.needUpdate == [None]: #Fullscreen update, yeah! @@ -207,6 +210,8 @@ for module in self.openModules[prio]: module.update(self.screen, rect_list) pygame.display.update(rect_list) + + self.updateLock.release() #Change the cursor, if needed if self.cursor != self.cursorNew: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ch...@us...> - 2009-05-01 15:27:32
|
Revision: 295 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=295&view=rev Author: chozone Date: 2009-05-01 15:27:26 +0000 (Fri, 01 May 2009) Log Message: ----------- Changed module system, now it works in python 2.6+. Had to rename the VP/modules/playground dir to VP/modules/playgroundObj, because there was a conflict between that dir and VP/modules/playground.py. Modified Paths: -------------- trunk/VP/interface.py trunk/VP/modules/playground.py Added Paths: ----------- trunk/VP/modules/__init__.py trunk/VP/modules/playgroundObj/ trunk/VP/modules/playgroundObj/__init__.py Removed Paths: ------------- trunk/VP/modules/playground/ Modified: trunk/VP/interface.py =================================================================== --- trunk/VP/interface.py 2009-03-31 20:46:57 UTC (rev 294) +++ trunk/VP/interface.py 2009-05-01 15:27:26 UTC (rev 295) @@ -40,9 +40,9 @@ #Load all modules in our memory self.modules = {} for module in os.listdir(getRealDir('modules')): - if module[-3:] == '.py': - realName = os.path.join('modules', module[:-3]) - self.modules[module[:-3]] = __import__(realName).Module + if module[-3:] == '.py' and not module.startswith('__'): + realName = '.'.join(('modules', module[:-3])) + self.modules[module[:-3]] = __import__(realName, fromlist=module[:-3]).Module @@ -82,7 +82,7 @@ for i, module in enumerate(self.openModules[prio]): if type(name) == str: - if module.__module__ == 'modules/' + name: + if module.__module__ == 'modules.' + name: module.close() del self.openModules[prio][i] print 'Interface.closeModule: Close', name, 'at', prio, '-', i @@ -129,7 +129,7 @@ #Search within the given priorities for prio in prioList: for i, module in enumerate(self.openModules[prio]): - if module.__module__ == 'modules/' + name: + if module.__module__ == 'modules.' + name: return True return False @@ -148,7 +148,7 @@ for prio in prioList: for i, module in enumerate(self.openModules[prio]): if type(name) == str: - if module.__module__ == 'modules/' + name: + if module.__module__ == 'modules.' + name: if len(self.openModules[prio])-1 != i: self.openModules[prio].append(self.openModules[prio].pop(i)) self.update(blit = True) @@ -270,7 +270,7 @@ self.lock.acquire() for prio in range(5): for module in self.openModules[prio]: - if name == '' or module.__module__ == 'modules/' + name: + if name == '' or module.__module__ == 'modules.' + name: module.call(*arg) self.forceUpdate() Added: trunk/VP/modules/__init__.py =================================================================== --- trunk/VP/modules/__init__.py (rev 0) +++ trunk/VP/modules/__init__.py 2009-05-01 15:27:26 UTC (rev 295) @@ -0,0 +1 @@ +# Dummy file, not a module. Do NOT remove this file! Modified: trunk/VP/modules/playground.py =================================================================== --- trunk/VP/modules/playground.py 2009-03-31 20:46:57 UTC (rev 294) +++ trunk/VP/modules/playground.py 2009-05-01 15:27:26 UTC (rev 295) @@ -25,10 +25,10 @@ #Loading all our objects-modules (kinda like interface.py) self.modObjects = {} - for object in os.listdir(getRealDir('modules','playground')): - if object[-3:] == '.py': - realName = os.path.join('modules', 'playground', object[:-3]) - self.modObjects[object[:-3]] = __import__(realName).Object + for object in os.listdir(getRealDir('modules','playgroundObj')): + if object[-3:] == '.py' and not object.startswith('__'): + realName = '.'.join(('modules', 'playgroundObj', object[:-3])) + self.modObjects[object[:-3]] = __import__(realName, fromlist=object[:-3]).Object self.surf = pygame.Surface((726, 402)) Property changes on: trunk/VP/modules/playgroundObj ___________________________________________________________________ Added: svn:mergeinfo + Added: trunk/VP/modules/playgroundObj/__init__.py =================================================================== --- trunk/VP/modules/playgroundObj/__init__.py (rev 0) +++ trunk/VP/modules/playgroundObj/__init__.py 2009-05-01 15:27:26 UTC (rev 295) @@ -0,0 +1 @@ +# Dummy file, not a playground-module. Do NOT remove this file! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ch...@us...> - 2009-05-01 22:22:13
|
Revision: 296 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=296&view=rev Author: chozone Date: 2009-05-01 22:22:11 +0000 (Fri, 01 May 2009) Log Message: ----------- With the following modifications, VP now works on windows: -event handler had to be in main thread, so swapped event loop, and Reponse loop. (is the Response loop still needed?) -notify.py now works with more than one program(not platform-dependent!). Also added support for Snarl. -on windows, clipboard now works, and had to replace all chr(0)'s with '', because... well, it's windows... Modified Paths: -------------- trunk/VP/TODO trunk/VP/VP.py trunk/VP/modules/input.py trunk/VP/notify.py Modified: trunk/VP/TODO =================================================================== --- trunk/VP/TODO 2009-05-01 15:27:26 UTC (rev 295) +++ trunk/VP/TODO 2009-05-01 22:22:11 UTC (rev 296) @@ -11,9 +11,16 @@ Chat * Making the scroll button (assigned to BlueWolf_) + Help +* Creating the help system (like http://dl.getdropbox.com/u/343509/help1.png) + Info(bar) * Creating the Info bar with information like: Current ground, user(?), money... + + Input +* Making special commands in chat +* Making that 'auto chat status' thingy (when you say something like 'brb', it will change your status to 'away') Menu * Creating checkitems (assigned to BlueWolf_) @@ -22,7 +29,7 @@ Playground (see VP-Grounds branche) * Creating the avatars (the images) -* Walls (assigned to chozone) +* Walls (assigned to chozone) on hold, we need jumping, before we can create/test this any further * Smooth walking * Jumping (will be assigned to BlueWolf_, or someone else really wants to do this...?) * Walking/running bit slower when walking diagonally (assigned to chozone) Modified: trunk/VP/VP.py =================================================================== --- trunk/VP/VP.py 2009-05-01 15:27:26 UTC (rev 295) +++ trunk/VP/VP.py 2009-05-01 22:22:11 UTC (rev 296) @@ -61,27 +61,22 @@ conf['misc']['time_after_idle'] = int(conf['misc'].get('time_after_idle', 0)) #in mins, 0 = off, later this 5? -class Events(threading.Thread): +class ResponseLoop(threading.Thread): def __init__(self, share): self.sh = share threading.Thread.__init__(self) def run(self): while 1: - resp = pygame.event.wait() - if resp.type == QUIT: - self.sh['response'].put(('Exit',)) + #Some wacky workaround here. + #Without timeout, the Queue will not respond to KeyboardInterrupts. + #This is a timeout of year. Think that will be enough :-) + resp = share['response'].get(True, 31536000) + print resp + + if resp[0] == 'Exit': + pygame.event.post(pygame.event.Event(QUIT)) return - - elif resp.type == USEREVENT: #Pinger - self.sh['Connection'].ping() - - elif resp.type == ACTIVEEVENT: - if resp.state == 2: #focus - self.sh['focus'] = resp.gain - - else: - self.sh['Interface'].event(resp, lock=True) @@ -116,23 +111,29 @@ share['Sounds'].start() share['Brains'].start() +#Start Response-loop in thread +respLoop = ResponseLoop(share) +respLoop.start() -#Starting our event-catcher -events = Events(share) -events.start() - #Entering our main-loop. Yeah! try: while 1: - #Some wacky workaround here. - #Without timeout, the Queue will not response to KeyboardInterrupts. - #This is a timeout of year. Think that will be enough :-) - resp = response.get(True, 31536000) + resp = pygame.event.wait() - if resp[0] == 'Exit': - share['conf'].write() - exit() + if resp.type == QUIT: + share['conf'].write() + exit() + + elif resp.type == USEREVENT: #Pinger + share['Connection'].ping() + + elif resp.type == ACTIVEEVENT: + if resp.state == 2: #focus + share['focus'] = resp.gain + + else: + share['Interface'].event(resp, lock=True) except KeyboardInterrupt: print Modified: trunk/VP/modules/input.py =================================================================== --- trunk/VP/modules/input.py 2009-05-01 15:27:26 UTC (rev 295) +++ trunk/VP/modules/input.py 2009-05-01 22:22:11 UTC (rev 296) @@ -39,9 +39,12 @@ else: #Just an enter if self.inputText != '': - text = self.inputText.encode('utf-8') - text = text.strip() - self.sh['Brains'].chatSend(text) + if self.inputText == '//exit': + self.sh['response'].put(('Exit',)) + else: + text = self.inputText.encode('utf-8') + text = text.strip() + self.sh['Brains'].chatSend(text) self.inputText = '' self.blit() @@ -56,9 +59,17 @@ else: #Control key pressed (and no backspace....) if ev.key == K_v: #Ctrl+V, paste clipboard - text = pygame.scrap.get('UTF8_STRING') - text = unicode(text) + if sys.platform == 'win32': + text = pygame.scrap.get('text/plain;charset=utf-8') + else: + text = pygame.scrap.get('UTF8_STRING') + + + if text: + text=text.replace(chr(0), '') + text = unicode(text) + #Check if we have to shorten, and maybe shorten #the text so it doesn't raise a 'too large' error. if self.fontObj.size(text)[0] > 16383: Modified: trunk/VP/notify.py =================================================================== --- trunk/VP/notify.py 2009-05-01 15:27:26 UTC (rev 295) +++ trunk/VP/notify.py 2009-05-01 22:22:11 UTC (rev 296) @@ -1,9 +1,36 @@ -import pynotify, re from functions import getRealDir -pynotify.init("Virtual Playground") + +method = None +print 'Looking for notify program...' + +#pynotify +try: + import pynotify +except ImportError: + print 'Not found: pynotify' +else: + import re + pynotify.init("Virtual Playground") + + print 'Found pynotify!' + method = 'pynotify' + +if not method: + #snarl + try: + import PySnarl + except ImportError: + print 'Not found: snarl' + else: + print 'Found snarl!' + method = 'snarl' + +if not method: print 'No notify program found!' + + def popup(caption,msg, img="", timeout=5000, urgency="normal"): - """popup(caption, message, image="", timeout=5000, urgency="normal) + """popup(caption, message, image="", timeout=5000, urgency="normal") Show a popup on screen. @@ -14,28 +41,36 @@ Urgency: low, normal, high """ - #Don't make libnotify crash by alien characters - msg=msg.decode('utf-8') + if method=='snarl': + id = PySnarl.snShowMessage( title = caption, + text = msg, + timeout = timeout/1000, + iconPath = getRealDir('images','popup',img)) - #Clickable urls - msg=re.sub('([^:]+://[^.]+\.[^ ]+)', '<a href="\\1">\\1</a>', msg) + elif method=='pynotify': - #Create it - notif=pynotify.Notification(caption,\ - msg,\ - getRealDir('images','popup',img)) - - #How long should we keep it on the screen? - notif.set_timeout(timeout) - - #Urgency - if urgency=="low": - notif.set_urgency(pynotify.URGENCY_LOW) - elif urgency=="high" or urgency=="critical": - notif.set_urgency(pynotify.URGENCY_CRITICAL) - else: - notif.set_urgency(pynotify.URGENCY_NORMAL) - - #Show it(+error catcher thingy) - if not notif.show(): - print "Failed to show notification" + #Don't make libnotify crash by alien characters + msg=msg.decode('utf-8') + + #Clickable urls + msg=re.sub('([^:]+://[^.]+\.[^ ]+)', '<a href="\\1">\\1</a>', msg) + + #Create it + notif=pynotify.Notification(caption, + msg, + getRealDir('images','popup',img)) + + #How long should we keep it on the screen? + notif.set_timeout(timeout) + + #Urgency + if urgency=="low": + notif.set_urgency(pynotify.URGENCY_LOW) + elif urgency=="high" or urgency=="critical": + notif.set_urgency(pynotify.URGENCY_CRITICAL) + else: + notif.set_urgency(pynotify.URGENCY_NORMAL) + + #Show it(+error catcher thingy) + if not notif.show(): + print "Failed to show notification" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ch...@us...> - 2009-05-02 15:19:39
|
Revision: 297 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=297&view=rev Author: chozone Date: 2009-05-02 15:19:34 +0000 (Sat, 02 May 2009) Log Message: ----------- Made some basic commands for the input (like //exit). And now, the auto chat status thing works (like when you say 'brb', it will change your status to away). Modified Paths: -------------- trunk/VP/TODO trunk/VP/VP.py trunk/VP/lang/en.lang trunk/VP/lang/nl.lang trunk/VP/modules/input.py trunk/VP/modules/settings.py Modified: trunk/VP/TODO =================================================================== --- trunk/VP/TODO 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/TODO 2009-05-02 15:19:34 UTC (rev 297) @@ -17,10 +17,6 @@ Info(bar) * Creating the Info bar with information like: Current ground, user(?), money... - - Input -* Making special commands in chat -* Making that 'auto chat status' thingy (when you say something like 'brb', it will change your status to 'away') Menu * Creating checkitems (assigned to BlueWolf_) Modified: trunk/VP/VP.py =================================================================== --- trunk/VP/VP.py 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/VP.py 2009-05-02 15:19:34 UTC (rev 297) @@ -45,9 +45,9 @@ #chat auto-states if not 'chat' in conf: conf['chat'] = {} - conf['chat']['auto_states_enabled'] = conf['chat'].get('auto_states_enabled','False') #Later this True? + conf['chat']['auto_states_enabled'] = conf['chat'].get('auto_states_enabled','True') conf['chat']['auto_states_online'] = conf['chat'].get('auto_states_online','(b|back)\Z') - conf['chat']['auto_states_busy'] = conf['chat'].get('auto_states_busy','(phone|dnd)((\W.*)\Z|\Z)') + conf['chat']['auto_states_busy'] = conf['chat'].get('auto_states_busy','(dnd)((\W.*)\Z|\Z)') conf['chat']['auto_states_away'] = conf['chat'].get('auto_states_away','(brb|afk)((\W.*)\Z|\Z)') #animations @@ -72,7 +72,6 @@ #Without timeout, the Queue will not respond to KeyboardInterrupts. #This is a timeout of year. Think that will be enough :-) resp = share['response'].get(True, 31536000) - print resp if resp[0] == 'Exit': pygame.event.post(pygame.event.Event(QUIT)) Modified: trunk/VP/lang/en.lang =================================================================== --- trunk/VP/lang/en.lang 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/lang/en.lang 2009-05-02 15:19:34 UTC (rev 297) @@ -50,7 +50,7 @@ [[autostatechangedefault]] online = (b|back)\Z -busy = (phone|dnd)((\W.*)\Z|\Z) +busy = (dnd)((\W.*)\Z|\Z) away = (brb|afk)((\W.*)\Z|\Z) Modified: trunk/VP/lang/nl.lang =================================================================== --- trunk/VP/lang/nl.lang 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/lang/nl.lang 2009-05-02 15:19:34 UTC (rev 297) @@ -50,7 +50,7 @@ [[autostatechangedefault]] online = (b|back|biw)\Z -busy = (phone|dnd)((\W.*)\Z|\Z) +busy = (dnd)((\W.*)\Z|\Z) away = (brb|afk|bzt)((\W.*)\Z|\Z) Modified: trunk/VP/modules/input.py =================================================================== --- trunk/VP/modules/input.py 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/modules/input.py 2009-05-02 15:19:34 UTC (rev 297) @@ -1,5 +1,5 @@ from functions import * -import time +import time, re class Module(): def __init__(self, share, *arg): @@ -39,9 +39,8 @@ else: #Just an enter if self.inputText != '': - if self.inputText == '//exit': - self.sh['response'].put(('Exit',)) - else: + textToSend=self.checkChat() + if textToSend: text = self.inputText.encode('utf-8') text = text.strip() self.sh['Brains'].chatSend(text) @@ -141,3 +140,51 @@ interface.update([179,471,370,29]) + + + def checkChat(self): + """ + Handles all commands that are in the chat. + Is called when user presses the enter key in the Input. + The message that will be send to the server is what this function returns. + """ + t=self.inputText + c=t[2:] if len(t)>=2 and t.startswith('//') else '' + + if c == 'exit' or c == 'quit': + self.sh['response'].put(('Exit',)) + elif c == 'time' or c == 'date' or c == 'datetime': + return time.ctime() + elif c.startswith('stat ') or c.startswith('status '): + t=t.replace('//status ', '') + t=t.replace('//stat ', '') + if t == 'online' or t == 'busy' or t == 'away': + user=self.sh['conf']['account']['user'] + curStatus=self.sh['users'][user]['State'] + + if t != curStatus: + self.sh['Brains'].setStatus(t) + else: + return self.inputText + elif c == 'online' or c == 'busy' or c == 'away': + user=self.sh['conf']['account']['user'] + curStatus=self.sh['users'][user]['State'] + if c != curStatus: + self.sh['Brains'].setStatus(c) + else: + #Maybe... it is part of that stupid auto chat status thingy? + conf=self.sh['conf']['chat'] + print conf + if conf['auto_states_enabled']=='True': + user=self.sh['conf']['account']['user'] + curStatus=self.sh['users'][user]['State'] + + stat=None + if re.match(conf['auto_states_online'], t): stat='online' + if re.match(conf['auto_states_busy'], t): stat='busy' + if re.match(conf['auto_states_away'], t): stat='away' + + if stat and stat != curStatus: + self.sh['Brains'].setStatus(stat) + + return self.inputText Modified: trunk/VP/modules/settings.py =================================================================== --- trunk/VP/modules/settings.py 2009-05-01 22:22:11 UTC (rev 296) +++ trunk/VP/modules/settings.py 2009-05-02 15:19:34 UTC (rev 297) @@ -117,8 +117,7 @@ gui.Label(position = (15,80), parent = self.tab_misc, text = self.lang('misc','autochangestatus'))#section caption #DISABLED self.as_time=gui.CheckBox(position = self.tab_misc.nextPosition(5), parent = self.tab_misc, text = self.lang('misc','afterxmin'), value=conf['misc']['time_after_idle'],enabled=False) - #DISABLED - self.as_chat=gui.CheckBox(position = self.tab_misc.nextPosition(2), parent = self.tab_misc, text = self.lang('misc','chat'), value=conf['chat']['auto_states_enabled'],enabled=False) + self.as_chat=gui.CheckBox(position = self.tab_misc.nextPosition(2), parent = self.tab_misc, text = self.lang('misc','chat'), value=conf['chat']['auto_states_enabled']) #Create a special font style for our button labelStyleCopy = gui.defaultLabelStyle.copy() @@ -280,12 +279,6 @@ when the user click the 'reset chat states' button. Updates all images""" - #standard regexes - #now in lang files - #sonline="(b|back)\Z" - #sbusy="(phone|dnd)((\W.*)\Z|\Z)" - #saway="(brb|afk)((\W.*)\Z|\Z)" - #save in the local dict conf = self.sh['conf'] conf['chat']['auto_states_online'] = self.lang('autostatechangedefault','online') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |