]> git.sesse.net Git - pkanalytics/blobdiff - events.h
Make the video actually fit its intended size.
[pkanalytics] / events.h
index caf832ac26ca0180364d8e899dba453beb909c00..df5fcb6a9b8c8b08871f2d76ef7804a5501652f7 100644 (file)
--- a/events.h
+++ b/events.h
@@ -25,9 +25,11 @@ public:
        QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
        QVariant data(const QModelIndex &index, int role) const override;
 
-       unsigned insert_event(uint64_t t, std::optional<int> player_id, const std::string &type = "unknown");  // Returns the row.
+       unsigned insert_event(uint64_t t, std::optional<int> player_id, std::optional<int> formation_id, const std::string &type = "unknown");  // Returns the row.
        void delete_event(unsigned row);
+       std::string get_event_type(unsigned row) { return events[row].type; }
        void set_event_type(unsigned row, const std::string &type);
+       void set_event_formation(unsigned row, int formation_id);
        uint64_t get_time(unsigned row) { return events[row].t; }
        unsigned get_last_event_pos(uint64_t t) const;  // Last event that happened at or before t.
        QModelIndex get_last_event_qt(uint64_t t) const {
@@ -38,6 +40,7 @@ public:
        struct Status {
                unsigned our_score, their_score;
                enum { NOT_STARTED, OFFENSE, DEFENSE } attack_state;
+               unsigned offensive_formation, defensive_formation;
                bool stoppage;
                enum { NOT_PULLING, SHOULD_PULL, PULL_IN_AIR } pull_state;
                unsigned num_passes;
@@ -48,6 +51,12 @@ public:
        std::set<int> get_team_at(uint64_t t);
        void set_team_at(uint64_t, const std::set<int> &new_team);
        std::vector<int> sort_team(const std::set<int> &team) const;  // Ordered first by gender, then by number.
+       void set_formation_at(uint64_t t, bool offense, unsigned formation);
+
+       // Used to notify when we've inserted a new one into the database.
+       void inserted_new_formation(int formation_id, const std::string &name) {
+               formations[formation_id] = Formation{ formation_id, name };
+       }
 
 private:
        struct Player {
@@ -58,10 +67,17 @@ private:
        std::map<int, Player> players;
        std::map<int, int> player_ordering;  // From id to position.
 
+       struct Formation {
+               int formation_id;
+               std::string name;
+       };
+       std::map<int, Formation> formations;
+
        struct Event {
                int event_id;
                uint64_t t;
                std::optional<int> player_id;
+               std::optional<int> formation_id;
                std::string type;
        };
        std::vector<Event> events;