def run(self): format = TextFormat() font = pygame.font.Font(None, format.size) bg = pygame.Surface((560, 30)) while self.running: time.sleep(2) users = self.talk("get:userlist") if users == False: return self.users = users.split(";;") users = users.replace(";;", ", ") print self.users print users text = font.render("> %s" % users, 1, hex2rgb(format.color)) textpos = text.get_rect() bg.fill(hex2rgb(Layout().background)) bg.blit(text, (0,0)) sf.display_surface(bg, (48, 610)) pygame.display.update((48, 610, 560, 30))
def draw(self, time): self.bg.fill(hex2rgb(Layout().Question.background)) format = TextFormat(None, 46, None) font = pygame.font.Font(None, format.size) text = font.render("%i sec" % time, 1, hex2rgb(format.color)) self.bg.blit(text, (0,0)) sf.display_surface(self.bg, (150, 440)) pygame.display.update()
def display_catname(self): bg = pygame.Surface((300, 60)) bg.fill(hex2rgb(Layout().Question.background)) format = TextFormat(None, 40) font = pygame.font.Font(None, format.size) text = font.render("Category: %s" % self.cat_name, 1, hex2rgb(format.color)) bg.blit(text, (0,0)) sf.display_surface(bg, (350, 190)) pygame.display.update()
def reset_points(self): self.found_straight = 0 self.straight_count = 0 self.icon_left = 0 self.bg_icons.fill(hex2rgb(Layout().Toolbar.background)) self.bg_icons_straight.fill(hex2rgb(Layout().Toolbar.background)) sf.display_surface(self.bg_icons, (540, 10), "toolbar") sf.display_surface(self.bg_icons_straight, (538, 50), "toolbar") sf.refresh()
def display_icon(self, icon_name): if icon_name == "found": self.found_straight += 1 if self.found_straight == 5: # Found Straight 5! self.bg_icons.fill(hex2rgb(Layout().Toolbar.background)) sf.display_surface(self.bg_icons, (540, 10), "toolbar") self.add_straight() self.icon_left = 0 self.found_straight = 1 fn = self.imgfn_found[self.img_found_count % len(self.imgfn_found)] self.img_found_count += 1 elif icon_name == "not-found": self.found_straight = 0 fn = self.imgfn_notfound[self.img_notfound_count % len(self.imgfn_notfound)] self.img_notfound_count += 1 img, img_rect = sf.image_load("images/%s" % fn) self.bg_icons.blit(img, (self.icon_left, 0)) sf.display_surface(self.bg_icons, (540, 10), "toolbar") sf.refresh() self.icon_left += img_rect[2] + 4
def clickOnMake(): global sf sf.display_line(0, True) sf.display_line(0, False) bg_icons = pygame.Surface((500, 32)) bg_icons.fill(hex2rgb(Layout().Toolbar.background)) sf.display_surface(bg_icons, (540, 10), "toolbar") sf.display_surface(bg_icons, (538, 50), "toolbar") sf.clear_text_items() # Select Quiz cat_id = -1 print 'ask_category', cat_id ask_category(cat_id)
def set_category(self, param): cat_id = int(param) self.category = cat_id cat_name = 'All' if cat_id > 0: q = "SELECT text FROM categories WHERE cat_id=%i AND lang_id=%s" % (cat_id, __SERVICES__.locale.lang_id) res = __SERVICES__.db.query(q) print res cat_name = res[0][0] # self.Spawner.master_set_status(u"cat:%s" % cat_name) bg = pygame.Surface((360, 30)) bg.fill(hex2rgb(Layout().background)) format = TextFormat() font = pygame.font.Font(None, format.size) text = font.render("%s" % cat_name, 1, hex2rgb(format.color)) bg.blit(text, (0,0)) sf.display_surface(bg, (480, 115)) pygame.display.update()
def update_status(self, params): self.status = params print "STATUS UPDATE:",params if params == False or len(params) == 0 or params == None or params == "None": self.close() return if self.connected == False: self.connection_ok() n = params.split(";;") users = n[1].replace(";", ", ") text = self.font.render("> %s" % users, 1, hex2rgb(self.format.color)) textpos = text.get_rect() self.bg.fill(hex2rgb(Layout().background)) self.bg.blit(text, (0,0)) sf.display_surface(self.bg, (48, 610)) pygame.display.update((48, 610, 560, 30)) print params
def nonet_function(self): print "client net aborted, quitting MultiPlayer-Client" self.running = False if self.waittext_id != None: sf.del_text_item(self.waittext_id) if self.textid_connectedto != None: sf.del_text_item(self.textid_connectedto) sf.add_text_item("Server quit the game", (340, 84)) # clear player bg = pygame.Surface((560, 30)) bg.fill(hex2rgb(Layout().background)) sf.display_surface(bg, (48, 610)) pygame.display.update() self.close() global game_client game_client = None