├── .github └── workflows │ ├── build.yml │ └── release.yml ├── LICENSE ├── README.md ├── SadMac.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcshareddata │ └── xcschemes │ │ └── SadMac.xcscheme └── xcuserdata │ └── stefan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── SadMac ├── Info.plist ├── SadMac.png ├── SadMacScene.h ├── SadMacScene.m ├── SadMacView.h └── SadMacView.m /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ci] 6 | 7 | jobs: 8 | build: 9 | runs-on: macos-10.15 10 | timeout-minutes: 30 11 | steps: 12 | - name: Checkout Project 13 | uses: actions/checkout@v2 14 | - name: Find Scheme of Default Project 15 | run: echo "::set-env name=SCHEME::$(xcodebuild -list -json | jq -r '.project.schemes[0]')" 16 | - name: Build 17 | run: xcodebuild -scheme "$SCHEME" CODE_SIGN_IDENTITY=- 18 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Release 3 | 4 | on: 5 | push: 6 | tags: [ v* ] 7 | 8 | jobs: 9 | build: 10 | runs-on: macos-10.15 11 | timeout-minutes: 10 12 | steps: 13 | - name: Checkout Project 14 | uses: actions/checkout@v2 15 | 16 | - name: Find Scheme of Default Project 17 | run: echo "::set-env name=SCHEME::$(xcodebuild -list -json | jq -r '.project.schemes[0]')" 18 | 19 | - name: Set environment variables from project settings 20 | run: | 21 | function set-env-from-proj { 22 | echo "::set-env name=$1::$(xcodebuild -scheme "$SCHEME" -showBuildSettings | grep " $1 " | sed "s/[ ]*$1 = //")" 23 | } 24 | set-env-from-proj FULL_PRODUCT_NAME 25 | set-env-from-proj INSTALL_PATH 26 | set-env-from-proj PRODUCT_BUNDLE_IDENTIFIER 27 | set-env-from-proj PRODUCT_MODULE_NAME 28 | set-env-from-proj PRODUCT_NAME 29 | set-env-from-proj PROJECT_NAME 30 | 31 | - name: Get the Marketing Version 32 | run: echo "::set-env name=MARKETING_VERSION::$(agvtool what-marketing-version -terse1)" 33 | 34 | - name: Test Build (Local Signing) 35 | run: xcodebuild -scheme "$SCHEME" CODE_SIGN_IDENTITY=- 36 | 37 | - name: Import signing certificate into keychain 38 | run: | 39 | KEYCHAIN_FILE=default.keychain 40 | KEYCHAIN_PASSWORD=myvoiceismypassport 41 | security create-keychain -p $KEYCHAIN_PASSWORD $KEYCHAIN_FILE 42 | security default-keychain -s $KEYCHAIN_FILE 43 | security unlock-keychain -p $KEYCHAIN_PASSWORD $KEYCHAIN_FILE 44 | security import <(echo $SIGNING_CERTIFICATE_P12_DATA | base64 --decode) \ 45 | -f pkcs12 \ 46 | -k $KEYCHAIN_FILE \ 47 | -P $SIGNING_CERTIFICATE_PASSWORD \ 48 | -T /usr/bin/codesign 49 | security set-key-partition-list -S apple-tool:,apple: -s -k $KEYCHAIN_PASSWORD $KEYCHAIN_FILE 50 | env: 51 | SIGNING_CERTIFICATE_P12_DATA: ${{ secrets.SIGNING_CERTIFICATE_P12_DATA }} 52 | SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.SIGNING_CERTIFICATE_PASSWORD }} 53 | 54 | - name: Build (Signed) & Install 55 | run: xcodebuild -scheme "$SCHEME" install DSTROOT=build/root 56 | 57 | - name: Package for Notarization 58 | run: ditto -V -c -k --keepParent "build/root/$INSTALL_PATH/$FULL_PRODUCT_NAME" build/$PRODUCT_MODULE_NAME.zip 59 | 60 | - name: Notarize 61 | run: npx notarize-cli --file "build/$PRODUCT_MODULE_NAME.zip" --no-staple 62 | env: 63 | NOTARIZE_USERNAME: ${{ secrets.NOTARIZE_USERNAME }} 64 | NOTARIZE_PASSWORD: ${{ secrets.NOTARIZE_PASSWORD }} 65 | 66 | - name: Staple 67 | run: xcrun stapler staple "build/root/$INSTALL_PATH/$FULL_PRODUCT_NAME" 68 | 69 | - name: Package for Distribution 70 | run: ditto -V -c -k --keepParent "build/root/$INSTALL_PATH/$FULL_PRODUCT_NAME" "build/$PRODUCT_MODULE_NAME-$MARKETING_VERSION.zip" 71 | 72 | - name: Release app 73 | uses: softprops/action-gh-release@v1 74 | with: 75 | files: build/${{ env.PRODUCT_MODULE_NAME }}-${{ env.MARKETING_VERSION }}.zip 76 | env: 77 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 78 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License, version 2.0 2 | 3 | 1. Definitions 4 | 5 | 1.1. "Contributor" 6 | 7 | means each individual or legal entity that creates, contributes to the 8 | creation of, or owns Covered Software. 9 | 10 | 1.2. "Contributor Version" 11 | 12 | means the combination of the Contributions of others (if any) used by a 13 | Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | 17 | means Covered Software of a particular Contributor. 18 | 19 | 1.4. "Covered Software" 20 | 21 | means Source Code Form to which the initial Contributor has attached the 22 | notice in Exhibit A, the Executable Form of such Source Code Form, and 23 | Modifications of such Source Code Form, in each case including portions 24 | thereof. 25 | 26 | 1.5. "Incompatible With Secondary Licenses" 27 | means 28 | 29 | a. that the initial Contributor has attached the notice described in 30 | Exhibit B to the Covered Software; or 31 | 32 | b. that the Covered Software was made available under the terms of 33 | version 1.1 or earlier of the License, but not also under the terms of 34 | a Secondary License. 35 | 36 | 1.6. "Executable Form" 37 | 38 | means any form of the work other than Source Code Form. 39 | 40 | 1.7. "Larger Work" 41 | 42 | means a work that combines Covered Software with other material, in a 43 | separate file or files, that is not Covered Software. 44 | 45 | 1.8. "License" 46 | 47 | means this document. 48 | 49 | 1.9. "Licensable" 50 | 51 | means having the right to grant, to the maximum extent possible, whether 52 | at the time of the initial grant or subsequently, any and all of the 53 | rights conveyed by this License. 54 | 55 | 1.10. "Modifications" 56 | 57 | means any of the following: 58 | 59 | a. any file in Source Code Form that results from an addition to, 60 | deletion from, or modification of the contents of Covered Software; or 61 | 62 | b. any new file in Source Code Form that contains any Covered Software. 63 | 64 | 1.11. "Patent Claims" of a Contributor 65 | 66 | means any patent claim(s), including without limitation, method, 67 | process, and apparatus claims, in any patent Licensable by such 68 | Contributor that would be infringed, but for the grant of the License, 69 | by the making, using, selling, offering for sale, having made, import, 70 | or transfer of either its Contributions or its Contributor Version. 71 | 72 | 1.12. "Secondary License" 73 | 74 | means either the GNU General Public License, Version 2.0, the GNU Lesser 75 | General Public License, Version 2.1, the GNU Affero General Public 76 | License, Version 3.0, or any later versions of those licenses. 77 | 78 | 1.13. "Source Code Form" 79 | 80 | means the form of the work preferred for making modifications. 81 | 82 | 1.14. "You" (or "Your") 83 | 84 | means an individual or a legal entity exercising rights under this 85 | License. For legal entities, "You" includes any entity that controls, is 86 | controlled by, or is under common control with You. For purposes of this 87 | definition, "control" means (a) the power, direct or indirect, to cause 88 | the direction or management of such entity, whether by contract or 89 | otherwise, or (b) ownership of more than fifty percent (50%) of the 90 | outstanding shares or beneficial ownership of such entity. 91 | 92 | 93 | 2. License Grants and Conditions 94 | 95 | 2.1. Grants 96 | 97 | Each Contributor hereby grants You a world-wide, royalty-free, 98 | non-exclusive license: 99 | 100 | a. under intellectual property rights (other than patent or trademark) 101 | Licensable by such Contributor to use, reproduce, make available, 102 | modify, display, perform, distribute, and otherwise exploit its 103 | Contributions, either on an unmodified basis, with Modifications, or 104 | as part of a Larger Work; and 105 | 106 | b. under Patent Claims of such Contributor to make, use, sell, offer for 107 | sale, have made, import, and otherwise transfer either its 108 | Contributions or its Contributor Version. 109 | 110 | 2.2. Effective Date 111 | 112 | The licenses granted in Section 2.1 with respect to any Contribution 113 | become effective for each Contribution on the date the Contributor first 114 | distributes such Contribution. 115 | 116 | 2.3. Limitations on Grant Scope 117 | 118 | The licenses granted in this Section 2 are the only rights granted under 119 | this License. No additional rights or licenses will be implied from the 120 | distribution or licensing of Covered Software under this License. 121 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 122 | Contributor: 123 | 124 | a. for any code that a Contributor has removed from Covered Software; or 125 | 126 | b. for infringements caused by: (i) Your and any other third party's 127 | modifications of Covered Software, or (ii) the combination of its 128 | Contributions with other software (except as part of its Contributor 129 | Version); or 130 | 131 | c. under Patent Claims infringed by Covered Software in the absence of 132 | its Contributions. 133 | 134 | This License does not grant any rights in the trademarks, service marks, 135 | or logos of any Contributor (except as may be necessary to comply with 136 | the notice requirements in Section 3.4). 137 | 138 | 2.4. Subsequent Licenses 139 | 140 | No Contributor makes additional grants as a result of Your choice to 141 | distribute the Covered Software under a subsequent version of this 142 | License (see Section 10.2) or under the terms of a Secondary License (if 143 | permitted under the terms of Section 3.3). 144 | 145 | 2.5. Representation 146 | 147 | Each Contributor represents that the Contributor believes its 148 | Contributions are its original creation(s) or it has sufficient rights to 149 | grant the rights to its Contributions conveyed by this License. 150 | 151 | 2.6. Fair Use 152 | 153 | This License is not intended to limit any rights You have under 154 | applicable copyright doctrines of fair use, fair dealing, or other 155 | equivalents. 156 | 157 | 2.7. Conditions 158 | 159 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in 160 | Section 2.1. 161 | 162 | 163 | 3. Responsibilities 164 | 165 | 3.1. Distribution of Source Form 166 | 167 | All distribution of Covered Software in Source Code Form, including any 168 | Modifications that You create or to which You contribute, must be under 169 | the terms of this License. You must inform recipients that the Source 170 | Code Form of the Covered Software is governed by the terms of this 171 | License, and how they can obtain a copy of this License. You may not 172 | attempt to alter or restrict the recipients' rights in the Source Code 173 | Form. 174 | 175 | 3.2. Distribution of Executable Form 176 | 177 | If You distribute Covered Software in Executable Form then: 178 | 179 | a. such Covered Software must also be made available in Source Code Form, 180 | as described in Section 3.1, and You must inform recipients of the 181 | Executable Form how they can obtain a copy of such Source Code Form by 182 | reasonable means in a timely manner, at a charge no more than the cost 183 | of distribution to the recipient; and 184 | 185 | b. You may distribute such Executable Form under the terms of this 186 | License, or sublicense it under different terms, provided that the 187 | license for the Executable Form does not attempt to limit or alter the 188 | recipients' rights in the Source Code Form under this License. 189 | 190 | 3.3. Distribution of a Larger Work 191 | 192 | You may create and distribute a Larger Work under terms of Your choice, 193 | provided that You also comply with the requirements of this License for 194 | the Covered Software. If the Larger Work is a combination of Covered 195 | Software with a work governed by one or more Secondary Licenses, and the 196 | Covered Software is not Incompatible With Secondary Licenses, this 197 | License permits You to additionally distribute such Covered Software 198 | under the terms of such Secondary License(s), so that the recipient of 199 | the Larger Work may, at their option, further distribute the Covered 200 | Software under the terms of either this License or such Secondary 201 | License(s). 202 | 203 | 3.4. Notices 204 | 205 | You may not remove or alter the substance of any license notices 206 | (including copyright notices, patent notices, disclaimers of warranty, or 207 | limitations of liability) contained within the Source Code Form of the 208 | Covered Software, except that You may alter any license notices to the 209 | extent required to remedy known factual inaccuracies. 210 | 211 | 3.5. Application of Additional Terms 212 | 213 | You may choose to offer, and to charge a fee for, warranty, support, 214 | indemnity or liability obligations to one or more recipients of Covered 215 | Software. However, You may do so only on Your own behalf, and not on 216 | behalf of any Contributor. You must make it absolutely clear that any 217 | such warranty, support, indemnity, or liability obligation is offered by 218 | You alone, and You hereby agree to indemnify every Contributor for any 219 | liability incurred by such Contributor as a result of warranty, support, 220 | indemnity or liability terms You offer. You may include additional 221 | disclaimers of warranty and limitations of liability specific to any 222 | jurisdiction. 223 | 224 | 4. Inability to Comply Due to Statute or Regulation 225 | 226 | If it is impossible for You to comply with any of the terms of this License 227 | with respect to some or all of the Covered Software due to statute, 228 | judicial order, or regulation then You must: (a) comply with the terms of 229 | this License to the maximum extent possible; and (b) describe the 230 | limitations and the code they affect. Such description must be placed in a 231 | text file included with all distributions of the Covered Software under 232 | this License. Except to the extent prohibited by statute or regulation, 233 | such description must be sufficiently detailed for a recipient of ordinary 234 | skill to be able to understand it. 235 | 236 | 5. Termination 237 | 238 | 5.1. The rights granted under this License will terminate automatically if You 239 | fail to comply with any of its terms. However, if You become compliant, 240 | then the rights granted under this License from a particular Contributor 241 | are reinstated (a) provisionally, unless and until such Contributor 242 | explicitly and finally terminates Your grants, and (b) on an ongoing 243 | basis, if such Contributor fails to notify You of the non-compliance by 244 | some reasonable means prior to 60 days after You have come back into 245 | compliance. Moreover, Your grants from a particular Contributor are 246 | reinstated on an ongoing basis if such Contributor notifies You of the 247 | non-compliance by some reasonable means, this is the first time You have 248 | received notice of non-compliance with this License from such 249 | Contributor, and You become compliant prior to 30 days after Your receipt 250 | of the notice. 251 | 252 | 5.2. If You initiate litigation against any entity by asserting a patent 253 | infringement claim (excluding declaratory judgment actions, 254 | counter-claims, and cross-claims) alleging that a Contributor Version 255 | directly or indirectly infringes any patent, then the rights granted to 256 | You by any and all Contributors for the Covered Software under Section 257 | 2.1 of this License shall terminate. 258 | 259 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user 260 | license agreements (excluding distributors and resellers) which have been 261 | validly granted by You or Your distributors under this License prior to 262 | termination shall survive termination. 263 | 264 | 6. Disclaimer of Warranty 265 | 266 | Covered Software is provided under this License on an "as is" basis, 267 | without warranty of any kind, either expressed, implied, or statutory, 268 | including, without limitation, warranties that the Covered Software is free 269 | of defects, merchantable, fit for a particular purpose or non-infringing. 270 | The entire risk as to the quality and performance of the Covered Software 271 | is with You. Should any Covered Software prove defective in any respect, 272 | You (not any Contributor) assume the cost of any necessary servicing, 273 | repair, or correction. This disclaimer of warranty constitutes an essential 274 | part of this License. No use of any Covered Software is authorized under 275 | this License except under this disclaimer. 276 | 277 | 7. Limitation of Liability 278 | 279 | Under no circumstances and under no legal theory, whether tort (including 280 | negligence), contract, or otherwise, shall any Contributor, or anyone who 281 | distributes Covered Software as permitted above, be liable to You for any 282 | direct, indirect, special, incidental, or consequential damages of any 283 | character including, without limitation, damages for lost profits, loss of 284 | goodwill, work stoppage, computer failure or malfunction, or any and all 285 | other commercial damages or losses, even if such party shall have been 286 | informed of the possibility of such damages. This limitation of liability 287 | shall not apply to liability for death or personal injury resulting from 288 | such party's negligence to the extent applicable law prohibits such 289 | limitation. Some jurisdictions do not allow the exclusion or limitation of 290 | incidental or consequential damages, so this exclusion and limitation may 291 | not apply to You. 292 | 293 | 8. Litigation 294 | 295 | Any litigation relating to this License may be brought only in the courts 296 | of a jurisdiction where the defendant maintains its principal place of 297 | business and such litigation shall be governed by laws of that 298 | jurisdiction, without reference to its conflict-of-law provisions. Nothing 299 | in this Section shall prevent a party's ability to bring cross-claims or 300 | counter-claims. 301 | 302 | 9. Miscellaneous 303 | 304 | This License represents the complete agreement concerning the subject 305 | matter hereof. If any provision of this License is held to be 306 | unenforceable, such provision shall be reformed only to the extent 307 | necessary to make it enforceable. Any law or regulation which provides that 308 | the language of a contract shall be construed against the drafter shall not 309 | be used to construe this License against a Contributor. 310 | 311 | 312 | 10. Versions of the License 313 | 314 | 10.1. New Versions 315 | 316 | Mozilla Foundation is the license steward. Except as provided in Section 317 | 10.3, no one other than the license steward has the right to modify or 318 | publish new versions of this License. Each version will be given a 319 | distinguishing version number. 320 | 321 | 10.2. Effect of New Versions 322 | 323 | You may distribute the Covered Software under the terms of the version 324 | of the License under which You originally received the Covered Software, 325 | or under the terms of any subsequent version published by the license 326 | steward. 327 | 328 | 10.3. Modified Versions 329 | 330 | If you create software not governed by this License, and you want to 331 | create a new license for such software, you may create and use a 332 | modified version of this License if you rename the license and remove 333 | any references to the name of the license steward (except to note that 334 | such modified license differs from this License). 335 | 336 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 337 | Licenses If You choose to distribute Source Code Form that is 338 | Incompatible With Secondary Licenses under the terms of this version of 339 | the License, the notice described in Exhibit B of this License must be 340 | attached. 341 | 342 | Exhibit A - Source Code Form License Notice 343 | 344 | This Source Code Form is subject to the 345 | terms of the Mozilla Public License, v. 346 | 2.0. If a copy of the MPL was not 347 | distributed with this file, You can 348 | obtain one at 349 | http://mozilla.org/MPL/2.0/. 350 | 351 | If it is not possible or desirable to put the notice in a particular file, 352 | then You may include the notice in a location (such as a LICENSE file in a 353 | relevant directory) where a recipient would be likely to look for such a 354 | notice. 355 | 356 | You may add additional accurate notices of copyright ownership. 357 | 358 | Exhibit B - "Incompatible With Secondary Licenses" Notice 359 | 360 | This Source Code Form is "Incompatible 361 | With Secondary Licenses", as defined by 362 | the Mozilla Public License, v. 2.0. 363 | 364 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sad Mac Screen Saver 2 | 3 | *Stefan Arentz, October 2017* 4 | 5 | 6 | ## Some notes on Notarizing 7 | 8 | (Mostly for myself but maybe others find this useful too...) 9 | 10 | First _Archive_ a build. Then from the _Organizer_, hit _Distribute Content_ and select the _Built Products_ option. This will export the signed `.saver` file. 11 | 12 | Then zip it up so that we can send it to the _Notarization Service_: 13 | 14 | ``` 15 | $ ditto -c -k --keepParent SadMac.saver SadMac.zip 16 | ``` 17 | 18 | Then send it to the _Notarization Service_: 19 | 20 | ``` 21 | $ xcrun altool --notarize-app --primary-bundle-id "$ORG_IDENTIFIER.SadMac.zip" --username $APPSTORE_CONNECT_USERNAME --file SadMac.zip 22 | No errors uploading 'SadMac.zip'. 23 | RequestUUID = ad7daf8e-fae4-475a-b117-dfd572e17a34 24 | ``` 25 | 26 | It will ask for a password, use the _App Specific Password_ you generated for Notarization. 27 | 28 | Get some coffee to allow the _Notarization_ to run and then check the status with: 29 | 30 | ``` 31 | $ xcrun altool --notarization-info ad7daf8e-fae4-475a-b117-dfd572e17a34 -u $APPSTORE_CONNECT_USERNAME 32 | No errors getting notarization info. 33 | Date: 2020-08-25 12:14:19 +0000 34 | Hash: df90782d2450e6c4f776f4f11c9a49b3036846cd18b632953c119aad12e80af7 35 | RequestUUID: ad7daf8e-fae4-475a-b117-dfd572e17a34 36 | Status: in progress 37 | Status Code: 0 38 | Status Message: Package Approved 39 | ``` 40 | 41 | When the package is approved, staple the token on the original `.saver` file: 42 | 43 | ``` 44 | $ xcrun stapler staple SadMac.saver 45 | Processing: /Users/stefan/Desktop/SadMac-1.3/Products/Users/stefan/Library/Screen Savers/SadMac.saver 46 | Processing: /Users/stefan/Desktop/SadMac-1.3/Products/Users/stefan/Library/Screen Savers/SadMac.saver 47 | The staple and validate action worked! 48 | ``` 49 | 50 | This file can now be zipped and uploaded to the GitHub releases. 51 | 52 | (Too many manual steps, so next time we'll make sure this is as simple as `notarize.py SadMac.saver`) 53 | -------------------------------------------------------------------------------- /SadMac.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F888F71B1F8A644B00E3A0EC /* SadMacView.h in Headers */ = {isa = PBXBuildFile; fileRef = F888F71A1F8A644B00E3A0EC /* SadMacView.h */; }; 11 | F888F71D1F8A644B00E3A0EC /* SadMacView.m in Sources */ = {isa = PBXBuildFile; fileRef = F888F71C1F8A644B00E3A0EC /* SadMacView.m */; }; 12 | F888F7271F8B154300E3A0EC /* SadMac.png in Resources */ = {isa = PBXBuildFile; fileRef = F888F7241F8B154300E3A0EC /* SadMac.png */; }; 13 | F888F7281F8B154300E3A0EC /* SadMacScene.h in Headers */ = {isa = PBXBuildFile; fileRef = F888F7251F8B154300E3A0EC /* SadMacScene.h */; }; 14 | F888F7291F8B154300E3A0EC /* SadMacScene.m in Sources */ = {isa = PBXBuildFile; fileRef = F888F7261F8B154300E3A0EC /* SadMacScene.m */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | F888F7171F8A644B00E3A0EC /* SadMac.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SadMac.saver; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | F888F71A1F8A644B00E3A0EC /* SadMacView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SadMacView.h; sourceTree = ""; }; 20 | F888F71C1F8A644B00E3A0EC /* SadMacView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SadMacView.m; sourceTree = ""; }; 21 | F888F71E1F8A644B00E3A0EC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 22 | F888F7241F8B154300E3A0EC /* SadMac.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SadMac.png; sourceTree = ""; }; 23 | F888F7251F8B154300E3A0EC /* SadMacScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SadMacScene.h; sourceTree = ""; }; 24 | F888F7261F8B154300E3A0EC /* SadMacScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SadMacScene.m; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | F888F7131F8A644B00E3A0EC /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | F888F70D1F8A644B00E3A0EC = { 39 | isa = PBXGroup; 40 | children = ( 41 | F888F7191F8A644B00E3A0EC /* SadMac */, 42 | F888F7181F8A644B00E3A0EC /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | F888F7181F8A644B00E3A0EC /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | F888F7171F8A644B00E3A0EC /* SadMac.saver */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | F888F7191F8A644B00E3A0EC /* SadMac */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | F888F71A1F8A644B00E3A0EC /* SadMacView.h */, 58 | F888F71C1F8A644B00E3A0EC /* SadMacView.m */, 59 | F888F71E1F8A644B00E3A0EC /* Info.plist */, 60 | F888F7241F8B154300E3A0EC /* SadMac.png */, 61 | F888F7251F8B154300E3A0EC /* SadMacScene.h */, 62 | F888F7261F8B154300E3A0EC /* SadMacScene.m */, 63 | ); 64 | path = SadMac; 65 | sourceTree = ""; 66 | }; 67 | /* End PBXGroup section */ 68 | 69 | /* Begin PBXHeadersBuildPhase section */ 70 | F888F7141F8A644B00E3A0EC /* Headers */ = { 71 | isa = PBXHeadersBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | F888F7281F8B154300E3A0EC /* SadMacScene.h in Headers */, 75 | F888F71B1F8A644B00E3A0EC /* SadMacView.h in Headers */, 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | /* End PBXHeadersBuildPhase section */ 80 | 81 | /* Begin PBXNativeTarget section */ 82 | F888F7161F8A644B00E3A0EC /* SadMac */ = { 83 | isa = PBXNativeTarget; 84 | buildConfigurationList = F888F7211F8A644B00E3A0EC /* Build configuration list for PBXNativeTarget "SadMac" */; 85 | buildPhases = ( 86 | F888F7121F8A644B00E3A0EC /* Sources */, 87 | F888F7131F8A644B00E3A0EC /* Frameworks */, 88 | F888F7141F8A644B00E3A0EC /* Headers */, 89 | F888F7151F8A644B00E3A0EC /* Resources */, 90 | F888F72A1F8B16EC00E3A0EC /* ShellScript */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = SadMac; 97 | productName = SadMac; 98 | productReference = F888F7171F8A644B00E3A0EC /* SadMac.saver */; 99 | productType = "com.apple.product-type.bundle"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | F888F70E1F8A644B00E3A0EC /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastUpgradeCheck = 0900; 108 | ORGANIZATIONNAME = "Stefan Arentz"; 109 | TargetAttributes = { 110 | F888F7161F8A644B00E3A0EC = { 111 | CreatedOnToolsVersion = 9.0; 112 | ProvisioningStyle = Automatic; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = F888F7111F8A644B00E3A0EC /* Build configuration list for PBXProject "SadMac" */; 117 | compatibilityVersion = "Xcode 8.0"; 118 | developmentRegion = en; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | ); 123 | mainGroup = F888F70D1F8A644B00E3A0EC; 124 | productRefGroup = F888F7181F8A644B00E3A0EC /* Products */; 125 | projectDirPath = ""; 126 | projectRoot = ""; 127 | targets = ( 128 | F888F7161F8A644B00E3A0EC /* SadMac */, 129 | ); 130 | }; 131 | /* End PBXProject section */ 132 | 133 | /* Begin PBXResourcesBuildPhase section */ 134 | F888F7151F8A644B00E3A0EC /* Resources */ = { 135 | isa = PBXResourcesBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | F888F7271F8B154300E3A0EC /* SadMac.png in Resources */, 139 | ); 140 | runOnlyForDeploymentPostprocessing = 0; 141 | }; 142 | /* End PBXResourcesBuildPhase section */ 143 | 144 | /* Begin PBXShellScriptBuildPhase section */ 145 | F888F72A1F8B16EC00E3A0EC /* ShellScript */ = { 146 | isa = PBXShellScriptBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | ); 150 | inputPaths = ( 151 | ); 152 | outputPaths = ( 153 | ); 154 | runOnlyForDeploymentPostprocessing = 0; 155 | shellPath = /bin/sh; 156 | shellScript = "if [[ \"${XCS}\" == \"1\" || \"${USER}\" == \"runner\" ]]; then\n exit 0\nfi\n\nSCREEN_SAVER_PATH=\"${HOME}/Library/Screen Savers/${FULL_PRODUCT_NAME}\"\nif [[ -d \"${SCREEN_SAVER_PATH}\" || -f \"${SCREEN_SAVER_PATH}\" || -L \"${SCREEN_SAVER_PATH}\" ]]; then\n rm -Rf \"${SCREEN_SAVER_PATH}\"\nfi\n\nln -s \"${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}\" \"${SCREEN_SAVER_PATH}\"\n"; 157 | }; 158 | /* End PBXShellScriptBuildPhase section */ 159 | 160 | /* Begin PBXSourcesBuildPhase section */ 161 | F888F7121F8A644B00E3A0EC /* Sources */ = { 162 | isa = PBXSourcesBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | F888F71D1F8A644B00E3A0EC /* SadMacView.m in Sources */, 166 | F888F7291F8B154300E3A0EC /* SadMacScene.m in Sources */, 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | }; 170 | /* End PBXSourcesBuildPhase section */ 171 | 172 | /* Begin XCBuildConfiguration section */ 173 | F888F71F1F8A644B00E3A0EC /* Debug */ = { 174 | isa = XCBuildConfiguration; 175 | buildSettings = { 176 | ALWAYS_SEARCH_USER_PATHS = NO; 177 | CLANG_ANALYZER_NONNULL = YES; 178 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 179 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 180 | CLANG_CXX_LIBRARY = "libc++"; 181 | CLANG_ENABLE_MODULES = YES; 182 | CLANG_ENABLE_OBJC_ARC = YES; 183 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 184 | CLANG_WARN_BOOL_CONVERSION = YES; 185 | CLANG_WARN_COMMA = YES; 186 | CLANG_WARN_CONSTANT_CONVERSION = YES; 187 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 188 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 189 | CLANG_WARN_EMPTY_BODY = YES; 190 | CLANG_WARN_ENUM_CONVERSION = YES; 191 | CLANG_WARN_INFINITE_RECURSION = YES; 192 | CLANG_WARN_INT_CONVERSION = YES; 193 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 194 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 195 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 196 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 197 | CLANG_WARN_STRICT_PROTOTYPES = YES; 198 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 199 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 200 | CLANG_WARN_UNREACHABLE_CODE = YES; 201 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 202 | CODE_SIGN_IDENTITY = "Mac Developer"; 203 | COPY_PHASE_STRIP = NO; 204 | DEBUG_INFORMATION_FORMAT = dwarf; 205 | ENABLE_STRICT_OBJC_MSGSEND = YES; 206 | ENABLE_TESTABILITY = YES; 207 | GCC_C_LANGUAGE_STANDARD = gnu11; 208 | GCC_DYNAMIC_NO_PIC = NO; 209 | GCC_NO_COMMON_BLOCKS = YES; 210 | GCC_OPTIMIZATION_LEVEL = 0; 211 | GCC_PREPROCESSOR_DEFINITIONS = ( 212 | "DEBUG=1", 213 | "$(inherited)", 214 | ); 215 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 216 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 217 | GCC_WARN_UNDECLARED_SELECTOR = YES; 218 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 219 | GCC_WARN_UNUSED_FUNCTION = YES; 220 | GCC_WARN_UNUSED_VARIABLE = YES; 221 | MACOSX_DEPLOYMENT_TARGET = 10.12; 222 | MTL_ENABLE_DEBUG_INFO = YES; 223 | ONLY_ACTIVE_ARCH = YES; 224 | SDKROOT = macosx; 225 | }; 226 | name = Debug; 227 | }; 228 | F888F7201F8A644B00E3A0EC /* Release */ = { 229 | isa = XCBuildConfiguration; 230 | buildSettings = { 231 | ALWAYS_SEARCH_USER_PATHS = NO; 232 | CLANG_ANALYZER_NONNULL = YES; 233 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 234 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 235 | CLANG_CXX_LIBRARY = "libc++"; 236 | CLANG_ENABLE_MODULES = YES; 237 | CLANG_ENABLE_OBJC_ARC = YES; 238 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 239 | CLANG_WARN_BOOL_CONVERSION = YES; 240 | CLANG_WARN_COMMA = YES; 241 | CLANG_WARN_CONSTANT_CONVERSION = YES; 242 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 243 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN_ENUM_CONVERSION = YES; 246 | CLANG_WARN_INFINITE_RECURSION = YES; 247 | CLANG_WARN_INT_CONVERSION = YES; 248 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 249 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 250 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 251 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 252 | CLANG_WARN_STRICT_PROTOTYPES = YES; 253 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 254 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 255 | CLANG_WARN_UNREACHABLE_CODE = YES; 256 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 257 | CODE_SIGN_IDENTITY = "Mac Developer"; 258 | COPY_PHASE_STRIP = NO; 259 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 260 | ENABLE_NS_ASSERTIONS = NO; 261 | ENABLE_STRICT_OBJC_MSGSEND = YES; 262 | GCC_C_LANGUAGE_STANDARD = gnu11; 263 | GCC_NO_COMMON_BLOCKS = YES; 264 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 265 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 266 | GCC_WARN_UNDECLARED_SELECTOR = YES; 267 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 268 | GCC_WARN_UNUSED_FUNCTION = YES; 269 | GCC_WARN_UNUSED_VARIABLE = YES; 270 | MACOSX_DEPLOYMENT_TARGET = 10.12; 271 | MTL_ENABLE_DEBUG_INFO = NO; 272 | SDKROOT = macosx; 273 | }; 274 | name = Release; 275 | }; 276 | F888F7221F8A644B00E3A0EC /* Debug */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | CODE_SIGN_IDENTITY = "-"; 280 | CODE_SIGN_STYLE = Automatic; 281 | COMBINE_HIDPI_IMAGES = YES; 282 | DEVELOPMENT_TEAM = ""; 283 | INFOPLIST_FILE = SadMac/Info.plist; 284 | INSTALL_PATH = "$(HOME)/Library/Screen Savers"; 285 | PRODUCT_BUNDLE_IDENTIFIER = ca.hogtownsoftware.SadMac; 286 | PRODUCT_NAME = "$(TARGET_NAME)"; 287 | PROVISIONING_PROFILE_SPECIFIER = ""; 288 | WRAPPER_EXTENSION = saver; 289 | }; 290 | name = Debug; 291 | }; 292 | F888F7231F8A644B00E3A0EC /* Release */ = { 293 | isa = XCBuildConfiguration; 294 | buildSettings = { 295 | CODE_SIGN_IDENTITY = "Developer ID Application"; 296 | CODE_SIGN_STYLE = Manual; 297 | COMBINE_HIDPI_IMAGES = YES; 298 | DEVELOPMENT_TEAM = 553QKZD2RX; 299 | INFOPLIST_FILE = SadMac/Info.plist; 300 | INSTALL_PATH = "$(HOME)/Library/Screen Savers"; 301 | PRODUCT_BUNDLE_IDENTIFIER = ca.hogtownsoftware.SadMac; 302 | PRODUCT_NAME = "$(TARGET_NAME)"; 303 | PROVISIONING_PROFILE_SPECIFIER = ""; 304 | WRAPPER_EXTENSION = saver; 305 | }; 306 | name = Release; 307 | }; 308 | /* End XCBuildConfiguration section */ 309 | 310 | /* Begin XCConfigurationList section */ 311 | F888F7111F8A644B00E3A0EC /* Build configuration list for PBXProject "SadMac" */ = { 312 | isa = XCConfigurationList; 313 | buildConfigurations = ( 314 | F888F71F1F8A644B00E3A0EC /* Debug */, 315 | F888F7201F8A644B00E3A0EC /* Release */, 316 | ); 317 | defaultConfigurationIsVisible = 0; 318 | defaultConfigurationName = Release; 319 | }; 320 | F888F7211F8A644B00E3A0EC /* Build configuration list for PBXNativeTarget "SadMac" */ = { 321 | isa = XCConfigurationList; 322 | buildConfigurations = ( 323 | F888F7221F8A644B00E3A0EC /* Debug */, 324 | F888F7231F8A644B00E3A0EC /* Release */, 325 | ); 326 | defaultConfigurationIsVisible = 0; 327 | defaultConfigurationName = Release; 328 | }; 329 | /* End XCConfigurationList section */ 330 | }; 331 | rootObject = F888F70E1F8A644B00E3A0EC /* Project object */; 332 | } 333 | -------------------------------------------------------------------------------- /SadMac.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SadMac.xcodeproj/xcshareddata/xcschemes/SadMac.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 47 | 50 | 51 | 52 | 58 | 59 | 60 | 61 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 76 | 82 | 83 | 84 | 85 | 87 | 88 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /SadMac.xcodeproj/xcuserdata/stefan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SadMac.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F888F7161F8A644B00E3A0EC 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /SadMac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.3 19 | CFBundleVersion 20 | 1 21 | NSHumanReadableCopyright 22 | Copyright © 2018 Stefan Arentz. All rights reserved. 23 | NSPrincipalClass 24 | SadMacView 25 | 26 | 27 | -------------------------------------------------------------------------------- /SadMac/SadMac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/st3fan/SadMacScreenSaver/bd5809acefcf2dfe054b438b51814659e10cd77a/SadMac/SadMac.png -------------------------------------------------------------------------------- /SadMac/SadMacScene.h: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | #import 6 | 7 | @interface SadMacScene: SKScene { 8 | BOOL _isPreview; 9 | } 10 | - (instancetype) initWithSize:(CGSize)size isPreview: (BOOL) isPreview; 11 | @end 12 | -------------------------------------------------------------------------------- /SadMac/SadMacScene.m: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | @import SpriteKit; 6 | 7 | #import "SadMacScene.h" 8 | 9 | @implementation SadMacScene 10 | 11 | - (id) initWithSize:(CGSize)size isPreview: (BOOL) isPreview { 12 | if (self = [super initWithSize: size]) { 13 | _isPreview = isPreview; 14 | } 15 | return self; 16 | } 17 | 18 | - (SKNode*) createFloor { 19 | SKSpriteNode *floor = [SKSpriteNode spriteNodeWithColor: [NSColor blackColor] size: CGSizeMake(CGRectGetWidth(self.frame), 2)]; 20 | floor.anchorPoint = CGPointZero; 21 | floor.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect: floor.frame]; 22 | floor.physicsBody.dynamic = YES; 23 | floor.physicsBody.density = 100.0; 24 | return floor; 25 | } 26 | 27 | CGFloat RandomScaleFactor() { 28 | int r = random() % 1000; 29 | if (r > 900) { 30 | return 0.5; 31 | } else if (r > 450) { 32 | return 0.125; 33 | } else { 34 | return 0.25; 35 | } 36 | } 37 | 38 | CGFloat RandomAngularVelocity() { 39 | CGFloat v = -35.0 + (random() % 70); 40 | return v / 100.0; 41 | } 42 | 43 | CGVector RandomVelocity() { 44 | return CGVectorMake(-250 + (random() % 500), -50 + (random() % 100)); 45 | } 46 | 47 | - (SKNode*) createSadMacAtPosition: (CGPoint) position { 48 | NSString *path = [[NSBundle bundleForClass: [self class]] pathForImageResource: @"SadMac"]; 49 | SKSpriteNode *node = [SKSpriteNode spriteNodeWithImageNamed: path]; 50 | if (node != nil) { 51 | CGFloat scaleFactor = RandomScaleFactor(_isPreview); 52 | [node scaleToSize: CGSizeMake(node.size.width * scaleFactor, node.size.height * scaleFactor)]; 53 | node.position = position; 54 | node.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize: node.size]; 55 | node.physicsBody.dynamic = YES; 56 | node.physicsBody.restitution = 0.33; 57 | node.physicsBody.angularDamping = 0.5; 58 | node.physicsBody.friction = 0.5; 59 | node.physicsBody.density = 0.5; 60 | node.physicsBody.angularVelocity = RandomAngularVelocity(); 61 | node.physicsBody.velocity = RandomVelocity(); 62 | node.physicsBody.categoryBitMask = 2; 63 | node.physicsBody.contactTestBitMask = 1; 64 | } 65 | 66 | return node; 67 | } 68 | 69 | - (void)sceneDidLoad { 70 | self.backgroundColor = [NSColor blackColor]; 71 | 72 | self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect: NSInsetRect(self.frame, -400, -400)]; 73 | self.physicsBody.categoryBitMask = 1; 74 | self.physicsBody.contactTestBitMask = 2; 75 | self.physicsWorld.contactDelegate = self; 76 | 77 | SKNode *floor = [self createFloor]; 78 | [self addChild: floor]; 79 | 80 | NSString *path = [[NSBundle bundleForClass: [self class]] pathForImageResource: @"SadMac"]; 81 | SKSpriteNode *node = [SKSpriteNode spriteNodeWithImageNamed: path]; 82 | [node scaleToSize: CGSizeMake(node.size.width * 0.25, node.size.height * 0.25)]; 83 | node.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)); 84 | node.alpha = 0.0; 85 | [self addChild: node]; 86 | 87 | SKAction *fadeInAction = [SKAction fadeAlphaTo: 1.0 duration: 1.5]; 88 | fadeInAction.timingMode = SKActionTimingEaseIn; 89 | 90 | SKAction *scaleUpAction = [SKAction scaleTo: 1.125 duration: 0.25]; 91 | scaleUpAction.timingMode = SKActionTimingEaseOut; 92 | 93 | SKAction *scaleDownAction = [SKAction scaleTo: 0.0 duration: 0.5]; 94 | scaleUpAction.timingMode = SKActionTimingEaseIn; 95 | 96 | SKAction *createSadMacAction = [SKAction runBlock:^{ 97 | CGFloat x = random() % (u_int32_t) CGRectGetWidth(self.frame); 98 | SKNode *node = [self createSadMacAtPosition: CGPointMake(x, self.size.height + 100)]; 99 | [self addChild: node]; 100 | }]; 101 | SKAction *loopAction = [SKAction sequence: @[[SKAction waitForDuration: 1.0], createSadMacAction]]; 102 | 103 | NSArray *actions = @[fadeInAction, [SKAction waitForDuration: 1.0], scaleUpAction, scaleDownAction, 104 | [SKAction repeatActionForever: loopAction]]; 105 | [node runAction: [SKAction sequence: actions]]; 106 | } 107 | 108 | - (void)didBeginContact:(SKPhysicsContact *)contact { 109 | if (contact.bodyA.categoryBitMask == 2 && contact.bodyB.categoryBitMask == 1) { 110 | [contact.bodyA.node removeFromParent]; 111 | } 112 | if (contact.bodyB.categoryBitMask == 2 && contact.bodyA.categoryBitMask == 1) { 113 | [contact.bodyB.node removeFromParent]; 114 | } 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /SadMac/SadMacView.h: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | #import 6 | 7 | @class SadMacScene; 8 | 9 | @interface SadMacView : ScreenSaverView { 10 | SKView *_sceneView; 11 | SadMacScene *_scene; 12 | } 13 | @property SKView *sceneView; 14 | @property SadMacScene *scene; 15 | @end 16 | -------------------------------------------------------------------------------- /SadMac/SadMacView.m: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | @import ScreenSaver; 6 | @import SpriteKit; 7 | 8 | #import "SadMacScene.h" 9 | #import "SadMacView.h" 10 | 11 | @interface MySKView: SKView { 12 | } 13 | @end 14 | 15 | @implementation MySKView 16 | -(BOOL)acceptsFirstResponder { 17 | return NO; 18 | } 19 | @end 20 | 21 | @implementation SadMacView 22 | 23 | @synthesize sceneView; 24 | @synthesize scene; 25 | 26 | - (instancetype)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview 27 | { 28 | if (self = [super initWithFrame:frame isPreview:isPreview]) { 29 | if (frame.size.width < 400) { 30 | // This is a bit hacky but it works ... 31 | NSTextField *textField = [[NSTextField alloc] initWithFrame: NSMakeRect(0, (self.bounds.size.height-70)/2, self.bounds.size.width, 70)]; 32 | [textField setTextColor: NSColor.whiteColor]; 33 | [textField setStringValue:@"Sad Mac 1.3\nStefan Arentz, August 2020\ngithub.com/st3fan/SadMacScreenSaver"]; 34 | [textField setBezeled:NO]; 35 | [textField setDrawsBackground:NO]; 36 | [textField setEditable:NO]; 37 | [textField setSelectable:NO]; 38 | [textField setAlignment: NSTextAlignmentCenter]; 39 | [textField setUsesSingleLineMode: NO]; 40 | [self addSubview:textField]; 41 | } else { 42 | self.sceneView = [[MySKView alloc] initWithFrame: self.bounds]; 43 | self.sceneView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; 44 | [self addSubview: self.sceneView]; 45 | self.scene = [[SadMacScene alloc] initWithSize: self.frame.size isPreview: isPreview]; 46 | [self.sceneView presentScene: self.scene]; 47 | } 48 | } 49 | return self; 50 | } 51 | 52 | - (BOOL)hasConfigureSheet 53 | { 54 | return NO; 55 | } 56 | 57 | - (NSWindow*)configureSheet 58 | { 59 | return nil; 60 | } 61 | 62 | - (void)keyDown:(NSEvent *)event { 63 | // This is nice for running from Xcode - it is otherwise hard to kill the saver. 64 | if ([[event charactersIgnoringModifiers] isEqualToString: @"q"]) { 65 | exit(0); 66 | } 67 | [super keyDown: event]; 68 | } 69 | 70 | @end 71 | --------------------------------------------------------------------------------