view SequenceController.h @ 45:80112c9349c4

demo mode. FUCKING ORIENTATION SHIT
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 15 Dec 2014 18:54:00 +0000
parents d810aa9ca03a
children 17402059e089
line wrap: on
line source
//
//  SequenceGenerator.h
//  riftathon
//
//  Created by Robert Tubb on 21/10/2014.
//
//

#ifndef __riftathon__SequenceGenerator__
#define __riftathon__SequenceGenerator__

#include <iostream>
#include "ofMain.h"
#include "presetManager.h"
#include "TrainingScoreManager.h"

#define MIN_TARGETS_IN_SEQUENCE 1
#define NUM_REPETITIONS_AT_LEVEL 1
#define MAX_TARGETS_IN_SEQUENCE 3
#define MIN_TEMPO   90
#define MAX_TEMPO   520
#define TEMPO_RANDOM_AMOUNT
#define MAX_TIME 2800
#define MIN_TIME 200
#define NUM_TEMPO_STEPS 15
#define END_NEUTRAL_MATCH 0

#define NUM_PRESETS 8
#define SLIDER_SLOW_FACTOR 1
#define SPACER_BARS false
#define NO_GUIDES_LEVEL false

class AnimStep{

    
public:
    
    AnimStep();
    typedef enum {PREVIEW_NEUTRAL_COUNT,
                MATCHING_NEUTRAL_COUNT,
                PREVIEW_MOVE,
                PREVIEW_LAST,
                GUIDED_MOVE,
                GUIDED_HIT,
                MATCHING_MOVE,
                MATCHING_LAST}
                stepType;
    
    stepType type;
    int getTimeAllowed(){
        return timeAllowedMs;
    }
    float getTimeBetweenTicks(){
        //return 1000* (60.0/tempo);
        return timeAllowedMs/4.0;
    }

    void setTempoFromTime(){
        tempo = 4 * 1000. * 60.0 / (timeAllowedMs);
    }
    void setTimeFromTempo(){
        timeAllowedMs = 4*1000* (60.0/tempo);
    }
    int presetIndex;
    Preset * currentTargetPreset;
    Preset * nextTargetPreset;
    int whichInSequence;
    bool isLastOfAll;

    int tempo;
    int tempoLevel;
    int timeAllowedMs;
    int seqNumber;
    int runNumber;
    int difficulty;
    bool isLastOfSeq;
    bool isLastOfRun;
    
    bool showsGuides; // depends on 'level'
    bool showsIcons;
    bool showsResultsAtEnd;
    int totalLengthOfSeq;
    vector<int> thisSequence; // so that we can show the whole sequence at the top?
    
    TrainingTestResult result; // only applies to steps that were scored.
    
    
    void saveResult(TrainingTestResult result);
};

// NOT USED
class Step{
public:
    typedef enum {COUNT_IN, PREVIEW_PREPARER, PREVIEW_DISPLAYER, MATCHING_PREPARER, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes;
    
    Step();
    
// gui display
    bool showsTargetIcon;
    bool showsControlSettings;
    bool showsControlGuides;
    bool showsMatchResults;
// gui input
    bool allowsCandidateControl;
// sound
    bool playsTarget;
    bool playsCandidate;
// control flow
    stepTypes type;
    bool isPreview;
    
    int seqNumber;
    int runNumber;
    bool isLastOfSeq;
    bool isLastOfRun;
    bool showsCountDown;
    bool hidesSliders;
    int tempo;
// preset info
    int presetIndex;
    int numInSequence;
    bool isLastOfAll;

    void setAsBlankCounter();
    void setAsPreviewPreparer();
    void setAsPreviewPlayer();
    void setAsMatchingPreparer();
    void setAsMatchingInteraction();
    void setAsMatchingFeedback();

};

class SequenceController{
public:
    SequenceController();
    void init(bool asoundOnlyMode, controlPanelType whichInterfaceAreWeUsing, bool demoMode);
    AnimStep getNextStep();
    void setToStart();
    void stepForward();
    float getStartIntervalTime();
    void saveResultForCurrentStep(TrainingTestResult result);
    TrainingTestResult getResultForPreviousStep();
    int getTotNumRuns(){return totNumRuns;};
    int getCurrentRunNumber(){return currentRunNumber;};
    void skipRun();
private:
    void generateSteps();
    void generateTestSequence(int run);
    void generateCountIn(int countInLength, int runNumber);
    void generateRun(int run, int numInSequence);// use this now
    void generateARun(int run, int numInSequence);
    void generateAnEasyRun(int run, int numInSequence = 1);
    void generateASoundOnlyRun(int run, int numInSequence);
    vector<int> randomSequence(int numInSequence);
    vector<int> nonRandomSequence(int numInSequence);
    int getRandomButNot(int max, vector<int> notThese);
    void makeGuidedSequence(vector<int> stepPresetIndices, int run, AnimStep& nextStep);
    void makeMatchingSequence(vector<int> stepPresetIndices, int run, AnimStep& nextStep);
    void makePreview(vector<int> stepPresetIndices, int run, AnimStep& nextStep);
protected:
    vector<AnimStep> steps;
    vector<AnimStep>::iterator currentStep;
    float tempoInc;
    int timeInc;
    bool soundOnlyMode;
    controlPanelType panelType;
    int totNumRuns;
    vector<int> timeIntervalsHard;
    int currentRunNumber;
};

#endif /* defined(__riftathon__SequenceGenerator__) */