Skip to content

Commit

Permalink
feat: Minor adjustments, start of adding back functionality to
Browse files Browse the repository at this point in the history
ExamineMenu.
  • Loading branch information
FlenarnTemp committed Jul 14, 2024
1 parent 2d281e2 commit 6bbcd4b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ add_library(
${CMAKE_CURRENT_BINARY_DIR}/version.rc
.clang-format
vcpkg.json
)
"src/Menus/ExamineMenu.h")

# include dir
target_include_directories(
Expand Down
3 changes: 3 additions & 0 deletions Plugin/src/Events/MenuOpenCloseEvent.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "Menus/ExamineMenu.h"
#include "Menus/DialogueMenu.h"

namespace RE
Expand All @@ -16,10 +17,12 @@ namespace RE
{
if (a_event.opening)
{
DEBUG("Opening DialogueMenu");
DialogueMenu::savedSubtitlePosition = DialogueMenu::GetSubtitlePosition();
}
else
{
DEBUG("Closing DialogueMenu.");
DialogueMenu::SetSubtitlePosition(DialogueMenu::savedSubtitlePosition.first, DialogueMenu::savedSubtitlePosition.second);
}
}
Expand Down
12 changes: 1 addition & 11 deletions Plugin/src/Menus/DialogueMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace RE
if (!a_params.args[0].IsBoolean()) return;

bool enabled = a_params.args[0].GetBoolean();

BSFixedString menuString("DialogueMenu");
if (UI::GetSingleton()->GetMenuOpen(menuString))
{
Expand Down Expand Up @@ -396,17 +397,6 @@ namespace RE

// =================

template <typename T>
void RegisterFunction(Scaleform::GFx::Value* dest, Scaleform::Ptr<Scaleform::GFx::ASMovieRootBase> movieRoot, const char* func_name)
{
Scaleform::GFx::Value fnValue;
Scaleform::GFx::FunctionHandler* func = nullptr;
func = new T;

movieRoot->CreateFunction(&fnValue, func);
dest->SetMember(func_name, fnValue);
}

bool RegisterScaleform(Scaleform::GFx::Movie* a_view, Scaleform::GFx::Value* a_value)
{
Scaleform::GFx::Value currentSWFPath;
Expand Down
40 changes: 40 additions & 0 deletions Plugin/src/Menus/ExamineMenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include "Shared/SharedFunctions.h"

namespace RE
{
namespace Cascadia
{
namespace ExamineMenu
{
class NoRepairKits : public Scaleform::GFx::FunctionHandler
{
public:
virtual void Call(const Params& a_params)
{
SendHUDMessage::ShowHUDMessage("$CAS_NoRepairKits", 0, true, true);
}
};

bool RegisterScaleform(Scaleform::GFx::Movie* a_view, Scaleform::GFx::Value* a_value)
{
Scaleform::GFx::Value currentSWFPath;

// Register native code handlers.
if (a_view->asMovieRoot->GetVariable(&currentSWFPath, "root.loaderInfo.url"))
{
if (_stricmp(currentSWFPath.GetString(), "Interface/ExamineMenu.swf") == 0)
{
Scaleform::GFx::Value bgsCodeObj;
a_view->asMovieRoot->GetVariable(&bgsCodeObj, "root.Menu_mc.BGSCodeObj");

RegisterFunction<NoRepairKits>(&bgsCodeObj, a_view->asMovieRoot, "NoRepairKits");
}
return true;
}
return false;
}
}
}
}
11 changes: 11 additions & 0 deletions Plugin/src/Shared/SharedFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,16 @@ namespace RE
float ConvertPercentageToFloat(std::uint8_t percentage);

std::string trim(const std::string& str);

template <typename T>
void RegisterFunction(Scaleform::GFx::Value* dest, Scaleform::Ptr<Scaleform::GFx::ASMovieRootBase> movieRoot, const char* func_name)
{
Scaleform::GFx::Value fnValue;
Scaleform::GFx::FunctionHandler* func = nullptr;
func = new T;

movieRoot->CreateFunction(&fnValue, func);
dest->SetMember(func_name, fnValue);
}
}
}
20 changes: 17 additions & 3 deletions Plugin/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace
}
else
{
WARN("Failed to define skills.");
FATAL("Failed to define skills.");
}

RE::Cascadia::DefineItemDegradationFormsFromGame();
Expand Down Expand Up @@ -103,11 +103,25 @@ DLLEXPORT bool F4SEAPI F4SEPlugin_Load(const F4SE::LoadInterface* a_F4SE)
}

const auto scaleform = F4SE::GetScaleformInterface();
if (!scaleform || !scaleform->Register("Cascadia", RE::Cascadia::DialogueMenu::RegisterScaleform))
if (!scaleform)
{
FATAL("Failed to register scaleform callback, marking as incompatible."sv);
FATAL("Failed to register Scaleform callback, marking as incompatible."sv);
return false;
}
else
{
if (!scaleform->Register("Cascadia-DialogueMenu", RE::Cascadia::DialogueMenu::RegisterScaleform))
{
FATAL("Failed to register Dialogue menu, marking as incompatible.");
return false;
}

/*if (!scaleform->Register("Cascadia-ExamineMenu", RE::Cascadia::ExamineMenu::RegisterScaleform))
{
FATAL("Failed to register Examine menu, marking as incompatible.");
return false;
}*/
}

RE::Cascadia::RegisterMenuOpenCloseEventSink();

Expand Down

0 comments on commit 6bbcd4b

Please sign in to comment.