| 77 | } |
| 78 | |
| 79 | void CGameTask::Load(const TASK_ID& id) |
| 80 | { |
| 81 | m_ID = id; |
| 82 | |
| 83 | if (!g_gameTaskXml) |
| 84 | { |
| 85 | g_gameTaskXml = xr_new<CUIXml>(); |
| 86 | g_gameTaskXml->Init(CONFIG_PATH, "gameplay", "game_tasks.xml"); |
| 87 | } |
| 88 | XML_NODE* task_node = g_gameTaskXml->NavigateToNodeWithAttribute("game_task", "id", *id); |
| 89 | |
| 90 | THROW3(task_node, "game task id=", *id); |
| 91 | g_gameTaskXml->SetLocalRoot(task_node); |
| 92 | m_Title = g_gameTaskXml->Read(g_gameTaskXml->GetLocalRoot(), "title", 0, NULL); |
| 93 | m_priority = g_gameTaskXml->ReadAttribInt(g_gameTaskXml->GetLocalRoot(), "prio", -1); |
| 94 | m_version = g_gameTaskXml->ReadAttribInt(g_gameTaskXml->GetLocalRoot(), "version", 0); |
| 95 | m_objectives_version = g_gameTaskXml->ReadAttribInt(g_gameTaskXml->GetLocalRoot(), "objectives_version", 0); |
| 96 | m_show_all_objectives = |
| 97 | !!g_gameTaskXml->ReadAttribInt(g_gameTaskXml->GetLocalRoot(), "show_all_objectives", (Core.Features.test(xrCore::Feature::show_objectives_ondemand) ? 0 : 1)); |
| 98 | #ifdef DEBUG |
| 99 | if (m_priority == u32(-1)) |
| 100 | { |
| 101 | Msg("Game Task [%s] has no priority", *id); |
| 102 | } |
| 103 | #endif // DEBUG |
| 104 | int tag_num = g_gameTaskXml->GetNodesNum(g_gameTaskXml->GetLocalRoot(), "objective"); |
| 105 | m_Objectives.clear(); |
| 106 | for (int i = 0; i < tag_num; i++) |
| 107 | { |
| 108 | XML_NODE* l_root = NULL; |
| 109 | l_root = g_gameTaskXml->NavigateToNode("objective", i); |
| 110 | g_gameTaskXml->SetLocalRoot(l_root); |
| 111 | |
| 112 | m_Objectives.emplace_back(this, i); |
| 113 | SGameTaskObjective& objective = m_Objectives.back(); |
| 114 | |
| 115 | //. |
| 116 | LPCSTR tag_text = g_gameTaskXml->Read(l_root, "text", 0, NULL); |
| 117 | objective.description = tag_text; |
| 118 | //. |
| 119 | tag_text = g_gameTaskXml->Read(l_root, "article", 0, NULL); |
| 120 | if (tag_text) |
| 121 | objective.article_id = tag_text; |
| 122 | |
| 123 | //. |
| 124 | if (i == 0) |
| 125 | { |
| 126 | objective.icon_texture_name = g_gameTaskXml->Read(g_gameTaskXml->GetLocalRoot(), "icon", 0, NULL); |
| 127 | if (objective.icon_texture_name.size() && 0 != _stricmp(*objective.icon_texture_name, "ui\\ui_icons_task")) |
| 128 | { |
| 129 | objective.icon_rect = CUITextureMaster::GetTextureRect(*objective.icon_texture_name); |
| 130 | objective.icon_rect.rb.sub(objective.icon_rect.rb, objective.icon_rect.lt); |
| 131 | objective.icon_texture_name = CUITextureMaster::GetTextureFileName(*objective.icon_texture_name); |
| 132 | } |
| 133 | else if (objective.icon_texture_name.size()) |
| 134 | { |
| 135 | objective.icon_rect.x1 = g_gameTaskXml->ReadAttribFlt(l_root, "icon", 0, "x"); |
| 136 | objective.icon_rect.y1 = g_gameTaskXml->ReadAttribFlt(l_root, "icon", 0, "y"); |
nothing calls this directly
no test coverage detected