SaveTool: implement weapon copying.
This commit is contained in:
parent
d74a7bc219
commit
940fe3feee
1 changed files with 53 additions and 43 deletions
|
@ -635,49 +635,59 @@ void SaveTool::drawWeapons() {
|
|||
|
||||
int id = 0;
|
||||
|
||||
#define weapcat(header, array, dirty, payload_type, payload_tooltip) \
|
||||
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); \
|
||||
ImGui::TableNextColumn(); \
|
||||
ImGui::TextUnformatted(header); \
|
||||
\
|
||||
for(UnsignedInt i = 0; i < _currentMass->array().size(); i++) { \
|
||||
auto& weapon = _currentMass->array()[i]; \
|
||||
\
|
||||
ImGui::TableNextRow(); \
|
||||
ImGui::TableNextColumn(); \
|
||||
ImGui::PushID(id); \
|
||||
if(ImGui::Selectable(weapon.name.c_str(), current_weapon == &weapon)) { \
|
||||
current_weapon = &weapon; \
|
||||
} \
|
||||
if(ImGui::BeginDragDropSource()) { \
|
||||
ImGui::SetDragDropPayload(payload_type, &i, sizeof(UnsignedInt)); \
|
||||
ImGui::Text(payload_tooltip " %i - %s", i + 1, weapon.name.c_str()); \
|
||||
ImGui::EndDragDropSource(); \
|
||||
} \
|
||||
if(ImGui::BeginDragDropTarget()) { \
|
||||
if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(payload_type)) { \
|
||||
int index = *static_cast<int*>(payload->Data); \
|
||||
\
|
||||
if(current_weapon == &_currentMass->array()[index]) { \
|
||||
current_weapon = &_currentMass->array()[i]; \
|
||||
} \
|
||||
else if (current_weapon == &_currentMass->array()[i]) { \
|
||||
current_weapon = &_currentMass->array()[index]; \
|
||||
} \
|
||||
\
|
||||
std::swap(_currentMass->array()[index], _currentMass->array()[i]); \
|
||||
(dirty) = true; \
|
||||
} \
|
||||
\
|
||||
ImGui::EndDragDropTarget(); \
|
||||
} \
|
||||
\
|
||||
ImGui::PopID(); \
|
||||
id++; \
|
||||
\
|
||||
if(weapon.attached == true) { \
|
||||
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, 0x1F008CFFu); \
|
||||
} \
|
||||
#define weapcat(header, array, dirty, payload_type, payload_tooltip) \
|
||||
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); \
|
||||
ImGui::TableNextColumn(); \
|
||||
ImGui::TextUnformatted(header); \
|
||||
\
|
||||
for(UnsignedInt i = 0; i < _currentMass->array().size(); i++) { \
|
||||
auto& weapon = _currentMass->array()[i]; \
|
||||
\
|
||||
ImGui::TableNextRow(); \
|
||||
ImGui::TableNextColumn(); \
|
||||
ImGui::PushID(id); \
|
||||
if(ImGui::Selectable(weapon.name.c_str(), current_weapon == &weapon)) { \
|
||||
current_weapon = &weapon; \
|
||||
} \
|
||||
if(ImGui::BeginDragDropSource()) { \
|
||||
ImGui::SetDragDropPayload(payload_type, &i, sizeof(UnsignedInt)); \
|
||||
if(ImGui::GetIO().KeyCtrl) { \
|
||||
ImGui::Text(payload_tooltip " %i - %s (copy)", i + 1, weapon.name.c_str()); \
|
||||
} \
|
||||
else { \
|
||||
ImGui::Text(payload_tooltip " %i - %s", i + 1, weapon.name.c_str()); \
|
||||
} \
|
||||
ImGui::EndDragDropSource(); \
|
||||
} \
|
||||
if(ImGui::BeginDragDropTarget()) { \
|
||||
if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(payload_type)) { \
|
||||
int index = *static_cast<int*>(payload->Data); \
|
||||
\
|
||||
if(!ImGui::GetIO().KeyCtrl) { \
|
||||
if(current_weapon == &_currentMass->array()[index]) { \
|
||||
current_weapon = &_currentMass->array()[i]; \
|
||||
} \
|
||||
else if (current_weapon == &_currentMass->array()[i]) { \
|
||||
current_weapon = &_currentMass->array()[index]; \
|
||||
} \
|
||||
\
|
||||
std::swap(_currentMass->array()[index], _currentMass->array()[i]); \
|
||||
} \
|
||||
else { \
|
||||
_currentMass->array()[i] = _currentMass->array()[index]; \
|
||||
} \
|
||||
(dirty) = true; \
|
||||
} \
|
||||
\
|
||||
ImGui::EndDragDropTarget(); \
|
||||
} \
|
||||
\
|
||||
ImGui::PopID(); \
|
||||
id++; \
|
||||
\
|
||||
if(weapon.attached == true) { \
|
||||
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, 0x1F008CFFu); \
|
||||
} \
|
||||
}
|
||||
|
||||
weapcat("Melee weapons", meleeWeapons, _meleeDirty, "MeleeWeapon", "Melee weapon")
|
||||
|
|
Loading…
Reference in a new issue