Skip to content
This repository has been archived by the owner on Dec 25, 2019. It is now read-only.

Menu doesn't find *.lua files *Solved #4

Open
otse opened this issue Jul 12, 2019 · 5 comments
Open

Menu doesn't find *.lua files *Solved #4

otse opened this issue Jul 12, 2019 · 5 comments

Comments

@otse
Copy link

otse commented Jul 12, 2019

void Menu::FindScripts()

https://github.com/Force67/DawnHook/blob/master/code/dawnhook/Menu.cpp#L97
This func somehow fails

@BlackOfWorld
Copy link

If you think just by saying "it doesn't work, fix" will help the developer, then you're wrong. Include console logs and anything you can to help resolve your issue.

@otse otse changed the title Can't find *.lua files Menu doesn't find *.lua files Jul 12, 2019
@otse
Copy link
Author

otse commented Jul 13, 2019

I wrote a test - it finds my lua files if you change path+L"\\*.lua" to simply path+L"*"

Seems the asterisk is doing something bad

@otse
Copy link
Author

otse commented Jul 13, 2019

Maybe the first result is a directory like .. or .

@otse
Copy link
Author

otse commented Jul 13, 2019

Hi, I fixed this by changing the imgui ScriptItemSelector at
https://github.com/Force67/DawnHook/blob/master/code/dawnhook/Menu.cpp#L21

By swapping the string * vec cast to a wstring

I also .clear() the found_scripts vec.

otse@92382b1#diff-9d1c756acfaa20c8de46590a71f6be80

One bug remains that it skips the first found file. E.g. if you have a, b, c, d.lua, it will skip a.lua

@otse
Copy link
Author

otse commented Jul 13, 2019

I've never used these Windows functions, but I think your loop uses FindNextFile too quickly. A do-while would do better here.

HANDLE hFind = FindFirstFileA(dir.c_str(), &data);      // DIRECTORY

    if (hFind != INVALID_HANDLE_VALUE) {
        do {
            std::cout << data.cFileName << std::endl;
        } while (FindNextFileA(hFind, &data));
        FindClose(hFind);
    }

@otse otse changed the title Menu doesn't find *.lua files Menu doesn't find *.lua files *Solved Jul 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants