Skip to content

Commit 00e2e00

Browse files
committed
copyable skins tab and champs tab
1 parent bf3b6ef commit 00e2e00

2 files changed

Lines changed: 89 additions & 33 deletions

File tree

KBotExt/ChampsTab.h

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -171,39 +171,75 @@ class ChampsTab
171171
}
172172
}
173173

174+
ImGui::SameLine();
175+
static char allNamesSeparator[64] = ",";
176+
if (ImGui::Button("Copy names to clipboard##champsTab"))
177+
{
178+
std::string allNames = "";
179+
for (const auto& champ : champsAll)
180+
{
181+
if (!champ.min.owned)
182+
continue;
183+
allNames += champ.min.name + allNamesSeparator;
184+
}
185+
Utils::CopyToClipboard(allNames);
186+
}
187+
ImGui::SameLine();
188+
189+
const ImVec2 label_size = ImGui::CalcTextSize("W", NULL, true);
190+
ImGui::InputTextMultiline("##separatorChampsTab", allNamesSeparator, IM_ARRAYSIZE(allNamesSeparator),
191+
ImVec2(0, label_size.y + ImGui::GetStyle().FramePadding.y * 2.0f), ImGuiInputTextFlags_AllowTabInput);
192+
174193
ImGui::Separator();
175194
ImGui::Text("Champions owned: %d", iChampsOwned);
176195
for (const auto& champ : champsAll)
177196
{
178197
if (!champ.min.owned)
179198
continue;
180199

181-
ImGui::Separator();
182-
ImGui::Text("name: %s", champ.min.name.c_str());
183200
int64_t t = std::stoll(champ.min.purchased);
184201
t /= 1000;
185202
char buffer[50];
186203
strftime(buffer, 100, "%Y-%m-%d %H:%M:%S", localtime(&t));
187-
ImGui::Text("purchased: %s", buffer);
188-
ImGui::Text("id: %d", champ.min.id);
189204

190-
if (champ.mas.lastPlayTime.empty())
191-
continue;
205+
std::string inputId = "champInput";
206+
inputId.append(std::to_string(champ.min.id));
207+
char input[768];
192208

193-
ImGui::Text("championLevel: %d", champ.mas.championLevel);
194-
ImGui::Text("championPoints: %d", champ.mas.championPoints);
195-
ImGui::Text("championPointsSinceLastLevel: %d", champ.mas.championPointsSinceLastLevel);
196-
ImGui::Text("championPointsUntilNextLevel: %d", champ.mas.championPointsUntilNextLevel);
197-
ImGui::Text("chestGranted: %d", champ.mas.chestGranted);
198-
ImGui::Text("formattedChampionPoints: %s", champ.mas.formattedChampionPoints.c_str());
199-
ImGui::Text("formattedMasteryGoal: %s", champ.mas.formattedMasteryGoal.c_str());
200-
ImGui::Text("highestGrade: %s", champ.mas.highestGrade.c_str());
201-
t = std::stoll(champ.mas.lastPlayTime);
202-
t /= 1000;
203-
strftime(buffer, 100, "%Y-%m-%d %H:%M:%S", localtime(&t));
204-
ImGui::Text("lastPlayTime: %s", buffer);
205-
ImGui::Text("playerId: %s", champ.mas.playerId.c_str());
206-
ImGui::Text("tokensEarned: %d", champ.mas.tokensEarned);
209+
float textHeight = (label_size.y + ImGui::GetStyle().FramePadding.y) * 3.f;
210+
std::string text = std::format(R"(name: {}
211+
purchased: {}
212+
id: {})", champ.min.name, buffer, champ.min.id);
213+
214+
if (!champ.mas.lastPlayTime.empty())
215+
{
216+
textHeight = (label_size.y + ImGui::GetStyle().FramePadding.y) * 12.f;
217+
218+
t = std::stoll(champ.mas.lastPlayTime);
219+
t /= 1000;
220+
strftime(buffer, 100, "%Y-%m-%d %H:%M:%S", localtime(&t));
221+
222+
text += std::format(R"(
223+
championLevel: {}
224+
championPoints: {}
225+
championPointsSinceLastLevel: {}
226+
championPointsUntilNextLevel: {}
227+
chestGranted: {}
228+
formattedChampionPoints: {}
229+
formattedMasteryGoal: {}
230+
highestGrade: {}
231+
lastPlayTime: {}
232+
playerId: {}
233+
tokensEarned: {})", champ.mas.championLevel, champ.mas.championPoints, champ.mas.championPointsSinceLastLevel,
234+
champ.mas.championPointsUntilNextLevel, champ.mas.chestGranted, champ.mas.formattedChampionPoints, champ.mas.formattedMasteryGoal,
235+
champ.mas.highestGrade, buffer, champ.mas.playerId, champ.mas.tokensEarned);
236+
}
237+
238+
strcpy(input, text.c_str());
239+
ImGui::PushID(inputId.c_str());
240+
ImGui::InputTextMultiline("", input, IM_ARRAYSIZE(input), ImVec2(ImGui::GetWindowSize().x, textHeight),
241+
ImGuiInputTextFlags_ReadOnly);
242+
ImGui::PopID();
207243
}
208244

209245
ImGui::EndTabItem();

KBotExt/SkinsTab.h

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,47 @@ class SkinsTab
121121
}
122122
}
123123

124+
ImGui::SameLine();
125+
static char allNamesSeparator[64] = ",";
126+
if (ImGui::Button("Copy names to clipboard##skinsTab"))
127+
{
128+
std::string allNames = "";
129+
for (const Skin& skin : ownedSkins)
130+
{
131+
if (skin.name == "")
132+
continue;
133+
allNames += skin.name + allNamesSeparator;
134+
}
135+
Utils::CopyToClipboard(allNames);
136+
}
137+
ImGui::SameLine();
138+
139+
const ImVec2 label_size = ImGui::CalcTextSize("W", NULL, true);
140+
ImGui::InputTextMultiline("##separatorSkinsTab", allNamesSeparator, IM_ARRAYSIZE(allNamesSeparator),
141+
ImVec2(0, label_size.y + ImGui::GetStyle().FramePadding.y * 2.0f), ImGuiInputTextFlags_AllowTabInput);
142+
124143
ImGui::Separator();
125144
ImGui::Text("Skins owned: %d", ownedSkins.size());
126145

127146
for (const Skin& skin : ownedSkins)
128147
{
129-
ImGui::Separator();
130-
if (!skin.name.empty())
131-
ImGui::Text("name: %s", skin.name.c_str());
132-
//else if (!champSkins.empty())
133-
// ImGui::Text("name: Chroma"); // todo find a way to get chroma's name
134-
ImGui::Text("inventoryType: %s", skin.inventoryType.c_str());
135-
ImGui::Text("itemId: %d", skin.itemId);
136-
ImGui::Text("ownershipType: %s", skin.ownershipType.c_str());
137-
ImGui::Text("isVintage: %d", skin.isVintage);
138-
139148
char timeBuff[50];
140149
strftime(timeBuff, sizeof(timeBuff), "%G-%m-%d %H:%M:%S", &skin.purchaseDate);
141-
ImGui::Text("purchaseDate: %s", timeBuff);
142150

143-
ImGui::Text("quantity: %d", skin.qunatity);
144-
ImGui::Text("uuid: %s", skin.uuid.c_str());
151+
std::string inputId = "skinInput";
152+
inputId.append(std::to_string(skin.itemId));
153+
char input[512];
154+
strcpy(input, std::format(R"(name: {}
155+
inventoryType: {}
156+
itemId: {}
157+
ownershipType: {}
158+
isVintage: {}
159+
purchaseDate: {}
160+
quantity: {}
161+
uuid: {})", skin.name, skin.inventoryType, skin.itemId, skin.ownershipType, skin.isVintage, timeBuff, skin.qunatity, skin.uuid).c_str());
162+
ImGui::PushID(inputId.c_str());
163+
ImGui::InputTextMultiline("", input, IM_ARRAYSIZE(input), ImVec2(ImGui::GetWindowSize().x, 0), ImGuiInputTextFlags_ReadOnly);
164+
ImGui::PopID();
145165
}
146166

147167
ImGui::EndTabItem();

0 commit comments

Comments
 (0)