Categories
Uncategorized

Week 11

In the previous I continued to work printing the task. I’ve added the initial options to printing such as layout (portrait, landscape), margins as well as the selecting the printer itself. In the process of adding these, I’ve customed myself a bit to Win32 printing API, since this is the only backend with which I was testing the actual printout.

First of all, I continued the work from the last week by introducing PrintingDialog, which will be opened when printout happens. To it, I’ve added layout and printer selection. In Win32 Print Spooler API, printer list is a string array, so for now, in the PrintingManager class, this virtual method is also Common::StringArray. Implement it was quite easy, since the documentation is there and not much code was needed. By adding printer selection, users can select the real physical printer or virtual one to get PDF-output. Since I have the actual printer, I started testing the code and see what was the output:

Tiny ScummVM logo printed as a test
CLUT8 test remained from the original PR

As you can see, while the logo and were printed, they were too small and not centered. This made me to spend some time actually looking how different platforms handle image printing. After comparing printer dialogs in different browsers, operating systems, I concluded I definitely needed to add scaling (or, rather, fitting to paper) and margins. To not waste more paper, I’ve been testing with PDF output since then, and was able to get the printing centered and fit to paper.

After that I started to think about preview image functionality, which is common these days in printer dialogs. Luckily, there is already an ImageAlbumDialog present, which had more enhanced image output as well as image preview. That meant I only needed to migrate all dialog code there. I’ve managed to make printing work when the right command is send, however, implementing GUI nice looking correctly (so that both preview appears on the left and printer settings on the right) appeared to be a little harder, and is not yet finished. This week I plan to fix this, and as was commented and suggested earlier start adding printing support to actual engines and see if the current API functionality is enough or needs to be adapted. Before that I plan to quickly fix a few things (mostly visual differences) in MacVenture engine, so that it looks and plays like in the original Macintosh.

 

Categories
Uncategorized

Week 10

In the previous week I finished with fixing leftover bugs in MacVenture and later started working on bringing printing support.

The last problem that was left from the week before that was polishing console window. In particular, there were problems with how the text was displayed when new text was added or when the window was resized. To make things easier I decided to change that console window from Graphics::MacWindow to Graphics::MacTextWindow. That allowed to take care of text wrapping and scroll management at once. However, to take it fully work, a few adjustments have to be made, as the class probably was initially created for the console with input (editable text). For example, to make the cursor be focused on the right place required to a little workaround, where I made the window editable, append the text, and make it uneditable again. Despite this, after it was implemented, I also added support for saving the text, so the save/loading functionality is also complete now.

After this with Sev’s suggestion, I started working on bringing printing support. It would useful for the MacVenture titles as all four games give a chance to print the diploma after completing the game. In addition it could be added to numerous HE games and others. I did not start from scratch, but rather from the previous attempt from few years back. I took the first few commits, and the later ones with some fixes. Then I added a simple test in testbed, so that I could test how the resulting pdf file. Once that was tested, I started adding code on top of it. I added a dialog for printing and along with it a feature to save the input surface as an image.

This week I plan continue the work on this1 and start actually implementing printing feature for the engines that needs it.

Categories
Uncategorized

Week 9: MacVenture III

Another week spent on improving and finishing the MacVenture engine. In the last week I focused on improving things that happen after the winning the game, i.e, loading diploma window & dialog, implementing “Clean/Mess up” functions. I also fixed the bitmap problem I had with with a few items in Uninvited game. Lastly, I spent time fixing the resize button and porting the leftover methods from the original codebase.

I started the week with adding support for the diploma window. There was already a pointer variable in the codebase, but until before I did not know what kind of diploma it was referring to. The diploma we are talking about here is the certificate you get after completing the games.

To implement it, a first added another constructor for the ImageAsset class, as the format for the diploma image was a little different from the rest of images. Once that was done, the diploma image already started showing:

Diploma after completing Shadowgate

After that, I needed to add the dialog that had with “Print” and “Exit” buttons. There was already a Dialog class for that, however only with prebuilt options. Similarly, I added the constructor for this, however, the text was a little off. To mitigate the issue, I added an additional MacText text so that line wrapping can be easily handled. Once that was added the dialog at the bottom started showing correctly:

After that I started fixing the bug where certain items (charm and statue) in Uninvited game were incorrectly displayed:

In fact, you can see the issue in one of the images in the previous post. For debugging, I first identified the object id of the item, then looked how the image was loaded. The problem was in ImageAsset::decodePPIC0() method, in particular, in the section where 32 bits were read and then bitshifted to the right, until most significant byte was taken. At first I thought the problem was that BitStream32BEMSB which was used here was behaving a little different from the GFile class in the original, and because of that these artifacts were happening. And indeed, in the original codebase, the position of the stream did not advance right away after getBits() was called, but was incrementing the internal variable and advanced the position only after that variable was greater than 0xa. I thought maybe I should wrap BitStream template inside the custom class to imitate the behavior of the original code. However, after thinking a little more and checking the walkHuff() method, where similar thing was happening, I realized than none of that actually needed. BitStream32BEMSB was advancing stream position correctly in the first place, so the only thing which was needed was to read the first 16 bits, and skip the other half. And indeed, this two line change fixed the issue:

Another thing I copied from the original javascript codebase was “Clean/Mess up” functions. Clean up is handy when there a lot items in the inventory, and you want the thing sorted. This was a simply copy-n-paste, however, the end result is quite satisfying and as said, useful for players:

At the end of week, I started polishing the console window The window where text (log) is displayed. There were small issues fixed away: numbers not showing and resize button not working. The last one was similar to the close button covered in this post. The last thing which needs to be properly done with console window is getting rid of unnecessary new lines, making the scrolling properly work and showing the text correctly when resizing (it gets clipped, not wrapped).