def update(self):

        with btc.ButtonStyle(rounding=0.0):
            self.layout_row_begin(pf.NK_STATIC, UI_TAB_BAR_HEIGHT - 10,
                                  UI_TAB_BAR_NUM_COLS)

            for idx in range(0, len(self.child_windows)):

                def on_tab_click():
                    self.active_idx = idx
                    self.__show_active()
                    pf.global_event(EVENT_TOP_TAB_SELECTION_CHANGED,
                                    self.active_idx)

                self.layout_row_push(UI_TAB_BAR_COL_WIDTH)

                if idx == self.active_idx:
                    with btc.ButtonStyle(
                            normal=TabBarWindow.SELECTED_COLOR,
                            hover=TabBarWindow.SELECTED_HOVER_COLOR):
                        self.button_label(self.labels[idx], on_tab_click)
                else:
                    self.button_label(self.labels[idx], on_tab_click)

            self.layout_row_end()
 def __image_button(self, img_normal, img_hover, img_active, action):
     ss = pf.get_simstate()
     with btc.ButtonStyle(normal=img_normal, hover=img_hover, active=img_active):
         if ss == pf.G_RUNNING:
             self.button_label("", action)
         else:
             self.button_label("", lambda: None)
        def settings_tab_group():
            with btc.ButtonStyle(rounding=0.0):

                for idx in range(0, len(self.child_windows)):

                    def on_tab_click():
                        self.active_idx = idx;
                        pf.global_event(EVENT_SETTINGS_TAB_SEL_CHANGED, self.active_idx)

                    self.layout_row_dynamic(40, 1)
                    if idx == self.active_idx:
                        with btc.ButtonStyle(
                            normal=SettingsTabbedWindow.SELECTED_COLOR, 
                            hover=SettingsTabbedWindow.SELECTED_HOVER_COLOR):
                            self.button_label(self.labels[idx], on_tab_click)
                    else:
                        self.button_label(self.labels[idx], on_tab_click)
 def __disabled_button_label(self, label, action):
     button_style = {
         "normal" : ActionPadWindow.DISABLED_BG_COLOR, 
         "hover" : ActionPadWindow.DISABLED_BG_COLOR,
         "active" : ActionPadWindow.DISABLED_BG_COLOR,
         "text_normal" : ActionPadWindow.DISABLED_TEXT_COLOR, 
         "text_hover" : ActionPadWindow.DISABLED_TEXT_COLOR,
         "text_active" : ActionPadWindow.DISABLED_TEXT_COLOR,
     }
     with btc.ButtonStyle(**button_style):
         self.button_label(label, action)
    def update(self):
        with btc.ButtonStyle(padding=(0.0, 0.0), rounding=0.0):

            def on_button_pressed(idx):
                pf.global_event(EVENT_UNIT_ACTION, idx)

            for r in range(0, ACTION_NUM_ROWS):
                self.layout_row_static(ActionPadWindow.BUTTON_WIDTH, ActionPadWindow.BUTTON_WIDTH, ACTION_NUM_COLS)

                for c in range(0, ACTION_NUM_COLS):
                    action = self.actions[r * ACTION_NUM_COLS + c]
                    if action:
                        self.__image_button(
                            img_normal = action.icon_normal, 
                            img_hover = action.icon_hover, 
                            img_active = action.icon_active,
                            action = action.action)
                    else:
                        self.__disabled_button_label("", lambda: None)
Пример #6
0
    def update(self):
        factions_list = pf.get_factions_list()

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

        self.layout_row_static(400, UI_LEFT_PANE_WIDTH - 30, 1)
        self.group("Factions", pf.NK_WINDOW_BORDER, self.factions_group)

        def on_delete_selected():
            pf.global_event(EVENT_DIPLO_FAC_REMOVED,
                            factions_list[self.selected_fac_idx]["id"])

        self.layout_row_dynamic(30, 1)
        if len(factions_list) > 1:
            self.button_label("Delete Selected", on_delete_selected)
        else:  #disabled - We cannot delete the very last faction

            button_style = {
                "normal": DiplomacyTabWindow.DISABLED_BG_COLOR,
                "hover": DiplomacyTabWindow.DISABLED_BG_COLOR,
                "active": DiplomacyTabWindow.DISABLED_BG_COLOR,
                "text_normal": DiplomacyTabWindow.DISABLED_TEXT_COLOR,
                "text_hover": DiplomacyTabWindow.DISABLED_TEXT_COLOR,
                "text_active": DiplomacyTabWindow.DISABLED_TEXT_COLOR
            }
            with btc.ButtonStyle(**button_style):
                self.button_label("Delete Selected", lambda: None)

        self.layout_row_dynamic(10, 1)

        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Faction Name:", (255, 255, 255))
        self.layout_row_dynamic(30, 1)
        self.fac_name = self.edit_string(pf.NK_EDIT_SIMPLE, self.fac_name)

        self.layout_row_dynamic(20, 1)
        self.label_colored_wrap("Faction Color:", (255, 255, 255))
        self.layout_row_dynamic(30, 1)
        self.fac_color = self.color_picker(self.fac_color,
                                           (UI_LEFT_PANE_WIDTH - 30, 120))

        self.layout_row_dynamic(10, 1)

        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_new_fac():
            pf.global_event(EVENT_DIPLO_FAC_NEW,
                            (self.fac_name, self.fac_color))

        if len(self.fac_name) > 0:
            self.layout_row_dynamic(30, 1)
            self.button_label("Update Selected", on_update_fac)
            self.layout_row_dynamic(30, 1)
            self.button_label("Add New Faction", on_new_fac)
        else:  #disabled - Can't update name to empty string
            button_style = {
                "normal": DiplomacyTabWindow.DISABLED_BG_COLOR,
                "hover": DiplomacyTabWindow.DISABLED_BG_COLOR,
                "active": DiplomacyTabWindow.DISABLED_BG_COLOR,
                "text_normal": DiplomacyTabWindow.DISABLED_TEXT_COLOR,
                "text_hover": DiplomacyTabWindow.DISABLED_TEXT_COLOR,
                "text_active": DiplomacyTabWindow.DISABLED_TEXT_COLOR
            }
            with btc.ButtonStyle(**button_style):
                self.layout_row_dynamic(30, 1)
                self.button_label("Update Selected", lambda: None)
                self.layout_row_dynamic(30, 1)
                self.button_label("Add New Faction", lambda: None)