Some Firefox v3.5 bug filled

Been a while since I blogged and as well worked on anything open source due to my job.

As a web developer, I been testing out some of the new CSS3 features of Firefox v3.5. Found some minor bugs, no biggie, but would hopefully be fixed. I wonder if I will have time to really look into them.

Fieldset does not support border-radius propertyhttps://bugzilla.mozilla.org/show_bug.cgi?id=512966

Text-shadow blur and underline messes up with padding-left – https://bugzilla.mozilla.org/show_bug.cgi?id=512988

EDIT: Seems Firefox v3.5 never had border-radius added in so my bug wasn’t a bug. I could of sworn I saw it in the list of added features.

Starting off Chomper

I actually been working on Chomper piece by piece for a while. I didn’t bother posting a bunch of posts but gather it all into like “Milestones” stages.

I am starting fresh. While I have the old “working” project, I didn’t want to just cut and paste the old code into the project because I wanted to…

  • understand everything again
  • optimize the code to be better structured (as I had 2 months to make that game before)

Here are some points of the current progress.

Start of the new project

I used the MFC wizard to create the base application of Chomper. I decided to use the Visual Studio theme because it looks clean and nice. Other than the extra options on the wizard nothing much is different like the 1st time I used it with the original game.

Disabling Dockable Tool Bars

I had a problem with disabling the docking ability of the tool bars. In the code it had the following…

// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndToolBar);

Sounds simple right? But commenting those 5 lines screws up the tool bar entirely! So that comment was not useful at all.

The solution was to just comment the first two lines and then the tool bars will be docked.

Disabling the registry

Another “feature” I wanted to disable was the writing to the registry. The reason why I don’t like using the registry is that

  1. This is a game. Not a program that will be used throughout the system.
  2. I prefer the settings to be in a file so that is easier for people to back up. Try telling a newbie how to backup the registry or worse backup up a specific “key” and watch them screw up their computer.
  3. There is a convenient place where each users settings are stored (C:\Documents and Settings\<USER>\Application Data\ by default)

Now I know which line does it. And that’s this…

SetRegistryKey(_T("Local AppWizard-Generated Applications"));

In my previous MFC applications, all I do is comment this line and all is well. However, not for Feature Pack though. Comment this line and you will get an assertion error. The reason I believe is because of the customizable “Workspace” feature. If you check the registry you will see that there is additional entries that store the information like the position of the window when closed, position of the tool bars, customized look, etc. On run, it has to read these entries and on exit, it saves them. Unfortunately, the new code expects them. So it is most likely hard coded to look into the registry and without the key, it fails. I have yet to disable this. I think I will have to overload the functions so that it doesn’t look into the registry. *sigh*

Additional Disabling “Features”

There are more things I disabled. Like the ability to go to the “Customize” tool bar window and such. They are easily layed out so I guess I won’t need to point them out.

Game Loop

I decided to look for a better game loop. Like I said in the previous post, the OnTimer is sufficient for a game like Pac-Man. But I wanted something that is more similar to the game loops used in DirectX games and such. I found an article that points it out.

http://www.gamedev.net/reference/articles/article2204.asp

It sums up everything pretty nicely. It overrides the Run() method, which is the message loop.

The problem however is that it uses 100% of a CPU core! This is not good for a game like Pac-Man which doesn’t even require full load of the CPU. Worse if you plan to play this on a laptop and drains your battery. The only solution, I have found is to use the Sleep function which sleeps the thread.

The New Implementation

So now I got a base application ready to go. I start to implement the features of my game. Since I am starting fresh the first thing I do are the following…

  • I added a StateManager Class to handle the states of Main Menu, Game Play, Game Over, Pause and Menu. This makes it MUCH easier to handle the various “modes of play” by just making a class for each state.
  • I make a BackBuffer Class to handle the Bliting instead of putting it in the actual frame animation method that I did before.
  • The new player class is now much more cleaner as before I put many things in the Draw() method (basically all the animations and such).

So far all is going well. When I have more free time, I will work on it again.

MFC + C++ 2008 Feature Pack Overview

Like I said in my previous MFC post, I will be using the new features found in Visual Studio 2008 and the new C++ 2008 Feature Pack. The C++ 2008 Feature Pack added many new MFC features and TR1 (adding many new C++ features). I actually have been playing around with it for quite a while (just the MFC part). I haven’t used any of the TR1 features yet.

To download the 2008 Feature pack is here. The thing is I forgot to install the Windows SDK BEFORE the Feature Pack which now requires me to repair VS2008 to just install the SDK since MS didn’t put any checking in their installers as it overwrites it :/ Just a note for people who are planning to install the Windows SDK.

This Feature Pack will most likely be included in the Service Pack 1 (SP1) release of Visual Studio 2008.

These new MFC features were actually bought out from a company that makes MFC components called BCGSoft. So it was nice of Microsoft to just give this to everyone for free.

Now for a brief talk about the features it bring to MFC. A feature that most people will like is the new visual themes that let you mimic the Visual Studio and Office suites. The docking manager like in Visual Studio is also another nice feature. As well the much loved/hated ribbon found in Office 2007 is also available. Plus there are many more which I haven’t tried yet.

There are bunch of new sample applications also included (found in C:\Program Files\Microsoft Visual Studio 9.0\Samples\1033). Useful because there is almost NO tutorials or books on MFC anymore. The MSDN website has all the help documents though but there is nothing like walking through an application to see how to put it all together. Various sample applications are available such as Windows Explorer, Visual Studio, Outlook, MS Money, Word and even Internet Explorer. Other examples include like making a those nice Alert windows like from MSN Messenger and shows some customization, like a customized tooltip. I don’t know how to make a customized “theme” but I’m sure it is possible.

That’s pretty much all I have to say about. All in all, this is nice addition to Visual Studio.

Whee! Got a Web Dev job!

Was going to post this yesterday but I finally got myself a web development job. It is a junior position working at The Score Television Network. I can’t wait to start 😀

Re-doing Pac-Man

Since I currently have free time (still looking for a job), I decided to redo my GUI546 project which was a Pac-Man clone (which is available at my portfolio).

First of all, Why? Well first of all the original project was basically to have it finished in 2 months (the other 2 months were porting it to Managed C++ which I dreaded). At that time, MFC was totally new to me. There wasn’t much help online-wise as MFC was pretty old and not intensively used framework (especially for games). The only reference book I had was a book made in 1998. So most of the 2 months was researching which resulted in not having it up to the “standard” that I would of like it to.

So here is the game plan of what the redo will focus on…

  • The game will be called “Chomper” (to avoid copyrights lol).
  • I will be using the new MFC updates found in Visual Studio 2008.
  • I will try to find a different (and maybe better way) to do the animation. The old method was to use OnTimer which for a game like Pac-Man is okay. But I would like to see if I find a better and more “game”-standard way to do the animation.
  • NO DLLs! I hate DLLs.
  • NO Managed C++. It totally slow down my game when I ported it to Managed C++.
  • Add artificial intelligence (AI) which was not implemented in the old game. The ghost currently move randomlly.
  • Actual ghost images instead of blocks.
  • Fix the multi-threading. I added the sound effects late in the project to just get the bonus marks to up the grade in the course. Unfortunately I added it crudely where the sound was in one thread thereby stopping the previous sound effect.

There are other features I would surely like to add but for now, this is the priority. This would make the game at least feature complete compared to the old version.

So we will see how this project goes.

Site move

The blog is now hosted on my personal site as it is more suited (as it doesn’t relate to my other site). The only issue is I had to manually change all the attachments to redirect here.

I also organized my OSD600 course into it’s separate category so that in the future I can separate from other open-source projects that I may take. Another issue with the doing that though is it was a pain to manually change a bunch of posts to add the category :S

If there are any broken links, please contact me and I’ll fix them as soon as I can.

Final thoughts of OSD600

Phew…. The projects are done. Semester is over. Exams are finished (and good thing with the TTC strike coming up). It now time to collect my thoughts and look back about this course. Might be useful for anyone reading this and plan to take OSD soon.

The Tough Beginning

There are lots of projects to choose from. All which would be amazing to add to Mozilla. But then, the fear comes in. Like many who started this course, just the sheer size of the Mozilla codebase is enough to get people scared. Javascript is new to most people (1 week tutorial in INT222 is not enough). And the question that we all have is, how do we begin?!? But like Dave said, you just have to dive into it and start taking baby steps. We all went into the depths of unknown and just started trying, experimenting, coding, whatever!

The Hardest Assignment is the 0.1

Like I said above, the question is how to begin. And that alone is the hardest part of 0.1. Just finding where to actually hack into and start working. What functions to use and what are available. Looking and researching through the codebase like a needle in a haystack. But all the work you do in 0.1 is well worth it. When you start working on 0.2 and 0.3, you just start coding like crazy :D. This is because you already know where to work and what not to touch.

Help is around the corner

There is lots of resources to help you. MXR to search around the code. You can talk to developers on IRC. Both Chris and Dave are there too. And fellow classmates. Unfortunately for us, we all did very different projects that had very little in common.

Final Thoughts

This was a very wonderful experience for me. It is different than other courses in the way it is structured. And I worked on something that I actually WANT to do (unlike other courses where you have to do assignments whether you like it or not). I have to agree with Peter that both Chris and Dave are definitely the right teachers for this.

All right. That’s the last post for OSD. Thanks to all my fellow peers and teachers. See ya around!

Mario in Javascript

Just for fun blog post as I end the course. Here’s a nice Super Mario Bros. done in Javascript! Only 14KB and even has music! It is pretty amazing.

Hmm… maybe there will soon be a Mozilla Game Engine? Code in Javascript. XUL for GUI interfaces. SQLite for data storage. And with Canvas 3D project being worked on… Who knows 😉

Linky: http://www.nihilogic.dk/labs/mario/mario_large_music.htm

Road to Code v0.3

Here is the final version for OSD600. Only a little change from v0.2 though. Not as big as v0.1 to v0.2. Here are my highlights going to v0.3.

slideshow-gallery-v03.JPG

Hiding the current image view

This was suppose to be in v0.2 but I was going through over and over and couldn’t get it to work. I was going through each tag in the email (I think) and try to put in a inline style in it but didn’t work. But then I realized, I was like using a bazooka to fix this problem. CSS has a built-in method to do this. It is with the media. I am only hiding this from view and vice-versa hiding my stuff in print. The solution was in my CSS, which styles my stuff, to have only apply to screen which is your display. And it worked. So I just put in some styles to hide the current method of displaying images and that was that 🙂

Apply to also Message View

As Radovan suggested, was to have this work also when viewing a message by itself. I currently have it on only the 3-panel view. So I just did a overlay to messageWindow.xul in my chrome.manifest and it already works like a charm. Nice! No extra work to do 😀

Adding the Next/Prev/Pause buttons

In v0.2, I had to use menu items to use this functions (not very accessible). So I added the buttons in the slideshow gallery. I didn’t have time to actually style them and shift them into correct positions though :S but at least it is functional.

User Preferences

Currently the only user preference is the time delay in the slideshow. Default is 10 seconds and now you can set it as many seconds as you want 😀

Bugs

  • Using low seconds in the delay like 1 second will display the slideshow weird as the transitions and switch conflict.
  • I didn’t have time to make it autoload. It still has to be manually started by going to Tools>Initialize Slideshow Gallery

Where to go from here?

As stated, this is the end of OSD600. I’m not taking the next course, OSD700 as I’m graduating (yay :D). But that means the end of this extension? Nope. I actually plan to continue this extension as it is still not polished to my liking. As I did this primarly for OSD class to get it done but as I worked on it, I now thought of changes of the design. This extension was done in a whim, with little planning and more try+error and experimenting. Once more polished, I may add it to Thunderbird Add-Ons as suggested by Chris.

So nope this is not the end. I will most likely stay in touch. Like being in IRC or just more blogging.

If you like to help or contribute or anything, by all means contact me.

Here is the extension if you like to give it a try.

slideshowgalleryjosephcresencia.xpi

Late Blog Posts – Thunderbird Bug Fix Lab

When we were doing this lab in the ORI, we had some initial troubles. First for some reason, we weren’t able to compile Thunderbird in one of the machines. Strange as we used the same .mozconfig that I used to compile Thunderbird on my laptop. But pressed for time, we decided to just used my (slow) laptop.

Our initial plan was to replace the email address detection with a whole new regular expression function to detect only email address (yeah going a bit overboard). But then realize, the function is in C++. IIRC C++ doesn’t have built-in support for regular expressions. Most likely Mozilla included some form of regex in there but we didn’t really check. So we used some C++ function found on the internet to validate emails and just slapped it in. And of course, it doesn’t work. As Mozilla has support for unicode (and is specific to mozilla it seems) and the function we have was meant for ASCII and of course casting won’t help.

So using the list of invalid emails in the wiki, we noticed that the only one that failed were the ones with mutiple consecutive dots like the message example. So it was already smart enough to notice like “s@y” was not an email address. In the message example the reason why it turned to an email link was the dots after “s@y” make it seem like it had a TLD (top level domain) even though it didn’t.

So this time we actually analyzed the code. And here is what we found….

if there is an @ symbol

and after the text if not not found (which mean it is found. really hate that.) a dot (.) then it is a email.

So this why the “s@y…” is turned to an email link. It found a @ and anything after it found a dot.  Really simple way to detect an email. I guess for speed considerations since by the looks of it, (I assume) it breaks the all words in the email by spaces and check each and every word if it is a email or a web address to make it a hyperlink.

Our plan was to do the following… After finding a dot, just check if the next character right after it is dot as well. If so, then don’t convert to a link and if not, then we can assume we have a valid email.

The issue then was how to get the position. It is not as easy as ASCII where we can just put str[pos+1] == ‘.’ (as we thought it would be) as we are dealing with unicode which can be a double byte character. But time ran out for us, and class was over. So we didn’t have a chance to fully test our plan. Hopefully, we will look into it eventually.