Skip to content

Commit

Permalink
[feature]
Browse files Browse the repository at this point in the history
* added: unarmed setting in the MCM (Pages>Unarmed) in Default, It
  will overwrite the CURRENT Setting for this Position and Page
  • Loading branch information
mlthelama committed Feb 3, 2023
1 parent 0290939 commit 1696fd1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
Binary file modified mcm/Interface/Translations/LamasTinyHUD_english.txt
Binary file not shown.
Binary file modified mcm/scripts/LamasTinyHUD_MCM.pex
Binary file not shown.
2 changes: 1 addition & 1 deletion mcm/source/Scripts/LamasTinyHUD_MCM.psc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Event OnSettingChange(String a_ID)
RefreshMenu()
elseif (a_ID == "uPositionSelect:Page")
FillPageSelection()
bUnarmed = bElden && (GetModSettingInt(a_ID) == 1 || GetModSettingInt(a_ID) == 3)
bUnarmed = (bElden && (GetModSettingInt(a_ID) == 1 || GetModSettingInt(a_ID) == 3)) || !bElden
RefreshMenu()
elseif (a_ID == "bHideOutsideCombat:MiscSetting")
bCombat = GetModSettingBool(a_ID)
Expand Down
1 change: 0 additions & 1 deletion src/handle/setting/set_setting_data.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "set_setting_data.h"
#include <handle/handle/edit_handle.h>

#include "equip/equip_slot.h"
#include "handle/handle/ammo_handle.h"
#include "handle/handle/name_handle.h"
Expand Down
40 changes: 31 additions & 9 deletions src/papyrus/papyrus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,18 @@ namespace papyrus {
}

void hud_mcm::add_unarmed_setting(RE::TESQuest*, uint32_t a_position) {
logger::trace("Try to add Unarmed for Position {}"sv, a_position);
if (a_position == static_cast<uint32_t>(handle::position_setting::position_type::right) ||
a_position == static_cast<uint32_t>(handle::position_setting::position_type::left)) {
auto elden = config::mcm_setting::get_elden_demon_souls();
logger::trace("Try to add Unarmed for Position {}, Elden {}"sv, a_position, elden);
auto page_handle = handle::page_handle::get_singleton();
auto position = static_cast<handle::position_setting::position_type>(a_position);
std::vector<data_helper*> data;
auto next_page = 0;
if (elden && (a_position == static_cast<uint32_t>(handle::position_setting::position_type::right) ||
a_position == static_cast<uint32_t>(handle::position_setting::position_type::left))) {
//
auto left = a_position == static_cast<uint32_t>(handle::position_setting::position_type::left);
auto max_pages = config::mcm_setting::get_max_page_count();
auto position = static_cast<handle::position_setting::position_type>(a_position);
auto page_handle = handle::page_handle::get_singleton();

auto highest_page = page_handle->get_highest_page_id_position(position);
if (static_cast<int>(max_pages) == highest_page) {
logger::warn("can not add Unarmed already enough settings"sv);
Expand All @@ -236,19 +240,37 @@ namespace papyrus {
}
}

auto next_page = highest_page + 1;
next_page = highest_page + 1;
const auto item = new data_helper();
item->type = handle::slot_setting::slot_type::weapon;
item->left = left;
item->form = RE::TESForm::LookupByID(util::unarmed); //unarmed
item->two_handed = false;
item->action_type = handle::slot_setting::acton_type::default_action;
std::vector<data_helper*> data;
data.push_back(item);
handle::set_setting_data::set_single_slot(next_page, position, data);

logger::trace("Added Unarmed Setting Page {}, Position {}"sv, next_page, a_position);
} else {
next_page = static_cast<int>(page_handle->get_active_page_id());

const auto item = new data_helper();
item->form = RE::TESForm::LookupByID(util::unarmed);
item->left = false;
item->type = handle::slot_setting::slot_type::weapon;
item->action_type = handle::slot_setting::acton_type::default_action;
data.push_back(item);

const auto item2 = new data_helper();
item2->form = RE::TESForm::LookupByID(util::unarmed);
item2->left = true;
item2->type = handle::slot_setting::slot_type::weapon;
item2->action_type = handle::slot_setting::acton_type::default_action;
data.push_back(item2);
}
handle::set_setting_data::set_single_slot(next_page, position, data);
logger::trace("Added Unarmed Setting Page {}, Position {}, Setting Count {}"sv,
next_page,
a_position,
data.size());
}

bool hud_mcm::Register(RE::BSScript::IVirtualMachine* a_vm) {
Expand Down

0 comments on commit 1696fd1

Please sign in to comment.