root/TvShows.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include "json.h"
#include "List.h"
#include "Constants.h"
#include "Search.h"


struct EpisodePage;
struct TvShows {
    List* lists;
    ListNode* selectedList;
    int scrollY;
    struct EpisodePage* episodePage;
    WINDOW* window;
    const char* baseUrl;
    void** activePage;
    struct Search search;
};

struct TvShowList {
    char* name;
    List* lis;
    ListNode* selectedLi;
};

struct TvShowLi {
    char* name;
    int watchedEpisodes;
    int downloadedEpisodes;
    int totalEpisodes;
    int y;
};

struct DrawPair {
    int y;
    int* linesToUpdate;
};

void TvShows_init(struct TvShows* this);
void TvShows_destroyMembers(struct TvShows* this);
DEFAULT_CREATE_DESTROY_H(TvShow)

void TvShows_searchForward(struct TvShows* this);
void TvShows_searchBackward(struct TvShows* this);

void TvShows_recreateWindowForData(struct TvShows* this);
int TvShows_printAll(struct TvShows* this, int* linesToUpdate);
bool TvShows_handleInput(struct TvShows* this, int c);
void TvShows_selectFirstOrLast(struct TvShows* this, bool direction);
void TvShows_selectDelta(struct TvShows* this, int delta);
void TvShows_playSelected(struct TvShows* this);
struct TvShowLi* TvShows_selectedTvShow(struct TvShows* this);

void TvShows_fetch(struct TvShows* this, const char* url);
void TvShows_restore(struct TvShows* this, json_value* json);
void TvShows_restoreList(struct TvShows* this, const char* name, json_value* json);

void TvShowList_init(struct TvShowList* this);
void TvShowList_destroyMembers(struct TvShowList* this);
DEFAULT_CREATE_DESTROY_H(TvShowList)

struct DrawPair TvShowList_draw(struct TvShowList* this, WINDOW* window, int scrollY, struct DrawPair info);
int TvShowList_selectDelta(struct TvShowList* this, WINDOW* window, int delta);

void TvShowLi_init(struct TvShowLi* this);
void TvShowLi_destroyMembers(struct TvShowLi* this);
DEFAULT_CREATE_DESTROY_H(TvShowLi)

struct TvShowLi* TvShowLi_restore(json_value* json);
void TvShowLi_draw(struct TvShowLi* li, WINDOW* window, bool selected, int y);
int TvShowLi_compare(void* a, void* b);