def __init__(self, *args, **kwargs): super(KnowledgeScreen, self).__init__(*args, **kwargs) self.knowledge_types = { _("Techs"): "techs", _("Items"): "items", _("Concepts"): "concepts" } self.cur_knowledge_type = "" self.cur_knowledge = None self.knowledge_inner_list = () self.knowledge_inner_list_key = () self.cur_focus = 0 self.knowledge_choice = \ listbox.UpdateListbox(self, (0.05, .18), (.21, .25), list=self.knowledge_types.keys(), update_func=self.set_knowledge_type) self.knowledge_inner = \ listbox.UpdateListbox(self, (.30, .18), (.21, .25), list=self.knowledge_inner_list, update_func=self.set_knowledge) self.description_pane = \ widget.BorderedWidget(self, (0.55, 0), (0.40, 0.7), anchor = constants.TOP_LEFT) self.back_button = button.ExitDialogButton(self, (0.17, 0.46), (-.3, -.1), anchor=constants.TOP_LEFT, text=_("&BACK"), autohotkey=True) #Set up the key handling. #This is likely not the best way to do it. self.remove_key_handler(pygame.K_UP, self.knowledge_choice.got_key) self.remove_key_handler(pygame.K_DOWN, self.knowledge_choice.got_key) self.remove_key_handler(pygame.K_PAGEUP, self.knowledge_choice.got_key) self.remove_key_handler(pygame.K_PAGEDOWN, self.knowledge_choice.got_key) self.remove_key_handler(pygame.K_UP, self.knowledge_inner.got_key) self.remove_key_handler(pygame.K_DOWN, self.knowledge_inner.got_key) self.remove_key_handler(pygame.K_PAGEUP, self.knowledge_inner.got_key) self.remove_key_handler(pygame.K_PAGEDOWN, self.knowledge_inner.got_key) self.add_key_handler(pygame.K_UP, self.key_handle) self.add_key_handler(pygame.K_DOWN, self.key_handle) self.add_key_handler(pygame.K_LEFT, self.key_handle) self.add_key_handler(pygame.K_RIGHT, self.key_handle)
def __init__(self, *args, **kwargs): super(GeneralPane, self).__init__(*args, **kwargs) self.language_label = text.Text(self, (.01, .01), (.14, .05), align=constants.LEFT, background_color="clear") self.languages = get_languages_list() self.language_choice = \ listbox.UpdateListbox(self, (.16, .01), (.20, .25), list=[lang[1] for lang in self.languages], update_func=self.set_language) self.theme_label = text.Text(self, (.37, .01), (.09, .05), text=_("Theme:"), align=constants.LEFT, background_color="clear") self.theme_choice = \ listbox.UpdateListbox(self, (.47, .01), (.12, .25), update_func=theme.set_theme, list_pos=theme.get_theme_pos())
def __init__(self, *args, **kwargs): super(VideoPane, self).__init__(*args, **kwargs) self.resolution_initialized = False self.resolution_label = text.Text(self, (.01, .01), (.14, .05), align=constants.LEFT, background_color="clear") self.resolution_choice = \ listbox.UpdateListbox(self, (.16, .01), (.20, .25), update_func=self.update_resolution) self.resolution_custom = OptionButton(self, (.01, .28), (.14, .05), autohotkey=True, function=self.set_resolution_custom) self.resolution_custom_horiz = \ text.EditableText(self, (.16, .28), (.14, .05), text=str(gg.default_screen_size[0]), borders=constants.ALL, border_color="widget_border", background_color=(0,0,50,255)) self.resolution_custom_X = text.Text(self, (.30, .28), (.02, .05), text="X", base_font="special", background_color="clear") self.resolution_custom_vert = \ text.EditableText(self, (.32, .28), (.14, .05), text=str(gg.default_screen_size[1]), borders=constants.ALL, border_color="widget_border", background_color=(0,0,50,255)) self.fullscreen_label = button.HotkeyText(self, (.40, .01), (.30, .05), autohotkey=True, align=constants.LEFT, background_color="clear") self.fullscreen_toggle = OptionButton(self, (.71, .01), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_fullscreen, args=(button.TOGGLE_VALUE,)) self.fullscreen_label.hotkey_target = self.fullscreen_toggle self.daynight_label = button.HotkeyText(self, (.40, .08), (.30, .05), autohotkey=True, align=constants.LEFT, background_color="clear") self.daynight_toggle = OptionButton(self, (.71, .08), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_daynight, args=(button.TOGGLE_VALUE,)) self.daynight_label.hotkey_target = self.daynight_toggle self.grab_label = button.HotkeyText(self, (.40, .15), (.30, .05), autohotkey=True, align=constants.LEFT, background_color="clear") self.grab_toggle = OptionButton(self, (.71, .15), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_grab, args=(button.TOGGLE_VALUE,)) self.grab_label.hotkey_target = self.grab_toggle
def __init__(self, *args, **kwargs): super(GeneralPane, self).__init__(*args, **kwargs) # First row self.fullscreen_label = button.HotkeyText(self, (.01, .01), (.14, .05), autohotkey=True, align=constants.LEFT, background_color="clear") self.fullscreen_toggle = OptionButton(self, (.16, .01), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_fullscreen, args=(button.TOGGLE_VALUE, )) self.fullscreen_label.hotkey_target = self.fullscreen_toggle self.daynight_label = button.HotkeyText(self, (.25, .01), (.20, .05), autohotkey=True, background_color="clear") self.daynight_toggle = OptionButton(self, (.46, .01), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_daynight, args=(button.TOGGLE_VALUE, )) self.daynight_label.hotkey_target = self.daynight_toggle self.grab_label = button.HotkeyText(self, (.55, .01), (.15, .05), autohotkey=True, background_color="clear") self.grab_toggle = OptionButton(self, (.71, .01), (.07, .05), text_shrink_factor=.75, force_underline=-1, function=self.set_grab, args=(button.TOGGLE_VALUE, )) self.grab_label.hotkey_target = self.grab_toggle # Second and third row self.resolution_label = text.Text(self, (.01, .08), (.14, .05), align=constants.LEFT, background_color="clear") self.resolution_group = button.ButtonGroup() rows = 2 cols = 4 def xpos(i): return .16 + .16 * (i % cols) def ypos(i): return .08 + .07 * int(i / cols) for index, (xres, yres) in enumerate(sorted(gg.resolutions[0:rows * cols])): self.resolution_group.add( OptionButton(self, (xpos(index), ypos(index)), (.14, .05), text="%sx%s" % (xres, yres), function=self.set_resolution, args=((xres, yres), ))) # Adjust index to full row index += cols - (index % cols) - 1 # Forth row self.resolution_custom = OptionButton( self, (xpos(0), ypos(index + 1)), (.14, .05), autohotkey=True, function=self.set_resolution_custom) self.resolution_group.add(self.resolution_custom) self.resolution_custom_horiz = \ text.EditableText(self, (xpos(1), ypos(index+1)), (.14, .05), text=str(gg.default_screen_size[0]), borders=constants.ALL, border_color="widget_border", background_color=(0,0,50,255)) self.resolution_custom_X = text.Text(self, (xpos(2) - .02, ypos(index + 1)), (.02, .05), text="X", base_font="special", background_color="clear") self.resolution_custom_vert = \ text.EditableText(self, (xpos(2), ypos(index+1)), (.14, .05), text=str(gg.default_screen_size[1]), borders=constants.ALL, border_color="widget_border", background_color=(0,0,50,255)) # Fifth row self.language_label = text.Text(self, (.01, .30), (.14, .05), align=constants.LEFT, background_color="clear") self.languages = get_languages_list() self.language_choice = \ listbox.UpdateListbox(self, (.16, .30), (.20, .25), list=[lang[1] for lang in self.languages], update_func=self.set_language) self.theme_label = text.Text(self, (.37, .30), (.09, .05), text=_("Theme:"), align=constants.LEFT, background_color="clear") self.theme_choice = \ listbox.UpdateListbox(self, (.47, .30), (.12, .25), update_func=theme.set_theme, list_pos=theme.get_theme_pos())
def make_listbox(self): return listbox.UpdateListbox(self, (0, 0), (-.53, -.85), anchor=constants.TOP_LEFT, update_func=self.handle_update)
def __init__(self, *args, **kwargs): kwargs.setdefault("yes_type", "ok") kwargs.setdefault("no_type", "cancel") super(OptionsScreen, self).__init__(*args, **kwargs) self.yes_button.function = self.check_restart self.size = (.79, .63) self.pos = (.5, .5) self.anchor = constants.MID_CENTER self.background_color = (0, 0, 50) self.borders = () labels = { 'fullscreen': g.hotkey(_("&Fullscreen:")), 'sound': g.hotkey(_("&Sound:")), 'mousegrab': g.hotkey(_("&Mouse grab:")), 'daynight': g.hotkey(_("Da&y/night display:")), } # First row self.fullscreen_label = text.Text( self, (.01, .01), (.14, .05), text=labels['fullscreen']['text'], underline=labels['fullscreen']['pos'], align=constants.LEFT, background_color=gg.colors["clear"]) self.fullscreen_toggle = OptionButton( self, (.16, .01), (.07, .05), text=_("NO"), text_shrink_factor=.75, hotkey=labels['fullscreen']['key'], force_underline=-1, function=self.set_fullscreen, args=(button.TOGGLE_VALUE, )) self.sound_label = text.Text(self, (.28, .01), (.15, .05), text=labels['sound']['text'], underline=labels['sound']['pos'], background_color=gg.colors["clear"]) self.sound_toggle = OptionButton(self, (.44, .01), (.07, .05), text=_("YES"), text_shrink_factor=.75, hotkey=labels['sound']['key'], force_underline=-1, function=self.set_sound, args=(button.TOGGLE_VALUE, )) self.grab_label = text.Text(self, (.55, .01), (.15, .05), text=labels['mousegrab']['text'], underline=labels['mousegrab']['pos'], background_color=gg.colors["clear"]) self.grab_toggle = OptionButton(self, (.71, .01), (.07, .05), text=_("NO"), text_shrink_factor=.75, hotkey=labels['mousegrab']['key'], force_underline=-1, function=self.set_grab, args=(button.TOGGLE_VALUE, )) # Second and third row self.resolution_label = text.Text(self, (.01, .08), (.14, .05), text=_("Resolution:"), align=constants.LEFT, background_color=gg.colors["clear"]) self.resolution_group = button.ButtonGroup() rows = 2 cols = 4 def xpos(i): return .16 + .16 * (i % cols) def ypos(i): return .08 + .07 * int(i / cols) for index, (xres, yres) in enumerate(sorted(gg.resolutions[0:rows * cols])): self.resolution_group.add( OptionButton(self, (xpos(index), ypos(index)), (.14, .05), text="%sx%s" % (xres, yres), function=self.set_resolution, args=((xres, yres), ))) # Adjust index to full row index += cols - (index % cols) - 1 # Forth row self.resolution_custom = OptionButton( self, (xpos(0), ypos(index + 1)), (.14, .05), text=_("&CUSTOM:"), autohotkey=True, function=self.set_resolution_custom) self.resolution_group.add(self.resolution_custom) self.resolution_custom_horiz = \ text.EditableText(self, (xpos(1), ypos(index+1)), (.14, .05), text=str(gg.default_screen_size[0]), borders=constants.ALL, border_color=gg.colors["white"], background_color=(0,0,50,255)) self.resolution_custom_X = text.Text( self, (xpos(2) - .02, ypos(index + 1)), (.02, .05), text="X", base_font=gg.font[1], background_color=gg.colors["clear"]) self.resolution_custom_vert = \ text.EditableText(self, (xpos(2), ypos(index+1)), (.14, .05), text=str(gg.default_screen_size[1]), borders=constants.ALL, border_color=gg.colors["white"], background_color=(0,0,50,255)) # Fifth row self.language_label = text.Text(self, (.01, .30), (.14, .05), text=_("Language:"), align=constants.LEFT, background_color=gg.colors["clear"]) self.languages = get_languages_list() self.language_choice = \ listbox.UpdateListbox(self, (.16, .30), (.21, .25), list=[lang[1] for lang in self.languages], update_func=self.set_language) self.daynight_label = text.Text(self, (.50, .30), (.20, .05), text=labels['daynight']['text'], underline=labels['daynight']['pos'], background_color=gg.colors["clear"]) self.daynight_toggle = OptionButton(self, (.71, .30), (.07, .05), text=_("NO"), text_shrink_factor=.75, hotkey=labels['daynight']['key'], force_underline=-1, function=self.set_daynight, args=(button.TOGGLE_VALUE, ))
def __init__(self, *args, **kwargs): super(OptionsScreen, self).__init__(*args, **kwargs) self.size = (.79, .63) self.pos = (.5, .5) self.anchor = constants.MID_CENTER self.background_color = (0,0,50) self.borders = () self.fullscreen_label = text.Text(self, (.01, .01), (.15, .05), text="Fullscreen:", underline=0, align=constants.LEFT, background_color=gg.colors["clear"]) self.fullscreen_toggle = OptionButton(self, (.17, .01), (.07, .05), text="NO", text_shrink_factor=.75, hotkey="f", force_underline=-1, function=self.set_fullscreen, args=(button.TOGGLE_VALUE,)) self.sound_label = text.Text(self, (.28, .01), (.15, .05), text="Sound:", underline=0, background_color=gg.colors["clear"]) self.sound_toggle = OptionButton(self, (.44, .01), (.07, .05), text="YES", text_shrink_factor=.75, hotkey="s", force_underline=-1, function=self.set_sound, args=(button.TOGGLE_VALUE,)) self.grab_label = text.Text(self, (.55, .01), (.15, .05), text="Mouse grab:", underline=0, background_color=gg.colors["clear"]) self.grab_toggle = OptionButton(self, (.71, .01), (.07, .05), text="NO", text_shrink_factor=.75, hotkey="m", force_underline=-1, function=self.set_grab, args=(button.TOGGLE_VALUE,)) self.resolution_label = text.Text(self, (.01, .08), (.15, .05), text="Resolution:", align=constants.LEFT, background_color=gg.colors["clear"]) self.resolution_group = button.ButtonGroup() self.resolution_640x480 = OptionButton(self, (.17, .08), (.12, .05), text="640X480", text_shrink_factor=.5, function=self.set_resolution, args=((640,480),)) self.resolution_group.add(self.resolution_640x480) self.resolution_800x600 = OptionButton(self, (.333, .08), (.12, .05), text="800X600", text_shrink_factor=.5, function=self.set_resolution, args=((800,600),)) self.resolution_group.add(self.resolution_800x600) self.resolution_1024x768 = OptionButton(self, (.496, .08), (.12, .05), text="1024X768", text_shrink_factor=.5, function=self.set_resolution, args=((1024,768),)) self.resolution_group.add(self.resolution_1024x768) self.resolution_1280x1024 = OptionButton(self, (.66, .08), (.12, .05), text="1280X1024", text_shrink_factor=.5, function=self.set_resolution, args=((1280,1024),)) self.resolution_group.add(self.resolution_1280x1024) self.resolution_custom = OptionButton(self, (.17, .15), (.12, .05), text="CUSTOM:", text_shrink_factor=.5) self.resolution_group.add(self.resolution_custom) self.resolution_custom_horiz = \ text.EditableText(self, (.333, .15), (.12, .05), text="1400", borders=constants.ALL, border_color=gg.colors["white"], background_color=(0,0,50,255)) self.resolution_custom_X = text.Text(self, (.46, .15), (.03, .05), text="X", base_font=gg.font[1], background_color=gg.colors["clear"]) self.resolution_custom_vert = \ text.EditableText(self, (.496, .15), (.12, .05), text="1050", borders=constants.ALL, border_color=gg.colors["white"], background_color=(0,0,50,255)) self.resolution_apply = \ button.FunctionButton(self, (.66, .15), (.12, .05), text="APPLY", text_shrink_factor=.75, hotkey="a", function=self.set_resolution_custom) self.soundbuf_label = text.Text(self, (.01, .22), (.25, .05), text="Sound buffering:", align=constants.LEFT, background_color=gg.colors["clear"]) self.soundbuf_group = button.ButtonGroup() self.soundbuf_low = OptionButton(self, (.27, .22), (.14, .05), text="LOW", hotkey="l", function=self.set_soundbuf, args=(1024,)) self.soundbuf_group.add(self.soundbuf_low) self.soundbuf_normal = OptionButton(self, (.44, .22), (.17, .05), text="NORMAL", hotkey="n", function=self.set_soundbuf, args=(1024*2,)) self.soundbuf_group.add(self.soundbuf_normal) self.soundbuf_high = OptionButton(self, (.64, .22), (.14, .05), text="HIGH", hotkey="h", function=self.set_soundbuf, args=(1024*4,)) self.soundbuf_group.add(self.soundbuf_high) self.language_label = text.Text(self, (.01, .30), (.15, .05), text="Language:", align=constants.LEFT, background_color=gg.colors["clear"]) self.language_choice = \ listbox.UpdateListbox(self, (.17, .30), (.21, .25), list=g.available_languages(), update_func=self.set_language) self.daynight_label = text.Text(self, (.55, .30), (.15, .05), text="Day/night display:", underline=2, background_color=gg.colors["clear"]) self.daynight_toggle = OptionButton(self, (.71, .30), (.07, .05), text="NO", text_shrink_factor=.75, hotkey="y", force_underline=-1, function=self.set_daynight, args=(button.TOGGLE_VALUE,)) self.save_button = button.FunctionButton(self, (.42, .45), (.34, .05), text="SAVE OPTIONS TO DISK", hotkey="d", function=save_options)