Compare commits

...

3 commits

Author SHA1 Message Date
c054169124 SaveTool: update formatting of accessory numbers. 2022-11-24 11:13:08 +01:00
b58ff5a763 Maps/Accessories: separate the size from the label.
That now means it's possible to filter the accessory list by accessory
size.
2022-11-24 10:46:58 +01:00
28eb40f6b4 PropertySerialiser: remove logging for missing serialisers.
It's spammy when dealing with most structures in the save files.
2022-11-24 10:45:37 +01:00
3 changed files with 620 additions and 556 deletions

File diff suppressed because it is too large Load diff

View file

@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/ScopeGuard.h> #include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Utility/Format.h>
#include <Magnum/ImGuiIntegration/Integration.h> #include <Magnum/ImGuiIntegration/Integration.h>
@ -495,7 +496,7 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::TextUnformatted("Accessory: <none>"); ImGui::TextUnformatted("Accessory: <none>");
} }
else if(accessories.find(accessory.id) != accessories.cend()) { else if(accessories.find(accessory.id) != accessories.cend()) {
ImGui::Text("Accessory #%i - %s", accessory.id, accessories.at(accessory.id).data()); ImGui::Text("Accessory #%.4i - %s", accessory.id, accessories.at(accessory.id).name.data());
} }
else { else {
ImGui::Text("Accessory #%i", accessory.id); ImGui::Text("Accessory #%i", accessory.id);
@ -505,12 +506,10 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::SameLine(); ImGui::SameLine();
static Int tab = 0; static Int tab = 0;
static Containers::Optional<AccessorySize> size = Containers::NullOpt;
if(ImGui::SmallButton("Change")) { if(ImGui::SmallButton("Change")) {
ImGui::OpenPopup("##AccessoryPopup"); ImGui::OpenPopup("##AccessoryPopup");
if(accessory.id < 1000) { if(accessory.id >= 3000) {
tab = 0;
}
else if(accessory.id >= 3000) {
tab = 3; tab = 3;
} }
else if(accessory.id >= 2000) { else if(accessory.id >= 2000) {
@ -519,9 +518,18 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
else if(accessory.id >= 1000) { else if(accessory.id >= 1000) {
tab = 1; tab = 1;
} }
else {
tab = 0;
}
} }
if(ImGui::BeginPopup("##AccessoryPopup")) { if(ImGui::BeginPopup("##AccessoryPopup")) {
Float selectable_width = 90.0f; static const char* size_labels[] = {
"S",
"M",
"L",
"XL"
};
static const Float selectable_width = 90.0f;
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f}); ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f});
if(ImGui::Selectable("Primitives", tab == 0, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) { if(ImGui::Selectable("Primitives", tab == 0, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) {
@ -549,10 +557,56 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::Separator(); ImGui::Separator();
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f});
if(ImGui::Selectable("All", !size, ImGuiSelectableFlags_DontClosePopups, {70.0f, 0.0f})) {
size = Containers::NullOpt;
}
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
if(ImGui::Selectable("S", size && *size == AccessorySize::S, ImGuiSelectableFlags_DontClosePopups, {70.0f, 0.0f})) {
if(!size) {
size.emplace();
}
*size = AccessorySize::S;
}
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
if(ImGui::Selectable("M", size && *size == AccessorySize::M, ImGuiSelectableFlags_DontClosePopups, {70.0f, 0.0f})) {
if(!size) {
size.emplace();
}
*size = AccessorySize::M;
}
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
if(ImGui::Selectable("L", size && *size == AccessorySize::L, ImGuiSelectableFlags_DontClosePopups, {70.0f, 0.0f})) {
if(!size) {
size.emplace();
}
*size = AccessorySize::L;
}
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
if(ImGui::Selectable("XL", size && *size == AccessorySize::XL, ImGuiSelectableFlags_DontClosePopups, {70.0f, 0.0f})) {
if(!size) {
size.emplace();
}
*size = AccessorySize::XL;
}
ImGui::PopStyleVar();
ImGui::Separator();
if(ImGui::BeginListBox("##AccessoryListbox", {-1.0f, 0.0f})) { if(ImGui::BeginListBox("##AccessoryListbox", {-1.0f, 0.0f})) {
for(const auto& acc : accessories) { for(const auto& acc : accessories) {
if(acc.first >= tab * 1000 && acc.first < ((tab + 1) * 1000)) { if(acc.first >= tab * 1000 && acc.first < ((tab + 1) * 1000) && (!size || *size == acc.second.size)) {
if(ImGui::Selectable(acc.second.data(), acc.first == accessory.id)) { if(ImGui::Selectable(Utility::format("#{:.4d} - {} ({})", acc.first, acc.second.name, size_labels[acc.second.size]).data(),
acc.first == accessory.id))
{
accessory.id = acc.first; accessory.id = acc.first;
accessory.attachIndex = 0; accessory.attachIndex = 0;
} }

View file

@ -160,7 +160,6 @@ auto PropertySerialiser::deserialise(Containers::String name, Containers::String
auto serialiser = getSerialiser(type); auto serialiser = getSerialiser(type);
if(serialiser == nullptr) { if(serialiser == nullptr) {
LOG_ERROR_FORMAT("No valid serialiser found for property type {}.", type);
return nullptr; return nullptr;
} }
@ -182,7 +181,6 @@ auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St
{ {
auto serialiser = getSerialiser(item_type); auto serialiser = getSerialiser(item_type);
if(!serialiser) { if(!serialiser) {
LOG_ERROR_FORMAT("No valid serialiser found for property type {}.", item_type);
return false; return false;
} }
return serialiser->serialise(prop, bytes_written, writer, *this); return serialiser->serialise(prop, bytes_written, writer, *this);