Skip to content

Commit

Permalink
Merge pull request #8 from bittiez/opacity-options
Browse files Browse the repository at this point in the history
Added opacity options for containers and journal
  • Loading branch information
bittiez authored Mar 5, 2023
2 parents d646336 + b63d0d0 commit ae0e5dd
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/ClassicUO.Client/Configuration/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ internal sealed class Profile
public bool HoldDownKeyAltToCloseAnchored { get; set; } = true;
public bool CloseAllAnchoredGumpsInGroupWithRightClick { get; set; } = false;
public bool HoldAltToMoveGumps { get; set; }

public byte JournalOpacity { get; set; } = 50;
public bool HideScreenshotStoredInMessage { get; set; }

// Experimental
Expand Down Expand Up @@ -264,6 +264,8 @@ internal sealed class Profile

public byte ContainersScale { get; set; } = 100;

public byte ContainerOpacity { get; set; } = 50;

public bool ScaleItemsInsideContainers { get; set; }

public bool DoubleClickToLootInsideContainers { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions src/ClassicUO.Client/Game/UI/Gumps/GridContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public GridContainer(uint local, ushort ogContainer) : base(DEFAULT_WIDTH, DEFAU
_background.Height = Height - (BORDER_WIDTH * 2);
_background.X = BORDER_WIDTH;
_background.Y = BORDER_WIDTH;
_background.Alpha = (float)ProfileManager.CurrentProfile.ContainerOpacity/100;
#endregion

#region TOP BAR AREA
Expand Down Expand Up @@ -487,7 +488,10 @@ private void updateItems()
protected override void UpdateContents()
{
if (InvalidateContents && !IsDisposed && IsVisible)
{
_background.Alpha = (float)ProfileManager.CurrentProfile.ContainerOpacity / 100;
updateItems();
}
}

public override void Dispose()
Expand Down
50 changes: 50 additions & 0 deletions src/ClassicUO.Client/Game/UI/Gumps/OptionsGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ internal class OptionsGump : Gump
private Combobox _dragSelectModifierKey;
private Combobox _backpackStyle;
private Checkbox _hueContainerGumps;
private HSliderBar _containerOpacity;


//counters
Expand Down Expand Up @@ -163,6 +164,7 @@ internal class OptionsGump : Gump
private FontSelector _tooltip_font_selector;
private HSliderBar _dragSelectStartX, _dragSelectStartY;
private Checkbox _dragSelectAsAnchor;
private HSliderBar _journalOpacity;

// video
private Checkbox _use_old_status_gump, _windowBorderless, _enableDeathScreen, _enableBlackWhiteEffect, _altLights, _enableLight, _enableShadows, _enableShadowsStatics, _auraMouse, _runMouseInSeparateThread, _useColoredLights, _darkNights, _partyAura, _hideChatGradient, _animatedWaterEffect;
Expand Down Expand Up @@ -689,6 +691,22 @@ private void BuildGeneral()

_use_smooth_boat_movement.IsVisible = Client.Version >= ClientVersion.CV_7090;

section.Add(AddLabel(null, "Journal Opacity", startX, startY));

section.AddRight
(
_journalOpacity = AddHSlider(
null,
0,
100,
_currentProfile.JournalOpacity,
startX,
startY,
200
),
2
);


SettingsSection section2 = AddSettingsSection(box, "Mobiles");
section2.Y = section.Bounds.Bottom + 40;
Expand Down Expand Up @@ -3265,6 +3283,23 @@ private void BuildContainers()
startY += _backpackStyle.Height + 2 + 10;
}

text = AddLabel(rightArea, "Grid container opacity", startX, startY);
startX += text.Width + 5;

_containerOpacity = AddHSlider
(
rightArea,
0,
100,
_currentProfile.ContainerOpacity,
startX,
startY,
200
);

startY += text.Height + 2;
startX = 5;

text = AddLabel(rightArea, ResGumps.ContainerScale, startX, startY);
startX += text.Width + 5;

Expand Down Expand Up @@ -3510,6 +3545,7 @@ private void SetDefault()
_use_old_status_gump.IsChecked = false;
_auraType.SelectedIndex = 0;
_fieldsType.SelectedIndex = 0;
_journalOpacity.Value = 50;

_showSkillsMessage.IsChecked = true;
_showSkillsMessageDelta.Value = 1;
Expand Down Expand Up @@ -3648,6 +3684,7 @@ private void SetDefault()
break;

case 11: // containers
_containerOpacity.Value = 50;
_containersScale.Value = 100;
_containerScaleItems.IsChecked = false;
_useLargeContianersGumps.IsChecked = false;
Expand Down Expand Up @@ -3788,6 +3825,12 @@ private void Apply()
_currentProfile.TextFading = _textFading.IsChecked;
_currentProfile.UseSmoothBoatMovement = _use_smooth_boat_movement.IsChecked;

if(_currentProfile.JournalOpacity != _journalOpacity.Value)
{
_currentProfile.JournalOpacity = (byte)_journalOpacity.Value;
UIManager.GetGump<ResizableJournal>()?.RequestUpdateContents();
}

if (_currentProfile.ShowHouseContent != _showHouseContent.IsChecked)
{
_currentProfile.ShowHouseContent = _showHouseContent.IsChecked;
Expand Down Expand Up @@ -4190,6 +4233,13 @@ private void Apply()


// containers
if(_containerOpacity.Value != _currentProfile.ContainerOpacity)
{
_currentProfile.ContainerOpacity = (byte)_containerOpacity.Value;
foreach (GridContainer gridContainer in UIManager.Gumps.OfType<GridContainer>())
gridContainer.RequestUpdateContents();
}

int containerScale = _currentProfile.ContainersScale;

if ((byte) _containersScale.Value != containerScale || _currentProfile.ScaleItemsInsideContainers != _containerScaleItems.IsChecked)
Expand Down
11 changes: 8 additions & 3 deletions src/ClassicUO.Client/Game/UI/Gumps/ResizableJournal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ internal class ResizableJournal : ResizableGump
#region CONSTANTS
private const int MIN_WIDTH = 410;
private const int MIN_HEIGHT = 350;
private const int LINE_SPACING = 4;
private const int BORDER_WIDTH = 5;
private const int BORDER_WIDTH = 4;
private const int SCROLL_BAR_WIDTH = 18;
#region TABS
private const int TAB_WIDTH = 100;
Expand Down Expand Up @@ -55,7 +54,7 @@ public ResizableJournal() : base(_lastWidth, _lastHeight, MIN_WIDTH, MIN_HEIGHT,
Y = _lastY;

#region Background
_background = new AlphaBlendControl(0.7f);
_background = new AlphaBlendControl(ProfileManager.CurrentProfile.JournalOpacity);
_background.Width = Width - (BORDER_WIDTH * 2);
_background.Height = Height - (BORDER_WIDTH * 2);
_background.X = BORDER_WIDTH;
Expand Down Expand Up @@ -177,6 +176,12 @@ private void InitJournalEntries()
}
}

protected override void UpdateContents()
{
base.UpdateContents();
_background.Alpha = (float)ProfileManager.CurrentProfile.JournalOpacity / 100;
}

public override void Update()
{
base.Update();
Expand Down

0 comments on commit ae0e5dd

Please sign in to comment.