Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help: inconsistent framerate IMenu, GFxMovie #64

Open
frammiie opened this issue Dec 13, 2022 · 0 comments
Open

help: inconsistent framerate IMenu, GFxMovie #64

frammiie opened this issue Dec 13, 2022 · 0 comments

Comments

@frammiie
Copy link

Opening

Hey there, first of all, thank you very much for all the time and effort you've
put in to make this library possible. 💖 It's truly been a great help in achieving
my modding ambitions.

Context

However, whilst using this library in order to create custom menus (Scaleform)
I've noticed some inconsistencies I'm having trouble explaining.
Currently I'm creating menus as following (inside class inheriting from IMenu):

auto menu = static_cast<RE::IMenu*>(this);
auto scaleformManager = RE::BSScaleformManager::GetSingleton();
scaleformManager->LoadMovie(menu, menu->uiMovie, FILE_NAME.data());
assert(success);

And registering it by:

void SkyflashMenu::Register() {
    auto ui = RE::UI::GetSingleton();
    if (ui) {
        ui->Register(MENU_NAME, Creator);
        logger::info("Registered {}", MENU_NAME);
    }
}

RE::stl::owner<RE::IMenu*> SkyflashMenu::Creator() {
    return new SkyflashMenu();
}

And opening it in papyrus via native function

auto msgQ = RE::UIMessageQueue::GetSingleton();
msgQ->AddMessage(SkyflashMenu::MenuName(), RE::UI_MESSAGE_TYPE::kShow, nullptr);

And this works great, the menu pops up, everything is working as intended,
menu flags work, input handling/focus is working fine.

Issue

However there's one glaring problem with this approach, the menu appears to
be running at game refresh rate, instead of the refresh rate defined in the SWF.

Unfortunately, frame rate is very important for my mod and I need it to be constant
in order for some time based coordination.

This is peculiar, because using SKSE to create the menu using OpenCustomMenu in
Papyrus code results into correct behavior, the code is as follows in SKSE:

CustomMenu::CustomMenu(const char* swfPath)
{
    CALL_MEMBER_FN(GFxLoader::GetSingleton(), LoadMovie)(this, &view, swfPath, GFxMovieView::ScaleModeType::kNoBorder, 0.0);
}

---

class GFxLoader {
public:
    // Note: Probably in subclass
    DEFINE_MEMBER_FN(LoadMovie, bool, 0x00ECE790, IMenu* menu, GFxMovieView** viewOut, const char* name, int scaleMode, float backGroundAlpha);
}

This looks similar in how Commonlib-NG does it:

bool BSScaleformManager::LoadMovie(IMenu* a_menu, GPtr<GFxMovieView>& a_viewOut, const char* a_fileName, ScaleModeType a_mode, float a_backGroundAlpha)
{
	using func_t = decltype(&BSScaleformManager::LoadMovie);
	REL::Relocation<func_t> func{ RELOCATION_ID(80302, 82325) };
	return func(this, a_menu, a_viewOut, a_fileName, a_mode, a_backGroundAlpha);
}

Considered Remedies

  • Setting menu flags, or any sort of configuration on the IMenu or GFxMovieView
    did not yield to any differences in this problematic frame behavior.

  • Manually advancing frame times is an option by selectively calling Advance on the
    GFxMovieView, however this is clunky and a native approach would be more fitting.

Closing Remarks

Unfortunately I'm not that proficient in C++ let alone reverse engineering, so I hope
one of you could help me along the way. The plugin needn't do much but load menu
and handle FxDelegate callbacks.

If you need any further info, or source, Papyrus, and / or ESP files, I would be happy to
provide them to you.

Once again, thank you for your time,
kind regards, frammiie

jpstewart pushed a commit that referenced this issue May 12, 2023
epinter pushed a commit to epinter/CommonLibSSE-NG that referenced this issue Sep 4, 2024
Co-authored-by: Ilya Perapechka <i_perapechka@wargaming.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant