-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi_buttons.hpp
More file actions
232 lines (195 loc) · 8.78 KB
/
api_buttons.hpp
File metadata and controls
232 lines (195 loc) · 8.78 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#pragma once
#include <vector>
#include <iostream>
#include <rumble_lol_plugin/league_client/button.hpp>
#include <rumble_lol_plugin/league_client/screen_identifier.hpp>
using namespace std;
/**
* @brief
* Place for store all the available data for the API.
*
* TODO Notate how in the future, this should be replaced by a REST API data supplier,
* where we can retrieve data dynamically from every patch, every client aspect change
* with posible new buttons etc.
*/
namespace RLE_data {
/**
* Represents all the game lobbies available in the API, this means,
* every lobby screen that the user can access by voice control
*/
const size_t available_client_lobbies = 9;
const LeagueClientScreenIdentifier lobbies [available_client_lobbies] {
LeagueClientScreenIdentifier::SummonersBlindLobby,
LeagueClientScreenIdentifier::SummonersDraftLobby,
LeagueClientScreenIdentifier::SummonersRankedLobby,
LeagueClientScreenIdentifier::SummonersFlexLobby,
LeagueClientScreenIdentifier::AramLobby,
LeagueClientScreenIdentifier::TFT_NormalLobby,
LeagueClientScreenIdentifier::TFT_RankedLobby,
LeagueClientScreenIdentifier::TFT_HyperRollLobby,
LeagueClientScreenIdentifier::UrfLobby,
};
/**
* The available buttons to use with this API against the League of Legends client with the League
*/
vector<tuple<const char*, const char*, const LeagueClientScreenIdentifier>> english_buttons {
// Navbar buttons
make_tuple("home", "home_button", LeagueClientScreenIdentifier::MainScreen),
make_tuple("play", "play_button", LeagueClientScreenIdentifier::ChooseGame),
make_tuple("tft", "tft_button", LeagueClientScreenIdentifier::TFT),
make_tuple("clash", "clash_button", LeagueClientScreenIdentifier::Clash),
make_tuple("profile", "profile_button", LeagueClientScreenIdentifier::Profile),
make_tuple("collection", "collection_button", LeagueClientScreenIdentifier::Collection),
make_tuple("loot", "loot_button", LeagueClientScreenIdentifier::Loot),
make_tuple("your shop", "your_shop_button", LeagueClientScreenIdentifier::YourShop),
make_tuple("store", "store_button", LeagueClientScreenIdentifier::Store),
// Choose Game options
make_tuple("summoners", "summoners_rift", LeagueClientScreenIdentifier::SummonersBlindLobby),
make_tuple("aram", "aram", LeagueClientScreenIdentifier::AramLobby),
make_tuple("tft", "teamfight_tactics", LeagueClientScreenIdentifier::TFT_NormalLobby),
make_tuple("urf", "urf", LeagueClientScreenIdentifier::UrfLobby),
// Ranked and draft modes position picker
make_tuple("primary", "primary", LeagueClientScreenIdentifier::GameLobby),
make_tuple("secondary", "secondary", LeagueClientScreenIdentifier::GameLobby),
// Roles
make_tuple("top", "top_role", LeagueClientScreenIdentifier::GameLobby),
make_tuple("jungler", "jungler_role", LeagueClientScreenIdentifier::GameLobby),
make_tuple("mid", "mid_role", LeagueClientScreenIdentifier::GameLobby),
make_tuple("bot", "bot_role", LeagueClientScreenIdentifier::GameLobby),
make_tuple("support", "support_role", LeagueClientScreenIdentifier::GameLobby),
make_tuple("fill", "autofill_role", LeagueClientScreenIdentifier::GameLobby),
// Summoner's Rift buttons
make_tuple("blind", "blind_pick", LeagueClientScreenIdentifier::SummonersBlindLobby),
make_tuple("draft", "draft_pick", LeagueClientScreenIdentifier::SummonersDraftLobby),
make_tuple("ranked", "ranked_solo_duo", LeagueClientScreenIdentifier::SummonersRankedLobby),
make_tuple("flex", "flex", LeagueClientScreenIdentifier::SummonersFlexLobby),
// Aram buttons aren't necessary, there is just one option
// TFT Buttons
make_tuple("normal", "tft_normal", LeagueClientScreenIdentifier::TFT_NormalLobby),
make_tuple("ranked", "tft_ranked", LeagueClientScreenIdentifier::TFT_RankedLobby),
make_tuple("hyper", "tft_hyper_roll", LeagueClientScreenIdentifier::TFT_HyperRollLobby),
// Urf buttons aren't necessary, there is just one option
// Training. Contains the "start now" from tutorial and "start game" from the practice tool
make_tuple("training", "training", LeagueClientScreenIdentifier::ChooseGame),
make_tuple("tutorial", "tutorial", LeagueClientScreenIdentifier::TutorialLobby),
make_tuple("practice", "practice", LeagueClientScreenIdentifier::PracticeTool),
make_tuple("start", "start", LeagueClientScreenIdentifier::GameLobby),
// TODO Pending implement the add bot functionality, or a handler to the same modal
// Join button from the team making screen
make_tuple("join", "join_game", LeagueClientScreenIdentifier::GameLobby),
// Find Game - Cancel queue - Confirm action
make_tuple("find", "find_game", LeagueClientScreenIdentifier::AcceptDecline),
make_tuple("accept", "accept_match", LeagueClientScreenIdentifier::ChampSelect),
make_tuple("decline", "decline_match", LeagueClientScreenIdentifier::GameLobby),
make_tuple("go", "confirm_button", LeagueClientScreenIdentifier::GameLobby),
make_tuple("cancel", "cancel_button", LeagueClientScreenIdentifier::CancelAction),
// Champ select buttons
make_tuple("finder", "search_bar", LeagueClientScreenIdentifier::ChampSelect),
make_tuple("editor", "runes_editor", LeagueClientScreenIdentifier::ChampSelect),
make_tuple("picker", "runes_picker", LeagueClientScreenIdentifier::ChampSelect),
make_tuple("lock", "lock_in", LeagueClientScreenIdentifier::ChampSelect),
// Binary decision modals
make_tuple("exit", "exit", LeagueClientScreenIdentifier::ClientClosed),
make_tuple("sign out", "sign_out", LeagueClientScreenIdentifier::ClientClosed),
make_tuple("yes", "yes", LeagueClientScreenIdentifier::ClientClosed),
make_tuple("no", "no", LeagueClientScreenIdentifier::ClientClosed),
make_tuple("close", "close", LeagueClientScreenIdentifier::ClientClosed),
};
vector<tuple<const char*, const char*, const LeagueClientScreenIdentifier>> spanish_buttons{
// TODO Just change it for the spanish correct definitions
};
std::string add_assets_route(const std::string& image_path, const Language language = Language::English) {
std::string base_path{ "../assets/" };
std::string image_extension{ ".jpg" };
switch (language)
{
case Language::English:
base_path.append("EN");
break;
case Language::Spanish:
base_path.append("SP");
break;
default:
base_path.append("EN");
};
base_path.append("/").append(image_path).append(image_extension);
return base_path;
}
/**
* Helper that returns a vector of ClientButton aggregates
*/
vector<ClientButton> get_buttons(const Language language, const bool debug = false)
{
vector<tuple<const char*, const char*, const LeagueClientScreenIdentifier>> desired_group_buttons{};
vector<ClientButton> api_buttons;
// Selects the buttons based on the language. Moves them to a new container to avoid dangling references caused by std::tuple
switch (language)
{
case Language::English:
for (auto &element : english_buttons)
desired_group_buttons.push_back(element); // TODO emplace_back them all
break;
case Language::Spanish:
for (auto &element : spanish_buttons)
desired_group_buttons.push_back(element);
break;
default:
for (auto &element : english_buttons)
desired_group_buttons.push_back(element);
};
// Creates a new button object, storing in a vector a raw pointer to the instance
for (auto &tuple : desired_group_buttons) {
const LeagueClientScreenIdentifier* lcsi = std::find(
std::begin(lobbies), std::end(lobbies), std::get<2>(tuple)
);
const auto identifier = std::get<0>(tuple);
const auto path = add_assets_route(std::get<1>(tuple), language);
if (lcsi != std::end(lobbies)) {
const auto but = ClientButton {
identifier,
path,
LeagueClientScreenIdentifier::ChooseGame,
language,
std::get<2>(tuple)
};
cout << "Generated button: " << but << endl;
api_buttons.push_back(
but
);
} else {
const auto but = ClientButton {
identifier,
path,
std::get<2>(tuple),
language,
LeagueClientScreenIdentifier::NoLobby,
};
cout << "Generated button [ELSE]: " << but << endl;
api_buttons.push_back(
but
);
}
}
if (debug) {
for (ClientButton& button : api_buttons) {
cout << "Button with identifier: " << button.identifier
<< "; with path: " << button.image_path << endl;
cout << "\tpointing to: " << button.next_screen
<< " and belongs to: " << button.lobby << endl;
}
}
return api_buttons;
}
// ClientButton::ClientButton(
// const char* identifier,
// const char* image_path,
// const LeagueClientScreenIdentifier next_screen,
// const Language selected_language,
// const LeagueClientScreenIdentifier lobby
// )
// : identifier{ const_cast<char*>(identifier) },
// image_path{ image_path },
// next_screen{ next_screen },
// selected_language{ selected_language },
// lobby{ lobby }
}