ZaneDubya / UltimaXNA

Ultima Online client in C#/XNA
GNU General Public License v3.0
142 stars 73 forks source link

Options menu. #111

Closed ZaneDubya closed 9 years ago

ZaneDubya commented 9 years ago

As a player, I want to be able to change settings from within the program.

PatrikSamuelTauchim commented 9 years ago

Hmm? ;-) https://github.com/Eskymak/UltimaXNA/tree/OptionsGump ultimaxnaoptionsgump01

ZaneDubya commented 9 years ago

Awesome! I'm on vacation but will try to get your P R in ASAP!

-Zane

On Jul 1, 2015, at 3:30 PM, Eskymák notifications@github.com wrote:

Hmm? ;-) https://github.com/Eskymak/UltimaXNA/tree/OptionsGump

— Reply to this email directly or view it on GitHub.

PatrikSamuelTauchim commented 9 years ago

Would be nice if some can make categories switching code so I can make those "tabs" actually working. I need just like two categories in order to have template I can use for rest of categories.

btw, I am using Gump Studio for design and all positioning and then just placing values to UltimaXNA gump code.

ZaneDubya commented 9 years ago

@Eskymak, back as of today and I will get working on your PRs this evening.

Regarding the 'category switching code', have you considering placing the gumplings on different Pages?

Re: horizontal sliders, I think I've implemented something like that for the skill selection in the character creation gump. Are you looking for something different?

I wonder if it would be possible to import gump studio creations...

PatrikSamuelTauchim commented 9 years ago

@ZaneDubya Thanks, I just looked on pagination once again and finally got how it works. So this part is done. :-D I will take another look at sliders, just haven't seen them used anywhere.

Gumpstudio can export similar, but not compatible code.

//Gumpstudio output for button
AddButton(0, 40, 218, 217, (int)Buttons.SoundButton, GumpButtonType.Page, 0);

//UltimaXNA button
AddControl(new Button(this, 0, 40, 218, 217, ButtonTypes.SwitchPage, 1, (int)Buttons.Sound));
ZaneDubya commented 9 years ago

Cool!

I think that renaming the XNA Client's enums and changing the ctors for the gumplings could definitely make it easier to import things from Gumpstudio. If you want to, you might look into that when you've completed the options menu. :)

fdsprod commented 9 years ago

@Eskymak @ZaneDubya Gump studio has the ability to create explort plugins. Thats how the RunUO code is produced. Might be easier to just create it that way (or both)

Vodacek commented 9 years ago

yes, I already did it, It is very easy to create export plugin, when I get home I will post example solution :)

PatrikSamuelTauchim commented 9 years ago

Sound options category almost done! ultimaxnaoptionsgump02

Just need to figure out, how to actualy get values from control elements :-D

ZaneDubya commented 9 years ago

@Eskymak Awesome! Try the HSliderBar.Value property?

PatrikSamuelTauchim commented 9 years ago

@ZaneDubya And how to choose from which slider to get value? Have same issue with checkboxes and cannot find any gump from which to take example code, because we probably doesnt have any.

AddControl(new HSliderBar(this, 60, 200, 150, 0, 100, Settings.Audio.MusicVolume, HSliderBarStyle.MetalWidgetRecessedBar), 1);
AddControl(new CheckBox(this, 60, 80, 210, 211, Settings.Audio.SoundOn, 61), 1);

CheckBox actually has some id defined but have no clue how to work with that :-/

Thanks

ZaneDubya commented 9 years ago

I suggest keeping a local reference to the child control if you want to use it after it is created.

m_VolumeMusic = (HSliderBar)AddControl(new HSliderBar(this, 60, 200, 150, 0, 100, Settings.Audio.MusicVolume, HSliderBarStyle.MetalWidgetRecessedBar), 1);

and then, in Update():

Config.AudioSettings.MusicVolume = m_VolumeMusic.Value;
PatrikSamuelTauchim commented 9 years ago

@ZaneDubya Great, it works!! Thanks

ZaneDubya commented 9 years ago

@Eskymak To connect the 'active tab' with the page, you might try using a GumpPicResized control, with gumpID set to the same gump used by the center of the ResizePic. :)

fdsprod commented 9 years ago

@Eskymak If you want to do it the RunUO way, you need to add each of those buttons to each page, with the active button per page being on top. The when the page switches, it renders the buttons associated with that page, with the active one on top. Basically, each page contains the entire gump, plus it's page only content.

I don't think it should be done this way, just sayin ;)

PatrikSamuelTauchim commented 9 years ago

@ZaneDubya Thanks, I will look at it :-) @jeffboulanger Yep I was also considering to do it like this if I will be unable to do it more sophisticated.

I also have more dirty ways to do it on my mind :D

PatrikSamuelTauchim commented 9 years ago

Guys, please look at my solution, if it is acceptable. It just works. :-) https://github.com/Eskymak/UltimaXNA/blob/OptionsGump/dev/Ultima/UI/WorldGumps/OptionsGump.cs

ZaneDubya commented 9 years ago

@Eskymak Outstanding work! Do you want to keep working on this before merging your current changes?

PatrikSamuelTauchim commented 9 years ago

@ZaneDubya I am fine with merge, since I believe, that ability to change settings without need to modify code can make our lives easier. Thanks! :)

Note and TODO: * Volume values have no effect for now, is there any way place where volume is set in current audio code? * Values next to sliders are not updated with slider movement * Menu Bar is not opened/closed while appropriate checkbox state is changed - re-login is needed * Many setting values are saved in weird configuration file category for now (needs to bring some order into it)

ZaneDubya commented 9 years ago

Merged with Master. As I said, looking good!

  1. Yes. Volume can be controlled as a property of the DynamicSoundInstance. I think we should expose a float value for volume, clamped from 0.0f and 1.0f, for music and separately, the same for sounds, as part of the audio service provider.
  2. Is there an OnUpdated event property for the sliders? If not, I should add one :)
  3. Not sure what it would take to fix this.
  4. Too true! If you feel up to it, you can try reorganizing them. :)
PatrikSamuelTauchim commented 9 years ago

2) I have not found OnUpdate event in sliders code, so I placed Update into options gump code 3) TopMenu will now be shown/disposed after applying/saving changes

e281882939794c244f482fcfe022327c56eafbb9

ZaneDubya commented 9 years ago

@jeffboulanger You mentioned a month ago about how RunUO builds its [props menu programmatically - do you think it would be feasible to do something like that for the Settings screen, using attributes? Would it take a ton of time to load/build the menu, or is reflection pretty fast for ~100 items?

ZaneDubya commented 9 years ago

Although the options gump does not yet contain all the configuration options that can be changed, we now have a solid core that we can build on. I'm closing this issue as implemented.