ScummVM DS Patches - version 4

(Quick download links : .NDS builds or .DS.GBA builds, modified sources here, SourceForge patches here)

I’ve patched ScummVM DS once again..

See here for more details, versioning, how, why, what, which, who..

Changes in ScummVM/DS 0.11.1.MMP4 (.NDS builds or .DS.GBA builds):

Be vigilant.

ScummVM DS Patches - version 3

(Quick download links : .NDS builds or .DS.GBA builds, modified sources here)

I’ve patched ScummVM DS once again..

See here for more details, versioning, how, why, what, which, who..

Changes in ScummVM/DS 0.11.1.MMP3 (.NDS builds or .DS.GBA builds):

Now I have to go.. Kyrandia needs my help ;)

A little better MeasureString…

System.Drawing.MeasureString is a shit.

You are better work it out with API calls and so on, but if you are on Mono that is out of choice.

Apart from the known problems (not working correctly without Antialiasing enabled, requiring specific StringFormats), it also skips trailing spaces.

At least this should fix that issue up:

int CountTrailingSpaces(string str)
{
    int spaces = 0;

    int i = 0;
    for (i = 0; i < str.Length; i++)
    {
        if (str[i] == ' ') ++spaces;
        else break;
    }

    for (int j = str.Length - 1; j > i; j--)
    {
        if (str[j] == ' ') ++spaces;
        else break;
    }
    return spaces;
}

SizeF MeasureString(Graphics gfx, string str, Font font)
{
    // these are the times you hate MS..
    SizeF size = gfx.MeasureString(str, font,
          new PointF(0.0f, 0.0f),
          StringFormat.GenericTypographic);

    if ((str.EndsWith(" ")||(str.StartsWith(" "))))
    {
        SizeF spacesize = gfx.MeasureString("! !", font,
              new PointF(0.0f, 0.0f),
              StringFormat.GenericTypographic);
        SizeF spacesizemin = gfx.MeasureString("!!", font,
              new PointF(0.0f, 0.0f),
              StringFormat.GenericTypographic);

        float spacewidth = spacesize.Width - spacesizemin.Width;

        int spaces = CountTrailingSpaces(str);

        size.Width += (spacewidth*(float)spaces);
    }

    return size;
}


:|

3D in managed mode (WPF, and not only)

In this week I had the chance to do a little work with WPF 3D capabilities.

I wanted to implement a user control implementing a visualizer of “something” in 2D for a Windows.Forms application. I decided to add a 3D view capability. Language used was C#.
I started with Managed DirectX. It’s crap. Simply put, there exist just two versions of MDX and they are not compatible (!). Plus the first one is very buggy (if you write a 50 lines program and find a bug in the SDK, you can claim it’s very buggy :(). The DLLs do not come with the framework. Last but not least they are abandoned, because MS decided to develop XNA.

I could go with XNA, but XNA is not, again, distributed with the framework, and is very game oriented. I didn’t want to force business users to run an XNA installer for a non-game application, specially taking into account that the 3D visualization is not a requirement, it’s an added feature of the component.

OpenGL wrappers exist, but the first one I found has been abandoned. Not the solution I wanted, but still better than MDX/XNA.

So I went to WPF. The 3D is not very complex and so WPF it’s enough.

I developed a 2D control using Windows.Forms and System.Drawing and then left the 3D part to an internal, hidden, control developed using WPF (thus my control is in the end what MS calls an hybrid control — supported scenario ;)).

So, let’s go with some considerations about WPF.

Edit :

I was forgetting a very important consideration.

WPF is fixed function, sadly. No shaders. In 2007 this is like releasing a single tasking operative system. I don’t know if I will use this Windows 3.1 of 3D in the future, on second thought.

Next Page →