void TreasureSupervisor::Initialize(MapTreasure* treasure) { if (!treasure) { IF_PRINT_WARNING(MAP_DEBUG) << "function argument was NULL" << std::endl; return; } _treasure = treasure; MapMode::CurrentInstance()->PushState(STATE_TREASURE); // Construct the object list, including any drunes that were contained within the treasure if (_treasure->_drunes != 0) { _list_options.AddOption(MakeUnicodeString("<img/icons/drunes.png> Drunes<R>" + NumberToString(_treasure->_drunes))); _coins_snd.Play(); } else { _items_snd.Play(); } for (uint32 i = 0; i < _treasure->_objects_list.size(); i++) { if (_treasure->_objects_list[i]->GetCount() > 1) { _list_options.AddOption(MakeUnicodeString("<" + _treasure->_objects_list[i]->GetIconImage().GetFilename() + "> ") + _treasure->_objects_list[i]->GetName() + MakeUnicodeString("<R>x" + NumberToString(_treasure->_objects_list[i]->GetCount()))); } else { _list_options.AddOption(MakeUnicodeString("<" + _treasure->_objects_list[i]->GetIconImage().GetFilename() + "> ") + _treasure->_objects_list[i]->GetName()); } } for (uint32 i = 0; i < _list_options.GetNumberOptions(); i++) { _list_options.GetEmbeddedImage(i)->SetDimensions(30.0f, 30.0f); } _action_options.SetSelection(0); _action_options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE); _list_options.SetSelection(0); _list_options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _selection = ACTION_SELECTED; _action_window.Show(); _list_window.Show(); // Immediately add the drunes and objects to the player's inventory GlobalManager->AddDrunes(_treasure->_drunes); for (uint32 i = 0; i < _treasure->_objects_list.size(); ++i) { GlobalObject* obj = _treasure->_objects_list[i]; if (!obj) continue; if (!GlobalManager->IsObjectInInventory(obj->GetID())) { // Pass a copy to the inventory, the treasure object will delete its content on destruction. hoa_global::GlobalObject* obj_copy = GlobalCreateNewObject(obj->GetID(), obj->GetCount()); GlobalManager->AddToInventory(obj_copy); } else { GlobalManager->IncrementObjectCount(obj->GetID(), obj->GetCount()); } } } // void TreasureSupervisor::Initialize(MapTreasure* treasure)