This commit is contained in:
workinghard
2015-05-10 00:09:50 -07:00
parent 1b6228ad7b
commit 736560ffdd
5 changed files with 50 additions and 9 deletions

View File

@@ -149,6 +149,11 @@
<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"/>

View File

@@ -188,6 +188,7 @@ class Animations: NSObject {
_animationArray.removeAtIndex(_animationSelected) _animationArray.removeAtIndex(_animationSelected)
if ( _animationSelected == 0 && _animationArray.count == 0 ) { // last Frame if ( _animationSelected == 0 && _animationArray.count == 0 ) { // last Frame
self.addAnimation() self.addAnimation()
self.setSelectedAnimationID(self.getSelectedAnimationID()-1)
} }
} }
func moveUpSelected() { func moveUpSelected() {
@@ -205,7 +206,7 @@ class Animations: NSObject {
func addAnimation() { func addAnimation() {
_animationArray.append(self.newAnimation()) _animationArray.append(self.newAnimation())
println("append Animation count: \(_animationArray.count)") println("append Animation. count: \(_animationArray.count)")
} }
func newAnimation() -> (NSMutableDictionary) { func newAnimation() -> (NSMutableDictionary) {
println("create new animation") println("create new animation")
@@ -226,20 +227,40 @@ class Animations: NSObject {
myData.length = myLength - 64 // remove one frame myData.length = myLength - 64 // remove one frame
} }
} }
/*
func insertDisplFrame() { func insertDisplFrame() {
// Insert empty frame at the current position
// Get Array // Get Array
// var myData = self.getAnimDataSelected()
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 myData: [UInt8] = [UInt8]() //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
// Insert empty frame at this position
for index in 0...64 { // Append one empty frame at the end
myData.insert(_emptyFrame[index], atIndex: frameStartPos) self.addFrame()
var lastArrPos: Int = myData.length - 1
println("Framestart: \(frameStartPos)")
println("Framelength: \(lastArrPos)")
// copy frames
while ( lastArrPos >= frameStartPos + 64) {
// myDataBytes[lastArrPos] = myDataBytes[lastArrPos-64]
let myByte: [UInt8] = [myDataBytes[lastArrPos-64]]
let bytePosition = NSMakeRange(lastArrPos, 1)
myData.replaceBytesInRange(bytePosition, withBytes: myByte)
--lastArrPos
} }
// clear current frame
self.clearLEDColor()
} }
/*
func deleteDisplFrame() { func deleteDisplFrame() {
// Get Array // Get Array
let myData = self.getAnimDataSelected() let myData = self.getAnimDataSelected()
@@ -252,6 +273,7 @@ class Animations: NSObject {
*/ */
func animationSpeedInt() -> Int { func animationSpeedInt() -> Int {
let frameSpeed: Int = (self.getAnimation(_animationSelected)).objectForKey(AnimSpeed) as! Int let frameSpeed: Int = (self.getAnimation(_animationSelected)).objectForKey(AnimSpeed) as! Int
return frameSpeed return frameSpeed

View File

@@ -87,6 +87,7 @@ class AnimationsController: NSObject, NSTableViewDataSource, NSTableViewDelegate
func tableViewSelectionDidChange(notification: NSNotification) { func tableViewSelectionDidChange(notification: NSNotification) {
let view: NSTableView = notification.object as! NSTableView let view: NSTableView = notification.object as! NSTableView
println("klicked \(view.selectedRow)")
__animations.setSelectedAnimationID(view.selectedRow) __animations.setSelectedAnimationID(view.selectedRow)
_gameView.resetView() _gameView.resetView()
@@ -96,7 +97,7 @@ class AnimationsController: NSObject, NSTableViewDataSource, NSTableViewDelegate
//_selectedAnimation = view.selectedRow //_selectedAnimation = view.selectedRow
//println("klicked \(view.selectedRow)") println("klicked \(view.selectedRow)")
} }
func tableView(tableView: NSTableView, setObjectValue object: AnyObject?, forTableColumn tableColumn: NSTableColumn?, row: Int) { func tableView(tableView: NSTableView, setObjectValue object: AnyObject?, forTableColumn tableColumn: NSTableColumn?, row: Int) {
@@ -135,6 +136,7 @@ class AnimationsController: NSObject, NSTableViewDataSource, NSTableViewDelegate
@IBAction func delNewAnimation(sender: AnyObject) { @IBAction func delNewAnimation(sender: AnyObject) {
__animations.deleteSelected() __animations.deleteSelected()
myTableView.selectRowIndexes(NSIndexSet(index: __animations.getSelectedAnimationID()-1), byExtendingSelection: false)
myTableView.reloadData() myTableView.reloadData()
} }

View File

@@ -175,4 +175,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSTextFieldDelegate {
__animations.sendFrame() __animations.sendFrame()
} }
@IBAction func cmdInsertPressed(send: AnyObject) {
// Insert one new frame at the current position
__animations.insertDisplFrame()
// Update visual
_gameView.updateLEDFrame()
_gameView.updateButtonVisibility()
// Update on a hardware
__animations.sendFrame()
}
} }

View File

@@ -193,6 +193,8 @@ class GameView: SCNView {
// remove one frame from the data array // remove one frame from the data array
// TODO! // TODO!
self.prevButtonPressed()
// Remove frame // Remove frame
__animations.removeFrame() __animations.removeFrame()
// if __animations.getAnimationFrameCount() > 1 { // if __animations.getAnimationFrameCount() > 1 {