Wargus / stratagus

The Stratagus strategy game engine
GNU General Public License v2.0
614 stars 115 forks source link

Trying to add code for disabled graphics. #107

Closed timfel closed 8 years ago

timfel commented 8 years ago

Been messing around with the engine code and lua code, trying to add it to get the "grayed out" or "disabled" graphics to show whenever I disable something like the sound effects - I want the slider arrows and slider bar to turn gray and become unusable when disabled, and then turn back to the regular color when re-enabled.

I added

void setDisabledImage(gcn::Image *image);

and

gcn::Image *disabledImage;

to widgets.cpp in the "ImageSlider", "ImageCheckBox" and "ImageRadioButton".

The Compiler gave me a LNK2019 error whenever i had this extra code in the ImageSlider variable and ui.pkg in the source directory. Could someone help me solve this? would be great to get the disabled images working. If you want more info on what I am expereiencing let me know.


Imported from Launchpad using lp2gh.

timfel commented 8 years ago

(by iddqd-mail) Added in rev.8897, haven't tested it though, so just try it :)

timfel commented 8 years ago

(by dinky-dye-aussie) Tried it out today. The slider bar turns gray, but the arrows don't. Plus the slider marker still shows, but as a gray square and not the graphic, but I don't want the marker to show at all...Is there a way to get rid of the slider marker altogether when disabled? I'll keep trying, but so far this is the code I use:

Example is using the "musicslider" lua code;

local musiccheckbox = {} musiccheckbox = menu:addImageRadioButton("", "musiccheckbox", 138, 200, offi, offi2, oni, oni2, function() SetMusicEnabled(true) end) musiccheckbox:setMarked(IsMusicEnabled())

    musiccheckbox = menu:addImageRadioButton("", "musiccheckbox", 138, 222, offi, offi2, oni, oni2, 
                                              function() SetMusicEnabled(false) end)
    if (IsMusicEnabled() == true) then
        musiccheckbox:setMarked(false)
        musicslider:setEnabled(true)
    else
        musiccheckbox:setMarked(true)
        musicslider:setEnabled(false)
    end
timfel commented 8 years ago

(by iddqd-mail) Slider marker bug fixed in rev.8908. What about arrow buttons, looks like you're using the same variable for multiple things definition. From options.lua: local musicslider = {} -- slider button to decrease slider value musicslider = menu:addImageLeftSliderButton("", nil, 21, offy + 36 * 3.25, function() musicslider:setValue(musicslider:getValue() - 25.5); SetMusicVolume(musicslider:getValue()) end)

    -- slider button to decrease slider value
    musicslider = menu:addImageRightSliderButton("", nil, 213, offy + 36 * 3.25, function() musicslider:setValue(musicslider:getValue() + 25.5); SetMusicVolume(musicslider:getValue()) end)

    -- slider itself
    musicslider = menu:addImageSlider(0, 255, 172, 18, offx + 41, offy + 36 * 3.25, g_marker, g_slider, function() SetMusicVolume(musicslider:getValue()) end)

    -- set the value so the game saves it
    musicslider:setValue(GetMusicVolume())

The "musicslider" variable used for 3 things: 2 buttons and slider. So, when you disable slider, only it will be disabled, buttons will remain active, because "musicslider" variable was redefined for slider and it has lost connection with buttons (they aren't assigned to any variable). Just use several variables to manage several things simultaneously.

timfel commented 8 years ago

(by dinky-dye-aussie) OK, will try this now :)

timfel commented 8 years ago

(by dinky-dye-aussie) That worked. The marker image no longer shows when disabled either. Thankyou Cybermind :) Now we just need to make it happen in real time. At the moment we still have to click ok and go back into the sound menu to see the changes...