Developer Store
Support
Member Forums

Screenshots
FAQ
Documentation
License
Known Issues
Downloads

MMOWorkshop.com Store Opened!
Torque MMO Kit - Open Sourced!
Torque MMO Kit - 1.5.2 Port Alpha Test
Torque MMO Kit - OSX Status

GarageGames.com irc.prairiegames.com
#mmoworkshop

PyTorque
TGB Web Browser


karvermimic

hallsofvalhalla - After a long epiphany
Leathel - FoHO pre-Alpha 2.42
OldRod - More Musings on the MMO Industry
xapken - nice
J.C. Smith - 0.0.4.1 Build Notes
Wolf Dreamer - Pointless blog of pointless things
AthlonJedi2 - Server Nuked !!!!!
gamer_goof - New character model GIRL1 available only $4
... MORE BLOGS!

My other project
A Message to all the new people.
MyGame
changing the primary class
See Ya Classes, Hello Skills!
XP Based Skills
fxFoliageReplicator zone loading...
Is it just me, or is it slow in ...
Places where NPC quest-givers ha...
TalentRaspel Grid

Introductions

Xerves here again for some more GUI fun. This time we are going to make modifications to the Item Information Window. I am going to go over a short list of changes and how to do them. If you have anything to add please feel free to add more information to this document if you wish.

In trying to keep this short and less wordy, any changes to the code in the code blocks will have #<<<< after it (a comment with <<<<).

Name to the Title of the Window

This is a very basic change, but it can be used to get rid of some space in the window by moving the name to the Title Bar of the window. To make these changes open up the following file:

mud/client/gui/itemInfoWnd.py

In order to do this we need to make 3 simple modifications. In the class function setSpell you need to make the following change:

        eval = r'ItemInfoWnd_NameText.setText("%s");'%(TEXT_BIG_HEADER+sinfo.NAME)
        TGEEval(eval)
        eval = 'ItemInfoWnd_Window.setText("%s");'%(sinfo.NAME) #<<<<
        TGEEval(eval) #<<<<
        eval = 'ItemInfoWnd_FlagsText.setText("");'
        TGEEval(eval)
        eval = 'ItemInfoWnd_InfoText.setText("%s");'%(TEXT_HEADER+sinfo.text)
        TGEEval(eval)

This sets the Name for the spell that is hovered on. Next 2 changes to the item function of setItem:

            eval = 'ItemInfoWnd_FlagsText.setText("%s%s");'%(TEXT_HEADER,text)
            TGEEval(eval)

            eval = 'ItemInfoWnd_Window.setText("%s");'%(ghost.NAME) #<<<<
            TGEEval(eval) #<<<<
            
            eval = 'ItemInfoWnd_NameText.setText("%s%s");'%(TEXT_BIG_HEADER,ghost.NAME)
            TGEEval(eval)
            
            eval = 'ItemInfoWnd_InfoText.setText("%s%s");'%(TEXT_HEADER,ghost.text)
            TGEEval(eval)

Just a bit more down the page find the following:

        else:
            eval = 'ItemInfoWnd_NameText.setText("");'
            TGEEval(eval)
            eval = 'ItemInfoWnd_FlagsText.setText("");'
            TGEEval(eval)
            eval = 'ItemInfoWnd_Window.setText("Information");' #<<<<
            TGEEval(eval) #<<<<
            eval = 'ItemInfoWnd_InfoText.setText("");'
            TGEEval(eval)

These changes will make it possible to display the Name of the item in the title. The 2nd bit of code puts the Window Title back to Information when there is no object present.

Removing the old name Field

1. Alright you now have the name in the title. Time to get rid of the field. You need to remove it from the code first. The easiest thing to do is stay in itemInfoWnd.py and do a search for Iteminfownd_NameText. You should find 4 entries (1 has a comment in front of it). Delete those lines along with the TGEEval call directly after it (you will notice all 3 references are posted above).

2. Once this is done you can delete the field from the actual GUI. To do this load up the game through the IDE and hit Ctrl+F10. Click on the middle button near the top and choose itemInfoWnd.

3. In the upper right hand corner you will see a list of items in the GUI. Keep drilling down and choose the very last item (guiControl) and it should have a itemInfoWnd nameText Field in it. Click on it and delete it. Also delete the guiControl container it was in with it.

4. Once you are done save the file using the File Menu.

Adjusting the location/size of the GUI

I am not going to go into detail here. Follow Step 2 above and open up the itemInfoWnd. Simply start moving things around and resizing them to what you need. You can adjust the image and move it to where you want. I did 50x50 pixels and put it in the upper right hand corner and placed the flags to the left and used the rest of the window for the Text.

Alignment

Alignment is controlled by these statements near the top of the itemInfoWnd.py file

TEXT_BIG_HEADER = """<font:Arial Bold:16><just:center><shadow:1:1><shadowcolor:000000>"""
TEXT_HEADER = """<font:Arial Bold:14><just:center><shadow:1:1><shadowcolor:000000>"""

You can remove the center justifications from here if you want. Check further down the code and you will notice that these headers are also used on the party window where the name displays below the picture. You might want that centered, so you will need to make some modifications so only the parts you want aligned to the left (or you might want to leave it center aligned, up to you).

Adding new values to the Item Info Screen

I decided to add new values for damage and tohit. I am going to use these as an example on how to pass this information back to the player. It is rather simple actually, just follow these directions:

1. Open up the following file:

mud/world/shared/playdata.py

You will need to add the entries to the getFullState function inside of the itemInfo class. Here is the example of mine:

        state['DAMSIZEDIE'] = item.itemProto.DamSizeDie
        state['DAMNUMDIE'] = item.itemProto.DamNumDie
        state['DAMPLUS'] = item.itemProto.DamPlus
        state['WEAPONTOHITSLASH'] = item.itemProto.weapontohitSlash
        state['WEAPONTOHITSTAB'] = item.itemProto.weapontohitStab
        state['WEAPONTOHITBASH'] = item.itemProto.weapontohitBash
        state['ARMORTOHITSLASH'] = item.itemProto.armortohitSlash
        state['ARMORTOHITSTAB'] = item.itemProto.armortohitStab
        state['ARMORTOHITBASH'] = item.itemProto.armortohitBash

In this example my values are currently setting in the Proto class for the item (what is assigned during creation) and not passed to the running item yet. It will store this value into the state so it can be accessed by the client.

2. You now need to modify the Text field that is passed to the window. In the same file find the iteminfoghost class and inside the generateItemText function is where you need to make your changes. Here is an example of the changes I made for the damage:

        # Weapon Desc
        if self.WPNRATE or self.DAMNUMDIE:
            if self.WPNRATE:
                text.append(r'\c3Speed: \c2%-15.1f'%(self.WPNRATE/10.0))
            if self.DAMNUMDIE:
                text.append(r'\c3Damage: \c2%dd%d+%d'%(self.DAMNUMDIE, self.DAMSIZEDIE, self.DAMPLUS))
            text.append(r'\n')

You will notice that the values I put into state above are what I am using here. So I am specifying Damage here. Please see the next section for what all that formatting code means!

Formatting and Color

We are going to examine this bit of code:

text.append(r'\c3Speed: \c2%-15.1f'%(self.WPNRATE/10.0))

It might look out of control, but it is very easy actually.

/c3 - Color code (White)
/c2 - Color code (Green)
/c1 - Color code (Red)
/c4 - Color code (Yellow)
/c0 - Color code (Light Grey)
%-15.1f - Floating value (the f).  Other options are s (string) i (integer) d (digit)
%-15.1f - %-15 represents 15 characters reserved beginning at the left side.  Ex "Testing        "
%-15.1f - .1 represents how many decimals to display.  so .1 would be 15.2, .2 would be 15.25, etc
%(self.WPNRATE/10.0) - Passed value to %-15.1f.  In this case my WPNRATE divided by 10.0

Also this bit for more reinforcement

text.append(r'\c3Damage: \c2%dd%d+%d'%(self.DAMNUMDIE, self.DAMSIZEDIE, self.DAMPLUS))

Breaking it down

\c2 - Color code
\c3 - Color code
%dd%d+%d'% - (DAMNUMDIE)d(DAMSIZEDIE)+(DAMPLUS)
%(self.DAMNUMDIE, self.DAMSIZEDIE, self.DAMPLUS) - 3 values passed to the %d values

Final little bit here:

text.append(r'\n')

Simple enough...

\n - New line (escape sequence for a new line is this value)
text.append(r'\n') - The r I believe is telling it to ignore escape sequences...as noticed by \\n used when the r is not present....

Changing the Order of information on the itemInfo Screen

I am not going to go into great detail, but all of this information is in the generateItemText class mentioned earlier in the playdata.py file. You will see all the values in the function for the Level, Range, Damage, Stats, etc. You will need to modify the code there and arrange it how you like.