impl touch controls settings

This commit is contained in:
RandomityGuy 2026-04-05 02:17:08 +01:00
parent 53aaa9d16a
commit e527f452f6

View file

@ -29,6 +29,11 @@ class OptionsDlg extends GuiImage {
@:privateAccess arial14b.loader = ResourceLoader.loader; @:privateAccess arial14b.loader = ResourceLoader.loader;
var arial14 = arial14b.toSdfFont(cast 12 * Settings.uiScale, MultiChannel); var arial14 = arial14b.toSdfFont(cast 12 * Settings.uiScale, MultiChannel);
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
var domcasual32 = domcasual32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
function loadButtonImages(path:String) { function loadButtonImages(path:String) {
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile(); var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile(); var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
@ -93,7 +98,7 @@ class OptionsDlg extends GuiImage {
} }
var gfxWindow = new GuiButton(loadButtonImages("data/ui/options/grafwindo")); var gfxWindow = new GuiButton(loadButtonImages("data/ui/options/grafwindo"));
gfxWindow.position = new Vector(174, 116); gfxWindow.position = new Vector(174, 58);
gfxWindow.extent = new Vector(97, 55); gfxWindow.extent = new Vector(97, 55);
gfxWindow.buttonType = Toggle; gfxWindow.buttonType = Toggle;
gfxWindow.pressedAction = (sender) -> { gfxWindow.pressedAction = (sender) -> {
@ -106,7 +111,7 @@ class OptionsDlg extends GuiImage {
windowBoxes.push(gfxWindow); windowBoxes.push(gfxWindow);
var gfxFull = new GuiButton(loadButtonImages("data/ui/options/grafful")); var gfxFull = new GuiButton(loadButtonImages("data/ui/options/grafful"));
gfxFull.position = new Vector(288, 118); gfxFull.position = new Vector(288, 60);
gfxFull.extent = new Vector(61, 55); gfxFull.extent = new Vector(61, 55);
gfxFull.buttonType = Toggle; gfxFull.buttonType = Toggle;
gfxFull.pressedAction = (sender) -> { gfxFull.pressedAction = (sender) -> {
@ -118,12 +123,67 @@ class OptionsDlg extends GuiImage {
graphicsPane.addChild(gfxFull); graphicsPane.addChild(gfxFull);
windowBoxes.push(gfxFull); windowBoxes.push(gfxFull);
var gfxText = new GuiImage(ResourceLoader.getResource("data/ui/options/graf_txt.png", ResourceLoader.getImage, this.imageResources).toTile()); // var gfxText = new GuiImage(ResourceLoader.getResource("data/ui/options/graf_txt.png", ResourceLoader.getImage, this.imageResources).toTile());
gfxText.horizSizing = Right; // gfxText.horizSizing = Right;
gfxText.vertSizing = Bottom; // gfxText.vertSizing = Bottom;
gfxText.position = new Vector(12, 12); // gfxText.position = new Vector(12, 12);
gfxText.extent = new Vector(146, 261); // gfxText.extent = new Vector(146, 261);
graphicsPane.addChild(gfxText); // graphicsPane.addChild(gfxText);
var resolutionLabel = new GuiText(domcasual32);
resolutionLabel.position = new Vector(12, 9);
resolutionLabel.extent = new Vector(146, 261);
resolutionLabel.text.textColor = 0x000000;
resolutionLabel.text.text = "Screen Resolution:";
resolutionLabel.justify = Right;
graphicsPane.addChild(resolutionLabel);
var screenStyleLabel = new GuiText(domcasual32);
screenStyleLabel.position = new Vector(12, 70);
screenStyleLabel.extent = new Vector(146, 261);
screenStyleLabel.text.textColor = 0x000000;
screenStyleLabel.text.text = "Screen Style:";
screenStyleLabel.justify = Right;
graphicsPane.addChild(screenStyleLabel);
var vsyncLabel = new GuiText(domcasual32);
vsyncLabel.position = new Vector(12, 120);
vsyncLabel.extent = new Vector(146, 261);
vsyncLabel.text.textColor = 0x000000;
vsyncLabel.text.text = "VSync:";
vsyncLabel.justify = Right;
graphicsPane.addChild(vsyncLabel);
var vsyncButton = new GuiButton(loadButtonImages("data/ui/options/graf_chkbx"));
vsyncButton.position = new Vector(170, 100);
vsyncButton.extent = new Vector(46, 54);
vsyncButton.buttonType = Toggle;
graphicsPane.addChild(vsyncButton);
if (Settings.optionsSettings.vsync) {
vsyncButton.pressed = true;
}
var fieldOfViewLabel = new GuiText(domcasual32);
fieldOfViewLabel.position = new Vector(12, 170);
fieldOfViewLabel.extent = new Vector(146, 261);
fieldOfViewLabel.text.textColor = 0x000000;
fieldOfViewLabel.text.text = "Field of View:";
fieldOfViewLabel.justify = Right;
graphicsPane.addChild(fieldOfViewLabel);
var fovSlide = new GuiImage(ResourceLoader.getResource("data/ui/options/slider.png", ResourceLoader.getImage, this.imageResources).toTile());
fovSlide.position = new Vector(170, 163);
fovSlide.extent = new Vector(254, 34);
graphicsPane.addChild(fovSlide);
var fovSlider = new GuiSlider(ResourceLoader.getResource("data/ui/options/aud_mus_knb.png", ResourceLoader.getImage, this.imageResources).toTile());
fovSlider.position = new Vector(170, 163);
fovSlider.extent = new Vector(250, 34);
fovSlider.sliderValue = (Settings.optionsSettings.fovX - 60) / (140 - 60);
fovSlider.pressedAction = (sender) -> {
Settings.optionsSettings.fovX = cast(60 + fovSlider.sliderValue * (140 - 60));
}
graphicsPane.addChild(fovSlider);
var resolutionBoxes = []; var resolutionBoxes = [];
@ -170,40 +230,40 @@ class OptionsDlg extends GuiImage {
gfx1024768.pressed = true; gfx1024768.pressed = true;
graphicsPane.addChild(gfx1024768); graphicsPane.addChild(gfx1024768);
var driverBoxes = []; // var driverBoxes = [];
function updateDriverFunc(sender:GuiButton) { // function updateDriverFunc(sender:GuiButton) {
for (box in driverBoxes) { // for (box in driverBoxes) {
if (box != sender) // if (box != sender)
box.pressed = false; // box.pressed = false;
} // }
} // }
var gfxopengl = new GuiButton(loadButtonImages("data/ui/options/grafopgl")); // var gfxopengl = new GuiButton(loadButtonImages("data/ui/options/grafopgl"));
gfxopengl.position = new Vector(165, 58); // gfxopengl.position = new Vector(165, 58);
gfxopengl.extent = new Vector(97, 54); // gfxopengl.extent = new Vector(97, 54);
gfxopengl.buttonType = Radio; // gfxopengl.buttonType = Radio;
driverBoxes.push(gfxopengl); // driverBoxes.push(gfxopengl);
gfxopengl.pressedAction = (sender) -> { // gfxopengl.pressedAction = (sender) -> {
updateDriverFunc(gfxopengl); // updateDriverFunc(gfxopengl);
} // }
if (Settings.optionsSettings.videoDriver == 0) { // if (Settings.optionsSettings.videoDriver == 0) {
gfxopengl.pressed = true; // gfxopengl.pressed = true;
} // }
graphicsPane.addChild(gfxopengl); // graphicsPane.addChild(gfxopengl);
var gfxd3d = new GuiButton(loadButtonImages("data/ui/options/grafdir3d")); // var gfxd3d = new GuiButton(loadButtonImages("data/ui/options/grafdir3d"));
gfxd3d.position = new Vector(270, 59); // gfxd3d.position = new Vector(270, 59);
gfxd3d.extent = new Vector(104, 52); // gfxd3d.extent = new Vector(104, 52);
gfxd3d.buttonType = Radio; // gfxd3d.buttonType = Radio;
driverBoxes.push(gfxd3d); // driverBoxes.push(gfxd3d);
gfxd3d.pressedAction = (sender) -> { // gfxd3d.pressedAction = (sender) -> {
updateDriverFunc(gfxd3d); // updateDriverFunc(gfxd3d);
} // }
if (Settings.optionsSettings.videoDriver == 1) { // if (Settings.optionsSettings.videoDriver == 1) {
gfxd3d.pressed = true; // gfxd3d.pressed = true;
} // }
graphicsPane.addChild(gfxd3d); // graphicsPane.addChild(gfxd3d);
var applyButton = new GuiButton(loadButtonImages("data/ui/options/grafapply")); var applyButton = new GuiButton(loadButtonImages("data/ui/options/grafapply"));
applyButton.position = new Vector(188, 239); applyButton.position = new Vector(188, 239);
@ -211,49 +271,49 @@ class OptionsDlg extends GuiImage {
applyButton.pressedAction = (sender) -> applyFunc(); applyButton.pressedAction = (sender) -> applyFunc();
graphicsPane.addChild(applyButton); graphicsPane.addChild(applyButton);
var bitBoxes = []; // var bitBoxes = [];
function updateBitsFunc(sender:GuiButton) { // function updateBitsFunc(sender:GuiButton) {
for (box in bitBoxes) { // for (box in bitBoxes) {
if (box != sender) // if (box != sender)
box.pressed = false; // box.pressed = false;
} // }
} // }
var gfx16 = new GuiButton(loadButtonImages("data/ui/options/graf16bt")); // var gfx16 = new GuiButton(loadButtonImages("data/ui/options/graf16bt"));
gfx16.position = new Vector(179, 170); // gfx16.position = new Vector(179, 170);
gfx16.extent = new Vector(79, 54); // gfx16.extent = new Vector(79, 54);
gfx16.buttonType = Radio; // gfx16.buttonType = Radio;
bitBoxes.push(gfx16); // bitBoxes.push(gfx16);
gfx16.pressedAction = (sender) -> { // gfx16.pressedAction = (sender) -> {
updateBitsFunc(gfx16); // updateBitsFunc(gfx16);
} // }
if (Settings.optionsSettings.colorDepth == 0) { // if (Settings.optionsSettings.colorDepth == 0) {
gfx16.pressed = true; // gfx16.pressed = true;
} // }
graphicsPane.addChild(gfx16); // graphicsPane.addChild(gfx16);
var gfx32 = new GuiButton(loadButtonImages("data/ui/options/graf32bt")); // var gfx32 = new GuiButton(loadButtonImages("data/ui/options/graf32bt"));
gfx32.position = new Vector(272, 174); // gfx32.position = new Vector(272, 174);
gfx32.extent = new Vector(84, 51); // gfx32.extent = new Vector(84, 51);
gfx32.buttonType = Radio; // gfx32.buttonType = Radio;
bitBoxes.push(gfx32); // bitBoxes.push(gfx32);
gfx32.pressedAction = (sender) -> { // gfx32.pressedAction = (sender) -> {
updateBitsFunc(gfx32); // updateBitsFunc(gfx32);
} // }
if (Settings.optionsSettings.colorDepth == 1) { // if (Settings.optionsSettings.colorDepth == 1) {
gfx32.pressed = true; // gfx32.pressed = true;
} // }
graphicsPane.addChild(gfx32); // graphicsPane.addChild(gfx32);
var shadowsButton = new GuiButton(loadButtonImages("data/ui/options/graf_chkbx")); // var shadowsButton = new GuiButton(loadButtonImages("data/ui/options/graf_chkbx"));
shadowsButton.position = new Vector(141, 233); // shadowsButton.position = new Vector(141, 233);
shadowsButton.extent = new Vector(46, 54); // shadowsButton.extent = new Vector(46, 54);
shadowsButton.buttonType = Toggle; // shadowsButton.buttonType = Toggle;
graphicsPane.addChild(shadowsButton); // graphicsPane.addChild(shadowsButton);
if (Settings.optionsSettings.shadows) { // if (Settings.optionsSettings.shadows) {
shadowsButton.pressed = true; // shadowsButton.pressed = true;
} // }
// AUDIO PANEL // AUDIO PANEL
@ -340,15 +400,15 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
Settings.optionsSettings.isFullScreen = true; Settings.optionsSettings.isFullScreen = true;
else else
Settings.optionsSettings.isFullScreen = false; Settings.optionsSettings.isFullScreen = false;
if (gfx16.pressed) // if (gfx16.pressed)
Settings.optionsSettings.colorDepth = 0; // Settings.optionsSettings.colorDepth = 0;
else // else
Settings.optionsSettings.colorDepth = 1; // Settings.optionsSettings.colorDepth = 1;
if (gfxopengl.pressed) // if (gfxopengl.pressed)
Settings.optionsSettings.videoDriver = 0; // Settings.optionsSettings.videoDriver = 0;
else // else
Settings.optionsSettings.videoDriver = 1; // Settings.optionsSettings.videoDriver = 1;
Settings.optionsSettings.shadows = shadowsButton.pressed; // Settings.optionsSettings.shadows = shadowsButton.pressed;
Settings.optionsSettings.musicVolume = audMusKnob.sliderValue; Settings.optionsSettings.musicVolume = audMusKnob.sliderValue;
Settings.optionsSettings.soundVolume = audSndKnob.sliderValue; Settings.optionsSettings.soundVolume = audSndKnob.sliderValue;
@ -460,6 +520,119 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
var controlsPane = new GuiControl(); var controlsPane = new GuiControl();
controlsPane.position = new Vector(44, 58); controlsPane.position = new Vector(44, 58);
controlsPane.extent = new Vector(459, 339); controlsPane.extent = new Vector(459, 339);
var transparentbmp = new hxd.BitmapData(1, 1);
transparentbmp.setPixel(0, 0, 0);
var transparentTile = Tile.fromBitmap(transparentbmp);
var domcasual24fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
var domcasual24b = new BitmapFont(domcasual24fontdata.entry);
@:privateAccess domcasual24b.loader = ResourceLoader.loader;
var domcasual24 = domcasual24b.toSdfFont(cast 20 * Settings.uiScale, MultiChannel);
if (Util.isTouchDevice()) {
var hideControlsLabel = new GuiText(domcasual32);
hideControlsLabel.position = new Vector(12, 62);
hideControlsLabel.extent = new Vector(200, 50);
hideControlsLabel.text.textColor = 0x000000;
hideControlsLabel.text.text = "Hide Controls:";
hideControlsLabel.justify = Right;
controlsPane.addChild(hideControlsLabel);
var hideControlsButton = new GuiButton(loadButtonImages("data/ui/options/graf_chkbx"));
hideControlsButton.position = new Vector(220, 46);
hideControlsButton.extent = new Vector(46, 54);
hideControlsButton.buttonType = Toggle;
hideControlsButton.pressedAction = (sender) -> {
Settings.touchSettings.hideControls = hideControlsButton.pressed;
}
controlsPane.addChild(hideControlsButton);
var buttonCameraFactorLabel = new GuiText(domcasual32);
buttonCameraFactorLabel.position = new Vector(12, 110);
buttonCameraFactorLabel.extent = new Vector(200, 50);
buttonCameraFactorLabel.text.textColor = 0x000000;
buttonCameraFactorLabel.text.text = "Button-Camera Factor:";
buttonCameraFactorLabel.justify = Right;
controlsPane.addChild(buttonCameraFactorLabel);
var buttonCameraFactorSlider = new GuiImage(ResourceLoader.getResource("data/ui/options/slider.png", ResourceLoader.getImage, this.imageResources)
.toTile());
buttonCameraFactorSlider.position = new Vector(220, 110);
buttonCameraFactorSlider.extent = new Vector(200, 34);
controlsPane.addChild(buttonCameraFactorSlider);
var buttonCameraFactorKnob = new GuiSlider(ResourceLoader.getResource("data/ui/options/aud_snd_knb.png", ResourceLoader.getImage,
this.imageResources)
.toTile());
buttonCameraFactorKnob.position = new Vector(220, 110);
buttonCameraFactorKnob.extent = new Vector(196, 34);
buttonCameraFactorKnob.sliderValue = Settings.touchSettings.buttonJoystickMultiplier / 3;
buttonCameraFactorKnob.pressedAction = (sender) -> {
Settings.touchSettings.buttonJoystickMultiplier = buttonCameraFactorKnob.sliderValue * 3;
}
controlsPane.addChild(buttonCameraFactorKnob);
var cameraSwipeExtentLabel = new GuiText(domcasual32);
cameraSwipeExtentLabel.position = new Vector(12, 160);
cameraSwipeExtentLabel.extent = new Vector(200, 50);
cameraSwipeExtentLabel.text.textColor = 0x000000;
cameraSwipeExtentLabel.text.text = "Camera Swipe Extent:";
cameraSwipeExtentLabel.justify = Right;
controlsPane.addChild(cameraSwipeExtentLabel);
var cameraSwipeExtentSlider = new GuiImage(ResourceLoader.getResource("data/ui/options/slider.png", ResourceLoader.getImage, this.imageResources)
.toTile());
cameraSwipeExtentSlider.position = new Vector(220, 160);
cameraSwipeExtentSlider.extent = new Vector(200, 34);
controlsPane.addChild(cameraSwipeExtentSlider);
var cameraSwipeExtentKnob = new GuiSlider(ResourceLoader.getResource("data/ui/options/aud_mus_knb.png", ResourceLoader.getImage,
this.imageResources)
.toTile());
cameraSwipeExtentKnob.position = new Vector(220, 160);
cameraSwipeExtentKnob.extent = new Vector(196, 34);
cameraSwipeExtentKnob.sliderValue = (Settings.touchSettings.cameraSwipeExtent - 5) / (35 - 5);
cameraSwipeExtentKnob.pressedAction = (sender) -> {
Settings.touchSettings.cameraSwipeExtent = 5 + (35 - 5) * cameraSwipeExtentKnob.sliderValue;
}
controlsPane.addChild(cameraSwipeExtentKnob);
var dynamicJoystickLabel = new GuiText(domcasual32);
dynamicJoystickLabel.position = new Vector(12, 210);
dynamicJoystickLabel.extent = new Vector(200, 50);
dynamicJoystickLabel.text.textColor = 0x000000;
dynamicJoystickLabel.text.text = "Dynamic Joystick:";
dynamicJoystickLabel.justify = Right;
controlsPane.addChild(dynamicJoystickLabel);
var dynamicJoystickButton = new GuiButton(loadButtonImages("data/ui/options/graf_chkbx"));
dynamicJoystickButton.position = new Vector(220, 194);
dynamicJoystickButton.extent = new Vector(46, 54);
dynamicJoystickButton.buttonType = Toggle;
dynamicJoystickButton.pressedAction = (sender) -> {
Settings.touchSettings.dynamicJoystick = dynamicJoystickButton.pressed;
}
controlsPane.addChild(dynamicJoystickButton);
var touchControlsTxt = new GuiText(domcasual32);
touchControlsTxt.text.text = "Touch Controls:";
touchControlsTxt.text.textColor = 0x000000;
touchControlsTxt.justify = Right;
touchControlsTxt.position = new Vector(12, 260);
touchControlsTxt.extent = new Vector(200, 40);
var touchControlsEdit = new GuiButtonText(loadButtonImages("data/ui/options/cntr_cam_dwn"), domcasual24);
touchControlsEdit.position = new Vector(82, 300);
touchControlsEdit.txtCtrl.text.text = "Edit";
touchControlsEdit.setExtent(new Vector(109, 39));
touchControlsEdit.pressedAction = (sender) -> {
MarbleGame.canvas.setContent(new TouchCtrlsEditGui());
}
controlsPane.addChild(touchControlsTxt);
controlsPane.addChild(touchControlsEdit);
} else {
// MARBLE PANEL // MARBLE PANEL
var marbleControlsPane = new GuiImage(ResourceLoader.getResource("data/ui/options/cntrl_marb_bse.png", ResourceLoader.getImage, this.imageResources) var marbleControlsPane = new GuiImage(ResourceLoader.getResource("data/ui/options/cntrl_marb_bse.png", ResourceLoader.getImage, this.imageResources)
.toTile()); .toTile());
@ -524,15 +697,6 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
} }
marbleControlsPane.addChild(moveJmp); marbleControlsPane.addChild(moveJmp);
var domcasual24fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
var domcasual24b = new BitmapFont(domcasual24fontdata.entry);
@:privateAccess domcasual24b.loader = ResourceLoader.loader;
var domcasual24 = domcasual24b.toSdfFont(cast 20 * Settings.uiScale, MultiChannel);
var transparentbmp = new hxd.BitmapData(1, 1);
transparentbmp.setPixel(0, 0, 0);
var transparentTile = Tile.fromBitmap(transparentbmp);
var marbleToCameraButton = new GuiButton([transparentTile, transparentTile, transparentTile]); var marbleToCameraButton = new GuiButton([transparentTile, transparentTile, transparentTile]);
marbleToCameraButton.position = new Vector(138, 26); marbleToCameraButton.position = new Vector(138, 26);
marbleToCameraButton.extent = new Vector(121, 40); marbleToCameraButton.extent = new Vector(121, 40);
@ -681,6 +845,7 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
Settings.controlsSettings.cameraSensitivity = 0.12 + (1.2 - 0.12) * mouseSensitivity.sliderValue; Settings.controlsSettings.cameraSensitivity = 0.12 + (1.2 - 0.12) * mouseSensitivity.sliderValue;
} }
mouseControlsPane.addChild(mouseSensitivity); mouseControlsPane.addChild(mouseSensitivity);
}
// INVISIBLE BUTTON SHIT // INVISIBLE BUTTON SHIT
var audioTabBtn = new GuiButton([transparentTile, transparentTile, transparentTile]); var audioTabBtn = new GuiButton([transparentTile, transparentTile, transparentTile]);