GSOC Day 4 – Icons and Type Differentiation


This post is about yesterday’s work – it was late when I finished, so I put the write-up off until today.

I continued to work on fixing bugs in tpclient-pywx today, starting with the problem of Overlay.py using the old method of determining object types (there were set object types in tp03, so you could just do something like: if isinstance(obj, Universe)). Since set object types no longer exist, I had to get creative to figure out which objects are worth drawing. I had to filter out the universe and all galaxies.


Filtering out the Universe object was fairly simple – it will always have an ID of 0. Galaxies will always have the Universe as their parent, so those should be simple as well, right? Wrong. Fleets can also have the universe as their parent, so I had to differentiate between galaxies and fleets.

The answer I came up with:

# If the object doesn't have a "Ship List" property, it's probably a galaxy.
for propertygroup in obj.properties:
	positionattrsstruct = getattr(obj, propertygroup.name)
	if not hasattr(positionattrsstruct, 'Ship List'):
		self[oid] = []
		return

This seems to work for now, although I have the feeling I’ll find more complications later.

The next problem was that the Icon drawing methods in Systems.py were out of date. They still used the old methods of finding position and of determining object type. It will be difficult to figure out all object types in that code, so in the future, objects will probably need to specify how to draw themselves. For now, however, I was able to separate the drawing of fleets from the drawing of everything else, and that will do for the moment.

The good news? With those bugs fixed, the client finally draws something on the starmap again! Screenshot:

This is probably a good time to interject about a tool I just started using, git-cl. Git-cl is a wrapper for the Rietveld code review tool from Google. It allows submission of Git branches and commits for review, so that others can comment on them before they’re pushed as a final version. It is a nice, easy way to see code changes and get feedback.

For example, I’ve been working on this patch.

My next task for the day was to fix the object description popups. They were still using the old method of getting ship lists from fleets, so I had to replace that with searching through the properties to find the ship list.

I realized while doing this that the Generic Reference System (which takes a number, like 9, and tells you what type of object this reference is to, such as “Design”) was out of date – it was missing 8: Category and 9: Design. I added these, and then fixed the ship listing. Screenshot:

The popup now shows ships in fleets.

Tomorrow, the error-fixing saga continues!

Advertisements

~ by greywhind on May 27, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: