camera: add zoom slider tooltip when dragging

Co-authored-by: superiorser9 <superiorser9@gmail.com>
This commit is contained in:
Adam
2021-06-01 20:19:56 -04:00
parent b1dd93bb0b
commit 8fe75748f9
2 changed files with 34 additions and 12 deletions

View File

@@ -367,15 +367,23 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
@Subscribe
private void onScriptPreFired(ScriptPreFired ev)
{
if (ev.getScriptId() == ScriptID.SETTINGS_SLIDER_CHOOSE_ONOP)
switch (ev.getScriptId())
{
int arg = client.getIntStackSize() - 7;
int[] is = client.getIntStack();
if (is[arg] == SettingID.CAMERA_ZOOM)
case ScriptID.SETTINGS_SLIDER_CHOOSE_ONOP:
{
addZoomTooltip(client.getScriptActiveWidget());
int arg = client.getIntStackSize() - 7;
int[] is = client.getIntStack();
if (is[arg] == SettingID.CAMERA_ZOOM)
{
addZoomTooltip(client.getScriptActiveWidget());
}
break;
}
case ScriptID.ZOOM_SLIDER_ONDRAG:
case ScriptID.SETTINGS_ZOOM_SLIDER_ONDRAG:
sliderTooltip = makeSliderTooltip();
break;
}
}
@@ -390,12 +398,14 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
private void addZoomTooltip(Widget w)
{
w.setOnMouseRepeatListener((JavaScriptCallback) ev ->
{
int value = client.getVar(VarClientInt.CAMERA_ZOOM_RESIZABLE_VIEWPORT);
int max = config.innerLimit() ? config.INNER_ZOOM_LIMIT : CameraPlugin.DEFAULT_INNER_ZOOM_LIMIT;
sliderTooltip = new Tooltip("Camera Zoom: " + value + " / " + max);
});
w.setOnMouseRepeatListener((JavaScriptCallback) ev -> sliderTooltip = makeSliderTooltip());
}
private Tooltip makeSliderTooltip()
{
int value = client.getVar(VarClientInt.CAMERA_ZOOM_RESIZABLE_VIEWPORT);
int max = config.innerLimit() ? config.INNER_ZOOM_LIMIT : CameraPlugin.DEFAULT_INNER_ZOOM_LIMIT;
return new Tooltip("Camera Zoom: " + value + " / " + max);
}
@Subscribe