Onscreen Widget Tool:

- edit/duplicate function support
- opened from cmd tool by sliding from screen edge
This commit is contained in:
TrueZhuangjia
2025-05-13 23:18:32 +08:00
committed by TrueZhuanjia
parent c8ebdc0a88
commit d3b62e38fc
14 changed files with 573 additions and 229 deletions
+46 -31
View File
@@ -751,14 +751,14 @@ ICAgICAgICAgICAgICA
<viewControllerLayoutGuide type="bottom" id="eaS-aj-VtA"/>
</layoutGuides>
<view key="view" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="Acw-S4-f8a">
<rect key="frame" x="0.0" y="0.0" width="834" height="1194"/>
<rect key="frame" x="0.0" y="0.0" width="1300" height="1194"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view alpha="0.75" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fZU-G0-fgM" userLabel="Toolbar Root View" customClass="ToolBarContainerView">
<rect key="frame" x="0.0" y="24" width="834" height="50"/>
<rect key="frame" x="0.0" y="24" width="1300" height="50"/>
<subviews>
<stackView autoresizesSubviews="NO" opaque="NO" contentMode="scaleToFill" spacing="70" translatesAutoresizingMaskIntoConstraints="NO" id="YLK-IE-ajS">
<rect key="frame" x="152" y="0.0" width="530" height="50"/>
<rect key="frame" x="235" y="0.0" width="830" height="50"/>
<subviews>
<button opaque="NO" tag="20" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qJs-n8-eV7" userLabel="Trash">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
@@ -786,20 +786,33 @@ ICAgICAgICAgICAgICA
<action selector="undoTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="54z-kO-oCo"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EPu-dl-Tv8">
<button autoresizesSubviews="NO" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uda-zt-xrG" userLabel="Save">
<rect key="frame" x="240" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="TEB-dw-YGo"/>
<constraint firstAttribute="height" constant="50" id="z50-CE-W0m"/>
</constraints>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="SquareAndArrowDown"/>
<connections>
<action selector="saveTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="bUV-Ja-Htd"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EPu-dl-Tv8">
<rect key="frame" x="360" y="0.0" width="50" height="50"/>
<subviews>
<button autoresizesSubviews="NO" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uda-zt-xrG" userLabel="Save">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OId-gk-Wkg" userLabel="Load">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="TEB-dw-YGo"/>
<constraint firstAttribute="height" constant="50" id="z50-CE-W0m"/>
<constraint firstAttribute="width" constant="50" id="XlA-qH-mSO"/>
<constraint firstAttribute="height" constant="50" id="xSe-dW-zjg"/>
</constraints>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="SquareAndArrowDown"/>
<state key="normal" image="SquaresArrowUp"/>
<connections>
<action selector="saveTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="bUV-Ja-Htd"/>
<action selector="loadTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="ZCn-S3-8em"/>
</connections>
</button>
</subviews>
@@ -807,42 +820,43 @@ ICAgICAgICAgICAgICA
<constraint firstAttribute="width" constant="50" id="G6V-W8-Ech"/>
</constraints>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1EQ-sU-0bc" userLabel="Load">
<rect key="frame" x="360" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="0Up-sg-4RI"/>
<constraint firstAttribute="width" constant="50" id="EBU-5l-gEs"/>
</constraints>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="SquaresArrowUp"/>
<connections>
<action selector="loadTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="84k-1w-sd2"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bMH-Yb-sb6" userLabel="Add">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fKN-ja-TRi" userLabel="Add">
<rect key="frame" x="480" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="hGO-XD-eLY"/>
<constraint firstAttribute="width" constant="50" id="rWU-3E-f4u"/>
<constraint firstAttribute="width" constant="50" id="g75-DA-uPz"/>
<constraint firstAttribute="height" constant="50" id="nJF-Od-j7Y"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="53"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="23"/>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="+"/>
<state key="normal" title="Add"/>
<connections>
<action selector="addTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="7dP-Lk-Mdj"/>
<action selector="addTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="y4c-PU-rbS"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="R45-lM-YPl">
<rect key="frame" x="600" y="0.0" width="230" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="SpF-xI-pOI"/>
<constraint firstAttribute="width" constant="50" id="p01-nF-Ee8"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="23"/>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Edit"/>
<connections>
<action selector="editTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="hfu-ay-iKZ"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="EPu-dl-Tv8" firstAttribute="centerY" secondItem="YLK-IE-ajS" secondAttribute="centerY" id="9Du-ZM-F8k"/>
<constraint firstItem="EPu-dl-Tv8" firstAttribute="centerX" secondItem="YLK-IE-ajS" secondAttribute="centerX" id="9ua-n0-eG4"/>
<constraint firstAttribute="width" constant="530" id="zzS-yc-O4H"/>
<constraint firstAttribute="width" constant="830" id="zzS-yc-O4H"/>
</constraints>
</stackView>
<view alpha="0.89999997615814209" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hKp-ds-86I" userLabel="Chevron View">
<rect key="frame" x="391" y="50" width="52" height="30"/>
<rect key="frame" x="624" y="50" width="52" height="30"/>
<subviews>
<imageView clipsSubviews="YES" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ChevronCompactUp" translatesAutoresizingMaskIntoConstraints="NO" id="iVZ-Fd-dY7">
<rect key="frame" x="0.0" y="0.0" width="52" height="30"/>
@@ -939,6 +953,7 @@ ICAgICAgICAgICAgICA
</view>
<toolbarItems/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<size key="freeformSize" width="1300" height="1194"/>
<connections>
<outlet property="chevronImageView" destination="iVZ-Fd-dY7" id="403-Nj-wRx"/>
<outlet property="chevronView" destination="hKp-ds-86I" id="Og9-aT-zNH"/>
@@ -1038,7 +1053,7 @@ ICAgICAgICAgICAgICA
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="K4u-Tz-tXU" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3514" y="1068"/>
<point key="canvasLocation" x="3742" y="955"/>
</scene>
</scenes>
<resources>
+44 -39
View File
@@ -722,7 +722,7 @@ ICAgICAgICAgICAgIA
<viewControllerLayoutGuide type="bottom" id="hby-2y-jAk"/>
</layoutGuides>
<view key="view" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="center" id="nSw-dc-mi4">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<rect key="frame" x="0.0" y="0.0" width="800" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" animating="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="oNu-Gu-QeM">
@@ -732,6 +732,7 @@ ICAgICAgICAgICAgIA
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<size key="freeformSize" width="800" height="896"/>
<connections>
<outlet property="loadingSpinner" destination="oNu-Gu-QeM" id="5IK-qn-mIZ"/>
</connections>
@@ -749,14 +750,14 @@ ICAgICAgICAgICAgIA
<viewControllerLayoutGuide type="bottom" id="TWA-bF-hnk"/>
</layoutGuides>
<view key="view" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="Mwx-9q-yJJ">
<rect key="frame" x="0.0" y="0.0" width="650" height="896"/>
<rect key="frame" x="0.0" y="0.0" width="1300" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Jnu-63-bcf" customClass="ToolBarContainerView">
<rect key="frame" x="0.0" y="0.0" width="650" height="50"/>
<rect key="frame" x="0.0" y="0.0" width="1300" height="50"/>
<subviews>
<stackView opaque="NO" contentMode="scaleAspectFill" alignment="center" spacing="70" translatesAutoresizingMaskIntoConstraints="NO" id="4he-pe-kYB">
<rect key="frame" x="60" y="0.0" width="530" height="50"/>
<rect key="frame" x="275" y="0.0" width="750" height="50"/>
<subviews>
<button opaque="NO" tag="20" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dhG-Fo-0GK" userLabel="Trash">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
@@ -788,27 +789,22 @@ ICAgICAgICAgICAgIA
<action selector="undoTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="Lzm-gS-xMV"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RDI-on-aPY">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LPA-ea-YHC" userLabel="Save">
<rect key="frame" x="240" y="0.0" width="50" height="50"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LPA-ea-YHC" userLabel="Save">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="Lot-pn-o60"/>
<constraint firstAttribute="height" constant="50" id="uWO-So-qxr"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="SquareAndArrowDown">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" configurationType="pointSize" pointSize="64"/>
</state>
<connections>
<action selector="saveTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="cSe-fN-UWC"/>
</connections>
</button>
</subviews>
</stackView>
<constraints>
<constraint firstAttribute="width" constant="50" id="Lot-pn-o60"/>
<constraint firstAttribute="height" constant="50" id="uWO-So-qxr"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="SquareAndArrowDown">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" configurationType="pointSize" pointSize="64"/>
</state>
<connections>
<action selector="saveTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="cSe-fN-UWC"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rXW-Ms-2cJ" userLabel="Load">
<rect key="frame" x="360" y="0.0" width="50" height="50"/>
<constraints>
@@ -824,35 +820,44 @@ ICAgICAgICAgICAgIA
<action selector="loadTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="DVp-Xi-K27"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" hasAttributedTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Up4-28-sgF" userLabel="Add">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Up4-28-sgF" userLabel="Add">
<rect key="frame" x="480" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="rWU-US-9dl"/>
<constraint firstAttribute="width" constant="50" id="wWj-wB-MRd"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal">
<attributedString key="attributedTitle">
<fragment content="+">
<attributes>
<font key="NSFont" size="50" name="Arial-BoldMT"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>
</attributedString>
</state>
<state key="normal" title="Add"/>
<connections>
<action selector="addTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="idY-3m-m01"/>
<action selector="addTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="Yzn-KO-PS9"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4pE-po-Zn1">
<rect key="frame" x="600" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="oFn-jm-orG"/>
<constraint firstAttribute="height" constant="50" id="sls-Vh-uxz"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Edit"/>
<connections>
<action selector="editTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="bd9-hf-0gN"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RDI-on-aPY">
<rect key="frame" x="720" y="0.0" width="30" height="50"/>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="width" constant="530" id="6BK-sG-WTH"/>
<constraint firstAttribute="width" constant="750" id="6BK-sG-WTH"/>
</constraints>
</stackView>
<view alpha="0.89999997615814209" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zll-IP-PFt" userLabel="Chevron View">
<rect key="frame" x="299" y="50" width="52" height="25"/>
<rect key="frame" x="624" y="50" width="52" height="25"/>
<subviews>
<imageView clipsSubviews="YES" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ChevronCompactUp" translatesAutoresizingMaskIntoConstraints="NO" id="76O-3K-aa8">
<rect key="frame" x="0.0" y="0.0" width="52" height="25"/>
@@ -942,7 +947,7 @@ ICAgICAgICAgICAgIA
<constraint firstItem="Jnu-63-bcf" firstAttribute="top" secondItem="Mwx-9q-yJJ" secondAttribute="top" id="wNr-7F-S0i" userLabel="Toolbar Top Constraint iPhone"/>
</constraints>
</view>
<size key="freeformSize" width="650" height="896"/>
<size key="freeformSize" width="1300" height="896"/>
<connections>
<outlet property="chevronImageView" destination="76O-3K-aa8" id="yGv-fM-Ohf"/>
<outlet property="chevronView" destination="Zll-IP-PFt" id="MGR-C0-h57"/>
+24 -24
View File
@@ -19,29 +19,29 @@ import UIKit
// MARK: - Properties
@objc var keyboardCmdString: String
@objc var cmdString: String
@objc var alias: String
// MARK: - Initialization
init(keyboardCmdString: String, alias: String) {
self.keyboardCmdString = keyboardCmdString
init(cmdString: String, alias: String) {
self.cmdString = cmdString
self.alias = alias
}
// MARK: - NSSecureCoding
required public init?(coder: NSCoder) {
guard let keyboardCmdString = coder.decodeObject(of: NSString.self, forKey: "keyboardCmdString") as String?,
guard let cmdString = coder.decodeObject(of: NSString.self, forKey: "keyboardCmdString") as String?,
let alias = coder.decodeObject(of: NSString.self, forKey: "alias") as String? else {
return nil
}
self.keyboardCmdString = keyboardCmdString
self.cmdString = cmdString
self.alias = alias
}
public func encode(with coder: NSCoder) {
coder.encode(keyboardCmdString, forKey: "keyboardCmdString")
coder.encode(cmdString, forKey: "keyboardCmdString")
coder.encode(alias, forKey: "alias")
}
}
@@ -377,21 +377,21 @@ import UIKit
let defaults = UserDefaults.standard
//if true { // save default entries if the data is empty.
if defaults.data(forKey: "savedCommands") == nil { // save default entries if the data is empty.
let defaultCommands: [RemoteCommand] = [
RemoteCommand(keyboardCmdString: "WIN", alias: "WIN"),
RemoteCommand(keyboardCmdString: "F11", alias: "F11"),
RemoteCommand(keyboardCmdString: "ESC", alias: "ESC"),
RemoteCommand(keyboardCmdString: "CTRL+SHIFT+ESC", alias: "任务管理器(Task Manager)"),
RemoteCommand(keyboardCmdString: "ALT+F1", alias: "N卡截图(Nvidia Screenshot)"),
RemoteCommand(keyboardCmdString: "ALT+F9", alias: "N卡录屏(Nvidia Screen Recording)"),
RemoteCommand(keyboardCmdString: "ALT+F4", alias: "关闭窗口(ALT+F4)"),
RemoteCommand(keyboardCmdString: "CTRL+A", alias: "全选(Select All)"),
RemoteCommand(keyboardCmdString: "CTRL+C", alias: "复制(Copy)"),
RemoteCommand(keyboardCmdString: "CTRL+V", alias: "粘贴(Paste)"),
RemoteCommand(keyboardCmdString: "WIN+D", alias: "切换桌面(Switch to Desktop)"),
RemoteCommand(keyboardCmdString: "WIN+P", alias: "多显模式(Project)"),
RemoteCommand(keyboardCmdString: "WIN+G", alias: "Xbox Game Bar"),
RemoteCommand(keyboardCmdString: "SHIFT+TAB", alias: "Steam Overlay"),
var defaultCommands: [RemoteCommand] = [
RemoteCommand(cmdString: "WIN", alias: "WIN"),
RemoteCommand(cmdString: "F11", alias: "F11"),
RemoteCommand(cmdString: "ESC", alias: "ESC"),
RemoteCommand(cmdString: "CTRL+SHIFT+ESC", alias: "任务管理器(Task Manager)"),
RemoteCommand(cmdString: "ALT+F1", alias: "N卡截图(Nvidia Screenshot)"),
RemoteCommand(cmdString: "ALT+F9", alias: "N卡录屏(Nvidia Screen Recording)"),
RemoteCommand(cmdString: "ALT+F4", alias: "关闭窗口(ALT+F4)"),
RemoteCommand(cmdString: "CTRL+A", alias: "全选(Select All)"),
RemoteCommand(cmdString: "CTRL+C", alias: "复制(Copy)"),
RemoteCommand(cmdString: "CTRL+V", alias: "粘贴(Paste)"),
RemoteCommand(cmdString: "WIN+D", alias: "切换桌面(Switch to Desktop)"),
RemoteCommand(cmdString: "WIN+P", alias: "多显模式(Project)"),
RemoteCommand(cmdString: "WIN+G", alias: "Xbox Game Bar"),
RemoteCommand(cmdString: "SHIFT+TAB", alias: "Steam Overlay"),
]
let data = try? NSKeyedArchiver.archivedData(withRootObject: defaultCommands, requiringSecureCoding: false)
@@ -505,9 +505,9 @@ import UIKit
}
@objc public func addCommand(_ command: RemoteCommand) -> Bool {
command.keyboardCmdString = command.keyboardCmdString.uppercased() // convert all letters to upper case
if(command.alias.trimmingCharacters(in: .whitespacesAndNewlines).count == 0) {command.alias = command.keyboardCmdString} // copy cmd string as alias when alias is empty
let keyStrings = extractKeyStringsFromComboCommand(from: command.keyboardCmdString)
command.cmdString = command.cmdString.uppercased() // convert all letters to upper case
if(command.alias.trimmingCharacters(in: .whitespacesAndNewlines).count == 0) {command.alias = command.cmdString} // copy cmd string as alias when alias is empty
let keyStrings = extractKeyStringsFromComboCommand(from: command.cmdString)
if (keyStrings == nil) {return false} // in case of non-keyboard command strings, return false
commands.append(command)
saveCommands()
+2 -2
View File
@@ -223,14 +223,14 @@ import UIKit
// ======================================================================================================
@objc public func setLocation(xOffset:CGFloat, yOffset:CGFloat) {
@objc public func setLocation(position: CGPoint) {
/*
NSLayoutConstraint.activate([
self.centerXAnchor.constraint(equalTo: self.superview!.leadingAnchor, constant: xOffset),
self.centerYAnchor.constraint(equalTo: self.superview!.topAnchor, constant: yOffset),
])
*/
storedCenter = CGPointMake(xOffset, yOffset)
storedCenter = position
center = storedCenter
}
+1 -1
View File
@@ -417,7 +417,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
// Add the widgetView to the view controller's view
[self->streamFrameTopLayerView addSubview:widgetView]; // add keyboard button to the stream frame view. must add it to the target view before setting location.
buttonState.position = [self denormalizeWidgetPosition:buttonState.position];
[widgetView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y];
[widgetView setLocationWithPosition:buttonState.position];
[widgetView resizeWidgetView]; // resize must be called after relocation
[widgetView adjustTransparencyWithAlpha:buttonState.backgroundAlpha];
[widgetView adjustBorderWithWidth:buttonState.borderWidth];
@@ -45,7 +45,7 @@
<attribute name="resolutionSelected" optional="YES" attributeType="Integer 16" defaultValueString="5" usesScalarValueType="NO" syncable="YES"/>
<attribute name="reverseMouseWheelDirection" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="showKeyboardToolbar" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="slideToSettingsDistance" optional="YES" attributeType="Float" defaultValueString="0.5" usesScalarValueType="NO" syncable="YES"/>
<attribute name="slideToSettingsDistance" optional="YES" attributeType="Float" defaultValueString="0.25" usesScalarValueType="NO" syncable="YES"/>
<attribute name="slideToSettingsScreenEdge" optional="YES" attributeType="Integer 32" defaultValueString="2" usesScalarValueType="NO" syncable="YES"/>
<attribute name="statsOverlayEnabled" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="statsOverlayLevel" optional="YES" attributeType="Integer 16" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
+185 -47
View File
@@ -53,6 +53,29 @@
}
}
},
"[ Open On-Screen Widget Tool ]" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "[ 打开屏显控件工具 ]"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "[ 打开屏显控件工具 ]"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "[ 打开屏显控件工具 ]"
}
}
}
},
"%@ is currently running" : {
"extractionState" : "manual",
"localizations" : {
@@ -398,6 +421,29 @@
}
}
},
"Command Tool" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "命令工具"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "命令工具"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "命令工具"
}
}
}
},
"Connecting" : {
"extractionState" : "manual",
"localizations" : {
@@ -565,6 +611,29 @@
}
}
},
"Create New" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "新增"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "新增"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "新增"
}
}
}
},
"Current profile updated successfully" : {
"extractionState" : "manual",
"localizations" : {
@@ -749,6 +818,29 @@
}
}
},
"Edit Selected Widget" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "编辑所选控件"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "编辑所选控件"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "编辑所选控件"
}
}
}
},
"Enter a new command and alias" : {
"extractionState" : "manual",
"localizations" : {
@@ -1238,6 +1330,29 @@
}
}
},
"left" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "左"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "左"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "左"
}
}
}
},
"Local Keyboard Toggle Disabled" : {
"extractionState" : "manual",
"localizations" : {
@@ -1342,6 +1457,29 @@
}
}
},
"Modify" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "修改"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "修改"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "修改"
}
}
}
},
"Moonlight-iOS/tvOS only supports adding PCs on your local network" : {
"extractionState" : "manual",
"localizations" : {
@@ -1768,6 +1906,29 @@
}
}
},
"Open widget tool in streaming by:\nSliding from %@ screen edge to open cmd tool.\nOr tap %d fingers on stream view, number of fingers required:" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "在串流视图中修改布局:\n从屏幕%@边缘向内滑动.\n或轻按%d根手指, 手势需要的手指数量:"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "在串流视图中修改布局:\n从屏幕%@边缘向内滑动.\n或轻按%d根手指, 手势需要的手指数量:"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "在串流视图中修改布局:\n从屏幕%@边缘向内滑动.\n或轻按%d根手指, 手势需要的手指数量:"
}
}
}
},
"Pairing" : {
"extractionState" : "manual",
"localizations" : {
@@ -2113,7 +2274,7 @@
}
}
},
"Rebase in Stream View" : {
"Rebase in Streaming" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
@@ -2205,6 +2366,29 @@
}
}
},
"right" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "右"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "右"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "右"
}
}
}
},
"Save" : {
"extractionState" : "manual",
"localizations" : {
@@ -2355,29 +2539,6 @@
}
}
},
"Send Commands" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "发送命令"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "发送命令"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "发送命令"
}
}
}
},
"Sensitivity: %.2f" : {
"extractionState" : "manual",
"localizations" : {
@@ -2539,29 +2700,6 @@
}
}
},
"Tap %d fingers to change layout in stream view, or change the number of fingers required to:" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "在串流视图中轻按%d根手指修改布局, 或将手势需要的手指数量改为:"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "在串流视图中轻按%d根手指修改布局, 或将手势需要的手指数量改为:"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "在串流视图中轻按%d根手指修改布局, 或将手势需要的手指数量改为:"
}
}
}
},
"Tap %d Fingers to Change OSC Layout in Stream View" : {
"extractionState" : "manual",
"localizations" : {
@@ -19,7 +19,11 @@ import UIKit
private let viewBackgroundColor = UIColor(white: 0.2, alpha: 0.8);
private let highlightColor = UIColor(white: 0.39, alpha: 0.8);
private let titleLabel = UILabel()
@objc public var specialEntries : NSMutableArray = ["widgetTool"]
private let specialEntryAliasDic : [String:String] = [
"widgetTool":SwiftLocalizationHelper.localizedString(forKey: "[ Open On-Screen Widget Tool ]")
]
private var viewPinned: Bool = false
private var isEditingMode: Bool = false {
didSet {
@@ -42,9 +46,11 @@ import UIKit
CommandManager.shared.viewController = self
}
override public func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
setupConstraints()
reloadTableView()
}
private func setupViews() {
@@ -54,7 +60,7 @@ import UIKit
view.layer.masksToBounds = true
// Set up the title label
titleLabel.text = SwiftLocalizationHelper.localizedString(forKey: "Send Commands")
titleLabel.text = SwiftLocalizationHelper.localizedString(forKey: "Command Tool")
titleLabel.font = UIFont.boldSystemFont(ofSize: 20) // Adjust font size as needed
titleLabel.textColor = UIColor.white // Adjust color as needed
titleLabel.textAlignment = .center
@@ -96,7 +102,7 @@ import UIKit
private func setupConstraints() {
guard let superview = view.superview else {
guard view.superview != nil else {
return
}
@@ -187,7 +193,7 @@ import UIKit
let submitAction = UIAlertAction(title: SwiftLocalizationHelper.localizedString(forKey: "Add"), style: .default) { [unowned alert] _ in
let keyboardCmdString = alert.textFields?[0].text ?? ""
let alias = alert.textFields?[1].text ?? keyboardCmdString
let newCommand = RemoteCommand(keyboardCmdString: keyboardCmdString, alias: alias)
let newCommand = RemoteCommand(cmdString: keyboardCmdString, alias: alias)
let addCommandSuceeded = CommandManager.shared.addCommand(newCommand)
//self.reloadTableView() // don't know why but this reload has to be called from the CommandManager, it doesn't work here.
@@ -207,8 +213,9 @@ import UIKit
alert.addAction(cancelAction)
if let selectedIndexPath = self.tableView.indexPathForSelectedRow {
let selectedCommand = CommandManager.shared.getAllCommands()[selectedIndexPath.row]
alert.textFields?[0].text = selectedCommand.keyboardCmdString // load selected keyboard cmd string
if isSpecialEntrySelected() {return}
let selectedCommand = CommandManager.shared.getAllCommands()[selectedIndexPath.row-specialEntries.count]
alert.textFields?[0].text = selectedCommand.cmdString // load selected keyboard cmd string
//alert.textFields?[1].text = selectedCommand.alias // leave the alias input field empty
}
@@ -220,9 +227,12 @@ import UIKit
guard let selectedIndexPath = tableView.indexPathForSelectedRow else {
return
}
if isSpecialEntrySelected() {return}
let previouslySelectedIndexPath = selectedIndexPath // memorize selected row before reloading tableview
CommandManager.shared.deleteCommand(at: selectedIndexPath.row)
CommandManager.shared.deleteCommand(at: selectedIndexPath.row-specialEntries.count)
reloadTableView()
// target new entry after deletion
var targetRowAfterDel = previouslySelectedIndexPath.row - 1
@@ -235,6 +245,8 @@ import UIKit
@objc private func editButtonTapped() {
isEditingMode.toggle()
deleteButton.isEnabled = !isSpecialEntrySelected()
addButton.isEnabled = !isSpecialEntrySelected()
}
@objc private func exitButtonTapped() {
@@ -257,7 +269,7 @@ import UIKit
// UITableViewDataSource
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return CommandManager.shared.getAllCommands().count
return specialEntries.count + CommandManager.shared.getAllCommands().count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -271,9 +283,14 @@ import UIKit
let selectedBackgroundView = UIView()
selectedBackgroundView.backgroundColor = highlightColor // Color for the selected state
cell.selectedBackgroundView = selectedBackgroundView
let command = CommandManager.shared.getAllCommands()[indexPath.row]
cell.textLabel?.text = command.alias
if indexPath.row < specialEntries.count {
cell.textLabel?.text = specialEntryAliasDic[specialEntries[indexPath.row] as! String]
}
else {
let command = CommandManager.shared.getAllCommands()[indexPath.row-specialEntries.count]
cell.textLabel?.text = command.alias
}
return cell
}
@@ -292,18 +309,41 @@ import UIKit
}
}
}
if !isEditingMode {
// Sending keyboard command
let command = CommandManager.shared.getAllCommands()[indexPath.row]
sendKeyboardCommand(command)
if indexPath.row < specialEntries.count{
handleSpecialEntries(index: indexPath.row)
}
else {
let command = CommandManager.shared.getAllCommands()[indexPath.row-specialEntries.count]
sendKeyboardCommand(command)
}
if !viewPinned { dismiss(animated: false, completion: nil) } // dimiss the view in sending mode & the view is not pinned
}
else {
let specialEntrySelected = indexPath.row < specialEntries.count
addButton.isEnabled = !specialEntrySelected
deleteButton.isEnabled = !specialEntrySelected
}
}
private func isSpecialEntrySelected() -> Bool {
return self.tableView.indexPathForSelectedRow?.row ?? specialEntries.count+1 < specialEntries.count
}
private func handleSpecialEntries(index:Int){
switch specialEntries[index] as? String {
case "widgetTool":
dismiss(animated: true, completion: nil)
NotificationCenter.default.post(name: Notification.Name("OscLayoutToolOpenedFromCmdToolNotification"),object: nil) // inform streamFrameViewController to open osc tool
default: break
}
}
private func sendKeyboardCommand(_ cmd: RemoteCommand) {
print("Sending key-value")
let keyboardCmdStrings = CommandManager.shared.extractKeyStringsFromComboCommand(from: cmd.keyboardCmdString)
let keyboardCmdStrings = CommandManager.shared.extractKeyStringsFromComboCommand(from: cmd.cmdString)
CommandManager.shared.sendKeyComboCommand(keyboardCmdStrings: keyboardCmdStrings!)
}
}
@@ -3,7 +3,8 @@
// Moonlight
//
// Created by Long Le on 9/27/22.
// Copyright © 2022 Moonlight Game Streaming Project. All rights reserved.
// Modified by True砖家 since 2024.6.24
// Copyright © True砖家 @ Bilibili & 2022 Moonlight Game Streaming Project. All rights reserved.
//
#import <UIKit/UIKit.h>
@@ -3,7 +3,8 @@
// Moonlight
//
// Created by Long Le on 9/27/22.
// Copyright © 2022 Moonlight Game Streaming Project. All rights reserved.
// Modified by True砖家 since 2024.6.24
// Copyright © True砖家 @ Bilibili & 2022 Moonlight Game Streaming Project. All rights reserved.
//
#import "LayoutOnScreenControlsViewController.h"
@@ -110,7 +111,7 @@
// Add the widgetView to the view controller's view
[self.view addSubview:widgetView];
buttonState.position = [self denormalizeWidgetPosition:buttonState.position];
[widgetView setLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y];
[widgetView setLocationWithPosition:buttonState.position];
[widgetView resizeWidgetView]; // resize must be called after relocation
[widgetView adjustTransparencyWithAlpha:buttonState.backgroundAlpha];
[widgetView adjustBorderWithWidth:buttonState.borderWidth];
@@ -119,7 +120,6 @@
}
}
- (void) viewDidLoad {
[super viewDidLoad];
profilesManager = [OSCProfilesManager sharedManager:self.view.bounds];
@@ -230,6 +230,7 @@
- (void) viewDidAppear:(BOOL)animated {
OnScreenWidgetView.editMode = true;
selectedWidgetView = nil;
[super viewWillAppear:animated];
[self profileRefresh];
}
@@ -368,6 +369,8 @@
- (IBAction) addTapped:(id)sender{
NSMutableDictionary* widgetInitParams = [NSMutableDictionary dictionary];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@""]
message:[LocalizationHelper localizedStringForKey:@"New On-Screen Widget"]
preferredStyle:UIAlertControllerStyleAlert];
@@ -418,54 +421,11 @@
UIAlertAction *okAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"OK"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
/*
alertController.textFields[0].keyboardType = UIKeyboardTypeASCIICapable;
alertController.textFields[0].autocorrectionType = UITextAutocorrectionTypeNo;
alertController.textFields[0].spellCheckingType = UITextSpellCheckingTypeNo;
alertController.textFields[1].keyboardType = UIKeyboardTypeASCIICapable;
alertController.textFields[1].autocorrectionType = UITextAutocorrectionTypeNo;
alertController.textFields[1].spellCheckingType = UITextSpellCheckingTypeNo;*/
NSString *cmdString = [alertController.textFields[0].text uppercaseString]; // convert to uppercase
NSString *buttonLabel = alertController.textFields[1].text;
NSString *minStickOffsetString = alertController.textFields[2].text;
NSString *widgetShape = [alertController.textFields[3].text lowercaseString];
if([buttonLabel isEqualToString:@""]) buttonLabel = [[cmdString lowercaseString] capitalizedString];
bool noValidKeyboardString = [CommandManager.shared extractKeyStringsFromComboCommandFrom:cmdString] == nil; // this is a invalid string.
bool noValidSuperComboButtonString = [CommandManager.shared extractSinglCmdStringsFromComboKeysFrom:cmdString] == nil; // this is a invalid string.
bool noValidMouseButtonString = ![CommandManager.mouseButtonMappings.allKeys containsObject:cmdString];
bool noValidTouchPadString = ![CommandManager.touchPadCmds containsObject:cmdString];
bool noValidOscButtonString = ![CommandManager.oscButtonMappings.allKeys containsObject:cmdString];
bool noValidSpecialButtonString = ![CommandManager.specialOverlayButtonCmds containsObject:cmdString];
bool invalidInput = noValidKeyboardString && noValidMouseButtonString && noValidTouchPadString && noValidOscButtonString && noValidSpecialButtonString && noValidSuperComboButtonString;
if([widgetShape isEqualToString:@"r"]) widgetShape = @"round";
else if([widgetShape isEqualToString:@"s"]) widgetShape = @"square";
else if([widgetShape isEqualToString:@""]) widgetShape = @"default";
else invalidInput = true;
NSCharacterSet *nonDigitCharacterSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
NSString *trimmedString = [minStickOffsetString stringByTrimmingCharactersInSet:nonDigitCharacterSet];
if(trimmedString.length != minStickOffsetString.length) invalidInput = true;
minStickOffsetString = trimmedString;
if(invalidInput) {
[self presentInvalidWidgetCommandAlert];
return;
}
//saving & present the keyboard button:
OnScreenWidgetView* widgetView = [[OnScreenWidgetView alloc] initWithCmdString:cmdString buttonLabel:buttonLabel shape:widgetShape];
widgetView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place
widgetView.minStickOffset = [minStickOffsetString floatValue];
[self.OnScreenWidgetViews addObject:widgetView];
// Add the widgetView to the view controller's view
[self.view addSubview:widgetView];
[widgetView setLocationWithXOffset:50 yOffset:50];
[widgetView resizeWidgetView];
[widgetInitParams setObject: alertController.textFields[0].text forKey:@"cmdString"]; // convert to uppercase
[widgetInitParams setObject: alertController.textFields[1].text forKey:@"buttonLabel"]; // convert to uppercase
[widgetInitParams setObject: alertController.textFields[2].text forKey:@"minStickOffsetString"]; // convert to uppercase
[widgetInitParams setObject: alertController.textFields[3].text forKey:@"shape"]; // convert to uppercase
[self createWidgetFromParams:widgetInitParams];
}];
[alertController addAction:readInstruction];
[alertController addAction:cancelAction];
@@ -474,6 +434,146 @@
}
- (IBAction) editTapped:(id)sender{
NSMutableDictionary* widgetInitParams = [NSMutableDictionary dictionary];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@""]
message:[LocalizationHelper localizedStringForKey:@"Edit Selected Widget"]
preferredStyle:UIAlertControllerStyleAlert];
if(self->selectedWidgetView == nil) return;
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Command"];
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.text = [self->selectedWidgetView.cmdString lowercaseString];
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Alias label (optional)"];
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.text = self->selectedWidgetView.buttonLabel;
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Minimum stick offset (0~32766)"];
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
if(self->selectedWidgetView.minStickOffset > 0) textField.text = [NSString stringWithFormat:@"%d", (int)self->selectedWidgetView.minStickOffset];
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = [LocalizationHelper localizedStringForKey:@"Shape (r - round, s - square)"];
textField.keyboardType = UIKeyboardTypeASCIICapable;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.spellCheckingType = UITextSpellCheckingTypeNo;
textField.text = self->selectedWidgetView.shape;
if([self->selectedWidgetView.shape isEqualToString: @"largeSquare"]) textField.enabled = false;
}];
UIAlertAction *createNewAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Create New"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[widgetInitParams setObject: alertController.textFields[0].text forKey:@"cmdString"];
[widgetInitParams setObject: alertController.textFields[1].text forKey:@"buttonLabel"];
[widgetInitParams setObject: alertController.textFields[2].text forKey:@"minStickOffsetString"];
[widgetInitParams setObject: alertController.textFields[3].text forKey:@"shape"];
[self updateWidget:self->selectedWidgetView byParams:widgetInitParams createNew:true];
}];
UIAlertAction *modifyAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Modify"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[widgetInitParams setObject: alertController.textFields[0].text forKey:@"cmdString"];
[widgetInitParams setObject: alertController.textFields[1].text forKey:@"buttonLabel"];
[widgetInitParams setObject: alertController.textFields[2].text forKey:@"minStickOffsetString"];
[widgetInitParams setObject: alertController.textFields[3].text forKey:@"shape"];
[self updateWidget:self->selectedWidgetView byParams:widgetInitParams createNew:false];
}];
[alertController addAction:createNewAction];
[alertController addAction:modifyAction];
[self presentViewController:alertController animated:YES completion:nil];
}
- (bool) isWidgetParamsValid:(NSMutableDictionary* )widgetInitParams{
NSString *cmdString = [widgetInitParams[@"cmdString"] uppercaseString]; // convert to uppercase
NSString *buttonLabel = widgetInitParams[@"buttonLabel"];
NSString *minStickOffsetString = widgetInitParams[@"minStickOffsetString"];
NSString *widgetShape = [widgetInitParams[@"shape"] lowercaseString];
widgetInitParams[@"cmdString"] = cmdString;
bool noValidKeyboardString = [CommandManager.shared extractKeyStringsFromComboCommandFrom:cmdString] == nil; // this is a invalid string.
bool noValidSuperComboButtonString = [CommandManager.shared extractSinglCmdStringsFromComboKeysFrom:cmdString] == nil; // this is a invalid string.
bool noValidMouseButtonString = ![CommandManager.mouseButtonMappings.allKeys containsObject:cmdString];
bool noValidTouchPadString = ![CommandManager.touchPadCmds containsObject:cmdString];
bool noValidOscButtonString = ![CommandManager.oscButtonMappings.allKeys containsObject:cmdString];
bool noValidSpecialButtonString = ![CommandManager.specialOverlayButtonCmds containsObject:cmdString];
bool paramInvalid = noValidKeyboardString && noValidMouseButtonString && noValidTouchPadString && noValidOscButtonString && noValidSpecialButtonString && noValidSuperComboButtonString;
if([buttonLabel isEqualToString:@""]) widgetInitParams[@"buttonLabel"] = [[cmdString lowercaseString] capitalizedString];
NSCharacterSet *nonDigitCharacterSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
NSString *trimmedString = [minStickOffsetString stringByTrimmingCharactersInSet:nonDigitCharacterSet];
if(trimmedString.length != minStickOffsetString.length) paramInvalid = true;
widgetInitParams[@"minStickOffsetString"] = trimmedString;
NSSet* validShapes = [NSSet setWithObjects:@"round", @"square", @"largesquare", nil];
if([widgetShape isEqualToString:@"r"]) widgetShape = @"round";
else if([widgetShape isEqualToString:@"s"]) widgetShape = @"square";
else if([widgetShape isEqualToString:@""]) widgetShape = @"default";
else if(![validShapes containsObject:widgetShape]){
paramInvalid = true;}
widgetInitParams[@"shape"] = widgetShape;
if(paramInvalid) [self presentInvalidWidgetCommandAlert];
return !paramInvalid;
}
- (void) updateWidget:(OnScreenWidgetView* )widget byParams:(NSMutableDictionary* )widgetInitParams createNew:(bool)createNew{
if(![self isWidgetParamsValid:widgetInitParams]) return;
OnScreenWidgetView* newWidget = [[OnScreenWidgetView alloc] initWithCmdString:widgetInitParams[@"cmdString"] buttonLabel:widgetInitParams[@"buttonLabel"] shape:widgetInitParams[@"shape"]]; //reconstruct widgetView
newWidget.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place
newWidget.widthFactor = widget.widthFactor;
newWidget.heightFactor = widget.heightFactor;
newWidget.borderWidth = widget.borderWidth;
newWidget.sensitivityFactor = widget.sensitivityFactor;
newWidget.stickIndicatorOffset = widget.stickIndicatorOffset;
newWidget.minStickOffset = [widgetInitParams[@"minStickOffsetString"] floatValue];
// Add the widgetView to the view controller's view
[self.view addSubview:newWidget];
if(createNew) [newWidget setLocationWithPosition:CGPointMake(50, 50)];
else [newWidget setLocationWithPosition:widget.center];
[newWidget resizeWidgetView]; // resize must be called after relocation
[newWidget adjustTransparencyWithAlpha:widget.backgroundAlpha];
[newWidget adjustBorderWithWidth:widget.borderWidth];
if(!createNew) [self.OnScreenWidgetViews removeObject:widget];
[self.OnScreenWidgetViews addObject:newWidget];
if(!createNew) [widget removeFromSuperview];
self->selectedWidgetView = newWidget;
}
- (void) createWidgetFromParams: (NSMutableDictionary*) widgetInitParams{
if(![self isWidgetParamsValid:widgetInitParams]) return;
//saving & present the keyboard button:
OnScreenWidgetView* widgetView = [[OnScreenWidgetView alloc] initWithCmdString:widgetInitParams[@"cmdString"] buttonLabel:widgetInitParams[@"buttonLabel"] shape:widgetInitParams[@"shape"]];
widgetView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place
widgetView.minStickOffset = [widgetInitParams[@"minStickOffsetString"] floatValue];
[self.OnScreenWidgetViews addObject:widgetView];
// Add the widgetView to the view controller's view
[self.view addSubview:widgetView];
[widgetView setLocationWithPosition:CGPointMake(50, 50)];
[widgetView resizeWidgetView];
}
/* show pop up notification that lets users choose to save the current OSC layout configuration as a profile they can load when they want. User can also choose to cancel out of this pop up */
- (IBAction) saveTapped:(id)sender {
@@ -602,8 +602,9 @@ BOOL isCustomResolution(CGSize res) {
}
- (void)showCustomOSCTip {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@"Rebase in Stream View"]
message:[LocalizationHelper localizedStringForKey:@"Tap %d fingers to change layout in stream view, or change the number of fingers required to:", self->oscLayoutFingers]
NSString* edgeSide = self.slideToSettingsScreenEdgeSelector.selectedSegmentIndex == 1 ? [LocalizationHelper localizedStringForKey:@"left"] : [LocalizationHelper localizedStringForKey:@"right"];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@"Rebase in Streaming"]
message:[LocalizationHelper localizedStringForKey:@"Open widget tool in streaming by:\nSliding from %@ screen edge to open cmd tool.\nOr tap %d fingers on stream view, number of fingers required:", edgeSide, self->oscLayoutFingers]
preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
@@ -612,7 +613,7 @@ BOOL isCustomResolution(CGSize res) {
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Cancel"]
style:UIAlertActionStyleCancel
style:UIAlertActionStyleDefault
handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"OK"]
@@ -70,6 +70,7 @@
CustomEdgeSlideGestureRecognizer *_slideToCmdToolRecognizer;
CustomTapGestureRecognizer *_oscLayoutTapRecoginizer;
LayoutOnScreenControlsViewController *_layoutOnScreenControlsVC;
CommandManagerViewController* cmdManViewController;
#endif
}
@@ -79,6 +80,7 @@
- (void)configOscLayoutTool{
if([self isOscLayoutToolEnabled]){
if(![cmdManViewController.specialEntries containsObject:@"widgetTool"]) [cmdManViewController.specialEntries insertObject:@"widgetTool" atIndex:0];
_oscLayoutTapRecoginizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(layoutOSC)];
_oscLayoutTapRecoginizer.numberOfTouchesRequired = _settings.oscLayoutToolFingers.intValue; //tap a predefined number of fingers to open osc layout tool
_oscLayoutTapRecoginizer.tapDownTimeThreshold = 0.2;
@@ -102,10 +104,10 @@
_layoutOnScreenControlsVC.view.backgroundColor = UIColor.clearColor;
_layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
}
else [cmdManViewController.specialEntries removeObject:@"widgetTool"];
}
- (void)presentCommandManagerViewController{
CommandManagerViewController* cmdManViewController = [[CommandManagerViewController alloc] init];
[self presentViewController:cmdManViewController animated:YES completion:nil];
}
@@ -240,7 +242,11 @@
selector:@selector(expandSettingsView) // //force expand settings view to update resolution table, and all setting includes current fullscreen resolution will be updated.
name:@"SettingsOverlayButtonPressedNotification"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(layoutOSC) // //force expand settings view to update resolution table, and all setting includes current fullscreen resolution will be updated.
name:@"OscLayoutToolOpenedFromCmdToolNotification"
object:nil];
#endif
}
@@ -291,6 +297,8 @@
_streamView = [[StreamView alloc] initWithFrame:self.view.frame];
cmdManViewController = [[CommandManagerViewController alloc] init];
/*
_settings.externalDisplayMode.intValue:
0 - stage manager
+24 -12
View File
@@ -721,18 +721,6 @@
}
}
},
"bMH-Yb-sb6.normalTitle" : {
"comment" : "Class = \"UIButton\"; normalTitle = \"+\"; ObjectID = \"bMH-Yb-sb6\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "+"
}
}
}
},
"bw9-4S-s2V.segmentTitles[0]" : {
"comment" : "Class = \"UISegmentedControl\"; bw9-4S-s2V.segmentTitles[0] = \"No\"; ObjectID = \"bw9-4S-s2V\";",
"extractionState" : "stale",
@@ -1417,6 +1405,18 @@
}
}
},
"fKN-ja-TRi.normalTitle" : {
"comment" : "Class = \"UIButton\"; normalTitle = \"Add\"; ObjectID = \"fKN-ja-TRi\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Add"
}
}
}
},
"FwK-oG-vuz.text" : {
"comment" : "Class = \"UILabel\"; text = \"Reverse Wheel Direction for Physical Mouse \"; ObjectID = \"FwK-oG-vuz\";",
"extractionState" : "extracted_with_value",
@@ -3127,6 +3127,18 @@
}
}
},
"R45-lM-YPl.normalTitle" : {
"comment" : "Class = \"UIButton\"; normalTitle = \"Edit\"; ObjectID = \"R45-lM-YPl\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Edit"
}
}
}
},
"RRk-03-hIr.segmentTitles[0]" : {
"comment" : "Class = \"UISegmentedControl\"; RRk-03-hIr.segmentTitles[0] = \"No\"; ObjectID = \"RRk-03-hIr\";",
"extractionState" : "extracted_with_value",
+24
View File
@@ -301,6 +301,18 @@
}
}
},
"4pE-po-Zn1.normalTitle" : {
"comment" : "Class = \"UIButton\"; normalTitle = \"Edit\"; ObjectID = \"4pE-po-Zn1\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Edit"
}
}
}
},
"4Qy-hB-oa5.text" : {
"comment" : "Class = \"UILabel\"; text = \"External Display Mode\"; ObjectID = \"4Qy-hB-oa5\";",
"extractionState" : "extracted_with_value",
@@ -2329,6 +2341,18 @@
}
}
},
"Up4-28-sgF.normalTitle" : {
"comment" : "Class = \"UIButton\"; normalTitle = \"Add\"; ObjectID = \"Up4-28-sgF\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Add"
}
}
}
},
"VGn-Oc-mKc.text" : {
"comment" : "Class = \"UILabel\"; text = \"Local Mouse Pointer\"; ObjectID = \"VGn-Oc-mKc\";",
"extractionState" : "extracted_with_value",