{"id":89,"date":"2025-07-21T15:17:31","date_gmt":"2025-07-21T15:17:31","guid":{"rendered":"https:\/\/blogs.scummvm.org\/alikhan\/?p=89"},"modified":"2025-07-21T15:25:14","modified_gmt":"2025-07-21T15:25:14","slug":"week-7-macventure","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/alikhan\/2025\/07\/21\/week-7-macventure\/","title":{"rendered":"Week 7: MacVenture"},"content":{"rendered":"<p>Last I week I started working on the MacVenture engine. The engine is based on the <a href=\"https:\/\/github.com\/mrkite\/webventure\">javascript implementation<\/a>. It is very close to completion, what&#8217;s left is to fix a few leftover bugs and playtest the games, so that they are completable. I started with the first <i>D\u00e9j\u00e0 Vu<\/i> game and close button was not working, drag (lasso) selection is missing, and in certain places the game window was not displaying the correct images. Throughout the week I tackled these problems.<\/p>\n<p>As said above, first thing I noticed is that the close button was not responding, e.g. after clicking on it, nothing was happening. It took quite some time to figure out what was going wrong, but eventually I found the reason for it. The problem was that the code for identifying whether the mouse was inside close button was looking like this:<\/p>\n<p><code>bool MacWindow::isInCloseButton(int x, int y) const { <\/code><br \/>\n<code>\u00a0 \u00a0 int bLeft = kBorderWidth;<\/code><br \/>\n<code>\u00a0 \u00a0 int bTop = kBorderWidth; <\/code><br \/>\n<code>\u00a0 \u00a0 if (_macBorder.hasOffsets()) { <\/code><br \/>\n<code>\u00a0 \u00a0 \u00a0 \u00a0bLeft = _macBorder.getOffset().left; <\/code><br \/>\n<code>\u00a0 \u00a0 \u00a0 \u00a0bTop = _macBorder.getOffset().top; <\/code><br \/>\n<code>\u00a0 \u00a0 } <\/code><br \/>\n<code>\u00a0 \u00a0 return (x &gt;= _innerDims.left - bLeft &amp;&amp; x &lt; _innerDims.left &amp;&amp; y &gt;= _innerDims.top - bTop &amp;&amp; y &lt; _innerDims.top); <\/code><br \/>\n<code>}<\/code><\/p>\n<p>As can be seen, it returns true if mouse position is at the corners of window borders. And it works correctly if close button is indeed at one of the corners, as in WAGE games:<\/p>\n<figure id=\"attachment_90\" aria-describedby=\"caption-attachment-90\" style=\"width: 146px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-90 size-medium\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/scummvm-afm-8-00000-146x300.png\" alt=\"\" width=\"146\" height=\"300\" srcset=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/scummvm-afm-8-00000-146x300.png 146w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/scummvm-afm-8-00000.png 334w\" sizes=\"auto, (max-width: 146px) 100vw, 146px\" \/><figcaption id=\"caption-attachment-90\" class=\"wp-caption-text\">Standard window with close button on the top left<\/figcaption><\/figure>\n<p>However, here the close button has a little offset to right and bottom from the left top position of border:<\/p>\n<figure id=\"attachment_92\" aria-describedby=\"caption-attachment-92\" style=\"width: 247px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-92 size-medium\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/scummvm-deja_vu-00000-1-247x300.png\" alt=\"\" width=\"247\" height=\"300\" srcset=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/scummvm-deja_vu-00000-1-247x300.png 247w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/scummvm-deja_vu-00000-1.png 293w\" sizes=\"auto, (max-width: 247px) 100vw, 247px\" \/><figcaption id=\"caption-attachment-92\" class=\"wp-caption-text\">Window with different close button<\/figcaption><\/figure>\n<p>So to make it work, I added offset fields for the closeButton, and made\u00a0 <code>MacWindow::isInCloseButton()<\/code> method to look at those offsets, if they are present.<\/p>\n<p>Next problem was absence of drag (or lasso) selection. It is needed to select multiple items in the inventory at once, as can be seen here:<\/p>\n<div style=\"width: 580px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-89-1\" width=\"580\" height=\"326\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/steamversion.mp4?_=1\" \/><a href=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/steamversion.mp4\">https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/steamversion.mp4<\/a><\/video><\/div>\n<p>However, making it works wasn&#8217;t that easy and took me a couple of tries and rewrites, and to the moment of writing, there is a slight bug that needs to be fixed. But the idea is simple: on the mouse button <strong>down<\/strong> event save the pivot point of the selection, on the mouse <strong>move\u00a0<\/strong>event update the the second point, and lastly, on mouse <strong>up<\/strong> event create a rectangle from the two points, look if any inventory objects are inside and mark them as selected. The difficulties was there because of the code flow structure which was altered and become noticebly different from the original code.<\/p>\n<p>What really helped me here and in the later problem is that I managed to get original code running and made it debuggable in browser. I updated the jQuery version the fresh one, fixed a few type errors and imported the main game code as module, so that when it is compiled with closure compiler, the separate mac.js is generated.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-95 aligncenter\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/Screenshot-573-300x149.png\" alt=\"\" width=\"566\" height=\"281\" srcset=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/Screenshot-573-300x149.png 300w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/Screenshot-573-1024x508.png 1024w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/Screenshot-573-768x381.png 768w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/Screenshot-573-1536x761.png 1536w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/Screenshot-573-1200x595.png 1200w, https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/Screenshot-573.png 1862w\" sizes=\"auto, (max-width: 566px) 100vw, 566px\" \/><\/p>\n<p>With this, I stepped through the js code, looked how the lasso was done, and made it essentially working:<\/p>\n<div style=\"width: 580px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-89-2\" width=\"580\" height=\"326\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/lasso.mp4?_=2\" \/><a href=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/lasso.mp4\">https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/lasso.mp4<\/a><\/video><\/div>\n<p>&nbsp;<\/p>\n<p>Afterwards I worked on fixing the issue right at the start of the game. What happened is that, when examining the mirror object, the engine would not pause and quickly skip the image of character. It happened, because the engine was not pausing after <code>MacVentureEngine::clickToContinue()<\/code> function was called. I added an additional flag that is set when clickToContinue is true, so that the game pauses, and the main game window shows the correct images. This is how it worked before and after the fix:<\/p>\n<div style=\"width: 580px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-89-3\" width=\"580\" height=\"326\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/beforefix.mp4?_=3\" \/><a href=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/beforefix.mp4\">https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/beforefix.mp4<\/a><\/video><\/div>\n<div style=\"width: 580px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-89-4\" width=\"580\" height=\"326\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/afterfix.mp4?_=4\" \/><a href=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/afterfix.mp4\">https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/afterfix.mp4<\/a><\/video><\/div>\n<p>There are two more bugs left from the last week which I am fixing now. First one related to window resize &#8211; when making the window smaller, it stops showing borders:<\/p>\n<div style=\"width: 580px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-89-5\" width=\"580\" height=\"326\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/resizeBug.mp4?_=5\" \/><a href=\"https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/resizeBug.mp4\">https:\/\/blogs.scummvm.org\/alikhan\/wp-content\/uploads\/sites\/78\/2025\/07\/resizeBug.mp4<\/a><\/video><\/div>\n<p>The second also probably related to it. Clicking at the resize button selects the object if that object happens to be there.<\/p>\n<p>For this week, I plan to continue the work on the MacVenture and fix the above mentioned bugs. Afterwards, I will solely focus on playtesting.<\/p>\n<p>Lastly, I want to mention that I succesfully passed the Midterm evaluation for GSoC. I want to thank my mentor &#8211; Eugene. He has been very supportive and always there for help and explanations. Also, the tasks and engines were all diverse and very interesting to work on. I am very enjoying contributing to ScummVM.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last I week I started working on the MacVenture engine. The engine is based on the javascript implementation. It is very close to completion, what&#8217;s left is to fix a few leftover bugs and playtest the games, so that they are completable. I started with the first D\u00e9j\u00e0 Vu game and close button was not [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/comments?post=89"}],"version-history":[{"count":7,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":104,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/posts\/89\/revisions\/104"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/alikhan\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}