Search bar for all tabs
This commit is contained in:
parent
de734aa66f
commit
3101984c3b
|
|
@ -19,6 +19,12 @@ ABowserStatue::ABowserStatue(const SpawnParams& params) {
|
|||
ResourceName = "mk:bowser_statue";
|
||||
FVector pos = params.Location.value_or(FVector(0, 0, 0));
|
||||
Pos[0] = pos.x; Pos[1] = pos.y; Pos[2] = pos.z;
|
||||
|
||||
IRotator rot = params.Rotation.value_or(IRotator(0, 0, 0));
|
||||
Rot[0] = rot.pitch; Rot[1] = rot.yaw; Rot[2] = rot.roll;
|
||||
|
||||
Scale = params.Scale.value_or(FVector(1.0f, 1.0f, 1.0f));
|
||||
|
||||
mBehaviour = static_cast<ABowserStatue::Behaviour>(params.Behaviour.value_or(0));
|
||||
}
|
||||
|
||||
|
|
@ -33,11 +39,11 @@ void ABowserStatue::Tick() {
|
|||
|
||||
void ABowserStatue::Draw(Camera *camera) {
|
||||
Mat4 mtx;
|
||||
FVector pos = FVector(Pos[0] + 76, Pos[1], Pos[2] + 1846);
|
||||
gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
|
||||
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
|
||||
|
||||
ApplyMatrixTransformations(mtx, pos, *(IRotator*)&Rot, Scale);
|
||||
|
||||
FVector pos = FVector(Pos[0] + 76, Pos[1], Pos[2] + 1846);
|
||||
ApplyMatrixTransformations(mtx, pos, *(IRotator*)Rot, Scale);
|
||||
AddObjectMatrix(mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gDPSetCombineMode(gDisplayListHead++,G_CC_MODULATEIA, G_CC_MODULATEIA);
|
||||
gDPSetRenderMode(gDisplayListHead++,G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
|
||||
|
|
|
|||
|
|
@ -58,16 +58,23 @@ namespace Editor {
|
|||
ImGui::EndChild();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginChild("RightPanel", ImVec2(0, 0), true, ImGuiWindowFlags_None);
|
||||
|
||||
// Search bar
|
||||
ImGui::InputTextWithHint("##GlobalSearch", "Search name or #tag", mSearchBuffer, IM_ARRAYSIZE(mSearchBuffer));
|
||||
ImGui::NewLine();
|
||||
|
||||
std::string search = ToLower(std::string(mSearchBuffer));
|
||||
|
||||
if (TrackContent) {
|
||||
AddTrackContent();
|
||||
AddTrackContent(search);
|
||||
}
|
||||
|
||||
if (ActorContent) {
|
||||
AddActorContent();
|
||||
AddActorContent(search);
|
||||
}
|
||||
|
||||
if (CustomContent) {
|
||||
AddCustomContent();
|
||||
AddCustomContent(search);
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
|
@ -82,10 +89,16 @@ namespace Editor {
|
|||
}
|
||||
}
|
||||
|
||||
void ContentBrowserWindow::AddTrackContent() {
|
||||
void ContentBrowserWindow::AddTrackContent(std::string search) {
|
||||
size_t i_track = 0;
|
||||
for (const TrackInfo* info : gTrackRegistry.GetAllInfo()) {
|
||||
if (!info) { continue; }
|
||||
|
||||
if (!search.empty() &&
|
||||
ToLower(info->Name).find(search) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string label = fmt::format("{}##{}", info->Name, i_track);
|
||||
if (ImGui::Button(label.c_str())) {
|
||||
//gGamestateNext = RACING;
|
||||
|
|
@ -105,21 +118,16 @@ namespace Editor {
|
|||
}
|
||||
}
|
||||
|
||||
void ContentBrowserWindow::AddActorContent() {
|
||||
static char searchBuffer[128] = ""; // Persistent search input
|
||||
void ContentBrowserWindow::AddActorContent(std::string search) {
|
||||
|
||||
// Draw search bar
|
||||
ImGui::InputTextWithHint("##SearchActors", "Search name or #tag", searchBuffer, IM_ARRAYSIZE(searchBuffer));
|
||||
ImGui::NewLine();
|
||||
std::string searchStr = searchBuffer;
|
||||
bool isTagSearch = false;
|
||||
std::string tagToSearch;
|
||||
|
||||
if (!searchStr.empty() && searchStr[0] == '#') {
|
||||
if (!search.empty() && search[0] == '#') {
|
||||
isTagSearch = true;
|
||||
tagToSearch = ToLower(searchStr.substr(1)); // Remove the #
|
||||
tagToSearch = ToLower(search.substr(1)); // Remove the #
|
||||
} else {
|
||||
searchStr = ToLower(searchStr);
|
||||
search = ToLower(search);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -142,12 +150,12 @@ void ContentBrowserWindow::AddActorContent() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (!searchStr.empty()) {
|
||||
if (ToLower(actorInfo->Name).find(searchStr) != std::string::npos) {
|
||||
} else if (!search.empty()) {
|
||||
if (ToLower(actorInfo->Name).find(search) != std::string::npos) {
|
||||
show = true;
|
||||
}
|
||||
} else {
|
||||
show = true; // No search → show all
|
||||
show = true; // No search --> show all
|
||||
}
|
||||
|
||||
if (!show) continue;
|
||||
|
|
@ -182,11 +190,17 @@ void ContentBrowserWindow::AddActorContent() {
|
|||
}
|
||||
|
||||
|
||||
void ContentBrowserWindow::AddCustomContent() {
|
||||
void ContentBrowserWindow::AddCustomContent(std::string search) {
|
||||
FVector pos = GetPositionAheadOfCamera(300.0f);
|
||||
|
||||
size_t i_custom = 0;
|
||||
for (const auto& file : Content) {
|
||||
std::string name = ToLower(file);
|
||||
if (!search.empty() &&
|
||||
name.find(search) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((i_custom != 0) && (i_custom % 5 == 0)) {
|
||||
} else {
|
||||
ImGui::SameLine();
|
||||
|
|
@ -222,6 +236,12 @@ void ContentBrowserWindow::AddActorContent() {
|
|||
} else if (file.find("_vertices") != std::string::npos) {
|
||||
// Has _vertices
|
||||
continue;
|
||||
} else if (file.find("_spawns") != std::string::npos) {
|
||||
// has _spawns
|
||||
continue;
|
||||
} else if (file.find("_waypoints") != std::string::npos) {
|
||||
// has _waypoints
|
||||
continue;
|
||||
} else if (file.find('.') != std::string::npos) {
|
||||
// File has an extension
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -21,14 +21,15 @@ protected:
|
|||
void InitElement() override {};
|
||||
void DrawElement() override;
|
||||
void UpdateElement() override {};
|
||||
void AddTrackContent();
|
||||
void AddActorContent();
|
||||
void AddCustomContent();
|
||||
void AddTrackContent(std::string search);
|
||||
void AddActorContent(std::string search);
|
||||
void AddCustomContent(std::string search);
|
||||
void FindContent();
|
||||
void FolderButton(const char* label, bool& contentFlag, const ImVec2& size = ImVec2(80, 32));
|
||||
ATrain* TrainWindow();
|
||||
|
||||
private:
|
||||
char mSearchBuffer[128] = ""; // Search bar for all tabs
|
||||
static std::string ToLower(const std::string& str) {
|
||||
std::string result = str;
|
||||
std::transform(result.begin(), result.end(), result.begin(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue