فهرست منبع

Update UI layer to support TroopType enum

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 2 ماه پیش
والد
کامیت
25a9cf0f4a
2فایلهای تغییر یافته به همراه11 افزوده شده و 2 حذف شده
  1. 3 2
      app/core/game_engine.cpp
  2. 8 0
      game/systems/production_service.h

+ 3 - 2
app/core/game_engine.cpp

@@ -6,6 +6,7 @@
 #include "../models/hover_tracker.h"
 #include "../utils/json_vec_utils.h"
 #include "game/audio/AudioSystem.h"
+#include "game/units/troop_type.h"
 #include <QBuffer>
 #include <QCoreApplication>
 #include <QCursor>
@@ -786,7 +787,7 @@ QVariantMap GameEngine::getSelectedProductionState() const {
       st);
   m["hasBarracks"] = st.hasBarracks;
   m["inProgress"] = st.inProgress;
-  m["productType"] = QString::fromStdString(st.productType);
+  m["productType"] = QString::fromStdString(Game::Units::troopTypeToString(st.productType));
   m["timeRemaining"] = st.timeRemaining;
   m["buildTime"] = st.buildTime;
   m["producedCount"] = st.producedCount;
@@ -796,7 +797,7 @@ QVariantMap GameEngine::getSelectedProductionState() const {
 
   QVariantList queueList;
   for (const auto &unitType : st.productionQueue) {
-    queueList.append(QString::fromStdString(unitType));
+    queueList.append(QString::fromStdString(Game::Units::troopTypeToString(unitType)));
   }
   m["productionQueue"] = queueList;
 

+ 8 - 0
game/systems/production_service.h

@@ -43,6 +43,14 @@ public:
       const std::vector<Engine::Core::EntityID> &selected, int ownerId,
       Game::Units::TroopType unitType);
 
+  static ProductionResult startProductionForFirstSelectedBarracks(
+      Engine::Core::World &world,
+      const std::vector<Engine::Core::EntityID> &selected, int ownerId,
+      const std::string &unitType) {
+    return startProductionForFirstSelectedBarracks(
+        world, selected, ownerId, Game::Units::troopTypeFromString(unitType));
+  }
+
   static bool setRallyForFirstSelectedBarracks(
       Engine::Core::World &world,
       const std::vector<Engine::Core::EntityID> &selected, int ownerId, float x,