mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-05 15:36:02 +00:00
Add opacity settings to on-screen controls (#798)
* Restore resize controls, Make buttons oval * Create new default configuration * Split Configuration Mode into separate Move and Resize modes * Add transparency setting for on-screen buttons * Updated translations for on-screen controls Co-authored-by: Leo <chun.huang@student.manchester.ac.uk>
This commit is contained in:
@@ -125,6 +125,13 @@ public class VirtualController {
|
||||
elements.clear();
|
||||
}
|
||||
|
||||
public void setOpacity(int opacity) {
|
||||
for (VirtualControllerElement element : elements) {
|
||||
element.setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addElement(VirtualControllerElement element, int x, int y, int width, int height) {
|
||||
elements.add(element);
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height);
|
||||
|
||||
@@ -324,6 +324,8 @@ public class VirtualControllerConfigurationLoader {
|
||||
screenScale(TRIGGER_HEIGHT, height)
|
||||
);
|
||||
}
|
||||
|
||||
controller.setOpacity(config.oscOpacity);
|
||||
}
|
||||
|
||||
public static void saveProfile(final VirtualController controller,
|
||||
@@ -361,4 +363,4 @@ public class VirtualControllerConfigurationLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,6 +295,15 @@ public abstract class VirtualControllerElement extends View {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
public void setOpacity(int opacity) {
|
||||
int hexOpacity = opacity * 255 / 100;
|
||||
this.normalColor = (hexOpacity << 24) | (normalColor & 0x00FFFFFF);
|
||||
this.pressedColor = (hexOpacity << 24) | (pressedColor & 0x00FFFFFF);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
protected final float getPercent(float value, float percent) {
|
||||
return value / 100 * percent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user