Devilutionx: Repeat the intro if no activity for 30 sec

Created on 21 Jul 2019  路  5Comments  路  Source: diasurgical/devilutionX

When in the main menu the intro video should replay if the player doesn't interact with the keyboard or mouse for 30 sec.

bug good first issue

All 5 comments

I added this in my rewrite by using a single flag. In the message loop add this code:

    switch(uMsg) {
    case WM_KEYDOWN:
    case WM_KEYUP:
    case WM_CHAR:
    case WM_SYSKEYDOWN:
    case WM_SYSCOMMAND:
    case WM_MOUSEMOVE:
    case WM_LBUTTONDOWN:
    case WM_LBUTTONUP:
    case WM_RBUTTONDOWN:
    case WM_RBUTTONUP:
        gbHasPressed = TRUE;
        break;
    }

Then in the main loop just reset the timer if the flag is set, or break out of the loop if the tick count is greater:

    if(gbHasPressed) {
        gbHasPressed = FALSE;
        dwTicks = GetTickCount() + introtimer * 1000;
    } else if(GetTickCount() >= dwTicks) {
        gbRunGame = FALSE;
    }

I'd like to take a shot at it.
Galaxyhaxz already presented a solution, but I have a few questions:

  • Is adding an extra _switch_ preferred over repeating gbHasPressed = TRUE on the existing _switch_ in DisableInputWmdProc?
  • Would forking and making a pull-request be the correct way to contribute? I'm new to this.

PS: Thank you both for bringing this game back. Never thought I'd be able to play it on Linux without Wine.

Note Galaxyhaxz's rewrite isn't public yet so things are a little bit different in DevilutionX, it could probably be implemented here:
https://github.com/diasurgical/devilutionX/blob/master/SourceX/DiabloUI/diabloui.cpp#L213

I don't belive DisableInputWmdProc would be triggered when the user is in the mainmenu.

Yes, create a fork and PR is the right way to go.

I have submitted the PR, took a while to understand the flow but it's complete, tested in 64bit Linux.
Several types of input are accounted for and I resolved a minor issue with the palette.
One thing I was left wondering was if I used the appropriate naming style since the INT is in snake_case and the DWORD is in camelCase.

snake_case is used in Devilution for guessed names, since the original used camelCase, but not all original names are known.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sharp299 picture sharp299  路  5Comments

predator8bit picture predator8bit  路  4Comments

xdub picture xdub  路  5Comments

legluondunet picture legluondunet  路  5Comments

Askmewho picture Askmewho  路  5Comments