Browse Source

added a timer

meemknight 2 years ago
parent
commit
8a5bca471b

+ 3 - 0
Pika/core/pikaEditor/containersWindow/containersWindow.cpp

@@ -395,6 +395,9 @@ void pika::ContainersWindow::update(pika::LogManager &logManager, bool &open, pi
 						{
 						{
 
 
 							ImGui::Text("Status: %s", c.flags.getStatusName());
 							ImGui::Text("Status: %s", c.flags.getStatusName());
+
+							ImGui::Text("Time (ms): %f", c.currentMs);
+
 							ImGui::Separator();
 							ImGui::Separator();
 
 
 							if (ImGui::BeginTabBar("##Tabs for play and record", ImGuiTabBarFlags_Reorderable))
 							if (ImGui::BeginTabBar("##Tabs for play and record", ImGuiTabBarFlags_Reorderable))

+ 20 - 5
Pika/core/pikaRuntime/containerManager/containerManager.cpp

@@ -295,11 +295,6 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 			auto windowInput = window.input;
 			auto windowInput = window.input;
 		
 		
 
 
-		#pragma region mouse pos
-			
-			
-		#pragma endregion
-
 		#if PIKA_DEVELOPMENT
 		#if PIKA_DEVELOPMENT
 
 
 			if (c.second.flags.status == pika::RuntimeContainer::FLAGS::STATUS_BEING_RECORDED)
 			if (c.second.flags.status == pika::RuntimeContainer::FLAGS::STATUS_BEING_RECORDED)
@@ -381,9 +376,29 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 
 
 			auto callUpdate = [&](pika::WindowState &windowState)
 			auto callUpdate = [&](pika::WindowState &windowState)
 			{
 			{
+
+				auto t1 = std::chrono::high_resolution_clock::now();
+
 				loadedDll.bindAllocatorDllRealm(&c.second.allocator);
 				loadedDll.bindAllocatorDllRealm(&c.second.allocator);
 				c.second.pointer->update(windowInput, windowState, c.second.requestedContainerInfo);
 				c.second.pointer->update(windowInput, windowState, c.second.requestedContainerInfo);
 				loadedDll.resetAllocatorDllRealm();
 				loadedDll.resetAllocatorDllRealm();
+
+				auto t2 = std::chrono::high_resolution_clock::now();
+				
+				auto milliseconds = (std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1)).count()/1000.f;
+
+				c.second.frameTimer += milliseconds;
+				c.second.frameCounter++;
+				if (c.second.frameCounter >= 100)
+				{
+					c.second.currentMs = c.second.frameTimer/100.f;
+
+					c.second.frameTimer = 0;
+					c.second.frameCounter = 0;
+				}
+				
+
+
 			};
 			};
 
 
 			if (c.second.imguiWindowId && !isProduction)
 			if (c.second.imguiWindowId && !isProduction)

+ 4 - 0
Pika/core/pikaRuntime/runtimeContainer/runtimeContainer.h

@@ -35,6 +35,10 @@ struct RuntimeContainer
 
 
 	int imguiWindowId = 0;
 	int imguiWindowId = 0;
 
 
+	unsigned int frameCounter = 0;
+	float frameTimer = 0;
+	float currentMs = 0;
+
 	struct FLAGS
 	struct FLAGS
 	{
 	{
 		enum
 		enum

+ 0 - 1
Pika/gameplay/containers/pikaGameplay.h

@@ -78,7 +78,6 @@ struct Gameplay : public Container
 			requestedInfo.consoleWrite(std::to_string(input.deltaTime).c_str());
 			requestedInfo.consoleWrite(std::to_string(input.deltaTime).c_str());
 		}
 		}
 
 
-
 		gl2d::enableNecessaryGLFeatures();
 		gl2d::enableNecessaryGLFeatures();
 		renderer.updateWindowMetrics(windowState.w, windowState.h);
 		renderer.updateWindowMetrics(windowState.w, windowState.h);
 
 

+ 4 - 5
Pika/resources/logs.txt

@@ -1,5 +1,4 @@
-#2023-01-23 21:44:36: Created container: Gameplay
-#2023-01-23 21:44:52: Reloaded dll
-#2023-01-23 21:45:12: Created container: ThreeDTest
-#2023-01-23 21:45:26: Destroyed continer: Gameplay #1
-#2023-01-23 21:45:26: Destroyed continer: ThreeDTest #2
+#2023-01-23 22:23:38: Created container: Gameplay
+#2023-01-23 22:23:51: Created container: ThreeDTest
+#2023-01-23 22:24:59: Destroyed continer: Gameplay #1
+#2023-01-23 22:24:59: Destroyed continer: ThreeDTest #2