mirror of
https://github.com/workinghard/Cube4Fun.git
synced 2025-12-14 04:42:09 +00:00
Delete and insert frame in the middle
This commit is contained in:
@@ -149,11 +149,6 @@
|
|||||||
<action selector="cut:" target="-1" id="228"/>
|
<action selector="cut:" target="-1" id="228"/>
|
||||||
</connections>
|
</connections>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
<menuItem title="Insert" keyEquivalent="i" id="QIf-r2-Qbo" userLabel="Insert">
|
|
||||||
<connections>
|
|
||||||
<action selector="cmdInsertPressed:" target="494" id="i2Y-8n-lla"/>
|
|
||||||
</connections>
|
|
||||||
</menuItem>
|
|
||||||
<menuItem title="Copy" keyEquivalent="c" id="197">
|
<menuItem title="Copy" keyEquivalent="c" id="197">
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="cmdCopyPressed:" target="494" id="ncB-O2-9om"/>
|
<action selector="cmdCopyPressed:" target="494" id="ncB-O2-9om"/>
|
||||||
@@ -169,6 +164,16 @@
|
|||||||
<action selector="clearLEDs:" target="494" id="3lJ-Lc-QCa"/>
|
<action selector="clearLEDs:" target="494" id="3lJ-Lc-QCa"/>
|
||||||
</connections>
|
</connections>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
|
<menuItem title="Insert Frame" keyEquivalent="i" id="QIf-r2-Qbo">
|
||||||
|
<connections>
|
||||||
|
<action selector="cmdInsertPressed:" target="494" id="i2Y-8n-lla"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
|
<menuItem title="Delete Frame" keyEquivalent="d" id="JW4-A1-fDy">
|
||||||
|
<connections>
|
||||||
|
<action selector="cmdDeletePressed:" target="494" id="CDU-vU-PaH"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
<menuItem title="Select All" hidden="YES" enabled="NO" keyEquivalent="a" id="198">
|
<menuItem title="Select All" hidden="YES" enabled="NO" keyEquivalent="a" id="198">
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="selectAll:" target="-1" id="232"/>
|
<action selector="selectAll:" target="-1" id="232"/>
|
||||||
|
|||||||
@@ -235,8 +235,6 @@ class Animations: NSObject {
|
|||||||
var myData: NSMutableData = (self.getAnimation(_animationSelected)).objectForKey(AnimFrames) as! NSMutableData
|
var myData: NSMutableData = (self.getAnimation(_animationSelected)).objectForKey(AnimFrames) as! NSMutableData
|
||||||
var myDataBytes = self.getAnimDataSelected()
|
var myDataBytes = self.getAnimDataSelected()
|
||||||
|
|
||||||
|
|
||||||
//var myData: [UInt8] = [UInt8]()
|
|
||||||
// Get startPositions of the selected frame
|
// Get startPositions of the selected frame
|
||||||
var frameStartPos = (self.getAnimationFrameID()-1)*64
|
var frameStartPos = (self.getAnimationFrameID()-1)*64
|
||||||
|
|
||||||
@@ -260,17 +258,34 @@ class Animations: NSObject {
|
|||||||
self.clearLEDColor()
|
self.clearLEDColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func deleteDisplFrame() {
|
func deleteDisplFrame() {
|
||||||
|
println("delete frame")
|
||||||
|
|
||||||
// Get Array
|
// Get Array
|
||||||
let myData = self.getAnimDataSelected()
|
var myData: NSMutableData = (self.getAnimation(_animationSelected)).objectForKey(AnimFrames) as! NSMutableData
|
||||||
|
var myDataBytes = self.getAnimDataSelected()
|
||||||
|
|
||||||
// Get startPositions of the selected frame
|
// Get startPositions of the selected frame
|
||||||
var frameStartPos = (self.getAnimationFrameID()-1)*64
|
var frameStartPos = (self.getAnimationFrameID()-1)*64
|
||||||
for index in 0...64 {
|
|
||||||
myData.removeAtIndex(frameStartPos)
|
var lastArrPos: Int = myData.length - 1 - 64
|
||||||
|
println("Framestart: \(frameStartPos)")
|
||||||
|
println("Framelength: \(lastArrPos)")
|
||||||
|
|
||||||
|
// copy frames (fill deleted frame)
|
||||||
|
while ( frameStartPos <= lastArrPos ) {
|
||||||
|
// myDataBytes[lastArrPos] = myDataBytes[lastArrPos-64]
|
||||||
|
let myByte: [UInt8] = [myDataBytes[frameStartPos+64]]
|
||||||
|
let bytePosition = NSMakeRange(frameStartPos, 1)
|
||||||
|
myData.replaceBytesInRange(bytePosition, withBytes: myByte)
|
||||||
|
++frameStartPos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete last frame
|
||||||
|
myData.length = myData.length - 64
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -185,4 +185,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSTextFieldDelegate {
|
|||||||
// Update on a hardware
|
// Update on a hardware
|
||||||
__animations.sendFrame()
|
__animations.sendFrame()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func cmdDeletePressed(send: AnyObject) {
|
||||||
|
// Check if we have more than one frame
|
||||||
|
if __animations.getAnimationFrameCount() > 1 {
|
||||||
|
__animations.deleteDisplFrame()
|
||||||
|
|
||||||
|
// Update visual
|
||||||
|
_gameView.updateLEDFrame()
|
||||||
|
_gameView.updateButtonVisibility()
|
||||||
|
|
||||||
|
// Update on a hardware
|
||||||
|
__animations.sendFrame()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user