UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

custom menu keyboard input and image button updated

broken avatar :(
Created 1 year ago
by AllMoDs
0 Members and 1 Guest are viewing this topic.
450 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 22 September 2015
Last active: 19 hours ago
Posts
256
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
My Contact & Social Links
More
Signature
×
AllMoDs's Groups
this is a itemDef to use your keyboard input in any menu and save the input
 
in your menu where onopen is put this
Code Snippet
Plaintext
execondvarintvalue allmods_cfg 0 "exec allmods/allmods";
in your raw folder make a new folder named allmods in that folder make a new cfg name it allmods put this in that
Code Snippet
Plaintext
seta allmods_keybord_input_saved "";
seta allmods_cfg "1";
this will make it so the keybord input will save and can be loaded back up every time the mod loads
allmods_keybord_input_saved is what will be loaded on mod start and the dvarString you need to show typed text else where
 
with this
Code Snippet
Plaintext
exp text        (dvarString("allmods_keybord_input_saved"))
add this to mod csv
Code Snippet
Plaintext
rawfile,allmods/allmods.cfg

Code Snippet
Plaintext
// pick one 
//visible when    (dvarInt("????") == 1);
//visible    1
//                       240 23 = background "black" size of black bar behind text from keybord
//rect            0 -400 240 23 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_BOTTOM
//background        "black" // can be a image
itemDef
{
    name            expert
    type            ITEM_TYPE_EDITFIELD                    
    background        "black"
    text            "" // leave like this ""
    dvar            "allmods_keybord_input"
    rect            0 -400 240 23 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_BOTTOM
    textalign        ITEM_ALIGN_MIDDLE_LEFT
    textalignx        0
    textscale        0.5
    textstyle        ITEM_TEXTSTYLE_SHADOWEDMORE
    style            WINDOW_STYLE_SHADER
    forecolor        1 1 1 1
    //visible when    (dvarInt("????") == ???);
    //visible    1
    maxChars        15
    maxpaintchars    15
    accept
    {
        seta allmods_keybord_input_saved dvarString( allmods_keybord_input );
        setdvar allmods_keybord_input_saved dvarString( allmods_keybord_input );
        setdvar allmods_keybord_input "";
    }
}

 
 
 
this is just a image button i did since there was not one in the game
Code Snippet
Plaintext
// pick one 
//    background        "black"  
//exp material    (dvarString("????"))
// pick one
//visible when    (dvarInt("????") == 1);
//visible    1
//                          60 60 = image size
//rect            -250 -285 60 60 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_BOTTOM

itemDef                                                                        
{                                                                            
    name            "AllMoDs_Menu_1_pic"
    type            ITEM_TYPE_BUTTON
    rect            -250 -285 60 60 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_BOTTOM
    forecolor        1 1 1 1                                         //ALLMoDs\\
    style            WINDOW_STYLE_SHADER
    //background        "black"
    //exp material    (dvarString("????"))
    //visible when    (dvarInt("????") == 1);
    //visible    1
    action
    {
        play "mouse_click";
        setdvar dvar_1 "1";
    }
    mouseEnter
    {
        play "mouse_over";
        setdvar dvar_1 "2";
    }
    mouseexit        
    {
        setdvar dvar_1 "0";
    }
}

you can use exp material and set the pic from gsc and chang it when ever you want
or just use  background for a single pic
can use
Code Snippet
Plaintext
scriptMenuResponse "????";
on any action , mouseEnter and mouseexit for pick up in gsc
can also set dvar on a player
 setdvar dvar_1 "1";
change them to what you want
 
or you can do like i did and have the pic change on mouse enter and exit
 
onopen set main pic
 
Code Snippet
cpp
onOpen
{
    setdvar goku_switch "goku_icon";
}
then
 
Code Snippet
cpp
itemDef                                                                        
{                                                                            
    name            "goku"  
    type            ITEM_TYPE_BUTTON
    rect            -220 -285 120 200 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_BOTTOM
    forecolor        1 1 1 1                                         //ALLMoDs\\
    style            WINDOW_STYLE_SHADER
    exp material    (dvarString("goku_switch"))
    visible 1
    action
    {
        scriptMenuResponse "picked_goku";
        setdvar you_got_it "0";
        close self;
    }
    mouseEnter
    {
        setdvar goku_switch "goku_icon_ssj";
        scriptMenuResponse "sound_goku";
    }
    mouseexit        
    {
            setdvar goku_switch "goku_icon";
    }
}
the pic switches and when clicked munu will send a scriptMenuResponse for that  close menu and on mouseEnter will play a sound
all this is set up in gsc  like this
Code Snippet
Plaintext
ipicked()
{
    self endon("disconnect");
    for(;;)
    {
        self waittill("menuresponse",menu,response);
        {
            if(response == "picked_goku")
            {
                level notify( "1st_picked" );
                self TakeAllWeapons();
                self thread goku_setup();
                self CloseInGameMenu("allmodsingamechar");
            }
            else if(response == "sound_goku")
            {
                self StopSounds();
                wait 0.05;
                self playsound("gokuintro");
            }
        }
        wait 0.05;
    }        
}            

that is sound and what to do when clicked
Last Edit: December 29, 2022, 07:41:57 pm by AllMoDs

 
Loading ...