📜 ⬆️ ⬇️

The thorny path in the Windows Store

Like many programmers, I was wary (and am) about Windows 8, but I could not help trying to write a couple of programs for the Windows Store. Still, this is a fashion trend: .Net 4.5, C # 5, XAML.

Just these days, on December 4th, I came across an article about the Microsoft W8 application contest. Laying out experimental programs was somehow not serious (although the market is literally overflowing with such crafts), so I decided to port a fairly large-scale project with MonoTouch and iOS. Stock up on popcorn, because besides the programmer details there will be comedy, drama, and a life ending.


Completely different C #


The code for MonoTouch / MonoDroid is written in C #, but this is normal, “canonical” C # with System.Drawing, System.Xml, System.IO, etc. I was expecting all this under Windows 8, with bonus bridge and lawyers, but the reality was cruel: the listed namespaces are absent in principle. There is no PointF anymore, XmlNode is crossed out, File.ReadAllText () cannot be made, there is no FileStream and anything compatible with it. Even with images you can do only one action - load, and even that is asynchronous, i.e. even the size in pixels immediately after loading we cannot find out without a tambourine.
Actually, in general, all I / O operations with the outside world have become asynchronous, with the keywords async and await, which after a few hours of work caused me to have attacks of uncontrollable rage. In fact, this is a good innovation and an interesting approach, but if in a stable and proven code a 500-byte text file was read (the order of levels in the game, the script, etc.), then now there is a noticeable change of the code, and at the same time the whole chain of calls must be marked as async. Another option is to write a wrapper imitating the old syntax, inside of which a non-kosher, synchronous call to the asynchronous method occurs (hello to future supportrs!).
')
In general, I am a supporter of code freezing: business logic is once written, debugged, and then not touched at all, and the changes concern only user interaction. Therefore, overcoming an attack of disgust, I sat down to create my own wrappers for wrappers.
For half a day, their own implementations of PointF, RectangleF, XmlDocument, System.IO.File, etc. were made, which, by syntax, are the same as in .Net 2.0-4.0, but inside they already use the realities of the Windows Store. To work with resources, I had to put up with crutches to “synchronize asynchronous devices”:
public static string ReadAllText(string path) { IAsyncOperation<StorageFile> file = StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///" + path)); file.AsTask<StorageFile>().Wait(); IAsyncOperation<string> result = FileIO.ReadTextAsync(file.GetResults()); result.AsTask<string>().Wait(); return result.GetResults(); } 


With XmlDocument and XmlElement it turned out to be more complicated, such classes exist in a “lightweight” form in the Windows.Data.Xml.Dom namespace, but now they are not inherited from XmlNode, but implement the IXmlNode interface with some syntax changes. My wrapper is not very handsome, doesn’t know how to work with XPath and many other features, but for the simplest tasks it worked fine. If someone needs it as a blank, here’s the code: paste2.org/p/2664348

Graphics


On iOS / Android, our games draw sprites via OpenGL ES 1.1. No shaders, no transformations, no VBO - calls glDrawTexiOES. In Windows, of course, GL doesn't even smell, so I counted on XNA and SpriteBatch, but ... it was not there. In the world of the Windows Store in general, XNA is not in its pure form, only due to its cross-platform implementation of MonoGame! The product is quite entertaining, but I wanted to get away with the platform's capabilities, and in the future I was interested in the Silverlight port option. The WPF / XAML solution looks home-grown, but it works almost as it should: for each sprite I create a Rectangle of the desired size on the Canvas and assign it an ImageBrush, which refers to the desired texture, and due to the transformations it extracts only a part of it. Technically, WPF uses DirectX for rendering, because this method has the right to life and gives good performance.
I found only one pitfall when the port was almost finished: in principle, there is no method to change the color of the sprite. For example, in the puzzle with colors, we painted different parts in red and blue through glColor4f (1.0f, 0.0f, 0.0f, 1.0f). With all the wealth of choice, I did not find an alternative (except for rewriting on MonoGame), so I had to work with three different textures. A similar problem happened in the puzzle with bones, but here I could manage with transparency - the bones fixed were now “gray” (on the right), and not “yellow”, as on other platforms (on the left).



The noticeable difference between Windows Store and mobile / tablet games is that they can be shown on huge screens and resolutions. For example, the graphics for the iPhone 3GS does not look good on a 27 "monitor with a resolution of 2560x1440. Fortunately, a certain amount of hi-res content was prepared for the iPad 3, and at the same time some levels and controls had long been redrawn. I am not an artist, because It took me almost more time than porting.

Putting to market


So, on December 6th, early in the morning, the program was ready to be sent for certification. There was little time left before the deadline for the contest, December 10, but I was hoping for the best. Screenshots for Windows Store are supposed to be done in a simulator with a resolution of 1366x768 in png format, which, in the best traditions of Microsoft, is bloated to impossibility. The size is acceptable for the same type of graphics, but not for photos or paintings: the screenshot shown above with Dali's work took 2.9 megabytes. This is not a problem for the modern Internet, but the program sending form does not accept files larger than 2 MB. It also does not take JPEG, because I previously skipped the screen through optipng, from which it did not visually change, but it became a megabyte less.

Renouncement


On Saturday morning, December 8th, I was denied certification of the program. The reason struck the imagination: "one or more screenshots were changed in third-party programs." Mentally cursing myself for carelessness, and developers and testers for all the sins committed and not committed by them, I deleted the screen and re-sent the program.
Separately, I will say that the idiocy of the situation with the screenshots I notified the support, the official forum, familiar representatives of the company, but did not get any intelligible answers. Yesterday I was contacted by a colleague from Belarus, whose situation is even more complicated: their program shows beautiful pictures of corners of the Earth, and all as one screenshots are more than 2 MB. Apparently, for each such screenshot you need to make a postscript like "changed in Photoshop to reduce the size."

Testing


Often, testers in the iTunes Store / Samsung Store / Amazon AppStore look at the basic qualities of the program: are there any obvious bugs, time bombs, naked beauties, keyloggers. Windows Store certification was no exception for my other products and took one, maximum two days. But this time, as I understood, the testers decided to go through the game entirely, otherwise I don’t understand what else they could do for 11 (!!) calendar days. Or simply could not pass the first puzzle.
The support service replied that technically only 7 working days had passed and it was not so bad, we still have to suffer. Having resigned myself to being terribly terrified of me, I talked to the organizers of the competition and found out that the deadline for submitting applications was shifted from December 10 to December 28. This was encouraging, although it was already clear that the chances of getting into the competition are slim.
On the night of December 17-18, I received a notification that the program was certified and will appear in the store in 4 hours.

Losses


A few days later the program in the store did not appear. Just at these days, Microsoft was almost at full strength going to go on a week-long vacation (or meet the COP with the family), so I sounded the alarm and promptly contacted customer support. A girl with a beautiful name Brandi (or an unsuccessfully named boy) reported that unfortunately in the process of certification all my screenshots were irretrievably lost! It was the 20th of December, one day before the intended holidays and side events. In order not to delay the process, I suggested three options at once: send screenshots by mail, cancel the certification of the program, take screenshots from the free version of the same game already sent for review. The decision, apparently, was not easy, because on December 23 of the day I was told that I probably need to send screenshots by mail ...
No sooner said than done, I attached a set of screenshots, wrote descriptions in Russian and English, sent and within 15 minutes received the answer:

At the end of 2012, after the end of the Mayan calendar, in an era when the Higgs boson was found, and a curious robot sends photos from Mars in real time, phones take 41 megapixels, and firms buy petabyte data stores, the limit for email messages in MS is 14 megabyte…
I compiled a new letter, threw away some of the screenshots and ... received a response from another robot:

At this stage, I freaked out, uploaded all the files to my hosting and sent the links. The next answer came in 6 days, December 29th, when there was no longer any talk of competition. He said that the screenshots were uploaded, everything is fine, but so far they have not posted the program, because in the logs you can see that there was still some promo image (picture on the right) - in fact, a decorated tile banner for the market, in case the editors want to bring the program to the main page. So, this promo image was also lost and they ask my advice on what to do next - release without it, or I will send the updated one.
I really wanted to write an obscene answer, but I answered with one phrase that we would do without a promo image.

Competition


In the meantime, the competition was the preliminary awarding of "8 best New Year programs." The Salads and the psychedelic game Lighthouse, somewhat distant from the New Year's theme and common sense, won there.
Now my product is also listed in the list of participants, because I managed to apply for certification of a free version of the same program and certification passed in one day. It differs from the paid one only with a banner that leads to the purchase of a paid one, which means going nowhere :)
Unfortunately, the main prize - a tablet with Windows 8 - cannot be compared with the promotion and 4kk banner-shows that Salads will receive, therefore the meaning of participation is somewhat lost. The final will be the other day, and at the same time they will award the prize-winner in the nomination “The greatest number of published applications by one participant”. Some people took this nomination as a call to action and began to make programs adding or subtracting two numbers. I advertise a couple of such masterpieces:

I will not begin to condemn the authors of the programs and the MS employees who missed such a thing in the market, but I hope that the organizers of the competitions are still more pleased to report the victory and promote something Cut The Rope than 12345 and Salads.

I’ll finish this story, although in reality the final is still to come: the end of the world has not come, but the program has not yet entered the store, the competition has not yet been completed, and technical problems in the Windows Store have not been solved.

Source: https://habr.com/ru/post/163773/


All Articles