Skip to content

Commit

Permalink
feature (#37)
Browse files Browse the repository at this point in the history
- [x] option to take only input when in tween menu (configuration)
- [x] custom menu for tween menu
- [x] custom menu display if [wait menu
redirected](https://www.nexusmods.com/skyrimspecialedition/mods/88507)
is detected
- [x] make mod detection over writable with a configuration
- [x] #38 
- [x] do not take input if some mod menus are open (configuration)
  • Loading branch information
mlthelama authored Jan 20, 2024
2 parents c642aa4 + 6b2559d commit bd4a0c2
Show file tree
Hide file tree
Showing 40 changed files with 918 additions and 270 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "extern/skyui"]
path = extern/skyui
url = https://github.com/mlthelama/skyui.git
[submodule "extern/hint_button_menu"]
path = extern/hint_button_menu
url = https://github.com/mlthelama/hint_button_menu.git
branch = main
9 changes: 9 additions & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(sources ${sources}
src/CLIK/MovieClip.h
src/CLIK/Object.h
src/CLIK/TextField.h
src/CLIK/TweenMainWidget.h
src/PCH.h
src/actor/champion.cpp
src/actor/champion.h
Expand Down Expand Up @@ -35,6 +36,8 @@ set(sources ${sources}
src/mod/armor_rating_rescaled_remake.h
src/mod/blade_and_blunt.cpp
src/mod/blade_and_blunt.h
src/mod/mod.cpp
src/mod/mod.h
src/mod/mod_manager.cpp
src/mod/mod_manager.h
src/scaleform/menus/faction_menu.cpp
Expand All @@ -43,6 +46,8 @@ set(sources ${sources}
src/scaleform/menus/stats_inventory_menu.h
src/scaleform/menus/stats_menu.cpp
src/scaleform/menus/stats_menu.h
src/scaleform/menus/tween_hint_menu.cpp
src/scaleform/menus/tween_hint_menu.h
src/scaleform/scaleform.cpp
src/scaleform/scaleform.h
src/setting/config_setting.cpp
Expand All @@ -58,6 +63,10 @@ set(sources ${sources}
src/setting/input_setting.h
src/setting/key_setting.cpp
src/setting/key_setting.h
src/setting/mod_detection.cpp
src/setting/mod_detection.h
src/setting/setting.cpp
src/setting/setting.h
src/util/file.cpp
src/util/file.h
src/util/form.cpp
Expand Down
54 changes: 30 additions & 24 deletions config/SkyrimCharacterSheet_Input.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
{
"debug": false,
"stat": {
"open_key_combination": [22],
"close_key_combination": [22],
"page_next_keys": [
32,
205,
77,
274
],
"page_previous_keys": [
30,
203,
75,
270
],
"pause_game": true
},
"inventory": {
"open_key_combination": [11],
"close_key_combination": [11],
"enabled": true,
"auto_show_inventory": true,
"auto_show_magic": false
}
"open_key_combination": [
22
],
"close_key_combination": [
22
],
"page_next_keys": [
32,
205,
77,
274
],
"page_previous_keys": [
30,
203,
75,
270
],
"pause_game": true,
"tween_menu_only": false,
"ignore_input_menu": ["CustomMenu"],
"inventory_open_key_combination": [
11
],
"inventory_close_key_combination": [
11
],
"inventory_enabled": true,
"inventory_auto_show_inventory": true,
"inventory_auto_show_magic": false
}
4 changes: 4 additions & 0 deletions config/SkyrimCharacterSheet_Menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"name": "$ShowStatsInventoryEffectTitle"
}
]
},
{
"key": "tween_hint",
"name": "$ShowTweenHint"
}
]
}
8 changes: 8 additions & 0 deletions config/SkyrimCharacterSheet_ModDetection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"armor_rating_rescaled_remake": true,
"hand_to_hand": true,
"skyrim_unbound": true,
"skyrim_souls": true,
"blade_and_blunt": true,
"wait_menu_redirected": true
}
7 changes: 5 additions & 2 deletions config/SkyrimCharacterSheet_Player.json
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,12 @@
"key": "fall_damage_mod",
"display_name": "$ShowFallDamageMod",
"ending": "%",
"result_handling": "multiply",
"result_handling_value": 100,
"icon_string": "default_misc",
"stats_column": "none",
"stats_inventory_column": "none"
"stats_column": "player",
"stats_inventory_column": "none",
"hide_value_when_zero": true
},
{
"key": "warmth",
Expand Down
1 change: 1 addition & 0 deletions extern/hint_button_menu
Submodule hint_button_menu added at c277ee
3 changes: 2 additions & 1 deletion scripts/archive_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ def make_rel_archive(a_args):
"Interface/ShowStatsInventory.swf")
archive.write(os.path.join(v_pwd, "swf", "Translations", "SkyrimCharacterSheet_english.txt"),
"Interface/Translations/SkyrimCharacterSheet_english.txt")

for lang in languages:
archive.write(os.path.join(v_pwd, "swf", "Translations", "SkyrimCharacterSheet_english.txt"),
"Interface/Translations/SkyrimCharacterSheet_" + lang + ".txt")

archive.write(os.path.join(v_pwd, "extern", "skyui", "swf", "icons_item_psychosteve_merged.swf"), "Interface/skyui/icons_item_psychosteve_merged.swf")
archive.write(os.path.join(v_pwd, "extern", "hint_button_menu", "bin", "hint_button_menu.swf"), "Interface/ShowTweenHintMenu.swf")


def parse_arguments():
Expand Down
9 changes: 9 additions & 0 deletions src/CLIK/TweenMainWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "CLIK/MovieClip.h"

namespace CLIK {
class TweenMainWidget : public MovieClip {
public:
[[nodiscard]] Object data_provider() const { return GetObject("dataProvider"); }
void data_provider(const Object& a_data_provider) { SetObject("dataProvider", a_data_provider); }
};
} // CLIK
4 changes: 3 additions & 1 deletion src/actor/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ namespace actor {
if (!a_player_data_element->ending.empty()) {
a_player_data->value += a_player_data_element->ending;
}
a_player_data->value += handle_max_handling(a_player_data_element, resist_damage);
if (!mod::mod_manager::get_singleton()->get_blade_and_blunt()) {
a_player_data->value += handle_max_handling(a_player_data_element, resist_damage);
}
}

void player::handle_ending(setting_data::player_data*& a_player_data_element,
Expand Down
7 changes: 4 additions & 3 deletions src/event/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

namespace event {
void sink_event_handlers() {
input_event::sink();
logger::info("Added Input Event"sv);

if (setting::input_setting::is_inventory_menu_enabled()) {
menu_open_close_event::sink();
logger::info("Added Menu Event"sv);

equip_event::sink();
logger::info("Added Equip Event"sv);
}
if (!setting::input_setting::get_tween_menu_only()) {
input_event::sink();
logger::info("Added Input Event"sv);
}
}
}
51 changes: 16 additions & 35 deletions src/event/input_event.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "input_event.h"
#include "input/menu_key_input_holder.h"
#include "scaleform/menus/faction_menu.h"
#include "scaleform/menus/stats_inventory_menu.h"
#include "scaleform/menus/stats_menu.h"
Expand All @@ -15,14 +16,15 @@ namespace event {

input_event::event_result input_event::ProcessEvent(RE::InputEvent* const* a_event,
[[maybe_unused]] RE::BSTEventSource<RE::InputEvent*>* a_event_source) {
open_key_combo_ = setting::input_setting::get_open_menu_key_combination();
close_key_combo_ = setting::input_setting::get_close_menu_key_combination();

if (is_one_combo_empty()) {
if (!a_event) {
return event_result::kContinue;
}

if (!a_event) {
auto* key_input = input::menu_key_input_holder::get_singleton();
open_key_combo_ = key_input->get_open_key_combo();
close_key_combo_ = key_input->get_close_key_combo();

if (is_one_combo_empty()) {
return event_result::kContinue;
}

Expand All @@ -33,7 +35,6 @@ namespace event {
return event_result::kContinue;
}

//clear_key_down(key_down_list_);
for (auto* event = *a_event; event; event = event->next) {
if (event->eventType != RE::INPUT_EVENT_TYPE::kButton) {
continue;
Expand All @@ -47,7 +48,7 @@ namespace event {
util::key_util::get_key_id(button->device.get(), key);

if (button->IsUp()) {
remove_key_down(key_down_list_, key);
key_input->remove_key_down(key);
}

if (!button->IsDown()) {
Expand All @@ -66,55 +67,35 @@ namespace event {

//for whatever reason I can open the menu while at a crafting station
//so let that not happen
if (ui->IsMenuOpen(RE::CraftingMenu::MENU_NAME)) {
if (ui->IsMenuOpen(RE::CraftingMenu::MENU_NAME) ||
input::menu_key_input_holder::is_one_ignore_menu_open()) {
continue;
}

if (open_key_combo_.contains(key) || close_key_combo_.contains(key)) {
add_key_down(key_down_list_, key);
key_input->add_key_down(key);
}

//logger::info("user event {}, id {}"sv, button->userEvent, button->idCode);

if (close_key_combo_ == key_down_list_) {
log_combo_set(close_key_combo_, key_down_list_);
if (key_input->is_down_list_equal(false)) {
if (scaleform::stats_menu::is_menu_open()) {
scaleform::stats_menu::close();
key_input->clear_set();
}
if (scaleform::faction_menu::is_menu_open()) {
scaleform::faction_menu::close();
key_input->clear_set();
}
}
if (open_key_combo_ == key_down_list_) {
log_combo_set(open_key_combo_, key_down_list_);
if (key_input->is_down_list_equal(true)) {
if (!scaleform::stats_menu::is_menu_open() && !scaleform::faction_menu::is_menu_open()) {
scaleform::stats_menu::open();
key_input->clear_set();
}
}
}

return event_result::kContinue;
}

void input_event::add_key_down(std::set<uint32_t>& a_set, uint32_t key) {
a_set.insert(key);
if (!a_set.empty()) {
logger::trace("size {}, down list {}"sv, a_set.size(), util::type_util::get_delimited_string(a_set));
}
}

void input_event::remove_key_down(std::set<uint32_t>& a_set, uint32_t key) {
a_set.erase(key);
if (!a_set.empty()) {
logger::trace("size {}, down list {}"sv, a_set.size(), util::type_util::get_delimited_string(a_set));
}
}

bool input_event::is_one_combo_empty() { return open_key_combo_.empty() || close_key_combo_.empty(); }

void input_event::log_combo_set(std::set<uint32_t>& a_needed, std::set<uint32_t>& a_down) {
logger::trace("key combo needed {}, down list {}"sv,
util::type_util::get_delimited_string(a_needed),
util::type_util::get_delimited_string(a_down));
}
}
10 changes: 1 addition & 9 deletions src/event/input_event.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "util/key_util.h"

namespace event {
Expand Down Expand Up @@ -26,14 +26,6 @@ namespace event {
std::set<uint32_t> open_key_combo_;
std::set<uint32_t> close_key_combo_;

std::set<uint32_t> key_down_list_;

static void add_key_down(std::set<uint32_t>& a_set, uint32_t key);

static void remove_key_down(std::set<uint32_t>& a_set, uint32_t key);

bool is_one_combo_empty();

static void log_combo_set(std::set<uint32_t>& a_needed, std::set<uint32_t>& a_down);
};
}
17 changes: 17 additions & 0 deletions src/event/menu_open_close_event.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "menu_open_close_event.h"
#include "input/menu_key_input_holder.h"
#include "scaleform/menus/faction_menu.h"
#include "scaleform/menus/stats_inventory_menu.h"
#include "scaleform/menus/stats_menu.h"
#include "scaleform/menus/tween_hint_menu.h"
#include "setting/input_setting.h"

namespace event {
Expand Down Expand Up @@ -49,6 +51,21 @@ namespace event {
}
}

if (setting::input_setting::get_tween_menu_only() && a_event->menuName == RE::TweenMenu::MENU_NAME) {
if (a_event->opening) {
scaleform::tween_hint_menu::open();
} else {
scaleform::tween_hint_menu::close();
}
}

if (a_event->menuName == scaleform::stats_menu::menu_name ||
a_event->menuName == scaleform::faction_menu::menu_name ||
a_event->menuName == scaleform::stats_inventory_menu::menu_name) {
auto* key_input = input::menu_key_input_holder::get_singleton();
key_input->clear_set();
}

return event_result::kContinue;
}
}
Loading

0 comments on commit bd4a0c2

Please sign in to comment.