Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "raylib.h"
- #include "imgui/imgui.h"
- #include "imgui/imgui_internal.h"
- #include "rlImGui.h"
- #include <iostream>
- #include <string>
- #include <vector>
- // Variables
- int listViewExScrollIndex = 0;
- int listViewExActive = 0;
- int listViewExFocus = 0;
- std::vector<char*> listViewExList;
- bool canAddEntity = false;
- std::vector<std::string> entityNames;
- int ImGuiListViewEx(std::vector<std::string>& items, int& focus, int& scroll, int& active) {
- ImGui::SetNextWindowSize(ImVec2(400, 200)); // set the container size
- ImVec2 screen = ImGui::GetIO().DisplaySize;
- ImVec2 childSize = ImVec2(.2 * screen.x, .7 * screen.y);
- ImGui::BeginChild("Entities List", childSize, true, ImGuiWindowFlags_HorizontalScrollbar);
- for (int i = 0; i < 3; i++) {
- if (ImGui::Button("Hello World Button", ImVec2(120,40))) {
- std::cout << "Button Selected is at index: " << i << std::endl;
- focus = i;
- active = i;
- }
- }
- ImGui::EndChild();
- return active;
- }
- void EntitiesList()
- {
- // Translate the rectangles coordinates to ImGui coordinates
- ImVec2 pos = ImGui::GetCursorScreenPos();
- ImVec2 size = ImGui::GetContentRegionAvail();
- Rectangle rec = { pos.x, pos.y, size.x, size.y };
- listViewExActive = ImGuiListViewEx(entityNames, listViewExFocus, listViewExScrollIndex, listViewExActive);
- }
- int main(int argc, char* argv[])
- {
- int screenWidth1 = 1900;
- int screenHeight1 = 900;
- SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE);
- InitWindow(screenWidth1, screenHeight1, "raylib [ImGui] example - ImGui Demo");
- SetTargetFPS(144);
- rlImGuiSetup(true);
- // Init Docking
- ImGui::CreateContext();
- ImGuiIO& io = ImGui::GetIO(); (void)io;
- io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
- // Main game loop
- while (!WindowShouldClose())
- {
- BeginDrawing();
- ClearBackground(DARKGRAY);
- // start the GUI
- rlImGuiBegin();
- ImGuiIO& io = ImGui::GetIO();
- // Entities List
- ImGui::Begin("Entities List Window", NULL);
- EntitiesList();
- ImGui::End();
- // end ImGui
- rlImGuiEnd();
- DrawFPS(screenWidth1*.9, screenHeight1*.1);
- // Finish drawing
- EndDrawing();
- }
- rlImGuiShutdown();
- CloseWindow();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment