def benchmark_gui(): if gui.messagebox.execute(gui.res.string_installer_tools_gui_benchmark, ["ok", "cancel"]) != "ok": return False desktop = gui.getDesktop() installer.marquee.setText(None) set_benchmark_progressbar(desktop, gui.res.string_installer_tools_off_screen_measure) start_time = pygame.time.get_ticks() offscreen_cnt = 0 while pygame.time.get_ticks() - start_time <= 5000: desktop.draw(gui.getScreen()) offscreen_cnt += 1 set_benchmark_progressbar(desktop, gui.res.string_installer_tools_framebuffer) screen = gui.getScreen() start_time = pygame.time.get_ticks() framebuffer_cnt = 0 while pygame.time.get_ticks() - start_time <= 5000: screen.set_at((random.randint(0, screen.get_width() - 1),random.randint(0, screen.get_height() - 1)), (random.randint(0,255),random.randint(0,255),random.randint(0,255))) pygame.display.update() framebuffer_cnt += 1 desktop.removeChild("progressbar") installer.marquee.setText(gui.res.string_installer_tools_speed) gui.messagebox.execute(gui.res.string_installer_tools_result % (float(offscreen_cnt) / 5, float(framebuffer_cnt) / 5), ["ok"]) return True
def benchmark_gui(): if gui.messagebox.execute(gui.res.string_installer_tools_gui_benchmark, ["ok", "cancel"]) != "ok": return False desktop = gui.getDesktop() installer.marquee.setText(None) set_benchmark_progressbar( desktop, gui.res.string_installer_tools_off_screen_measure) start_time = pygame.time.get_ticks() offscreen_cnt = 0 while pygame.time.get_ticks() - start_time <= 5000: desktop.draw(gui.getScreen()) offscreen_cnt += 1 set_benchmark_progressbar(desktop, gui.res.string_installer_tools_framebuffer) screen = gui.getScreen() start_time = pygame.time.get_ticks() framebuffer_cnt = 0 while pygame.time.get_ticks() - start_time <= 5000: screen.set_at((random.randint( 0, screen.get_width() - 1), random.randint(0, screen.get_height() - 1)), (random.randint(0, 255), random.randint( 0, 255), random.randint(0, 255))) pygame.display.update() framebuffer_cnt += 1 desktop.removeChild("progressbar") installer.marquee.setText(gui.res.string_installer_tools_speed) gui.messagebox.execute( gui.res.string_installer_tools_result % (float(offscreen_cnt) / 5, float(framebuffer_cnt) / 5), ["ok"]) return True
def benchmark_gui(): if dialogbox.messagebox.execute(gui.res.string_benchmark_start_desc, dialogbox.DialogBox.OKCANCEL()) != "ok": return False desktop = gui.getDesktop() footer.window.setText(None) set_benchmark_progressbar(desktop, gui.res.string_drawing_measure) start_time = pygame.time.get_ticks() offscreen_cnt = 0 while pygame.time.get_ticks() - start_time <= 5000: desktop.draw(gui.getScreen()) offscreen_cnt += 1 set_benchmark_progressbar(desktop, gui.res.string_frame_buffer_measure) screen = gui.getScreen() start_time = pygame.time.get_ticks() framebuffer_cnt = 0 while pygame.time.get_ticks() - start_time <= 5000: screen.set_at((random.randint( 0, screen.get_width() - 1), random.randint(0, screen.get_height() - 1)), (random.randint(0, 255), random.randint( 0, 255), random.randint(0, 255))) pygame.display.update() framebuffer_cnt += 1 desktop.removeChild("progressbar") footer.window.setText(gui.res.string_speed_indication) dialogbox.messagebox.execute( gui.res.string_benchmark_result % (float(offscreen_cnt) / 5, float(framebuffer_cnt) / 5)) return False
def init(): s = system.getSystem() global hostname, version hostname = s.getHostname() version = system.version # 画像リソースのロード screen = gui.getScreen() global background, left_arrow, right_arrow, up_arrow, down_arrow, contents_color background = resource_loader.loadImage( ['background.jpg', 'background.png'], screen) gui.res.register("background", background) messagebox_buttons["ok"] = resource_loader.loadImage("button_ok.png") gui.res.register("button_ok", messagebox_buttons["ok"]) messagebox_buttons["cancel"] = resource_loader.loadImage( "button_cancel.png") gui.res.register("button_cancel", messagebox_buttons["cancel"]) left_arrow = resource_loader.loadImage("left.png") gui.res.register("left_arrow", left_arrow) right_arrow = resource_loader.loadImage("right.png") gui.res.register("right_arrow", right_arrow) up_arrow = resource_loader.loadImage("up.png") gui.res.register("list_up_arrow", up_arrow) down_arrow = resource_loader.loadImage("down.png") gui.res.register("list_down_arrow", down_arrow) gui.res.register("caution_sign", resource_loader.loadImage("caution_sign.png")) gui.res.register("icon_status", resource_loader.loadImage("icon_status.png")) gui.res.register("icon_volume", resource_loader.loadImage("icon_volume.png")) gui.res.register("icon_domain", resource_loader.loadImage("icon_domain.png")) gui.res.register("icon_app", resource_loader.loadImage("icon_app.png")) gui.res.register("icon_options", resource_loader.loadImage("icon_options.png")) gui.res.register("icon_console", resource_loader.loadImage("icon_console.png")) gui.res.register("icon_support", resource_loader.loadImage("icon_support.png")) gui.res.register("icon_back", resource_loader.loadImage("icon_back.png")) gui.res.register("icon_shutdown", resource_loader.loadImage("icon_shutdown.png")) gui.res.register("contents_panel", resource_loader.loadImage("contents_panel.png")) # フォントのロード global fontfile, font, smallfont, extrasmallfont fontfile_candidates = [ theme.getThemeFilePath("pfont.ttf"), "/System/Library/Fonts/ヒラギノ角ゴ ProN W3.otf", "/usr/share/fonts/vlgothic/VL-PGothic-Regular.ttf", "/usr/share/fonts/truetype/takao-gothic/TakaoPGothic.ttf" ] for fc in fontfile_candidates: if fc != None and os.path.exists(fc): fontfile = fc break gui.res.register("font_system", gui.FontFactory(fontfile)) font = gui.res.font_system.getFont(28) smallfont = gui.res.font_system.getFont(22) extrasmallfont = gui.res.font_system.getFont(16) gui.res.register("font_messagebox", font) gui.res.register("font_select_option", smallfont) gui.res.register("font_splash_message", font) gui.res.register("font_splash_serialno", smallfont) # 音声リソースのロード if sound_materials != None: sound_materials["click"] = resource_loader.loadSound("click.ogg") sound_materials["cancel"] = resource_loader.loadSound("cancel.ogg") sound_materials["fail"] = resource_loader.loadSound("fail.ogg") sound_materials["success"] = resource_loader.loadSound("success.ogg") # クロックの初期化 #global clock clock = pygame.time.Clock() gui.setClock(clock) # initialize dialog box subsystem dialogbox.init()
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 init(): s = system.getSystem() global hostname, version hostname = s.getHostname() version = system.version # 画像リソースのロード screen = gui.getScreen() global background, left_arrow, right_arrow, up_arrow, down_arrow, contents_color background = resource_loader.loadImage(['background.jpg','background.png'], screen) gui.res.register("background", background) messagebox_buttons["ok"] = resource_loader.loadImage("button_ok.png") gui.res.register("button_ok", messagebox_buttons["ok"]) messagebox_buttons["cancel"] = resource_loader.loadImage("button_cancel.png") gui.res.register("button_cancel", messagebox_buttons["cancel"]) left_arrow = resource_loader.loadImage("left.png") gui.res.register("left_arrow", left_arrow) right_arrow = resource_loader.loadImage("right.png") gui.res.register("right_arrow", right_arrow) up_arrow = resource_loader.loadImage("up.png") gui.res.register("list_up_arrow", up_arrow) down_arrow = resource_loader.loadImage("down.png") gui.res.register("list_down_arrow", down_arrow) gui.res.register("caution_sign", resource_loader.loadImage("caution_sign.png")) gui.res.register("icon_status", resource_loader.loadImage("icon_status.png")) gui.res.register("icon_volume", resource_loader.loadImage("icon_volume.png")) gui.res.register("icon_domain", resource_loader.loadImage("icon_domain.png")) gui.res.register("icon_app", resource_loader.loadImage("icon_app.png")) gui.res.register("icon_options", resource_loader.loadImage("icon_options.png")) gui.res.register("icon_console", resource_loader.loadImage("icon_console.png")) gui.res.register("icon_support", resource_loader.loadImage("icon_support.png")) gui.res.register("icon_back", resource_loader.loadImage("icon_back.png")) gui.res.register("icon_shutdown", resource_loader.loadImage("icon_shutdown.png")) gui.res.register("contents_panel", resource_loader.loadImage("contents_panel.png")) # フォントのロード global fontfile, font, smallfont, extrasmallfont fontfile_candidates = [ theme.getThemeFilePath("pfont.ttf"), "/System/Library/Fonts/ヒラギノ角ゴ ProN W3.otf", "/usr/share/fonts/vlgothic/VL-PGothic-Regular.ttf", "/usr/share/fonts/truetype/takao-gothic/TakaoPGothic.ttf"] for fc in fontfile_candidates: if fc != None and os.path.exists(fc): fontfile = fc break gui.res.register("font_system", gui.FontFactory(fontfile)) font = gui.res.font_system.getFont(28) smallfont = gui.res.font_system.getFont(22) extrasmallfont = gui.res.font_system.getFont(16) gui.res.register("font_messagebox", font) gui.res.register("font_select_option", smallfont) gui.res.register("font_splash_message", font) gui.res.register("font_splash_serialno", smallfont) # 音声リソースのロード if sound_materials != None: sound_materials["click"] = resource_loader.loadSound("click.ogg") sound_materials["cancel"] = resource_loader.loadSound("cancel.ogg") sound_materials["fail"] = resource_loader.loadSound("fail.ogg") sound_materials["success"] = resource_loader.loadSound("success.ogg") # クロックの初期化 #global clock clock = pygame.time.Clock() gui.setClock(clock) # initialize dialog box subsystem dialogbox.init()
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