Exemple #1
0
void UiController::PerformUpdateUI()
{
	OnUpdateUI();

	bool show_ui = IsUiOn();
	if (!show_ui)
		return;

	bool do_ui = ImGui::Begin("MQ2Nav Tools", &show_ui, ImVec2(400, 400), -1, 0);

	if (!show_ui) {
		mq2nav::GetSettings().show_ui = false;
		mq2nav::SaveSettings();
	}

	if (!do_ui) {
		ImGui::End();
		return;
	}

	ImGui::TabLabels(static_cast<int>(TabPage::Max), s_tabNames, m_selectedTab,
		nullptr, true, nullptr);
	TabPage selectedTab = static_cast<TabPage>(m_selectedTab);

	ImGui::Separator();

	PerformUpdateTab(selectedTab);
	OnTabUpdate(selectedTab);

	ImGui::End();
}
Exemple #2
0
void UiController::PerformUpdateTab(TabPage page)
{
	if (page == TabPage::Settings)
	{
		// "Settings" section (maybe make a separate window?)
		bool changed = false;
		auto& settings = mq2nav::GetSettings();

		enum BreakBehavior {
			DoNothing = 0,
			Stop = 1,
			Pause = 2
		};

		int current = DoNothing;
		if (settings.autobreak)
			current = Stop;
		else  if (settings.autopause)
			current = Pause;

		if (ImGui::Combo("Break Behavior", &current, "Disabled\0Stop Navigation\0Pause Navigation"))
		{
			settings.autobreak = current == Stop;
			settings.autopause = current == Pause;
			changed = true;
		}
		if (ImGui::IsItemHovered())
			ImGui::SetTooltip(
				"Auto Break Behavior\n"
				"-------------------------------------------------\n"
				"What happens when a movement key is pressed.\n"
				"  Disable - Auto break is turned off\n"
				"  Stop - Stop the navigation\n"
				"  Pause - Pause navigation. /nav pause to unpause");

		if (ImGui::Checkbox("Attempt to get unstuck", &settings.attempt_unstuck))
			changed = true;
		if (ImGui::IsItemHovered())
			ImGui::SetTooltip("Automatically try to get unstuck of movement is impeeded.\nThis will do things like jump and click randomly. Use with caution!");

		if (ImGui::Checkbox("Auto update nav mesh", &settings.autoreload))
		{
			changed = true;
		}
		if (ImGui::IsItemHovered())
			ImGui::SetTooltip("Automatically reload the navmesh when it is modified");

		if (changed)
			mq2nav::SaveSettings();
	}

	else if (page == TabPage::Tools)
	{
		auto modelLoader = g_mq2Nav->Get<ModelLoader>();
		modelLoader->OnUpdateUI();
	}

	else if (page == TabPage::Waypoints)
	{
		mq2nav::RenderWaypointsUI();
	}

	else if (page == TabPage::Theme)
	{
		ImGui::ShowStyleEditor();
	}
}
Exemple #3
0
void MQ2NavigationPlugin::OnUpdateTab(TabPage tabId)
{
	if (tabId == TabPage::Navigation)
	{
		ImGui::TextColored(ImColor(255, 255, 0), "Type /nav ui to toggle this window");

		if (ImGui::Checkbox("Pause navigation", &m_isPaused)) {
			if (m_isPaused)
				MQ2Globals::ExecuteCmd(FindMappableCommand("FORWARD"), 0, 0);
		}

		if (ImGui::CollapsingHeader("Pathing Debug"))
		{
			bool settingsChanged = false;
			auto& settings = mq2nav::GetSettings();

			if (ImGui::Checkbox("Render pathing debug draw", &settings.debug_render_pathing))
				settingsChanged = true;
			if (ImGui::Checkbox("Use Pathing Corridor (experimental)", &settings.debug_use_pathing_corridor))
				settingsChanged = true;

			if (settingsChanged)
				mq2nav::SaveSettings();

			if (m_activePath) 
			{
				auto charInfo = GetCharInfo();
				glm::vec3 myPos(charInfo->pSpawn->X, charInfo->pSpawn->Z, charInfo->pSpawn->Y);
				auto dest = m_activePath->GetDestination();

				ImGui::LabelText("Position", "(%.2f, %.2f, %.2f)", myPos.x, myPos.y, myPos.z);

				ImGui::LabelText("Current Waypoint", "(%.2f, %.2f, %.2f,",
					m_currentWaypoint.x, m_currentWaypoint.y, m_currentWaypoint.z);
				ImGui::LabelText("Distance to Waypoint", "%.2f", glm::distance(m_currentWaypoint, myPos));

				ImGui::LabelText("Destination", "(%.2f, %.2f, %.2f)", dest.x, dest.y, dest.z);
				ImGui::LabelText("Distance", "%.2f", glm::distance(dest, myPos));

				ImGui::Text("Path Nodes");
				ImGui::Separator();

				ImGui::BeginChild("PathNodes");
				for (int i = 0; i < m_activePath->GetPathSize(); ++i)
				{
					ImColor color(255, 255, 255);

					if (i == 0)
						color = ImColor(255, 255, 0);
					if (i == m_activePath->GetPathIndex())
						color = ImColor(0, 255, 0);
					if (i == m_activePath->GetPathSize() - 1)
						color = ImColor(255, 0, 0);

					auto pos = m_activePath->GetRawPosition(i);
					ImGui::TextColored(color, "%04d: (%.2f, %.2f, %.2f)", i,
						pos[0], pos[1], pos[2]);
				}
				ImGui::EndChild();
			}
			else {
				ImGui::LabelText("Destination", "<none>");
				ImGui::LabelText("Distance", "");
			}

			ImGui::Separator();
			ImGui::LabelText("Ending Door", "%s", m_pEndingDoor ? m_pEndingDoor->Name : "<none>");
			ImGui::LabelText("Ending Item", "%s", m_pEndingItem ? m_pEndingItem->Name : "<none>");
			ImGui::LabelText("Is Active", "%s", m_isActive ? "true" : "false");
			ImGui::LabelText("Spam Click", "%s", m_bSpamClick ? "true" : "false");
			ImGui::LabelText("Current Waypoint", "(%.2f, %.2f, %.2f)", m_currentWaypoint.x, m_currentWaypoint.y, m_currentWaypoint.z);
			ImGui::LabelText("Stuck Data", "(%.2f, %.2f) %d", m_stuckX, m_stuckY, m_stuckTimer.time_since_epoch());
			ImGui::LabelText("Last Click", "%d", m_lastClick.time_since_epoch() / 1000000);
			ImGui::LabelText("Pathfind Timer", "%d", m_pathfindTimer.time_since_epoch() / 1000000);
		}

		ImGui::Separator();

		auto navmeshRenderer = Get<NavMeshRenderer>();
		navmeshRenderer->OnUpdateUI();

		if (m_activePath) m_activePath->OnUpdateUI();
	}
}