Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TouchControlsEnabler.csx (and a script to fix alphys lab crash) #1415

Merged
merged 21 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Linq;
using UndertaleModLib.Util;

EnsureDataLoaded();

if (Data?.GeneralInfo?.DisplayName?.Content.ToLower() == "undertale")
mustafakhalaf-git marked this conversation as resolved.
Show resolved Hide resolved
{
ReplaceTextInGML("gml_Object_obj_labdarkness_Create_0", "glowamt = 0.5", "");
mustafakhalaf-git marked this conversation as resolved.
Show resolved Hide resolved
ReplaceTextInGML("gml_Object_obj_labdarkness_Create_0", "if (global.plot > 125)", "");
ReplaceTextInGML("gml_Object_obj_labdarkness_Create_0", "if (scr_murderlv() >= 12)", "");
ReplaceTextInGML("gml_Object_obj_labdarkness_Create_0", "instance_destroy()", "");
ReplaceTextInGML("gml_Object_obj_labdarkness_Draw_0", "x1 = (obj_mainchara.x - 10)", "");
ReplaceTextInGML("gml_Object_obj_labdarkness_Draw_0", "x2 = (obj_mainchara.x + 30)", "");
ReplaceTextInGML("gml_Object_obj_labdarkness_Draw_0", "y1 = (obj_mainchara.y - 5)", "");
ReplaceTextInGML("gml_Object_obj_labdarkness_Draw_0", "y2 = (obj_mainchara.y + 35)", "");
ReplaceTextInGML("gml_Object_obj_labdarkness_Draw_0", "draw_sprite_ext(spr_darkhalo_big, 0, x1, y1, 1, 1, 0, c_white, glowamt)", "");
ReplaceTextInGML("gml_Object_obj_labdarkness_Draw_0", "draw_set_alpha(1)", "");
ReplaceTextInGML("gml_Object_obj_labcamera_Create_0", "if (global.osflavor == 2)", "if (global.osflavor == 4)");
mustafakhalaf-git marked this conversation as resolved.
Show resolved Hide resolved
} else {
ScriptError("Error 0: Compatible with Undertale only");
return;
}
411 changes: 411 additions & 0 deletions UndertaleModTool/Scripts/Community Scripts/TouchControlsEnabler.csx

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
persistent = true
control_fixture = physics_fixture_create()
physics_fixture_set_awake(control_fixture, 1)
mustafakhalaf-git marked this conversation as resolved.
Show resolved Hide resolved
if (string_lower(game_display_name) == "undertale")
{
settings_font = fnt_main
settings_num_x = 477
}
else
{
settings_font = fnt_mainbig
settings_num_x = 502
}
zx = 510
zy = 340
xx = 560
xy = 280
cx = 610
cy = 220
button_scale = 2.5
analog_scale = 3.3
analog_posx = -42
analog_posy = 232.5
analog_edit_selected = 0
analog_center_x = (analog_posx + (((59 * analog_scale) / 2) - ((41 * analog_scale) / 2)))
analog_center_y = (analog_posy + (((59 * analog_scale) / 2) - ((41 * analog_scale) / 2)))
arrowkeys_area_size = 19.675
arrowkeys_back_area_size = 45
joystick_type = 0
settingsx = 5
settingsy = 5
edit = 0
black_fade = 0
text_black_fade = 0
controls_opacity = 0.5
if file_exists("touchconfig.ini")
{
ini_open("touchconfig.ini")
zx = ini_read_real("CONFIG", "zx", 0)
zy = ini_read_real("CONFIG", "zy", 0)
xx = ini_read_real("CONFIG", "xx", 0)
xy = ini_read_real("CONFIG", "xy", 0)
cx = ini_read_real("CONFIG", "cx", 0)
cy = ini_read_real("CONFIG", "cy", 0)
analog_posx = ini_read_real("CONFIG", "analog_posx", 0)
analog_posy = ini_read_real("CONFIG", "analog_posy", 0)
button_scale = ini_read_real("CONFIG", "button_scale", 0)
analog_scale = ini_read_real("CONFIG", "analog_scale", 0)
joystick_type = ini_read_real("CONFIG", "joystick_type", 0)
controls_opacity = ini_read_real("CONFIG", "controls_opacity", 0)
ini_close()
mustafakhalaf-git marked this conversation as resolved.
Show resolved Hide resolved
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
draw_sprite_ext(spr_black, 0, 0, 0, 1, 1, 0, c_white, black_fade)
draw_set_font(settings_font)
draw_sprite_ext(spr_controls_config, 0, 220, 22.5, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_button_scale, 0, 120.5, 75, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_arrow_leftright, 0, 459.5, 75, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_analog_scale, 0, 120.5, 121, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_arrow_leftright, 0, 459.5, 121, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_analog_type, 0, 124, 167, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_arrow_leftright, 0, 459.5, 167, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_controls_opacity, 0, 106.5, 213, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_arrow_leftright, 0, 459.5, 213, 2, 2, 0, c_white, text_black_fade)
draw_sprite_ext(spr_reset_config, 0, 241, 412.25, 2, 2, 0, c_white, text_black_fade)
draw_text_colour(settings_num_x, 67, button_scale, c_white, c_white, c_white, c_white, text_black_fade)
draw_text_colour(settings_num_x, 113, analog_scale, c_white, c_white, c_white, c_white, text_black_fade)
draw_text_colour(settings_num_x, 159, joystick_type, c_white, c_white, c_white, c_white, text_black_fade)
draw_text_colour(settings_num_x, 205, controls_opacity, c_white, c_white, c_white, c_white, text_black_fade)
draw_sprite_ext(spr_z_button, keyboard_check(ord("Z")), zx, zy, button_scale, button_scale, 0, c_white, controls_opacity)
draw_sprite_ext(spr_x_button, keyboard_check(ord("X")), xx, xy, button_scale, button_scale, 0, c_white, controls_opacity)
draw_sprite_ext(spr_c_button, keyboard_check(ord("C")), cx, cy, button_scale, button_scale, 0, c_white, controls_opacity)
draw_sprite_ext(spr_joybase, joystick_type, analog_posx, analog_posy, analog_scale, analog_scale, 0, c_white, controls_opacity)
draw_sprite_ext(spr_joystick, joystick_type, analog_center_x, analog_center_y, analog_scale, analog_scale, 0, c_white, controls_opacity)
draw_sprite_ext(spr_settings, keyboard_check(92), settingsx, settingsy, button_scale, button_scale, 0, c_white, controls_opacity)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
virtual_key_zp = virtual_key_add(zx, zy, (27 * button_scale), (29 * button_scale), 125)
virtual_key_xp = virtual_key_add(xx, xy, (27 * button_scale), (29 * button_scale), 124)
virtual_key_cp = virtual_key_add(cx, cy, (27 * button_scale), (29 * button_scale), 94)
virtual_key_analogp = virtual_key_add(analog_posx, analog_posy, (59 * analog_scale), (59 * analog_scale), 93)
virtual_key_settings = virtual_key_add(settingsx, settingsy, (19 * button_scale), (25 * button_scale), 92)
if (edit == 0)
mustafakhalaf-git marked this conversation as resolved.
Show resolved Hide resolved
{
virtual_key_z = virtual_key_add(zx, zy, (27 * button_scale), (29 * button_scale), 90)
virtual_key_x = virtual_key_add(xx, xy, (27 * button_scale), (29 * button_scale), 88)
virtual_key_c = virtual_key_add(cx, cy, (27 * button_scale), (29 * button_scale), 67)
virtual_key_up = virtual_key_add((analog_posx - (arrowkeys_back_area_size * analog_scale)), (analog_posy - (arrowkeys_back_area_size * analog_scale)), ((arrowkeys_back_area_size * analog_scale) + ((59 * analog_scale) + (arrowkeys_back_area_size * analog_scale))), ((arrowkeys_area_size * analog_scale) + (arrowkeys_back_area_size * analog_scale)), 38)
virtual_key_right = virtual_key_add(((analog_posx + (59 * analog_scale)) - (arrowkeys_area_size * analog_scale)), (analog_posy - (arrowkeys_back_area_size * analog_scale)), ((arrowkeys_area_size * analog_scale) + (arrowkeys_back_area_size * analog_scale)), (((arrowkeys_back_area_size * analog_scale) + (59 * analog_scale)) + (arrowkeys_back_area_size * analog_scale)), 39)
virtual_key_left = virtual_key_add((analog_posx - (arrowkeys_back_area_size * analog_scale)), (analog_posy - (arrowkeys_back_area_size * analog_scale)), ((arrowkeys_area_size * analog_scale) + (arrowkeys_back_area_size * analog_scale)), ((arrowkeys_back_area_size * analog_scale) + ((59 * analog_scale) + (arrowkeys_back_area_size * analog_scale))), 37)
virtual_key_down = virtual_key_add((analog_posx - (arrowkeys_back_area_size * analog_scale)), ((analog_posy + (59 * analog_scale)) - (arrowkeys_area_size * analog_scale)), (((arrowkeys_back_area_size * analog_scale) + (59 * analog_scale)) + (arrowkeys_back_area_size * analog_scale)), ((arrowkeys_area_size * analog_scale) + (arrowkeys_back_area_size * analog_scale)), 40)
virtual_key_analog = virtual_key_add((analog_posx - (arrowkeys_back_area_size * analog_scale)), (analog_posy - (arrowkeys_back_area_size * analog_scale)), (((59 + arrowkeys_back_area_size) * analog_scale) + (arrowkeys_back_area_size * analog_scale)), (((59 + arrowkeys_back_area_size) * analog_scale) + (arrowkeys_back_area_size * analog_scale)), 126)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
if keyboard_check(ord("~"))
mustafakhalaf-git marked this conversation as resolved.
Show resolved Hide resolved
{
if (device_mouse_x_to_gui(0) >= analog_posx && device_mouse_x_to_gui(0) <= (analog_posx + (59 * analog_scale)))
analog_center_x = (device_mouse_x_to_gui(0) - (21 * analog_scale))
if (device_mouse_y_to_gui(0) >= analog_posy && device_mouse_y_to_gui(0) <= (analog_posy + (59 * analog_scale)))
analog_center_y = (device_mouse_y_to_gui(0) - (21 * analog_scale))
}
else
{
analog_center_x = (analog_posx + (((59 * analog_scale) / 2) - ((41 * analog_scale) / 2)))
analog_center_y = (analog_posy + (((59 * analog_scale) / 2) - ((41 * analog_scale) / 2)))
}
if keyboard_check_pressed(92)
{
edit += 1
if (edit == 1)
{
black_fade = 0.4
text_black_fade = 0.9
}
else if (edit == 3)
{
virtual_key_delete(virtual_key_up)
virtual_key_delete(virtual_key_down)
virtual_key_delete(virtual_key_left)
virtual_key_delete(virtual_key_right)
virtual_key_delete(virtual_key_z)
virtual_key_delete(virtual_key_x)
virtual_key_delete(virtual_key_c)
virtual_key_delete(virtual_key_zp)
virtual_key_delete(virtual_key_xp)
virtual_key_delete(virtual_key_cp)
virtual_key_delete(virtual_key_analog)
virtual_key_delete(virtual_key_analogp)
ini_open("touchconfig.ini")
ini_write_real("CONFIG", "zx", zx)
ini_write_real("CONFIG", "zy", zy)
ini_write_real("CONFIG", "xx", xx)
ini_write_real("CONFIG", "xy", xy)
ini_write_real("CONFIG", "cx", cx)
ini_write_real("CONFIG", "cy", cy)
ini_write_real("CONFIG", "analog_posx", analog_posx)
ini_write_real("CONFIG", "analog_posy", analog_posy)
ini_write_real("CONFIG", "button_scale", button_scale)
ini_write_real("CONFIG", "analog_scale", analog_scale)
ini_write_real("CONFIG", "joystick_type", joystick_type)
ini_write_real("CONFIG", "controls_opacity", controls_opacity)
ini_close()
black_fade = 0
text_black_fade = 0
edit = 0
scr_add_keys()
}
}
if edit
mustafakhalaf-git marked this conversation as resolved.
Show resolved Hide resolved
{
virtual_key_delete(virtual_key_up)
virtual_key_delete(virtual_key_down)
virtual_key_delete(virtual_key_left)
virtual_key_delete(virtual_key_right)
virtual_key_delete(virtual_key_z)
virtual_key_delete(virtual_key_x)
virtual_key_delete(virtual_key_c)
virtual_key_delete(virtual_key_zp)
virtual_key_delete(virtual_key_xp)
virtual_key_delete(virtual_key_cp)
virtual_key_delete(virtual_key_analog)
virtual_key_delete(virtual_key_analogp)
scr_add_keys()
if keyboard_check(ord("}"))
{
zx = (device_mouse_x_to_gui(0) - (19.5 * button_scale))
zy = (device_mouse_y_to_gui(0) - (18 * button_scale))
}
if keyboard_check(ord("|"))
{
xx = (device_mouse_x_to_gui(0) - (19.5 * button_scale))
xy = (device_mouse_y_to_gui(0) - (18 * button_scale))
}
if keyboard_check(ord("^"))
{
cx = (device_mouse_x_to_gui(0) - (19.5 * button_scale))
cy = (device_mouse_y_to_gui(0) - (18 * button_scale))
}
if keyboard_check(ord("]"))
{
analog_posx = (device_mouse_x_to_gui(0) - (29.5 * analog_scale))
analog_posy = (device_mouse_y_to_gui(0) - (29.5 * analog_scale))
}
if (device_mouse_x_to_gui(0) >= 459.5 && device_mouse_y_to_gui(0) >= 75 && device_mouse_x_to_gui(0) <= 469.5 && device_mouse_y_to_gui(0) <= 93 && mouse_check_button_pressed(mb_left))
{
if (button_scale > 1)
button_scale -= 0.1
}
if (device_mouse_x_to_gui(0) >= 531.5 && device_mouse_y_to_gui(0) >= 75 && device_mouse_x_to_gui(0) <= 541.5 && device_mouse_y_to_gui(0) <= 93 && mouse_check_button_pressed(mb_left))
{
if (button_scale < 3)
button_scale += 0.1
}
if (device_mouse_x_to_gui(0) >= 459.5 && device_mouse_y_to_gui(0) >= 121 && device_mouse_x_to_gui(0) <= 469.5 && device_mouse_y_to_gui(0) <= 139 && mouse_check_button_pressed(mb_left))
{
if (analog_scale > 1)
analog_scale -= 0.1
}
if (device_mouse_x_to_gui(0) >= 531.5 && device_mouse_y_to_gui(0) >= 121 && device_mouse_x_to_gui(0) <= 541.5 && device_mouse_y_to_gui(0) <= 139 && mouse_check_button_pressed(mb_left))
{
if (analog_scale < 4)
analog_scale += 0.1
}
if (device_mouse_x_to_gui(0) >= 459.5 && device_mouse_y_to_gui(0) >= 167 && device_mouse_x_to_gui(0) <= 469.5 && device_mouse_y_to_gui(0) <= 185 && mouse_check_button_pressed(mb_left))
{
if (joystick_type == 1)
joystick_type -= 1
}
if (device_mouse_x_to_gui(0) >= 531.5 && device_mouse_y_to_gui(0) >= 167 && device_mouse_x_to_gui(0) <= 541.5 && device_mouse_y_to_gui(0) <= 185 && mouse_check_button_pressed(mb_left))
{
if (joystick_type == 0)
joystick_type += 1
}
if (device_mouse_x_to_gui(0) >= 459.5 && device_mouse_y_to_gui(0) >= 167 && device_mouse_x_to_gui(0) <= 469.5 && device_mouse_y_to_gui(0) <= 231 && mouse_check_button_pressed(mb_left))
{
if (controls_opacity > 0.10)
controls_opacity -= 0.05
}
if (device_mouse_x_to_gui(0) >= 531.5 && device_mouse_y_to_gui(0) >= 167 && device_mouse_x_to_gui(0) <= 541.5 && device_mouse_y_to_gui(0) <= 231 && mouse_check_button_pressed(mb_left))
{
if (controls_opacity < 1.00)
controls_opacity += 0.05
}
if (device_mouse_x_to_gui(0) >= 241 && device_mouse_y_to_gui(0) >= 412.25 && device_mouse_x_to_gui(0) <= 399 && device_mouse_y_to_gui(0) <= 436.25 && mouse_check_button_pressed(mb_left))
{
zx = 510
zy = 340
xx = 560
xy = 280
cx = 610
cy = 220
button_scale = 2.5
analog_scale = 3.3
analog_posx = -42
analog_posy = 232.5
joystick_type = 0
controls_opacity = 0.5
}
}