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):
- All previous changes
- Fixed a bug with mouse icon
- Attempt to show mouse cursor on upper screen also when LCDs are swapped (sometimes it fails to be in the correct position but it covers most cases).
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):
- All previous changes
ScummVM Build G (NDS only - for Lure of the Temptress… untested yet and the main site does not report it as working.. so state is unknown.)- Hover-only mouse option - this will simulate the job done by a mousepad on a laptop
- Show cursor on aux screen - this will show the cursor on the secondary screen if the screens are not swapped (together with Hover-only, it provides an UI to ScummVM more similar to the classical one found on laptops).
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.
- I found WPF nothing to go crazy about. MDX allows you to easily render some complex things (like 3D text) at the price of difficult rendering of basic primitives. OpenGL is the opposite. With WPF you might think it will all be easier. 3D Text is no easier at all (there is wrapper class from Petzold somewhere in the net, but nothing native and easy). Simple primitives are absent (no sphere, cylinder, plane ?!).
- There is not a meaningful level of knowledge; they are masking out the product of matrices but in the same help page they speak about quaternions.. the result is an API which is hard to be used both for a 3D expert and for a 3D primer. Some informations (like if the translation is in the last row or last column of the 4×4 matrix - it depends on how the product is implemented etc.) is hard to be found.
- MeshGeometry3D is a cool class, well implemented.
- You will spend quite some time experimenting things you shouldn’t experiment with.. because it’s not easy to predict how material concatenation work or similar things without trying at first (it’s done differently from other 3D toolsets).
- They somewhat idiotically reimplemented many basic types. So you’ll find yourself converting System.Drawing colors in WPF colors, or WinForms mouse arguments in WPF mouse arguments. I can understand the latter but not so much the former (at least, implement a converting constructor). The same goes for images, etc. At now the easiest way to convert an image I found (the easiest, not the fastest) is serializing on a memory stream!
- You must work with (their) scenegraph. This is generally good (to have a scenegraph to work with!) but in my case an “immediate mode” approach would have been better.
- 3D Hit-testing is easy.
- Good Exporters/Importers are hard to find. The 3ds one works.. “almost”. It has defects and working only on basic models. Plus it doesn’t fix 3dsmax inverted axis issues.
- Antialiasing is not supported (apart from registry hacks) on Windows XP/2003. Vista only. Marketing crap.
- Keyboard.Modifiers doesn’t work in hybrid scenarios (at least doesn’t seem to work). Had to rely on System.Windows.Forms.Control.ModifierKeys (using WinForms code in a WPF event handler… bah).
- Downloading someone else code is helpful to work around stupid issues like not understanding how to define a resource.
- I hate XAML.
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.