Compare commits

...

3 Commits

Author SHA1 Message Date
Guillaume Jacquemin 3a3b5bfdff
GameData: change the style name map's, well, name. 2024-03-08 19:27:44 +01:00
Guillaume Jacquemin ca050b0e48
Update Corrade, Magnum, ImGui. 2024-03-08 19:27:22 +01:00
Guillaume Jacquemin 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) {
ImGui::PushTextWrapPos(wrap_pos);
}
ImGui::TextUnformatted(text.data());
ImGui::TextUnformatted(text.cbegin(), text.cend());
if(wrap_pos > 0.0f) {
ImGui::PopTextWrapPos();
}

View File

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

View File

@ -319,7 +319,7 @@ Application::drawCustomStyle(GameObjects::CustomStyle& style) {
}
if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted(style.name.data());
ImGui::TextUnformatted(style.name.cbegin(), style.name.cend());
static Containers::StaticArray<33, char> name_buf{ValueInit};
if(ImGui::SmallButton(ICON_FA_EDIT " Rename")) {
@ -672,7 +672,7 @@ Application::drawAccessoryEditor(GameObjects::Accessory& accessory, Containers::
ImGui::BeginGroup();
ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth());
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)) {
accessory.styles[0] = style.first;
}
@ -683,7 +683,7 @@ Application::drawAccessoryEditor(GameObjects::Accessory& accessory, Containers::
ImGui::PopItemWidth();
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
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)) {
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;
}
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",
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(),
part.styles[i] == style.first))
{

View File

@ -179,7 +179,7 @@ Application::drawFrameStyles() {
if(ImGui::BeginCombo("##Style",
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(),
_currentMass->frameStyles()[i] == style.first))
{

View File

@ -257,7 +257,7 @@ Application::drawWeaponCategory(Containers::StringView name, Containers::ArrayVi
{
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableNextColumn();
ImGui::TextUnformatted(name.data());
ImGui::TextUnformatted(name.cbegin(), name.cend());
ImGui::PushID(payload_type.data());
@ -458,7 +458,7 @@ Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
}
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) {
ImGui::TextUnformatted("<none>");
@ -515,7 +515,7 @@ Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
ImGui::PushID(i);
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(),
part.styles[i] == style.first)) {
part.styles[i] = style.first;

View File

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

View File

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

View File

@ -27,43 +27,9 @@ using namespace Containers::Literals;
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
{
{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},
{101, "Silver"_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