Skip to content

Commit

Permalink
index saving and rift only for playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
obviousjim committed Mar 6, 2014
1 parent 09a7c64 commit 0a339c3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 119 deletions.
1 change: 1 addition & 0 deletions CloudsVisualSystemPlaylist/src/testView.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
bool isPlayingPlaylist;
bool shouldPlayPlaylist;
int playlistIndex;
vector<int> riftIndeces;

float maxSystemDuration;
float systemStartTime;
Expand Down
166 changes: 47 additions & 119 deletions CloudsVisualSystemPlaylist/src/testView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,60 @@ - (void)setup

visualSystems.loadPresets();
visualSystems.loadCachedDataForSystems();

for(int i = 0; i < visualSystems.getPresets().size(); i++){
if(visualSystems.getPresets()[i].enabledOculus){
riftIndeces.push_back(i);
}
}

[presetTable setTarget:self];
[presetTable setDoubleAction:@selector(playPlaylist:)];
[presetTable reloadData];

maxSystemDuration = 35.0;
maxSystemDuration = 50.0;

mixer.setup();
mixer.setDiageticVolume(1);


string path = "index_save.txt";
if(ofFile(path).exists()){
ofBuffer b = ofBufferFromFile(path);
NSMutableIndexSet* set = [NSMutableIndexSet indexSet];

vector<string> components = ofSplitString(b.getText(), ",");
for(int i = 0; i < components.size(); i++){
[set addIndex:ofToInt(components[i])];
}
[presetTable selectRowIndexes:set byExtendingSelection:NO];
}
}


- (IBAction) playPlaylist:(id)sender
{
shouldPlayPlaylist = true;

//save a file of indices
vector<string> indeces;

NSUInteger idx = [presetTable.selectedRowIndexes firstIndex];
while (idx != NSNotFound) {
indeces.push_back( ofToString(idx) );
idx = [presetTable.selectedRowIndexes indexGreaterThanIndex:idx];
}

ofBuffer buf(ofJoinString(indeces, ","));
string path = "index_save.txt";
ofBufferToFile(path, buf);

}

- (void)update
{

if(shouldPlayPlaylist){

isPlayingPlaylist = false;
shouldPlayPlaylist = false;
playlist.clear();
currentVisualSystem = NULL;
Expand All @@ -44,7 +75,7 @@ - (void)update
NSUInteger idx = [presetTable.selectedRowIndexes firstIndex];
while (idx != NSNotFound) {

CloudsVisualSystemPreset& preset = visualSystems.getPresets()[ idx ];
CloudsVisualSystemPreset& preset = visualSystems.getPresets()[ riftIndeces[idx] ];
CloudsVisualSystem* system = CloudsVisualSystemManager::InstantiateSystem( preset.systemName ) ;
if(system == NULL){
continue;
Expand Down Expand Up @@ -73,114 +104,6 @@ - (void)update
}
}

/*
if(runningTest){
if(ofGetElapsedTimef() - lastSystemStartTime > 1){
if(currentVisualSystem != NULL){
cout << "5) (" << currentTestPresetIndex << "/" << testPresetIndeces.size() << ") STOPPING SYSTEM " << currentVisualSystem->getSystemName() << endl;
currentVisualSystem->stopSystem();
}
if(testBatchIndex == testBatch.size() || testBatch.size() == 0){
for(int i = 0; i < testBatch.size(); i++){
cout << "5) CALLING EXIT " << testBatch[i]->getSystemName() << endl;
testBatch[i]->exit();
}
cout << "DELETING PRESET BATCH" << endl;
testBatch.clear();
currentVisualSystem = NULL;
int i = 0;
for(i = currentTestPresetIndex; i < MIN(testPresetIndeces.size(),currentTestPresetIndex+2); i++){
CloudsVisualSystemPreset& preset = visualSystems.getPresets()[ testPresetIndeces[i] ];
cout << "******* 1) (" << i << "/" << testPresetIndeces.size() << ") INSTANTIATING " << preset.systemName << " : " << preset.presetName << endl;
CloudsVisualSystem* vs = CloudsVisualSystemManager::InstantiateSystem( preset.systemName );
cout << "******* 2) (" << i << "/" << testPresetIndeces.size() << ") SETTING UP " << preset.systemName << " : " << preset.presetName << endl;
if(vs == NULL){
cout << "******* 3) (" << i << "/" << testPresetIndeces.size() << ") PRESET NOT REGISTERED " << preset.systemName << " : " << preset.presetName << endl;
continue;
}
vs->setup();
cout << "******* 3) (" << i << "/" << testPresetIndeces.size() << ") LOADING PRESET " << preset.systemName << " : " << preset.presetName << endl;
vs->loadPresetGUISFromName(preset.presetName);
testBatch.push_back(vs);
}
if(i == testPresetIndeces.size()){
runningTest = false;
}
testBatchIndex = 0;
}
if(testBatchIndex < testBatch.size()){
currentVisualSystem = testBatch[testBatchIndex];
cout << "4) PLAYING SYSTEM " << currentVisualSystem->getSystemName() << endl;
currentVisualSystem->playSystem();
lastSystemStartTime = ofGetElapsedTimef();
testBatchIndex++;
currentTestPresetIndex++;
if(currentTestPresetIndex == testPresetIndeces.size()-1){
cout<<"TEST COMPLETE : Reshufling and looping test"<<endl;
currentTestPresetIndex = 0;
random_shuffle(testPresetIndeces.begin(), testPresetIndeces.end());
}
}
}
}
else if(shouldPlaySelectedRow){
if(currentVisualSystem != NULL){
currentVisualSystem->stopSystem();
currentVisualSystem->exit();
currentVisualSystem = NULL;
}
cout << "loading system " << visualSystems.getPresets()[ self.selectedPresetIndex ].systemName << " preset " << visualSystems.getPresets()[self.selectedPresetIndex].presetName << endl;
visualSystems.DeallocateSystems();
currentVisualSystem = CloudsVisualSystemManager::InstantiateSystem( visualSystems.getPresets()[ self.selectedPresetIndex ].systemName );
///SCREENCAPTURE MODE
currentVisualSystem->setNumSamples(4);
currentVisualSystem->forceScreenResolution(1920, 1080);
currentVisualSystem->setDrawToScreen(false);
/////
if(currentVisualSystem != NULL){
currentVisualSystem->setup();
string presetName = visualSystems.getPresets()[ self.selectedPresetIndex ].presetName;
if(presetName == "+New Preset"){
currentVisualSystem->loadPresetGUISFromName("");
}
else if(presetName == "+Current State"){
currentVisualSystem->loadPresetGUISFromName("Working");
}
else {
currentVisualSystem->loadPresetGUISFromName(presetName);
}
currentVisualSystem->playSystem();
}
else{
ofSystemAlertDialog(visualSystems.getPresets()[self.selectedPresetIndex].systemName + " is not registered system");
}
shouldPlaySelectedRow = false;
}
*/

}

- (void)draw
Expand All @@ -200,7 +123,7 @@ - (void) gotoNextSystem

playlistIndex++;

if(playlistIndex == playlist.size()){
if(playlistIndex >= playlist.size()){
//restart the same playlist
shouldPlayPlaylist = true;
}
Expand Down Expand Up @@ -242,7 +165,9 @@ - (void)mouseDragged:(NSPoint)p button:(int)button

- (void)mousePressed:(NSPoint)p button:(int)button
{
[self gotoNextSystem];
if(isPlayingPlaylist){
[self gotoNextSystem];
}
}

- (void)mouseReleased:(NSPoint)p button:(int)button
Expand All @@ -257,17 +182,23 @@ - (void)windowResized:(NSSize)size

- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return visualSystems.getPresets().size();
// return visualSystems.getPresets().size();
return riftIndeces.size();
}

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{

int presetIndex = rowIndex;
// int presetIndex = rowIndex;
int presetIndex = riftIndeces[rowIndex];

if([@"system" isEqualToString:aTableColumn.identifier]){
return [NSString stringWithUTF8String: visualSystems.getPresets()[presetIndex].systemName.c_str()];
}
else if([@"preset" isEqualToString:aTableColumn.identifier]){
return [NSString stringWithUTF8String: visualSystems.getPresets()[presetIndex].presetName.c_str()];
}

// else if([@"grade" isEqualToString:aTableColumn.identifier]){
// return [NSString stringWithUTF8String:
// (string(visualSystems.getPresets()[presetIndex].hasFiles ? "" : "!!") +
Expand All @@ -277,9 +208,6 @@ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColu
// (visualSystems.getPresets()[presetIndex].hasSound() ? "Snd" : "")
// ).c_str()];
// }
else if([@"preset" isEqualToString:aTableColumn.identifier]){
return [NSString stringWithUTF8String: visualSystems.getPresets()[presetIndex].presetName.c_str()];
}
// else if( [@"keywords" isEqualToString:aTableColumn.identifier] ){
// return [NSString stringWithUTF8String: ofJoinString( visualSystems.keywordsForPreset(presetIndex), ",").c_str() ];
// }
Expand Down

0 comments on commit 0a339c3

Please sign in to comment.