mirror of
https://github.com/workinghard/Cube4Fun.git
synced 2025-12-13 20:32:09 +00:00
a
This commit is contained in:
@@ -149,6 +149,11 @@
|
||||
<action selector="cut:" target="-1" id="228"/>
|
||||
</connections>
|
||||
</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">
|
||||
<connections>
|
||||
<action selector="cmdCopyPressed:" target="494" id="ncB-O2-9om"/>
|
||||
|
||||
@@ -188,6 +188,7 @@ class Animations: NSObject {
|
||||
_animationArray.removeAtIndex(_animationSelected)
|
||||
if ( _animationSelected == 0 && _animationArray.count == 0 ) { // last Frame
|
||||
self.addAnimation()
|
||||
self.setSelectedAnimationID(self.getSelectedAnimationID()-1)
|
||||
}
|
||||
}
|
||||
func moveUpSelected() {
|
||||
@@ -205,7 +206,7 @@ class Animations: NSObject {
|
||||
|
||||
func addAnimation() {
|
||||
_animationArray.append(self.newAnimation())
|
||||
println("append Animation count: \(_animationArray.count)")
|
||||
println("append Animation. count: \(_animationArray.count)")
|
||||
}
|
||||
func newAnimation() -> (NSMutableDictionary) {
|
||||
println("create new animation")
|
||||
@@ -226,20 +227,40 @@ class Animations: NSObject {
|
||||
myData.length = myLength - 64 // remove one frame
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
func insertDisplFrame() {
|
||||
// Insert empty frame at the current position
|
||||
|
||||
// Get Array
|
||||
// var myData = self.getAnimDataSelected()
|
||||
var myData: NSMutableData = (self.getAnimation(_animationSelected)).objectForKey(AnimFrames) as! NSMutableData
|
||||
var myDataBytes = self.getAnimDataSelected()
|
||||
|
||||
|
||||
//var myData: [UInt8] = [UInt8]()
|
||||
// Get startPositions of the selected frame
|
||||
var frameStartPos = (self.getAnimationFrameID()-1)*64
|
||||
// Insert empty frame at this position
|
||||
for index in 0...64 {
|
||||
myData.insert(_emptyFrame[index], atIndex: frameStartPos)
|
||||
}
|
||||
|
||||
// Append one empty frame at the end
|
||||
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() {
|
||||
// Get Array
|
||||
let myData = self.getAnimDataSelected()
|
||||
@@ -249,7 +270,8 @@ class Animations: NSObject {
|
||||
myData.removeAtIndex(frameStartPos)
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
func animationSpeedInt() -> Int {
|
||||
|
||||
@@ -87,6 +87,7 @@ class AnimationsController: NSObject, NSTableViewDataSource, NSTableViewDelegate
|
||||
|
||||
func tableViewSelectionDidChange(notification: NSNotification) {
|
||||
let view: NSTableView = notification.object as! NSTableView
|
||||
println("klicked \(view.selectedRow)")
|
||||
__animations.setSelectedAnimationID(view.selectedRow)
|
||||
|
||||
_gameView.resetView()
|
||||
@@ -96,7 +97,7 @@ class AnimationsController: NSObject, NSTableViewDataSource, NSTableViewDelegate
|
||||
|
||||
//_selectedAnimation = view.selectedRow
|
||||
|
||||
//println("klicked \(view.selectedRow)")
|
||||
println("klicked \(view.selectedRow)")
|
||||
}
|
||||
|
||||
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) {
|
||||
__animations.deleteSelected()
|
||||
myTableView.selectRowIndexes(NSIndexSet(index: __animations.getSelectedAnimationID()-1), byExtendingSelection: false)
|
||||
myTableView.reloadData()
|
||||
}
|
||||
|
||||
|
||||
@@ -175,4 +175,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSTextFieldDelegate {
|
||||
__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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +193,8 @@ class GameView: SCNView {
|
||||
// remove one frame from the data array
|
||||
// TODO!
|
||||
|
||||
self.prevButtonPressed()
|
||||
|
||||
// Remove frame
|
||||
__animations.removeFrame()
|
||||
// if __animations.getAnimationFrameCount() > 1 {
|
||||
|
||||
Reference in New Issue
Block a user