Пример #1
0
    def warn_about_refund(self):
        form = self.form
        settings = L5RCMSettings()

        if not settings.app.warn_about_refund:
            return True

        msgBox = QtWidgets.QMessageBox(form)
        msgBox.setWindowTitle('L5R: CM')
        msgBox.setText(self.tr("Advancements refund."))
        msgBox.setInformativeText(
            self.tr(
                "If this advancement is required from other ones\n"
                "removing it might lean to incoherences in your character.\n"
                "Continue anyway?"))

        do_not_prompt_again = QtWidgets.QCheckBox(
            self.tr("Do not prompt again"), msgBox)
        # PREVENT MSGBOX TO CLOSE ON CLICK
        do_not_prompt_again.blockSignals(True)
        msgBox.addButton(QtWidgets.QMessageBox.Yes)
        msgBox.addButton(QtWidgets.QMessageBox.No)
        msgBox.addButton(do_not_prompt_again, QtWidgets.QMessageBox.ActionRole)
        msgBox.setDefaultButton(QtWidgets.QMessageBox.No)
        result = msgBox.exec_()
        if do_not_prompt_again.checkState() == QtCore.Qt.Checked:
            settings.app.warn_about_refund = False
        if result == QtWidgets.QMessageBox.Yes:
            return True
        return False
Пример #2
0
    def __init__(self, type_, parent=None):
        super(WeaponTableViewModel, self).__init__(parent)
        self.type = type_
        self.items = []
        if type_ == 'melee':
            self.headers = [
                self.tr('Name'),
                self.tr('DR'),
                self.tr('Sec. DR'),
                self.tr('ATK Roll'),
                self.tr('Mod. ATK Roll'),
                self.tr('DMG Roll'),
                self.tr('Mod. DMG Roll')
            ]
        elif type_ == 'ranged':
            self.headers = [
                self.tr('Name'),
                self.tr('Range'),
                self.tr('Strength'),
                self.tr('Min. Str.'),
                self.tr('ATK Roll'),
                self.tr('Mod. ATK Roll')
            ]
        elif type_ == 'arrow':
            self.headers = [
                self.tr('Name'),
                self.tr('DR'),
                self.tr('Quantity')
            ]

        self.settings = L5RCMSettings()
    def __init__(self, parent=None):
        super(MaViewModel, self).__init__(parent)

        self.items = []
        self.headers = [self.tr('Skill'), self.tr('Rank'), self.tr('Effect')]

        self.settings = L5RCMSettings()
Пример #4
0
    def update_data_blacklist(self):

        api.data.set_blacklist(
            [x.id for x in self.dstore.packs if not x.active])

        settings = L5RCMSettings()
        settings.app.data_pack_blacklist = api.data.get_blacklist()
Пример #5
0
    def __init__(self, parent=None):
        super(DataPackModel, self).__init__(parent)
        self.items = []
        self.headers = [self.tr('Name'),
                        self.tr('Language'),
                        self.tr('Version'),
                        self.tr('Authors')]

        self.settings = L5RCMSettings()
Пример #6
0
    def __init__(self, type_, parent=None):
        super(PerkViewModel, self).__init__(parent)

        self.items = []

        self.headers = [self.tr('Name'), self.tr('Rank'), self.tr('Value')]

        self.type = type_
        self.settings = L5RCMSettings()
Пример #7
0
    def reload_data(self):
        settings = L5RCMSettings()

        api.data.set_locale(self.locale)
        api.data.set_blacklist(settings.app.data_pack_blacklist)
        api.data.reload()

        # assign Data storage reference, for backward compatibility
        self.dstore = api.data.model()
Пример #8
0
    def __init__(self, parent=None):
        super(KihoTableViewModel, self).__init__(parent)

        self.items = []
        self.headers = [
            self.tr('Name'),
            self.tr('Mastery'),
            self.tr('Element')]

        self.settings = L5RCMSettings()
Пример #9
0
    def __init__(self, parent=None):
        super(EquipmentListModel, self).__init__(parent)

        self.school_outfit = []
        self.items = []
        self.settings = L5RCMSettings()

        self.bold_font = None
        if self.parent:
            self.bold_font = parent.font()
            self.bold_font.setBold(True)
    def __init__(self, parent=None):
        super(TechViewModel, self).__init__(parent)

        self.items = []
        self.headers = [
            self.tr('Rank'),
            self.tr('School'),
            self.tr('School Rank'),
            self.tr('Name')
        ]

        self.settings = L5RCMSettings()
    def __init__(self, parent=None):
        super(ModifiersTableViewModel, self).__init__(parent)

        self.items = []
        self.headers = [
            self.tr('Modifies'),
            self.tr('Detail'),
            self.tr('Value'),
            self.tr('Reason')]

        self.dirty = False
        self.settings = L5RCMSettings()
Пример #12
0
    def __init__(self, parent=None):
        super(AdvancementViewModel, self).__init__(parent)

        self.items = []
        self.headers = [
            self.tr('Tag'),
            self.tr('Cost'),
            self.tr('Text'),
            self.tr('Timestamp')
        ]

        self.settings = L5RCMSettings()
    def __init__(self, parent=None):
        super(SkillTableViewModel, self).__init__(parent)

        self.items = []
        self.headers = [
            self.tr('Name'),
            self.tr('Rank'),
            self.tr('Trait'),
            self.tr('Base Roll'),
            self.tr('Mod Roll'),
            self.tr('Emphases')
        ]

        self.settings = L5RCMSettings()
        if parent:
            self.bold_font = parent.font()
            self.bold_font.setBold(True)
    def __init__(self, parent=None):
        super(SpellTableViewModel, self).__init__(parent)

        self.items = []
        self.headers = [
            self.tr('Name'),
            self.tr('Ring'),
            self.tr('Mastery'),
            self.tr('Range'),
            self.tr('Area of Effect'),
            self.tr('Duration'),
            self.tr('Raises')
        ]

        self.settings = L5RCMSettings()
        if parent:
            self.bold_font = parent.font()
            self.bold_font.setBold(True)

        self.memo_icon = QtGui.QIcon(get_icon_path('book', (16, 16)))
Пример #15
0
    def open_image_dialog(self):
        supported_ext = ['.png']
        supported_filters = [self.tr("PNG Images (*.png)")]

        settings = L5RCMSettings()
        last_data_dir = settings.app.last_open_image_dir

        fileName = QtWidgets.QFileDialog.getOpenFileName(
            self.form, self.tr("Open image"), last_data_dir,
            ";;".join(supported_filters))

        if not fileName:
            return None

        if type(fileName) is tuple:
            fileName = fileName[0]

        if fileName:
            settings.app.last_open_image_dir = os.path.dirname(fileName)
        return fileName
Пример #16
0
 def __init__(self, parent=None):
     super(ColorFriendlySortProxyModel, self).__init__(parent)
     self.settings = L5RCMSettings()
    def export_body(self, io):
        m = self.model
        f = self.form

        fields = {
            'NAME': m.name,
            'CLAN': self.get_clan_name(),
            'RANK': api.character.insight_rank(),
            'FAMILY': self.get_family_name(),
            'SCHOOL': self.get_school_name(),
            'EXP': self.get_exp(),
            'INSIGHT': api.character.insight()
        }

        # TRAITS AND RINGS
        for i in range(0, 8):
            trait_nm = models.attrib_name_from_id(i)
            fields[trait_nm.upper()] = api.character.modified_trait_rank(
                trait_nm)
        for i in range(0, 5):
            ring_nm = models.ring_name_from_id(i)
            fields[ring_nm.upper()] = api.character.ring_rank(ring_nm)

        # HONOR, GLORY, STATUS, TAINT
        hvalue, hdots = api.rules.split_decimal(api.character.honor())
        gvalue, gdots = api.rules.split_decimal(api.character.glory())
        svalue, sdots = api.rules.split_decimal(api.character.status())
        tvalue, tdots = api.rules.split_decimal(api.character.taint())

        fields['HONOR'] = hvalue
        fields['GLORY'] = gvalue
        fields['STATUS'] = svalue
        fields['TAINT'] = tvalue

        for i in range(1, int(hdots * 10) + 1):
            fields['HONOR_DOT.%d' % i] = True

        for i in range(1, int(gdots * 10) + 1):
            fields['GLORY_DOT.%d' % i] = True

        for i in range(1, int(sdots * 10) + 1):
            fields['STATUS_DOT.%d' % i] = True

        for i in range(1, int(tdots * 10) + 1):
            fields['TAINT_DOT.%d' % i] = True

        # INITIATIVE
        fields['INITIATIVE_BASE'] = f.tx_base_init.text()
        fields['INITIATIVE_MOD'] = f.tx_mod_init.text()
        fields['INITIATIVE_CUR'] = f.tx_cur_init.text()

        # TN / RD
        fields['TN_BASE'] = api.character.get_base_tn()
        fields['TN_CUR'] = api.character.get_full_tn()
        fields['BASE_RD'] = api.character.get_base_rd()
        fields['CUR_RD'] = api.character.get_full_rd()

        # ARMOR
        fields['ARMOR_TYPE'] = api.character.get_armor_name()
        fields['ARMOR_TN'] = api.character.get_armor_tn()
        fields['ARMOR_RD'] = api.character.get_armor_rd()
        fields['ARMOR_NOTES'] = api.character.get_armor_desc()

        # WOUNDS
        w_labels = [
            'HEALTHY', 'NICKED', 'GRAZED', 'HURT', 'INJURED', 'CRIPPLED',
            'DOWN', 'OUT'
        ]

        settings = L5RCMSettings()
        method = settings.app.health_method

        wounds_table = api.rules.get_wounds_table()
        for i, (i_inc, i_total, i_stacked, _inc_wounds, _total_wounds,
                _stacked_wounds) in enumerate(wounds_table):
            if method == 'default':
                value = i_inc
            elif method == 'wounds':
                value = i_stacked
            else:
                value = i_total
            fields[w_labels[i]] = str(value) if value else ''

        fields['WOUND_HEAL_BASE'] = api.rules.get_wound_heal_rate()
        fields['WOUND_HEAL_CUR'] = fields['WOUND_HEAL_BASE']

        # MERITS AND FLAWS
        merits = f.merits_view_model.items
        flaws = f.flaws_view_model.items

        count = min(17, len(merits))
        for i in range(1, count + 1):
            merit = merits[i - 1]
            fields['ADVANTAGE_NM.%d' % i] = merit.name
            fields['ADVANTAGE_PT.%d' % i] = abs(merit.cost)

        count = min(17, len(flaws))
        for i in range(1, count + 1):
            flaw = flaws[i - 1]
            fields['DISADVANTAGE_NM.%d' % i] = flaw.name
            fields['DISADVANTAGE_PT.%d' % i] = abs(flaw.cost)

        # WEAPONS
        melee_weapons = f.melee_view_model.items
        range_weapons = [
            x for x in f.ranged_view_model.items if 'melee' not in x.tags
        ]
        wl = zigzag(melee_weapons, range_weapons)

        count = min(2, len(wl))
        for i in range(1, count + 1):
            weap = wl[i - 1]
            fields['WEAP_TYPE.%d' % i] = weap.name
            if weap.base_atk != weap.max_atk:
                fields['WEAP_ATK.%d' % i] = weap.base_atk + "/" + weap.max_atk
            else:
                fields['WEAP_ATK.%d' % i] = weap.base_atk
            if weap.base_dmg != weap.max_dmg:
                fields['WEAP_DMG.%d' % i] = weap.base_dmg + "/" + weap.max_dmg
            else:
                fields['WEAP_DMG.%d' % i] = weap.base_dmg
            fields['WEAP_NOTES.%d' % i] = weap.desc

        # ARROWS
        arrows = f.arrow_view_model.items
        count = min(5, len(arrows))
        for i in range(1, count + 1):
            ar = arrows[i - 1]
            fields['ARROW_TYPE.%d' % i] = ar.name.replace('Arrow', '')
            fields['ARROW_DMG.%d' % i] = ar.dr
            fields['ARROW_QTY.%d' % i] = ar.qty

        # PERSONAL INFORMATIONS
        fields['GENDER'] = m.get_property('sex')
        fields['AGE'] = m.get_property('age')
        fields['HEIGHT'] = m.get_property('height')
        fields['WEIGHT'] = m.get_property('weight')
        fields['HAIR'] = m.get_property('hair')
        fields['EYES'] = m.get_property('eyes')
        fields['FATHER'] = m.get_property('father')
        fields['MOTHER'] = m.get_property('mother')
        fields['BROTHERS'] = m.get_property('brothers')
        fields['SISTERS'] = m.get_property('sisters')
        fields['MARITAL STATUS'] = m.get_property('marsta')
        fields['SPOUSE'] = m.get_property('spouse')

        if m.get_property('childr'):
            chrows = m.get_property('childr').split('\n\r')
            for i in range(0, len(chrows)):
                fields['CHILDREN.%d' % (i + 1)] = chrows[i]

        # EQUIPMENT
        starting_outfit_ = []
        first_rank_ = api.character.rankadv.get_first()
        if first_rank_:
            starting_outfit_ = first_rank_.outfit

        equip_list = starting_outfit_ + m.get_property('equip', [])
        equip_num = min(50, len(equip_list))
        equip_cols = [18, 18, 15]
        c = 0
        for i in range(0, len(equip_cols)):
            for j in range(0, equip_cols[i]):
                if c < equip_num:
                    fields['EQUIP_LINE.{0}.{1}'.format(j, i)] = equip_list[c]
                    c += 1

        # MONEY
        money = api.character.get_money()
        if money and len(money) == 3:
            fields['KOKU'] = str(money[0])
            fields['BU'] = str(money[1])
            fields['ZENI'] = str(money[2])

        # MISC
        misc = f.tx_pc_notes.get_plain_text()
        fields['MISCELLANEOUS'] = misc

        # SKILLS
        if settings.pc_export.first_page_skills:
            skills = f.sk_view_model.items
            if self.skill_offset > 0:
                skills = skills[self.skill_offset:]

            sorted_skills = sorted(skills,
                                   key=lambda x:
                                   (not x.is_school, -x.rank, x.name))
            for i, sk in enumerate(sorted_skills):
                j = i + 1
                if i >= self.skills_per_page:
                    break

                fields['SKILL_IS_SCHOOL.%d' % j] = sk.is_school
                fields['SKILL_NAME.%d' % j] = sk.name
                fields['SKILL_RANK.%d' % j] = sk.rank
                fields['SKILL_TRAIT.%d' % j] = sk.trait
                fields['SKILL_ROLL.%d' % j] = sk.mod_roll
                fields['SKILL_EMPH_MA.%d' % j] = ', '.join(sk.emph)

        # EXPORT FIELDS
        for k in fields:
            self.export_field(k, fields[k], io)
Пример #18
0
    def on_toggle_display_banner(self):
        settings = L5RCMSettings()
        settings.ui.banner_enabled = not settings.ui.banner_enabled

        self.set_banner_visibility(settings.ui.banner_enabled)