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:
gotoAndDie
2020-03-21 07:41:27 +00:00
committed by GitHub
parent 37cf260ba6
commit 04b8a718e3
16 changed files with 69 additions and 2 deletions

View File

@@ -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);

View File

@@ -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 {
}
}
}
}
}

View File

@@ -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;
}