├── .gitattributes ├── .gitignore ├── CoreExtension.yyp ├── LICENSE ├── README.md ├── docs_src ├── ScriptingAPI.md └── index.md ├── gmdoc.json ├── objects └── CE_OGUI │ ├── CE_OGUI.yy │ ├── CleanUp_0.gml │ ├── Create_0.gml │ ├── Draw_64.gml │ ├── Gesture_64.gml │ ├── Gesture_66.gml │ ├── Gesture_67.gml │ ├── Gesture_68.gml │ ├── KeyPress_1.gml │ ├── KeyPress_13.gml │ ├── Keyboard_1.gml │ ├── Mouse_53.gml │ └── Step_0.gml ├── options ├── amazonfire │ └── options_amazonfire.yy ├── android │ └── options_android.yy ├── html5 │ └── options_html5.yy ├── ios │ └── options_ios.yy ├── linux │ └── options_linux.yy ├── mac │ └── options_mac.yy ├── main │ └── options_main.yy ├── operagx │ └── options_operagx.yy ├── tvos │ └── options_tvos.yy ├── windows │ └── options_windows.yy └── windowsuap │ └── options_windowsuap.yy ├── rooms └── RmTest │ └── RmTest.yy ├── scripts ├── CE_ArgumentException │ ├── CE_ArgumentException.gml │ └── CE_ArgumentException.yy ├── CE_ArrayUtils │ ├── CE_ArrayUtils.gml │ └── CE_ArrayUtils.yy ├── CE_Assert │ ├── CE_Assert.gml │ └── CE_Assert.yy ├── CE_Class │ ├── CE_Class.gml │ └── CE_Class.yy ├── CE_ColorUtils │ ├── CE_ColorUtils.gml │ └── CE_ColorUtils.yy ├── CE_Component │ ├── CE_Component.gml │ └── CE_Component.yy ├── CE_Config │ ├── CE_Config.gml │ └── CE_Config.yy ├── CE_DeltaTime │ ├── CE_DeltaTime.gml │ └── CE_DeltaTime.yy ├── CE_DrawUtils │ ├── CE_DrawUtils.gml │ └── CE_DrawUtils.yy ├── CE_DualQuaternion │ ├── CE_DualQuaternion.gml │ └── CE_DualQuaternion.yy ├── CE_EmptyIterator │ ├── CE_EmptyIterator.gml │ └── CE_EmptyIterator.yy ├── CE_Entity │ ├── CE_Entity.gml │ └── CE_Entity.yy ├── CE_Exception │ ├── CE_Exception.gml │ └── CE_Exception.yy ├── CE_GUI │ ├── CE_GUI.gml │ └── CE_GUI.yy ├── CE_GUIBlurEvent │ ├── CE_GUIBlurEvent.gml │ └── CE_GUIBlurEvent.yy ├── CE_GUIChangeEvent │ ├── CE_GUIChangeEvent.gml │ └── CE_GUIChangeEvent.yy ├── CE_GUIClickEvent │ ├── CE_GUIClickEvent.gml │ └── CE_GUIClickEvent.yy ├── CE_GUIContainer │ ├── CE_GUIContainer.gml │ └── CE_GUIContainer.yy ├── CE_GUICreate_ │ ├── CE_GUICreate_.gml │ └── CE_GUICreate_.yy ├── CE_GUIDeactivateEvent │ ├── CE_GUIDeactivateEvent.gml │ └── CE_GUIDeactivateEvent.yy ├── CE_GUIDragEndEvent │ ├── CE_GUIDragEndEvent.gml │ └── CE_GUIDragEndEvent.yy ├── CE_GUIDragEvent │ ├── CE_GUIDragEvent.gml │ └── CE_GUIDragEvent.yy ├── CE_GUIDragStartEvent │ ├── CE_GUIDragStartEvent.gml │ └── CE_GUIDragStartEvent.yy ├── CE_GUIEvent │ ├── CE_GUIEvent.gml │ └── CE_GUIEvent.yy ├── CE_GUIFocusEvent │ ├── CE_GUIFocusEvent.gml │ └── CE_GUIFocusEvent.yy ├── CE_GUIHSlider │ ├── CE_GUIHSlider.gml │ └── CE_GUIHSlider.yy ├── CE_GUIInput │ ├── CE_GUIInput.gml │ └── CE_GUIInput.yy ├── CE_GUIKeyDownEvent │ ├── CE_GUIKeyDownEvent.gml │ └── CE_GUIKeyDownEvent.yy ├── CE_GUIKeyPressEvent │ ├── CE_GUIKeyPressEvent.gml │ └── CE_GUIKeyPressEvent.yy ├── CE_GUIRoot │ ├── CE_GUIRoot.gml │ └── CE_GUIRoot.yy ├── CE_GUIWidget │ ├── CE_GUIWidget.gml │ └── CE_GUIWidget.yy ├── CE_GetCallingFunctionName │ ├── CE_GetCallingFunctionName.gml │ └── CE_GetCallingFunctionName.yy ├── CE_Hex │ ├── CE_Hex.gml │ └── CE_Hex.yy ├── CE_IOException │ ├── CE_IOException.gml │ └── CE_IOException.yy ├── CE_Input │ ├── CE_Input.gml │ └── CE_Input.yy ├── CE_InstanceUtils │ ├── CE_InstanceUtils.gml │ └── CE_InstanceUtils.yy ├── CE_Iterator │ ├── CE_Iterator.gml │ └── CE_Iterator.yy ├── CE_ListIterator │ ├── CE_ListIterator.gml │ └── CE_ListIterator.yy ├── CE_ListUtils │ ├── CE_ListUtils.gml │ └── CE_ListUtils.yy ├── CE_MapIterator │ ├── CE_MapIterator.gml │ └── CE_MapIterator.yy ├── CE_MapIteratorEntry │ ├── CE_MapIteratorEntry.gml │ └── CE_MapIteratorEntry.yy ├── CE_MapUtils │ ├── CE_MapUtils.gml │ └── CE_MapUtils.yy ├── CE_MathMisc │ ├── CE_MathMisc.gml │ └── CE_MathMisc.yy ├── CE_Matrix │ ├── CE_Matrix.gml │ └── CE_Matrix.yy ├── CE_NativeArray │ ├── CE_NativeArray.gml │ └── CE_NativeArray.yy ├── CE_NavGrid │ ├── CE_NavGrid.gml │ └── CE_NavGrid.yy ├── CE_NavGridPath │ ├── CE_NavGridPath.gml │ └── CE_NavGridPath.yy ├── CE_NotImplementedException │ ├── CE_NotImplementedException.gml │ └── CE_NotImplementedException.yy ├── CE_ObjectUtils │ ├── CE_ObjectUtils.gml │ └── CE_ObjectUtils.yy ├── CE_OutOfRangeException │ ├── CE_OutOfRangeException.gml │ └── CE_OutOfRangeException.yy ├── CE_Quaternion │ ├── CE_Quaternion.gml │ └── CE_Quaternion.yy ├── CE_RealUtils │ ├── CE_RealUtils.gml │ └── CE_RealUtils.yy ├── CE_StateMachine │ ├── CE_StateMachine.gml │ └── CE_StateMachine.yy ├── CE_StateMachineState │ ├── CE_StateMachineState.gml │ └── CE_StateMachineState.yy ├── CE_StringUtils │ ├── CE_StringUtils.gml │ └── CE_StringUtils.yy ├── CE_StructUtils │ ├── CE_StructUtils.gml │ └── CE_StructUtils.yy ├── CE_SurfaceUtils │ ├── CE_SurfaceUtils.gml │ └── CE_SurfaceUtils.yy ├── CE_TimeUtils │ ├── CE_TimeUtils.gml │ └── CE_TimeUtils.yy ├── CE_Timer │ ├── CE_Timer.gml │ └── CE_Timer.yy ├── CE_TimerTimeout │ ├── CE_TimerTimeout.gml │ └── CE_TimerTimeout.yy ├── CE_Tween │ ├── CE_Tween.gml │ └── CE_Tween.yy ├── CE_UUID │ ├── CE_UUID.gml │ └── CE_UUID.yy ├── CE_Vec2 │ ├── CE_Vec2.gml │ └── CE_Vec2.yy ├── CE_Vec3 │ ├── CE_Vec3.gml │ └── CE_Vec3.yy ├── CE_Vec4 │ ├── CE_Vec4.gml │ └── CE_Vec4.yy ├── CE_XMLDocument │ ├── CE_XMLDocument.gml │ └── CE_XMLDocument.yy ├── CE_XMLElement │ ├── CE_XMLElement.gml │ └── CE_XMLElement.yy └── CE_XMLValue │ ├── CE_XMLValue.gml │ └── CE_XMLValue.yy ├── shaders ├── CE_ShClearColor │ ├── CE_ShClearColor.fsh │ ├── CE_ShClearColor.vsh │ └── CE_ShClearColor.yy ├── CE_ShGaussianBlur │ ├── CE_ShGaussianBlur.fsh │ ├── CE_ShGaussianBlur.vsh │ └── CE_ShGaussianBlur.yy └── CE_ShNavGrid │ ├── CE_ShNavGrid.fsh │ ├── CE_ShNavGrid.vsh │ └── CE_ShNavGrid.yy └── sprites └── CE_SprRectangle ├── 40c214dd-f3dd-4577-a620-273b2694354f.png ├── CE_SprRectangle.yy └── layers └── 40c214dd-f3dd-4577-a620-273b2694354f └── a88aa6ab-c8f0-4edf-ab96-41afa065b2bc.png /.gitattributes: -------------------------------------------------------------------------------- 1 | docs_src/* linguist-documentation -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /docs_build/ 2 | /docs_src/ScriptingAPI/ 3 | !.gitkeep 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoreExtension 2 | > CoreExtension (CE) is a collection of CC0 programming libraries for GameMaker Studio 2 3 | 4 | [![License](https://img.shields.io/github/license/blueburn-cz/CoreExtension)](LICENSE) 5 | [![Discord](https://img.shields.io/discord/298884075585011713?label=Discord)](https://discord.gg/ep2BGPm) 6 | 7 | # Table of Contents 8 | * [License](#license) 9 | * [Projects using CE](#projects-using-ce) 10 | * [Links](#links) 11 | 12 | # License 13 | CE is released under the CC0 license, which means you can use it for free without giving its authors any credits whatsoever! See [LICENSE](LICENSE) for the full license text. 14 | 15 | # Projects using CE 16 | * [BBMOD](https://marketplace.yoyogames.com/assets/10210/bbmod-3) 17 | * Your project here? 18 | 19 | # Links 20 | * [Discord](https://discord.gg/ep2BGPm) 21 | -------------------------------------------------------------------------------- /docs_src/ScriptingAPI.md: -------------------------------------------------------------------------------- 1 | # Scripting API 2 | In this section you can find documentation for all functions, structs, enums, macros and global variables contained in CoreExtension. 3 | -------------------------------------------------------------------------------- /docs_src/index.md: -------------------------------------------------------------------------------- 1 | # CoreExtension 2 | Welcome to the official documentation of the latest version of CoreExtension (CE), a collection of CC0 programming libraries for GameMaker Studio 2! 3 | 4 | ## Links 5 | * [GitHub](https://github.com/blueburn-cz/CoreExtension) 6 | -------------------------------------------------------------------------------- /gmdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "_version": 2, 3 | "project": "ce.yyp", 4 | "project_name": "CoreExtension", 5 | "title": "CoreExtension Docs", 6 | "author": "BlueBurn", 7 | "prefix": "CE_", 8 | "toc": { 9 | "CE Docs": "index.md" 10 | } 11 | } -------------------------------------------------------------------------------- /objects/CE_OGUI/CE_OGUI.yy: -------------------------------------------------------------------------------- 1 | { 2 | "spriteId": null, 3 | "solid": false, 4 | "visible": true, 5 | "spriteMaskId": null, 6 | "persistent": false, 7 | "parentObjectId": null, 8 | "physicsObject": false, 9 | "physicsSensor": false, 10 | "physicsShape": 1, 11 | "physicsGroup": 1, 12 | "physicsDensity": 0.5, 13 | "physicsRestitution": 0.1, 14 | "physicsLinearDamping": 0.1, 15 | "physicsAngularDamping": 0.1, 16 | "physicsFriction": 0.2, 17 | "physicsStartAwake": true, 18 | "physicsKinematic": false, 19 | "physicsShapePoints": [], 20 | "eventList": [ 21 | {"isDnD":false,"eventNum":0,"eventType":0,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 22 | {"isDnD":false,"eventNum":0,"eventType":12,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 23 | {"isDnD":false,"eventNum":0,"eventType":3,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 24 | {"isDnD":false,"eventNum":64,"eventType":8,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 25 | {"isDnD":false,"eventNum":53,"eventType":6,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 26 | {"isDnD":false,"eventNum":1,"eventType":9,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 27 | {"isDnD":false,"eventNum":64,"eventType":13,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 28 | {"isDnD":false,"eventNum":66,"eventType":13,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 29 | {"isDnD":false,"eventNum":67,"eventType":13,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 30 | {"isDnD":false,"eventNum":68,"eventType":13,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 31 | {"isDnD":false,"eventNum":13,"eventType":9,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 32 | {"isDnD":false,"eventNum":1,"eventType":5,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",}, 33 | ], 34 | "properties": [], 35 | "overriddenProperties": [], 36 | "parent": { 37 | "name": "GUI", 38 | "path": "folders/CoreExtension/GUI.yy", 39 | }, 40 | "resourceVersion": "1.0", 41 | "name": "CE_OGUI", 42 | "tags": [], 43 | "resourceType": "GMObject", 44 | } -------------------------------------------------------------------------------- /objects/CE_OGUI/CleanUp_0.gml: -------------------------------------------------------------------------------- 1 | gui.Destroy(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Create_0.gml: -------------------------------------------------------------------------------- 1 | gui = new CE_GUIRoot(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Draw_64.gml: -------------------------------------------------------------------------------- 1 | gui.Draw(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Gesture_64.gml: -------------------------------------------------------------------------------- 1 | gui.GlobalTap(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Gesture_66.gml: -------------------------------------------------------------------------------- 1 | gui.GlobalDragStart(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Gesture_67.gml: -------------------------------------------------------------------------------- 1 | gui.GlobalDragging(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Gesture_68.gml: -------------------------------------------------------------------------------- 1 | gui.GlobalDragEnd(); -------------------------------------------------------------------------------- /objects/CE_OGUI/KeyPress_1.gml: -------------------------------------------------------------------------------- 1 | gui.KeyPressAny(); -------------------------------------------------------------------------------- /objects/CE_OGUI/KeyPress_13.gml: -------------------------------------------------------------------------------- 1 | gui.KeyPressEnter(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Keyboard_1.gml: -------------------------------------------------------------------------------- 1 | gui.KeyDownAny(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Mouse_53.gml: -------------------------------------------------------------------------------- 1 | gui.GlobalLeftPressed(); -------------------------------------------------------------------------------- /objects/CE_OGUI/Step_0.gml: -------------------------------------------------------------------------------- 1 | gui.Update(); -------------------------------------------------------------------------------- /options/amazonfire/options_amazonfire.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_amazonfire_sync_android": false, 3 | "option_amazonfire_display_name": "Created with GameMaker Studio 2", 4 | "option_amazonfire_version": "1.0.0.0", 5 | "option_amazonfire_tools_from_version": false, 6 | "option_amazonfire_build_tools": "", 7 | "option_amazonfire_support_lib": "", 8 | "option_amazonfire_target_sdk": "", 9 | "option_amazonfire_minimum_sdk": "", 10 | "option_amazonfire_compile_sdk": "", 11 | "option_amazonfire_package_domain": "com", 12 | "option_amazonfire_package_company": "company", 13 | "option_amazonfire_package_product": "game", 14 | "option_amazonfire_orient_portrait": true, 15 | "option_amazonfire_orient_portrait_flipped": true, 16 | "option_amazonfire_orient_landscape": true, 17 | "option_amazonfire_orient_landscape_flipped": true, 18 | "option_amazonfire_gamepad_support": true, 19 | "option_amazonfire_lint": false, 20 | "option_amazonfire_install_location": 0, 21 | "option_amazonfire_sleep_margin": 4, 22 | "option_amazonfire_splash_screens_landscape": "${base_options_dir}/amazonfire/splash/landscape.png", 23 | "option_amazonfire_splash_screens_portrait": "${base_options_dir}/amazonfire/splash/portrait.png", 24 | "option_amazonfire_splash_time": 0, 25 | "option_amazonfire_launchscreen_fill": 0, 26 | "option_amazonfire_splashscreen_background_colour": 255, 27 | "option_amazonfire_tv_banner": "${base_options_dir}/amazonfire/tv_banner.png", 28 | "option_amazonfire_interpolate_pixels": false, 29 | "option_amazonfire_screen_depth": 0, 30 | "option_amazonfire_scale": 0, 31 | "option_amazonfire_texture_page": "2048x2048", 32 | "option_amazonfire_icon_ldpi": "${base_options_dir}/android/icons/ldpi.png", 33 | "option_amazonfire_icon_mdpi": "${base_options_dir}/android/icons/mdpi.png", 34 | "option_amazonfire_icon_hdpi": "${base_options_dir}/android/icons/hdpi.png", 35 | "option_amazonfire_icon_xhdpi": "${base_options_dir}/android/icons/xhdpi.png", 36 | "option_amazonfire_icon_xxhdpi": "${base_options_dir}/android/icons/xxhdpi.png", 37 | "option_amazonfire_icon_xxxhdpi": "${base_options_dir}/android/icons/xxxhdpi.png", 38 | "option_amazonfire_permission_write_external_storage": false, 39 | "option_amazonfire_permission_read_phone_state": false, 40 | "option_amazonfire_permission_network_state": false, 41 | "option_amazonfire_permission_internet": true, 42 | "option_amazonfire_permission_bluetooth": true, 43 | "option_amazonfire_permission_record_audio": false, 44 | "option_amazonfire_application_tag_inject": "", 45 | "resourceVersion": "1.0", 46 | "name": "Amazon Fire", 47 | "tags": [], 48 | "resourceType": "GMAmazonFireOptions", 49 | } -------------------------------------------------------------------------------- /options/android/options_android.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_android_sync_amazon": false, 3 | "option_android_display_name": "Created with GameMaker Studio 2", 4 | "option_android_version": "1.0.0.0", 5 | "option_android_tools_from_version": false, 6 | "option_android_build_tools": "", 7 | "option_android_support_lib": "30.0.0", 8 | "option_android_target_sdk": "30", 9 | "option_android_minimum_sdk": "16", 10 | "option_android_compile_sdk": "30", 11 | "option_android_package_domain": "com", 12 | "option_android_package_company": "company", 13 | "option_android_package_product": "game", 14 | "option_android_arch_armv7": true, 15 | "option_android_arch_x86": true, 16 | "option_android_arch_arm64": true, 17 | "option_android_arch_x86_64": true, 18 | "option_android_orient_portrait": true, 19 | "option_android_orient_portrait_flipped": true, 20 | "option_android_orient_landscape": false, 21 | "option_android_orient_landscape_flipped": false, 22 | "option_android_gamepad_support": true, 23 | "option_android_lint": false, 24 | "option_android_install_location": 0, 25 | "option_android_sleep_margin": 4, 26 | "option_android_splash_screens_landscape": "${base_options_dir}/android/splash/landscape.png", 27 | "option_android_splash_screens_portrait": "${base_options_dir}/android/splash/portrait.png", 28 | "option_android_splash_time": 0, 29 | "option_android_launchscreen_fill": 0, 30 | "option_android_splashscreen_background_colour": 255, 31 | "option_android_tv_banner": "${base_options_dir}/android/tv_banner.png", 32 | "option_android_interpolate_pixels": false, 33 | "option_android_screen_depth": 1, 34 | "option_android_device_support": 0, 35 | "option_android_scale": 1, 36 | "option_android_texture_page": "2048x2048", 37 | "option_android_icon_ldpi": "${base_options_dir}/android/icons/ldpi.png", 38 | "option_android_icon_mdpi": "${base_options_dir}/android/icons/mdpi.png", 39 | "option_android_icon_hdpi": "${base_options_dir}/android/icons/hdpi.png", 40 | "option_android_icon_xhdpi": "${base_options_dir}/android/icons/xhdpi.png", 41 | "option_android_icon_xxhdpi": "${base_options_dir}/android/icons/xxhdpi.png", 42 | "option_android_icon_xxxhdpi": "${base_options_dir}/android/icons/xxxhdpi.png", 43 | "option_android_icon_adaptive_generate": false, 44 | "option_android_icon_adaptive_ldpi": "${base_options_dir}/android/icons_adaptive/ldpi.png", 45 | "option_android_icon_adaptive_mdpi": "${base_options_dir}/android/icons_adaptive/mdpi.png", 46 | "option_android_icon_adaptive_hdpi": "${base_options_dir}/android/icons_adaptive/hdpi.png", 47 | "option_android_icon_adaptive_xhdpi": "${base_options_dir}/android/icons_adaptive/xhdpi.png", 48 | "option_android_icon_adaptive_xxhdpi": "${base_options_dir}/android/icons_adaptive/xxhdpi.png", 49 | "option_android_icon_adaptive_xxxhdpi": "${base_options_dir}/android/icons_adaptive/xxxhdpi.png", 50 | "option_android_icon_adaptivebg_ldpi": "${base_options_dir}/android/icons_adaptivebg/ldpi.png", 51 | "option_android_icon_adaptivebg_mdpi": "${base_options_dir}/android/icons_adaptivebg/mdpi.png", 52 | "option_android_icon_adaptivebg_hdpi": "${base_options_dir}/android/icons_adaptivebg/hdpi.png", 53 | "option_android_icon_adaptivebg_xhdpi": "${base_options_dir}/android/icons_adaptivebg/xhdpi.png", 54 | "option_android_icon_adaptivebg_xxhdpi": "${base_options_dir}/android/icons_adaptivebg/xxhdpi.png", 55 | "option_android_icon_adaptivebg_xxxhdpi": "${base_options_dir}/android/icons_adaptivebg/xxxhdpi.png", 56 | "option_android_use_facebook": false, 57 | "option_android_facebook_id": "", 58 | "option_android_facebook_app_display_name": "", 59 | "option_android_google_cloud_saving": false, 60 | "option_android_google_services_app_id": "", 61 | "option_android_permission_write_external_storage": false, 62 | "option_android_permission_read_phone_state": false, 63 | "option_android_permission_network_state": false, 64 | "option_android_permission_internet": true, 65 | "option_android_permission_bluetooth": true, 66 | "option_android_permission_record_audio": false, 67 | "option_android_application_tag_inject": "", 68 | "option_android_google_apk_expansion": false, 69 | "option_android_google_dynamic_asset_delivery": false, 70 | "option_android_google_licensing_public_key": "", 71 | "option_android_tv_isgame": true, 72 | "resourceVersion": "1.0", 73 | "name": "Android", 74 | "tags": [], 75 | "resourceType": "GMAndroidOptions", 76 | } -------------------------------------------------------------------------------- /options/html5/options_html5.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_html5_browser_title": "Created with GameMaker Studio 2", 3 | "option_html5_version": "1.0.0.0", 4 | "option_html5_foldername": "html5game", 5 | "option_html5_outputname": "index.html", 6 | "option_html5_splash_png": "${base_options_dir}/html5/splash.png", 7 | "option_html5_usesplash": false, 8 | "option_html5_outputdebugtoconsole": false, 9 | "option_html5_display_cursor": true, 10 | "option_html5_localrunalert": true, 11 | "option_html5_index": "", 12 | "option_html5_loadingbar": "", 13 | "option_html5_jsprepend": "", 14 | "option_html5_icon": "${base_options_dir}/html5/fav.ico", 15 | "option_html5_allow_fullscreen": true, 16 | "option_html5_interpolate_pixels": true, 17 | "option_html5_centregame": false, 18 | "option_html5_usebuiltinparticles": true, 19 | "option_html5_usebuiltinfont": true, 20 | "option_html5_webgl": 2, 21 | "option_html5_scale": 0, 22 | "option_html5_texture_page": "2048x2048", 23 | "option_html5_use_facebook": false, 24 | "option_html5_facebook_id": "", 25 | "option_html5_facebook_app_display_name": "", 26 | "option_html5_flurry_enable": false, 27 | "option_html5_flurry_id": "", 28 | "option_html5_google_analytics_enable": false, 29 | "option_html5_google_tracking_id": "", 30 | "resourceVersion": "1.0", 31 | "name": "HTML5", 32 | "tags": [], 33 | "resourceType": "GMHtml5Options", 34 | } -------------------------------------------------------------------------------- /options/ios/options_ios.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_ios_display_name": "Created with GameMaker Studio 2", 3 | "option_ios_bundle_name": "com.company.game", 4 | "option_ios_version": "1.0.0.0", 5 | "option_ios_output_dir": "~/gamemakerstudio2", 6 | "option_ios_team_id": "", 7 | "option_ios_orientation_portrait": true, 8 | "option_ios_orientation_portrait_flipped": true, 9 | "option_ios_orientation_landscape": true, 10 | "option_ios_orientation_landscape_flipped": true, 11 | "option_ios_devices": 2, 12 | "option_ios_defer_home_indicator": false, 13 | "option_ios_icon_iphone_app_120": "${base_options_dir}/ios/icons/app/iphone_120.png", 14 | "option_ios_icon_iphone_app_180": "${base_options_dir}/ios/icons/app/iphone_180.png", 15 | "option_ios_icon_ipad_app_76": "${base_options_dir}/ios/icons/app/ipad_76.png", 16 | "option_ios_icon_ipad_app_152": "${base_options_dir}/ios/icons/app/ipad_152.png", 17 | "option_ios_icon_ipad_pro_app_167": "${base_options_dir}/ios/icons/app/ipad_pro_167.png", 18 | "option_ios_icon_iphone_notification_40": "${base_options_dir}/ios/icons/notification/iphone_40.png", 19 | "option_ios_icon_iphone_notification_60": "${base_options_dir}/ios/icons/notification/iphone_60.png", 20 | "option_ios_icon_ipad_notification_20": "${base_options_dir}/ios/icons/notification/ipad_20.png", 21 | "option_ios_icon_ipad_notification_40": "${base_options_dir}/ios/icons/notification/ipad_40.png", 22 | "option_ios_icon_iphone_spotlight_80": "${base_options_dir}/ios/icons/spotlight/iphone_80.png", 23 | "option_ios_icon_iphone_spotlight_120": "${base_options_dir}/ios/icons/spotlight/iphone_120.png", 24 | "option_ios_icon_ipad_spotlight_40": "${base_options_dir}/ios/icons/spotlight/ipad_40.png", 25 | "option_ios_icon_ipad_spotlight_80": "${base_options_dir}/ios/icons/spotlight/ipad_80.png", 26 | "option_ios_icon_iphone_settings_58": "${base_options_dir}/ios/icons/settings/iphone_58.png", 27 | "option_ios_icon_iphone_settings_87": "${base_options_dir}/ios/icons/settings/iphone_87.png", 28 | "option_ios_icon_ipad_settings_29": "${base_options_dir}/ios/icons/settings/ipad_29.png", 29 | "option_ios_icon_ipad_settings_58": "${base_options_dir}/ios/icons/settings/ipad_58.png", 30 | "option_ios_icon_itunes_artwork_1024": "${base_options_dir}/ios/icons/itunes/itunes_1024.png", 31 | "option_ios_splashscreen_background_colour": 255, 32 | "option_ios_launchscreen_image": "${base_options_dir}/ios/splash/launchscreen.png", 33 | "option_ios_launchscreen_image_landscape": "${base_options_dir}/ios/splash/launchscreen-landscape.png", 34 | "option_ios_launchscreen_fill": 0, 35 | "option_ios_interpolate_pixels": false, 36 | "option_ios_half_ipad1_textures": false, 37 | "option_ios_scale": 0, 38 | "option_ios_texture_page": "2048x2048", 39 | "option_ios_use_facebook": false, 40 | "option_ios_facebook_id": "", 41 | "option_ios_facebook_app_display_name": "", 42 | "option_ios_push_notifications": false, 43 | "option_ios_apple_sign_in": false, 44 | "option_ios_podfile_path": "${options_dir}/ios/Podfile", 45 | "option_ios_podfile_lock_path": "${options_dir}/ios/Podfile.lock", 46 | "resourceVersion": "1.3", 47 | "name": "iOS", 48 | "tags": [], 49 | "resourceType": "GMiOSOptions", 50 | } -------------------------------------------------------------------------------- /options/linux/options_linux.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_linux_display_name": "Created with GameMaker Studio 2", 3 | "option_linux_version": "1.0.0.0", 4 | "option_linux_maintainer_email": "", 5 | "option_linux_homepage": "http://www.yoyogames.com", 6 | "option_linux_short_desc": "", 7 | "option_linux_long_desc": "", 8 | "option_linux_splash_screen": "${base_options_dir}/linux/splash/splash.png", 9 | "option_linux_display_splash": false, 10 | "option_linux_icon": "${base_options_dir}/linux/icons/64.png", 11 | "option_linux_start_fullscreen": false, 12 | "option_linux_allow_fullscreen": false, 13 | "option_linux_interpolate_pixels": true, 14 | "option_linux_display_cursor": true, 15 | "option_linux_sync": false, 16 | "option_linux_resize_window": false, 17 | "option_linux_scale": 0, 18 | "option_linux_texture_page": "2048x2048", 19 | "option_linux_enable_steam": false, 20 | "option_linux_disable_sandbox": false, 21 | "resourceVersion": "1.0", 22 | "name": "Linux", 23 | "tags": [], 24 | "resourceType": "GMLinuxOptions", 25 | } -------------------------------------------------------------------------------- /options/mac/options_mac.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_mac_display_name": "Created with GameMaker Studio 2", 3 | "option_mac_app_id": "com.company.game", 4 | "option_mac_version": "1.0.0.0", 5 | "option_mac_output_dir": "~/gamemakerstudio2", 6 | "option_mac_team_id": "", 7 | "option_mac_signing_identity": "Developer ID Application:", 8 | "option_mac_copyright": "", 9 | "option_mac_splash_png": "${base_options_dir}/mac/splash/splash.png", 10 | "option_mac_icon_png": "${base_options_dir}/mac/icons/1024.png", 11 | "option_mac_installer_background_png": "${base_options_dir}/mac/splash/installer_background.png", 12 | "option_mac_menu_dock": false, 13 | "option_mac_display_cursor": true, 14 | "option_mac_start_fullscreen": false, 15 | "option_mac_allow_fullscreen": false, 16 | "option_mac_interpolate_pixels": true, 17 | "option_mac_vsync": false, 18 | "option_mac_resize_window": false, 19 | "option_mac_enable_retina": false, 20 | "option_mac_scale": 0, 21 | "option_mac_texture_page": "2048x2048", 22 | "option_mac_build_app_store": false, 23 | "option_mac_allow_incoming_network": false, 24 | "option_mac_allow_outgoing_network": false, 25 | "option_mac_app_category": "Games", 26 | "option_mac_enable_steam": false, 27 | "option_mac_disable_sandbox": false, 28 | "option_mac_apple_sign_in": false, 29 | "resourceVersion": "1.0", 30 | "name": "macOS", 31 | "tags": [], 32 | "resourceType": "GMMacOptions", 33 | } -------------------------------------------------------------------------------- /options/main/options_main.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_gameguid": "17d3fd50-f248-46f5-a2fa-5028c0ea2461", 3 | "option_gameid": "0", 4 | "option_game_speed": 60, 5 | "option_mips_for_3d_textures": false, 6 | "option_draw_colour": 4294967295, 7 | "option_window_colour": 255, 8 | "option_steam_app_id": "0", 9 | "option_sci_usesci": false, 10 | "option_author": "", 11 | "option_lastchanged": "", 12 | "option_spine_licence": false, 13 | "option_template_image": "${base_options_dir}/main/template_image.png", 14 | "option_template_icon": "${base_options_dir}/main/template_icon.png", 15 | "option_template_description": null, 16 | "resourceVersion": "1.2", 17 | "name": "Main", 18 | "tags": [], 19 | "resourceType": "GMMainOptions", 20 | } -------------------------------------------------------------------------------- /options/operagx/options_operagx.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_operagx_version": "1.0.0.0", 3 | "option_operagx_game_name": "${project_name}", 4 | "option_operagx_interpolate_pixels": true, 5 | "option_operagx_scale": 0, 6 | "option_operagx_texture_page": "2048x2048", 7 | "resourceVersion": "1.0", 8 | "name": "operagx", 9 | "tags": [], 10 | "resourceType": "GMOperaGXOptions", 11 | } -------------------------------------------------------------------------------- /options/tvos/options_tvos.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_tvos_display_name": "Made in GameMaker Studio 2", 3 | "option_tvos_bundle_name": "com.company.game", 4 | "option_tvos_version": "1.0.0.0", 5 | "option_tvos_output_dir": "~/GameMakerStudio2/tvOS", 6 | "option_tvos_team_id": "", 7 | "option_tvos_icon_400": "${base_options_dir}/tvos/icons/400.png", 8 | "option_tvos_icon_400_2x": "${base_options_dir}/tvos/icons/400_2x.png", 9 | "option_tvos_icon_1280": "${base_options_dir}/tvos/icons/1280.png", 10 | "option_tvos_topshelf": "${base_options_dir}/tvos/topshelf/topshelf.png", 11 | "option_tvos_topshelf_2x": "${base_options_dir}/tvos/topshelf/topshelf_2x.png", 12 | "option_tvos_topshelf_wide": "${base_options_dir}/tvos/topshelf/topshelf_wide.png", 13 | "option_tvos_topshelf_wide_2x": "${base_options_dir}/tvos/topshelf/topshelf_wide_2x.png", 14 | "option_tvos_splashscreen": "${base_options_dir}/tvos/splash/splash.png", 15 | "option_tvos_splashscreen_2x": "${base_options_dir}/tvos/splash/splash_2x.png", 16 | "option_tvos_splash_time": 0, 17 | "option_tvos_interpolate_pixels": true, 18 | "option_tvos_scale": 0, 19 | "option_tvos_texture_page": "2048x2048", 20 | "option_tvos_display_cursor": false, 21 | "option_tvos_push_notifications": false, 22 | "option_tvos_apple_sign_in": false, 23 | "option_tvos_podfile_path": "${options_dir}\\tvos\\Podfile", 24 | "option_tvos_podfile_lock_path": "${options_dir}\\tvos\\Podfile.lock", 25 | "resourceVersion": "1.3", 26 | "name": "tvOS", 27 | "tags": [], 28 | "resourceType": "GMtvOSOptions", 29 | } -------------------------------------------------------------------------------- /options/windows/options_windows.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_windows_display_name": "Created with GameMaker Studio 2", 3 | "option_windows_executable_name": "${project_name}.exe", 4 | "option_windows_version": "1.0.0.0", 5 | "option_windows_company_info": "YoYo Games Ltd", 6 | "option_windows_product_info": "Created with GameMaker Studio 2", 7 | "option_windows_copyright_info": "", 8 | "option_windows_description_info": "A GameMaker Studio 2 Game", 9 | "option_windows_display_cursor": true, 10 | "option_windows_icon": "${base_options_dir}/windows/icons/icon.ico", 11 | "option_windows_save_location": 0, 12 | "option_windows_splash_screen": "${base_options_dir}/windows/splash/splash.png", 13 | "option_windows_use_splash": false, 14 | "option_windows_start_fullscreen": false, 15 | "option_windows_allow_fullscreen_switching": true, 16 | "option_windows_interpolate_pixels": false, 17 | "option_windows_vsync": false, 18 | "option_windows_resize_window": true, 19 | "option_windows_borderless": false, 20 | "option_windows_scale": 1, 21 | "option_windows_copy_exe_to_dest": false, 22 | "option_windows_sleep_margin": 10, 23 | "option_windows_texture_page": "2048x2048", 24 | "option_windows_installer_finished": "${base_options_dir}/windows/installer/finished.bmp", 25 | "option_windows_installer_header": "${base_options_dir}/windows/installer/header.bmp", 26 | "option_windows_license": "${base_options_dir}/windows/installer/license.txt", 27 | "option_windows_nsis_file": "${base_options_dir}/windows/installer/nsis_script.nsi", 28 | "option_windows_enable_steam": false, 29 | "option_windows_disable_sandbox": false, 30 | "option_windows_steam_use_alternative_launcher": false, 31 | "option_windows_use_x64": false, 32 | "resourceVersion": "1.1", 33 | "name": "Windows", 34 | "tags": [], 35 | "resourceType": "GMWindowsOptions", 36 | } -------------------------------------------------------------------------------- /options/windowsuap/options_windowsuap.yy: -------------------------------------------------------------------------------- 1 | { 2 | "option_windowsuap_display_name": "Created with GameMaker Studio 2", 3 | "option_windowsuap_package_name": "YourPackageName", 4 | "option_windowsuap_publisher_display_name": "YourPublisherName", 5 | "option_windowsuap_package_display_name": "YourPackageDisplayName", 6 | "option_windowsuap_description": "Your Description", 7 | "option_windowsuap_version": "1.0.0.0", 8 | "option_windowsuap_orient_portrait": true, 9 | "option_windowsuap_orient_portrait_flipped": true, 10 | "option_windowsuap_orient_landscape": true, 11 | "option_windowsuap_orient_landscape_flipped": true, 12 | "option_windowsuap_small_logo": "${base_options_dir}/windowsuap/logos/SmallLogo.scale-100.png", 13 | "option_windowsuap_smallish_logo": "${base_options_dir}/windowsuap/logos/SmallishLogo.scale-100.png", 14 | "option_windowsuap_store_logo": "${base_options_dir}/windowsuap/logos/StoreLogo.scale-100.png", 15 | "option_windowsuap_logo": "${base_options_dir}/windowsuap/logos/Logo.scale-100.png", 16 | "option_windowsuap_logo_background_colour": 4278190080, 17 | "option_windowsuap_logo_foreground_text": 0, 18 | "option_windowsuap_wide_logo": "${base_options_dir}/windowsuap/logos/WideLogo.scale-100.png", 19 | "option_windowsuap_large_logo": "${base_options_dir}/windowsuap/logos/LargeLogo.scale-100.png", 20 | "option_windowsuap_splash_png": "${base_options_dir}/windowsuap/splash/SplashScreen.scale-100.png", 21 | "option_windowsuap_splash_background_colour": 4278190080, 22 | "option_windowsuap_interpolate_pixels": false, 23 | "option_windowsuap_display_cursor": true, 24 | "option_windowsuap_start_fullscreen": false, 25 | "option_windowsuap_allow_fullscreen_switching": false, 26 | "option_windowsuap_use_synchronization": true, 27 | "option_windowsuap_scale": 0, 28 | "option_windowsuap_texture_page": "2048x2048", 29 | "option_windowsuap_certificate_location": "${base_options_dir}\\windowsuap\\keys\\WinUWPRunner_TemporaryKey.pfx", 30 | "option_windowsuap_certificate_publishername": "CN=Sandbox", 31 | "option_windowsuap_native_cpu": 0, 32 | "option_windowsuap_internet_capable": false, 33 | "option_windowsuap_microphone_capable": false, 34 | "option_windowsuap_iap_sandbox": false, 35 | "option_windowsuap_targetdevicefamily_universal": true, 36 | "option_windowsuap_target_platform_version": "10.0.14393.0", 37 | "option_windowsuap_target_platform_min_version": "10.0.14393.0", 38 | "option_windowsuap_targetdevicefamily_desktop": false, 39 | "option_windowsuap_desktop_family_platform_version": "10.0.14393.0", 40 | "option_windowsuap_desktop_family_platform_min_version": "10.0.14393.0", 41 | "option_windowsuap_targetdevicefamily_xbox": false, 42 | "option_windowsuap_xbox_family_platform_version": "10.0.14393.0", 43 | "option_windowsuap_xbox_family_platform_min_version": "10.0.14393.0", 44 | "option_windowsuap_targetdevicefamily_mobile": false, 45 | "option_windowsuap_mobile_family_platform_version": "10.0.14393.0", 46 | "option_windowsuap_mobile_family_platform_min_version": "10.0.14393.0", 47 | "option_windowsuap_targetdevicefamily_holographic": false, 48 | "option_windowsuap_holographic_family_platform_version": "10.0.14393.0", 49 | "option_windowsuap_holographic_family_platform_min_version": "10.0.14393.0", 50 | "option_windowsuap_targetdevicefamily_team": false, 51 | "option_windowsuap_team_family_platform_version": "10.0.14393.0", 52 | "option_windowsuap_team_family_platform_min_version": "10.0.14393.0", 53 | "option_windowsuap_xbox_live": false, 54 | "option_windowsuap_xbox_live_creators_program": false, 55 | "option_windowsuap_xbox_live_title_id": "0", 56 | "option_windowsuap_xbox_live_scid": "00000000-0000-0000-0000-000000000000", 57 | "resourceVersion": "1.0", 58 | "name": "Windows UWP", 59 | "tags": [], 60 | "resourceType": "GMWindowsUAPOptions", 61 | } -------------------------------------------------------------------------------- /rooms/RmTest/RmTest.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnd": false, 3 | "volume": 1.0, 4 | "parentRoom": null, 5 | "views": [ 6 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 7 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 8 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 9 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 10 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 11 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 12 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 13 | {"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,}, 14 | ], 15 | "layers": [ 16 | {"instances":[],"visible":true,"depth":0,"userdefinedDepth":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"gridX":32,"gridY":32,"layers":[],"hierarchyFrozen":false,"resourceVersion":"1.0","name":"Instances","tags":[],"resourceType":"GMRInstanceLayer",}, 17 | {"spriteId":null,"colour":4278190080,"x":0,"y":0,"htiled":false,"vtiled":false,"hspeed":0.0,"vspeed":0.0,"stretch":false,"animationFPS":15.0,"animationSpeedType":0,"userdefinedAnimFPS":false,"visible":true,"depth":100,"userdefinedDepth":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"gridX":32,"gridY":32,"layers":[],"hierarchyFrozen":false,"resourceVersion":"1.0","name":"Background","tags":[],"resourceType":"GMRBackgroundLayer",}, 18 | ], 19 | "inheritLayers": false, 20 | "creationCodeFile": "", 21 | "inheritCode": false, 22 | "instanceCreationOrder": [], 23 | "inheritCreationOrder": false, 24 | "sequenceId": null, 25 | "roomSettings": { 26 | "inheritRoomSettings": false, 27 | "Width": 1366, 28 | "Height": 768, 29 | "persistent": false, 30 | }, 31 | "viewSettings": { 32 | "inheritViewSettings": false, 33 | "enableViews": false, 34 | "clearViewBackground": false, 35 | "clearDisplayBuffer": true, 36 | }, 37 | "physicsSettings": { 38 | "inheritPhysicsSettings": false, 39 | "PhysicsWorld": false, 40 | "PhysicsWorldGravityX": 0.0, 41 | "PhysicsWorldGravityY": 10.0, 42 | "PhysicsWorldPixToMetres": 0.1, 43 | }, 44 | "parent": { 45 | "name": "Test", 46 | "path": "folders/Test.yy", 47 | }, 48 | "resourceVersion": "1.0", 49 | "name": "RmTest", 50 | "tags": [], 51 | "resourceType": "GMRoom", 52 | } -------------------------------------------------------------------------------- /scripts/CE_ArgumentException/CE_ArgumentException.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_ArgumentException() 2 | /// @extends CE_Exception 3 | /// @desc An exception thrown if an invalid argument is given to a function. 4 | function CE_ArgumentException(_argumentName) 5 | : CE_Exception("Invalid argument " + _argumentName + "!") constructor 6 | { 7 | CE_CLASS_GENERATED_BODY; 8 | } -------------------------------------------------------------------------------- /scripts/CE_ArgumentException/CE_ArgumentException.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Exceptions", 6 | "path": "folders/CoreExtension/Core/Exceptions.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_ArgumentException", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_ArrayUtils/CE_ArrayUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_ArrayUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Assert/CE_Assert.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_Assert(_exp, _msg) 2 | /// @desc Shows the error message if the expression is not a `real` (`bool`) or 3 | /// equals to `0` (`false`) and aborts the game. 4 | /// @param {any} _exp The expression to assert. 5 | /// @param {string} _msg The error message. 6 | /// @note Asserts work only when {@link CE_DEBUG} is Set to `true`! 7 | /// This is handy when you have thoroughly tested your game and you don't want to 8 | /// show error messages in release builds. 9 | /// @see CE_DEBUG 10 | function CE_Assert(_exp, _msg) 11 | { 12 | if (CE_DEBUG) 13 | { 14 | if (!(is_real(_exp) || is_bool(_exp)) || !_exp) 15 | { 16 | show_error(_msg, true); 17 | } 18 | } 19 | } 20 | 21 | /// @func CE_AssertDsExists(_id, _type, _msg) 22 | /// @desc Checks if the data structure of given id and type exists. If it 23 | /// does not, then aborts the game, showing the error message. 24 | /// @param {real} id The id of the ds. 25 | /// @param {real} type The ds type (`ds_type_map`, `ds_type_list`, ...). 26 | /// @param {string} msg The error message. 27 | /// @example 28 | /// ```gml 29 | /// var _map = ds_map_create(); 30 | /// CE_AssertDsExists(_map, ds_type_map, 31 | /// "This should pass, since we just created it."); 32 | /// ds_map_destroy(_map); 33 | /// CE_AssertDsExists(_map, ds_type_map, 34 | /// "This will abort the game just as expected."); 35 | /// ``` 36 | /// @note Asserts work only when {@link CE_DEBUG} is Set to `true`! 37 | /// This is handy when you have thoroughly tested your game and you don't want to 38 | /// show error messages in release builds. 39 | /// @see CE_DEBUG 40 | function CE_AssertDsExists(_id, _type, _msg) 41 | { 42 | if (CE_DEBUG) 43 | { 44 | if (!ds_exists(_id, _type)) 45 | { 46 | show_error(_msg, true); 47 | } 48 | } 49 | } 50 | 51 | /// @func CE_AssertEquals(_exp, _val, _msg) 52 | /// @desc Shows the error message if the expression is not equal to `val`. 53 | /// @param {any} _exp The expression to assert. 54 | /// @param {any} _val The expected value. 55 | /// @param {string} _msg The error message. 56 | /// @note Asserts work only when {@link CE_DEBUG} is Set to `true`! 57 | /// This is handy when you have thoroughly tested your game and you don't want to 58 | /// show error messages in release builds. 59 | /// @see CE_DEBUG 60 | function CE_AssertEquals(_exp, _val, _msg) 61 | { 62 | if (CE_DEBUG) 63 | { 64 | if (typeof(_exp) != typeof(_val) 65 | || _exp != _val) 66 | { 67 | show_error(_msg, true); 68 | } 69 | } 70 | } 71 | 72 | /// @func CE_AssertIsInt(_value, _msg) 73 | /// @desc Checks whether the given value is an integer, if not, shows the error 74 | /// message and aborts the game. 75 | /// @param {any} _value The value to check. 76 | /// @param {string} _msg The error message. 77 | /// @note Asserts work only when {@link CE_DEBUG} is Set to `true`! 78 | /// This is handy when you have thoroughly tested your game and you don't want to 79 | /// show error messages in release builds. 80 | /// @see CE_DEBUG 81 | function CE_AssertIsInt(_value, _msg) 82 | { 83 | if (CE_DEBUG) 84 | { 85 | if (!is_real(_value) 86 | || floor(_value) != _value) 87 | { 88 | show_error(_msg, true); 89 | } 90 | } 91 | } 92 | 93 | /// @func CE_AssertNotEquals(exp, val, msg) 94 | /// @desc Shows the error message if the expression is equal to `val`. 95 | /// @param {any} _exp The expression to assert. 96 | /// @param {any} _val The expected value. 97 | /// @param {string} _msg The error message. 98 | /// @note Asserts work only when {@link CE_DEBUG} is Set to `true`! 99 | /// This is handy when you have thoroughly tested your game and you don't want to 100 | /// show error messages in release builds. 101 | /// @see CE_DEBUG 102 | function CE_AssertNotEquals(_exp, _val, _msg) 103 | { 104 | if (CE_DEBUG) 105 | { 106 | if (typeof(_exp) == typeof(_val) 107 | && _exp == _val) 108 | { 109 | show_error(_msg, true); 110 | } 111 | } 112 | } -------------------------------------------------------------------------------- /scripts/CE_Assert/CE_Assert.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Core", 6 | "path": "folders/CoreExtension/Core.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Assert", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Class/CE_Class.gml: -------------------------------------------------------------------------------- 1 | /// @macro Must be the first line when defining a custom class! 2 | /// @example 3 | /// ```gml 4 | /// function CRectangle(_x, _y, _width, _height) 5 | /// : CE_Class() constructor 6 | /// { 7 | /// CE_CLASS_GENERATED_BODY; 8 | /// X = _x; 9 | /// Y = _y; 10 | /// Width = _width; 11 | /// Height = _height; 12 | /// } 13 | /// ``` 14 | #macro CE_CLASS_GENERATED_BODY \ 15 | static __ClassName = CE_GetCallingFunctionName(); \ // TODO: Could be instanceof? 16 | array_push(__Inheritance, __ClassName) 17 | 18 | /// @func CE_Class() 19 | /// @desc Base for CE structs that require more OOP functionality. 20 | function CE_Class() constructor 21 | { 22 | /// @var {string[]} An array of names of inherited classes. 23 | /// @private 24 | __Inheritance = []; 25 | 26 | CE_CLASS_GENERATED_BODY; 27 | 28 | /// @var {string[]} An array of names of implemented interfaces. 29 | /// @private 30 | __Interfaces = []; 31 | 32 | /// @var {func[]} An array of functions executed when the destroy method 33 | /// is called. 34 | /// @private 35 | __DestroyActions = []; 36 | 37 | /// @func IsInstance(_class) 38 | /// @desc Checks if the struct inherits from given class. 39 | /// @param {typeof CE_Class} _class The class type. 40 | /// @return {bool} Returns `true` if the struct inherits from the class. 41 | static IsInstance = function (_class) { 42 | gml_pragma("forceinline"); 43 | return CE_ArrayIncludes(__Inheritance, CE_ClassGetName(_class)); 44 | }; 45 | 46 | /// @func Implement(_interface) 47 | /// @desc Implements an interface into the struct. 48 | /// @return {CE_Class} Returns `self`. 49 | /// @throws {CE_Exception} If the struct already implements the interface. 50 | static Implement = function (_interface) { 51 | gml_pragma("forceinline"); 52 | if (Implements(_interface)) 53 | { 54 | throw new CE_Exception("Interface already implemented!"); 55 | return self; 56 | } 57 | array_push(__Interfaces, _interface); 58 | method(self, _interface)(); 59 | return self; 60 | }; 61 | 62 | /// @func Implements(_interface) 63 | /// @desc Checks whether the struct implements an interface. 64 | /// @param {typeof CE_Class} _interface The interface to check. 65 | /// @return {bool} Returns `true` if the struct implements the interface. 66 | static Implements = function (_interface) { 67 | gml_pragma("forceinline"); 68 | return CE_ArrayIncludes(__Interfaces, CE_ClassGetName(_interface)); 69 | }; 70 | 71 | /// @func Destroy() 72 | /// @desc Frees resources used by the struct from memory. 73 | static Destroy = function () { 74 | gml_pragma("forceinline"); 75 | var _destroyActions = __DestroyActions; 76 | var i = 0; 77 | repeat (array_length(_destroyActions)) 78 | { 79 | method(self, _destroyActions[i++])(); 80 | } 81 | }; 82 | } 83 | 84 | /// @func CE_IsClass(_value) 85 | /// @desc Checks if a value is an instance of `CE_Class`. 86 | /// @param {any} _value The value to check. 87 | /// @return {bool} Returns `true` if the value is an instance of `CE_Class`. 88 | /// @see CE_Class 89 | function CE_IsClass(_value) 90 | { 91 | gml_pragma("forceinline"); 92 | return (is_struct(_value) 93 | && variable_struct_exists(_value, "__ClassName")); 94 | } 95 | 96 | /// @func CE_ClassGetName(_class) 97 | /// @desc Retrieves class name from class instance or class type. 98 | /// @param {typeof CE_Class/CE_Class} _class The class instance or the class type. 99 | /// @return {string} The name of the class. 100 | function CE_ClassGetName(_class) 101 | { 102 | gml_pragma("forceinline"); 103 | return is_struct(_class) 104 | ? _class.__ClassName 105 | : script_get_name(_class); 106 | } -------------------------------------------------------------------------------- /scripts/CE_Class/CE_Class.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Core", 6 | "path": "folders/CoreExtension/Core.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Class", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_ColorUtils/CE_ColorUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_ColorAlphaToARGB(_color, _alpha) 2 | /// @desc Converts the color and aplha into a ARGB color. 3 | /// @param {real} _color The color. 4 | /// @param {real} _alpha The alpha. 5 | /// @return {real} The ARGB color. 6 | function CE_ColorAlphaToARGB(_color, _alpha) 7 | { 8 | gml_pragma("forceinline"); 9 | return CE_ColorSwapRB(_color) | ((_alpha * 255) << 24); 10 | } 11 | 12 | /// @func CE_ARGBToAlpha(_argb) 13 | /// @desc Converts ARGB color to alpha. 14 | /// @param {real} _argb The ARGB color. 15 | /// @return {real} The alpha. 16 | function CE_ARGBToAlpha(_argb) 17 | { 18 | gml_pragma("forceinline"); 19 | return (((_argb & $FF000000) >> 24) / 255); 20 | } 21 | 22 | /// @func CE_ARGBToColor(_argb) 23 | /// @desc Converts ARGB color to BGR color. 24 | /// @param {real} _argb The ARGB color. 25 | /// @return {real} The BGR color. 26 | function CE_ARGBToColor(_argb) 27 | { 28 | gml_pragma("forceinline"); 29 | return CE_ColorSwapRB(_argb & $FFFFFF); 30 | } 31 | 32 | /// @func CE_ColorInvert(_color) 33 | /// @desc Inverts the color. 34 | /// @param {real} _color The color to invert. 35 | /// @return {real} The inverted color. 36 | function CE_ColorInvert(_color) 37 | { 38 | gml_pragma("forceinline"); 39 | return make_color_rgb( 40 | 255 - color_get_red(_color), 41 | 255 - color_get_green(_color), 42 | 255 - color_get_blue(_color)); 43 | } 44 | 45 | /// @func CE_ColorSwapRB(_color) 46 | /// @desc Converts between RGB and BGR color format. 47 | /// @param {real} _color The BGR or RGB color. 48 | /// @return {real} The resulting color. 49 | function CE_ColorSwapRB(_color) 50 | { 51 | gml_pragma("forceinline"); 52 | return ((_color & $FF0000) >> 16) 53 | | (_color & $FF00) 54 | | ((_color & $FF) << 16); 55 | } -------------------------------------------------------------------------------- /scripts/CE_ColorUtils/CE_ColorUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_ColorUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Component/CE_Component.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_Component() 2 | /// @extends CE_Class 3 | /// @desc Base class for entity components. 4 | /// @see CE_Entity 5 | function CE_Component() 6 | : CE_Class() constructor 7 | { 8 | CE_CLASS_GENERATED_BODY; 9 | 10 | /// @var The owner of the component. Equals to `undefined` if the component 11 | /// has not been added to an entity yet. 12 | /// @readonly 13 | Owner = undefined; 14 | 15 | /// @var {bool} If `false` then the component is disabled and it should not 16 | /// do anything. 17 | Enabled = true; 18 | 19 | /// @func OnAdd() 20 | /// @desc A function executed when the component is added to an entity. 21 | static OnAdd = function () { 22 | }; 23 | 24 | /// @func OnRemove() 25 | /// @desc A function executed when the component is removed from an entity. 26 | static OnRemove = function () { 27 | }; 28 | 29 | /// @func OnRoomStart() 30 | /// @desc A function executed when the room starts. 31 | static OnRoomStart = function () { 32 | }; 33 | 34 | /// @func OnCollisionEnter(_other) 35 | /// @desc A function executed once the entity starts colliding with other 36 | /// entity. 37 | /// @param _other The other entity. 38 | static OnCollisionEnter = function (_other) { 39 | }; 40 | 41 | /// @func OnCollision(_other) 42 | /// @desc A function executed while the entity collides with other entity. 43 | /// @param _other The other entity. 44 | static OnCollision = function (_other) { 45 | }; 46 | 47 | /// @func OnCollisionExit(_other) 48 | /// @desc A function executed once the entity is not colliding with other 49 | /// entity anymore. 50 | /// @param _other The other entity. 51 | static OnCollisionExit = function (_other) { 52 | }; 53 | 54 | /// @func OnPreUpdate(_deltaTime) 55 | /// @param {CE_DeltaTime} _deltaTime 56 | static OnPreUpdate = function (_deltaTime) { 57 | }; 58 | 59 | /// @func OnUpdate(_deltaTime) 60 | /// @param {CE_DeltaTime} _deltaTime 61 | static OnUpdate = function (_deltaTime) { 62 | }; 63 | 64 | /// @func OnPostUpdate(_deltaTime) 65 | /// @param {CE_DeltaTime} _deltaTime 66 | static OnPostUpdate = function (_deltaTime) { 67 | }; 68 | 69 | /// @func OnDraw() 70 | static OnDraw = function () { 71 | }; 72 | 73 | /// @func OnDrawGUI() 74 | static OnDrawGUI = function () { 75 | }; 76 | } -------------------------------------------------------------------------------- /scripts/CE_Component/CE_Component.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "ECS", 6 | "path": "folders/CoreExtension/ECS.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Component", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Config/CE_Config.gml: -------------------------------------------------------------------------------- 1 | //gml_pragma("UnityBuild", "false"); 2 | 3 | /// @macro {bool} Use `true` to enable debug. 4 | #macro CE_DEBUG true 5 | 6 | /// @macro {real} The width of the screen that the game is designed for, 7 | /// ignoring the device orientation (always use the longer side). 8 | #macro CE_DESIGN_SCREEN_WIDTH 1920 9 | 10 | /// @macro {real} The height of the screen that the game is designed for, 11 | /// ignoring the device orientation (always use the shorter side). 12 | #macro CE_DESIGN_SCREEN_HEIGHT 1080 13 | 14 | /// @macro {real} Aspect ratio of the screen that the game is designed for, 15 | /// ignoring the device orientation. 16 | #macro CE_DESIGN_SCREEN_ASPECT (CE_DESIGN_SCREEN_WIDTH / CE_DESIGN_SCREEN_HEIGHT) -------------------------------------------------------------------------------- /scripts/CE_Config/CE_Config.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Core", 6 | "path": "folders/CoreExtension/Core.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Config", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_DeltaTime/CE_DeltaTime.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_DeltaTime() 2 | /// @extends CE_DeltaTime 3 | function CE_DeltaTime() 4 | : CE_Class() constructor 5 | { 6 | CE_CLASS_GENERATED_BODY; 7 | 8 | /// @var {real} Control how fast the game plays. This could be used for 9 | /// slow motion effect (values less than 1.0) or to pause the game (0.0). 10 | static GameSpeed = 1.0; 11 | 12 | /// @func GetMicroseconds() 13 | /// @desc Retrieves microseconds passed since the last frame. 14 | /// @return {real} Number of microseconds passed since the last frame. 15 | /// @note This is affected by {@link CE_DeltaTime.GameSpeed}! 16 | /// @see CE_DeltaTime.GameSpeed 17 | static GetMicroseconds = function () { 18 | gml_pragma("forceinline"); 19 | return (delta_time * GameSpeed); 20 | }; 21 | 22 | /// @func GetMilliseconds() 23 | /// @desc Retrieves milliseconds passed since the last frame. 24 | /// @return {real} Number of milliseconds passed since the last frame. 25 | /// @note This is affected by {@link CE_DeltaTime.GameSpeed}! 26 | /// @see CE_DeltaTime.GameSpeed 27 | static GetMilliseconds = function () { 28 | gml_pragma("forceinline"); 29 | return ((delta_time * GameSpeed) / 1000.0); 30 | }; 31 | 32 | /// @func GetSeconds() 33 | /// @desc Retrieves seconds passed since the last frame. 34 | /// @return {real} Number of seconds passed since the last frame. 35 | /// @note This is affected by {@link CE_DeltaTime.GameSpeed}! 36 | /// @see CE_DeltaTime.GameSpeed 37 | static GetSeconds = function () { 38 | gml_pragma("forceinline"); 39 | return ((delta_time * GameSpeed) / 1000000.0); 40 | }; 41 | 42 | /// @func GetMinutes() 43 | /// @desc Retrieves minutes passed since the last frame. 44 | /// @return {real} Number of minutes passed since the last frame. 45 | /// @note This is affected by {@link CE_DeltaTime.GameSpeed}! 46 | /// @see CE_DeltaTime.GameSpeed 47 | static GetMinutes = function () { 48 | gml_pragma("forceinline"); 49 | return ((delta_time * GameSpeed) / 60000000.0); 50 | }; 51 | 52 | /// @func GetHours() 53 | /// @desc Retrieves hours passed since the last frame. 54 | /// @return {real} Number of hours passed since the last frame. 55 | /// @note This is affected by {@link CE_DeltaTime.GameSpeed}! 56 | /// @see CE_DeltaTime.GameSpeed 57 | static GetHours = function () { 58 | gml_pragma("forceinline"); 59 | return ((delta_time * GameSpeed) / 3600000000.0); 60 | }; 61 | } -------------------------------------------------------------------------------- /scripts/CE_DeltaTime/CE_DeltaTime.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Core", 6 | "path": "folders/CoreExtension/Core.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_DeltaTime", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_DrawUtils/CE_DrawUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_DrawRectangle(_x, _y, _width, _height[, _color[, _alpha]]) 2 | /// @desc Draws a rectangle of the given size and color at the given position. 3 | /// @param {real} _x The x position to draw the rectangle at. 4 | /// @param {real} _y The y position to draw the rectangle at. 5 | /// @param {real} _width The width of the rectangle. 6 | /// @param {real} _height The height of the rectangle. 7 | /// @param {uint} [_color] The color of the rectangle. Defaults to `c_white`. 8 | /// @param {real} [_alpha] The alpha of the rectangle. Defaults to 1. 9 | function CE_DrawRectangle(_x, _y, _width, _height) 10 | { 11 | gml_pragma("forceinline"); 12 | draw_sprite_ext(CE_SprRectangle, 0, _x, _y, _width, _height, 0, 13 | (argument_count > 4) ? argument[4] : c_white, 14 | (argument_count > 5) ? argument[5] : 1); 15 | } 16 | 17 | /// @func CE_DrawSpriteNineSlice(_sprite, _subimage, _x, _y, _width, _height, _tiled[, _color[, _alpha]]) 18 | /// @desc Draws a nine-slice sprite. 19 | /// @param {real} _sprite The nine slice sprite to draw. 20 | /// @param {real} _subimage The subimage of the sprite to draw. 21 | /// @param {real} _x The x position to draw the sprite at. 22 | /// @param {real} _y The y position to draw the sprite at. 23 | /// @param {real} _width The width to which the sprite should be stretched. 24 | /// @param {real} _height The height to which the sprite should be stretched. 25 | /// @param {bool} _tiled True to tile the sprite of false to stretch. 26 | /// @param {real} [_color] The color to blend the sprite with. Defaults to 27 | /// `c_white`. 28 | /// @param {real} [_alpha] The opacity of the sprite. Defaults to 1. 29 | /// @note Currently it is not supported to use width and height smaller than 30 | /// the size of the original image. 31 | function CE_DrawSpriteNineSlice(_sprite, _subimage, _x, _y, _width, _height, _tiled) 32 | { 33 | var _color = (argument_count > 7) ? argument[7] : c_white; 34 | var _alpha = (argument_count > 8) ? argument[8] : 1; 35 | 36 | var _spriteWidth = sprite_get_width(_sprite); 37 | var _spriteHeight = sprite_get_height(_sprite); 38 | 39 | var _sliceX = floor(_spriteWidth / 3); 40 | var _sliceX2 = _sliceX * 2; 41 | var _sliceY = floor(_spriteHeight / 3); 42 | var _sliceY2 = _sliceY * 2; 43 | 44 | _width = max(_width, _sliceX2); 45 | _height = max(_height, _sliceY2); 46 | 47 | var _widthInner = _width - _sliceX2; 48 | var _heightInner = _height - _sliceY2; 49 | 50 | var _scaleHor = _widthInner / _sliceX; 51 | var _scaleVer = _heightInner / _sliceY; 52 | 53 | var _centerX = _x + _sliceX; 54 | var _centerY = _y + _sliceY; 55 | var _rightX = _x + _width - _sliceX; 56 | var _bottomY = _y + _height - _sliceY; 57 | 58 | if (!_tiled) 59 | { 60 | // Top edge 61 | draw_sprite_part_ext(_sprite, _subimage, _sliceX, 0, 62 | _sliceX, _sliceY, _centerX, _y, _scaleHor, 1, _color, _alpha); 63 | 64 | // Left edge 65 | draw_sprite_part_ext(_sprite, _subimage, 0, _sliceY, 66 | _sliceX, _sliceY, _x, _centerY, 1, _scaleVer, _color, _alpha); 67 | 68 | // Center 69 | draw_sprite_part_ext(_sprite, _subimage, _sliceX, _sliceY, 70 | _sliceX, _sliceY, _centerX, _centerY, _scaleHor, _scaleVer, _color, _alpha); 71 | 72 | // Right edge 73 | draw_sprite_part_ext(_sprite, _subimage, _sliceX2, _sliceY, 74 | _sliceX, _sliceY, _rightX, _centerY, 1, _scaleVer, _color, _alpha); 75 | 76 | // Bottom edge 77 | draw_sprite_part_ext(_sprite, _subimage, _sliceX, _sliceY2, 78 | _sliceX, _sliceY, _centerX, _bottomY, _scaleHor, 1, _color, _alpha); 79 | } 80 | else 81 | { 82 | var _drawX = _centerX; 83 | 84 | while (_drawX < _centerX + _widthInner) 85 | { 86 | var _drawY = _centerY; 87 | while (_drawY < _centerY + _heightInner) 88 | { 89 | // Center 90 | draw_sprite_part_ext(_sprite, _subimage, _sliceX, _sliceY, 91 | _sliceX, _sliceY, _drawX, _drawY, 1, 1, _color, _alpha); 92 | _drawY += _sliceY; 93 | } 94 | _drawX += _sliceX; 95 | } 96 | 97 | _drawX = _centerX; 98 | 99 | var _drawY = _centerY; 100 | while (_drawY < _centerY + _heightInner) 101 | { 102 | // Left edge 103 | draw_sprite_part_ext(_sprite, _subimage, 0, _sliceY, 104 | _sliceX, _sliceY, _x, _drawY, 1, 1, _color, _alpha); 105 | // Right edge 106 | draw_sprite_part_ext(_sprite, _subimage, _sliceX2, _sliceY, 107 | _sliceX, _sliceY, _rightX, _drawY, 1, 1, _color, _alpha); 108 | _drawY += _sliceY; 109 | } 110 | 111 | while (_drawX < _x + _width - _sliceX) 112 | { 113 | // Top edge 114 | draw_sprite_part_ext(_sprite, _subimage, _sliceX, 0, 115 | _sliceX, _sliceY, _drawX, _y, 1, 1, _color, _alpha); 116 | 117 | // Bottom edge 118 | draw_sprite_part_ext(_sprite, _subimage, _sliceX, _sliceY2, 119 | _sliceX, _sliceY, _drawX, _bottomY, 1, 1, _color, _alpha); 120 | 121 | _drawX += _sliceX; 122 | } 123 | } 124 | 125 | // Top left corner 126 | draw_sprite_part_ext(_sprite, _subimage, 0, 0, 127 | _sliceX, _sliceY, _x, _y, 1, 1, _color, _alpha); 128 | 129 | // Top right corner 130 | draw_sprite_part_ext(_sprite, _subimage, _sliceX2, 0, 131 | _sliceX, _sliceY, _rightX, _y, 1, 1, _color, _alpha); 132 | 133 | // Bottom left corner 134 | draw_sprite_part_ext(_sprite, _subimage, 0, _sliceY2, 135 | _sliceX, _sliceY, _x, _bottomY, 1, 1, _color, _alpha); 136 | 137 | // Bottom right corner 138 | draw_sprite_part_ext(_sprite, _subimage, _sliceX2, _sliceY2, 139 | _sliceX, _sliceY, _rightX, _bottomY, 1, 1, _color, _alpha); 140 | } 141 | 142 | /// @func CE_DrawTextShadow(_x, _y, _string[, _color[, _shadow]]) 143 | /// @desc Draws a text with a shadow. 144 | /// @param {real} _x The x position to draw the text at. 145 | /// @param {real} _y The y position to draw the text at. 146 | /// @param {string} _string The text to draw. 147 | /// @param {uint} [_color] The color of the text. Defaults to `c_white`. 148 | /// @param {uint} [_shadow] The color of the shadow. Defaults to `c_black`. 149 | function CE_DrawTextShadow(_x, _y, _string) 150 | { 151 | var _color = (argument_count > 3) ? argument[3] : c_white; 152 | var _shadow = (argument_count > 4) ? argument[4] : c_black; 153 | draw_text_color(_x + 1, _y + 1, _string, _shadow, _shadow, _shadow, _shadow, 1); 154 | draw_text_color(_x, _y, _string, _color, _color, _color, _color, 1); 155 | } -------------------------------------------------------------------------------- /scripts/CE_DrawUtils/CE_DrawUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Draw", 6 | "path": "folders/CoreExtension/Utils/Draw.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_DrawUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_DualQuaternion/CE_DualQuaternion.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Math", 6 | "path": "folders/CoreExtension/Math.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_DualQuaternion", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_EmptyIterator/CE_EmptyIterator.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_EmptyIterator() 2 | /// @extends CE_Iterator 3 | /// @desc An empty iterator. 4 | function CE_EmptyIterator() 5 | : CE_Iterator(undefined) constructor 6 | { 7 | static Reset = function () {}; 8 | 9 | static HasNext = function () { 10 | gml_pragma("forceinline"); 11 | return false; 12 | }; 13 | 14 | static GetNext = function () { 15 | gml_pragma("forceinline"); 16 | throw new CE_OutOfRangeException(); 17 | }; 18 | } -------------------------------------------------------------------------------- /scripts/CE_EmptyIterator/CE_EmptyIterator.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Iterators", 6 | "path": "folders/CoreExtension/Core/Iterators.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_EmptyIterator", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Entity/CE_Entity.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "ECS", 6 | "path": "folders/CoreExtension/ECS.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Entity", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Exception/CE_Exception.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_Exception([_message]) 2 | /// @extends CE_Class 3 | /// @desc The base struct for exceptions thrown by the CE library. 4 | /// @param {string} [_message] An exception message. Defaults to an empty string. 5 | function CE_Exception(_message="") 6 | : CE_Class() constructor 7 | { 8 | CE_CLASS_GENERATED_BODY; 9 | 10 | /// @var {string} The exception message. 11 | /// @readonly 12 | Message = _message; 13 | } -------------------------------------------------------------------------------- /scripts/CE_Exception/CE_Exception.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Exceptions", 6 | "path": "folders/CoreExtension/Core/Exceptions.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Exception", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUI/CE_GUI.gml: -------------------------------------------------------------------------------- 1 | /// @enum Enumeration of possible background image styles. 2 | enum CE_EGUIBackgroundStyle 3 | { 4 | /// @member Draw background scaled. 5 | Scale, 6 | /// @member Draw background scaled, keeping the aspect ratio. 7 | Fit, 8 | /// @member Draw background stretched. 9 | Stretch, 10 | /// @member Draw background nine sliced. 11 | NineSlice, 12 | /// @member Total number of members of this enum. 13 | SIZE 14 | }; 15 | 16 | /// @enum Enumeration of widget alignment. 17 | enum CE_EGUIAlign 18 | { 19 | /// @member Align at the start of the parent widget. 20 | Start = 0, 21 | /// @member Align at center of the parent widget. 22 | Center = 0.5, 23 | /// @member Align at the end of the parent widget. 24 | End = 1, 25 | /// @member Any value greater than 1 will act as 'fill'! 26 | Fill = 2, 27 | /// @member Total number of members of this enum. 28 | SIZE 29 | }; 30 | 31 | /// @enum Enumeration of possible widget positions relative to their parent. 32 | enum CE_EGUIPosition 33 | { 34 | /// @enum Parent's scroll is applied to widget's position (default). 35 | Scroll, 36 | /// @enum Widget ignores parent's scroll. 37 | Fixed, 38 | /// @member Total number of members of this enum. 39 | SIZE 40 | }; 41 | 42 | /// @enum Enumeration of possible content styles. 43 | enum CE_EGUIContentStyle 44 | { 45 | /// @enum Widgets are drawed in a column and their defined position becomes 46 | /// an offset from their calculated position. 47 | Column, 48 | /// @enum Widgets keep their defined position (default). 49 | Default, 50 | /// @enum Widgets are drawed in a grid and their defined position becomes 51 | /// an offset from the cell position. 52 | Grid, 53 | /// @enum Widgets are drawed in a rows and their defined position becomes 54 | /// an offset from their calculated position. 55 | Row, 56 | /// @member Total number of members of this enum. 57 | SIZE 58 | }; 59 | 60 | /// @func CE_GUIMouseInRect(_x, _y, _width, _height) 61 | /// @param {real} _x The x position of the rectangle's top left corner. 62 | /// @param {real} _y The y position of the rectangle's top left corner. 63 | /// @param {real} _width The width of the rectangle. 64 | /// @param {real} _height The height of the rectangle. 65 | /// @return {bool} True if the mouse is in the rectangle. 66 | function CE_GUIMouseInRect(_x, _y, _width, _height) 67 | { 68 | gml_pragma("forceinline"); 69 | return CE_PointInRectangle( 70 | global.__ceGuiCurrent.MouseX, 71 | global.__ceGuiCurrent.MouseY, 72 | _x, 73 | _y, 74 | _width, 75 | _height); 76 | } -------------------------------------------------------------------------------- /scripts/CE_GUI/CE_GUI.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "GUI", 6 | "path": "folders/CoreExtension/GUI.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUI", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIBlurEvent/CE_GUIBlurEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIBlurEvent() 2 | /// @extends CE_GUIEvent 3 | function CE_GUIBlurEvent() 4 | : CE_GUIEvent() constructor 5 | { 6 | CE_CLASS_GENERATED_BODY; 7 | } -------------------------------------------------------------------------------- /scripts/CE_GUIBlurEvent/CE_GUIBlurEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIBlurEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIChangeEvent/CE_GUIChangeEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIChangeEvent(_valueOld) 2 | /// @extends CE_GUIEvent 3 | /// @param {any} _valueOld 4 | function CE_GUIChangeEvent(_valueOld) 5 | : CE_GUIEvent() constructor 6 | { 7 | CE_CLASS_GENERATED_BODY; 8 | 9 | /// @var {any} 10 | /// @readonly 11 | ValueOld = _valueOld; 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIChangeEvent/CE_GUIChangeEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIChangeEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIClickEvent/CE_GUIClickEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIClickEvent(_button) 2 | /// @extends CE_GUIEvent 3 | /// @param {int} _button 4 | function CE_GUIClickEvent(_button) 5 | : CE_GUIEvent() constructor 6 | { 7 | CE_CLASS_GENERATED_BODY; 8 | 9 | /// @var {int} 10 | /// @readonly 11 | Button = _button; 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIClickEvent/CE_GUIClickEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIClickEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIContainer/CE_GUIContainer.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIContainer([_props]) 2 | /// @extends CE_GUIWidget 3 | /// @desc A container of widgets. 4 | /// @param {struct} [_props] 5 | function CE_GUIContainer(_props={}) 6 | : CE_GUIWidget(_props) constructor 7 | { 8 | CE_CLASS_GENERATED_BODY; 9 | 10 | static Super_Widget = { 11 | OnCleanUp: OnCleanUp, 12 | UpdatePosition: UpdatePosition, 13 | Update: Update, 14 | }; 15 | 16 | /// @var {ds_list} 17 | /// @readonly 18 | Widgets = ds_list_create(); 19 | 20 | /// @var {bool} 21 | Overflow = CE_StructGet(_props, "Overflow", false); 22 | 23 | /// @var {surface} 24 | /// @readonly 25 | Surface = noone; 26 | 27 | /// @var {CE_EGUIContentStyle} 28 | ContentStyle = CE_StructGet(_props, "ContentStyle", CE_EGUIContentStyle.Default); 29 | 30 | /// @var {uint} 31 | GridColumns = CE_StructGet(_props, "GridColumns", 1); 32 | 33 | /// @var {uint} 34 | GridRows = CE_StructGet(_props, "GridRows", 1); 35 | 36 | /// @var {real} 37 | SpacingH = CE_StructGet(_props, "SpacingH", 0); 38 | 39 | /// @var {real} 40 | SpacingV = CE_StructGet(_props, "SpacingV", 0); 41 | 42 | /// @var {real} 43 | /// @readonly 44 | ContentW = 0; 45 | 46 | /// @var {real} 47 | /// @readonly 48 | ContentH = 0; 49 | 50 | /// @var {real} 51 | /// @readonly 52 | ScrollX = 0; 53 | 54 | /// @var {real} 55 | /// @readonly 56 | ScrollY = 0; 57 | 58 | /// @var {bool} 59 | ScrollXEnable = CE_StructGet(_props, "ScrollXEnable", false); 60 | 61 | /// @var {bool} 62 | ScrollYEnable = CE_StructGet(_props, "ScrollYEnable", false); 63 | 64 | AddEventListener(CE_GUIChangeEvent, method(self, OnChange)); 65 | AddEventListener(CE_GUIDragEvent, method(self, OnDrag)); 66 | 67 | /// @func SetSpacing(_h[, _v]) 68 | /// @desc 69 | /// @param {real} _h 70 | /// @param {real} [_v] 71 | /// @return {CE_GUIContainer} Return `self`. 72 | static SetSpacing = function (_h) { 73 | gml_pragma("forceinline"); 74 | SpacingH = _h; 75 | SpacingV = (argument_count > 1) ? argument[1] : _h; 76 | return self; 77 | }; 78 | 79 | /// @func AddWidget(_widget) 80 | /// @desc Adds the widget to the container. 81 | /// @param {CE_GUIWidget} _widget The widget to add. 82 | /// @return {CE_GUIContainer} Return `self`. 83 | static AddWidget = function (_widget) { 84 | CE_Assert(_widget.Root == undefined, "Widget is already added to a GUI."); 85 | CE_Assert(_widget.Parent == undefined, "Widget already has a parent."); 86 | CE_Assert(Root != undefined, "Parent must be added to a GUI."); 87 | _widget.Root = Root; 88 | _widget.Parent = self; 89 | CE_ListAddUnique(Widgets, _widget); 90 | return self; 91 | }; 92 | 93 | /// @func Empty() 94 | /// @desc Destroys all child widgets of the container. 95 | /// @return {CE_GUIContainer} Returns `self`. 96 | static Empty = function () { 97 | var _widgets = Widgets; 98 | var _index = 0; 99 | repeat (ds_list_size(_widgets)) 100 | { 101 | _widgets[| _index++].Destroy(); 102 | } 103 | return self; 104 | }; 105 | 106 | static OnChange = function (_event) { 107 | Redraw = true; 108 | }; 109 | 110 | /// @func OnDrag(_event) 111 | /// @param {CE_GUIDragEvent} _event The event. 112 | static OnDrag = function (_event) { 113 | var _redraw = false; 114 | 115 | if (ScrollXEnable) 116 | { 117 | var _scrollXOld = ScrollX; 118 | var _scrollX = clamp(_scrollXOld + _event.DiffX, 119 | 0, max(ContentW - RealWidth, 0)); 120 | if (_scrollX != _scrollXOld) 121 | { 122 | ScrollX = _scrollX; 123 | _redraw = true; 124 | } 125 | _event.Propagate = false; 126 | } 127 | 128 | if (ScrollYEnable) 129 | { 130 | var _scrollYOld = ScrollY; 131 | var _scrollY = clamp(_scrollYOld + _event.DiffY, 132 | 0, max(ContentH - RealHeight, 0)); 133 | if (_scrollY != _scrollYOld) 134 | { 135 | ScrollY = _scrollY; 136 | _redraw = true; 137 | } 138 | _event.Propagate = false; 139 | } 140 | 141 | if (_redraw) 142 | { 143 | Redraw = true; 144 | } 145 | }; 146 | 147 | static UpdatePosition = function (_mouseX, _mouseY) { 148 | method(self, Super_Widget.UpdatePosition)(_mouseX, _mouseY); 149 | 150 | if (!Visible) 151 | { 152 | return self; 153 | } 154 | 155 | var _root = Root; 156 | var _x = RealX; 157 | var _y = RealY; 158 | var _width = RealWidth; 159 | var _height = RealHeight; 160 | 161 | var _scrollX = _x - ScrollX; 162 | var _scrollY = _y - ScrollY; 163 | 164 | var _contentStyle = ContentStyle; 165 | var _contentW = 0; 166 | var _contentH = 0; 167 | var _spacingH = SpacingH; 168 | var _spacingV = SpacingV; 169 | 170 | var _paddingLeft = PaddingLeft; 171 | var _paddingTop = PaddingTop; 172 | var _paddingRight = PaddingRight; 173 | var _paddingBottom = PaddingBottom; 174 | 175 | var _drawX = _paddingLeft; 176 | var _drawY = _paddingTop; 177 | var _stepX = 0; 178 | var _stepY = 0; 179 | 180 | var _contentMaxW = _width - _paddingLeft - _paddingRight; 181 | var _contentMaxH = _height - _paddingTop - _paddingBottom; 182 | 183 | if (_contentStyle == CE_EGUIContentStyle.Grid) 184 | { 185 | _stepX = _contentMaxW / GridColumns; 186 | _stepY = _contentMaxH / GridRows; 187 | } 188 | else 189 | { 190 | _stepX = _spacingH; 191 | _stepY = _spacingV; 192 | } 193 | 194 | var _widgets = Widgets; 195 | var _widgetCount = ds_list_size(_widgets); 196 | 197 | for (var i = 0; i < _widgetCount; ++i) 198 | { 199 | var _widget = _widgets[| i]; 200 | 201 | if (!_widget.Visible) 202 | { 203 | continue; 204 | } 205 | 206 | _widget.PrecomputeSize(); 207 | 208 | var _widgetRealX = 0; 209 | var _widgetRealY = 0; 210 | var _widgetPosition = _widget.Position; 211 | var _widgetWidth = (_widget.WidthRelative) 212 | ? _widget.Width * _contentMaxW 213 | : _widget.RealWidth; 214 | var _widgetHeight = (_widget.HeightRelative) 215 | ? _widget.Height * _contentMaxH 216 | : _widget.RealHeight; 217 | 218 | switch (_widgetPosition) 219 | { 220 | case CE_EGUIPosition.Scroll: 221 | var __xReal, __yReal; 222 | 223 | if (_contentStyle == CE_EGUIContentStyle.Grid) 224 | { 225 | __xReal = _drawX + _widget.X + (_stepX - _widgetWidth) * _widget.AlignH; 226 | __yReal = _drawY + _widget.Y + (_stepY - _widgetHeight) * _widget.AlignV; 227 | } 228 | else 229 | { 230 | _drawX += _widget.MarginLeft; 231 | _drawY += _widget.MarginTop; 232 | __xReal = _drawX + _widget.X + (_contentMaxW - _widgetWidth) * _widget.AlignH; 233 | __yReal = _drawY + _widget.Y + (_contentMaxH - _widgetHeight) * _widget.AlignV; 234 | _drawX += _widget.MarginRight; 235 | _drawY += _widget.MarginBottom; 236 | } 237 | 238 | _widgetRealX = _scrollX + __xReal; 239 | _widgetRealY = _scrollY + __yReal; 240 | 241 | switch (_contentStyle) 242 | { 243 | case CE_EGUIContentStyle.Column: 244 | _drawY += _widgetHeight + _spacingV; 245 | _contentW = max(__xReal + _widgetWidth, _contentW); 246 | _contentH = max(__yReal + _widgetHeight, _contentH); 247 | break; 248 | 249 | case CE_EGUIContentStyle.Default: 250 | _contentW = max(__xReal + _widgetWidth, _contentW); 251 | _contentH = max(__yReal + _widgetHeight, _contentH); 252 | break; 253 | 254 | case CE_EGUIContentStyle.Grid: 255 | _drawX += _stepX; 256 | if (_drawX >= _width - _paddingRight) 257 | { 258 | _drawX = _paddingLeft; 259 | _drawY += _stepY; 260 | } 261 | _contentW = max(_drawX + _stepX, _contentW); 262 | _contentH = max(_drawY + _stepY, _contentH); 263 | break; 264 | 265 | case CE_EGUIContentStyle.Row: 266 | _drawX += _widgetWidth + _spacingH; 267 | _contentW = max(__xReal + _widgetWidth, _contentW); 268 | _contentH = max(__yReal + _widgetHeight, _contentH); 269 | break; 270 | } 271 | break; 272 | 273 | case CE_EGUIPosition.Fixed: 274 | _widgetRealX = _x + _widget.X + (_width - _widgetWidth) * _widget.AlignH; 275 | _widgetRealY = _y + _widget.Y + (_height - _widgetHeight) * _widget.AlignV; 276 | break; 277 | 278 | default: 279 | CE_Assert(false, "Invalid widget position property"); 280 | } 281 | 282 | _widget.RealX = _widgetRealX; 283 | _widget.RealY = _widgetRealY; 284 | _widget.RealWidth = _widgetWidth; 285 | _widget.RealHeight = _widgetHeight; 286 | _widget.UpdatePosition(_mouseX + _x - _widgetRealX, _mouseY + _y - _widgetRealY); 287 | } 288 | 289 | _contentW += _paddingRight; 290 | _contentH += _paddingBottom; 291 | 292 | ContentW = _contentW; 293 | ContentH = _contentH; 294 | 295 | if (Grow 296 | && (_width != _contentW 297 | || _height != _contentH)) 298 | { 299 | RealWidth = _contentW; 300 | RealHeight = _contentH; 301 | if (_root != undefined) 302 | { 303 | _root.FixPositioning = true; 304 | } 305 | } 306 | 307 | return self; 308 | }; 309 | 310 | static Update = function () { 311 | method(self, Super_Widget.Update)(); 312 | var _widgets = Widgets; 313 | var _index = 0; 314 | repeat (ds_list_size(_widgets)) 315 | { 316 | _widgets[| _index++].Update(); 317 | } 318 | return self; 319 | }; 320 | 321 | /// @func DrawItems() 322 | static DrawItems = function () { 323 | var _widgets = Widgets; 324 | var _index = 0; 325 | repeat (ds_list_size(_widgets)) 326 | { 327 | _widgets[| _index++].Draw(); 328 | } 329 | }; 330 | 331 | static OnDraw = function () { 332 | var _x = RealX; 333 | var _y = RealY; 334 | var _width = RealWidth; 335 | var _height = RealHeight; 336 | var _overflow = Overflow; 337 | var _redraw = Redraw; 338 | 339 | if (!_overflow) 340 | { 341 | gpu_push_state(); 342 | var _surfaceOld = Surface; 343 | var _surface = CE_SurfaceCheck(_surfaceOld, _width, _height); 344 | if (_surface != _surfaceOld) 345 | { 346 | Surface = _surface; 347 | _redraw = true; 348 | } 349 | if (_redraw) 350 | { 351 | var _parent = Parent; 352 | if (_parent != undefined) 353 | { 354 | _parent.Redraw = true; 355 | } 356 | Redraw = false; 357 | surface_set_target(_surface); 358 | draw_clear_alpha(0, 0); 359 | gpu_set_blendmode_ext_sepalpha(bm_src_alpha, bm_inv_src_alpha, bm_one, bm_inv_src_alpha); 360 | matrix_stack_push(matrix_get(matrix_world)); 361 | matrix_set(matrix_world, matrix_build(-_x, -_y, 0, 0, 0, 0, 1, 1, 1)); 362 | DrawBackground(); 363 | DrawItems(); 364 | matrix_set(matrix_world, matrix_stack_top()); 365 | matrix_stack_pop(); 366 | gpu_set_blendmode(bm_normal); 367 | surface_reset_target(); 368 | } 369 | gpu_pop_state(); 370 | draw_surface(_surface, _x, _y); 371 | } 372 | else 373 | { 374 | DrawBackground(); 375 | DrawItems(); 376 | } 377 | }; 378 | 379 | static OnCleanUp = function () { 380 | method(self, Super_Widget.OnCleanUp)(); 381 | 382 | for (var i = ds_list_size(Widgets) - 1; i >= 0; --i) 383 | { 384 | Widgets[| i].OnCleanUp(); 385 | } 386 | ds_list_destroy(Widgets); 387 | 388 | if (Surface != noone 389 | && surface_exists(Surface)) 390 | { 391 | surface_free(Surface); 392 | } 393 | }; 394 | } -------------------------------------------------------------------------------- /scripts/CE_GUIContainer/CE_GUIContainer.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "GUI", 6 | "path": "folders/CoreExtension/GUI.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIContainer", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUICreate_/CE_GUICreate_.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUICreateText(_text[, _props]) 2 | /// @desc Creates a new text widget. 3 | /// @param {string} _text 4 | /// @param {struct} [_props] 5 | /// @return {CE_GUIWidget} The created widget. 6 | function CE_GUICreateText(_text, _props={}) 7 | { 8 | var _widget = new CE_GUIWidget(_props); 9 | _widget.Text = _text; 10 | _widget.Grow = true; 11 | return _widget; 12 | } 13 | 14 | /// @func CE_GUICreateGrid(_cols, _rows[, _x[, _y[, _width[, _height]]]]) 15 | /// @desc Creates a new grid widget. 16 | /// @param {rows} _cols Number of grid columns. 17 | /// @param {rows} _rows Number of grid rows. 18 | /// @param {rows} [_x] Widget's x position. Defaults to 0. 19 | /// @param {rows} [_y] Widget's y position. Defaults to 0. 20 | /// @param {rows} [_width] Widget's width. Defaults to 1. 21 | /// @param {rows} [_height] Widget's height. Defaults to 1. 22 | /// @return {CE_GUIContainer} The created widget. 23 | function CE_GUICreateGrid(_rows, _cols) 24 | { 25 | var _w = new CE_GUIContainer(); 26 | _w.ContentStyle = CE_EGUIContentStyle.Grid; 27 | _w.GridColumns = _rows; 28 | _w.GridRows = _cols; 29 | _w.X = (argument_count > 2) ? argument[2] : 0; 30 | _w.Y = (argument_count > 3) ? argument[3] : 0; 31 | _w.Width = (argument_count > 4) ? argument[4] : 1; 32 | _w.Height = (argument_count > 5) ? argument[5] : 1; 33 | return _w; 34 | } 35 | 36 | /// @func CE_GUICreateHBox([_x[, _y]]) 37 | /// @desc Creates a new horizontal box widget. 38 | /// @param {real} [_x] The x position. Defaults to 0. 39 | /// @param {real} [_y] The y position. Defaults to 0. 40 | /// @return {CE_GUIContainer} The created widget. 41 | function CE_GUICreateHBox(_x=0, _y=0) 42 | { 43 | var _w = new CE_GUIContainer(); 44 | _w.ContentStyle = CE_EGUIContentStyle.Row; 45 | _w.Grow = true; 46 | _w.X = _x; 47 | _w.Y = _y; 48 | return _w; 49 | } 50 | 51 | /// @func CE_GUICreateSprite(_sprite[, _index[, _x[, _y[, _color[, _alpha]]]]]) 52 | /// @desc Creates a new widget from the sprite. 53 | /// @param {real} _sprite The sprite. 54 | /// @param {real} [_index] The sprite subimage index. Defaults to 0. 55 | /// @param {real} [_x] The x position of the sprite. Defaults to 0. 56 | /// @param {real} [_y] The y position of the sprite. Defaults to 0. 57 | /// @param {real} [_color] The color to blend the sprite with. Defaults 58 | /// to `c_white`. 59 | /// @param {real} [_alpha] The sprite alpha. Defaults to 1. 60 | /// @return {CE_GUIWidget} The created widget. 61 | function CE_GUICreateSprite(_sprite, _index=0, _x=0, _y=0, _color=c_white, _alpha=1) 62 | { 63 | var _w = new CE_GUIWidget(); 64 | _w.BackgroundSprite = _sprite; 65 | _w.BackgroundIndex = _index; 66 | _w.X = _x; 67 | _w.Y = _y; 68 | _w.BackgroundSpriteBlend = _color; 69 | _w.BackgroundSpriteAlpha = _alpha; 70 | _w.Width = sprite_get_width(_sprite); 71 | _w.Height = sprite_get_height(_sprite); 72 | return _w; 73 | } 74 | 75 | /// @func CE_GUICreateVBox([_x[, _y]]) 76 | /// @desc Creates a new vertical box widget. 77 | /// @param {real} [_x] The x position. Defaults to 0. 78 | /// @param {real} [_y] The y position. Defaults to 0. 79 | /// @return {CE_GUIContainer} The created widget. 80 | function CE_GUICreateVBox(_x=0, _y=0) 81 | { 82 | var _w = new CE_GUIContainer(); 83 | _w.ContentStyle = CE_EGUIContentStyle.Column; 84 | _w.Grow = true; 85 | _w.X = _x; 86 | _w.Y = _y; 87 | return _w; 88 | } -------------------------------------------------------------------------------- /scripts/CE_GUICreate_/CE_GUICreate_.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "GUI", 6 | "path": "folders/CoreExtension/GUI.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUICreate_", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIDeactivateEvent/CE_GUIDeactivateEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIDeactivateEvent() 2 | /// @extends CE_GUIEvent 3 | function CE_GUIDeactivateEvent() 4 | : CE_GUIEvent() constructor 5 | { 6 | CE_CLASS_GENERATED_BODY; 7 | } -------------------------------------------------------------------------------- /scripts/CE_GUIDeactivateEvent/CE_GUIDeactivateEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIDeactivateEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIDragEndEvent/CE_GUIDragEndEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIDragEndEvent() 2 | /// @extends CE_GUIEvent 3 | function CE_GUIDragEndEvent() 4 | : CE_GUIEvent() constructor 5 | { 6 | CE_CLASS_GENERATED_BODY; 7 | } -------------------------------------------------------------------------------- /scripts/CE_GUIDragEndEvent/CE_GUIDragEndEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIDragEndEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIDragEvent/CE_GUIDragEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIDragEvent(_diffX, _diffY) 2 | /// @extends CE_GUIEvent 3 | /// @param {real} _diffX 4 | /// @param {real} _diffY 5 | function CE_GUIDragEvent(_diffX, _diffY) 6 | : CE_GUIEvent() constructor 7 | { 8 | CE_CLASS_GENERATED_BODY; 9 | 10 | /// @var {real} 11 | /// @readonly 12 | DiffX = _diffX; 13 | 14 | /// @var {real} 15 | /// @readonly 16 | DiffY = _diffY; 17 | } -------------------------------------------------------------------------------- /scripts/CE_GUIDragEvent/CE_GUIDragEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIDragEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIDragStartEvent/CE_GUIDragStartEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIDragStartEvent() 2 | /// @extends CE_GUIEvent 3 | function CE_GUIDragStartEvent() 4 | : CE_GUIEvent() constructor 5 | { 6 | CE_CLASS_GENERATED_BODY; 7 | } -------------------------------------------------------------------------------- /scripts/CE_GUIDragStartEvent/CE_GUIDragStartEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIDragStartEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIEvent/CE_GUIEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIEvent() 2 | /// @extends CE_Class 3 | /// @desc Base class for GUI events. 4 | function CE_GUIEvent() 5 | : CE_Class() constructor 6 | { 7 | CE_CLASS_GENERATED_BODY; 8 | 9 | /// @var {CE_GUIWidget/undefined} 10 | /// @readonly 11 | Target = undefined; 12 | 13 | /// @var {bool} 14 | Propagate = true; 15 | } -------------------------------------------------------------------------------- /scripts/CE_GUIEvent/CE_GUIEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIFocusEvent/CE_GUIFocusEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIFocusEvent() 2 | /// @extends CE_GUIEvent 3 | function CE_GUIFocusEvent() 4 | : CE_GUIEvent() constructor 5 | { 6 | CE_CLASS_GENERATED_BODY; 7 | } -------------------------------------------------------------------------------- /scripts/CE_GUIFocusEvent/CE_GUIFocusEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIFocusEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIHSlider/CE_GUIHSlider.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIHSlider(_min, _max, _value[, _integers[, _props]]) 2 | /// @extends CE_GUIWidget 3 | /// @param {real} _min Minimum value. 4 | /// @param {real} _max Maximum value. 5 | /// @param {real} _value The current value. 6 | /// @param {bool} [_integers] True if the values can be integers only. Defaults 7 | /// to `false`. 8 | /// @param {struct} [_props] 9 | function CE_GUIHSlider(_min, _max, _value, _integers=false, _props={}) 10 | : CE_GUIWidget(_props) constructor 11 | { 12 | CE_CLASS_GENERATED_BODY; 13 | 14 | /// @var {real} 15 | /// @readonly 16 | Min = _min; 17 | 18 | /// @var {real} 19 | /// @readonly 20 | Max = _max; 21 | 22 | /// @var {real} 23 | /// @readonly 24 | Value = _value; 25 | 26 | /// @var {bool} 27 | /// @readonly 28 | Integers = _integers; 29 | 30 | Width = CE_StructGet(_props, "Width", 256); 31 | Height = CE_StructGet(_props, "Height", 32); 32 | 33 | var _onDrag = method(self, OnDrag); 34 | AddEventListener(CE_GUIClickEvent, _onDrag); 35 | AddEventListener(CE_GUIDragEvent, _onDrag); 36 | AddEventListener(CE_GUIDragStartEvent, _onDrag); 37 | 38 | static OnDrag = function (_event) { 39 | _event.Propagate = false; 40 | 41 | var _width = Width; 42 | var _min = Min; 43 | var _max = Max; 44 | var _valueOld = Value; 45 | var _value = lerp(_min, _max, clamp(MouseX / _width, 0, 1)); 46 | _value = (Integers) ? round(_value) : _value; 47 | 48 | if (_value != _valueOld) 49 | { 50 | Value = _value; 51 | var _eventChange = new CE_GUIChangeEvent(_valueOld); 52 | TriggerEvent(_eventChange); 53 | _eventChange.Destroy(); 54 | } 55 | }; 56 | 57 | static OnDraw = function () { 58 | var _x = RealX; 59 | var _y = RealY; 60 | var _width = Width; 61 | var _height = Height; 62 | var _min = Min; 63 | var _max = Max; 64 | var _val = Value; 65 | var _mul = (_val - _min) / (_max - _min); 66 | 67 | CE_DrawRectangle(_x, _y, _width, _height, $101010); 68 | CE_DrawRectangle(_x, _y, _width * _mul, _height, $FF8000); 69 | }; 70 | } -------------------------------------------------------------------------------- /scripts/CE_GUIHSlider/CE_GUIHSlider.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "GUI", 6 | "path": "folders/CoreExtension/GUI.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIHSlider", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIInput/CE_GUIInput.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIInput(_value[, _decimalPlaces[, _props]]) 2 | /// @extends CE_GUIWidget 3 | /// @desc An input widget. 4 | /// @param {any} _value The initial value. 5 | /// @param {uint} [_decimalPlaces] Number of decimal places. Defaults to 2. 6 | /// @param {struct} [_props] 7 | function CE_GUIInput(_value, _decimalPlaces=2, _props={}) 8 | : CE_GUIWidget(_props) constructor 9 | { 10 | CE_CLASS_GENERATED_BODY; 11 | 12 | /// @var {real/string} 13 | /// @readonly 14 | Value = _value; 15 | 16 | /// @var {uint} 17 | /// @readonly 18 | DecimalPlaces = _decimalPlaces; 19 | 20 | /// @var {uint/undefined} Limit number of characters. 21 | Length = undefined; 22 | 23 | /// @var {string} Backup of the keyboard string. 24 | /// @private 25 | KeyboardString = ""; 26 | 27 | Width = CE_StructGet(_props, "Width", 256); 28 | BackgroundColor = CE_StructGet(_props, "BackgroundColor", c_white); 29 | BackgroundAlpha = CE_StructGet(_props, "BackgroundAlpha", 1); 30 | 31 | PaddingLeft = CE_StructGet(_props, "PaddingLeft", 16); 32 | PaddingRight = CE_StructGet(_props, "PaddingRight", 16); 33 | PaddingTop = CE_StructGet(_props, "PaddingTop", 8); 34 | PaddingBottom = CE_StructGet(_props, "PaddingBottom", 8); 35 | 36 | AddEventListener(CE_GUIFocusEvent, method(self, OnFocus)); 37 | AddEventListener(CE_GUIBlurEvent, method(self, OnBlur)); 38 | AddEventListener(CE_GUIKeyDownEvent, method(self, OnKeyDown)); 39 | AddEventListener(CE_GUIKeyPressEvent, method(self, OnKeyPress)); 40 | 41 | static OnFocus = function (_event) { 42 | var _value = Value; 43 | 44 | KeyboardString = keyboard_string; 45 | keyboard_string = is_real(_value) 46 | ? CE_RealToString(_value, DecimalPlaces) 47 | : _value; 48 | 49 | if (os_type == os_android) 50 | { 51 | keyboard_virtual_show( 52 | is_real(_value) ? kbv_type_numbers : kbv_type_default, 53 | kbv_returnkey_default, 54 | kbv_autocapitalize_none, 55 | false); 56 | } 57 | }; 58 | 59 | static OnBlur = function (_event) { 60 | var _valueOld = Value; 61 | 62 | if (is_real(_valueOld)) 63 | { 64 | var _real = CE_RealParse(keyboard_string); 65 | if (!is_nan(_real)) 66 | { 67 | Value = _real; 68 | } 69 | } 70 | else 71 | { 72 | Value = keyboard_string; 73 | } 74 | 75 | keyboard_string = KeyboardString; 76 | KeyboardString = ""; 77 | 78 | if (os_type == os_android) 79 | { 80 | keyboard_virtual_hide(); 81 | } 82 | 83 | // TODO: Validate input value before change? 84 | 85 | if (_valueOld != Value) 86 | { 87 | var _ev = new CE_GUIChangeEvent(_valueOld); 88 | TriggerEvent(_ev); 89 | _ev.Destroy(); 90 | } 91 | }; 92 | 93 | static OnKeyDown = function (_event) { 94 | RequestRedraw(); 95 | }; 96 | 97 | static OnKeyPress = function (_event) { 98 | var _key = _event.Key; 99 | if (_key == vk_enter 100 | || _key == vk_return) 101 | { 102 | Root.SetFocusedWidget(undefined); 103 | } 104 | RequestRedraw(); 105 | }; 106 | 107 | static OnDraw = function () { 108 | var _root = Root; 109 | _root.SetCurrentFont(Font); 110 | var _charWidth = string_width("Q"); 111 | var _charHeight = string_height("Q"); 112 | 113 | var _x = RealX; 114 | var _y = RealY; 115 | var _width = RealWidth; 116 | var _height = PaddingTop + _charHeight + PaddingBottom; 117 | RealHeight = _height; 118 | 119 | var _textX = _x + PaddingLeft; 120 | var _textY = _y + PaddingTop; 121 | var _value = Value; 122 | 123 | DrawBackground(); 124 | 125 | var _color = c_black; 126 | var _charCount = floor((_width - PaddingLeft - PaddingRight) / _charWidth); 127 | var _focused = (_root.WidgetFocused == self); 128 | var _text; 129 | 130 | if (_focused) 131 | { 132 | var _length = Length; 133 | //if (is_real(_value)) 134 | //{ 135 | // var _digits = string_digits(keyboard_string); 136 | // if (keyboard_string != _digits) 137 | // { 138 | // keyboard_string = _digits; 139 | // } 140 | //} 141 | if (_length != undefined 142 | && _length > 0 143 | && string_length(keyboard_string) > _length) 144 | { 145 | keyboard_string = string_copy(keyboard_string, 1, _length); 146 | } 147 | _text = keyboard_string; 148 | var _copyFrom = max(string_length(_text) - _charCount + 1, 1); 149 | _text = string_copy(_text, _copyFrom, _charCount); 150 | } 151 | else 152 | { 153 | _text = is_real(_value) 154 | ? CE_RealToString(_value, DecimalPlaces) 155 | : _value; 156 | _text = string_copy(_text, 1, _charCount); 157 | } 158 | 159 | draw_text_color(_textX, _textY, _text, _color, _color, _color, _color, 1); 160 | 161 | if (_focused) 162 | { 163 | CE_DrawRectangle(_textX + string_width(_text), _textY, 4, _charHeight, $FF8000, 1); 164 | } 165 | }; 166 | 167 | static OnDrawProxy = function () { 168 | var _root = Root; 169 | var _displayWidth = _root.GetDisplayWidth(); 170 | var _displayHeight = _root.GetDisplayHeight(); 171 | var _keyboardHeight = keyboard_virtual_height() ?? 0; 172 | 173 | // TODO: Proxy input font configuration! 174 | _root.SetCurrentFont(FntGUILarge); 175 | 176 | var _charWidth = string_width("Q"); 177 | var _charHeight = string_height("Q"); 178 | 179 | // Overlay 180 | CE_DrawRectangle(0, 0, _displayWidth, _displayHeight, c_black, 0.5); 181 | 182 | var _padding = 8; 183 | var _inputWidth = _displayWidth * 0.75; 184 | var _inputHeight = _charHeight + _padding * 2; 185 | var _inputX = floor((_displayWidth - _inputWidth) * 0.5); 186 | var _inputY = floor(((_displayHeight - _keyboardHeight) - _inputHeight) * 0.5); 187 | 188 | // Background 189 | CE_DrawRectangle(_inputX, _inputY, _inputWidth, _inputHeight, c_white, 1); 190 | 191 | var _charCount = floor((_inputWidth - _padding * 2) / _charWidth); 192 | var _text = keyboard_string; 193 | var _copyFrom = max(string_length(_text) - _charCount + 1, 1); 194 | _text = string_copy(_text, _copyFrom, _charCount); 195 | var _textX = _inputX + _padding; 196 | var _textY = _inputY + _padding; 197 | 198 | // Text 199 | draw_text_color(_textX, _textY, _text, c_black, c_black, c_black, c_black, 1); 200 | 201 | // Beam 202 | CE_DrawRectangle(_textX + string_width(_text), _textY, 4, _charHeight, $FF8000, 1); 203 | }; 204 | } -------------------------------------------------------------------------------- /scripts/CE_GUIInput/CE_GUIInput.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "GUI", 6 | "path": "folders/CoreExtension/GUI.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIInput", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIKeyDownEvent/CE_GUIKeyDownEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIKeyDownEvent(_key) 2 | /// @extends CE_GUIEvent 3 | /// @param {int} _key 4 | function CE_GUIKeyDownEvent(_key) 5 | : CE_GUIEvent() constructor 6 | { 7 | CE_CLASS_GENERATED_BODY; 8 | 9 | /// @var {int} 10 | /// @readonly 11 | Key = _key; 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIKeyDownEvent/CE_GUIKeyDownEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIKeyDownEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIKeyPressEvent/CE_GUIKeyPressEvent.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GUIKeyPressEvent(_key) 2 | /// @extends CE_GUIEvent 3 | /// @param {int} _key 4 | function CE_GUIKeyPressEvent(_key) 5 | : CE_GUIEvent() constructor 6 | { 7 | CE_CLASS_GENERATED_BODY; 8 | 9 | /// @var {int} 10 | /// @readonly 11 | Key = _key; 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIKeyPressEvent/CE_GUIKeyPressEvent.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Events", 6 | "path": "folders/CoreExtension/GUI/Events.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIKeyPressEvent", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIRoot/CE_GUIRoot.gml: -------------------------------------------------------------------------------- 1 | /// @var {CE_GUIRoot/undefined} 2 | /// @private 3 | global.__ceGuiCurrent = undefined; 4 | 5 | /// @func CE_GUIRoot() 6 | /// @extends CE_GUIContainer 7 | /// @desc Root GUI widget. 8 | function CE_GUIRoot() 9 | : CE_GUIContainer() constructor 10 | { 11 | CE_CLASS_GENERATED_BODY; 12 | 13 | static Super_Container = { 14 | Update: Update, 15 | OnDraw: OnDraw, 16 | }; 17 | 18 | Root = self; 19 | 20 | WidgetHovered = undefined; 21 | WidgetDragging = undefined; 22 | WidgetFocused = undefined; 23 | Scale = 1; 24 | 25 | MouseDragXLast = 0; 26 | MouseDragYLast = 0; 27 | 28 | WidgetDraggable = undefined; 29 | 30 | FixPositioning = false; 31 | 32 | DestroyList = ds_list_create(); 33 | 34 | WindowInit = true; 35 | 36 | WindowSizePrev = [0, 0]; 37 | 38 | /// @func GetDisplayWidth() 39 | /// @return {real} The width of the display within the GUI. 40 | static GetDisplayWidth = function () { 41 | gml_pragma("forceinline"); 42 | return window_get_width() / Scale; 43 | }; 44 | 45 | /// @func GetDisplayHeight() 46 | /// @return {real} The width of the display within the GUI. 47 | static GetDisplayHeight = function () { 48 | gml_pragma("forceinline"); 49 | return window_get_height() / Scale; 50 | }; 51 | 52 | /// @func IsTyping() 53 | /// @return {bool} 54 | static IsTyping = function () { 55 | if (keyboard_virtual_status()) 56 | { 57 | return true; 58 | } 59 | if (WidgetFocused != undefined 60 | && WidgetFocused.IsInstance(CE_GUIInput)) 61 | { 62 | return true; 63 | } 64 | return false; 65 | }; 66 | 67 | /// @func SetCurrentFont([_font]) 68 | /// @param {font} [_font] The font resource. 69 | /// @return {CE_GUIRoot} Returns `self`. 70 | static SetCurrentFont = function (_font=Font) { 71 | if (_font != undefined 72 | && draw_get_font() != _font) 73 | { 74 | draw_set_font(_font); 75 | } 76 | return self; 77 | }; 78 | 79 | /// @func SetFocusedWidget(_widget) 80 | /// @param {CE_GUIWidget/undefined} _widget The widget or `undefined`. 81 | /// @return {CE_GUIRoot} Returns `self`. 82 | static SetFocusedWidget = function (_widget) { 83 | var _widgetPrev = WidgetFocused; 84 | 85 | WidgetFocused = _widget; 86 | 87 | if (_widgetPrev != undefined) 88 | { 89 | var _ev = new CE_GUIBlurEvent(); 90 | _widgetPrev.TriggerEvent(_ev); 91 | _ev.Destroy(); 92 | } 93 | 94 | if (_widget != undefined) 95 | { 96 | var _ev = new CE_GUIFocusEvent(); 97 | _widget.TriggerEvent(_ev); 98 | _ev.Destroy(); 99 | } 100 | 101 | return self; 102 | }; 103 | 104 | static KeyDownAny = function () { 105 | var _focused = WidgetFocused; 106 | if (_focused != undefined) 107 | { 108 | var _ev = new CE_GUIKeyDownEvent(keyboard_key); 109 | _focused.TriggerEvent(_ev); 110 | _ev.Destroy(); 111 | } 112 | }; 113 | 114 | static KeyPressAny = function () { 115 | var _focused = WidgetFocused; 116 | if (_focused != undefined) 117 | { 118 | var _ev = new CE_GUIKeyPressEvent(keyboard_key); 119 | _focused.TriggerEvent(_ev); 120 | _ev.Destroy(); 121 | } 122 | }; 123 | 124 | static KeyPressEnter = function () { 125 | // Fixes returning from input on Android 126 | var _focused = WidgetFocused; 127 | if (_focused != undefined) 128 | { 129 | var _ev = new CE_GUIKeyPressEvent(vk_enter); 130 | _focused.TriggerEvent(_ev); 131 | _ev.Destroy(); 132 | } 133 | }; 134 | 135 | static GlobalLeftPressed = function () { 136 | // Required for plaforms with touch controls only 137 | _Update(); 138 | }; 139 | 140 | static GlobalTap = function () { 141 | var _hovered = WidgetHovered; 142 | if (WidgetFocused != _hovered) 143 | { 144 | SetFocusedWidget(_hovered); 145 | } 146 | if (_hovered != undefined) 147 | { 148 | var _event = new CE_GUIClickEvent(mb_left); 149 | _hovered.TriggerEvent(_event); 150 | _event.Destroy(); 151 | } 152 | }; 153 | 154 | static GlobalDragStart = function () { 155 | var _draggable = WidgetDraggable; 156 | if (_draggable != undefined) 157 | { 158 | if (WidgetFocused != undefined) 159 | { 160 | SetFocusedWidget(undefined); 161 | } 162 | WidgetDragging = _draggable; 163 | MouseDragXLast = MouseX; 164 | MouseDragYLast = MouseY; 165 | var _event = new CE_GUIDragStartEvent(); 166 | _draggable.TriggerEvent(_event); 167 | _event.Destroy(); 168 | } 169 | }; 170 | 171 | static GlobalDragEnd = function () { 172 | var _dragging = WidgetDragging; 173 | if (_dragging != undefined) 174 | { 175 | var _event = new CE_GUIDragEndEvent(); 176 | _dragging.TriggerEvent(_event); 177 | _event.Destroy(); 178 | WidgetDragging = noone; 179 | } 180 | }; 181 | 182 | static GlobalDragging = function () { 183 | var _dragging = WidgetDragging; 184 | if (_dragging != undefined) 185 | { 186 | var _mouseX = MouseX; 187 | var _mouseY = MouseY; 188 | var _event = new CE_GUIDragEvent( 189 | MouseDragXLast - _mouseX, 190 | MouseDragYLast - _mouseY); 191 | _dragging.TriggerEvent(_event); 192 | _event.Destroy(); 193 | MouseDragXLast = _mouseX; 194 | MouseDragYLast = _mouseY; 195 | } 196 | }; 197 | 198 | static _Update = function () { 199 | global.__ceGuiCurrent = self; 200 | 201 | SetRectangle(0, 0, GetDisplayWidth(), GetDisplayHeight()); 202 | RealX = 0; 203 | RealY = 0; 204 | RealWidth = Width; 205 | RealHeight = Height; 206 | 207 | var _mouseX = device_mouse_x_to_gui(0); 208 | var _mouseY = device_mouse_y_to_gui(0); 209 | 210 | MouseX = _mouseX; 211 | MouseY = _mouseY; 212 | WidgetHovered = undefined; 213 | WidgetDraggable = undefined; 214 | 215 | UpdatePosition(_mouseX, _mouseY); 216 | while (FixPositioning) 217 | { 218 | FixPositioning = false; 219 | UpdatePosition(_mouseX, _mouseY); 220 | } 221 | 222 | global.__ceGuiCurrent = undefined; 223 | }; 224 | 225 | static Update = function () { 226 | method(self, Super_Container.Update)(); 227 | 228 | var _windowWidth = window_get_width(); 229 | var _windowHeight = window_get_height(); 230 | 231 | if (WindowInit 232 | || _windowWidth != WindowSizePrev[0] 233 | || _windowHeight != WindowSizePrev[1]) 234 | { 235 | var _scale; 236 | if (_windowWidth > _windowHeight) 237 | { 238 | _scale = CE_ScaleKeepAspectRatio( 239 | _windowWidth, 240 | _windowHeight, 241 | CE_DESIGN_SCREEN_WIDTH, 242 | CE_DESIGN_SCREEN_HEIGHT); 243 | } 244 | else 245 | { 246 | _scale = CE_ScaleKeepAspectRatio( 247 | _windowWidth, 248 | _windowHeight, 249 | CE_DESIGN_SCREEN_HEIGHT, 250 | CE_DESIGN_SCREEN_WIDTH); 251 | } 252 | 253 | display_set_gui_size(_windowWidth, _windowHeight); 254 | display_set_gui_maximize(_scale, _scale); 255 | Scale = _scale; 256 | 257 | WindowSizePrev = [ 258 | _windowWidth, 259 | _windowHeight 260 | ]; 261 | 262 | WindowInit = false; 263 | } 264 | 265 | _Update(); 266 | 267 | return self; 268 | }; 269 | 270 | static OnDraw = function () { 271 | if (!Visible) 272 | { 273 | return; 274 | } 275 | 276 | gpu_push_state(); 277 | gpu_set_tex_filter(true); 278 | 279 | var _font = draw_get_font(); 280 | 281 | global.__ceGuiCurrent = self; 282 | method(self, Super_Container.OnDraw)(); 283 | 284 | #region Proxy widget 285 | var _focused = WidgetFocused; 286 | if (_focused != undefined) 287 | { 288 | var _focusedX = _focused.RealX; 289 | var _focusedY = _focused.RealY; 290 | var _displayWidth = GetDisplayWidth(); 291 | var _displayHeight = GetDisplayHeight(); 292 | var _keyboardHeight = keyboard_virtual_height() ?? 0; 293 | 294 | if (rectangle_in_rectangle(_focusedX, _focusedY, 295 | _focusedX + _focused.RealWidth, _focusedY + _focused.RealHeight, 296 | 0, 0, _displayWidth, _displayHeight - (_keyboardHeight / Scale)) != 1) 297 | { 298 | _focused.OnDrawProxy(); 299 | } 300 | } 301 | #endregion Proxy widget 302 | 303 | global.__ceGuiCurrent = undefined; 304 | 305 | #region Destroy widgets 306 | var _destroyList = DestroyList; 307 | 308 | for (var i = ds_list_size(_destroyList) - 1; i >= 0; --i) 309 | { 310 | var _widget = _destroyList[| i]; 311 | if (!ce_gui_widget_exists(_widget)) 312 | { 313 | continue; 314 | } 315 | #region Remove from parent 316 | var _parent = _widget.Parent; 317 | if (_parent != undefined) 318 | { 319 | CE_ListRemove(_parent.Widgets, _widget); 320 | } 321 | #endregion Remove from parent 322 | _widget.OnCleanUp(); 323 | } 324 | ds_list_clear(_destroyList); 325 | #endregion Destroy widgets 326 | 327 | if (draw_get_font() != _font) 328 | { 329 | draw_set_font(_font); 330 | } 331 | 332 | gpu_pop_state(); 333 | }; 334 | 335 | /// @func Destroy() 336 | /// @desc Destroys the widget. 337 | static Destroy = function () { 338 | OnCleanUp(); 339 | }; 340 | } 341 | 342 | /// @func ce_is_mouse_over_gui(_root) 343 | /// @param {CE_GUIRoot} _root The id of the GUI. 344 | /// @return {bool} Returns `true` if mouse is over some GUI element. 345 | function ce_is_mouse_over_gui(_root) 346 | { 347 | gml_pragma("forceinline"); 348 | return (_root.WidgetHovered != undefined); 349 | } -------------------------------------------------------------------------------- /scripts/CE_GUIRoot/CE_GUIRoot.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "GUI", 6 | "path": "folders/CoreExtension/GUI.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIRoot", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GUIWidget/CE_GUIWidget.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "GUI", 6 | "path": "folders/CoreExtension/GUI.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GUIWidget", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_GetCallingFunctionName/CE_GetCallingFunctionName.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GetCallingFunctionName() 2 | /// @desc Retrieves name of the calling function. 3 | /// @return {string} The name of the calling function. 4 | function CE_GetCallingFunctionName() 5 | { 6 | gml_pragma("forceinline"); 7 | var _name = debug_get_callstack(/*2*/)[1]; // TODO: Check if this argument works in YYC already 8 | _name = string_replace(_name, "gml_Script_", ""); 9 | var _pos = string_pos(":", _name); 10 | if (_pos > 0) 11 | { 12 | _name = string_copy(_name, 1, _pos - 1); 13 | } 14 | return _name; 15 | } -------------------------------------------------------------------------------- /scripts/CE_GetCallingFunctionName/CE_GetCallingFunctionName.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Core", 6 | "path": "folders/CoreExtension/Core.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_GetCallingFunctionName", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Hex/CE_Hex.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_ByteArrayToHex(_bytes) 2 | /// @desc Converts an array of number between 0..255 into a string of 3 | /// hexadecimal representations of each number. 4 | /// @param {array} _bytes The array with numbers. 5 | /// @return {string} The resulting string. 6 | function CE_ByteArrayToHex(_bytes) 7 | { 8 | var _str = ""; 9 | var i = 0; 10 | repeat (array_length(_bytes)) 11 | { 12 | _str += CE_ByteToHex(_bytes[i++]); 13 | } 14 | return _str; 15 | } 16 | 17 | /// @func CE_ByteToHex(_byte) 18 | /// @desc Converts a number in range 0..255 into a hexadecimal representation. 19 | /// @param {real} _byte The number to convert. 20 | /// @return {string} The hexadecimal representation. 21 | function CE_ByteToHex(_byte) 22 | { 23 | gml_pragma("forceinline"); 24 | return (CE_NibbleToHex((_byte & 0xF0) >> 4) + CE_NibbleToHex(_byte & 0xF)); 25 | } 26 | 27 | /// @func CE_NibbleToHex(_nibble) 28 | /// @desc Converts a number in range 0..15 into its hexadecimal representation. 29 | /// @param {real} _nibble The number to convert. 30 | /// @return {string} The hexadecimal representation. 31 | function CE_NibbleToHex(_nibble) 32 | { 33 | gml_pragma("forceinline"); 34 | static _nibbleToHex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]; 35 | return _nibbleToHex[_nibble]; 36 | } 37 | 38 | /// @func CE_HexToNibble(_hex) 39 | /// @desc Converts a hex char into a nibble. 40 | /// @param {string} _hex The character to convert. 41 | /// @return {real/NaN} The parsed nibble on success or NaN on fail. 42 | function CE_HexToNibble(_hex) 43 | { 44 | var _char = string_char_at(_hex, 1); 45 | _char = ord(string_upper(_char)); 46 | if (_char >= ord("0") && _char <= ord("9")) 47 | { 48 | return _char - ord("0"); 49 | } 50 | else if (_char >= ord("A") && _char <= ord("F")) 51 | { 52 | return 10 + _char - ord("A"); 53 | } 54 | else 55 | { 56 | return NaN; 57 | } 58 | } 59 | 60 | /// @func CE_HexToReal(_hex) 61 | /// @desc Converts hex string into a number. 62 | /// @param {string} _hex The hex string. 63 | /// @return {real/NaN} The parsed number on success or NaN on fail. 64 | function CE_HexToReal(_hex) 65 | { 66 | var _real = 0; 67 | var _index = 1; 68 | repeat (string_length(_hex)) 69 | { 70 | var _char = string_char_at(_hex, _index++); 71 | var _nibble = CE_HexToNibble(_char); 72 | if (is_nan(_nibble)) 73 | { 74 | return NaN; 75 | } 76 | _real = (_real << 4) | _nibble; 77 | } 78 | return _real; 79 | } -------------------------------------------------------------------------------- /scripts/CE_Hex/CE_Hex.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Core", 6 | "path": "folders/CoreExtension/Core.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Hex", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_IOException/CE_IOException.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_IOException() 2 | /// @extends CE_Exception 3 | /// @desc An exception thrown if an error occurs during reading/writing files. 4 | function CE_IOException() 5 | : CE_Exception() constructor 6 | { 7 | CE_CLASS_GENERATED_BODY; 8 | } -------------------------------------------------------------------------------- /scripts/CE_IOException/CE_IOException.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Exceptions", 6 | "path": "folders/CoreExtension/Core/Exceptions.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_IOException", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Input/CE_Input.gml: -------------------------------------------------------------------------------- 1 | /// @function CE_Input() 2 | /// @desc Input-handling singleton. 3 | function CE_Input() constructor 4 | { 5 | /// @var {ds_map} Mapping of actions to an array 6 | /// of keys that trigger them. 7 | /// @private 8 | static ActionToKeys = ds_map_create(); 9 | 10 | /// @var {ds_map} Mapping of keys to action they trigger. 11 | /// @private 12 | static KeyToAction = ds_map_create(); 13 | 14 | /// @func UnbindKey(_key) 15 | /// @desc Unbinds a key from an action. 16 | /// @param {real} _key The key to unbind. 17 | /// @return {CE_Input} Returns `self`. 18 | static UnbindKey = function (_key) { 19 | gml_pragma("forceinline"); 20 | if (ds_map_exists(KeyToAction, _key)) 21 | { 22 | var _action = KeyToAction[? _key]; 23 | var _keys = ActionToKeys[? _action]; 24 | var _index = 0; 25 | repeat (array_length(_keys)) 26 | { 27 | if (_keys[_index] == _key) 28 | { 29 | array_delete(_keys, _index, 1); 30 | if (array_length(_keys) == 0) 31 | { 32 | ds_map_delete(ActionToKeys, _action); 33 | } 34 | break; 35 | } 36 | ++_index; 37 | } 38 | ds_map_delete(KeyToAction, _key); 39 | } 40 | return self; 41 | }; 42 | 43 | /// @func UnbindAction(_action) 44 | /// @desc Unbinds all keys from an action. 45 | /// @param {string/real} _action The action to unbind. 46 | /// @return {CE_Input} Returns `self`. 47 | static UnbindAction = function (_action) { 48 | gml_pragma("forceinline"); 49 | if (ds_map_exists(ActionToKeys, _action)) 50 | { 51 | var _keys = ActionToKeys[? _action]; 52 | var _index = 0; 53 | repeat (array_length(_keys)) 54 | { 55 | ds_map_delete(KeyToAction, _keys[_index++]); 56 | } 57 | ds_map_delete(ActionToKeys, _action); 58 | } 59 | return self; 60 | }; 61 | 62 | /// @func Bind(_action, _key) 63 | /// @desc Binds a key to an action. 64 | /// @param {string/real} _action The action to bind the key to. 65 | /// @param {real} _key The key to bind to the action. 66 | /// @return {CE_Input} Returns `self`. 67 | /// @note If the key is already bound to an action, it is unbound first. 68 | static Bind = function (_action, _key) { 69 | gml_pragma("forceinline"); 70 | UnbindKey(_key); 71 | if (!ds_map_exists(ActionToKeys, _action)) 72 | { 73 | ActionToKeys[? _action] = []; 74 | } 75 | array_push(ActionToKeys[? _action], _key); 76 | return self; 77 | }; 78 | 79 | /// @func Check(_action) 80 | /// @desc Checks if any key bound to an action is held down. 81 | /// @param {string/real} _action The action to check. 82 | /// @return {bool} Returns `true` if a key bound to an action is held down. 83 | static Check = function (_action) { 84 | gml_pragma("forceinline"); 85 | if (!ds_map_exists(ActionToKeys, _action)) 86 | { 87 | return false; 88 | } 89 | var _keys = ActionToKeys[? _action]; 90 | var _index = 0; 91 | repeat (array_length(_keys)) 92 | { 93 | var _key = _keys[_index++]; 94 | switch (_key) 95 | { 96 | case mb_any: 97 | case mb_left: 98 | case mb_middle: 99 | case mb_right: 100 | case mb_side1: 101 | case mb_side2: 102 | if (mouse_check_button(_key)) 103 | { 104 | return true; 105 | } 106 | break; 107 | 108 | default: 109 | if (keyboard_check(_key)) 110 | { 111 | return true; 112 | } 113 | break; 114 | } 115 | } 116 | return false; 117 | }; 118 | 119 | /// @func CheckPressed(_action) 120 | /// @desc Checks if any key bound to an action was pressed. 121 | /// @param {string/real} _action The action to check. 122 | /// @return {bool} Returns `true` if a key bound to an action was pressed. 123 | static CheckPressed = function (_action) { 124 | gml_pragma("forceinline"); 125 | if (!ds_map_exists(ActionToKeys, _action)) 126 | { 127 | return false; 128 | } 129 | var _keys = ActionToKeys[? _action]; 130 | var _index = 0; 131 | repeat (array_length(_keys)) 132 | { 133 | var _key = _keys[_index++]; 134 | switch (_key) 135 | { 136 | case mb_any: 137 | case mb_left: 138 | case mb_middle: 139 | case mb_right: 140 | case mb_side1: 141 | case mb_side2: 142 | if (mouse_check_button_pressed(_key)) 143 | { 144 | return true; 145 | } 146 | break; 147 | 148 | default: 149 | if (keyboard_check_pressed(_key)) 150 | { 151 | return true; 152 | } 153 | break; 154 | } 155 | } 156 | return false; 157 | }; 158 | 159 | /// @func CheckReleased(_action) 160 | /// @desc Checks if any key bound to an action was released. 161 | /// @param {string/real} _action The action to check. 162 | /// @return {bool} Returns `true` if a key bound to an action was released. 163 | static CheckReleased = function (_action) { 164 | gml_pragma("forceinline"); 165 | if (!ds_map_exists(ActionToKeys, _action)) 166 | { 167 | return false; 168 | } 169 | var _keys = ActionToKeys[? _action]; 170 | var _index = 0; 171 | repeat (array_length(_keys)) 172 | { 173 | var _key = _keys[_index++]; 174 | switch (_key) 175 | { 176 | case mb_any: 177 | case mb_left: 178 | case mb_middle: 179 | case mb_right: 180 | case mb_side1: 181 | case mb_side2: 182 | if (mouse_check_button_released(_key)) 183 | { 184 | return true; 185 | } 186 | break; 187 | 188 | default: 189 | if (keyboard_check_released(_key)) 190 | { 191 | return true; 192 | } 193 | break; 194 | } 195 | } 196 | return false; 197 | }; 198 | } -------------------------------------------------------------------------------- /scripts/CE_Input/CE_Input.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Input", 6 | "path": "folders/CoreExtension/Input.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Input", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_InstanceUtils/CE_InstanceUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_InstanceCreate3D(_x[, _y, _z], _object) 2 | /// @desc Creates an instance of an object at given x, y, z position 3 | /// on a layer with id 0. 4 | /// @param {real/real[]} _x The x position to create the instance at 5 | /// or an array with `[x, y, z]` position. 6 | /// @param {real} [_y] The y position to create the instance at. Not 7 | /// used if `_x` is an array. 8 | /// @param {real} [_z] The z position to create the instance at. Not 9 | /// used if `_x` is an array. 10 | /// @param {object} _object The object to create an instance of. 11 | /// @return {real} The id of the created instance. 12 | function CE_InstanceCreate3D(_x) 13 | { 14 | gml_pragma("forceinline"); 15 | 16 | var _y, _z, _object; 17 | 18 | if (argument_count == 4) 19 | { 20 | _y = argument[1]; 21 | _z = argument[2]; 22 | _object = argument[3]; 23 | } 24 | else 25 | { 26 | _y = _x[1]; 27 | _z = _x[2]; 28 | _x = _x[0]; 29 | _object = argument[1]; 30 | } 31 | 32 | with (instance_create_layer(_x, _y, 0, _object)) 33 | { 34 | z = _z; 35 | return id; 36 | } 37 | } -------------------------------------------------------------------------------- /scripts/CE_InstanceUtils/CE_InstanceUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_InstanceUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Iterator/CE_Iterator.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_Iterator(_data) 2 | /// @extends CE_Class 3 | /// @desc Base class for iterators. 4 | /// @param {any} _data An iterable data structure. 5 | function CE_Iterator(_data) 6 | : CE_Class() constructor 7 | { 8 | CE_CLASS_GENERATED_BODY; 9 | 10 | /// @var The data structure to iterate through. 11 | /// @private 12 | Data = _data; 13 | 14 | /// @func Reset() 15 | /// @desc Resets the iterator to the beginning. 16 | /// @throws {CE_NotImplementedException} If the method is not implemented. 17 | static Reset = function () { 18 | throw new CE_NotImplementedException(); 19 | }; 20 | 21 | /// @func HasNext() 22 | /// @desc Checks whether the iterator has a next entry. 23 | /// @return {bool} Returns true if the iterator has a next entry. 24 | /// @throws {CE_NotImplementedException} If the method is not implemented. 25 | /// @see CE_Iterator.GetNext 26 | static HasNext = function () { 27 | throw new CE_NotImplementedException(); 28 | }; 29 | 30 | /// @func GetNext() 31 | /// @desc Retrieves the next entry in the iterator. 32 | /// @return {any} Returns the next entry. 33 | /// @throws {CE_OutOfRangeException} If there is no next entry. 34 | /// @throws {CE_NotImplementedException} If the method is not implemented. 35 | /// @see CE_Iterator.HasNext 36 | static GetNext = function () { 37 | throw new CE_NotImplementedException(); 38 | }; 39 | } -------------------------------------------------------------------------------- /scripts/CE_Iterator/CE_Iterator.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Iterators", 6 | "path": "folders/CoreExtension/Core/Iterators.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Iterator", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_ListIterator/CE_ListIterator.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_ListIterator(_list) 2 | /// @extends CE_Iterator 3 | /// @desc Implements an iterator over a `ds_list`. 4 | /// @param {ds_list} _list The list to iterate through. 5 | function CE_ListIterator(_list) 6 | : CE_Iterator(_list) constructor 7 | { 8 | Index = 0; 9 | 10 | static Reset = function () { 11 | gml_pragma("forceinline"); 12 | Index = 0; 13 | }; 14 | 15 | static HasNext = function () { 16 | gml_pragma("forceinline"); 17 | return (Index < ds_list_size(Data)); 18 | }; 19 | 20 | /// @func GetNext() 21 | /// @desc Retrieves the next value in the list. 22 | /// @return {any} The next value in the list. 23 | /// @throws {CE_OutOfRangeException} When there is no next value in the list. 24 | static GetNext = function () { 25 | gml_pragma("forceinline"); 26 | if (Index >= ds_list_size(Data)) 27 | { 28 | throw new CE_OutOfRangeException(); 29 | } 30 | return Data[| Index++]; 31 | }; 32 | } -------------------------------------------------------------------------------- /scripts/CE_ListIterator/CE_ListIterator.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Iterators", 6 | "path": "folders/CoreExtension/Core/Iterators.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_ListIterator", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_ListUtils/CE_ListUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_ListUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_MapIterator/CE_MapIterator.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_MapIterator(_map) 2 | /// @extends CE_Iterator 3 | /// @desc Implements an iterator over a `ds_map`. 4 | /// @param {ds_map} _map The map to iterate through. 5 | function CE_MapIterator(_map) 6 | : CE_Iterator(_map) constructor 7 | { 8 | Index = ds_map_find_first(Data); 9 | 10 | static Reset = function () { 11 | gml_pragma("forceinline"); 12 | Index = ds_map_find_first(Data); 13 | }; 14 | 15 | static HasNext = function () { 16 | gml_pragma("forceinline"); 17 | return (Index != undefined); 18 | }; 19 | 20 | /// @func GetNext() 21 | /// @desc Retrieves the next entry in the map. 22 | /// @return {CE_MapIteratorEntry} The next entry in the map. 23 | /// @throws {CE_OutOfRangeException} When there is no next entry in the map. 24 | /// @see CE_MapIteratorEntry 25 | static GetNext = function () { 26 | gml_pragma("forceinline"); 27 | if (Index == undefined) 28 | { 29 | throw new CE_OutOfRangeException(); 30 | } 31 | var _entry = new CE_MapIteratorEntry(Index, Data[? Index]); 32 | Index = ds_map_find_next(Data, Index); 33 | return _entry; 34 | }; 35 | } -------------------------------------------------------------------------------- /scripts/CE_MapIterator/CE_MapIterator.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Iterators", 6 | "path": "folders/CoreExtension/Core/Iterators.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_MapIterator", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_MapIteratorEntry/CE_MapIteratorEntry.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_MapIteratorEntry(_key, _value) 2 | /// @desc An item returned by an {@link CE_MapIterator}. 3 | /// @param {string} _key The entry key. 4 | /// @param {any} _value The entry value. 5 | /// @see CE_MapIterator 6 | function CE_MapIteratorEntry(_key, _value) constructor 7 | { 8 | /// @var {string} The entry key. 9 | /// @readonly 10 | Key = _key; 11 | 12 | /// @var {any} The entry value. 13 | /// @readonly 14 | Value = _value; 15 | } -------------------------------------------------------------------------------- /scripts/CE_MapIteratorEntry/CE_MapIteratorEntry.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Iterators", 6 | "path": "folders/CoreExtension/Core/Iterators.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_MapIteratorEntry", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_MapUtils/CE_MapUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_MapClone(_map) 2 | /// @desc Creates a shallow copy of the map. 3 | /// @param {ds_map} _map The map to clone. 4 | /// @return {ds_map} The created map. 5 | function CE_MapClone(_map) 6 | { 7 | var _clone = ds_map_create(); 8 | ds_map_copy(_clone, _map); 9 | return _clone; 10 | } 11 | 12 | /// @func CE_MapCreateFromArray(_keyValueArray) 13 | /// @desc Creates a new map, taking keys and values from the array. 14 | /// @param {array} _keyValueArray An array that containing keys at odd indices and 15 | /// values at even indices. 16 | /// @return {ds_map} The created map. 17 | /// @example 18 | /// Variables `_p1` and `_p2` hold maps with the exact same key-value pairs. 19 | /// ```gml 20 | /// var _p1 = CE_MapCreateFromArray([ 21 | /// "first_name", "Some", 22 | /// "last_name", "Dude", 23 | /// "age", 24, 24 | /// ]); 25 | /// var _p2 = ds_map_create(); 26 | /// ds_map_add(_p2, "first_name", "Some"); 27 | /// ds_map_add(_p2, "last_name", "Dude"); 28 | /// ds_map_add(_p2, "age", 24); 29 | /// ``` 30 | function CE_MapCreateFromArray(_keyValueArray) 31 | { 32 | var _map = ds_map_create(); 33 | var _size = array_length(_keyValueArray); 34 | for (var i = 0; i < _size; i += 2) 35 | { 36 | _map[? _keyValueArray[i]] = _keyValueArray[i + 1]; 37 | } 38 | return _map; 39 | } 40 | 41 | /// @func CE_MapExtend(_target, _source) 42 | /// @desc Shallowly copies key-value pairs from source map to the target map, 43 | /// overwriting the already existing ones. 44 | /// @param {ds_map} _target The map to be extended. 45 | /// @param {ds_map} _source The map to take the key-value pairs from. 46 | function CE_MapExtend(_target, _source) 47 | { 48 | var _size = ds_map_size(_source); 49 | var _key = ds_map_find_first(_source) 50 | for (var i = 0; i < _size; ++i) 51 | { 52 | _target[? _key] = _source[? _key]; 53 | _key = ds_map_find_next(_source, _key); 54 | } 55 | } 56 | 57 | /// @func CE_MapExtendFromArray(_map, _keyValueArray) 58 | /// @desc Extends a map by key-value pairs stored in an array. 59 | /// @param {ds_map} _map The map to extend. 60 | /// @param {array} _keyValueArray An array that contains keys 61 | /// at odd indices and values at even indices. 62 | function CE_MapExtendFromArray(_map, _keyValueArray) 63 | { 64 | var _size = array_length(_keyValueArray); 65 | for (var i = 0; i < _size; i += 2) 66 | { 67 | _map[? _keyValueArray[i]] = _keyValueArray[i + 1]; 68 | } 69 | } 70 | 71 | /// @func CE_MapFindKey(_map, _value) 72 | /// @desc Finds the first key of the map that contains given value. 73 | /// @param {ds_map} _map The map to search in. 74 | /// @param {any} _value The value that the key should contain. 75 | /// @return {string/real} The found key or `undefined`. 76 | function CE_MapFindKey(_map, _value) 77 | { 78 | var _key = ds_map_find_first(_map); 79 | repeat (ds_map_size(_map)) 80 | { 81 | if (_map[? _key] == _value) 82 | { 83 | return _key; 84 | } 85 | _key = ds_map_find_next(_map, _key); 86 | } 87 | return undefined; 88 | } 89 | 90 | /// @func CE_MapGet(_map, _index[, _default]) 91 | /// @desc Retrieves a value at given index of a map. 92 | /// @param {ds_map} _map The map to Get the value from. 93 | /// @param {real} _index The index. 94 | /// @param {any} [_default] The default value. Defaults to `undefined`. 95 | /// @return {any} Value at given index or the default value if the index does 96 | /// not exist. 97 | /// @example 98 | /// ```gml 99 | /// var _map = ds_map_create(); 100 | /// _map[? "a"] = 1; 101 | /// _map[? "b"] = 2; 102 | /// CE_MapGet(_map, "a"); // => 1 103 | /// CE_MapGet(_map, "b", 1); // => 2 104 | /// CE_MapGet(_map, "c", 3); // => 3 105 | /// CE_MapGet(_map, "c"); // => undefined 106 | /// ``` 107 | function CE_MapGet(_map, _index) 108 | { 109 | if (argument_count > 2 110 | && !ds_map_exists(_map, _index)) 111 | { 112 | return argument[2]; 113 | } 114 | return _map[? _index]; 115 | } 116 | 117 | /// @func CE_MapGetKeys(_map) 118 | /// @desc Retrieves an array of keys of a map. 119 | /// @param {ds_map} _map The map. 120 | /// @return {array} An array of all keys in the map. 121 | function CE_MapGetKeys(_map) 122 | { 123 | var _size = ds_map_size(_map); 124 | var _arr = array_create(_size, ""); 125 | var _key = ds_map_find_first(_map) 126 | for (var i = 0; i < _size; ++i) 127 | { 128 | _arr[i] = _key; 129 | _key = ds_map_find_next(_map, _key); 130 | } 131 | return _arr; 132 | } 133 | 134 | /// @func CE_MapGetValues(_map) 135 | /// @desc Retrieves an array of values of a map. 136 | /// @param {ds_map} _map The map. 137 | /// @return {array} An array of all values in the map. 138 | function CE_MapGetValues(_map) 139 | { 140 | var _size = ds_map_size(_map); 141 | var _arr = array_create(_size, ""); 142 | var _key = ds_map_find_first(_map) 143 | for (var i = 0; i < _size; ++i) 144 | { 145 | _arr[i] = _map[? _key]; 146 | _key = ds_map_find_next(_map, _key); 147 | } 148 | return _arr; 149 | } -------------------------------------------------------------------------------- /scripts/CE_MapUtils/CE_MapUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_MapUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_MathMisc/CE_MathMisc.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_Hammersley2D(_i, _n) 2 | /// @desc Gets i-th point from sequence of uniformly distributed points on a 3 | /// unit square. 4 | /// @param {real} _i The point index in sequence. 5 | /// @param {real} _n The total size of the sequence. 6 | /// @source http://holger.dammertz.org/stuff/notes__hammersley_on_hemisphere.html 7 | function CE_Hammersley2D(_i, _n) 8 | { 9 | var b = (_n << 16) | (_n >> 16); 10 | b = ((b & 0x55555555) << 1) | ((b & 0xAAAAAAAA) >> 1); 11 | b = ((b & 0x33333333) << 2) | ((b & 0xCCCCCCCC) >> 2); 12 | b = ((b & 0x0F0F0F0F) << 4) | ((b & 0xF0F0F0F0) >> 4); 13 | b = ((b & 0x00FF00FF) << 8) | ((b & 0xFF00FF00) >> 8); 14 | return [ 15 | _i / _n, 16 | b * 2.3283064365386963 * 0.0000000001 17 | ]; 18 | } 19 | 20 | /// @func CE_PointInRectangle(_pointX, _pointY, _rectX, _rectY, _rectWidth, _rectHeight) 21 | /// @param {real} _pointX The x position of the point. 22 | /// @param {real} _pointY The y position of the point. 23 | /// @param {real} _rectX The x position of the rectangle's top left corner. 24 | /// @param {real} _rectY The y position of the rectangle's top left corner. 25 | /// @param {real} _rectWidth The width of the rectangle. 26 | /// @param {real} _rectHeight The height of the rectangle. 27 | /// @return {bool} Returns `true` if the point is in the rectangle. 28 | function CE_PointInRectangle(_pointX, _pointY, _rectX, _rectY, _rectWidth, _rectHeight) 29 | { 30 | gml_pragma("forceinline"); 31 | return (_pointX > _rectX 32 | && _pointY > _rectY 33 | && _pointX < _rectX + _rectWidth 34 | && _pointY < _rectY + _rectHeight); 35 | } 36 | 37 | /// @func CE_ScaleKeepAspectRatio(_targetW _targetH, _width, _height) 38 | /// @param {real} _targetW The target width. 39 | /// @param {real} _targetH The target height. 40 | /// @param {real} _width The original width. 41 | /// @param {real} _height The original height. 42 | /// @return {real} The scale. 43 | function CE_ScaleKeepAspectRatio(_targetW, _targetH, _width, _height) 44 | { 45 | var _prevAspect = _targetW / _targetH; 46 | var _imgAspect = _width / _height; 47 | if (_prevAspect > _imgAspect) 48 | { 49 | return _targetH / _height; 50 | } 51 | return _targetW / _width; 52 | } 53 | 54 | /// @func CE_Smoothstep(_e0, _e1, _x) 55 | /// @desc Performs smooth Hermite interpolation between 0 and 1 when 56 | /// e0 < x < e1. 57 | /// @param {real} _e0 The lower edge of the Hermite function. 58 | /// @param {real} _e1 The upper edge of the Hermite function. 59 | /// @param {real} _x The source value for interpolation. 60 | /// @return {real} The resulting interpolated value. 61 | /// @source https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/smoothstep.xhtml 62 | function CE_Smoothstep(_e0, _e1, _x) 63 | { 64 | var _t = clamp((_x - _e0) / (_e1 - _e0), 0, 1); 65 | return (_t * _t * (3 - 2 * _t)); 66 | } 67 | 68 | /// @func CE_Snap(_value, _step) 69 | /// @desc Floors value to multiples of step using formula 70 | /// `floor(value / step) * step`. 71 | /// @param {real} _value The value. 72 | /// @param {real} _step The step. 73 | /// @return {real} The resulting value. 74 | /// @example 75 | /// ```gml 76 | /// CE_Snap(3.8, 2); // => 2 77 | /// CE_Snap(4.2, 2); // => 4 78 | /// ``` 79 | function CE_Snap(_value, _step) 80 | { 81 | gml_pragma("forceinline"); 82 | return floor(_value / _step) * _step; 83 | } 84 | 85 | /// @func CE_Wrap(_number, _min, _max) 86 | /// @desc Wraps number between values min and max. 87 | /// @param {real} _number The number to wrap. 88 | /// @param {real} _min The minimal value. 89 | /// @param {real} _max The maximal value. 90 | /// @return {real} The wrapped number. 91 | function CE_Wrap(_number, _min, _max) 92 | { 93 | gml_pragma("forceinline"); 94 | if (_number > _max) 95 | { 96 | return _number % _max; 97 | } 98 | if (_number < _min) 99 | { 100 | return _number % _max + _max; 101 | } 102 | return _number; 103 | } 104 | 105 | /// @func CE_WrapAngle(_angle) 106 | /// @desc Wraps angle between values 0..360. 107 | /// @param {real} angle The angle to wrap. 108 | /// @return {real} The wrapped angle. 109 | function CE_WrapAngle(_angle) 110 | { 111 | gml_pragma("forceinline"); 112 | return (_angle + ceil(-_angle / 360) * 360); 113 | } -------------------------------------------------------------------------------- /scripts/CE_MathMisc/CE_MathMisc.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Math", 6 | "path": "folders/CoreExtension/Math.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_MathMisc", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Matrix/CE_Matrix.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Math", 6 | "path": "folders/CoreExtension/Math.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Matrix", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_NativeArray/CE_NativeArray.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_NativeArray(_type, _size) 2 | /// @extends CE_Class 3 | /// @desc Implements an array using a buffer. This can be used to share 4 | /// the array with a dynamic library through a pointer to the buffer. 5 | /// @param {uint} _type The type of all values in the array. Use one of 6 | /// the `buffer_` types. `buffer_string` and `buffer_text` are currently 7 | /// not supported! 8 | /// @param {uint} _size The size of the array. 9 | /// @see ce_native_array_from_array 10 | function CE_NativeArray(_type, _size) 11 | : CE_Class() constructor 12 | { 13 | CE_CLASS_GENERATED_BODY; 14 | 15 | static Super_Class = { 16 | Destroy: Destroy, 17 | }; 18 | 19 | /// @var {uint} The type of values within the array. See `buffer_` 20 | /// constants. 21 | /// @readonly 22 | Type = _type; 23 | 24 | /// @var {uint} The size of the type in bytes. 25 | /// @readonly 26 | TypeSize = buffer_sizeof(Type); 27 | 28 | /// @var {uint} The size of the array. 29 | /// @readonly 30 | Size = _size; 31 | 32 | /// @var {buffer} The underlying buffer. 33 | /// @private 34 | // TODO: Fix native array buffer alignment? 35 | Buffer = buffer_create(TypeSize * Size, buffer_fixed, 1); 36 | 37 | /// @func GetPtr() 38 | /// @desc Retrieves a pointer to the underyling buffer. 39 | /// @return {ptr} The pointer to the underlying buffer. 40 | /// @example 41 | /// ```gml 42 | /// function native_array_sort(_nativeArray) 43 | /// { 44 | /// gml_pragma("forceinline"); 45 | /// static _fn = external_define( 46 | /// "MyExtension.dll", 47 | /// "native_array_sort", 48 | /// dll_cdecl, 49 | /// ty_real, 50 | /// 3, 51 | /// ty_string, // Pointer to the buffer 52 | /// ty_real, // Size of the array 53 | /// ty_real); // Size of array entry type in bytes 54 | /// return external_call(_fn, _nativeArray.GetPtr(), _nativeArray.Size, _nativeArray.TypeSize); 55 | /// } 56 | /// ``` 57 | static GetPtr = function () { 58 | gml_pragma("forceinline"); 59 | return buffer_get_address(Buffer); 60 | }; 61 | 62 | /// @func GetByteSize() 63 | /// @desc Retrieves the total size of the array in bytes. 64 | /// @return {uint} The total size of the array in bytes. 65 | static GetByteSize = function () { 66 | gml_pragma("forceinline"); 67 | return buffer_get_size(Buffer); 68 | }; 69 | 70 | /// @func Get(_index) 71 | /// @desc Retrieves a value at given index. 72 | /// @param {uint} _index A position within the native array to read 73 | /// the value from. 74 | /// @return {real} The value at given index. 75 | static Get = function (_index) { 76 | gml_pragma("forceinline"); 77 | buffer_seek(Buffer, buffer_seek_start, TypeSize * _index); 78 | return buffer_read(Buffer, Type); 79 | }; 80 | 81 | /// @func Set(_index, _value) 82 | /// @desc Sets a value at given index. 83 | /// @param {uint} _index A position within the native to set the value 84 | /// at. 85 | /// @param {real} _value The value. 86 | /// @return {CE_NativeArray} Returns `self`. 87 | static Set = function (_index, _value) { 88 | gml_pragma("forceinline"); 89 | buffer_seek(Buffer, buffer_seek_start, TypeSize * _index); 90 | buffer_write(Buffer, Type, _value); 91 | return self; 92 | }; 93 | 94 | /// @func FromArray(_array) 95 | /// @desc Copies values from a normal array into the native array. 96 | /// @param {real[]} _array The array to copy the values from. 97 | /// @return {CE_NativeArray} Returns `self`. 98 | static FromArray = function (_array) { 99 | gml_pragma("forceinline"); 100 | var i = 0; 101 | buffer_seek(Buffer, buffer_seek_start, 0); 102 | repeat (min(array_length(_array), Size)) 103 | { 104 | buffer_write(Buffer, Type, _array[i++]); 105 | } 106 | return self; 107 | }; 108 | 109 | /// @func ToArray([_array]) 110 | /// @desc Copies all values from the native array into a normal array. 111 | /// @param {array} [_array] The target array to copy the values to. If 112 | /// not specified, then a new one is created. 113 | /// @return {real[]} The target array. 114 | static ToArray = function () { 115 | gml_pragma("forceinline"); 116 | var _array = (argument_count > 0) ? argument[0] : array_create(Size, 0); 117 | var i = 0; 118 | buffer_seek(Buffer, buffer_seek_start, 0); 119 | repeat (Size) 120 | { 121 | _array[@ i++] = buffer_read(Buffer, Type); 122 | } 123 | return _array; 124 | }; 125 | 126 | /// @func ToString() 127 | /// @desc Pretty-prints the native array into a string. 128 | /// @return {string} The created string. 129 | static ToString = function () { 130 | gml_pragma("forceinline"); 131 | var _str = "[ "; 132 | buffer_seek(Buffer, buffer_seek_start, 0); 133 | repeat (Size - 1) 134 | { 135 | _str += string(buffer_read(Buffer, Type)) + ", "; 136 | } 137 | return (_str + string(buffer_read(Buffer, Type)) + " ]"); 138 | }; 139 | 140 | static Destroy = function () { 141 | method(self, Super_Class.Destroy)(); 142 | buffer_delete(Buffer); 143 | }; 144 | } 145 | 146 | /// @func ce_native_array_from_array(_array, _type) 147 | /// @desc Creates a new {@link CE_NativeArray} and fills it with values from 148 | /// the given array. 149 | /// @param {real[]} _array The array to create a native array from. 150 | /// @param {uint} _type The type of all values in the array. Use one of 151 | /// the `buffer_` types. `buffer_string` and `buffer_text` are currently 152 | /// not supported! 153 | /// @return {CE_NativeArray} The created native array. 154 | /// @see CE_NativeArray 155 | function ce_native_array_from_array(_array, _type) 156 | { 157 | gml_pragma("forceinline"); 158 | return new CE_NativeArray(_type, array_length(_array)).FromArray(_array); 159 | } -------------------------------------------------------------------------------- /scripts/CE_NativeArray/CE_NativeArray.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Native", 6 | "path": "folders/CoreExtension/Native.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_NativeArray", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_NavGrid/CE_NavGrid.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "NavGrid", 6 | "path": "folders/CoreExtension/NavGrid.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_NavGrid", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_NavGridPath/CE_NavGridPath.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_NavGridPath() 2 | /// @extends CE_Class 3 | /// @see CE_NavGrid 4 | function CE_NavGridPath() 5 | : CE_Class() constructor 6 | { 7 | CE_CLASS_GENERATED_BODY; 8 | 9 | static Super_Class = { 10 | Destroy: Destroy, 11 | }; 12 | 13 | /// @var {ds_map} 14 | /// @private 15 | Map = ds_map_create(); 16 | 17 | /// @var {bool} If `false` then the path was not found. 18 | /// @readonly 19 | Found = false; 20 | 21 | /// @var {CE_NavGrid/undefined} The navgrid to which the path belongs. 22 | /// @private 23 | NavGrid = undefined; 24 | 25 | /// @var {bool} If `true` then the path can possibly contain diagonal 26 | /// traversals. 27 | /// @readonly 28 | Diagonal = false; 29 | 30 | /// @var {uint} 31 | /// @private 32 | IndexStart = 0; 33 | 34 | /// @var {uint} 35 | /// @private 36 | IndexFinish = 0; 37 | 38 | /// @var {uint} 39 | /// @private 40 | IndexCurrent = undefined; 41 | 42 | /// @var {real} 43 | /// @readonly 44 | StartX = 0.0; 45 | 46 | /// @var {real} 47 | /// @readonly 48 | StartY = 0.0; 49 | 50 | /// @var {real} 51 | /// @readonly 52 | FinishX = 0.0; 53 | 54 | /// @var {real} 55 | /// @readonly 56 | FinishY = 0.0; 57 | 58 | /// @func Clear() 59 | /// @desc Clears the path data. 60 | /// @return {CE_NavGridPath} Returns `self`. 61 | static Clear = function () { 62 | gml_pragma("forceinline"); 63 | ds_map_clear(Map); 64 | return self; 65 | }; 66 | 67 | /// @func Add(_from, _to) 68 | /// @desc Defines traversal to the next cell. 69 | /// @param {uint} _from The cell we are traversing from (encoded). 70 | /// @param {uint} _to The cell we are traversing to (encoded). 71 | /// @return {CE_NavGridPath} Returns `self`. 72 | static Add = function (_from, _to) { 73 | gml_pragma("forceinline"); 74 | Map[? _from] = _to; 75 | return self; 76 | }; 77 | 78 | /// @func Start() 79 | /// @return {CE_NavGridPath} Returns `self`. 80 | static Start = function () { 81 | gml_pragma("forceinline"); 82 | IndexCurrent = IndexStart; 83 | return self; 84 | }; 85 | 86 | /// @func HasNext() 87 | /// @desc Checks if there is a next point in the path. 88 | /// @return {bool} Returns `true` if there is a next point in the path. 89 | static HasNext = function () { 90 | gml_pragma("forceinline"); 91 | return ds_map_exists(Map, IndexCurrent); 92 | }; 93 | 94 | /// @func Next() 95 | /// @desc Goes to the next point in the path. 96 | /// @return {CE_NavGridPath} Returns `self`. 97 | static Next = function () { 98 | gml_pragma("forceinline"); 99 | IndexCurrent = Map[? IndexCurrent]; 100 | return self; 101 | }; 102 | 103 | /// @func GetX() 104 | /// @desc Retrieves the X coordinate of the current point. 105 | /// @return {real} The X coordinate of the current point. 106 | static GetX = function () { 107 | gml_pragma("forceinline"); 108 | switch (IndexCurrent) 109 | { 110 | case IndexStart: 111 | return StartX; 112 | 113 | case IndexFinish: 114 | return FinishX; 115 | 116 | default: 117 | return NavGrid.LocalToWorldX(NavGrid.DecodeLocalX(IndexCurrent)); 118 | } 119 | }; 120 | 121 | /// @func GetY() 122 | /// @desc Retrieves the Y coordinate of the current point. 123 | /// @return {real} The Y coordinate of the current point. 124 | static GetY = function () { 125 | gml_pragma("forceinline"); 126 | switch (IndexCurrent) 127 | { 128 | case IndexStart: 129 | return StartY; 130 | 131 | case IndexFinish: 132 | return FinishY; 133 | 134 | default: 135 | return NavGrid.LocalToWorldY(NavGrid.DecodeLocalY(IndexCurrent)); 136 | } 137 | }; 138 | 139 | static Destroy = function () { 140 | method(self, Super_Class.Destroy)(); 141 | ds_map_destroy(Map); 142 | }; 143 | } -------------------------------------------------------------------------------- /scripts/CE_NavGridPath/CE_NavGridPath.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "NavGrid", 6 | "path": "folders/CoreExtension/NavGrid.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_NavGridPath", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_NotImplementedException/CE_NotImplementedException.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_NotImplementedException() 2 | /// @extends CE_Exception 3 | function CE_NotImplementedException() 4 | : CE_Exception() constructor 5 | { 6 | CE_CLASS_GENERATED_BODY; 7 | } -------------------------------------------------------------------------------- /scripts/CE_NotImplementedException/CE_NotImplementedException.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Exceptions", 6 | "path": "folders/CoreExtension/Core/Exceptions.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_NotImplementedException", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_ObjectUtils/CE_ObjectUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_ObjectGetBase(_object) 2 | /// @param {real} _object The object index. 3 | /// @return {real} The index of the base object in the object's ancestors 4 | /// hierarchy. 5 | /// @example 6 | /// If object `C` has parent `B` and object `B` has parent `A`, then 7 | /// `CE_ObjectGetBase(C) would return `A`. 8 | function CE_ObjectGetBase(_object) 9 | { 10 | while (true) 11 | { 12 | var _parent = object_get_parent(_object); 13 | if (_parent < 0) 14 | { 15 | return _object; 16 | } 17 | _object = _parent; 18 | } 19 | } 20 | 21 | /// @func CE_ObjectIs(_a, _b) 22 | /// @param {real} _a The index of object A. 23 | /// @param {real} _b The index of object B. 24 | /// @return {bool} Returns `true` if object A is or inherits from object B. 25 | function CE_ObjectIs(_a, _b) 26 | { 27 | gml_pragma("forceinline"); 28 | return (_a == _b || object_is_ancestor(_a, _b)); 29 | } -------------------------------------------------------------------------------- /scripts/CE_ObjectUtils/CE_ObjectUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_ObjectUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_OutOfRangeException/CE_OutOfRangeException.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_OutOfRangeException() 2 | /// @extends CE_Exception 3 | /// @desc An exception thrown when you try to read a value from a data structure 4 | /// at an index which is out of its range. 5 | function CE_OutOfRangeException() 6 | : CE_Exception("Index out of range!") constructor 7 | { 8 | CE_CLASS_GENERATED_BODY; 9 | } -------------------------------------------------------------------------------- /scripts/CE_OutOfRangeException/CE_OutOfRangeException.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Exceptions", 6 | "path": "folders/CoreExtension/Core/Exceptions.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_OutOfRangeException", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Quaternion/CE_Quaternion.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Math", 6 | "path": "folders/CoreExtension/Math.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Quaternion", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_RealUtils/CE_RealUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_RealParse(string) 2 | /// @desc Parses a real number from a string. 3 | /// @param {string} string The string to Parse the number from. 4 | /// @return {real/string} The parsed number or `NaN` if the string does not 5 | /// represent a number. 6 | function CE_RealParse(_string) 7 | { 8 | var _sign = 1; 9 | var _number = "0"; 10 | var _index = 1; 11 | var _state = 0; 12 | 13 | repeat (string_length(_string) + 1) 14 | { 15 | var _char = string_char_at(_string, _index++); 16 | 17 | switch (_state) 18 | { 19 | case 0: 20 | if (_char == "-") 21 | { 22 | _sign *= -1; 23 | } 24 | else if (_char == "+") 25 | { 26 | _sign *= +1; 27 | } 28 | else if (CE_CharIsDigit(_char) 29 | || _char == ".") 30 | { 31 | _state = 1; 32 | --_index; 33 | } 34 | else 35 | { 36 | return NaN; 37 | } 38 | break; 39 | 40 | case 1: 41 | if (CE_CharIsDigit(_char) 42 | || _char == ".") 43 | { 44 | _number += _char; 45 | } 46 | else 47 | { 48 | return NaN; 49 | } 50 | break; 51 | 52 | case 2: 53 | if (CE_CharIsDigit(_char)) 54 | { 55 | _number += _char; 56 | } 57 | else 58 | { 59 | return NaN; 60 | } 61 | break; 62 | } 63 | } 64 | 65 | return _sign * real(_number); 66 | } 67 | 68 | /// @func CE_RealCompare(r1, r2) 69 | /// @desc Compares two numbers. 70 | /// @param {real} _r1 The first number. 71 | /// @param {real} _r2 The second number. 72 | /// @return {real} Returns `cmpfunc_equal` if the numbers are equal or 73 | /// `cmpfunc_less` / `cmpfunc_greater` if the first number is 74 | /// less / greater than the second number. 75 | /// @example 76 | /// Sorting an array of numbers using a bubble sort algorithm and this function 77 | /// for number comparison. 78 | /// ```gml 79 | /// var _numbers = [3, 1, 2]; 80 | /// var _size = array_length(_numbers); 81 | /// for (var i = 0; i < _size - 1; ++i) 82 | /// { 83 | /// for (var j = 0; j < _size - i - 1; ++j) 84 | /// { 85 | /// if (CE_RealCompare(_numbers[j], _numbers[j + 1]) == cmpfunc_greater) 86 | /// { 87 | /// CE_ArraySwap(_numbers, j, j + 1); 88 | /// } 89 | /// } 90 | /// } 91 | /// // The array is now equal to [1, 2, 3]. 92 | /// ``` 93 | function CE_RealCompare(_r1, _r2) 94 | { 95 | gml_pragma("forceinline"); 96 | return ((_r1 < _r2) ? cmpfunc_less 97 | : ((_r1 > _r2) ? cmpfunc_greater 98 | : cmpfunc_equal)); 99 | } 100 | 101 | /// @func CE_RealIsEven(_real) 102 | /// @param {real} _real The number to check. 103 | /// @return {bool} Returns `true` if the number is even. 104 | function CE_RealIsEven(_real) 105 | { 106 | gml_pragma("forceinline"); 107 | return (_real & $1 == 0); 108 | } 109 | 110 | /// @func CE_RealIsOdd(_real) 111 | /// @param {real} _real The number to check. 112 | /// @return {bool} Returns `true` if the number is odd. 113 | function CE_RealIsOdd(_real) 114 | { 115 | gml_pragma("forceinline"); 116 | return (_real & $1 == 1); 117 | } 118 | 119 | /// @func CE_RealToString(_real[, _decimalPlaces]) 120 | /// @desc Converts a real value to a string without generating trailing zeros 121 | /// after a decimal point. 122 | /// @param {real} _real The real value to convert to a string. 123 | /// @param {real} [_decimalPlaces] Maximum decimal places. Defaults to 16. 124 | /// @return {string} The resulting string. 125 | /// @example 126 | /// ```gml 127 | /// CE_RealToString(16); // => 16 128 | /// CE_RealToString(16.870); // => 16.87 129 | /// ``` 130 | function CE_RealToString(_real, _decimalPlaces=16) 131 | { 132 | var _string = string_format(_real, -1, _decimalPlaces); 133 | var _stringLength = string_length(_string); 134 | 135 | while (_decimalPlaces >= 0 136 | && string_byte_at(_string, _stringLength) == 48) 137 | { 138 | _string = string_format(_real, -1, --_decimalPlaces); 139 | --_stringLength; 140 | } 141 | 142 | return _string; 143 | } -------------------------------------------------------------------------------- /scripts/CE_RealUtils/CE_RealUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_RealUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_StateMachine/CE_StateMachine.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_StateMachine() 2 | /// @extends CE_Class 3 | /// @desc A state machine. 4 | /// @see CE_StateMachineState 5 | function CE_StateMachine() 6 | : CE_Class() constructor 7 | { 8 | CE_CLASS_GENERATED_BODY; 9 | 10 | static Super_Class = { 11 | Destroy: Destroy, 12 | }; 13 | 14 | /// @var {CE_StateMachineState[]} An array of sates. 15 | /// @private 16 | StateArray = []; 17 | 18 | /// @var {bool} If `false` then the state machine has not yet entered its 19 | /// initial state. 20 | /// @readonly 21 | /// @see CE_StateMachine.Start 22 | Started = false; 23 | 24 | /// @var {bool} If `true` then the state machine has reached its final state. 25 | /// @readonly 26 | /// @see CE_StateMachine.Finish 27 | Finished = false; 28 | 29 | /// @var {CE_StateMachineState/undefined} The current state. 30 | /// @readonly 31 | State = undefined; 32 | 33 | /// @var {func/undefined} A function executed on the Start of the state of 34 | /// the state machine. It should take the state machine as the first argument. 35 | OnEnter = undefined; 36 | 37 | /// @var {func/undefined} A function executed in the Update method *before* 38 | /// the current state is updated. It should take the state machine as the 39 | /// first argument and {@link CE_DeltaTime} as the second argument. 40 | OnPreUpdate = undefined; 41 | 42 | /// @var {func/undefined} A function executed when the state changes. 43 | /// It should take the state machine as the first argument and its previous 44 | /// state as the second argument. 45 | OnStateChange = undefined; 46 | 47 | /// @var {func/undefined} A function executed in the Update method *after* 48 | /// the current state is updated. It should take the state machine as the 49 | /// first argument and {@link CE_DeltaTime} as the second argument. 50 | OnPostUpdate = undefined; 51 | 52 | /// @var {func/undefined} A function executed on the end of the state machine. 53 | /// It should take the state machine as the first argument. 54 | OnExit = undefined; 55 | 56 | /// @func Start() 57 | /// @desc Enters the initial state of the state machine. 58 | /// @return {CE_StateMachine} Returns `self`. 59 | static Start = function () { 60 | gml_pragma("forceinline"); 61 | Started = true; 62 | Finished = false; 63 | if (OnEnter != undefined) 64 | { 65 | OnEnter(self); 66 | } 67 | return self; 68 | }; 69 | 70 | /// @func Finish() 71 | /// @desc Enters the exit state of the state machine. 72 | /// @return {CE_StateMachine} Returns `self`. 73 | static Finish = function () { 74 | gml_pragma("forceinline"); 75 | Finished = true; 76 | if (OnExit != undefined) 77 | { 78 | OnExit(self); 79 | } 80 | return self; 81 | }; 82 | 83 | /// @func AddState(_state) 84 | /// @desc Adds a state to the state machine. 85 | /// @param {CE_StateMachineState} _state The state to add. 86 | /// @return {CE_StateMachine} Returns `self`. 87 | static AddState = function (_state) { 88 | gml_pragma("forceinline"); 89 | _state.StateMachine = self; 90 | array_push(StateArray, _state); 91 | return self; 92 | }; 93 | 94 | /// @func ChangeState(_state) 95 | /// @desc Changes the state of the state machine and executes 96 | /// {@link CE_StateMachine.OnStateChange}. 97 | /// @param {uint} _state The new state. 98 | /// @return {CE_StateMachine} Returns itself. 99 | /// @throws {string} If an invalid state is passed. 100 | static ChangeState = function (_state) { 101 | gml_pragma("forceinline"); 102 | 103 | // Check if the state is valid 104 | if (_state.StateMachine != self) 105 | { 106 | throw "Invalid state \"" + string(_state.Name) + "\"!"; 107 | } 108 | 109 | // Exit current state 110 | var _statePrev = State; 111 | 112 | if (_statePrev != undefined) 113 | { 114 | if (_statePrev.OnExit != undefined) 115 | { 116 | _statePrev.IsActive = false; 117 | _statePrev.OnExit(_statePrev); 118 | } 119 | } 120 | 121 | // Enter new state 122 | State = _state; 123 | State.IsActive = true; 124 | State.ActiveSince = current_time; 125 | 126 | if (State.OnEnter != undefined) 127 | { 128 | State.OnEnter(State); 129 | } 130 | 131 | // Trigger OnStateChange 132 | if (OnStateChange != undefined) 133 | { 134 | OnStateChange(self, _statePrev); 135 | } 136 | 137 | return self; 138 | }; 139 | 140 | /// @func Update(_deltaTime) 141 | /// @desc Executes function for the current state of the state machine 142 | /// (if defined). 143 | /// @param {CE_DeltaTime} _deltaTime Delta time singleton. 144 | /// @return {CE_StateMachine} Returns `self`. 145 | /// @note This function does not do anything if the state machine has not 146 | /// started yet or if it has already reached its final state. 147 | /// @see CE_StateMachine.Start 148 | /// @see CE_StateMachine.Finish 149 | static Update = function (_deltaTime) { 150 | gml_pragma("forceinline"); 151 | 152 | if (!Started || Finished) 153 | { 154 | return self; 155 | } 156 | 157 | if (OnPreUpdate != undefined) 158 | { 159 | OnPreUpdate(self, _deltaTime); 160 | } 161 | 162 | if (State != undefined && State.OnUpdate != undefined) 163 | { 164 | State.OnUpdate(State); 165 | } 166 | 167 | if (OnPostUpdate != undefined) 168 | { 169 | OnPostUpdate(self, _deltaTime); 170 | } 171 | 172 | return self; 173 | }; 174 | 175 | static Destroy = function () { 176 | method(self, Super_Class.Destroy)(); 177 | for (var i = array_length(StateArray) - 1; i >= 0; --i) 178 | { 179 | StateArray[i].Destroy(); 180 | } 181 | }; 182 | } -------------------------------------------------------------------------------- /scripts/CE_StateMachine/CE_StateMachine.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "StateMachine", 6 | "path": "folders/CoreExtension/StateMachine.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_StateMachine", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_StateMachineState/CE_StateMachineState.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_StateMachineState(_name) 2 | /// @extends CE_Class 3 | /// @desc A state of a state machine. 4 | /// @param {string} _name The name of the state. 5 | /// @see CE_StateMachine 6 | function CE_StateMachineState(_name) 7 | : CE_Class() constructor 8 | { 9 | CE_CLASS_GENERATED_BODY; 10 | 11 | /// @var {CE_StateMachine/undefined} The state machine to which this state 12 | /// belongs. 13 | /// @readonly 14 | StateMachine = undefined; 15 | 16 | /// @var {string} The name of the state. 17 | Name = _name; 18 | 19 | /// @var {func/undefined} A function executed when a state machines enters 20 | /// this state. Should take the state as the first argument. 21 | OnEnter = undefined; 22 | 23 | /// @var {func/undefined} A function executed while the state is active. 24 | /// Should take the state as the first argument and {@link CE_DeltaTime} as 25 | /// the second. 26 | OnUpdate = undefined; 27 | 28 | /// @var {func/undefined} A function executed when a state machine exists this 29 | /// state. Should take the state as the first argument. 30 | OnExit = undefined; 31 | 32 | /// @var {bool} If `true` then the state is currently active. 33 | /// @readonly 34 | IsActive = false; 35 | 36 | /// @var {uint} 37 | /// @private 38 | ActiveSince = 0; 39 | 40 | /// @func GetDuration() 41 | /// @desc Retrieves how long (in milliseconds) has the state been active for. 42 | /// @return {uint} Number of milliseconds for which has the state been active. 43 | static GetDuration = function () { 44 | gml_pragma("forceinline"); 45 | return (current_time - ActiveSince); 46 | }; 47 | } -------------------------------------------------------------------------------- /scripts/CE_StateMachineState/CE_StateMachineState.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "StateMachine", 6 | "path": "folders/CoreExtension/StateMachine.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_StateMachineState", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_StringUtils/CE_StringUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_CharIsDigit(_char) 2 | /// @param {string} _char The character. 3 | /// @return {bool} Returns `true` if the character is a digit. 4 | function CE_CharIsDigit(_char) 5 | { 6 | gml_pragma("forceinline"); 7 | return (_char >= "0" && _char <= "9"); 8 | } 9 | 10 | /// @func CE_CharIsLetter(_char) 11 | /// @param {string} _char The character. 12 | /// @return {bool} Returns `true` if the character is a letter. 13 | function CE_CharIsLetter(_char) 14 | { 15 | gml_pragma("forceinline"); 16 | return ((_char >= "a" && _char <= "b") 17 | || (_char >= "A" && _char <= "B")); 18 | } 19 | 20 | /// @func CE_StringCompare(_s1, _s2) 21 | /// @desc Compares the first string to the second string. 22 | /// @param {string} _s1 The first string. 23 | /// @param {string} _s2 The seconds string. 24 | /// @return {real} Returns `cmpfunc_equal` when the strings are equal or 25 | /// `cmpfunc_less` / `cmpfunc_greater` when the first one goes 26 | /// before / after the second one. 27 | /// @example Sorting an array of strings using a bubble sort algorithm and this 28 | /// function for string comparison. 29 | /// ```gml 30 | /// var _names = ["John", "Adam", "David"]; 31 | /// var _size = array_length_1d(_names); 32 | /// for (var i = 0; i < _size - 1; ++i) 33 | /// { 34 | /// for (var j = 0; j < _size - i - 1; ++j) 35 | /// { 36 | /// if (CE_StringCompare(_names[j], _names[j + 1]) == cmpfunc_greater) 37 | /// { 38 | /// CE_ArraySwap(_names, j, j + 1); 39 | /// } 40 | /// } 41 | /// } 42 | /// // The array is now equal to ["Adam", "David", "John"]. 43 | /// ``` 44 | function CE_StringCompare(_s1, _s2) 45 | { 46 | var _c0, _c1, i = 1; 47 | do 48 | { 49 | _c0 = string_char_at(_s1, i); 50 | _c1 = string_char_at(_s2, i++); 51 | if (_c0 == _c1) 52 | { 53 | continue; 54 | } 55 | if (_c0 < _c1) 56 | { 57 | return cmpfunc_less; 58 | } 59 | return cmpfunc_greater; 60 | } 61 | until (_c0 == "" && _c1 == ""); 62 | return cmpfunc_equal; 63 | } 64 | 65 | /// @func CE_StringEndsWith(_string, _substring) 66 | /// @param {string} _string The string to check. 67 | /// @param {string} _substring The expected end of the string. 68 | /// @return {bool} Returns `true` if the string ends with the substring. 69 | function CE_StringEndsWith(_string, _substring) 70 | { 71 | var _len = string_length(_substring); 72 | return (string_copy(_string, string_length(_string) - _len + 1, _len) == _substring); 73 | } 74 | 75 | /// @func CE_StringExplode(_string, _delimiter) 76 | /// @desc Splits the string on every occurence of the delimiter and puts 77 | /// the resulting substrings into an array. 78 | /// @param {string} _string The string to split. 79 | /// @param {string} _delimiter The string to split on. 80 | /// @return {array} The array of substrings. 81 | /// @example 82 | /// This creates an array `["Hello", " World!"]`. 83 | /// ``` 84 | /// CE_StringExplode("Hello, World!", ","); 85 | /// ``` 86 | function CE_StringExplode(_string, _delimiter) 87 | { 88 | var _count = string_count(_delimiter, _string); 89 | var _arr = array_create(_count + 1, undefined); 90 | var _start = 1; 91 | var i = 0; 92 | repeat (_count) 93 | { 94 | var _end = string_pos_ext(_delimiter, _string, _start); 95 | _arr[@ i++] = string_copy(_string, _start, _end - _start); 96 | _start = _end + 1; 97 | } 98 | _arr[@ i] = string_delete(_string, 1, _start - 1); 99 | return _arr; 100 | } 101 | 102 | /// @func CE_StringFormat(_string[, _data]) 103 | /// @desc Replaces all occurences of `${identifier}` in the string with given 104 | /// data. 105 | /// @param {string} _string The string to format. 106 | /// @param {array/ds_map} [_data] An array or a map containing the data. 107 | /// If an array is passed, the identifiers must be numbers or variable names of 108 | /// the calling instance. If a map is passed, the identifiers must be keys of 109 | /// the map or variable names of the calling instance. Using unknown identifiers 110 | /// will result in error. Only maps with strings as keys are supported. 111 | /// @return {string} The resulting string. 112 | /// @example 113 | /// ``` 114 | /// // Prints "Hello, Some!" 115 | /// username = "Some"; 116 | /// show_debug_message(CE_StringFormat("Hello, ${username}!")); 117 | /// // Prints "You have 100 HP." 118 | /// show_debug_message(CE_StringFormat("You have ${0} HP.", [100])); 119 | /// // Prints "Hello, Dude!" 120 | /// var _data = ds_map_create(); 121 | /// _data[? "username"] = "Dude"; 122 | /// show_debug_message(CE_StringFormat("Hello, ${username}!", _data)); 123 | /// ds_map_destroy(_data); 124 | /// ``` 125 | function CE_StringFormat(_string) 126 | { 127 | // TODO: Add support for `other.` etc? 128 | var _str = _string; 129 | var _data = (argument_count > 1) ? argument[1] : undefined; 130 | var _isMap = is_real(_data); 131 | var _isArray = is_array(_data); 132 | var _result = ""; 133 | 134 | while (true) 135 | { 136 | var _start = string_pos("${", _str); 137 | if (_start == 0) 138 | { 139 | break; 140 | } 141 | _result += string_copy(_str, 1, _start - 1); 142 | _str = string_delete(_str, 1, _start + 1); 143 | var _end = string_pos("}", _str); 144 | if (_end == 0) 145 | { 146 | return _string; 147 | } 148 | --_end; 149 | var _varName = string_copy(_str, 1, _end); 150 | var _added = false; 151 | if (_isMap 152 | && ds_map_exists(_data, _varName)) 153 | { 154 | _result += string(_data[? _varName]); 155 | _added = true; 156 | } 157 | else if (_isArray 158 | && string_digits(_varName) == _varName) 159 | { 160 | _result += string(_data[real(_varName)]); 161 | _added = true 162 | } 163 | if (!_added) 164 | { 165 | _result += string(variable_instance_get(id, _varName)); 166 | } 167 | _str = string_delete(_str, 1, _end + 1); 168 | } 169 | 170 | _result += _str; 171 | 172 | return _result; 173 | } 174 | 175 | /// @func CE_StringJoin(_string, values...) 176 | /// @desc Joins given values together putting the string between each 177 | /// consecutive two. 178 | /// @param {string} _string The string to put between two consecutive values. 179 | /// @param {any} _values Any number of values to be joined. 180 | /// @return {string} The resulting string. 181 | /// @example 182 | /// This could show a debug message saying "Player Patrik took 60 damage!". 183 | /// ```gml 184 | /// show_debug_message( 185 | /// CE_StringJoin(" ", "Player", player.name, "took", _damage, "damage!")); 186 | /// ``` 187 | function CE_StringJoin(_string) 188 | { 189 | if (argument_count == 1) 190 | { 191 | return ""; 192 | } 193 | var _str = ""; 194 | for (var i = 1; i < argument_count - 1; ++i) 195 | { 196 | _str += string(argument[i]) + _string; 197 | } 198 | _str += string(argument[i]); 199 | return _str; 200 | } 201 | 202 | /// @func CE_StringJoinArray(_string, _array) 203 | /// @desc Joins values in the array putting the string between each two 204 | /// consecutive values. 205 | /// @param {string} _string The string to put between two consecutive values. 206 | /// @param {array} _array An array of values that you want to join. 207 | /// @return {string} The resulting string. 208 | /// @example 209 | /// This will show a message saying "Numbers: 1, 2, 3, 4". 210 | /// ```gml 211 | /// show_message("Numbers: " + CE_StringJoinArray(", ", [1, 2, 3, 4])); 212 | /// ``` 213 | function CE_StringJoinArray(_string, _array) 214 | { 215 | var _size = array_length(_array); 216 | if (_size == 0) 217 | { 218 | return ""; 219 | } 220 | var _str = ""; 221 | for (var i = 0; i < _size - 1; ++i) 222 | { 223 | _str += string(_array[i]) + _string; 224 | } 225 | _str += string(_array[i]); 226 | return _str; 227 | } 228 | 229 | /// @func CE_StringJoinList(_string, _list) 230 | /// @desc Joins values in the list putting the string between each two 231 | /// consecutive values. 232 | /// @param {string} _string The string to put between two consecutive values. 233 | /// @param {ds_list} _list The the list of values that you want to join. 234 | /// @return {string} The resulting string. 235 | /// @example 236 | /// This will show a message saying "Numbers: 1, 2, 3, 4". 237 | /// ```gml 238 | /// var _numbers = ds_list_create(); 239 | /// ds_list_add(_numbers, 1, 2, 3, 4); 240 | /// show_message("Numbers: " + CE_StringJoinList(", ", _numbers)); 241 | /// ``` 242 | function CE_StringJoinList(_string, _list) 243 | { 244 | var _size = ds_list_size(_list); 245 | if (_size == 0) 246 | { 247 | return ""; 248 | } 249 | var _str = ""; 250 | for (var i = 0; i < _size - 1; ++i) 251 | { 252 | _str += string(_list[| i]) + _string; 253 | } 254 | _str += string(_list[| i]); 255 | return _str; 256 | } 257 | 258 | /// @func CE_StringRemovePart(_string, _startStr, _endStr) 259 | /// @desc Removes part beginning with `_startStr` and ending with `_endStr` 260 | /// from the string. 261 | /// @param {string} _string The string to remove the part from. 262 | /// @param {string} _startStr The start of the part to remove. 263 | /// @param {string} _endStr The end of the part to remove. 264 | /// @return {string} The string with the given part removed. 265 | function CE_StringRemovePart(_string, _startStr, _endStr) 266 | { 267 | var _start = string_pos(_startStr, _string); 268 | var _end = string_pos(_endStr, _string); 269 | return string_delete(_string, _start, _end - _start + string_length(_endStr)); 270 | } 271 | 272 | /// @func CE_StringStartsWith(_string, _substring) 273 | /// @param {string} _string The string. 274 | /// @param {string} _substring The expected start of the string. 275 | /// @return {bool} Returns `true` if the string starts with the substring. 276 | function CE_StringStartsWith(_string, _substring) 277 | { 278 | return (string_copy(_string, 1, string_length(_substring)) == _substring); 279 | } 280 | 281 | /// @func CE_StringTrim(_string) 282 | /// @desc Removes leading and trailing whitespace from the string. 283 | /// @param {string} _string The string to remove the whitespace from. 284 | /// @return {string} The resulting string. 285 | function CE_StringTrim(_string) 286 | { 287 | gml_pragma("forceinline"); 288 | return CE_StringTrimLeft(CE_StringTrimRight(_string)); 289 | } 290 | 291 | /// @func CE_StringTrimLeft(_string) 292 | /// @desc Removes leading whitespace from the string. 293 | /// @param {string} _string The string to remove the whitespace from. 294 | /// @return {string} The resulting string. 295 | function CE_StringTrimLeft(_string) 296 | { 297 | var ch; 298 | var i = 0; 299 | do 300 | { 301 | ch = string_char_at(_string, 1 + (i++)); 302 | } 303 | until (ch != " " && ch != "\t" && ch != "\n"); 304 | return string_delete(_string, 1, i - 1); 305 | } 306 | 307 | /// @func CE_StringTrimRight(_string) 308 | /// @desc Removes trailing whitespace from the string. 309 | /// @param {string} _string The string to remove the whitespace from. 310 | /// @return {string} The resulting string. 311 | function CE_StringTrimRight(_string) 312 | { 313 | var ch; 314 | var i = string_length(_string); 315 | do 316 | { 317 | ch = string_char_at(_string, i--); 318 | } 319 | until (ch != " " && ch != "\t" && ch != "\n"); 320 | _string = string_delete(_string, i + 2, string_length(_string) - i); 321 | return _string; 322 | } -------------------------------------------------------------------------------- /scripts/CE_StringUtils/CE_StringUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_StringUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_StructUtils/CE_StructUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_StructGet(_struct, _name[, _default]) 2 | /// @desc Retrieves structure's property value. 3 | /// @param {struct} _struct The structure. 4 | /// @param {string} _name The property name. 5 | /// @param {any} [_default] The value returned when the struct doesn't have 6 | /// such property. 7 | /// @return {any} The property value. 8 | function CE_StructGet(_struct, _name, _default=undefined) 9 | { 10 | gml_pragma("forceinline"); 11 | if (!variable_struct_exists(_struct, _name)) 12 | { 13 | return _default; 14 | } 15 | return variable_struct_get(_struct, _name); 16 | } 17 | 18 | /// @func CE_StructSet(_struct, _name, _value) 19 | /// @desc Sets structure's property value. 20 | /// @param {struct} _struct The structure. 21 | /// @param {string} _name The property name. 22 | /// @param {any} _value The value. 23 | /// @note This is equivalent to using `variable_struct_set`. 24 | function CE_StructSet(_struct, _name, _value) 25 | { 26 | gml_pragma("forceinline"); 27 | variable_struct_set(_struct, _name, _value); 28 | } 29 | 30 | /// @func CE_StructExtend(_target, ..._source) 31 | /// @desc Extends target structure with properties from source structure. 32 | /// @param {struct} _target The structure to add the properties to. 33 | /// @param {struct} _source The structure containing properties to add. 34 | /// @return {struct} Returns the target structure. 35 | function CE_StructExtend(_target) 36 | { 37 | gml_pragma("forceinline"); 38 | var s = 1; 39 | repeat (argument_count - 1) 40 | { 41 | var _source = argument[s++]; 42 | var _names = variable_struct_get_names(_source); 43 | var n = 0; 44 | repeat (array_length(_names)) 45 | { 46 | var _name = _names[n++]; 47 | _target[$ _name] = _source[$ _name]; 48 | } 49 | } 50 | return _target; 51 | } -------------------------------------------------------------------------------- /scripts/CE_StructUtils/CE_StructUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_StructUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_SurfaceUtils/CE_SurfaceUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_SurfaceBlur(_target, _work, _scale) 2 | /// @desc Blurs the target surface. 3 | /// @param {surface} _target The surface to be blurred. 4 | /// @param {surface/undefined} _work A working surface. Must have the same size 5 | /// as the target surface. If `undefined`, then a temporary surface is created. 6 | /// @param {real} _scale The scale of the blur kernel. 7 | function CE_SurfaceBlur(_target, _work, _scale) 8 | { 9 | var _width = surface_get_width(_target); 10 | var _height = surface_get_height(_target); 11 | var _isTemp = false; 12 | 13 | if (_work == undefined) 14 | { 15 | _work = surface_create(_width, _height); 16 | _isTemp = true; 17 | } 18 | 19 | static _shader = CE_ShGaussianBlur; 20 | static _uTexel = shader_get_uniform(_shader, "u_vTexel"); 21 | var _texelW = _scale / _width; 22 | var _texelH = _scale / _height; 23 | 24 | surface_set_target(_work); 25 | draw_clear_alpha(0, 0); 26 | shader_set(_shader); 27 | shader_set_uniform_f(_uTexel, _texelW, 0.0); 28 | draw_surface(_target, 0, 0); 29 | shader_reset(); 30 | surface_reset_target(); 31 | 32 | surface_set_target(_target); 33 | draw_clear_alpha(0, 0); 34 | shader_set(_shader); 35 | shader_set_uniform_f(_uTexel, 0.0, _texelH); 36 | draw_surface(_work, 0, 0); 37 | shader_reset(); 38 | surface_reset_target(); 39 | 40 | if (_isTemp) 41 | { 42 | surface_free(_work); 43 | } 44 | } 45 | 46 | /// @func CE_SurfaceCheck(_surface, _width, _height) 47 | /// @desc Checks whether the surface exists and if it has correct size. Broken 48 | /// surfaces are recreated. Surfaces of wrong size are resized. 49 | /// @param {surface} _surface The surface to check. 50 | /// @param {real} _width The desired width of the surface. 51 | /// @param {real} _height The desired height of the surface. 52 | /// @return {surface} The surface. 53 | function CE_SurfaceCheck(_surface, _width, _height) 54 | { 55 | _width = max(round(_width), 1); 56 | _height = max(round(_height), 1); 57 | 58 | if (!surface_exists(_surface)) 59 | { 60 | return surface_create(_width, _height); 61 | } 62 | 63 | if (surface_get_width(_surface) != _width 64 | || surface_get_height(_surface) != _height) 65 | { 66 | surface_resize(_surface, _width, _height); 67 | } 68 | 69 | return _surface; 70 | } 71 | 72 | /// @func CE_SurfaceClone(_surface) 73 | /// @desc Creates a copy of a surface. 74 | /// @param {real} _surface The surface to create a copy of. 75 | /// @return {surface} The created surface. 76 | function CE_SurfaceClone(_surface) 77 | { 78 | var _clone = surface_create( 79 | surface_get_width(_surface), 80 | surface_get_height(_surface)); 81 | surface_copy(_clone, 0, 0, _surface); 82 | return _clone; 83 | } 84 | 85 | /// @func CE_SurfaceCreateFromSprite(sprite, index) 86 | /// @desc Creates a surface from the sprite. 87 | /// @param {sprite} _sprite The sprite. 88 | /// @param {real} _index The sprite subimage index. 89 | /// @return {surface} The created surface. 90 | function CE_SurfaceCreateFromSprite(_sprite, _index) 91 | { 92 | var _surface = surface_create(sprite_get_width(_sprite), sprite_get_height(_sprite)); 93 | surface_set_target(_surface); 94 | draw_clear_alpha(0, 0); 95 | draw_sprite(_sprite, _index, 0, 0); 96 | surface_reset_target(); 97 | return _surface; 98 | } 99 | 100 | /// @func CE_SurfaceClearColor(_color, _alpha) 101 | /// @desc Clears color of the current render target without clearing its 102 | /// depth buffer. 103 | /// @param {uint} _color The color to clear the target with. 104 | /// @param {real} _alpha The alpha to clear the target with. 105 | function CE_SurfaceClearColor(_color, _alpha) 106 | { 107 | var _surface = surface_get_target(); 108 | gpu_push_state(); 109 | gpu_set_blendenable(true); 110 | gpu_set_blendmode_ext(bm_one, bm_zero); 111 | gpu_set_ztestenable(false); 112 | gpu_set_zwriteenable(false); 113 | shader_set(CE_ShClearColor); 114 | shader_set_uniform_f(shader_get_uniform(CE_ShClearColor, "u_vColor"), 115 | color_get_red(_color) / 255, 116 | color_get_green(_color) / 255, 117 | color_get_blue(_color) / 255, 118 | _alpha); 119 | draw_rectangle(0, 0, surface_get_width(_surface), surface_get_height(_surface), false); 120 | shader_reset(); 121 | gpu_pop_state(); 122 | } 123 | 124 | /// @func CE_SurfaceCopy(_source, _target) 125 | /// @desc Renders contents of one surface to another without blending (affected 126 | /// pixels in the target surface are completely overwritten with ones from the 127 | /// source surface). 128 | /// @param {surface} _source The surface to be rendered. 129 | /// @param {surface} _target The surface to render into. 130 | function CE_SurfaceCopy(_source, _target) 131 | { 132 | surface_set_target(_target); 133 | gpu_push_state(); 134 | gpu_set_blendenable(true); 135 | gpu_set_blendmode_ext(bm_one, bm_zero); 136 | gpu_set_ztestenable(false); 137 | gpu_set_zwriteenable(false); 138 | draw_surface(_source, 0, 0); 139 | gpu_pop_state(); 140 | surface_reset_target(); 141 | } -------------------------------------------------------------------------------- /scripts/CE_SurfaceUtils/CE_SurfaceUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Surface", 6 | "path": "folders/CoreExtension/Utils/Surface.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_SurfaceUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_TimeUtils/CE_TimeUtils.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_HoursToMilliseconds(_hours) 2 | /// @param {real} _hours Hours to be converted to milliseconds. 3 | /// @return {real} Hours converted to milliseconds. 4 | function CE_HoursToMilliseconds(_hours) 5 | { 6 | gml_pragma("forceinline"); 7 | return (_hours * 3600000.0); 8 | } 9 | 10 | /// @func CE_MinutesToMilliseconds(_minutes) 11 | /// @param {real} _minutes Minutes to be converted to milliseconds. 12 | /// @return {real} Minutes converted to milliseconds. 13 | function CE_MinutesToMilliseconds(_minutes) 14 | { 15 | gml_pragma("forceinline"); 16 | return (_minutes * 60000.0); 17 | } 18 | 19 | /// @func CE_SecondsToMilliseconds(_seconds) 20 | /// @param {real} _seconds Seconds to be converted to milliseconds. 21 | /// @return {real} Seconds converted to milliseconds. 22 | function CE_SecondsToMilliseconds(_seconds) 23 | { 24 | gml_pragma("forceinline"); 25 | return (_seconds * 1000.0); 26 | } 27 | 28 | /// @func CE_PerSecond(_value) 29 | /// @param {real} value The value to convert. 30 | /// @return {real} The converted value. 31 | /// @example 32 | /// This will make the calling instance move to the right by 32px per second, 33 | /// independently on the framerate. 34 | /// ```gml 35 | /// x += CE_PerSecond(32); 36 | /// ``` 37 | function CE_PerSecond(_value) 38 | { 39 | gml_pragma("forceinline"); 40 | return (_value * delta_time * 0.000001); 41 | } -------------------------------------------------------------------------------- /scripts/CE_TimeUtils/CE_TimeUtils.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Utils", 6 | "path": "folders/CoreExtension/Utils.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_TimeUtils", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Timer/CE_Timer.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_Timer() 2 | function CE_Timer() constructor 3 | { 4 | /// @var {struct[]} 5 | /// @private 6 | TimeoutArray = []; 7 | 8 | /// @func AddTimeout(_callback, _duration) 9 | /// @param {func} _callback A function to execute after the timeout. 10 | /// @param {uint} _duration Timeout duration in seconds. 11 | /// @return {CE_TimerTimeout} The added timeout. 12 | static AddTimeout = function (_callback, _duration) { 13 | gml_pragma("forceinline"); 14 | var _timeout = new CE_TimerTimeout(_callback, _duration); 15 | array_push(TimeoutArray, _timeout); 16 | return _timeout; 17 | }; 18 | 19 | /// @func Update() 20 | /// @return {CE_Timer} Returns self. 21 | static Update = function () { 22 | var i = 0; 23 | repeat (array_length(TimeoutArray)) 24 | { 25 | var _timeout = TimeoutArray[i]; 26 | if (_timeout.Canceled) 27 | { 28 | array_delete(TimeoutArray, i, 1); 29 | } 30 | else if (current_time >= _timeout.Start + _timeout.Duration) 31 | { 32 | _timeout.Callback(); 33 | array_delete(TimeoutArray, i, 1); 34 | } 35 | else 36 | { 37 | ++i; 38 | } 39 | } 40 | return self; 41 | }; 42 | } -------------------------------------------------------------------------------- /scripts/CE_Timer/CE_Timer.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Timer", 6 | "path": "folders/CoreExtension/Timer.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Timer", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_TimerTimeout/CE_TimerTimeout.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_TimerTimeout(_callback, _duration) 2 | /// @param {func} _callback 3 | /// @param {uint} _duration 4 | function CE_TimerTimeout(_callback, _duration) constructor 5 | { 6 | /// @var {func} 7 | /// @readonly 8 | Callback = _callback; 9 | 10 | /// @var {uint} 11 | /// @readonly 12 | Start = current_time; 13 | 14 | /// @var {uint} 15 | /// @readonly 16 | Duration = _duration; 17 | 18 | /// @var {bool} 19 | /// @readonly 20 | Canceled = false; 21 | 22 | /// @func Cancel() 23 | /// @desc Cancels the timeout. 24 | /// @return {CE_TimerTimeout} Return self. 25 | static Cancel = function () { 26 | gml_pragma("forceinline"); 27 | Canceled = true; 28 | return self; 29 | }; 30 | } -------------------------------------------------------------------------------- /scripts/CE_TimerTimeout/CE_TimerTimeout.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Timer", 6 | "path": "folders/CoreExtension/Timer.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_TimerTimeout", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Tween/CE_Tween.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Tween", 6 | "path": "folders/CoreExtension/Tween.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Tween", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_UUID/CE_UUID.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_GenerateUUID([_bytes]) 2 | /// @desc Generates a version 4 UUID. 3 | /// @param {array} [_bytes] An array that will be used for storing random bytes. 4 | /// Its size must be 16! If the array is not provided, a new one is created. 5 | /// Providing the array can Save some extra ms when sequentially generating 6 | /// large numbers of UUIDs. 7 | /// @return {string} The generated UUID. 8 | /// @note Depends on the `_to_hex` functions. 9 | /// @source https://www.cryptosys.net/pki/uuid-rfc4122.html 10 | function CE_GenerateUUID() 11 | { 12 | var _bytes = (argument_count > 0) ? argument[0] : array_create(16, 0); 13 | 14 | var _seed = random_get_seed(); 15 | randomize(); 16 | for (var i = 0; i < 16; ++i) 17 | { 18 | _bytes[@ i] = irandom(255); 19 | } 20 | random_set_seed(_seed); 21 | 22 | _bytes[@ 6] = (0x40 | (_bytes[6] & 0xF)); 23 | _bytes[@ 8] = (0x80 | (_bytes[8] & 0x3F)); 24 | 25 | var _str = CE_ByteArrayToHex(_bytes); 26 | 27 | return string_copy(_str, 1, 8) + "-" 28 | + string_copy(_str, 9, 4) + "-" 29 | + string_copy(_str, 13, 4) + "-" 30 | + string_copy(_str, 17, 4) + "-" 31 | + string_copy(_str, 21, 12); 32 | } -------------------------------------------------------------------------------- /scripts/CE_UUID/CE_UUID.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Core", 6 | "path": "folders/CoreExtension/Core.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_UUID", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Vec2/CE_Vec2.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Math", 6 | "path": "folders/CoreExtension/Math.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Vec2", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Vec3/CE_Vec3.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Math", 6 | "path": "folders/CoreExtension/Math.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Vec3", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_Vec4/CE_Vec4.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "Math", 6 | "path": "folders/CoreExtension/Math.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_Vec4", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_XMLDocument/CE_XMLDocument.gml: -------------------------------------------------------------------------------- 1 | /// @enum An enumeration of XML characters. 2 | /// @private 3 | enum CE_EXMLChar 4 | { 5 | Null = 0, 6 | LF = 10, 7 | CR = 13, 8 | Space = 32, 9 | EM = 33, // ! 10 | DQ = 34, // " 11 | SQ = 39, // ' 12 | Slash = 47, 13 | LT = 60, // < 14 | Equal = 61, // = 15 | GT = 62, // > 16 | QM = 63, // ? 17 | }; 18 | 19 | /// @func CE_XMLDocument() 20 | /// @extends CE_Class 21 | /// @desc An XML document. 22 | function CE_XMLDocument() 23 | : CE_Class() constructor 24 | { 25 | CE_CLASS_GENERATED_BODY; 26 | 27 | static Super_Class = { 28 | Destroy: Destroy, 29 | }; 30 | 31 | /// @var {string/undefined} Path to the XML file. It is undefined until the 32 | /// document is saved or loaded. 33 | /// @see CE_XMLDocument.Save 34 | /// @see CE_XMLDocument.Load 35 | /// @readonly 36 | Path = undefined; 37 | 38 | /// @var {CE_XMLElement/undefined} The root element of the XML document. 39 | Root = undefined; 40 | 41 | /// @func Load(_path) 42 | /// @desc Loads an XML document from a file. 43 | /// @param {string} _path The path to the file to load. 44 | /// @return {CE_XMLDocument} Returns `self`. 45 | /// @throws {CE_IOError} If the file could not be loaded. 46 | /// @example 47 | /// Example "conf.xml" containing window width and height: 48 | /// ```xml 49 | /// 50 | /// 51 | /// 1920 52 | /// 1080 53 | /// 54 | /// 55 | /// ``` 56 | /// Code that loads window width and height from the conf: 57 | /// ```gml 58 | /// try 59 | /// { 60 | /// var _conf = new CE_XMLDocument().Load("conf.xml"); 61 | /// var _window = _conf.Root.Find({ Name: "window" }); 62 | /// var _windowWidth = _window.Find({ Name: "width" }).Value; 63 | /// var _windowHeight = _window.Find({ Name: "height" }).Value; 64 | /// window_set_size(_windowWidth, _windowHeight); 65 | /// _conf.Destroy(); 66 | /// } 67 | /// catch (_e) 68 | /// { 69 | /// // TODO: Handle exceptions... 70 | /// } 71 | /// ``` 72 | static Load = function (_path) { 73 | var _file = file_bin_open(_path, 0); 74 | 75 | if (_file == -1) 76 | { 77 | throw new CE_IOException("Could not open file " + _path + "!"); 78 | } 79 | 80 | var _filePos = 0; 81 | var _fileSize = file_bin_size(_file); 82 | var _byte = CE_EXMLChar.Space; 83 | var _lastByte; 84 | var _isSeparator = true; 85 | var _token = ""; 86 | var _isString = false; 87 | var _attributeName = ""; 88 | var _root = undefined; 89 | var _element = undefined; 90 | var _lastElement = undefined; 91 | var _parentElement = undefined; 92 | var _isClosing = false; 93 | var _isComment = false; 94 | 95 | do 96 | { 97 | // Read byte from file 98 | _lastByte = _byte; 99 | _byte = file_bin_read_byte(_file); 100 | 101 | // Process byte 102 | _isSeparator = true; 103 | 104 | switch (_byte) 105 | { 106 | // Start of new element 107 | case CE_EXMLChar.LT: 108 | if (_element != undefined) 109 | { 110 | if (_root != undefined) 111 | { 112 | _root.Destroy(); 113 | } 114 | throw new CE_Exception("Unexpected symbol '<' at " + string(_filePos) + "!"); 115 | } 116 | 117 | // Set element value 118 | while (string_byte_at(_token, 1) == 32) 119 | { 120 | _token = string_delete(_token, 1, 1); 121 | } 122 | 123 | if (_token != "" 124 | && _parentElement != undefined 125 | && _parentElement.GetChildCount() == 0) 126 | { 127 | _parentElement.Value = CE_XMLValueFromString(_token); 128 | } 129 | 130 | _element = new CE_XMLElement(); 131 | break; 132 | 133 | // End of element 134 | case CE_EXMLChar.GT: 135 | if (_element == undefined) 136 | { 137 | if (_root != undefined) 138 | { 139 | _root.Destroy(); 140 | } 141 | throw new CE_Exception("Unexpected symbol '>' at " + string(_filePos) + "!"); 142 | } 143 | 144 | _lastElement = _element; 145 | 146 | if (_root == undefined 147 | && !_isComment) 148 | { 149 | _root = _element; 150 | } 151 | 152 | if (_isComment) 153 | { 154 | _lastElement = undefined; 155 | _element.Destroy(); 156 | _isComment = false; 157 | } 158 | else if (_lastByte == CE_EXMLChar.Slash) 159 | { 160 | // Self-closing element 161 | if (_parentElement != undefined) 162 | { 163 | _parentElement.AddChild(_element); 164 | } 165 | } 166 | else if (_isClosing) 167 | { 168 | // If the element is not self-closing and it does not 169 | // have a value defined, then set its value to an empty string. 170 | if (_parentElement.Value == undefined 171 | && _parentElement.GetChildCount() == 0) 172 | { 173 | _parentElement.Value = ""; 174 | } 175 | _parentElement = _parentElement.Parent; 176 | _lastElement = undefined; 177 | _element.Destroy(); 178 | _isClosing = false; 179 | } 180 | else 181 | { 182 | if (_parentElement != undefined) 183 | { 184 | _parentElement.AddChild(_element); 185 | } 186 | _parentElement = _element; 187 | } 188 | _element = undefined; 189 | break; 190 | 191 | // Closing element 192 | case CE_EXMLChar.Slash: 193 | if (_isString || _element == undefined) 194 | { 195 | _isSeparator = false; 196 | } 197 | else if (_lastByte == CE_EXMLChar.LT) 198 | { 199 | _isClosing = true; 200 | } 201 | break; 202 | 203 | // Attribute 204 | case CE_EXMLChar.Equal: 205 | if (!_isString) 206 | { 207 | if (_token != "") 208 | { 209 | _attributeName = _token; 210 | } 211 | } 212 | else 213 | { 214 | _isSeparator = false; 215 | } 216 | break; 217 | 218 | // Start/end of string 219 | case CE_EXMLChar.SQ: 220 | case CE_EXMLChar.DQ: 221 | if (_isString == _byte) 222 | { 223 | _isString = false; 224 | // Store attribute 225 | if (_attributeName != "") 226 | { 227 | if (_element != undefined) 228 | { 229 | _element.SetAttribute(_attributeName, CE_XMLValueFromString(_token)); 230 | } 231 | _attributeName = ""; 232 | } 233 | } 234 | else if (!_isString) 235 | { 236 | _isString = _byte; 237 | } 238 | break; 239 | 240 | // Treat as comments 241 | case CE_EXMLChar.QM: 242 | case CE_EXMLChar.EM: 243 | if (_lastByte == CE_EXMLChar.LT) 244 | { 245 | _isComment = true; 246 | } 247 | else 248 | { 249 | _isSeparator = false; 250 | } 251 | break; 252 | 253 | default: 254 | // Whitespace 255 | if (!_isString && _element != undefined 256 | && ((_byte > CE_EXMLChar.Null && _byte <= CE_EXMLChar.CR) 257 | || _byte == CE_EXMLChar.Space)) 258 | { 259 | // ... 260 | } 261 | else 262 | { 263 | _isSeparator = false; 264 | } 265 | break; 266 | } 267 | 268 | // Process tokens 269 | if (_isSeparator) 270 | { 271 | // End of token 272 | if (_token != "") 273 | { 274 | // Set element name 275 | if (_element != undefined && _element.Name == "") 276 | { 277 | _element.Name = _token; 278 | } 279 | else if (_lastElement != undefined && _lastElement.Name == "") 280 | { 281 | _lastElement.Name = _token; 282 | } 283 | _token = ""; 284 | } 285 | } 286 | else 287 | { 288 | // Build token 289 | if (_byte > CE_EXMLChar.Null && _byte <= CE_EXMLChar.CR) 290 | { 291 | _byte = CE_EXMLChar.Space; // Replace new lines, tabs, etc. with spaces 292 | } 293 | _token += chr(_byte); 294 | } 295 | } 296 | until (++_filePos == _fileSize); 297 | 298 | file_bin_close(_file); 299 | 300 | Root = _root; 301 | Path = _path; 302 | 303 | return self; 304 | }; 305 | 306 | /// @func ToString() 307 | /// @desc Writes the XML document into a string. 308 | /// @return {string} The resulting string. 309 | static ToString = function () { 310 | gml_pragma("forceinline"); 311 | return Root.ToString(); 312 | }; 313 | 314 | /// @func Save([_path]) 315 | /// @desc Saves the XML document into a file. 316 | /// @param {string} [_path] The file path. Defaults to {@link CE_XMLDocument.Path}. 317 | /// @return {CE_XMLDocument} Returns `self`. 318 | /// @throws {CE_ArgumentException} If the save path is not defined. 319 | /// @throws {CE_IOException} If writing to the file fails. 320 | /// @example 321 | /// ```gml 322 | /// try 323 | /// { 324 | /// var _conf = new CE_XMLDocument(); 325 | /// _conf.Root = new CE_XMLElement("conf", [ 326 | /// new CE_XMLElement("window", [ 327 | /// new CE_XMLElement("width", window_get_width()), 328 | /// new CE_XMLElement("height", window_get_height()) 329 | /// ]) 330 | /// ]); 331 | /// _conf.Save("conf.xml"); 332 | /// _conf.Destroy(); 333 | /// } 334 | /// catch (_e) 335 | /// { 336 | /// // TODO: Handle exception... 337 | /// } 338 | /// ``` 339 | /// The code above could output an XML file "conf.xml" looking like this: 340 | /// ```xml 341 | /// 342 | /// 343 | /// 1920 344 | /// 1080 345 | /// 346 | /// 347 | /// ``` 348 | static Save = function (_path=Path) { 349 | if (_path == undefined) 350 | { 351 | throw new CE_ArgumentException("_path"); 352 | } 353 | Path = _path; 354 | 355 | var _file = file_text_open_write(_path); 356 | if (_file == -1) 357 | { 358 | throw new CE_IOException(); 359 | } 360 | file_text_write_string(_file, ToString()); 361 | file_text_writeln(_file); 362 | file_text_close(_file); 363 | 364 | return self; 365 | }; 366 | 367 | static Destroy = function () { 368 | method(self, Super_Class.Destroy)(); 369 | if (Root != undefined) 370 | { 371 | Root.Destroy(); 372 | Root = undefined; 373 | } 374 | }; 375 | } -------------------------------------------------------------------------------- /scripts/CE_XMLDocument/CE_XMLDocument.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "XML", 6 | "path": "folders/CoreExtension/XML.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_XMLDocument", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_XMLElement/CE_XMLElement.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "XML", 6 | "path": "folders/CoreExtension/XML.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_XMLElement", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /scripts/CE_XMLValue/CE_XMLValue.gml: -------------------------------------------------------------------------------- 1 | /// @func CE_XMLValueFromString(_string) 2 | /// @desc Parses value from the string. 3 | /// @param {string} _string The string to parse. 4 | /// @return {real/string} Real value or a string, where XML character entities 5 | /// are replaced with their original form. 6 | function CE_XMLValueFromString(_string) 7 | { 8 | // Clear whitespace, replace character entities 9 | while (string_byte_at(_string, 1) == 32) 10 | { 11 | _string = string_delete(_string, 1, 1); 12 | } 13 | 14 | _string = string_replace_all(_string, "<", "<"); 15 | _string = string_replace_all(_string, ">", ">"); 16 | _string = string_replace_all(_string, """, "\""); 17 | _string = string_replace_all(_string, "'", "'"); 18 | _string = string_replace_all(_string, "&", "&"); 19 | 20 | // Parse real 21 | var _real = CE_RealParse(_string); 22 | 23 | if (is_nan(_real)) 24 | { 25 | return _string; 26 | } 27 | 28 | return _real; 29 | } 30 | 31 | /// @func CE_XMLValueToString(_value) 32 | /// @desc Turns a value into an XML-safe string. 33 | /// @param {any} _value The value to be turned into a string. 34 | /// @return {string} The resulting string. 35 | function CE_XMLValueToString(_value) 36 | { 37 | if (is_real(_value)) 38 | { 39 | var _dec = 16; // Maximum decimal places 40 | var _string = string_format(_value, -1, _dec); 41 | var _stringLength = string_length(_string); 42 | 43 | do 44 | { 45 | _string = string_format(_value, -1, --_dec); 46 | if (string_byte_at(_string, --_stringLength) != 48) 47 | { 48 | break; 49 | } 50 | } 51 | until (_dec == 0); 52 | 53 | return _string; 54 | } 55 | 56 | if (is_string(_value)) 57 | { 58 | _value = string_replace_all(_value, "&", "&"); 59 | _value = string_replace_all(_value, "<", "<"); 60 | _value = string_replace_all(_value, ">", ">"); 61 | _value = string_replace_all(_value, "\"", """); 62 | _value = string_replace_all(_value, "'", "'"); 63 | } 64 | 65 | return string(_value); 66 | } -------------------------------------------------------------------------------- /scripts/CE_XMLValue/CE_XMLValue.yy: -------------------------------------------------------------------------------- 1 | { 2 | "isDnD": false, 3 | "isCompatibility": false, 4 | "parent": { 5 | "name": "XML", 6 | "path": "folders/CoreExtension/XML.yy", 7 | }, 8 | "resourceVersion": "1.0", 9 | "name": "CE_XMLValue", 10 | "tags": [], 11 | "resourceType": "GMScript", 12 | } -------------------------------------------------------------------------------- /shaders/CE_ShClearColor/CE_ShClearColor.fsh: -------------------------------------------------------------------------------- 1 | uniform vec4 u_vColor; 2 | 3 | void main() 4 | { 5 | gl_FragColor = u_vColor; 6 | } -------------------------------------------------------------------------------- /shaders/CE_ShClearColor/CE_ShClearColor.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 in_Position; 2 | 3 | void main() 4 | { 5 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * in_Position; 6 | } -------------------------------------------------------------------------------- /shaders/CE_ShClearColor/CE_ShClearColor.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Surface", 5 | "path": "folders/CoreExtension/Utils/Surface.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "CE_ShClearColor", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /shaders/CE_ShGaussianBlur/CE_ShGaussianBlur.fsh: -------------------------------------------------------------------------------- 1 | varying vec2 v_vTexCoord; 2 | 3 | uniform vec2 u_vTexel; 4 | 5 | #pragma include("GaussianBlur.xsh", "glsl") 6 | /// @param image The image to blur. 7 | /// @param uv The current texture coordinates. 8 | /// @param texel `(1 / imageWidth, 1 / imageHeight) * direction`, where `direction` 9 | /// is `(1.0, 0.0)` for horizontal or `(0.0, 1.0)` for vertical blur. 10 | /// @source http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/ 11 | vec4 xGaussianBlur(sampler2D image, vec2 uv, vec2 texel) 12 | { 13 | vec4 color = texture2D(image, uv) * 0.2270270270; 14 | vec2 offset1 = texel * 1.3846153846; 15 | vec2 offset2 = texel * 3.2307692308; 16 | color += texture2D(image, uv + offset1) * 0.3162162162; 17 | color += texture2D(image, uv - offset1) * 0.3162162162; 18 | color += texture2D(image, uv + offset2) * 0.0702702703; 19 | color += texture2D(image, uv - offset2) * 0.0702702703; 20 | return color; 21 | } 22 | // include("GaussianBlur.xsh") 23 | 24 | void main() 25 | { 26 | gl_FragColor = xGaussianBlur(gm_BaseTexture, v_vTexCoord, u_vTexel); 27 | } -------------------------------------------------------------------------------- /shaders/CE_ShGaussianBlur/CE_ShGaussianBlur.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 in_Position; 2 | attribute vec2 in_TextureCoord; 3 | 4 | varying vec2 v_vTexCoord; 5 | 6 | void main() 7 | { 8 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * in_Position; 9 | v_vTexCoord = in_TextureCoord; 10 | } -------------------------------------------------------------------------------- /shaders/CE_ShGaussianBlur/CE_ShGaussianBlur.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Surface", 5 | "path": "folders/CoreExtension/Utils/Surface.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "CE_ShGaussianBlur", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /shaders/CE_ShNavGrid/CE_ShNavGrid.fsh: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | gl_FragColor = vec4(vec3(1.0), 0.5); 4 | } -------------------------------------------------------------------------------- /shaders/CE_ShNavGrid/CE_ShNavGrid.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 in_Position; 2 | 3 | void main() 4 | { 5 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * in_Position; 6 | } -------------------------------------------------------------------------------- /shaders/CE_ShNavGrid/CE_ShNavGrid.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "NavGrid", 5 | "path": "folders/CoreExtension/NavGrid.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "CE_ShNavGrid", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /sprites/CE_SprRectangle/40c214dd-f3dd-4577-a620-273b2694354f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueburncz/CoreExtension/bc1eb8216f407a28bb22ea39fa5b7ce974cec339/sprites/CE_SprRectangle/40c214dd-f3dd-4577-a620-273b2694354f.png -------------------------------------------------------------------------------- /sprites/CE_SprRectangle/CE_SprRectangle.yy: -------------------------------------------------------------------------------- 1 | { 2 | "bboxMode": 0, 3 | "collisionKind": 1, 4 | "type": 0, 5 | "origin": 0, 6 | "preMultiplyAlpha": false, 7 | "edgeFiltering": false, 8 | "collisionTolerance": 0, 9 | "swfPrecision": 2.525, 10 | "bbox_left": 0, 11 | "bbox_right": 0, 12 | "bbox_top": 0, 13 | "bbox_bottom": 0, 14 | "HTile": false, 15 | "VTile": false, 16 | "For3D": false, 17 | "width": 1, 18 | "height": 1, 19 | "textureGroupId": { 20 | "name": "Default", 21 | "path": "texturegroups/Default", 22 | }, 23 | "swatchColours": null, 24 | "gridX": 0, 25 | "gridY": 0, 26 | "frames": [ 27 | {"compositeImage":{"FrameId":{"name":"40c214dd-f3dd-4577-a620-273b2694354f","path":"sprites/CE_SprRectangle/CE_SprRectangle.yy",},"LayerId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMSpriteBitmap",},"images":[ 28 | {"FrameId":{"name":"40c214dd-f3dd-4577-a620-273b2694354f","path":"sprites/CE_SprRectangle/CE_SprRectangle.yy",},"LayerId":{"name":"a88aa6ab-c8f0-4edf-ab96-41afa065b2bc","path":"sprites/CE_SprRectangle/CE_SprRectangle.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMSpriteBitmap",}, 29 | ],"parent":{"name":"CE_SprRectangle","path":"sprites/CE_SprRectangle/CE_SprRectangle.yy",},"resourceVersion":"1.0","name":"40c214dd-f3dd-4577-a620-273b2694354f","tags":[],"resourceType":"GMSpriteFrame",}, 30 | ], 31 | "sequence": { 32 | "spriteId": {"name":"CE_SprRectangle","path":"sprites/CE_SprRectangle/CE_SprRectangle.yy",}, 33 | "timeUnits": 1, 34 | "playback": 1, 35 | "playbackSpeed": 30.0, 36 | "playbackSpeedType": 0, 37 | "autoRecord": true, 38 | "volume": 1.0, 39 | "length": 1.0, 40 | "events": {"Keyframes":[],"resourceVersion":"1.0","resourceType":"KeyframeStore",}, 41 | "moments": {"Keyframes":[],"resourceVersion":"1.0","resourceType":"KeyframeStore",}, 42 | "tracks": [ 43 | {"name":"frames","spriteId":null,"keyframes":{"Keyframes":[ 44 | {"id":"85548687-44cd-4925-b4aa-eb4868e7c44d","Key":0.0,"Length":1.0,"Stretch":false,"Disabled":false,"IsCreationKey":false,"Channels":{"0":{"Id":{"name":"40c214dd-f3dd-4577-a620-273b2694354f","path":"sprites/CE_SprRectangle/CE_SprRectangle.yy",},"resourceVersion":"1.0","resourceType":"SpriteFrameKeyframe",},},"resourceVersion":"1.0","resourceType":"Keyframe",}, 45 | ],"resourceVersion":"1.0","resourceType":"KeyframeStore",},"trackColour":0,"inheritsTrackColour":true,"builtinName":0,"traits":0,"interpolation":1,"tracks":[],"events":[],"isCreationTrack":false,"resourceVersion":"1.0","tags":[],"resourceType":"GMSpriteFramesTrack","modifiers":[],}, 46 | ], 47 | "visibleRange": null, 48 | "lockOrigin": false, 49 | "showBackdrop": true, 50 | "showBackdropImage": false, 51 | "backdropImagePath": "", 52 | "backdropImageOpacity": 0.5, 53 | "backdropWidth": 1366, 54 | "backdropHeight": 768, 55 | "backdropXOffset": 0.0, 56 | "backdropYOffset": 0.0, 57 | "xorigin": 0, 58 | "yorigin": 0, 59 | "eventToFunction": {}, 60 | "eventStubScript": null, 61 | "parent": {"name":"CE_SprRectangle","path":"sprites/CE_SprRectangle/CE_SprRectangle.yy",}, 62 | "resourceVersion": "1.3", 63 | "name": "CE_SprRectangle", 64 | "tags": [], 65 | "resourceType": "GMSequence", 66 | }, 67 | "layers": [ 68 | {"visible":true,"isLocked":false,"blendMode":0,"opacity":100.0,"displayName":"default","resourceVersion":"1.0","name":"a88aa6ab-c8f0-4edf-ab96-41afa065b2bc","tags":[],"resourceType":"GMImageLayer",}, 69 | ], 70 | "nineSlice": null, 71 | "parent": { 72 | "name": "Draw", 73 | "path": "folders/CoreExtension/Utils/Draw.yy", 74 | }, 75 | "resourceVersion": "1.0", 76 | "name": "CE_SprRectangle", 77 | "tags": [], 78 | "resourceType": "GMSprite", 79 | } -------------------------------------------------------------------------------- /sprites/CE_SprRectangle/layers/40c214dd-f3dd-4577-a620-273b2694354f/a88aa6ab-c8f0-4edf-ab96-41afa065b2bc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueburncz/CoreExtension/bc1eb8216f407a28bb22ea39fa5b7ce974cec339/sprites/CE_SprRectangle/layers/40c214dd-f3dd-4577-a620-273b2694354f/a88aa6ab-c8f0-4edf-ab96-41afa065b2bc.png --------------------------------------------------------------------------------