def on_apply():
     pf.global_event(EVENT_SETTINGS_APPLY, None)
Beispiel #2
0
 def on_tab_click():
     self.active_idx = idx
     self.__show_active()
     pf.global_event(EVENT_TOP_TAB_SELECTION_CHANGED,
                     self.active_idx)
Beispiel #3
0
 def on_new_fac():
     pf.global_event(EVENT_DIPLO_FAC_NEW,
                     (self.fac_name, self.fac_color))
Beispiel #4
0
 def on_save_as():
     pf.global_event(EVENT_MENU_SAVE_AS, None)
Beispiel #5
0
 def on_okay():
     pf.global_event(EVENT_FILE_CHOOSER_OKAY, self.filestring)
Beispiel #6
0
 def on_cancel():
     pf.global_event(EVENT_MENU_CANCEL, None)
Beispiel #7
0
 def on_load():
     pf.global_event(EVENT_MENU_LOAD, None)
 def on_performance():
     pf.global_event(EVENT_MENU_PERF_SHOW, None)
Beispiel #9
0
 def on_update_fac():
     facs = pf.get_factions_list()
     pf.global_event(EVENT_DIPLO_FAC_CHANGED, (facs[self.selected_fac_idx]["id"], self.fac_name, self.fac_color))
 def on_session():
     pf.global_event(EVENT_MENU_SESSION_SHOW, None)
 def on_settings():
     pf.global_event(EVENT_MENU_SETTINGS_SHOW, None)
 def on_button_pressed(idx):
     pf.global_event(EVENT_UNIT_ACTION, idx)
 def on_tab_click():
     self.active_idx = idx
     pf.global_event(EVENT_SETTINGS_TAB_SEL_CHANGED,
                     self.active_idx)
 def on_hide(self):
     pf.global_event(EVENT_SETTINGS_HIDE, None)
Beispiel #15
0
    def update(self):

        # Mode
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Mode:", (255, 255, 255))

        old_mode = self.mode
        self.layout_row_dynamic(20, 2)
        if self.option_label("Place", self.mode == self.OBJECTS_MODE_PLACE):
            self.mode = self.OBJECTS_MODE_PLACE
        if self.option_label("Select", self.mode == self.OBJECTS_MODE_SELECT):
            self.mode = self.OBJECTS_MODE_SELECT
        self.layout_row_dynamic(10, 1)

        if self.mode != old_mode:
            pf.global_event(EVENT_OBJECTS_TAB_MODE_CHANGED, self.mode)

        if self.mode == self.OBJECTS_MODE_PLACE:
            # Objects
            self.layout_row_dynamic(20, 1)
            self.label_colored_wrap("Objects:", (255, 255, 255))

            def objects_group():
                self.layout_row_static(25, UI_LEFT_PANE_WIDTH - 60, 1)
                for i in range(0, len(self.objects_list)):
                    old = self.selected_object_idx
                    on = self.selectable_label(self.objects_list[i],
                                               pf.NK_TEXT_ALIGN_LEFT,
                                               i == self.selected_object_idx)
                    if on:
                        self.selected_object_idx = i
                    if self.selected_object_idx != old:
                        pf.global_event(EVENT_OBJECT_SELECTION_CHANGED, i)

            self.layout_row_static(400, UI_LEFT_PANE_WIDTH - 30, 1)
            self.group("Objects", pf.NK_WINDOW_BORDER, objects_group)
        elif self.mode == self.OBJECTS_MODE_SELECT:
            # Selection
            sel_obj_list = pf.get_unit_selection()

            if len(sel_obj_list) == 0:
                return

            self.layout_row_dynamic(20, 1)
            self.label_colored_wrap("Selection:", (255, 255, 255))

            if len(sel_obj_list) > 1:

                def selection_group():
                    self.layout_row_static(25, UI_LEFT_PANE_WIDTH - 60, 1)
                    for i in range(0, len(sel_obj_list)):
                        name = "{0} {1}".format(
                            sel_obj_list[i].name,
                            format_str_for_numlist(sel_obj_list[i].pos))
                        on = self.selectable_label(name, pf.NK_TEXT_ALIGN_LEFT,
                                                   False)
                        if on:
                            pf.global_event(EVENT_OBJECT_SELECTED_UNIT_PICKED,
                                            sel_obj_list[i])

                self.layout_row_static(400, UI_LEFT_PANE_WIDTH - 30, 1)
                self.group("Selection", pf.NK_WINDOW_BORDER, selection_group)
            else:
                assert (len(sel_obj_list) == 1)
                self.layout_row_dynamic(10, 1)
                self.layout_row_dynamic(20, 1)
                self.label_colored_wrap(sel_obj_list[0].name, (200, 200, 0))

                pos_str = "Position: {0}".format(
                    format_str_for_numlist(sel_obj_list[0].pos))
                self.layout_row_dynamic(20, 1)
                self.label_colored_wrap(pos_str, (255, 255, 255))

                rot_str = "Rotation: {0}".format(
                    format_str_for_numlist(sel_obj_list[0].rotation))
                self.layout_row_dynamic(20, 1)
                self.label_colored_wrap(rot_str, (255, 255, 255))

                scale_str = "Scale: {0}".format(
                    format_str_for_numlist(sel_obj_list[0].scale))
                self.layout_row_dynamic(20, 1)
                self.label_colored_wrap(scale_str, (255, 255, 255))

                select_str = "Selectable: {0}".format(
                    "True" if sel_obj_list[0].selectable else "False")
                self.layout_row_dynamic(20, 1)
                self.label_colored_wrap(select_str, (255, 255, 255))

            def on_delete():
                pf.global_event(EVENT_OBJECT_DELETE_SELECTION, None)

            self.layout_row_dynamic(30, 1)
            self.button_label("Delete", on_delete)
Beispiel #16
0
 def on_delete_selected():
     pf.global_event(EVENT_DIPLO_FAC_REMOVED, factions_list[self.selected_fac_idx]["id"])
Beispiel #17
0
    def update(self):
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Selected Tile:", (255, 255, 255))

        self.layout_row_dynamic(30, 1)
        label = str(self.selected_tile) if self.selected_tile is None \
            else "Chunk: {0} Tile: {1}".format(self.selected_tile[0], self.selected_tile[1])
        self.label_colored_wrap(label, (200, 200, 0))

        # Brush type
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Brush Type:", (255, 255, 255))

        old_brush_type_idx = self.brush_type_idx
        self.layout_row_dynamic(20, 2)
        if self.option_label("Texture", self.brush_type_idx == 0):
            self.brush_type_idx = 0
        if self.option_label("Elevation", self.brush_type_idx == 1):
            self.brush_type_idx = 1
        self.layout_row_dynamic(10, 1)

        if self.brush_type_idx != old_brush_type_idx:
            pf.global_event(EVENT_TERRAIN_BRUSH_TYPE_CHANGED,
                            self.brush_type_idx)

        # Brush size
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Brush Size:", (255, 255, 255))

        old_brush_size_idx = self.brush_size_idx
        self.layout_row_dynamic(20, 2)
        if self.option_label("Small", self.brush_size_idx == 0):
            self.brush_size_idx = 0
        if self.option_label("Large", self.brush_size_idx == 1):
            self.brush_size_idx = 1
        self.layout_row_dynamic(10, 1)

        if self.brush_size_idx != old_brush_size_idx:
            pf.global_event(EVENT_TERRAIN_BRUSH_SIZE_CHANGED,
                            self.brush_size_idx)

        if self.brush_type_idx == 0:
            # Texture
            self.layout_row_dynamic(20, 1)
            self.label_colored_wrap("Texture:", (255, 255, 255))

            def textures_group():
                self.layout_row_static(25, LEFT_PANE_WIDTH - 60, 1)
                for i in range(0, len(self.materials_list)):
                    old = self.selected_mat_idx
                    on = self.selectable_label(self.materials_list[i].name,
                                               NK_TEXT_ALIGN_LEFT,
                                               i == self.selected_mat_idx)
                    if on:
                        self.selected_mat_idx = i
                    if self.selected_mat_idx != old:
                        pf.global_event(EVENT_TEXTURE_SELECTION_CHANGED, i)

            self.layout_row_static(400, LEFT_PANE_WIDTH - 30, 1)
            self.group("Texture:", NK_WINDOW_BORDER, textures_group)
        else:
            # Elevation
            self.layout_row_dynamic(20, 1)
            self.label_colored_wrap("Edges:", (255, 255, 255))

            old_edges_type_idx = self.edges_type_idx
            self.layout_row_dynamic(20, 2)
            if self.option_label("Hard", self.edges_type_idx == 0):
                self.edges_type_idx = 0
            if self.option_label("Smooth", self.edges_type_idx == 1):
                self.edges_type_idx = 1
            self.layout_row_dynamic(10, 1)

            if old_edges_type_idx != self.edges_type_idx:
                pf.global_event(EVENT_TERRAIN_EDGE_TYPE_CHANGED,
                                self.edges_type_idx)

            self.layout_row_dynamic(20, 1)
            self.label_colored_wrap("Height:", (255, 255, 255))

            self.layout_row_static(25, LEFT_PANE_WIDTH - 30, 1)
            old_height_idx = self.selected_height_idx
            self.selected_height_idx = self.combo_box(
                [str(h) for h in self.heights], self.selected_height_idx, 25,
                (LEFT_PANE_WIDTH - 30, 200))
            if old_height_idx != self.selected_height_idx:
                pf.global_event(EVENT_HEIGHT_SELECTION_CHANGED,
                                self.heights[self.selected_height_idx])
Beispiel #18
0
        if callable(getattr(cls, attr)) and attr not in dir(object)
        and not isinstance(getattr(cls, attr), types.BuiltinMethodType)
    ]

    if len(methods) > 0:
        print indented_border(2, char='*')
        print 2 * tab + "METHODS"
        print indented_border(2, char='*')
    for method in methods:
        print 2 * tab + "[{0}]".format(method.__name__)
        print "{0}".format(wrapper(2).fill(method.__doc__))
        print

print star_border
print "BUILT-IN CONSTANTS"
print star_border
print

for const in [
        attr for attr in dir(pf)
        if (isinstance(getattr(pf, attr), types.IntType)
            or isinstance(getattr(pf, attr), types.LongType)
            or isinstance(getattr(pf, attr), types.FloatType)
            or isinstance(getattr(pf, attr), types.StringType)
            or isinstance(getattr(pf, attr), types.UnicodeType))
        and not attr.startswith('__')
]:
    print(tab + "{0} {1}".format(const, getattr(pf, const)))

pf.global_event(pf.SDL_QUIT, None)
Beispiel #19
0
 def on_new():
     pf.global_event(EVENT_MENU_NEW, None)
Beispiel #20
0
    def update(self):

        # AR 
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Aspect Ratio:", (255, 255, 255))

        self.layout_row_dynamic(25, 1)
        old_ar_idx = self.ar_idx
        self.ar_idx = self.combo_box(self.__ar_opt_strings, self.ar_idx, 25, (VideoSettingsWindow.WIDTH - 40, 200))
        if old_ar_idx != self.ar_idx:
            pf.global_event(EVENT_AR_SETTING_CHANGED, self.ar_opts[self.ar_idx])

        # Resolution 
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Resolution:", (255, 255, 255))

        self.layout_row_dynamic(25, 1)
        old_res_idx = self.res_idx
        self.res_idx = self.combo_box(self.res_opt_strings, self.res_idx, 25, (VideoSettingsWindow.WIDTH - 40, 200))
        if old_res_idx != self.res_idx:
            pf.global_event(EVENT_RES_SETTING_CHANGED, self.res_opts[self.res_idx])

        # Window Mode
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Window Mode:", (255, 255, 255))

        self.layout_row_dynamic(25, 1)
        old_mode_idx = self.mode_idx
        self.mode_idx = self.combo_box(self.mode_opt_strings, self.mode_idx, 25, (VideoSettingsWindow.WIDTH - 40, 200))
        if old_mode_idx != self.mode_idx:
            pf.global_event(EVENT_WINMODE_SETTING_CHANGED, self.mode_opts[self.mode_idx])

        # Window Always On Top
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Window Always On Top (Requires Restart):", (255, 255, 255))

        self.layout_row_dynamic(20, 2)
        old_win_on_top_idx = self.win_on_top_idx
        if self.option_label(self.__win_on_top_opt_strings[0], self.win_on_top_idx == 0):
            self.win_on_top_idx = 0
        if self.option_label(self.__win_on_top_opt_strings[1], self.win_on_top_idx == 1):
            self.win_on_top_idx = 1
        
        if self.win_on_top_idx != old_win_on_top_idx:
            pf.global_event(EVENT_WIN_TOP_SETTING_CHANGED, self.win_on_top_opts[self.win_on_top_idx])

        # Vsync
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Vsync:", (255, 255, 255))

        self.layout_row_dynamic(20, 2)
        old_vsync_idx = self.vsync_idx
        if self.option_label(self.__vsync_opt_strings[0], self.vsync_idx == 0):
            self.vsync_idx = 0
        if self.option_label(self.__vsync_opt_strings[1], self.vsync_idx == 1):
            self.vsync_idx = 1
        
        if self.vsync_idx != old_vsync_idx:
            pf.global_event(EVENT_VSYNC_SETTING_CHANGED, self.vsync_opts[self.vsync_idx])

        # Shadows
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Shadows:", (255, 255, 255))

        self.layout_row_dynamic(20, 2)
        old_shadows_idx = self.shadows_idx
        if self.option_label(self.__shadows_opt_strings[0], self.shadows_idx == 0):
            self.shadows_idx = 0
        if self.option_label(self.__shadows_opt_strings[1], self.shadows_idx == 1):
            self.shadows_idx = 1
        
        if self.shadows_idx != old_shadows_idx:
            pf.global_event(EVENT_SHADOWS_SETTING_CHANGED, self.shadows_opts[self.shadows_idx])

        # Water Reflections
        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Water Reflections:", (255, 255, 255))

        self.layout_row_dynamic(20, 2)
        old_water_reflect_idx = self.water_reflect_idx
        if self.option_label(self.__water_reflect_opt_strings[0], self.water_reflect_idx == 0):
            self.water_reflect_idx = 0
        if self.option_label(self.__water_reflect_opt_strings[1], self.water_reflect_idx == 1):
            self.water_reflect_idx = 1
        
        if self.water_reflect_idx != old_water_reflect_idx:
            pf.global_event(EVENT_WATER_REF_SETTING_CHANGED, self.water_reflect_opts[self.water_reflect_idx])
Beispiel #21
0
 def on_save():
     pf.global_event(EVENT_MENU_SAVE, None)
Beispiel #22
0
 def __on_exit(self, event):
     pf.global_event(pf.SDL_QUIT, None)
Beispiel #23
0
 def on_exit():
     pf.global_event(EVENT_MENU_EXIT, None)
Beispiel #24
0
 def __on_old_game_teardown_begin(self, event):
     pf.global_event(EVENT_OLD_GAME_TEARDOWN_END, event)
Beispiel #25
0
 def on_cancel():
     pf.global_event(EVENT_FILE_CHOOSER_CANCEL, None)
Beispiel #26
0
 def __on_new(self, event):
     pf.global_event(EVENT_OLD_GAME_TEARDOWN_BEGIN, (map.Map(4, 4), None))
Beispiel #27
0
 def on_update_fac():
     pf.global_event(
         EVENT_DIPLO_FAC_CHANGED,
         (self.selected_fac_idx, self.fac_name, self.fac_color))
Beispiel #28
0
 def on_delete():
     pf.global_event(EVENT_OBJECT_DELETE_SELECTION, None)
Beispiel #29
0
 def on_delete_selected():
     pf.global_event(EVENT_DIPLO_FAC_REMOVED, self.selected_fac_idx)
 def on_exit():
     pf.global_event(EVENT_SETTINGS_HIDE, None)