Dicecord Project Update 2

Welcome to Update 2 of the Dicecord project. This weekend I completed all goals I set out in the last update. I made the Square object, added it as a rote marker, added in a derived stats section and added in a bunch of the major stats that use a larger dot. As always, the latest code can be found here. Below is an example of how the sheet looks right now.

Current version of sheet

Current version of sheet

Square Object

The Square object is another abstract button like the dot but with some different behaviors depending on the context used.

The square in front of the skills marks whether the skills are favored for casting rote spells; when activated it puts a mark through the box and adds the skill to a list contained within the character object. When clicked again it will remove the strike.

The squares in the beats and willpower sections are similar to the dots: clicking one fills in everything up to and including the clicked square; updating a stat in the character object as it does so.

The Health square is special and has not been fully coded at this time. This one cycles through four states that represents different types of damage: undamaged, bashing, lethal and aggravated. In the current implementation it will draw the different states on initiation but as yet the logic to change them has not been coded.

Examples of different square types.

Examples of different square types.

Derived Stats and XP

The Derived Stats and XP section sits at the bottom of the middle row. The derived stats specifically are Speed, Defense and Initiative. These stats are calculated based on your other stats. In the current implementation they will update as soon as you disable edit mode. Later I will see if I can have them update as soon as a stat is changed in order to highlight to a user how a build affects these stats.

In addition, I added a “modifier” column to each derived stat which isn’t in the default character sheet. Users will be able to use this to record modifications to the stat, for example if your character has an item that increases their defense you can add the bonus here.

One difference between this section and others is that edit mode does not need to be active to change content here. Beats can be added, modifications can be recorded and xp can be logged at will. These changes are more temporary in nature so I decided to have them changed easier than other parts of the character.

One extra feature here that I plan to add elsewhere are tooltips. When you hover over the derived stat names the cursor changes and after a second or so a tooltip will appear telling you what the calculation is for the stat. I’m going to add this feature to merits and have users record details of the merit when creating it, these details will appear when hovering over the label. I’ll also use it to display any specialties a user has associated with a skill.

Hover example

Hover example

Wisdom, Gnosis and Willpower

I created the big dot object for Wisdom, Gnosis and Willpower. This has a radius of about 10 pixels versus the normal dot’s 6. I feel like this is a bit too big though and later I will look into using a smaller dot. Wisdom and Gnosis, like Arcana, are unique to mages. When I start adding in other Chronicles of Darkness games I will need to make these sections have different names and content.

Removing Ratings

While previously we had the ability to set the rating of a skill, what was missing was the ability to set it back to 0. This was because my button click events were set to fill in content up to and including the clicked dot/square. In order to allow for the removal of dots I changed the click event to check what the last clicked item was, if the same item is clicked twice then it will empty it. For example, if I click dot 3 twice, the first click will fill all up to and including the 3rd dot, the second click will fill only the first two. If performing this action on the first dot, the second click will result in no filled dots.

Cursor Changing

As a quick bonus I added in a cursor change when hovering over any dot or square. When hovering over them your cursor will change to a hand icon indicating that a click action can be performed. I might look into having this only occur when edit mode is active, but it seems like this might be quite complex.

General Musings

I mentioned last week that PYQt’s habit of force closing when an error occurs was causing issues. This week I figured out that the Python debugger can be used to get around this issue. I merely set a break point shortly before where I think the error is and keep stepping until the full error shows in the debugger.

The Layout is starting to be a bit mismatched. This is due to how I have some single widgets spanning multiple columns/rows in the QT grid layout I’m using. Once the sheet has all its contents I will look into doing a full UI pass to make things line up better.

In the derived stats section, the underlined number was surprisingly complex to do. I had hoped I could just add a bottom border but actually I had to create a new form of label that includes a paint event to draw a line close to the bottom of the widget. I saw a lot of blogs that talked generally about this approach but none with any code samples. On the off-chance that someone else happens upon this blog trying to solve that problem I’ll include the code below. Later on I’ll make a quick tutorial explaining the solution in more detail.

class Num_with_Line(QWidget):
    '''
    A Label with a line under it.
    '''
    def __init__(self, text):
        super().__init__()
        self.text = text
        #maximum size hard coded, need to change on a later pass
        self.setMaximumWidth(15)
        self.setMaximumHeight(15)
        self.initUI()
        
        
    def initUI(self):      
        self.grid = QGridLayout()
        self.grid.setSpacing(0)
        self.grid.setContentsMargins(0,0,0,0)
        self.setLayout(self.grid)
        
        self.rating = QLabel(self.text)
        self.rating.setAlignment(Qt.AlignCenter)
        
        self.grid.addWidget(self.rating,0,0)
        

    def paintEvent(self, event):
        qp = QPainter()
        qp.begin(self)
        self.drawLine(qp)
        qp.end()

    def drawLine(self, qp):
        size = self.size()
        qp.setPen(Qt.black)
        qp.drawLine(0,size.height()-1,size.width(),size.height()-1)

    def change_text(self, new_text):
        self.text = new_text
        self.rating.setText(new_text)
        self.update()

Goals for Next Week

  • Finish the health object. It needs to be possible to click-through to add damage and have the damage record changed on the character object.
  • Add a mana object. I’m going to approach this like the derived stats with two boxes: one is a modifier to add to your pool and the other is the amount of spent mana.
  • Add a hover action for merits that displays user written explanations about them in a tooltip.
  • Add the ability to add specialties to a skill. This will change the skill label’s font slightly and add a hover action that displays the specialty in a tooltip.
  • Add in Obsessions, Aspirations, Conditions and Tilts. I am going to approach these like the merits where the sheet will just have the name for each entry and you hover over it to see details.
  • At that point all the standard sheet content will be entered. If I have extra time I will start a UI pass.
This entry was posted in Dicecord, Python and tagged , , . Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.