Compare commits

...

3 commits

Author SHA1 Message Date
3a3b5bfdff
GameData: change the style name map's, well, name. 2024-03-08 19:27:44 +01:00
ca050b0e48
Update Corrade, Magnum, ImGui. 2024-03-08 19:27:22 +01:00
22f5fc947c
Application: use iterators for TextUnformatted calls.
Corrade's string views aren't guaranteed to be null-terminated,
though most of them come from strings, which _are_
null-terminated. Still, safety first.
2024-02-08 11:08:14 +01:00
13 changed files with 22 additions and 55 deletions

View file

@ -421,7 +421,7 @@ Application::drawTooltip(Containers::StringView text, float wrap_pos) {
if(wrap_pos > 0.0f) { if(wrap_pos > 0.0f) {
ImGui::PushTextWrapPos(wrap_pos); ImGui::PushTextWrapPos(wrap_pos);
} }
ImGui::TextUnformatted(text.data()); ImGui::TextUnformatted(text.cbegin(), text.cend());
if(wrap_pos > 0.0f) { if(wrap_pos > 0.0f) {
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();
} }

View file

@ -360,7 +360,7 @@ Application::drawMaterialRow(Containers::StringView name, std::int32_t tier, Gam
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier); ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.data()); ImGui::TextUnformatted(name.cbegin(), name.cend());
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
ImGui::Text("%i", _currentProfile->material(id)); ImGui::Text("%i", _currentProfile->material(id));
if(conf().cheatMode()) { if(conf().cheatMode()) {
@ -387,7 +387,7 @@ Application::drawUnavailableMaterialRow(Containers::StringView name, std::int32_
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier); ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.begin(), name.end()); ImGui::TextUnformatted(name.cbegin(), name.cend());
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
ImGui::TextDisabled("Unavailable as of game version " SAVETOOL_SUPPORTED_GAME_VERSION); ImGui::TextDisabled("Unavailable as of game version " SAVETOOL_SUPPORTED_GAME_VERSION);
} }
@ -480,7 +480,8 @@ Application::drawMassManager() {
ImGui::TextDisabled("<invalid>"); ImGui::TextDisabled("<invalid>");
break; break;
case GameObjects::Mass::State::Valid: case GameObjects::Mass::State::Valid:
ImGui::TextUnformatted(_massManager->hangar(i).name().data()); ImGui::TextUnformatted(_massManager->hangar(i).name().cbegin(),
_massManager->hangar(i).name().cend());
break; break;
} }

View file

@ -319,7 +319,7 @@ Application::drawCustomStyle(GameObjects::CustomStyle& style) {
} }
if(ImGui::BeginMenuBar()) { if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted(style.name.data()); ImGui::TextUnformatted(style.name.cbegin(), style.name.cend());
static Containers::StaticArray<33, char> name_buf{ValueInit}; static Containers::StaticArray<33, char> name_buf{ValueInit};
if(ImGui::SmallButton(ICON_FA_EDIT " Rename")) { if(ImGui::SmallButton(ICON_FA_EDIT " Rename")) {
@ -672,7 +672,7 @@ Application::drawAccessoryEditor(GameObjects::Accessory& accessory, Containers::
ImGui::BeginGroup(); ImGui::BeginGroup();
ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth()); ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth());
if(ImGui::BeginCombo("##Style1", getStyleName(accessory.styles[0], style_view).data())) { if(ImGui::BeginCombo("##Style1", getStyleName(accessory.styles[0], style_view).data())) {
for(const auto& style : GameData::style_names) { for(const auto& style : GameData::builtin_style_names) {
if(ImGui::Selectable(getStyleName(style.first, style_view).data(), accessory.styles[0] == style.first)) { if(ImGui::Selectable(getStyleName(style.first, style_view).data(), accessory.styles[0] == style.first)) {
accessory.styles[0] = style.first; accessory.styles[0] = style.first;
} }
@ -683,7 +683,7 @@ Application::drawAccessoryEditor(GameObjects::Accessory& accessory, Containers::
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
if(ImGui::BeginCombo("##Style2", getStyleName(accessory.styles[1], style_view).data())) { if(ImGui::BeginCombo("##Style2", getStyleName(accessory.styles[1], style_view).data())) {
for(const auto& style : GameData::style_names) { for(const auto& style : GameData::builtin_style_names) {
if(ImGui::Selectable(getStyleName(style.first, style_view).data(), accessory.styles[1] == style.first)) { if(ImGui::Selectable(getStyleName(style.first, style_view).data(), accessory.styles[1] == style.first)) {
accessory.styles[1] = style.first; accessory.styles[1] = style.first;
} }
@ -762,7 +762,7 @@ Application::getStyleName(std::int32_t id, Containers::ArrayView<GameObjects::Cu
return _currentMass->globalStyles()[id - 50].name; return _currentMass->globalStyles()[id - 50].name;
} }
else { else {
return GameData::style_names.at(id); return GameData::builtin_style_names.at(id);
} }
} }

View file

@ -121,7 +121,7 @@ Application::drawArmour() {
if(ImGui::BeginCombo("##Style", if(ImGui::BeginCombo("##Style",
getStyleName(part.styles[i], _currentMass->armourCustomStyles()).data())) getStyleName(part.styles[i], _currentMass->armourCustomStyles()).data()))
{ {
for(const auto& style : GameData::style_names) { for(const auto& style : GameData::builtin_style_names) {
if(ImGui::Selectable(getStyleName(style.first, _currentMass->armourCustomStyles()).data(), if(ImGui::Selectable(getStyleName(style.first, _currentMass->armourCustomStyles()).data(),
part.styles[i] == style.first)) part.styles[i] == style.first))
{ {

View file

@ -179,7 +179,7 @@ Application::drawFrameStyles() {
if(ImGui::BeginCombo("##Style", if(ImGui::BeginCombo("##Style",
getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()).data())) getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()).data()))
{ {
for(const auto& style : GameData::style_names) { for(const auto& style : GameData::builtin_style_names) {
if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()).data(), if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()).data(),
_currentMass->frameStyles()[i] == style.first)) _currentMass->frameStyles()[i] == style.first))
{ {

View file

@ -257,7 +257,7 @@ Application::drawWeaponCategory(Containers::StringView name, Containers::ArrayVi
{ {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextUnformatted(name.data()); ImGui::TextUnformatted(name.cbegin(), name.cend());
ImGui::PushID(payload_type.data()); ImGui::PushID(payload_type.data());
@ -458,7 +458,7 @@ Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
} }
if(map->find(part.id) != map->cend()) { if(map->find(part.id) != map->cend()) {
ImGui::TextUnformatted(map->at(part.id).data()); ImGui::TextUnformatted(map->at(part.id).cbegin(), map->at(part.id).cend());
} }
else if(part.id == -1) { else if(part.id == -1) {
ImGui::TextUnformatted("<none>"); ImGui::TextUnformatted("<none>");
@ -515,7 +515,7 @@ Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
ImGui::PushID(i); ImGui::PushID(i);
if(ImGui::BeginCombo("##Style", getStyleName(part.styles[i], weapon.customStyles).data())) { if(ImGui::BeginCombo("##Style", getStyleName(part.styles[i], weapon.customStyles).data())) {
for(const auto& style: GameData::style_names) { for(const auto& style: GameData::builtin_style_names) {
if(ImGui::Selectable(getStyleName(style.first, weapon.customStyles).data(), if(ImGui::Selectable(getStyleName(style.first, weapon.customStyles).data(),
part.styles[i] == style.first)) { part.styles[i] == style.first)) {
part.styles[i] = style.first; part.styles[i] = style.first;

View file

@ -266,11 +266,11 @@ Application::drawBackupListPopup() {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::TextUnformatted(backup.company.data()); ImGui::TextUnformatted(backup.company.cbegin(), backup.company.cend());
if(ImGui::IsItemHovered()) { if(ImGui::IsItemHovered()) {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
for(const auto& file : backup.includedFiles) { for(const auto& file : backup.includedFiles) {
ImGui::TextUnformatted(file.data()); ImGui::TextUnformatted(file.cbegin());
} }
ImGui::EndTooltip(); ImGui::EndTooltip();
} }

View file

@ -92,7 +92,7 @@ Application::drawAbout() {
if(ImGui::BeginChild("##GPL", {0.0f, float(windowSize().y()) * 0.3f}, ImGuiChildFlags_Border)) { if(ImGui::BeginChild("##GPL", {0.0f, float(windowSize().y()) * 0.3f}, ImGuiChildFlags_Border)) {
static auto licence = _rs.getRaw("COPYING"); static auto licence = _rs.getRaw("COPYING");
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(licence.begin(), licence.end()); ImGui::TextUnformatted(licence.cbegin(), licence.cend());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();

View file

@ -27,43 +27,9 @@ using namespace Containers::Literals;
namespace mbst { namespace GameData { namespace mbst { namespace GameData {
extern const std::map<std::int32_t, Containers::StringView> style_names extern const std::map<std::int32_t, Containers::StringView> builtin_style_names
#ifdef STYLENAMES_DEFINITION #ifdef STYLENAMES_DEFINITION
{ {
{0, "Custom Style 1"_s},
{1, "Custom Style 2"_s},
{2, "Custom Style 3"_s},
{3, "Custom Style 4"_s},
{4, "Custom Style 5"_s},
{5, "Custom Style 6"_s},
{6, "Custom Style 7"_s},
{7, "Custom Style 8"_s},
{8, "Custom Style 9"_s},
{9, "Custom Style 10"_s},
{10, "Custom Style 11"_s},
{11, "Custom Style 12"_s},
{12, "Custom Style 13"_s},
{13, "Custom Style 14"_s},
{14, "Custom Style 15"_s},
{15, "Custom Style 16"_s},
{50, "Global Style 1"_s},
{51, "Global Style 2"_s},
{52, "Global Style 3"_s},
{53, "Global Style 4"_s},
{54, "Global Style 5"_s},
{55, "Global Style 6"_s},
{56, "Global Style 7"_s},
{57, "Global Style 8"_s},
{58, "Global Style 9"_s},
{59, "Global Style 10"_s},
{60, "Global Style 11"_s},
{61, "Global Style 12"_s},
{62, "Global Style 13"_s},
{63, "Global Style 14"_s},
{64, "Global Style 15"_s},
{65, "Global Style 16"_s},
{100, "Iron"_s}, {100, "Iron"_s},
{101, "Silver"_s}, {101, "Silver"_s},
{102, "Gold"_s}, {102, "Gold"_s},

2
third-party/corrade vendored

@ -1 +1 @@
Subproject commit 4922edf269ce77efe073f6b750a34892e1f3c30d Subproject commit 295bbba1f49887da060465f88b8501965f6acd7d

2
third-party/imgui vendored

@ -1 +1 @@
Subproject commit 7965494ff323c8a3232ac1233a08b984e3c981ae Subproject commit 3c435c029788cc26c52e835e2feb262a3057addc

2
third-party/magnum vendored

@ -1 +1 @@
Subproject commit b91b0b24cde81a4eb9029cb2202b3a652c9bd0e9 Subproject commit 7d0a8215d38284f7b7ae041cfbb19d410e5988a6

@ -1 +1 @@
Subproject commit bb8a4a870f217fc9ac15ff0ddc145974be49a5e7 Subproject commit f01593fc94556bff23a848ac71187c56e034b6d9