{"id":2781,"date":"2021-12-27T18:00:31","date_gmt":"2021-12-27T18:00:31","guid":{"rendered":"https:\/\/castle-engine.io\/wp\/?p=2781"},"modified":"2021-12-24T05:13:38","modified_gmt":"2021-12-24T05:13:38","slug":"tcastlewindow-scenemanager-removal-of-a-deprecated-property-soon","status":"publish","type":"post","link":"https:\/\/castle-engine.io\/wp\/2021\/12\/27\/tcastlewindow-scenemanager-removal-of-a-deprecated-property-soon\/","title":{"rendered":"TCastleWindow.SceneManager: removal of a deprecated property soon"},"content":{"rendered":"<table class=\"thumbnails thumbnails-align-right\"><tr><td>\n          <a href=\"https:\/\/castle-engine.io\/wp\/wp-content\/uploads\/2021\/12\/ex_multiple.png\"\n             class=\"screenshot\"\n             title=\"Castle Game Engine example - multiple_viewports\"><img loading=\"lazy\" decoding=\"async\"\n            style=\"float: right\"\n            src=\"https:\/\/castle-engine.io\/wp\/wp-content\/uploads\/2021\/12\/ex_multiple-200x117.png\"\n             width=\"200\" height=\"117\" \n            alt=\"Castle Game Engine example - multiple_viewports\"\n          ><\/a><\/td><\/tr><\/table>\n<p>As we extend the engine, we sometimes have to deprecate some old features, that were not very useful, and sometimes prevented the engine API from being flexible and easy to understand.<\/p>\n<p>One of these things was <code>TCastleSceneManager<\/code> class (renamed to <code>TCastleViewport<\/code> since 2 years), with its single &#8220;central&#8221; instance in <code>TCastleWindow.SceneManager<\/code> or <code>TCastleControl.SceneManager<\/code>. In a hindsight, I know it was a mistake to add such &#8220;central&#8221; reference to &#8220;one main scene manager&#8221;. It was much better to focus on adding multiple UI controls to your window (which we did), and realizing that various scenarios are possible:<\/p>\n<ul>\n<li>\n    Some games don&#8217;t need <code>TCastleSceneManager<\/code> \/ <code>TCastleViewport<\/code> at all. <\/p>\n<p>E.g. applications with simple UI, where everything is just a simple 2D UI control.<\/p>\n<li>\n<p>Some games need one instance of <code>TCastleSceneManager<\/code> \/ <code>TCastleViewport<\/code> (e.g. typical 3D FPS games). But it still may not exist always, so it better exists only within particular <code>TUIState<\/code>.<\/p>\n<li>\n<p>Some games need more instances of <code>TCastleSceneManager<\/code> \/ <code>TCastleViewport<\/code>. Maybe on one <code>TUIState<\/code> (e.g. split-screen local multiplayer games), maybe spread in many <code>TUIState<\/code> instances (e.g. 3D game view, 3D map view etc.).\n<\/ul>\n<p>This observation led to the API you now have and use. But&#8230; the <code>TCastleWindow.SceneManager<\/code> and <code>TCastleControl.SceneManager<\/code> are still defined, for backward compatibility. And we advise everyone to use classes with <code>Base<\/code> suffix, <code>TCastleWindowBase<\/code> and <code>TCastleControlBase<\/code>, to avoid having this <em>&#8220;automatic central scene manager&#8221;<\/em> present. This is causing complicated engine code (for backward compatibility), complicated docs (why the <code>Base<\/code> suffix?), and unnecessary dependencies in <code>CastleWindow<\/code> unit (that right now has to depend on almost all CGE code, as <code>TCastleSceneManager<\/code> \/ <code>TCastleViewport<\/code> depends on <code>TCastleScene<\/code> that depends on almost everything else).<\/p>\n<p>We had <code>TCastleWindow.SceneManager<\/code> and <code>TCastleControl.SceneManager<\/code> deprecated for <a href=\"https:\/\/castle-engine.io\/wp\/2019\/12\/29\/last-refactor-before-cge-7-0-release-say-hello-to-tcastleviewport-and-tcastlewindowbase-say-goodbye-to-tcastlescenemanager-and-tcastlewindow\/\">2 years now, since December 2019<\/a>. Time to actually remove them \ud83d\ude42 So, a plea: if you use <code>TCastleWindow<\/code> or <code>TCastleControl<\/code>, if you see messages that they are deprecated but you keep using them anyway&#8230; stop \ud83d\ude42<\/p>\n<p>The best way to upgrade is to switch to using <code>TUIState<\/code>, designed by CGE editor, and put <code>TCastleViewport<\/code> in your games this way. But as a last resort, you can even create local copy of existing <code>TCastleWindow<\/code> code from <code>castlewindow.pas<\/code>, it isn&#8217;t long.<\/p>\n<p>At the <b>end of January 2022<\/b> (in 1 month) we will actually remove <code>TCastleWindow.SceneManager<\/code> and <code>TCastleControl.SceneManager<\/code>. The <code>TCastleWindow<\/code> and <code>TCastleControl<\/code> will become equivalent to their <code>...Base<\/code> counterparts, and we will encourage to use again the simpler names (as there will be no point in using <code>...Base<\/code> suffix). It is easy to try it <b>right now<\/b>: go to <a href=\"https:\/\/github.com\/castle-engine\/castle-engine\/blob\/master\/src\/common_includes\/castleconf.inc\">src\/common_includes\/castleconf.inc<\/a>, find<\/p>\n<pre>\n{$ifdef FPC}\n  {$define CASTLE_DEPRECATED_WINDOW_CLASSES}\n{$endif}\n<\/pre>\n<p>and just remove it. Or add something, e.g. dot, to make the <code>{$define CASTLE_DEPRECATED_WINDOW_CLASSES}<\/code> inactive, like this:<\/p>\n<pre>\n{$ifdef FPC}\n  {.$define CASTLE_DEPRECATED_WINDOW_CLASSES}\n{$endif}\n<\/pre>\n<p>This will change the <code>TCastleWindow<\/code> and <code>TCastleControl<\/code> to be equivalent to their <code>...Base<\/code> counterparts, without any deprecated <code>SceneManager<\/code> property.<\/p>\n<p><i>Please support the engine development on <a href=\"https:\/\/www.patreon.com\/castleengine\">our Patreon<\/a>. It funds development of the engine, it means we have resources to design the engine the right way!<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we extend the engine, we sometimes have to deprecate some old features, that were not very useful, and sometimes prevented the engine API from being flexible and easy to understand. One of these things was TCastleSceneManager class (renamed to TCastleViewport since 2 years), with its single &#8220;central&#8221; instance in TCastleWindow.SceneManager or TCastleControl.SceneManager. In a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/castle-engine.io\/wp\/2021\/12\/27\/tcastlewindow-scenemanager-removal-of-a-deprecated-property-soon\/\" class=\"more-link\">Continue reading  \u27a4<span class=\"screen-reader-text\"> &#8220;TCastleWindow.SceneManager: removal of a deprecated property soon&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2735,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"publish_to_discourse":"1","publish_post_category":"9","wpdc_auto_publish_overridden":"","wpdc_topic_tags":"","wpdc_pin_topic":"","wpdc_pin_until":"","discourse_post_id":"1643","discourse_permalink":"https:\/\/forum.castle-engine.io\/t\/tcastlewindow-scenemanager-removal-of-a-deprecated-property-soon\/480","wpdc_publishing_response":"success","wpdc_publishing_error":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-2781","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/castle-engine.io\/wp\/wp-content\/uploads\/2021\/12\/ex_multiple.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9IgYW-IR","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/posts\/2781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/comments?post=2781"}],"version-history":[{"count":11,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/posts\/2781\/revisions"}],"predecessor-version":[{"id":2792,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/posts\/2781\/revisions\/2792"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/media\/2735"}],"wp:attachment":[{"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/media?parent=2781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/categories?post=2781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/tags?post=2781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}