Skip to content

Commit

Permalink
Move Welcome text to resource file
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Apr 28, 2022
1 parent 19ae573 commit 2554814
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 62 deletions.
4 changes: 4 additions & 0 deletions ShapeScript.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
01F1A6182806BD1A00A1621B /* StandardLibraryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F1A6172806BD1A00A1621B /* StandardLibraryTests.swift */; };
01F1A703280AD2BA00A1621B /* StringMatchingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F1A702280AD2BA00A1621B /* StringMatchingTests.swift */; };
01F1A7A5280F724600A1621B /* Material+Brightness.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F1A7A1280F724600A1621B /* Material+Brightness.swift */; };
01F1A8AD2819C37000A1621B /* Welcome.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 01F1A8A82819C37000A1621B /* Welcome.rtf */; };
01FDE3CE26BD73A000A46F66 /* LRUCache.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 01FDE3C026BD736700A46F66 /* LRUCache.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
01FDE3CF26BD73AA00A46F66 /* LRUCache.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01FDE3C026BD736700A46F66 /* LRUCache.framework */; };
01FDE3D526BD766C00A46F66 /* GeometryCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01FDE3D426BD766C00A46F66 /* GeometryCache.swift */; };
Expand Down Expand Up @@ -236,6 +237,7 @@
01F1A6172806BD1A00A1621B /* StandardLibraryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardLibraryTests.swift; sourceTree = "<group>"; };
01F1A702280AD2BA00A1621B /* StringMatchingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringMatchingTests.swift; sourceTree = "<group>"; };
01F1A7A1280F724600A1621B /* Material+Brightness.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+Brightness.swift"; sourceTree = "<group>"; };
01F1A8A82819C37000A1621B /* Welcome.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; path = Welcome.rtf; sourceTree = "<group>"; };
01FDE3B626BD736700A46F66 /* LRUCache.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = LRUCache.xcodeproj; sourceTree = "<group>"; };
01FDE3D426BD766C00A46F66 /* GeometryCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeometryCache.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -309,6 +311,7 @@
0152E5CF2145009A0082A5A3 /* Main.storyboard */,
0152E5D22145009A0082A5A3 /* Info.plist */,
0152E5D32145009A0082A5A3 /* Viewer.entitlements */,
01F1A8A82819C37000A1621B /* Welcome.rtf */,
);
path = Viewer;
sourceTree = "<group>";
Expand Down Expand Up @@ -621,6 +624,7 @@
buildActionMask = 2147483647;
files = (
0152E5D12145009A0082A5A3 /* Main.storyboard in Resources */,
01F1A8AD2819C37000A1621B /* Welcome.rtf in Resources */,
0152E5CE2145009A0082A5A3 /* Assets.xcassets in Resources */,
01BD9437219367D2005FFAEC /* Examples in Resources */,
);
Expand Down
66 changes: 5 additions & 61 deletions Viewer/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19162"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -1193,7 +1193,7 @@
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" drawsBackground="NO" id="s63-TB-AyE">
<rect key="frame" x="0.0" y="0.0" width="240" height="135"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" smartInsertDelete="YES" id="OaV-Ak-1uT">
<rect key="frame" x="0.0" y="0.0" width="240" height="135"/>
Expand Down Expand Up @@ -1268,7 +1268,7 @@
</buttonCell>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Uyk-FY-bZa">
<rect key="frame" x="178" y="29" width="124" height="18"/>
<rect key="frame" x="179" y="29" width="123" height="18"/>
<buttonCell key="cell" type="check" title="Show at Startup" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Pdw-43-3k6">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -1290,63 +1290,6 @@
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<size key="minSize" width="442" height="197"/>
<size key="maxSize" width="448" height="10000000"/>
<attributedString key="textStorage">
<fragment>
<string key="content">ShapeScript is a text-based 3D modelling tool. If this is your first time using ShapeScript, we recommend you check out the Getting Started guide.</string>
<attributes>
<color key="NSColor" name="textColor" catalog="System" colorSpace="catalog"/>
<font key="NSFont" metaFont="system" size="14"/>
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO"/>
</attributes>
</fragment>
<fragment>
<string key="content" base64-UTF8="YES">
Cg
</string>
<attributes>
<color key="NSColor" name="textColor" catalog="System" colorSpace="catalog"/>
<font key="NSFont" metaFont="system" size="14"/>
<real key="NSKern" value="0.0"/>
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO"/>
</attributes>
</fragment>
<fragment>
<string key="content">
This viewer is free to use for creating and previewing models in ShapeScript's own shape file format.

The commercial release of ShapeScript (which you can find on the </string>
<attributes>
<color key="NSColor" name="textColor" catalog="System" colorSpace="catalog"/>
<font key="NSFont" metaFont="system" size="14"/>
<real key="NSKern" value="0.0"/>
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="leftToRight" defaultTabInterval="36" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO">
<tabStops/>
</paragraphStyle>
</attributes>
</fragment>
<fragment content="Mac App Store">
<attributes>
<color key="NSColor" name="textColor" catalog="System" colorSpace="catalog"/>
<font key="NSFont" metaFont="system" size="14"/>
<real key="NSKern" value="0.0"/>
<url key="NSLink" string="https://apps.apple.com/app/id1441135869"/>
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="leftToRight" defaultTabInterval="36" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO">
<tabStops/>
</paragraphStyle>
</attributes>
</fragment>
<fragment>
<string key="content">) includes a one-time in-app purchase to unlock the ability to export ShapeScript models in various formats, for use with other applications.</string>
<attributes>
<color key="NSColor" name="textColor" catalog="System" colorSpace="catalog"/>
<font key="NSFont" metaFont="system" size="14"/>
<real key="NSKern" value="0.0"/>
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="leftToRight" defaultTabInterval="36" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO">
<tabStops/>
</paragraphStyle>
</attributes>
</fragment>
</attributedString>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
</subviews>
Expand Down Expand Up @@ -1377,6 +1320,7 @@ The commercial release of ShapeScript (which you can find on the </string>
</view>
<connections>
<outlet property="shouldShowAtStartupCheckbox" destination="Uyk-FY-bZa" id="V2P-ka-699"/>
<outlet property="welcomeView" destination="Oke-rb-mcR" id="6Ne-p3-G49"/>
</connections>
</viewController>
<customObject id="GWO-iI-wG3" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
Expand Down
6 changes: 6 additions & 0 deletions Viewer/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ let isHighSierra: Bool = {

let useOpenGL = isHighSierra

func loadRTF(_ file: String) -> NSAttributedString {
let file = Bundle.main.url(forResource: file, withExtension: "rtf")!
let data = try! Data(contentsOf: file)
return NSAttributedString(rtf: data, documentAttributes: nil)!
}

func isImageFile(_ url: URL) -> Bool {
[
"webp",
Expand Down
14 changes: 14 additions & 0 deletions Viewer/Welcome.rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{\rtf1\ansi\ansicpg1252\cocoartf2638
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0\cname textColor;}
\paperw11900\paperh16840\margl1440\margr1440\vieww15100\viewh13360\viewkind0
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0

\f0\fs28 \cf2 ShapeScript is a text-based 3D modeling tool. If this is your first time using ShapeScript, we recommend you check out the Getting Started guide.\expnd0\expndtw0\kerning0
\
\pard\pardeftab720\partightenfactor0
\cf2 \
This viewer is free to use for creating and previewing models in ShapeScript's own shape file format.\
\
The commercial release of ShapeScript (which you can find on the {\field{\*\fldinst{HYPERLINK "https://apps.apple.com/app/id1441135869"}}{\fldrslt Mac App Store}}) includes a one-time in-app purchase to unlock the ability to export ShapeScript models in various formats, for use with other applications.}
4 changes: 3 additions & 1 deletion Viewer/WelcomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import Cocoa

class WelcomeViewController: NSViewController {
@IBOutlet var shouldShowAtStartupCheckbox: NSButton!
@IBOutlet private var welcomeView: NSTextView!
@IBOutlet private var shouldShowAtStartupCheckbox: NSButton!

override func viewDidLoad() {
super.viewDidLoad()
welcomeView.textStorage?.setAttributedString(loadRTF("Welcome"))
shouldShowAtStartupCheckbox.state =
WelcomeViewController.shouldShowAtStartup ? .on : .off
}
Expand Down

0 comments on commit 2554814

Please sign in to comment.