Wolf3d Haven Forum

Please log in or register. Smile

Join the forum, it's quick and easy

Wolf3d Haven Forum

Please log in or register. Smile

Wolf3d Haven Forum

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Wolf3d Haven Forum

A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...


2 posters

    Adding feature toggles to the customization menu

    avatar
    Metalor
    Bring em' On!
    Bring em' On!


    Number of posts : 158
    Age : 34
    Registration date : 2012-04-05

    Adding feature toggles to the customization menu Empty Adding feature toggles to the customization menu

    Post by Metalor Mon Apr 16, 2012 11:21 pm

    I'm having trouble adding toggles to my EXE so that the player can manually disable certain features at their leisure.

    Specifically, I need to add a toggle so that the player can disable the shading within the menu.

    Anyone got some tips to help me out?
    linuxwolf
    linuxwolf
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 160
    Age : 42
    Location : Australia
    Hobbie : Games
    Registration date : 2011-12-25

    Adding feature toggles to the customization menu Empty Re: Adding feature toggles to the customization menu

    Post by linuxwolf Tue Apr 17, 2012 3:54 am

    The Wolf3D menu is difficult to work with so don't expect these changes to work out of the box.

    Code:
    diff a/foreign.h b/foreign.h
    index 66c0bb7..49400e6 100755
    --- a/foreign.h
    +++ b/foreign.h
    @@ -50,6 +50,7 @@
     #define   STR_GAMEPAD   "Gravis GamePad Enabled"
     #define   STR_SENS   "Mouse Sensitivity"
     #define   STR_CUSTOM   "Customize controls"
    +#define   STR_SHADING   "Shading"
     
     //#define   STR_DADDY   "Can I play, Daddy?"
     //#define   STR_HURTME   "Don't hurt me."
    diff a/wl_menu.cpp b/wl_menu.cpp
    index c9f774f..bbc4c97 100755
    --- a/wl_menu.cpp
    +++ b/wl_menu.cpp
    @@ -134,7 +134,7 @@ CP_itemtype SndMenu[] = {
     #endif
     };
     
    -enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_CUSTOMIZE };
    +enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_CUSTOMIZE, CTL_SHADING };
     
     CP_itemtype CtlMenu[] = {
     #ifdef JAPAN
    @@ -142,11 +142,13 @@ CP_itemtype CtlMenu[] = {
        {0, "", MouseSensitivity},
        {0, "", 0},
        {1, "", CustomControls}
    +    {1, "", 0}
     #else
        {0, STR_MOUSEEN, 0},
        {0, STR_SENS, MouseSensitivity},
        {0, STR_JOYEN, 0},
    -    {1, STR_CUSTOM, CustomControls}
    +    {1, STR_CUSTOM, CustomControls},
    +    {1, STR_SHADING, 0}
     #endif
     };
     
    @@ -2094,6 +2096,13 @@ CP_Control (int)
                    MenuFadeIn ();
                    WaitKeyUp ();
                    break;
    +
    +            case CTL_SHADING:
    +                shadingenabled ^= 1;
    +                DrawCtlScreen ();
    +                CusItems.curpos = -1;
    +                ShootSnd ();
    +                break;
            }
        }
        while (which >= 0);
    @@ -2280,6 +2289,13 @@ DrawCtlScreen (void)
        else
            VWB_DrawPic (x, y, C_NOTSELECTEDPIC);
     
    +    x = CTL_X + CtlItems.indent - 24;
    +    y = CTL_Y + 40; // LinuxWolf: 40 will need to be adjusted to something else
    +    if (shadingenabled)
    +        VWB_DrawPic (x, y, C_SELECTEDPIC);
    +    else
    +        VWB_DrawPic (x, y, C_NOTSELECTEDPIC);
    +
        //
        // PICK FIRST AVAILABLE SPOT
        //
    avatar
    Metalor
    Bring em' On!
    Bring em' On!


    Number of posts : 158
    Age : 34
    Registration date : 2012-04-05

    Adding feature toggles to the customization menu Empty Re: Adding feature toggles to the customization menu

    Post by Metalor Tue Apr 17, 2012 12:27 pm

    Well I did what you said to do and going from there I was able to enable the feature I wanted, however I have a few more bugs that have arisen that I need help with (they're on this subject, so I'll post them here).

    A picture for clarity:
    Adding feature toggles to the customization menu Draw_menu_bug_by_tiny_brain-d4wlzw3
    Anyways, the bugs should be apparent right away.
    First, the shading tab is outside of the controls selection box (and the cursor will go outside that box as well, causing further image distortion).
    And second, the Light that signifies of the shading tab is active or deactive is next to the Control customization tab instead of the shading tab.

    I need to fix both of these, but I'm also going to be adding another controls menu, so I need to extend the dark green box surroudning the menu items so that there is room for another item (this one, placed directly below the Customize Controls tab, and above the Shading Toggle which will be located at the bottom of the menu altogether).


    Here's the code for my DrawCtlScreen:
    Code:
    void
    DrawCtlScreen (void)
    {
        int i, x, y;

    #ifdef JAPAN
        CA_CacheScreen (S_CONTROLPIC);
    #else
        ClearMScreen ();
        DrawStripes (10);
        VWB_DrawPic (80, 0, C_CONTROLPIC);
        VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
        DrawWindow (CTL_X - 8, CTL_Y - 5, CTL_W, CTL_H, BKGDCOLOR);
    #endif
        WindowX = 0;
        WindowW = 320;
        SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);

        if (IN_JoyPresent())
            CtlMenu[CTL_JOYENABLE].active = 1;

        if (MousePresent)
        {
            CtlMenu[CTL_MOUSESENS].active = CtlMenu[CTL_MOUSEENABLE].active = 1;
        }

        CtlMenu[CTL_MOUSESENS].active = mouseenabled;


        DrawMenu (&CtlItems, CtlMenu);


        x = CTL_X + CtlItems.indent - 32;//24;
        y = CTL_Y + 3;
        if (mouseenabled)
            VWB_DrawPic (x, y, C_SELECTEDPIC);
        else
            VWB_DrawPic (x, y, C_NOTSELECTEDPIC);

        y = CTL_Y + 29;
        if (joystickenabled)
            VWB_DrawPic (x, y, C_SELECTEDPIC);
        else
            VWB_DrawPic (x, y, C_NOTSELECTEDPIC);

        //x = CTL_X + CtlItems.indent - 24;
        y = CTL_Y + 40; // LinuxWolf: 40 will need to be adjusted to something else
        if (shadingenabled)
            VWB_DrawPic (x, y, C_SELECTEDPIC);
        else
            VWB_DrawPic (x, y, C_NOTSELECTEDPIC);

        //
        // PICK FIRST AVAILABLE SPOT
        //
        if (CtlItems.curpos < 0 || !CtlMenu[CtlItems.curpos].active)
        {
            for (i = 0; i < CtlItems.amount; i++)
            {
                if (CtlMenu[i].active)
                {
                    CtlItems.curpos = i;
                    break;
                }
            }
        }

        DrawMenuGun (&CtlItems);
        VW_UpdateScreen ();
    }

    Can anyone help me with this? I'd be immensely greatful.
    linuxwolf
    linuxwolf
    Bring em' On!
    Bring em' On!


    Male
    Number of posts : 160
    Age : 42
    Location : Australia
    Hobbie : Games
    Registration date : 2011-12-25

    Adding feature toggles to the customization menu Empty Re: Adding feature toggles to the customization menu

    Post by linuxwolf Tue Apr 17, 2012 4:10 pm

    Adjust this line in wl_menu.h line 86 (approx) to fix shading tab and cursor outside the controls selection box:

    #define CTL_H 60

    Increase this value from 60 to, say, 80 and see if the box is big enough to contain all items and cursor.

    Also adjust this line in wl_menu.cpp line 4385 (approx):

    y = CTL_Y + 40; // LinuxWolf: 40 will need to be adjusted to something else
    if (shadingenabled)

    The number 40 needs to be adjusted to make the cursor appear at the correct spot. I already added a comment to the end of that line as a hint.
    avatar
    Metalor
    Bring em' On!
    Bring em' On!


    Number of posts : 158
    Age : 34
    Registration date : 2012-04-05

    Adding feature toggles to the customization menu Empty Re: Adding feature toggles to the customization menu

    Post by Metalor Tue Apr 17, 2012 5:38 pm

    Alright, thanks for the help. I got the whole thing to work properly now.

    Sponsored content


    Adding feature toggles to the customization menu Empty Re: Adding feature toggles to the customization menu

    Post by Sponsored content


      Current date/time is Fri Nov 08, 2024 1:40 am