Trying to add code for disabled graphics.

Bug #1325376 reported by Travis on 2014-06-01
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Stratagus
Fix Released
Undecided
cybermind

Bug Description

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.

Related branches

cybermind (iddqd-mail) wrote :

Added in rev.8897, haven't tested it though, so just try it :)

Changed in stratagus:
status: New → Fix Committed
assignee: nobody → cybermind (iddqd-mail)
Travis (dinky-dye-aussie) wrote :

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

cybermind (iddqd-mail) wrote :

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.

Travis (dinky-dye-aussie) wrote :

OK, will try this now :)

Travis (dinky-dye-aussie) wrote :

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...

cybermind (iddqd-mail) on 2015-03-19
Changed in stratagus:
status: Fix Committed → Fix Released
milestone: none → 2.3
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers