/*
 * MIT License
 * Author: Mark Allyn
 *
 * scope_manager.h — owns the ordered list of scopes and drives the
 * 120-second auto-advance cycle.
 *
 * s key → advance, S key → reverse.
 * Any other key is forwarded to the current scope.
 * Any key press resets the auto-advance timer for the active scope.
 */

#pragma once
#include <vector>
#include <memory>
#include <string>
#include "scope.h"

class ScopeManager {
public:
    ScopeManager() = default;

    // Add a scope to the end of the list (ownership transferred).
    void addScope(std::unique_ptr<Scope> scope);

    // Call after GL context is current; initialises all scopes.
    bool init(const std::string& shaderDir);

    // Forward from the main loop.
    void render(float dt, float viewportW, float viewportH);

    // Called from GLFW key callback.
    void handleKey(int key, int scancode, int action, int mods);

    int  currentIndex() const { return current_; }

private:
    void advanceScope(int direction);

    std::vector<std::unique_ptr<Scope>> scopes_;
    int current_ = 0;
};
