desktop.addChild("footer", footer.window, (0, desktop.getHeight() - footer.window.getHeight()), -1, CoordTransition((0, desktop.getHeight()))) desktop.addChild( "mainmenu", mainmenu.window, (0, header.window.getHeight()), 1, CoordTransition( (-mainmenu.window.getWidth(), header.window.getHeight()))) mmeh = MainMenuEventHandler(desktop) mainmenu.window.setEventHandler(mmeh) mmeh.onChange(mainmenu.window) desktop.setTransition( "contents", CoordTransition((desktop.getWidth(), header.window.getHeight()))) gui.setDesktop(desktop) while True: set_marquee() selected = gui.eventLoop(mainmenu.window) if selected != None: selected = mainmenu.window.getSelected().getData()[0] if hasattr(selected, "main"): mainmenu.window.keepShowingCursor() selected.main() elif hasattr(selected, "activate") and selected.activate(): play_sound("click") gui.eventLoop(SelectedEventHandler(selected)) pygame.quit() exit(0)
s = system.getSystem() mainmenu.window.addItem(mainmenu.SmallListItem(gui.res.icon_back, gui.res.string_back if s.isRunningAsGetty() else gui.res.string_end, (back,gui.res.string_back_description if s.isRunningAsGetty() else gui.res.string_back_home_))) mainmenu.window.addItem(mainmenu.SmallListItem(gui.res.icon_shutdown,gui.res.string_shutdown , (shutdown,gui.res.string_shutdown_description))) desktop.addChild("header", header.window, (0, 0), -1, CoordTransition((0, -header.window.getHeight())) ) desktop.addChild("footer", footer.window, (0, desktop.getHeight()-footer.window.getHeight()), -1, CoordTransition((0, desktop.getHeight()) )) desktop.addChild("mainmenu", mainmenu.window, (0, header.window.getHeight()), 1, CoordTransition((-mainmenu.window.getWidth(), header.window.getHeight()))) mmeh = MainMenuEventHandler(desktop) mainmenu.window.setEventHandler(mmeh) mmeh.onChange(mainmenu.window) desktop.setTransition("contents", CoordTransition((desktop.getWidth(), header.window.getHeight()))) gui.setDesktop(desktop) while True: set_marquee() selected = gui.eventLoop(mainmenu.window) if selected != None: selected = mainmenu.window.getSelected().getData()[0] if hasattr(selected, "main"): mainmenu.window.keepShowingCursor() selected.main() elif hasattr(selected, "activate") and selected.activate(): play_sound("click") gui.eventLoop(SelectedEventHandler(selected)) pygame.quit() exit(0)
def main(): clock = gui.getClock() screen = gui.getScreen() title = resource_loader.loadImage("title.png") title_background = resource_loader.loadImage(("title_background.jpg", "title_background.png"), screen) copyright = resource_loader.loadImage("copyright.png") for y in range(1,100,10): clock.tick(60) screen.blit(title_background, title_background.get_rect()) rotitle = pygame.transform.rotozoom(title, 0, y / 100.0) screen.blit(rotitle, (320 - rotitle.get_width() / 2,200 - rotitle.get_height() / 2)) pygame.display.flip() for y in range(0, 120, 10): clock.tick(60) screen.blit(title_background, title_background.get_rect()) screen.blit(title, (320 - title.get_width() / 2, 200 - title.get_height() / 2)) screen.blit(copyright, (400, 510 - y)) pygame.display.flip() # シリアルナンバー表示 s = system.getSystem() hostname_txt = pygamehelper.render_font_with_shadow(gui.res.font_splash_serialno, u"SERIAL#: %s" % (s.getHostname()), (255, 255, 255)) screen.blit(hostname_txt, (16, 430)) pygame.display.flip() oldbg = screen.copy() count = 0 start_msg = pygamehelper.render_font_with_shadow(gui.res.font_splash_message, gui.res.string_enter_key_start, (255, 255, 255)) while True: clock.tick(8) event = pygame.event.poll() if gui.isSelectEvent(event): break if count == 0: screen.blit(start_msg, (screen.get_width() / 2 - start_msg.get_width() / 2, screen.get_height() * 2 / 3 - start_msg.get_height() / 2)) pygame.display.update() elif count == 6: screen.blit(oldbg, (0,0)) pygame.display.update() count += 1 if count > 11: count = 0 wbui.play_sound("click") background = resource_loader.loadImage(("background.jpg", "background.png"), screen) for alpha in reversed(range(0,255,32)): clock.tick(60) screen.blit(background, background.get_rect()) oldbg.set_alpha(alpha) screen.blit(oldbg, oldbg.get_rect()) pygame.display.flip() try: desktop = gui.DesktopWindow(screen.get_size()) gui.setDesktop(desktop) for i in (1,2,3): if try_auth(): return True else: gui.messagebox.execute(gui.res.string_incorrect_pass, ["ok"], gui.res.color_dialog_negative) finally: gui.setDesktop(None) return False
def start(install_image=None): desktop = gui.DesktopWindow(gui.getScreen().get_size(), gui.res.background) gui.setDesktop(desktop) global header, marquee header = Header() marquee = Marquee() with dialogbox.messagebox.open(u"使用可能なディスクを調査中..."): q = multiprocessing.Queue() p = multiprocessing.Process(target=get_usable_disks, args=(install_image, q)) p.start() while p.is_alive(): gui.yieldFrame() p.join() rst = q.get_nowait() if isinstance(rst, Exception): raise rst disks, install_image = rst mainmenu = MainMenu() mme = MainMenuEventHandler() mainmenu.setEventHandler(mme) install.window = Install() tools.window = Tools() mainmenu_items = [] if len(disks) > 0: mainmenu_items.append( MainMenu.ListItem(gui.res.icon_install, gui.res.string_inst_inatall, install.window)) mainmenu_items.append( MainMenu.ListItem(gui.res.icon_tools, gui.res.string_inst_tool, tools.window)) mainmenu.addItems(mainmenu_items) items_height = sum(map(lambda x: x.getHeight(), mainmenu_items)) mainmenu.addItem( gui.list.Separator(332 - mainmenu.getMarginTop() - items_height)) mainmenu.addItem( MainMenu.SmallListItem(gui.res.icon_shutdown, gui.res.string_inst_end_)) for disk in disks: install.window.addItem( gui.list.TextListItem( "%s %s(%s)" % (disk["vendor"], disk["model"], disk["size_str"]), gui.res.font_select_option, None, None, ("install", disk, u"%s %s(%s, %s)に Walbrixをインストールします" % (disk["vendor"], disk["model"], disk["name"], disk["size_str"])))) tools.window.addItem( gui.list.TextListItem(gui.res.string_inst_gui_benchmark, gui.res.font_select_option, None, None, ("benchmark", gui.res.string_inst_speed_desc))) tools.window.addItem( gui.list.TextListItem(gui.res.string_inst_console, gui.res.font_select_option, None, None, ("console", gui.res.string_linux_console_exit))) desktop.addChild("header", header, (0, 0), -1) desktop.addChild("marquee", marquee, (0, gui.getScreen().get_height() - marquee.getHeight()), -1) desktop.addChild("mainmenu", mainmenu, (0, header.getHeight()), 1) while True: mme.onChange(mainmenu) while gui.eventLoop(mainmenu) == None: pass selected = mainmenu.getSelected().getWindow() if selected == None: return False mainmenu.keepShowingCursor() while True: if gui.eventLoop(selected) == None: break action = selected.getSelected().getData() if action[0] == "install": install.run(action[1], install_image) elif action[0] == "benchmark": if not tools.benchmark_gui(): continue elif action[0] == "console": if not tools.console(): continue