#include #include #include #include #include #include #include #include int main() { // Initialize Steam API if (!SteamAPI_Init()) { std::cerr << "Failed to initialize Steam API" << std::endl; return 1; } // Initialize GLFW if (!glfwInit()) { std::cerr << "Failed to initialize GLFW" << std::endl; SteamAPI_Shutdown(); return -1; } // Create window GLFWwindow* window = glfwCreateWindow(1280, 720, "Steam Friends List", nullptr, nullptr); if (!window) { std::cerr << "Failed to create GLFW window" << std::endl; glfwTerminate(); SteamAPI_Shutdown(); return -1; } glfwMakeContextCurrent(window); glfwSwapInterval(1); // Enable vsync // Initialize ImGui IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; // Load Chinese font io.Fonts->AddFontFromFileTTF("font.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesChineseSimplifiedCommon()); ImGui::StyleColorsDark(); // Initialize ImGui backends ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 130"); // Get friends list std::vector friendsList; int friendCount = SteamFriends()->GetFriendCount(k_EFriendFlagAll); for (int i = 0; i < friendCount; ++i) { CSteamID friendID = SteamFriends()->GetFriendByIndex(i, k_EFriendFlagAll); const char* name = SteamFriends()->GetFriendPersonaName(friendID); friendsList.push_back(std::string("Friend ") + std::to_string(i + 1) + ": " + name); } // Main loop while (!glfwWindowShouldClose(window)) { // Poll events glfwPollEvents(); // Start ImGui frame ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); // Create a window for friends list ImGui::Begin("Steam Friends List"); ImGui::Text("Number of friends: %d", friendCount); ImGui::Separator(); if (friendCount > 0) { ImGui::Columns(4, nullptr, true); // 4 columns, with borders for (const auto& friendName : friendsList) { ImGui::Text("%s", friendName.c_str()); ImGui::NextColumn(); } ImGui::Columns(1); // Reset to 1 column } ImGui::End(); // Rendering ImGui::Render(); int display_w, display_h; glfwGetFramebufferSize(window, &display_w, &display_h); glViewport(0, 0, display_w, display_h); glClearColor(0.45f, 0.55f, 0.60f, 1.00f); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); // Swap buffers glfwSwapBuffers(window); } // Cleanup ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); glfwDestroyWindow(window); glfwTerminate(); SteamAPI_Shutdown(); return 0; }