Preference bar step value
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Preference bar step value
I was wondering if there was a way to use the step value you use with a variable or field bar, but with the music/sound/autoplay preference bars. I have a hotbar for my preference screen imagemap that looks similar to this
Rather than the player being able to move the slider until it's in the middle of a block, I'd like to have it go up in even increments so it shows the blocks in their entirety if that makes sense.
If I can't do it with a preference bar, does anyone know code to make a VariableValue bar able to change the preference values I want instead?
but with thicker "blocks."Rather than the player being able to move the slider until it's in the middle of a block, I'd like to have it go up in even increments so it shows the blocks in their entirety if that makes sense.
If I can't do it with a preference bar, does anyone know code to make a VariableValue bar able to change the preference values I want instead?
-
- Eileen-Class Veteran
- Posts: 1258
- Joined: Fri Sep 21, 2007 7:13 am
- Projects: a battle engine
- Contact:
Re: Preference bar step value
auto-forward time and text speed are easy:
for volume, you need to reimplement MixerValue:
then use it:
Code: Select all
bar FieldValue(_preferences, "afm_time", range=30.0, max_is_zero=True, style="slider", step=1.0)
bar FieldValue(_preferences, "text_cps", range=200, max_is_zero=True, style="slider", step=10)
Code: Select all
init python:
class SteppedMixerValue(BarValue):
"""
:doc: value
The value of an audio mixer.
`mixer`
The name of the mixer to adjust. This is usually one of
"music", "sfx", or "voice", but user code can create new
mixers.
`step`
The amount to change the bar by. If None, defaults to 1/10th of
the bar.
"""
def __init__(self, mixer, step=None):
self.mixer = mixer
self.step = step
def set_mixer(self, value):
_preferences.set_volume(self.mixer, value)
def get_adjustment(self):
return ui.adjustment(
range=1.0,
value=_preferences.get_volume(self.mixer),
changed=self.set_mixer,
step=self.step)
def get_style(self):
return "slider", "vslider"
Code: Select all
bar value SteppedMixerValue('music', step=0.1)
bar value SteppedMixerValue('sfx', step=0.1)
Re: Preference bar step value
While it certainly works, it doesn't replicate the effect I wanted where it only shows whole blocks when it's adjusted by mouse. I think I might just wait a while and see if I can live with users being able to put 3.5 blocks for music, but it's weird because I remember making a slider for something else and the player could only move it in certain size increments even when using the mouse. Thank you for your help none the less, though.
-
- Eileen-Class Veteran
- Posts: 1258
- Joined: Fri Sep 21, 2007 7:13 am
- Projects: a battle engine
- Contact:
Re: Preference bar step value
I'm confused. Isn't this precisely what you asked for?
This is clearly something that you can achieve with using VariableValue, so I assumed it was just the step property you needed so I provided an approach that allows you to specify a step property when putting in these bars.
So what's the problem? What does this approach not do that using VariableValue does do?
This is clearly something that you can achieve with using VariableValue, so I assumed it was just the step property you needed so I provided an approach that allows you to specify a step property when putting in these bars.
So what's the problem? What does this approach not do that using VariableValue does do?
Re: Preference bar step value
It's only going in set increments when you use the arrow keys, not the mouse. I've done a slider before where I used VariableValue although it was for an in-game variable, not a preference or anything important, and got that effect with both mouse and keys which is why I'm trying for that effect.
-
- Eileen-Class Veteran
- Posts: 1258
- Joined: Fri Sep 21, 2007 7:13 am
- Projects: a battle engine
- Contact:
Re: Preference bar step value
All VariableValue is is FieldValue but with 'renpy.store' as the object- everything just gets passed along, including those 'step' values, so if that doesn't work I don't see how VariableValue would work.
Re: Preference bar step value
I promise it did. It was a height slider, and it would only go up by inches so whenever the player played around with the bar it would go up by set amounts until it hit the cap. The only difference I can see between the two other than one being VariableValue is that one had an offset for the minimum height though I don't know why that would cause it to work or not. I guess I'll just have to mess around and see.
-
- Eileen-Class Veteran
- Posts: 1258
- Joined: Fri Sep 21, 2007 7:13 am
- Projects: a battle engine
- Contact:
Re: Preference bar step value
I did some tests with VariableValue and I can't get step to produce the behaviour you described. I also had a look at ui.adjustment and it doesn't actually seem to allow for that, at least by default.
Anyway, here's a new SteppedMixerValue. This ugly mess is probably the best I can do:
Something like this could be done for the text and auto sliders too (in which you'd create a custom Value class like that, only instead of adjusting the mixers, it would change _preferences variables.
Anyway, here's a new SteppedMixerValue. This ugly mess is probably the best I can do:
Code: Select all
class SteppedMixerValue(BarValue):
"""
:doc: value
The value of an audio mixer.
`mixer`
The name of the mixer to adjust. This is usually one of
"music", "sfx", or "voice", but user code can create new
mixers.
`step`
The amount to change the bar by. If None, defaults to 1/10th of
the bar.
"""
def __init__(self, mixer, step=None):
self.mixer = mixer
self.step = step
self.adjustment = ui.adjustment(
range=1.0,
value=_preferences.get_volume(self.mixer),
changed=self.set_mixer,
step=self.step)
def set_mixer(self, value):
roundedvalue = round(value / self.step) * self.step
if roundedvalue != value:
self.adjustment.change(roundedvalue)
return
_preferences.set_volume(self.mixer, value)
def get_adjustment(self):
return self.adjustment
def get_style(self):
return "slider", "vslider"
Re: Preference bar step value
Here, this is what I did basically. You see what I mean about the increments?
I'll definitely try what you just posted, though.
I'll definitely try what you just posted, though.
- Attachments
-
- step_slider.rpy
- (1.72 KiB) Downloaded 125 times
-
- Eileen-Class Veteran
- Posts: 1258
- Joined: Fri Sep 21, 2007 7:13 am
- Projects: a battle engine
- Contact:
Re: Preference bar step value
Aha, yep, I suspected what it was after mulling over your earlier posts for a bit.
It has nothing to do with step and everything to do with height being an integer. This isn't too valuable to you unless you use a separate integer variable and update the preferences with that variable multiplied by something to get it into the right range. Although it might be useful for a tidie4 implementation, since you'd just need a custom ui.adjustment for each bar and do the conversiin in the changed function.
It has nothing to do with step and everything to do with height being an integer. This isn't too valuable to you unless you use a separate integer variable and update the preferences with that variable multiplied by something to get it into the right range. Although it might be useful for a tidie4 implementation, since you'd just need a custom ui.adjustment for each bar and do the conversiin in the changed function.
Re: Preference bar step value
Yeah, that's what I was thinking when I changed the step and it didn't change anything that I could see but in the end it's just a nice effect I liked so I'll probably put seeing if I can do it to the back of the list.
Who is online
Users browsing this forum: Ocelot