Skip to content

Commit 2bc8ae2

Browse files
committed
📦 v1.0 released!
1 parent 2893491 commit 2bc8ae2

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/main.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ extern "C" {
1717
// Main code
1818
int main(int argc, char* argv[])
1919
{
20-
const int version_major = 0;
21-
const int version_minor = 9;
20+
const int version_major = 1;
21+
const int version_minor = 0;
2222
// Setup SDL
2323
// (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
2424
// depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to the latest version of SDL is recommended!)
@@ -54,6 +54,8 @@ int main(int argc, char* argv[])
5454

5555
AnimationWallet* animations_wallet = new AnimationWallet(current_animations_folder);
5656

57+
// TODO: Manifest reader
58+
5759
// Setup Dear ImGui context
5860
IMGUI_CHECKVERSION();
5961
ImGui::CreateContext();
@@ -91,6 +93,9 @@ int main(int argc, char* argv[])
9193
const int image_width = 128;
9294
const int image_height = 64;
9395

96+
char* manifest_content_char = (char*)malloc(sizeof(char) * 1000);
97+
int manifest_content_max_size = sizeof(char) * 1000;
98+
9499
// Our state
95100
bool show_toolbox = false;
96101
bool show_demo_window = false;
@@ -259,7 +264,7 @@ int main(int argc, char* argv[])
259264
ImGui::Text("Flipper-Zero Animation Manager v%d.%d", version_major, version_minor);
260265
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
261266
ImGui::Text("Made with <3 by Ooggle");
262-
ImGui::Text("https://github.com/Ooggle"); // TODO: clickable link
267+
ImGui::Text("https://github.com/Ooggle/FlipperAnimationManager"); // TODO: clickable link
263268
ImGui::Separator();
264269
if(ImGui::Button("Close") || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
265270
ImGui::CloseCurrentPopup();
@@ -281,16 +286,25 @@ int main(int argc, char* argv[])
281286
ImGui::Separator();
282287
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
283288
// TODO: optimize this bad way of generating manifest.txt
289+
284290
ImGui::Text("Manifest.txt");
285-
char* manifest_content_char = (char*)malloc(sizeof(char) * manifest_content.size());
286-
strcpy(manifest_content_char, manifest_content.c_str());
291+
292+
if(strcmp(manifest_content_char, manifest_content.c_str()))
293+
{
294+
// Not very pretty but it will remain like that until I found something better without abusing (re)allocations
295+
if(sizeof(char) * manifest_content.size() > manifest_content_max_size)
296+
{
297+
manifest_content_max_size+= sizeof(char) * 1000;
298+
manifest_content_char = (char*)realloc(manifest_content_char, manifest_content_max_size);
299+
}
300+
strcpy(manifest_content_char, manifest_content.c_str());
301+
}
287302
ImGui::InputTextMultiline("##source", manifest_content_char, manifest_content.size(), ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 40), ImGuiInputTextFlags_ReadOnly);
288303
if(ImGui::Button("Copy Manifest to clipboard"))
289304
{
290305
ImGui::SetClipboardText(manifest_content_char);
291306
// TODO: show copied to clipboard message
292307
}
293-
free(manifest_content_char);
294308
ImGui::End();
295309

296310
if(show_demo_window)
@@ -327,6 +341,7 @@ int main(int argc, char* argv[])
327341

328342
// Cleanup
329343
delete(animations_wallet);
344+
free(manifest_content_char);
330345

331346
// Cleanup Imgui
332347
ImGui_ImplOpenGL2_Shutdown();

0 commit comments

Comments
 (0)