Save SliderBar values?

  • Hello mates;

    A while ago I needed a popup that would go in and out of the screen horizontally. But not so simple, the popup would have (hand-made) SlideBars and keep their values as it goes in and out. Fortunately this heroes showed me how to do it here:

    how-do-i-hold-an-object-position-inside-another-object_t196243

    And this was beautiful. Made me very happy <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    With all this help, I'm finally starting to make cool things on my own. Very grateful for this community!

    Ok;

    Now I wonder how to save this SliderBar values when I change layouts?

    Here's an example; Notice that is all working fine, the values still the same as the popup moves, but when you change the layout obviously they will be back to default:

    https://www.dropbox.com/s/83xcpls4gv094 ... .capx?dl=0

    I would like to change the layouts and keep the SliderBar's values, I'm shure there's a simple way of doing it, but just can't figure out. <img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question">

    Thanks in advance for your time and suggestions.

  • Hello mates;

    A while ago I needed a popup that would go in and out of the screen horizontally. But not so simple, the popup would have (hand-made) SlideBars and keep their values as it goes in and out. Fortunately this heroes showed me how to do it here:

    how-do-i-hold-an-object-position-inside-another-object_t196243

    And this was beautiful. Made me very happy <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    With all this help, I'm finally starting to make cool things on my own. Very grateful for this community!

    Ok;

    Now I wonder how to save this SliderBar values when I change layouts?

    Here's an example; Notice that is all working fine, the values still the same as the popup moves, but when you change the layout obviously they will be back to default:

    https://www.dropbox.com/s/83xcpls4gv094 ... .capx?dl=0

    I would like to change the layouts and keep the SliderBar's values, I'm shure there's a simple way of doing it, but just can't figure out. <img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question">

    Thanks in advance for your time and suggestions.

    persist behavior?

  • persist behavior?

    Persist wouldn't do it because the same popup are in many screens, I want to save the values from one layout to another. But that was clever^^

  • Save the values in global viariables. Set slider value to the global variable on start of the layout.

    Have you tried it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Save the values in global viariables. Set slider value to the global variable on start of the layout.

    Have you tried it?

    Yeah, didn't work. The Buttons don't follow the values, but the contrary. I guess I would need to save the positions of the buttons inside the line then...

  • Oh, you are using a custom slider bar.

    Just calculate the position of slid_btn using the Unlerp() function, same as you do in "TextBox->On Text Changed" event.

  • Just calculate the position of slid_btn using the Unlerp() function

    Yeah, I just need to calculate slid_btn position, and place it there on start of layout.

    I tried saving the textbox value in 'Value0' and then ~ On start of layout ~ slid_btn ~ Set X to = slid_line.X+unlerp(slid_line.minVal, slid_line.maxVal, Value0)

    And I tried other things, but I lack understanding. Am I close?

  • Set X to

    slid_line.X+unlerp(slid_line.minVal,slid_line.maxVal, Value0 )*slid_line.Width

    And, of course you need to pick each slide bar and use different variables in the formula - Value0, Value1 etc.

  • Set X to

    slid_line.X+unlerp(slid_line.minVal,slid_line.maxVal, Value0 )*slid_line.Width

    And, of course you need to pick each slide bar and use different variables in the formula - Value0, Value1 etc.

    Thanks!

    Like that: http://www.dropbox.com/s/zax5jdxf7m5a92 ... o.png?dl=0 (img)

    But still something wrong.

    Could you please see this .capx?: https://www.dropbox.com/s/83xcpls4gv0944f/SlidersPopup.capx?dl=0 And point me what simple thing am I missing?

  • Here you go:

    https://www.dropbox.com/s/5z3l8ud2nn2uj ... .capx?dl=0

    I optimized your code and layouts a bit.

    Global variables were probably not the best choice for storing these values.

    You can replace them with a dictionary. This will allow you to access any of them by ID, for example:

    MyDictionary Set Key ("Value" & Str(slid_line.ID)) to 70

    With dictionary you'll be able to loop through values, easily save to local storage etc.

  • Hey dop2000 many thanks!

    I never used dictionary before, tnx for introducing it too.

    You're awesome o/

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)