Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert default visibility #347

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions xml_converter/doc/menu/default_visibility.md

This file was deleted.

22 changes: 22 additions & 0 deletions xml_converter/doc/menu/hide_category.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Hide Category
type: Boolean
applies_to: [Category]
xml_fields: [DefaultToggle]
protobuf_field: hide_category
custom_functions:
read.xml:
function: inverted_xml_attribute_to_bool
side_effects: []
write.xml:
function: bool_to_inverted_xml_attribute
side_effects: []
---

Notes
=====
If the category should be shown or hidden on or off by default.

https://blishhud.com/docs/markers/attributes/defaulttoggle


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_hide_category/input/pack/markers.bin.textproto._old	2024-09-05 01:20:42.761849680 +0000
+++ xml_converter/integration_tests/test_cases/proto_hide_category/input/pack/markers.bin.textproto._new	2024-09-05 01:20:42.765849687 +0000
@@ -0,0 +1,50 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "My Category 2"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3404\0141b"
+}
+category {
+  name: "My Category 3"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\355i\3405\0141b"
+}
+category {
+  name: "My Category 4"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3406\0141b"
+}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_hide_category/input/pack/markers.bin.textproto._old	2024-09-05 01:23:50.377220259 +0000
+++ xml_converter/integration_tests/test_cases/proto_hide_category/input/pack/markers.bin.textproto._new	2024-09-05 01:23:50.385220281 +0000
@@ -0,0 +1,50 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "My Category 2"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3404\0141b"
+}
+category {
+  name: "My Category 3"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\355i\3405\0141b"
+}
+category {
+  name: "My Category 4"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3406\0141b"
+}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_hide_category/input/pack/markers.bin.textproto._old	2024-09-08 00:48:04.767466414 +0000
+++ xml_converter/integration_tests/test_cases/proto_hide_category/input/pack/markers.bin.textproto._new	2024-09-08 00:48:04.775466387 +0000
@@ -0,0 +1,50 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "My Category 2"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3404\0141b"
+}
+category {
+  name: "My Category 3"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\355i\3405\0141b"
+}
+category {
+  name: "My Category 4"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3406\0141b"
+}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

.
My Category 2B\Ï)Cf¦RC{ÔWC0B(èÌ“^–
.
My Category 2 2B\Ï)Cf¦RC{ÔWCB(íià4 1b
0
My Category 3 2B\Ï)Cf¦RC{ÔWC0B(íià5 1b
.
My Category 4 2B\Ï)Cf¦RC{ÔWCB(íià6 1b
Expand Down
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_hide_category/output_proto/markers.bin.textproto._old	2024-09-05 01:20:42.773849700 +0000
+++ xml_converter/integration_tests/test_cases/proto_hide_category/output_proto/markers.bin.textproto._new	2024-09-05 01:20:42.781849713 +0000
@@ -0,0 +1,50 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "My Category 2"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3404\0141b"
+}
+category {
+  name: "My Category 3"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\355i\3405\0141b"
+}
+category {
+  name: "My Category 4"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3406\0141b"
+}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_hide_category/output_proto/markers.bin.textproto._old	2024-09-05 01:23:50.389220292 +0000
+++ xml_converter/integration_tests/test_cases/proto_hide_category/output_proto/markers.bin.textproto._new	2024-09-05 01:23:50.397220314 +0000
@@ -0,0 +1,50 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "My Category 2"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3404\0141b"
+}
+category {
+  name: "My Category 3"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\355i\3405\0141b"
+}
+category {
+  name: "My Category 4"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3406\0141b"
+}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_hide_category/output_proto/markers.bin.textproto._old	2024-09-08 00:48:04.795466321 +0000
+++ xml_converter/integration_tests/test_cases/proto_hide_category/output_proto/markers.bin.textproto._new	2024-09-08 00:48:04.803466295 +0000
@@ -0,0 +1,50 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "My Category 2"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3404\0141b"
+}
+category {
+  name: "My Category 3"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\355i\3405\0141b"
+}
+category {
+  name: "My Category 4"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3406\0141b"
+}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

.
My Category 2B\Ï)Cf¦RC{ÔWC0B(èÌ“^–
.
My Category 2 2B\Ï)Cf¦RC{ÔWCB(íià4 1b
0
My Category 3 2B\Ï)Cf¦RC{ÔWC0B(íià5 1b
.
My Category 4 2B\Ï)Cf¦RC{ÔWCB(íià6 1b
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" DefaultToggle="false" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<MarkerCategory DisplayName="My Category 2" ID="KO1p4DQMMWI=" Name="mycategory2">
</MarkerCategory>

<MarkerCategory DisplayName="My Category 3" DefaultToggle="false" ID="KO1p4DUMMWI=" Name="mycategory3">
</MarkerCategory>

<MarkerCategory DisplayName="My Category 4" ID="KO1p4DYMMWI=" Name="mycategory4">
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory2" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory3" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory4" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
</OverlayData>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
input_paths:
"pack": "proto"
expected_stdout: |
expected_stderr: |
expected_returncode: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" DefaultToggle="false" Name="mycategory">
</MarkerCategory>
<MarkerCategory DisplayName="My Category 2" DefaultToggle="true" Name="mycategory2">
</MarkerCategory>
<MarkerCategory DisplayName="My Category 3" DefaultToggle="0" Name="mycategory3">
</MarkerCategory>
<MarkerCategory DisplayName="My Category 4" DefaultToggle="1" Name="mycategory4">
</MarkerCategory>
<POIs>
<POI Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" />
<POI Type="mycategory2" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" />
<POI Type="mycategory3" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" />
<POI Type="mycategory4" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" />
</POIs>
</OverlayData>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_default_toggle/output_proto/markers.bin.textproto._old	2024-09-05 01:23:50.405220336 +0000
+++ xml_converter/integration_tests/test_cases/xml_default_toggle/output_proto/markers.bin.textproto._new	2024-09-05 01:23:50.413220357 +0000
@@ -0,0 +1,50 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "My Category 2"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3404\0141b"
+}
+category {
+  name: "My Category 3"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\355i\3405\0141b"
+}
+category {
+  name: "My Category 4"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3406\0141b"
+}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_default_toggle/output_proto/markers.bin.textproto._old	2024-09-08 00:48:04.807466282 +0000
+++ xml_converter/integration_tests/test_cases/xml_default_toggle/output_proto/markers.bin.textproto._new	2024-09-08 00:48:04.815466255 +0000
@@ -0,0 +1,50 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "My Category 2"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3404\0141b"
+}
+category {
+  name: "My Category 3"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  default_visibility: true
+  id: "(\355i\3405\0141b"
+}
+category {
+  name: "My Category 4"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\355i\3406\0141b"
+}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

.
My Category 2B\Ï)Cf¦RC{ÔWC0B(èÌ“^–
.
My Category 2 2B\Ï)Cf¦RC{ÔWCB(íià4 1b
0
My Category 3 2B\Ï)Cf¦RC{ÔWC0B(íià5 1b
.
My Category 4 2B\Ï)Cf¦RC{ÔWCB(íià6 1b
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" DefaultToggle="false" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<MarkerCategory DisplayName="My Category 2" DefaultToggle="true" ID="KO1p4DQMMWI=" Name="mycategory2">
</MarkerCategory>

<MarkerCategory DisplayName="My Category 3" DefaultToggle="false" ID="KO1p4DUMMWI=" Name="mycategory3">
</MarkerCategory>

<MarkerCategory DisplayName="My Category 4" DefaultToggle="true" ID="KO1p4DYMMWI=" Name="mycategory4">
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory2" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory3" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory4" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
</OverlayData>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
input_paths:
"pack": "xml"
expected_stdout: |
expected_stderr: |
expected_returncode: 0
2 changes: 1 addition & 1 deletion xml_converter/proto/waypoint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ message Category {
repeated Icon icon = 3;
repeated Trail trail = 4;
bool is_separator = 5;
bool default_visibility = 6;
bool hide_category = 6;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What were other names that were considered here and why did you decide on hide_category?
As it is written now this field is Category.hide_category which seems redundant.
Just removing category and making it Category.hide might look like a good idea initially but will it make intuitive sense when combined with the hidden/shown safe file data too?

Copy link
Contributor Author

@klingbolt klingbolt Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other top names I considered were hide_by_default and default_hide_category.
There is another field in the XML called hide that we made trigger.action_hide_category so I used that naming convention. Though on further thought, that field is a Category object and this one is a bool so maybe they don't need to be similar.
I considered using hide but was concerned that it was too similar to the Godot function hide() and that when accessing this field, Category.get_hide() isn't descriptive enough.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut tells me that hide_category is too imperative / verb-ish when it should be more declarative / noun-ish.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

How about is_hidden? This makes it clear its a property not a command. Also fits with some other attributes like is_separator and is_wall.

string tip_description = 7;
bytes id = 8;
}
Expand Down
28 changes: 14 additions & 14 deletions xml_converter/src/category_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ void Category::init_from_xml(rapidxml::xml_node<>* node, vector<XMLError*>* erro
bool Category::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector<XMLError*>* errors, XMLReaderState* state) {
string attributename;
attributename = normalize(get_attribute_name(attribute));
if (attributename == "defaulttoggle") {
xml_attribute_to_bool(attribute, errors, state, &(this->default_visibility), &(this->default_visibility_is_set));
}
else if (attributename == "displayname") {
if (attributename == "displayname") {
xml_attribute_to_string(attribute, errors, state, &(this->display_name), &(this->display_name_is_set));
}
else if (attributename == "defaulttoggle") {
inverted_xml_attribute_to_bool(attribute, errors, state, &(this->hide_category), &(this->hide_category_is_set));
}
else if (attributename == "isseparator") {
xml_attribute_to_bool(attribute, errors, state, &(this->is_separator), &(this->is_separator_is_set));
}
Expand All @@ -78,12 +78,12 @@ bool Category::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector<X
vector<string> Category::as_xml(XMLWriterState* state) const {
vector<string> xml_node_contents;
xml_node_contents.push_back("<MarkerCategory ");
if (this->default_visibility_is_set) {
xml_node_contents.push_back(bool_to_xml_attribute("DefaultToggle", state, &this->default_visibility));
}
if (this->display_name_is_set) {
xml_node_contents.push_back(string_to_xml_attribute("DisplayName", state, &this->display_name));
}
if (this->hide_category_is_set) {
xml_node_contents.push_back(bool_to_inverted_xml_attribute("DefaultToggle", state, &this->hide_category));
}
if (this->is_separator_is_set) {
xml_node_contents.push_back(bool_to_xml_attribute("IsSeparator", state, &this->is_separator));
}
Expand Down Expand Up @@ -113,14 +113,14 @@ vector<string> Category::as_xml(XMLWriterState* state) const {

waypoint::Category Category::as_protobuf(ProtoWriterState* state) const {
waypoint::Category proto_category;
if (this->default_visibility_is_set) {
std::function<void(bool)> setter = [&proto_category](bool val) { proto_category.set_default_visibility(val); };
bool_to_proto(this->default_visibility, state, setter);
}
if (this->display_name_is_set) {
std::function<void(std::string)> setter = [&proto_category](std::string val) { proto_category.set_name(val); };
display_name_and_name_to_proto_display_name(this->display_name, state, setter, &(this->name), &(this->name_is_set));
}
if (this->hide_category_is_set) {
std::function<void(bool)> setter = [&proto_category](bool val) { proto_category.set_hide_category(val); };
bool_to_proto(this->hide_category, state, setter);
}
if (this->is_separator_is_set) {
std::function<void(bool)> setter = [&proto_category](bool val) { proto_category.set_is_separator(val); };
bool_to_proto(this->is_separator, state, setter);
Expand All @@ -137,12 +137,12 @@ waypoint::Category Category::as_protobuf(ProtoWriterState* state) const {
}

void Category::parse_protobuf(waypoint::Category proto_category, ProtoReaderState* state) {
if (proto_category.default_visibility() != 0) {
proto_to_bool(proto_category.default_visibility(), state, &(this->default_visibility), &(this->default_visibility_is_set));
}
if (proto_category.name() != "") {
proto_display_name_to_display_name_and_name(proto_category.name(), state, &(this->display_name), &(this->display_name_is_set), &(this->name), &(this->name_is_set));
}
if (proto_category.hide_category() != 0) {
proto_to_bool(proto_category.hide_category(), state, &(this->hide_category), &(this->hide_category_is_set));
}
if (proto_category.is_separator() != 0) {
proto_to_bool(proto_category.is_separator(), state, &(this->is_separator), &(this->is_separator_is_set));
}
Expand Down
4 changes: 2 additions & 2 deletions xml_converter/src/category_gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class XMLError;

class Category : public Parseable {
public:
bool default_visibility;
std::string display_name;
bool hide_category;
bool is_separator;
UniqueId menu_id;
std::string name;
std::string tooltip_description;
bool default_visibility_is_set = false;
bool display_name_is_set = false;
bool hide_category_is_set = false;
bool is_separator_is_set = false;
bool menu_id_is_set = false;
bool name_is_set = false;
Expand Down
Loading