| 409 | } |
| 410 | |
| 411 | void Toolbar::top_toolbar() { |
| 412 | auto& gui = main.g.gui; |
| 413 | auto& io = gui.io; |
| 414 | |
| 415 | gui.element<LayoutElement>("top menu bar", [&] (LayoutElement*, const Clay_ElementId& lId) { |
| 416 | CLAY(lId, { |
| 417 | .layout = { |
| 418 | .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) }, |
| 419 | .padding = CLAY_PADDING_ALL(static_cast<uint16_t>(io.theme->padding1 / 2)), |
| 420 | .childGap = static_cast<uint16_t>(io.theme->childGap1 / 2), |
| 421 | .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER}, |
| 422 | .layoutDirection = CLAY_LEFT_TO_RIGHT |
| 423 | }, |
| 424 | .backgroundColor = convert_vec4<Clay_Color>(io.theme->backColor1), |
| 425 | .cornerRadius = CLAY_CORNER_RADIUS(io.theme->windowCorners1) |
| 426 | }) { |
| 427 | global_log(); |
| 428 | |
| 429 | auto icon_button_top_toolbar = [&](const char* id, const std::string& svgPath, bool isSelected, const std::function<void()>& onClick) { |
| 430 | return svg_icon_button(gui, id, svgPath, { |
| 431 | .drawType = SelectableButton::DrawType::TRANSPARENT_ALL, |
| 432 | .isSelected = isSelected, |
| 433 | .onClick = onClick |
| 434 | }); |
| 435 | }; |
| 436 | |
| 437 | Element* mainMenuButton = icon_button_top_toolbar("Main Menu Button", "data/icons/menu.svg", menuPopUpOpen, [&] { |
| 438 | menuPopUpOpen = !menuPopUpOpen; |
| 439 | }); |
| 440 | |
| 441 | std::vector<MovableTabListData::IconNamePair> tabNames; |
| 442 | for(size_t i = 0; i < main.worlds.size(); i++) { |
| 443 | auto& w = main.worlds[i]; |
| 444 | bool shouldAddStarNextToName = w->should_ask_before_closing() && !w->netServer && !w->netClient; |
| 445 | tabNames.emplace_back(w->netObjMan.is_connected() ? "data/icons/network.svg" : "", w->name + (shouldAddStarNextToName ? "*" : "")); |
| 446 | } |
| 447 | |
| 448 | size_t worldIndex = std::find(main.worlds.begin(), main.worlds.end(), main.world) - main.worlds.begin(); |
| 449 | |
| 450 | gui.element<MovableTabList>("file tab list", MovableTabListData{ |
| 451 | .tabNames = tabNames, |
| 452 | .selectedTab = worldIndex, |
| 453 | .changeSelectedTab = [&] (size_t i) { |
| 454 | main.switch_to_tab(i); |
| 455 | }, |
| 456 | .closeTab = [&] (size_t i) { |
| 457 | if(main.worlds[i]->should_ask_before_closing()) |
| 458 | add_world_to_close_popup_data(main.worlds[i]); |
| 459 | else |
| 460 | main.set_tab_to_close(main.worlds[i].get()); |
| 461 | } |
| 462 | }); |
| 463 | |
| 464 | if(!main.world->clientStillConnecting) { |
| 465 | if(main.world->netObjMan.is_connected()) { |
| 466 | icon_button_top_toolbar("Player List Toggle Button", "data/icons/list.svg", playerMenuOpen, [&] { |
| 467 | playerMenuOpen = !playerMenuOpen; |
| 468 | }); |
nothing calls this directly
no test coverage detected