From dd6544293cc4d68322d00984134eb63c4407db61 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 10:26:57 +0300 Subject: [PATCH 01/84] Removed a number of GM8 function stubs that are long-gone from the native runtime. --- scripts/Unsupported.js | 145 +---------------------------------------- 1 file changed, 1 insertion(+), 144 deletions(-) diff --git a/scripts/Unsupported.js b/scripts/Unsupported.js index e56283e5..85648484 100644 --- a/scripts/Unsupported.js +++ b/scripts/Unsupported.js @@ -16,11 +16,6 @@ // Scripts -function execute_string() { ErrorFunction("execute_string()");} -function execute_file() { ErrorFunction("execute_file()");} -function show_info() { ErrorFunction("show_info()");} -function load_info(fname) { ErrorFunction("load_info()");} -function script_get_text(ind) { ErrorFunction("script_get_text()"); } function game_save(name) { ErrorFunction("game_save()"); } function game_load(name) { ErrorFunction("game_load()"); } function game_save_buffer(buffer) { ErrorFunction("game_save_buffer()"); } @@ -28,49 +23,12 @@ function game_load_buffer(buffer) { ErrorFunction("game_load_buffer()"); } // Splash screens -function splash_show_video(fname,loop) { ErrorFunction("splash_show_video()"); } -function splash_show_text(fname,delay) { ErrorFunction("splash_show_text()"); } -function splash_show_image(fname,delay) { ErrorFunction("splash_show_image()"); } -function splash_show_web(url,delay) { ErrorFunction("splash_show_web()"); } -function splash_set_main(main) { ErrorFunction("splash_set_main()"); } -function splash_set_scale(scale) { ErrorFunction("splash_set_scale()"); } -function splash_set_cursor(vis) { ErrorFunction("splash_set_cursor()"); } -function splash_set_color(col) { ErrorFunction("splash_set_color()"); } -var splash_set_colour = splash_set_color; -function splash_set_caption(cap) { ErrorFunction("splash_set_caption()"); } -function splash_set_fullscreen(full) { ErrorFunction("splash_set_fullscreen()"); } -function splash_set_border(border) { ErrorFunction("splash_set_border()"); } -function splash_set_size(w,h) { ErrorFunction("splash_set_size()"); } -function splash_set_position(x,y) { ErrorFunction("splash_set_position()"); } -function splash_set_adapt(adapt) { ErrorFunction("splash_set_adapt()"); } -function splash_set_top(top) { ErrorFunction("splash_set_top()"); } -function splash_set_interrupt(interrupt) { ErrorFunction("splash_set_interrupt()"); } -function splash_set_stop_key(stop) { ErrorFunction("splash_set_stop_key()"); } -function splash_set_stop_mouse(stop) { ErrorFunction("splash_set_stop_mouse()"); } -function splash_set_close_button(show) { ErrorFunction("splash_set_close_button()"); } function os_set_orientation_lock() { ErrorFunction("os_set_orientation_lock()"); } // general -function screen_redraw() {ErrorFunction("screen_redraw()");} -function screen_refresh() {ErrorFunction("screen_refresh()");} -function set_automatic_draw(value) {ErrorFunction("set_automatic_draw()");} -function set_synchronization(value) {ErrorFunction("set_synchronization()");} -function screen_wait_vsync() {ErrorFunction("screen_wait_vsync()");} -function window_set_region_size(w,h,adaptwindow) {ErrorFunction("window_set_region_size()");} -function window_get_region_width() {ErrorFunction("window_get_region_width()");} -function window_get_region_height() {ErrorFunction("window_get_region_height()");} function screen_save(fname) {MissingFunction("screen_save()");} function screen_save_part(fname,x,y,w,h) {MissingFunction("screen_save_part()");} -function transition_define(kind,name) {MissingFunction("transition_define()");} -function transition_exists(kind) {MissingFunction("transition_exists()");} - -function display_get_colordepth() {ErrorFunction("display_get_colordepth()");} -function display_get_frequency() {ErrorFunction("display_get_frequency()");} -function display_set_size(w,h) {ErrorFunction("display_set_size()");} -function display_set_colordepth(coldepth) {ErrorFunction("display_set_colordepth()");} -function display_set_frequency(frequency) {ErrorFunction("display_set_frequency()");} -function display_set_all(w,h,frequency,coldepth) {ErrorFunction("display_set_all()");} -function display_test_all(w,h,frequency,coldepth) {ErrorFunction("display_test_all()");} + function display_reset(AA) {ErrorFunction("display_reset()");} function display_mouse_set(x,y) {ErrorFunction("display_mouse_set()");} @@ -151,30 +109,7 @@ function clipboard_set_text(str) { // -------------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------------- -function set_program_priority(priority) {MissingFunction("set_program_priority()");} - - - - // IO -function joystick_exists(id) { return false; } -function joystick_name(id) {ErrorFunction("joystick_name()");} -function joystick_axes(id) {ErrorFunction("joystick_axes()");} -function joystick_buttons(id) {ErrorFunction("joystick_buttons()");} -function joystick_has_pov(id) {ErrorFunction("joystick_has_pov()");} -function joystick_direction(id) {ErrorFunction("joystick_direction()");} -function joystick_check_button(id,numb) {ErrorFunction("joystick_check_button()");} -function joystick_xpos(id) {ErrorFunction("joystick_xpos()");} -function joystick_ypos(id) {ErrorFunction("joystick_ypos()");} -function joystick_zpos(id) {ErrorFunction("joystick_zpos()");} -function joystick_rpos(id) {ErrorFunction("joystick_rpos()");} -function joystick_upos(id) {ErrorFunction("joystick_upos()");} -function joystick_vpos(id) {ErrorFunction("joystick_vpos()");} -function joystick_pov(id) {ErrorFunction("joystick_pov()");} - -function io_handle( ) {ErrorFunction("io_handle()");} -function mouse_wait() {ErrorFunction("mouse_wait()");} -function keyboard_wait() {ErrorFunction("keyboard_wait()");} function keyboard_get_numlock() {ErrorFunction("keyboard_get_numlock()");} function keyboard_set_numlock(on) {ErrorFunction("keyboard_set_numlock()");} @@ -232,35 +167,7 @@ function execute_program(prog,arg,wait) { ErrorFunction("execute_program()") function execute_shell(prog,arg) { ErrorFunction("execute_shell()"); } var secure_mode = true; - -// Registry -function registry_write_string(name,str) { ErrorFunction("registry_write_string()"); } -function registry_write_real(name,x) { ErrorFunction("registry_write_real()"); } -function registry_read_string(name) { ErrorFunction("registry_read_string()"); } -function registry_read_real(name) { ErrorFunction("registry_read_real()"); } -function registry_exists(name) { ErrorFunction("registry_exists()"); } -function registry_write_string_ext(key,name,str) { ErrorFunction("registry_write_string_ext()"); } -function registry_write_real_ext(key,name,x) { ErrorFunction("registry_write_real_ext()"); } -function registry_read_string_ext(key,name) { ErrorFunction("registry_read_string_ext()"); } -function registry_read_real_ext(key,name) { ErrorFunction("registry_read_real_ext()"); } -function registry_exists_ext(key,name) { ErrorFunction("registry_exists_ext()"); } -function registry_set_root(root) { ErrorFunction("registry_set_root()"); } - - // Message boxes/dialogs etc. -function message_text_font(_name,_size,_color,_style) {ErrorFunction("message_text_font()");} -function message_button(_spr) {ErrorFunction("message_button()");} -function message_button_font(_name,_size,_color,_style) {ErrorFunction("message_button_font()");} -function message_input_font(_name, _size, _color, _style) {ErrorFunction("message_input_font()");} -function message_text_charset() { ErrorFunction("message_text_charset()"); } -function message_mouse_color(col) { ErrorFunction("message_mouse_color()"); } -function message_input_color(col) { ErrorFunction("message_input_color()"); } -function message_caption(show, str) { ErrorFunction("message_caption()"); } -function message_position(x, y) { ErrorFunction("message_position()"); } -function message_size(w, h) { ErrorFunction("message_size()"); } -function show_menu(str, def) { ErrorFunction("show_menu()"); } -function show_menu_pos(x, y, str, def) { ErrorFunction("show_menu_pos()"); } -function get_color(defcol) { ErrorFunction("get_color()"); } function get_open_filename(filter, fname) { ErrorFunction("get_open_filename()"); } function get_save_filename(filter, fname) { ErrorFunction("get_save_filename()"); } function get_open_filename_ext(filter, fname, dir, title) { ErrorFunction("get_open_filename_ext()"); } @@ -271,43 +178,6 @@ function get_directory_alt(capt, root) { ErrorFunction("get_directory_alt()"); // sound -function sound_3d_set_sound_position(snd,x,y,z) { ErrorFunction("sound_3d_set_sound_position()"); } -function sound_3d_set_sound_velocity(snd,x,y,z) { ErrorFunction("sound_3d_set_sound_velocity()"); } -function sound_3d_set_sound_distance(snd,mindist,maxdist) { ErrorFunction("sound_3d_set_sound_distance()"); } -function sound_3d_set_sound_cone(snd,x,y,z,anglein,angleout,voloutside) { ErrorFunction("sound_3d_set_sound_cone()"); } -function sound_background_tempo(factor) { ErrorFunction("sound_background_tempo()"); } -function sound_pan(index,value) { ErrorFunction("sound_pan()"); } -function sound_set_search_directory(dir) { ErrorFunction("sound_set_search_directory()"); } -function sound_effect_set(snd,effect) { ErrorFunction("sound_effect_set()"); } -function sound_effect_chorus(snd,wetdry,depth,feedback,frequency,wave,delay,phase) { ErrorFunction("sound_effect_chorus()"); } -function sound_effect_echo(snd,wetdry,feedback,leftdelay,rightdelay,pandelay) { ErrorFunction("sound_effect_echo()"); } -function sound_effect_flanger(snd,wetdry,depth,feedback,frequency,wave,delay,phase) { ErrorFunction("sound_effect_flanger()"); } -function sound_effect_gargle(snd,rate,wave) { ErrorFunction("sound_effect_gargle()"); } -function sound_effect_reverb(snd,gain,mix,time,ratio) { ErrorFunction("sound_effect_reverb()"); } -function sound_effect_compressor(snd,gain,attack,release,threshold,ratio,delay) { ErrorFunction("sound_effect_compressor()"); } -function sound_effect_equalizer(snd,center,bandwidth,gain) { ErrorFunction("sound_effect_equalizer()"); } -function sound_discard(index) { ErrorFunction("sound_discard()"); } -function sound_restore(index) { ErrorFunction("sound_restore()"); } -function sound_get_preload(index) { ErrorFunction("sound_get_preload()"); } - -function cd_init() { ErrorFunction("cd_init()"); } -function cd_present() { ErrorFunction("cd_present()"); } -function cd_number() { ErrorFunction("cd_number()"); } -function cd_playing() { ErrorFunction("cd_playing()"); } -function cd_paused() { ErrorFunction("cd_paused()"); } -function cd_track() { ErrorFunction("cd_track()"); } -function cd_length() { ErrorFunction("cd_length()"); } -function cd_track_length(n) { ErrorFunction("cd_track_length()"); } -function cd_position() { ErrorFunction("cd_position()"); } -function cd_track_position() { ErrorFunction("cd_track_position()"); } -function cd_play(first,last) { ErrorFunction("cd_play()"); } -function cd_stop() { ErrorFunction("cd_stop()"); } -function cd_pause() { ErrorFunction("cd_pause()"); } -function cd_resume() { ErrorFunction("cd_resume()"); } -function cd_set_position(pos) { ErrorFunction("cd_set_position()"); } -function cd_set_track_position(pos) { ErrorFunction("cd_set_track_position()"); } -function cd_open_door() { ErrorFunction("cd_open_door()"); } -function cd_close_door() { ErrorFunction("cd_close_door()"); } function MCI_command(str) { ErrorFunction("MCI_command()"); } function texture_preload(texid) { ErrorFunction("texture_preload()"); } @@ -324,19 +194,6 @@ function texture_get_uvs(_tex) { ErrorFunction("texture_get_uvs()"); } function texture_global_scale(pow2integer) { ErrorFunction("texture_global_scale()"); } -function file_open_read() { ErrorFunction("file_open_read()"); } -function file_open_write() { ErrorFunction("file_open_write()"); } -function file_open_append() { ErrorFunction("file_open_append()"); } -function file_read_real() { ErrorFunction("file_read_real()"); } -function file_read_string() { ErrorFunction("file_read_string()"); } -function file_readln() { ErrorFunction("file_readln()"); } -function file_write_real() { ErrorFunction("file_write_real()"); } -function file_write_string() { ErrorFunction("file_write_string()"); } -function file_writeln() { ErrorFunction("file_writeln()"); } -function file_eof() { ErrorFunction("file_eof()"); } -function file_eoln() { ErrorFunction("file_eoln()"); } -function file_close() { ErrorFunction("file_close()"); } - //steam functions function steam_activate_overlay() { ErrorFunction("steam_activate_overlay()"); return -1; } function steam_is_overlay_enabled() { ErrorFunction("steam_is_overlay_enabled()"); return -1; } From 61a3cca94907df0fa6fec02fe17d9e016afeab33 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 11:13:57 +0300 Subject: [PATCH 02/84] Removed most of the contents of Function_Action.js (GMS1 DnD helpers, long-gone) --- scripts/functions/Function_Action.js | 1636 -------------------------- 1 file changed, 1636 deletions(-) diff --git a/scripts/functions/Function_Action.js b/scripts/functions/Function_Action.js index 9f2e4b54..54bf31e4 100644 --- a/scripts/functions/Function_Action.js +++ b/scripts/functions/Function_Action.js @@ -17,1639 +17,3 @@ // Whether the arguments to a function are relative var Argument_Relative = false; - -// Error messages -var error_a0003 = 'Trying to stop non-existing sound.', - error_a0004 = 'Trying to draw a non-existing sprite.', - error_a0005 = 'Trying to draw a non-existing background.', - error_a0006 = 'Cannot compare arguments.', - //error_a0007 = 'Video file not found (or name too long).', - error_a0008 = 'Trying to replace non-existing resource.', - error_a0009 = 'File does not exist.', - //error_a0010 = 'Trying to save screen to empty image file name.', - //error_a0011 = 'In secure mode you cannot open webpages.', - //error_a0012 = 'Failed to open the webpage.', - //error_a0013 = 'The particle system must first be created.', - error_a0014 = 'The particle emitter must first be created.'; - -// Track particle systems -var g_ParticleSystem = -1, - g_ParticleType = [], - g_ParticleEmit = []; - - -function action_execute_script() { ErrorFunction("action_execute_script()"); } -function action_show_info() { ErrorFunction("action_show_info()"); } -function action_show_video() { ErrorFunction("action_show_video()"); } - -function action_unknown() {} -function action_path_old() { action_unknown(); } -function action_draw_font() { action_unknown(); } -function action_draw_font_old() { action_unknown(); } -function action_fill_color() { action_unknown(); } -function action_line_color() { action_unknown(); } -function action_highscore() { action_unknown(); } - -function action_if_question(_arg) -{ - return show_question(_arg); -} - -function action_set_relative(rel) -{ - Argument_Relative = (rel < 0.5) ? false : true; -} - - -function action_set_cursor(_spr, _show) { - window_set_cursor(_spr); - g_CurrentCursor = _spr; - if( !_show ){ - EnableCursor(false); - }else{ - EnableCursor(true); - } -} - - -function action_set_sprite(_inst, _spr, _scale) -{ - // Left in for compatibility - var sprIndex = Round(_spr); - if (sprite_exists(sprIndex)) - { - _inst.sprite_index = sprIndex; - } - - if (_scale > 0 ) - { - _inst.image_xscale = _scale; - _inst.image_yscale = _scale; - } -} - -function action_set_motion(_inst, _dir, _val) -{ - if ( true == Argument_Relative ) - { - _inst.AddTo_Speed(_dir, _val); - } - else - { - _inst.direction = _dir; - _inst.speed = _val; - } -} - -function action_set_hspeed(_inst, _speed) -{ - if ( Argument_Relative ) - { - _inst.hspeed = _inst.hspeed + _speed; - } - else - { - _inst.hspeed = _speed; - } -} - -function action_set_vspeed(_inst, _speed) -{ - if ( Argument_Relative ) - { - _inst.vspeed = _inst.vspeed+_speed; - } - else - { - _inst.vspeed = _speed; - } -} - -function action_set_gravity(_inst, _gdir, _gravity) -{ - if (true == Argument_Relative ) - { - _inst.gravity_direction += _gdir; - _inst.gravity += _gravity; - } - else - { - _inst.gravity_direction = _gdir; - _inst.gravity = _gravity; - } -} - -function action_set_friction(_inst, _friction) -{ - if (true == Argument_Relative ) - { - _inst.friction += _friction; - } - else - { - _inst.friction = _friction; - } -} - -function action_move(_inst, direction, size) -{ - var b = false; - var d = 0; - - // Check whether any direction allowed - if (direction.length != 9) - { - debug("Incorrect argument for action_move()"); - return; - } - - for ( d=0 ; d<9 ; d++ ) - { - b = ((true==b) || (direction[d] == '1')) ? true : false; - } - - if ( true != b ) { - return; - } - - // Adapt the speed - if ( true == Argument_Relative ) - { - _inst.speed = _inst.speed + size; - } - else - { - _inst.speed = size ; - } - - // Find a valid direction - do - { - d = floor(YYRandom(9)); - } while ( !(direction[d] == '1') ); - - switch(d) - { - case 0: _inst.direction = 225; break; - case 1: _inst.direction = 270; break; - case 2: _inst.direction = 315; break; - case 3: _inst.direction = 180; break; - case 4: { _inst.direction = 0; _inst.speed = 0; break; } - case 5: _inst.direction = 0; break; - case 6: _inst.direction = 135; break; - case 7: _inst.direction = 90; break; - case 8: _inst.direction = 45; break; - } -} - -function action_move_point(_inst, _x, _y, _speed) -{ - if ( true == Argument_Relative ) - { - move_towards_point(_inst, _x + _inst.x, _y + _inst.y, _speed); - } - else - { - move_towards_point(_inst, _x, _y, _speed); - } -} - -function action_move_to(_inst, _x, _y) -{ - if ( true == Argument_Relative ) - { - _inst.SetPosition(_x + _inst.x, _y + _inst.y); - } - else - { - _inst.SetPosition(_x, _y); - } -} - -function action_move_start(_inst) -{ - _inst.SetPosition(_inst.xstart, _inst.ystart); -} - -function action_move_random(_inst, _sx, _sy) -{ - move_random(_inst, _sx, _sy); -} - -function action_snap(_inst, _hsnap, _vsnap) -{ - move_snap(_inst, _hsnap, _vsnap); -} - -function action_wrap(_inst, _wrap) -{ - var wrap = Round(_wrap); - _inst.wrap((wrap == 0) || (wrap == 2) ? true : false, (wrap == 1) || (wrap == 2) ? true : false); -} - -function action_reverse_xdir(_inst) -{ - _inst.hspeed = -_inst.hspeed; -} - -function action_reverse_ydir(_inst) -{ - _inst.vspeed = -_inst.vspeed; -} - -function action_move_contact(_inst, _dir, _maxdist, _useall) -{ - move_contact(_inst, _dir, _maxdist, _useall); -} - -function action_bounce(_inst, _adv, _useall) -{ - Command_Bounce(_inst, (_adv >= 0.5) ? true : false, (_useall == 1) ? true : false); -} - -function action_kill_object(_inst) -{ - instance_destroy(_inst ); -} - -function action_create_object(_inst, _objid, _x, _y) -{ - var objid = Round(_objid); - if (true != object_exists(objid)) - { - debug("Creating existence for non-existent object: " + objid.toString()); - return; - } - - var inst = null; - if ( true == Argument_Relative ) - { - inst = g_RunRoom.GML_AddInstance(_x + _inst.x, _y + _inst.y, objid); - } - else - { - inst = g_RunRoom.GML_AddInstance(_x, _y, objid); - } - - inst.PerformEvent(EVENT_PRE_CREATE, 0, inst, inst); - inst.PerformEvent(EVENT_CREATE, 0, inst, inst); - inst.created = true; -} - -function action_create_object_motion(_inst, _objid, _x, _y, _speed, _dir) -{ - var objid = Round(_objid); - if (true != object_exists(objid)) - { - debug("Creating instance for non-existent object: " + objid); - return; - } - - var inst = null; - if ( true == Argument_Relative ) - { - inst = g_RunRoom.GML_AddInstance(_x + _inst.x, _y + _inst.y, objid); - } - else - { - inst = g_RunRoom.GML_AddInstance(_x, _y, objid); - } - - inst.speed = _speed; - inst.direction =_dir; - inst.PerformEvent(EVENT_PRE_CREATE, 0, inst, inst); - inst.PerformEvent(EVENT_CREATE, 0, inst, inst); - inst.created = true; -} - -function action_create_object_random(_inst, _objid0, _objid1, _objid2, _objid3, _x, _y) -{ - if (!object_exists(_objid0 | 0) && !object_exists(_objid1 | 0) && !object_exists(_objid2 | 0) && !object_exists(_objid3 | 0)) - { - return; - } - - while ( true ) - { - var n = ~~YYRandom(4); - var id = arguments[n + 1] | 0; - if (!object_exists(id)) { - continue; - } - - var inst; - if (true == Argument_Relative) - { - inst = g_RunRoom.GML_AddInstance(_x + _inst.x, _y + _inst.y, id); - } - else - { - inst = g_RunRoom.GML_AddInstance(_x, _y, id); - } - - inst.PerformEvent(EVENT_PRE_CREATE, 0, inst, inst); - inst.PerformEvent(EVENT_CREATE, 0, inst, inst); - inst.created = true; - return; - } -} - -function action_sprite_set(_inst, _spr, _subimg, _imgspeed) -{ - var sprIndex = Round(_spr); - if (sprite_exists(sprIndex)) { - _inst.sprite_index = sprIndex; - } - - if (_subimg >= 0) { - _inst.image_index = _subimg; - } - - _inst.image_speed = _imgspeed; -} - -function action_sprite_color(_inst, _col, _alpha) -{ - _inst.image_blend = Round(_col); - _inst.image_alpha = _alpha; -} -var action_sprite_colour = action_sprite_color; - - -function action_sound(_snd, _loop) { - if (g_AudioModel == Audio_WebAudio) { - var snd = Round(_snd); - audio_play_sound(snd, 1, _loop >= 0.5 ? true : false); -/* audio_music fns DEPRECATED - switch (audio_get_type(snd)) { - case 0: - audio_play_sound(snd, 1, _loop >= 0.5 ? true : false); - break; - case 1: - audio_play_music(snd, _loop >= 0.5 ? true : false); - break; - } // end switch -*/ - } - else { - var snd = Round(_snd); - if (_loop >= 0.5) { - g_pSoundManager.Loop(snd); - } - g_pSoundManager.Play(snd); - } -} - -function action_set_alarm(_inst, _time, _alarm) -{ - var alarm = Round(_alarm); - var time = Round(_time); - if (!Argument_Relative || (_inst.get_timer(alarm) < 0) ) - { - _inst.set_timer(alarm, time); - } - else - { - _inst.set_timer(alarm, _inst.get_timer(alarm) + time); - } -} - -function action_end_game() -{ - game_end(); -} - -function action_restart_game() -{ - game_restart(); -} - -function action_if_dice(_arg) -{ - var Result; - if (_arg <= 1 ) - { - Result = 1; - } - else - { - Result = (YYRandom(Round(1000*_arg)) <= 1000) ? 1 : 0; - } - return Result; -} - -function action_if_variable() -{ - var r = 0; - if (typeof(arguments[0]) != typeof(arguments[1])) - { - // It's fine to compare a boolean against a number so convert if necessary - if ((typeof(arguments[0] == "boolean") && (typeof(arguments[1]) == "number"))) { - r = (arguments[0] == true) ? (1 - arguments[1]) : (0 - arguments[1]); - } - else if ((typeof(arguments[1] == "boolean") && (typeof(arguments[0]) == "number"))) { - r = (arguments[1] == true) ? (arguments[0] - 1) : (arguments[0] - 0); - } - else { - debug(error_a0006); - return; - } - } - else { - if (typeof(arguments[0]) == "string") - { - // From the C => "r = strcmp( _val1.str, _val2.str)" - r = (arguments[0] == arguments[1]) ? 0 : 1; - } - else - { - r = arguments[0] - arguments[1]; - } - } - - var result; - if (Round(arguments[2]) == 1) - { - result = (r < 0) ? 1 : 0; - } - else if (Round(arguments[2]) == 2) - { - result = (r > 0) ? 1 : 0; - } - else if (Round(arguments[2]) == 3) - { - result = (r <= 0) ? 1 : 0; - } - else if (Round(arguments[2]) == 4) - { - result = (r >= 0) ? 1 : 0; - } - else - { - result = (r == 0) ? 1 : 0; - } - return result; -} - -function action_draw_variable(_inst, _var, _x, _y) -{ - var str = ""; - if (typeof(arguments[0]) == "number") - { - if (_var == Round(_var)) - { - str = (Round(_var) | 0).toString(); - } - else - { - str = _var.toFixed(2).toString(); // should be 10.2 and not hard-coded like this - } - } - else - { - str = _var.toString(); - } - - - if (Argument_Relative ) - { - draw_text(_x + _inst.x, _y + _inst.y, str); - } - else - { - draw_text(_x, _y, str); - } -} - -function action_set_score(_score) -{ - if (Argument_Relative) - { - g_pBuiltIn.score += Round(_score); - } - else - { - g_pBuiltIn.score = Round(_score); - } -} - -function action_if_score() -{ - var result; - if (Round(arguments[1]) == 1) - { - result = (g_pBuiltIn.score < arguments[0]) ? 1 : 0; - } - else if (Round(arguments[1]) == 2) - { - result = (g_pBuiltIn.score > arguments[0]) ? 1 : 0; - } - else - { - result = (g_pBuiltIn.score == arguments[0]) ? 1 : 0; - } - return result; -} - -function action_draw_score(_inst, _x, _y, _score_str) -{ - var scoreStr = ""; - if (_score_str) - { - scoreStr = _score_str; - } - - var score = scoreStr + g_pBuiltIn.score.toString(); - if (Argument_Relative) - { - draw_text(_x + _inst.x, _y + _inst.y, score); - } - else - { - draw_text(_x, _y, score); - } -} - -function action_set_life(_lives) -{ - var oldlives = g_pBuiltIn.lives; - if ( true == Argument_Relative ) - { - g_pBuiltIn.lives += Round(_lives); - } - else - { - g_pBuiltIn.lives = Round(_lives); - } - - if ((oldlives > 0) && (g_pBuiltIn.lives <= 0) ) - { - g_pInstanceManager.PerformEvent(EVENT_OTHER_NOLIVES, 0); - } -} - -function action_if_life() -{ - var result; - if (Round(arguments[1]) == 1) - { - result = (g_pBuiltIn.lives < arguments[0]) ? 1 : 0; - } - else if (Round(arguments[1]) == 2) - { - result = (g_pBuiltIn.lives > arguments[0]) ? 1 : 0; - } - else - { - result = (g_pBuiltIn.lives == arguments[0]) ? 1 : 0; - } - return result; -} - -function action_draw_life(_inst, _x, _y, _life_str) -{ - var lifeStr = _life_str; - if (!lifeStr) - { - lifeStr = ""; - } - - var lives = lifeStr + g_pBuiltIn.lives.toString(); - if (Argument_Relative ) - { - draw_text(_x + _inst.x, _y + _inst.y, lives); - } - else - { - draw_text(_x, _y, lives); - } -} - -function action_draw_life_images(_inst, _x, _y, _spr) -{ - if (sprite_exists(Round(_spr))) - { - var spr = g_pSpriteManager.Get(Round(_spr)); - var w = spr.width; - for (var i=0; i < g_pBuiltIn.lives; i++) - { - if (Argument_Relative) - { - spr.Draw(0, _x + _inst.x + (i*w), _y + _inst.y, 1, 1, 0, clWhite, 1); - } - else - { - spr.Draw(0, _x + (i*w), _y, 1, 1, 0, clWhite, 1); - } - } - } -} - -function action_set_health(_inst, _health) -{ - var oldhealth = 0.0; - - oldhealth = g_pBuiltIn.health; - if ( true == Argument_Relative ) - { - g_pBuiltIn.health += _health; - } - else - { - g_pBuiltIn.health = _health; - } - - if ((oldhealth > 0) && (g_pBuiltIn.health <= 0)) - { - g_pInstanceManager.PerformEvent(EVENT_OTHER_NOHEALTH, 0); - } -} - -function action_if_health(_inst, _value, _op) -{ - var result; - _op = ~ ~_op; - if (_op == 1) - { - result = (g_pBuiltIn.health < _value) ? 1 : 0; - } - else if (_op == 2) - { - result = (g_pBuiltIn.health > _value) ? 1 : 0; - } - else - { - result = (g_pBuiltIn.health == _value) ? 1 : 0; - } - return result; -} - -function action_set_caption(_show_score_caption, _score_caption, _show_lives_caption, _lives_caption, _show_health_caption, _health_caption) -{ - g_pBuiltIn.show_score = Round(_show_score_caption) == 1 ? true : false; - g_pBuiltIn.caption_score = _score_caption; - - g_pBuiltIn.show_lives = Round(_show_lives_caption) == 1 ? true : false; - g_pBuiltIn.caption_lives = _lives_caption; - - g_pBuiltIn.show_health = Round(_show_health_caption) == 1 ? true : false; - g_pBuiltIn.caption_health = _health_caption; -} - -function action_draw_sprite(_inst, _spr, _x, _y, _subimg) -{ - if (!sprite_exists(Round(_spr)) ) - { - debug(error_a0004); - return; - } - - var subimg; - if (_subimg < 0) { - subimg = _inst.image_index; - } - else { - subimg = Math.floor(_subimg); - } - - var spr = g_pSpriteManager.Get(Round(_spr)); - if (Argument_Relative) - { - spr.Draw(subimg, _x + _inst.x, _y + _inst.y, 1, 1, 0, clWhite, 1); - } - else - { - spr.Draw(subimg, _x, _y, 1, 1, 0, clWhite, 1); - } -} - -function action_draw_background(_inst, _bg, _x, _y, _tiled) -{ - - //Fritz: Seems to have been disabled at some point in the past & throwing multiple errors so going to nuke it - ErrorFunction("action_draw_background()"); - /* - if ( true != Background_Exists(Round(_bg)) ) - { - debug(error_a0005); - return; - } - - var background = g_pBackgroundManager.Get(Round(_bg)); - var tiled = (_tiled >= 0.5) ? true : false; - */ -/* - if (Argument_Relative) - { - // bg.DrawTiled(_x + _inst.x, _y + _inst.y, 1.0, 1.0, tiled, tiled, 0,0, g_RunRoom.GetWidth(), g_Run_Room.GetHeight(), clWhite, 1.0); - } - else - { - // bg.DrawTiled(_x, _y, 1.0, 1.0, tiled, tiled, 0,0, g_RunRoom.GetWidth(), g_Run_Room.GetHeight(), clWhite, 1.0); - } -*/ -} - -function action_draw_text(_inst, _str, _x, _y) -{ - if (Argument_Relative) - { - draw_text(_x + _inst.x, _y + _inst.y, _str); - } - else - { - draw_text(_x, _y, _str); - } -} - -function action_draw_text_transformed(_inst, _text, _x, _y, _xscale, _yscale, _rot) -{ - if (Argument_Relative) - { - draw_text_transformed(_x + _inst.x, _y + _inst.y, _text, _xscale, _yscale, _rot); - } - else - { - draw_text_transformed(_x, _y, _text, _xscale, _yscale, _rot); - } -} - -function action_draw_rectangle(_inst, _x, _y, _x2, _y2, _outline) -{ - if (Argument_Relative ) - { - draw_rectangle(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, (_outline >= 0.5) ? true : false); - } - else - { - draw_rectangle(_x, _y, _x2, _y2, (_outline >= 0.5) ? true : false); - } -} - -function action_draw_line(_inst, _x, _y, _x2, _y2) -{ - if (Argument_Relative ) - { - draw_line(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y); - } - else - { - draw_line(_x, _y, _x2, _y2); - } -} - -function action_color(_col) -{ - draw_set_color(_col); -} -var action_colour = action_color; - - -function action_font(_font, _halign) -{ - draw_set_font(_font); - draw_set_halign(_halign); -} - - -function action_draw_health(_inst, _x, _y, _x2, _y2, _col, _col2) -{ - var col1 = 0; - var col2 = 0; - var col3 = 0; - var col4 = 0; - switch (Round(_col)) - { - case 0: col1 = clBlack; break; - case 1: col1 = clBlack; break; - case 2: col1 = clGray; break; - case 3: col1 = clSilver; break; - case 4: col1 = clWhite; break; - case 5: col1 = clMaroon; break; - case 6: col1 = clGreen; break; - case 7: col1 = clOlive; break; - case 8: col1 = clNavy; break; - case 9: col1 = clPurple; break; - case 10: col1 = clTeal; break; - case 11: col1 = clRed; break; - case 12: col1 = clLime; break; - case 13: col1 = clYellow; break; - case 14: col1 = clBlue; break; - case 15: col1 = clFuchsia; break; - case 16: col1 = clAqua; break; - } - - switch (Round(_col2)) - { - case 0: { col2 = clRed; col3 = clYellow; col4 = clLime; } break; - case 1: { col2 = clBlack; col3 = clGray; col4 = clWhite; } break; - case 2: col2 = clBlack; break; - case 3: col2 = clGray; break; - case 4: col2 = clSilver; break; - case 5: col2 = clWhite; break; - case 6: col2 = clMaroon; break; - case 7: col2 = clGreen; break; - case 8: col2 = clOlive; break; - case 9: col2 = clNavy; break; - case 10: col2 = clPurple; break; - case 11: col2 = clTeal; break; - case 12: col2 = clRed; break; - case 13: col2 = clLime; break; - case 14: col2 = clYellow; break; - case 15: col2 = clBlue; break; - case 16: col2 = clFuchsia; break; - case 17: col2 = clAqua; break; - } - - if (Round(_col2) > 1) - { - col3 = col2; - col4 = col2; - } - - if (Argument_Relative ) - { - draw_healthbar_ex(_x+_inst.x,_y+_inst.y, _x2+_inst.x, _y2+_inst.y, g_pBuiltIn.health, col1, col2, col3, col4, 0, (_col >= 0.5)?true:false, true); - } - else - { - draw_healthbar_ex(_x, _y, _x2, _y2, g_pBuiltIn.health, col1, col2, col3, col4, 0, (_col >= 0.5) ? true : false, true); - } -} - -function action_another_room(_room, _transition) -{ - room_goto(Round(_room)); -} - -function action_current_room() -{ - room_restart(); -} - -function action_previous_room() -{ - room_goto_previous(); -} - -function action_next_room() -{ - room_goto_next(); -} - -function action_if_previous_room() -{ - return ((g_pBuiltIn.get_current_room() != g_pBuiltIn.room_first) ? 1 : 0); -} - -function action_if_next_room() -{ - return ((g_pBuiltIn.get_current_room() != g_pBuiltIn.room_last) ? 1 : 0); -} - -function action_partsyst_create(_depth) -{ - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - ParticleSystem_Clear(g_ParticleSystem); - ParticleSystem_Depth(g_ParticleSystem, Round(_depth)); - - g_ParticleType = new Array(16); - g_ParticleEmit = new Array(16); - for (var i = 0 ; i < 16; i++ ) { - g_ParticleType[i] = -1; - g_ParticleEmit[i] = -1; - } -} - -function action_partsyst_destroy() -{ - if (g_ParticleSystem >= 0) { - ParticleSystem_Destroy(g_ParticleSystem); - } - g_ParticleSystem = -1; -} - -function action_partsyst_clear() -{ - if (g_ParticleSystem >= 0) { - ParticleSystem_Particles_Clear(g_ParticleSystem); - } -} - -function action_parttype_create_old(_type, _shape, _sizeMin, _sizeMax, _colStart, _colEnd) -{ - var type = Round(_type); - var shape = Round(_shape); - var colStart = Round(_colStart); - var colEnd = Round(_colEnd); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleType[type] < 0 ) { - g_ParticleType[type] = ParticleType_Create(); - } - var pt = g_ParticleType[type]; - ParticleType_Shape(pt, shape); - ParticleType_Size(pt, _sizeMin, _sizeMax, 0, 0); - ParticleType_Color2(pt, colStart, colEnd); -} - -function action_parttype_create(_type, _shape, _spr, _sizeMin, _sizeMax, _sizeIncr) -{ - var type = Round(_type); - var shape = Round(_shape); - var spr = Round(_spr); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - - if (g_ParticleType[type] < 0) { - g_ParticleType[type] = ParticleType_Create(); - } - var pt = g_ParticleType[type]; - ParticleType_Shape(pt, shape); - ParticleType_Sprite(pt, spr, true, false, false); - ParticleType_Size(pt, _sizeMin, _sizeMax, _sizeIncr, 0); -} - -function action_parttype_color(_type, _mixCol, _colStart, _colEnd, _alphaStart, _alphaEnd) -{ - var type = Round(_type); - var mixCol = Round(_mixCol); - var colStart = Round(_colStart); - var colEnd = Round(_colEnd); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleType[type] < 0 ) { - g_ParticleType[type] = ParticleType_Create(); - } - var pt = g_ParticleType[type]; - if (mixCol == 0) - { - ParticleType_Colour_Mix(pt, colStart, colEnd); - } - else - { - ParticleType_Color2(pt, colStart, colEnd); - } - ParticleType_Alpha2(pt, _alphaStart, _alphaEnd); -} -var action_parttype_colour = action_parttype_color; - -function action_parttype_life(_type, _lifeMin, _lifeMax) -{ - var type = Round(_type); - var lifeMin = Round(_lifeMin); - var lifeMax = Round(_lifeMax); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleType[type] < 0 ) { - g_ParticleType[type] = ParticleType_Create(); - } - var pt = g_ParticleType[type]; - ParticleType_Life(pt, lifeMin, lifeMax); -} - -function action_parttype_speed(_type, _speedMin, _speedMax, _dirMin, _dirMax, _speedIncr) -{ - var type = Round(_type); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleType[type] < 0 ) { - g_ParticleType[type] = ParticleType_Create(); - } - var pt = g_ParticleType[type]; - ParticleType_Speed(pt, _speedMin, _speedMax, -_speedIncr, 0); - ParticleType_Direction(pt, _dirMin, _dirMax, 0, 0); -} - -function action_parttype_gravity(_type, _gravStrength, _gravDir) -{ - var type = Round(_type); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleType[type] < 0 ) { - g_ParticleType[type] = ParticleType_Create(); - } - var pt = g_ParticleType[type]; - ParticleType_Gravity(pt, _gravStrength, _gravDir); -} - -function action_parttype_secondary(_type, _stepType, _stepNumber, _deathType, _deathNumber) -{ - var type = Round(_type); - var stepNumber = Round(_stepNumber); - var stepType = Round(_stepType); - var deathNumber = Round(_deathNumber); - var deathType = Round(_deathType); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleType[type] < 0 ) { - g_ParticleType[type] = ParticleType_Create(); - } - var pt = g_ParticleType[type]; - - ParticleType_Step(pt, stepNumber, g_ParticleType[stepType]); - ParticleType_Death(pt, deathNumber, g_ParticleType[deathType]); -} - -function action_partemit_create(_emit, _shape, _xmin, _xmax, _ymin, _ymax) -{ - var emit = Round(_emit); - var shape = Round(_shape); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleEmit[emit] < 0 ) { - g_ParticleEmit[emit] = ParticleSystem_Emitter_Create(g_ParticleSystem); - } - var pe = g_ParticleEmit[emit]; - ParticleSystem_Emitter_Region(g_ParticleSystem, pe, _xmin, _xmax, _ymin, _ymax, shape, PART_EDISTR_LINEAR); -} - -function action_partemit_destroy(_emit) -{ - var emit = Round(_emit); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleEmit[emit] < 0 ) { - return; - } - var pe = g_ParticleEmit[emit]; - ParticleSystem_Emitter_Destroy(g_ParticleSystem, pe); -} - -function action_partemit_burst(_emit, _type, _number) -{ - var emit = Round(_emit); - var type = Round(_type); - var number = Round(_number); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleEmit[emit] < 0 ) - { - debug(error_a0014); - return; - } - var pe = g_ParticleEmit[emit]; - ParticleSystem_Emitter_Burst(g_ParticleSystem, pe, g_ParticleType[type], number); -} - -function action_partemit_stream(_emit, _type, _number) -{ - var emit = Round(_emit); - var type = Round(_type); - var number = Round(_number); - - if (g_ParticleSystem < 0) { - g_ParticleSystem = ParticleSystem_Create(); - } - if (g_ParticleEmit[emit] < 0 ) - { - debug(error_a0014); - return; - } - var pe = g_ParticleEmit[emit]; - ParticleSystem_Emitter_Stream(g_ParticleSystem, pe, g_ParticleType[type], number); -} - -function action_draw_gradient_hor(_inst, _x, _y, _x2, _y2, _col1, _col2) -{ - if (Argument_Relative) - { - draw_rectangle_gradient(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, _col1, _col2, false, false); - } - else - { - draw_rectangle_gradient(_x, _y, _x2, _y2, _col1, _col2, false, false); - } -} - -function action_draw_gradient_vert(_inst, _x, _y, _x2, _y2, _col1, _col2) -{ - if (Argument_Relative) - { - draw_rectangle_gradient(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, _col1, _col2, true, false); - } - else - { - draw_rectangle_gradient(_x, _y, _x2, _y2, _col1, _col2, true, false); - } -} - -function action_draw_arrow(_inst, _x, _y, _x2, _y2, _size) -{ - if (Argument_Relative) - { - draw_arrow(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, _size); - } - else - { - draw_arrow(_x, _y, _x2, _y2, _size); - } -} - -function action_if_empty(_inst, _arg0, _arg1, _arg2) -{ - var val1 = _arg0; - var val2 = _arg1; - - if (Argument_Relative) - { - val1 += _inst.x; - val2 += _inst.y; - } - if (Round(_arg2) == 0) - { - return place_free(_inst, val1, val2) ? 1 : 0; - } - - return place_empty(_inst, val1, val2) ? 1 : 0; -} - -function action_if_collision(_inst, _arg0, _arg1, _arg2) -{ - var val1 = _arg0; - var val2 = _arg1; - if (Argument_Relative ) - { - val1 += _inst.x; - val2 += _inst.y; - } - - if (Round(_arg2) == 0) - { - return !place_free(_inst, val1, val2) ? 1 : 0; - } - return !place_empty(_inst, val1, val2) ? 1 : 0; -} - -function action_if(_arg0) -{ - return _arg0; -} - -function action_if_number(_arg0, _arg1, _arg2) -{ - var n = instance_number(Round(_arg0)); - - var result; - if (Round(_arg2) == 1) - { - result = (n < _arg1) ? 1 : 0; - } - else if (Round(_arg2) == 2) - { - result = (n > _arg1) ? 1 : 0; - } - else - { - result = (n == _arg1) ? 1 : 0; - } - - return result; -} - -function action_if_object(_inst, _obj, _x, _y) -{ - if (Argument_Relative) - { - return place_meeting(_inst, _x + _inst.x, _y + _inst.y, Round(_obj)) ? 1 : 0; - } - return place_meeting(_inst, _x, _y, Round(_obj)) ? 1 : 0; -} - -function action_if_mouse(_arg0) -{ - var result; - switch (Round(_arg0)) - { - case 1: result = (g_pIOManager.Button_Down(1) || g_pIOManager.Button_Released(1)) ? 1 : 0; break; - case 2: result = (g_pIOManager.Button_Down(2) || g_pIOManager.Button_Released(2)) ? 1 : 0; break; - case 3: result = (g_pIOManager.Button_Down(3) || g_pIOManager.Button_Released(3)) ? 1 : 0; break; - default:result = (g_pIOManager.Button_Current_Get() == 0) ? 1 : 0; - } - - return result; -} - -function action_if_aligned(_inst, _x, _y) -{ - if (_x > 0) - { - if (Math.abs(_inst.x - _x * Round(_inst.x / _x)) >= 0.001 ) { - return 0; - } - } - - if (_y > 0) - { - if (Math.abs(_inst.y - _y * Round(_inst.y / _y)) >= 0.001 ) { - return 0; - } - } - - return 1; -} - -function action_path(_inst, _path, _speed, _atend, _relative) -{ - _inst.Assign_Path(Round(_path), _speed, 1, 0, (_relative >= 0.5) ? true : false, Round(_atend)); -} - -function action_path_end(_inst) -{ - _inst.Assign_Path(-1, 0, 1, 0, false, 0); -} - -function action_path_position(_inst, _pos) -{ - if (Argument_Relative) - { - _inst.path_position += _pos; - } - else - { - _inst.path_position = _pos; - } -} - -function action_path_speed(_inst, _speed) -{ - if (Argument_Relative) - { - _inst.path_speed = _inst.path_speed + _speed; - } - else - { - _inst.path_speed = _speed; - } -} - -function action_linear_step(_inst, _x, _y, _stepsize, _checkall) -{ - if (Argument_Relative) - { - mp_linear_step(_inst, _x + _inst.x, _y + _inst.y, _stepsize, (_checkall >= 0.5) ? true : false); - } - else - { - mp_linear_step(_inst, _x, _y, _stepsize, (_checkall >= 0.5) ? true : false); - } -} - -function action_potential_step(_inst, _x, _y, _stepsize, _checkall) -{ - if (Argument_Relative) - { - mp_potential_step(_inst, _x + _inst.x, _y + _inst.y, _stepsize, (_checkall >= 0.5) ? true : false); - } - else - { - mp_potential_step(_inst, _x, _y, _stepsize, (_checkall >= 0.5) ? true : false); - } -} - -// ############################################################################################# -/// Function: -/// -/// -/// -/// In: -/// Out: -/// -/// -// ############################################################################################# -function action_inherited(_inst, _other) { - - if (!_inst) return; - event_inherited(_inst, _other); - - /*if (!object_exists(_inst)) { - return; - } - var parent = _inst.pObject.pParent; - if( _inst.pObject.pParent!=null ) - { - if (!object_exists(parent)) { - return; - } - parent.PerformEvent(Current_Event_Type, Current_Event_Number, _inst, _inst); - }*/ -} - -function action_change_object(_inst, _newobj, _perform_events) -{ - instance_change(_inst, _newobj | 0, (_perform_events >= 0.5) ? true : false); -} - -function action_kill_position(_inst, _x, _y) -{ - if (Argument_Relative) - { - position_destroy(_inst, _x + _inst.x, _y + _inst.y); - } - else - { - position_destroy(_inst, _x, _y); - } -} - -function action_end_sound(_snd) { - - if (g_AudioModel == Audio_WebAudio) { - var snd = Round(_snd); - - audio_stop_sound(snd); - - } - else { - var snd = g_pSoundManager.Get(Round(_snd)); - if ((snd != null) && (snd != undefined)) { - g_pSoundManager.Stop(_snd); - } - else { - debug(error_a0003); - } - } -} - -function action_if_sound(_snd) { - if (g_AudioModel == Audio_WebAudio) { - var snd = Round(_snd); - - return audio_is_playing(snd); - - } - else { - var snd = g_pSoundManager.Get(Round(_snd)); - if ((snd != null) && (snd != undefined)) { - return (g_pSoundManager.SoundIsPlaying(_snd) ? 1 : 0); - } - return 0; - } -} - -function action_effect(_inst, _kind, _x, _y, _size, _col, _below) -{ - var ps = (_below < 0.5) ? ps_above : ps_false; - - if (Argument_Relative) - { - Effect_Create(ps, Round(_kind), _x + _inst.x, _y + _inst.y, Round(_size), Round(_col)); - } - else - { - Effect_Create(ps, Round(_kind), _x, _y, Round(_size), Round(_col)); - } -} - -function action_message(_message) -{ - alert(_message); -} - -function action_sprite_transform(_inst, _sx, _sy, _angle, _dir) -{ - _inst.image_xscale = _sx; - _inst.image_yscale = _sy; - _inst.image_angle = _angle; - if ((_dir == 1) || (_dir == 3)) { - _inst.image_xscale = -_inst.image_xscale; - } - if ((_dir == 2) || (_dir == 3)) { - _inst.image_yscale = -_inst.image_yscale; - } -} - -function action_sleep(_sleepTime, _refresh) -{ - if (_refresh >= 0.5 ) - { - g_RunRoom.Draw(); - } - - Timing_Wait(_sleepTime); -} - -function action_snapshot(_fname) -{ - surface_save(0, _fname); -} - -function action_replace_sprite(_spr, _fname, _imgNum) -{ - if (!sprite_exists(Round(_spr))) - { - debug(error_a0008); - return; - } - - if (!file_exists(_fname)) - { - debug(error_a0009); - return; - } - - var spr = g_pSpriteManager.Get(Round(_spr)); - sprite_replace(Round(_spr), _fname, Round(_imgNum), spr.colcheck, spr.transparent, spr.smooth, spr.preload, spr.xOrigin, spr.yOrigin); -} - -function action_replace_sound(_snd, _fname) -{ - if (!sound_exists(Round(_snd))) - { - debug(error_a0008); - return; - } - if ( true != file_exists(_fname)) - { - debug(error_a0009); - return; - } - - var snd = g_pSoundManager.Get(Round(_snd)); - sound_replace(Round(_snd), _fname, snd.kind, snd.preload); -} - -function action_replace_background(_bg, _fname) -{ - if (!background_exists(Round(_bg)) ) - { - debug(error_a0008); - return; - } - if (!file_exists(_fname)) //Fritz: was FileExists() which doesn't - { - debug(error_a0009); - return; - } - var back = g_pBackgroundManager.Get(Round(_bg)); - background_replace(Round(_bg), _fname, back.transparent, back.smooth, back.preload); -} - -function action_set_timeline(_inst, _index, _pos) -{ - action_timeline_set(_inst, _index, _pos, 0, 0); -} - -function action_timeline_set(_inst, _index, _pos, _paused, _loop) -{ - _inst.timeline_index = _index; - _inst.timeline_position = _pos; - _inst.timeline_paused = _paused; - _inst.timeline_looped = _loop; -} - -function action_set_timeline_position(_inst, _pos) -{ - if (Argument_Relative) - { - _inst.timeline_position += _pos; - } - else - { - _inst.timeline_position = _pos; - } -} - -function action_set_timeline_speed(_inst, _speed) -{ - if (Argument_Relative) - { - _inst.timeline_speed += _speed; - } - else - { - _inst.timeline_speed = _speed; - } -} - -function action_timeline_start(_inst) -{ - _inst.timeline_paused = false; -} - -function action_timeline_stop(_inst) -{ - _inst.timeline_paused = true; - _inst.timeline_position = 0; -} - -function action_timeline_pause(_inst) -{ - _inst.timeline_paused = true; -} - -function action_draw_ellipse(_inst, _x, _y, _x2, _y2, _outline) -{ - if (Argument_Relative) - { - draw_ellipse(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, (_outline >= 0.5) ? true : false); - } - else - { - draw_ellipse(_x, _y, _x2, _y2, (_outline >= 0.5) ? true : false); - } -} - -function action_draw_ellipse_gradient(_inst, _x, _y, _x2, _y2, _col1, _col2) { - - if (Argument_Relative) - { - draw_ellipse_gradient(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, _col1, _col2, false); - } - else - { - draw_ellipse_gradient(_x, _y, _x2, _y2, _col1, _col2, false); - } -} - -function action_splash_web(_url) -{ - YoYo_OpenURL(_url); -} - -function action_webpage(_url) -{ - YoYo_OpenURL(_url); -} - -function action_highscore_show(_background, _border, _col1, _col2, _fontname, _fontsize, _fontstyle) -{ - var x, y; - x = (g_pBuiltIn.room_width / 2) - 100; - y = (g_pBuiltIn.room_height / 2) - 100; - draw_highscore(x, y, x + 200, y + 200); -} - -// ############################################################################################# -/// Function: -/// Action to clear hiscores. -/// -// ############################################################################################# -function action_highscore_clear() -{ - highscore_clear(); - highscore_save(); -} - - -// ############################################################################################# -/// Function: -/// Action to toggle/clear/set fullscreen mode -/// -/// -/// In: 0,1 or 2 -/// Out: -/// -/// -// ############################################################################################# -function action_fullscreen(_mode) { -/* - var full; - - // toggle? - if (_mode == 0) - { - if (window_get_fullscreen()) - { - full = false; - } else - { - full = false; - } - } else if (_mode == 1) - { - full = false; // into windowed - } else if (_mode == 2) - { - full = true; // into fullscreen - } else - return; - - - window_set_fullscreen(full); -*/ -} - - From 96d47986f2ddedd2f1ec5962ff087fcb984648d6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 11:15:32 +0300 Subject: [PATCH 03/84] Removed IAP function stubs (long-gone) --- scripts/functions/Function_IAP.js | 96 ------------------------------- 1 file changed, 96 deletions(-) diff --git a/scripts/functions/Function_IAP.js b/scripts/functions/Function_IAP.js index 4268ffac..2200ebc2 100644 --- a/scripts/functions/Function_IAP.js +++ b/scripts/functions/Function_IAP.js @@ -10,99 +10,3 @@ // // ********************************************************************************************************************** -// ############################################################################################# - - -// ############################################################################################# -// Deprecated functions -function iap_store_status() { return iap_status(); } -function iap_event_queue() { ErrorFunction("iap_event_queue()"); } -function iap_product_status() { ErrorFunction("iap_product_status()"); } -//function iap_is_purchased() { ErrorFunction("iap_is_purchased()"); } -function iap_is_downloaded() { ErrorFunction("iap_is_downloaded()"); } -function iap_product_files() { ErrorFunction("iap_product_files()"); } -function iap_files_purchased() { ErrorFunction("iap_files_purchased()"); } - - - -// ############################################################################################# -/// Function: -/// Enable in app purchase -/// -// ############################################################################################# -function iap_activate(_val) { - -} - -// ############################################################################################# -/// Function: -/// Return the current status of the store -/// -// ############################################################################################# -function iap_status() { - return -1; -} - -// ############################################################################################# -/// Function: -/// Acquire a product -/// -// ############################################################################################# -function iap_acquire(_product, _payload) { - - - return -1; -} - -// ############################################################################################# -/// Function: -/// Consume an acquired product -/// -// ############################################################################################# -function iap_consume(_product) { - - -} - - -// ############################################################################################# -/// Function: -/// Check to see if the product has been purchased as far as we're concerned -/// -// ############################################################################################# -function iap_restore_all() { - - -} - -// ############################################################################################# -/// Function: -/// Return the full set of iap products known about -/// -// ############################################################################################# -function iap_enumerate_products(_list) { - - -} - -// ############################################################################################# -/// Function: -/// Fill out the provided ds_map with the product information -/// -// ############################################################################################# -function iap_product_details(_product, _map) { - - return 0; //return 0 if product was not found, to be consistent with native -} - -// ############################################################################################# -/// Function: -/// Fill out the provided ds_map with the purchase information -/// -// ############################################################################################# -function iap_purchase_details(_purchase, _map) { - - return 0; //return 0 if purchase was not found, to be consistent with native -} - - From 8e64627a0d1110623576adcfa258c7eb1215253f Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 11:17:09 +0300 Subject: [PATCH 04/84] Removed Steamworks function stubs (as that's an extension now) --- scripts/Unsupported.js | 94 ------------------------------------------ 1 file changed, 94 deletions(-) diff --git a/scripts/Unsupported.js b/scripts/Unsupported.js index 85648484..bceebaaf 100644 --- a/scripts/Unsupported.js +++ b/scripts/Unsupported.js @@ -193,100 +193,6 @@ function texture_set_interpolation_ext(stage, linear) { ErrorFunction("textur function texture_get_uvs(_tex) { ErrorFunction("texture_get_uvs()"); } function texture_global_scale(pow2integer) { ErrorFunction("texture_global_scale()"); } - -//steam functions -function steam_activate_overlay() { ErrorFunction("steam_activate_overlay()"); return -1; } -function steam_is_overlay_enabled() { ErrorFunction("steam_is_overlay_enabled()"); return -1; } -function steam_is_overlay_activated() { ErrorFunction("steam_is_overlay_activated()"); return -1; } -function steam_get_persona_name() { ErrorFunction("steam_get_persona_name()"); return "";} -function steam_initialised() { ErrorFunction("steam_initialised()"); return -1; } -function steam_is_cloud_enabled_for_app() { ErrorFunction("steam_is_cloud_enabled_for_app()"); return -1; } -function steam_is_cloud_enabled_for_account() { ErrorFunction("steam_is_cloud_enabled_for_account()"); return -1; } -function steam_file_persisted() { ErrorFunction("steam_file_persisted()"); return -1; } -function steam_get_quota_total() { ErrorFunction("steam_get_quota_total()"); return -1;} -function steam_get_quota_free() { ErrorFunction("steam_get_quota_free()"); return -1;} -function steam_file_write() { ErrorFunction("steam_file_write()"); return -1;} -function steam_file_write_file() { ErrorFunction("steam_file_write_file()"); return -1;} -function steam_file_read() { ErrorFunction("steam_file_read()"); return "";} -function steam_file_delete() { ErrorFunction("steam_file_delete()"); return -1;} -function steam_file_exists() { ErrorFunction("steam_file_exists()"); return -1; } -function steam_file_size() { ErrorFunction("steam_file_size()"); return -1; } -function steam_file_share() { ErrorFunction("steam_file_share()"); return -1; } -function steam_publish_workshop_file() { ErrorFunction("steam_publish_workshop_file()"); return -1; } -function steam_is_screenshot_requested() { ErrorFunction("steam_is_screenshot_requested()"); return -1; } -function steam_send_screenshot() { ErrorFunction("steam_send_screenshot()"); return -1; } -function steam_is_user_logged_on() { ErrorFunction("steam_is_user_logged_on()"); return -1; } -function steam_get_user_steam_id() { ErrorFunction("steam_get_user_steam_id()"); return -1; } -function steam_user_owns_dlc() { ErrorFunction("steam_user_owns_dlc()"); return -1; } -function steam_user_installed_dlc() { ErrorFunction("steam_user_installed_dlc()"); return -1; } -function steam_set_achievement() { ErrorFunction("steam_set_achievement()"); return -1; } -function steam_get_achievement() { ErrorFunction("steam_get_achievement()"); return -1; } -function steam_clear_achievement() { ErrorFunction("steam_clear_achievement()"); return -1; } -function steam_set_stat_int() { ErrorFunction("steam_set_stat_int()"); return -1; } -function steam_set_stat_float() { ErrorFunction("steam_set_stat_float()"); return -1; } -function steam_set_stat_avg_rate() { ErrorFunction("steam_set_stat_avg_rate()"); return -1; } -function steam_get_stat_int() { ErrorFunction("steam_get_stat_int()"); return -1; } -function steam_get_stat_float() { ErrorFunction("steam_get_stat_float()"); return -1; } -function steam_get_stat_avg_rate() { ErrorFunction("steam_get_stat_avg_rate()"); return -1; } -function steam_reset_all_stats() { ErrorFunction("steam_reset_all_stats()"); return -1; } -function steam_reset_all_stats_achievements() { ErrorFunction("steam_reset_all_stats_achievements()"); return -1; } -function steam_stats_ready() { ErrorFunction("steam_stats_ready()"); return -1; } -function steam_create_leaderboard() { ErrorFunction("steam_create_leaderboard()"); return -1; } -function steam_upload_score() { ErrorFunction("steam_upload_score()"); return -1; } -function steam_upload_score_ext() { ErrorFunction("steam_upload_score_ext()"); return -1; } -function steam_download_scores_around_user() { ErrorFunction("steam_download_scores_around_user()"); return -1; } -function steam_download_scores() { ErrorFunction("steam_download_scores()"); return -1; } -function steam_download_friends_scores() { ErrorFunction("steam_download_friends_scores()"); return -1; } -function steam_upload_score_buffer() { ErrorFunction("steam_upload_score_buffer()"); return -1; } -function steam_upload_score_buffer_ext() { ErrorFunction("steam_upload_score_buffer_ext()"); return -1; } -function steam_activate_overlay_browser() { ErrorFunction("steam_activate_overlay_browser()"); return -1; } -function steam_activate_overlay_user() { ErrorFunction("steam_activate_overlay_user()"); return -1; } -function steam_activate_overlay_store() { ErrorFunction("steam_activate_overlay_store()"); return -1; } -function steam_get_user_persona_name() { ErrorFunction("steam_get_user_persona_name()"); return -1; } - - -//steam ugc functions -function steam_get_app_id() { ErrorFunction("steam_get_app_id()"); return -1; } -function steam_get_user_account_id() { ErrorFunction("steam_get_user_account_id()"); return -1; } -function steam_ugc_download() { ErrorFunction("steam_ugc_download()"); return -1; } -function steam_ugc_create_item() { ErrorFunction("steam_ugc_create_item()"); return -1; } -function steam_ugc_start_item_update() { ErrorFunction("steam_ugc_start_item_update()"); return -1; } -function steam_ugc_set_item_title() { ErrorFunction("steam_ugc_set_item_title()"); return -1; } -function steam_ugc_set_item_description() { ErrorFunction("steam_ugc_set_item_description()"); return -1; } -function steam_ugc_set_item_visibility() { ErrorFunction("steam_ugc_set_item_visibility()"); return -1; } -function steam_ugc_set_item_tags() { ErrorFunction("steam_ugc_set_item_tags()"); return -1; } -function steam_ugc_set_item_content() { ErrorFunction("steam_ugc_set_item_content()"); return -1; } -function steam_ugc_set_item_preview() { ErrorFunction("steam_ugc_set_item_preview()"); return -1; } -function steam_ugc_submit_item_update() { ErrorFunction("steam_ugc_submit_item_update()"); return -1; } -function steam_ugc_get_item_update_progress() { ErrorFunction("steam_ugc_get_item_update_progress()"); return -1; } -function steam_ugc_subscribe_item() { ErrorFunction("steam_ugc_subscribe_item()"); return -1; } -function steam_ugc_unsubscribe_item() { ErrorFunction("steam_ugc_unsubscribe_item()"); return -1; } -function steam_ugc_num_subscribed_items() { ErrorFunction("steam_ugc_num_subscribed_items()"); return -1; } -function steam_ugc_get_subscribed_items() { ErrorFunction("steam_ugc_get_subscribed_items()"); return -1; } -function steam_ugc_get_item_install_info() { ErrorFunction("steam_ugc_get_item_install_info()"); return -1; } -function steam_ugc_get_item_update_info() { ErrorFunction("steam_ugc_get_item_update_info()"); return -1; } -function steam_ugc_request_item_details() { ErrorFunction("steam_ugc_request_item_details()"); return -1; } -function steam_ugc_create_query_user() { ErrorFunction("steam_ugc_create_query_user()"); return -1; } -function steam_ugc_create_query_user_ex() { ErrorFunction("steam_ugc_create_query_user_ex()"); return -1; } -function steam_ugc_create_query_all() { ErrorFunction("steam_ugc_create_query_all()"); return -1; } -function steam_ugc_create_query_all_ex() { ErrorFunction("steam_ugc_create_query_all_ex()"); return -1; } -function steam_ugc_query_set_cloud_filename_filter() { ErrorFunction("steam_ugc_query_set_cloud_filename_filter()"); return -1; } -function steam_ugc_query_set_match_any_tag() { ErrorFunction("steam_ugc_query_set_match_any_tag()"); return -1; } -function steam_ugc_query_set_search_text() { ErrorFunction("steam_ugc_query_set_search_text()"); return -1; } -function steam_ugc_query_set_ranked_by_trend_days() { ErrorFunction("steam_ugc_query_set_ranked_by_trend_days()"); return -1; } -function steam_ugc_query_add_required_tag() { ErrorFunction("steam_ugc_query_add_required_tag()"); return -1; } -function steam_ugc_query_add_excluded_tag() { ErrorFunction("steam_ugc_query_add_excluded_tag()"); return -1; } -function steam_ugc_query_set_return_long_description() { ErrorFunction("steam_ugc_query_set_return_long_description()"); return -1; } -function steam_ugc_query_set_return_total_only() { ErrorFunction("steam_ugc_query_set_return_total_only()"); return -1; } -function steam_ugc_query_set_allow_cached_response() { ErrorFunction("steam_ugc_query_set_allow_cached_response()"); return -1; } -function steam_ugc_send_query(ugc_query_handle) { ErrorFunction("steam_ugc_send_query( ugc_query_handle )"); return -1; } -function steam_current_game_language() { ErrorFunction("steam_current_game_language()"); return -1; } -function steam_available_languages() { ErrorFunction("steam_available_languages()"); return -1; } - - - - - function draw_set_alpha_test() { ErrorFunction("draw_set_alpha_test()"); } function draw_set_alpha_test_ref_value() { ErrorFunction("draw_set_alpha_test_ref_value()"); } function draw_get_alpha_test() { ErrorFunction("draw_get_alpha_test()"); return 0; } From d323879f8f8d5d90693cc1ed6da91dea4fa20fe2 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 11:50:15 +0300 Subject: [PATCH 05/84] Removed some more GM8 function stubs --- scripts/Unsupported.js | 53 ------------------------------------------ 1 file changed, 53 deletions(-) diff --git a/scripts/Unsupported.js b/scripts/Unsupported.js index bceebaaf..e21c379c 100644 --- a/scripts/Unsupported.js +++ b/scripts/Unsupported.js @@ -115,66 +115,13 @@ function keyboard_set_numlock(on) {ErrorFunction("keyboard_set // Sprites. Backgrounds -function background_save(ind,fname) {ErrorFunction("background_save()");} function sprite_save_strip(ind,fname) {ErrorFunction("sprite_save_strip()");} - -// Objects -function object_add() {ErrorFunction("object_add()");} -function object_delete(ind) {ErrorFunction("object_delete()");} -function object_event_add(ind,evtype,evnumb,codestr) {ErrorFunction("object_event_add()");} -function object_event_clear(ind,evtype,evnumb) {ErrorFunction("object_event_clear()");} - - -// Particles -function part_changer_create(_ps) { ErrorFunction("part_changer_create()"); } -function part_changer_destroy(_ps,_ind) { ErrorFunction("part_changer_destroy()"); } -function part_changer_destroy_all(_ps) { ErrorFunction("part_changer_destroy_all()"); } -function part_changer_exists(_ps,_ind) { ErrorFunction("part_changer_exists()"); } -function part_changer_clear(_ps,_ind) { ErrorFunction("part_changer_clear()"); } -function part_changer_region(_ps,_ind,_xmin,_xmax,_ymin,_ymax,_shape) { ErrorFunction("part_changer_region()"); } -function part_changer_types(_ps,_ind,_parttype1,_parttype2) { ErrorFunction("part_changer_types()"); } -function part_changer_kind(_ps,_ind,_kind) { ErrorFunction("part_changer_kind()"); } - -function part_deflector_create(ps) { ErrorFunction("part_deflector_create()"); } -function part_deflector_destroy(ps,ind) { ErrorFunction("part_deflector_destroy()"); } -function part_deflector_destroy_all(ps) { ErrorFunction("part_deflector_destroy_all()"); } -function part_deflector_exists(ps,ind) { ErrorFunction("part_deflector_exists()"); } -function part_deflector_clear(ps,ind) { ErrorFunction("part_deflector_clear()"); } -function part_deflector_region(ps,ind,xmin,xmax,ymin,ymax) { ErrorFunction("part_deflector_region()"); } -function part_deflector_kind(ps,ind,kind) { ErrorFunction("part_deflector_kind()"); } -function part_deflector_friction(ps,ind,friction) { ErrorFunction("part_deflector_friction()"); } - -function part_destroyer_create(ps) { ErrorFunction("part_destroyer_create()"); } -function part_destroyer_destroy(ps,ind) { ErrorFunction("part_destroyer_destroy()"); } -function part_destroyer_destroy_all(ps) { ErrorFunction("part_destroyer_destroy_all()"); } -function part_destroyer_exists(ps,ind) { ErrorFunction("part_destroyer_exists()"); } -function part_destroyer_clear(ps,ind) { ErrorFunction("part_destroyer_clear()"); } -function part_destroyer_region(ps,ind,xmin,xmax,ymin,ymax,shape) { ErrorFunction("part_destroyer_region()"); } - -function part_attractor_create(ps) { ErrorFunction("part_attractor_create()"); } -function part_attractor_destroy(ps,ind) { ErrorFunction("part_attractor_destroy()"); } -function part_attractor_destroy_all(ps) { ErrorFunction("part_attractor_destroy_all()"); } -function part_attractor_exists(ps,ind) { ErrorFunction("part_attractor_exists()"); } -function part_attractor_clear(ps,ind) { ErrorFunction("part_attractor_clear()"); } -function part_attractor_position(ps,ind,x,y) { ErrorFunction("part_attractor_position()"); } -function part_attractor_force(ps,ind,force,dist,kind,aditive) { ErrorFunction("part_attractor_force()"); } - - - -// executing programs -function execute_program(prog,arg,wait) { ErrorFunction("execute_program()"); } -function execute_shell(prog,arg) { ErrorFunction("execute_shell()"); } -var secure_mode = true; - // Message boxes/dialogs etc. function get_open_filename(filter, fname) { ErrorFunction("get_open_filename()"); } function get_save_filename(filter, fname) { ErrorFunction("get_save_filename()"); } function get_open_filename_ext(filter, fname, dir, title) { ErrorFunction("get_open_filename_ext()"); } function get_save_filename_ext(filter, fname, dir, title) { ErrorFunction("get_save_filename_ext()"); } -function get_directory(dname) { ErrorFunction("get_directory()"); } -function get_directory_alt(capt, root) { ErrorFunction("get_directory_alt()"); } -//function show_error(str, abort) { ErrorFunction("show_error()"); } // sound From 4c59dbcac97be9cce3099be9f42354e38f645ff6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 13:54:55 +0300 Subject: [PATCH 06/84] 2d function stubs (that cannot be currently auto-removed by "remove unused functions") now use GetMissingFunction. --- scripts/Builders/yyPrimBuilder.js | 50 +++++++++++++-------------- scripts/functions/Function_Debug.js | 8 +++++ scripts/functions/Function_Shaders.js | 34 +++++++++--------- scripts/yyBufferVertex.js | 50 +++++++++++++-------------- scripts/yyVertexManager.js | 22 ++++++------ 5 files changed, 86 insertions(+), 78 deletions(-) diff --git a/scripts/Builders/yyPrimBuilder.js b/scripts/Builders/yyPrimBuilder.js index 7443c494..5d52ac39 100644 --- a/scripts/Builders/yyPrimBuilder.js +++ b/scripts/Builders/yyPrimBuilder.js @@ -10,31 +10,31 @@ // // ********************************************************************************************************************* -function draw_primitive_begin(kind) { ErrorFunction("draw_primitive_begin()"); } -function draw_primitive_begin_texture(kind, texid) { ErrorFunction("draw_primitive_begin_texture()"); } -function draw_vertex(x,y) { ErrorFunction("draw_vertex()"); } -function draw_vertex_color(x,y,col,alpha) { ErrorFunction("draw_vertex_color()"); } -var draw_vertex_colour = draw_vertex_color; -function draw_vertex_texture(x,y,xtex,ytex) { ErrorFunction("draw_vertex_texture()"); } -function draw_vertex_texture_color(x,y,xtex,ytex,col,alpha) { ErrorFunction("draw_vertex_texture_color()"); } -var draw_vertex_texture_colour = draw_vertex_texture_color; -function draw_primitive_end() { ErrorFunction("draw_primitive_end()"); } - -function d3d_primitive_begin(kind) { ErrorFunction("d3d_primitive_begin()"); } -function d3d_primitive_begin_texture(kind,texid) { ErrorFunction("d3d_primitive_begin_texture()"); } -function d3d_vertex(x,y,z) { ErrorFunction("d3d_vertex()"); } -function d3d_vertex_color(x,y,z,col,alpha) { ErrorFunction("d3d_vertex_color()"); } -var d3d_vertex_colour = d3d_vertex_color; -function d3d_vertex_texture(x,y,z,xtex,ytex) { ErrorFunction("d3d_vertex_texture()"); } -function d3d_vertex_texture_color(x,y,z,xtex,ytex,col,alpha) { ErrorFunction("d3d_vertex_texture_color()"); } -var d3d_vertex_texture_colour = d3d_vertex_texture_color; -function d3d_vertex_normal(x,y,z,nx,ny,nz) { ErrorFunction("d3d_vertex_normal()"); } -function d3d_vertex_normal_color(x,y,z,nx,ny,nz,col,alpha) { ErrorFunction("d3d_vertex_normal_color()"); } -var d3d_vertex_normal_colour = d3d_vertex_normal_color; -function d3d_vertex_normal_texture(x,y,z,nx,ny,nz,xtex,ytex) { ErrorFunction("d3d_vertex_normal_texture()"); } -function d3d_vertex_normal_texture_color(x,y,z,nx,ny,nz,xtex,ytex,col,alpha){ ErrorFunction("d3d_vertex_normal_texture_color()"); } -var d3d_vertex_normal_texture_colour = d3d_vertex_normal_texture_color; -function d3d_primitive_end() { ErrorFunction("d3d_primitive_end()"); } +var draw_primitive_begin = GetErrorFunction("draw_primitive_begin"), + draw_primitive_begin_texture = GetErrorFunction("draw_primitive_begin_texture"), + draw_vertex = GetErrorFunction("draw_vertex"), + draw_vertex_color = GetErrorFunction("draw_vertex_color"), + draw_vertex_colour = draw_vertex_color, + draw_vertex_texture = GetErrorFunction("draw_vertex_texture"), + draw_vertex_texture_color = GetErrorFunction("draw_vertex_texture_color"), + draw_vertex_texture_colour = draw_vertex_texture_color, + draw_primitive_end = GetErrorFunction("draw_primitive_end"); + +var d3d_primitive_begin = GetErrorFunction("d3d_primitive_begin"), + d3d_primitive_begin_texture = GetErrorFunction("d3d_primitive_begin_texture"), + d3d_vertex = GetErrorFunction("d3d_vertex"), + d3d_vertex_color = GetErrorFunction("d3d_vertex_color"), + d3d_vertex_colour = d3d_vertex_color, + d3d_vertex_texture = GetErrorFunction("d3d_vertex_texture"), + d3d_vertex_texture_color = GetErrorFunction("d3d_vertex_texture_color"), + d3d_vertex_texture_colour = d3d_vertex_texture_color, + d3d_vertex_normal = GetErrorFunction("d3d_vertex_normal"), + d3d_vertex_normal_color = GetErrorFunction("d3d_vertex_normal_color"), + d3d_vertex_normal_colour = d3d_vertex_normal_color, + d3d_vertex_normal_texture = GetErrorFunction("d3d_vertex_normal_texture"), + d3d_vertex_normal_texture_color = GetErrorFunction("d3d_vertex_normal_texture_color"), + d3d_vertex_normal_texture_colour = d3d_vertex_normal_texture_color, + d3d_primitive_end = GetErrorFunction("d3d_primitive_end"); // ---------------------------------------------------------------------------------------------------------------------------------------- var g_PrimBuffer = null; // raw ArrayBuffer data diff --git a/scripts/functions/Function_Debug.js b/scripts/functions/Function_Debug.js index 72264bfc..e6fac9d7 100644 --- a/scripts/functions/Function_Debug.js +++ b/scripts/functions/Function_Debug.js @@ -185,6 +185,14 @@ function ErrorFunction(_text) debug( txt ); } } +function GetErrorFunction(name, returnValue) +{ + return function() + { + ErrorFunction(name); + return returnValue; + } +} // ############################################################################################# diff --git a/scripts/functions/Function_Shaders.js b/scripts/functions/Function_Shaders.js index 39877f3a..64182664 100644 --- a/scripts/functions/Function_Shaders.js +++ b/scripts/functions/Function_Shaders.js @@ -11,23 +11,23 @@ // ********************************************************************************************************************** // WebGL.js redefines these to useful functions -var fn_texture_get_texel_width = function() { ErrorFunction("yy_texture_get_texel_width()"); }; -var fn_texture_get_texel_height = function() { ErrorFunction("yy_texture_get_texel_height()"); }; -var fn_texture_set_stage = function() { ErrorFunction("texture_set_stage()"); }; - -var fn_shader_is_compiled = function() { ErrorFunction("shader_is_compiled()"); }; -var fn_shader_set = function() { ErrorFunction("shader_set()"); }; -var fn_shader_get_uniform = function() { ErrorFunction("shader_get_uniform()"); }; -var fn_shader_set_uniform_i = function() { ErrorFunction("shader_set_uniform_i()"); }; -var fn_shader_set_uniform_f = function() { ErrorFunction("shader_set_uniform_f()"); }; -var fn_shader_set_uniform_matrix = function() { ErrorFunction("shader_set_uniform_matrix()"); }; -var fn_shader_get_sampler_index = function() { ErrorFunction("shader_set_uniform_matrix()"); }; -var fn_shader_enable_corner_id = function() { ErrorFunction("shader_enable_corner_id()"); }; -var fn_shader_set_uniform_i_array = function() { ErrorFunction("shader_set_uniform_array_i()"); }; -var fn_shader_set_uniform_f_array = function() { ErrorFunction("shader_set_uniform_array_f()"); }; -var fn_shader_set_uniform_f_buffer = function() { ErrorFunction("shader_set_uniform_buffer_f()"); }; -var fn_shader_set_uniform_matrix_array = function() { ErrorFunction("shader_set_uniform_matrix_array()"); }; -var fn_shader_get_name = function (index) { ErrorFunction("shader_get_name()"); }; +var fn_texture_get_texel_width = GetErrorFunction("fn_texture_get_texel_width",0), + fn_texture_get_texel_height = GetErrorFunction("fn_texture_get_texel_height",0), + fn_texture_set_stage = GetErrorFunction("fn_texture_set_stage"); + +var fn_shader_is_compiled = GetErrorFunction("fn_shader_is_compiled",0), + fn_shader_set = GetErrorFunction("fn_shader_set"), + fn_shader_get_uniform = GetErrorFunction("fn_shader_get_uniform",-1), + fn_shader_set_uniform_i = GetErrorFunction("fn_shader_set_uniform_i"), + fn_shader_set_uniform_f = GetErrorFunction("fn_shader_set_uniform_f"), + fn_shader_set_uniform_matrix = GetErrorFunction("fn_shader_set_uniform_matrix"), + fn_shader_get_sampler_index = GetErrorFunction("fn_shader_get_sampler_index"), + fn_shader_enable_corner_id = GetErrorFunction("fn_shader_enable_corner_id"), + fn_shader_set_uniform_i_array = GetErrorFunction("fn_shader_set_uniform_i_array"), + fn_shader_set_uniform_f_array = GetErrorFunction("fn_shader_set_uniform_f_array"), + fn_shader_set_uniform_f_buffer = GetErrorFunction("fn_shader_set_uniform_f_buffer"), + fn_shader_set_uniform_matrix_array = GetErrorFunction("fn_shader_set_uniform_matrix_array"), + fn_shader_get_name = GetErrorFunction("fn_shader_get_name",""); var g_CurrentShader = -1; // -------------------------------------------------------------------------------------------------------------------- diff --git a/scripts/yyBufferVertex.js b/scripts/yyBufferVertex.js index 42673fa4..da84f761 100644 --- a/scripts/yyBufferVertex.js +++ b/scripts/yyBufferVertex.js @@ -15,31 +15,31 @@ // Function definitions for Canvas mode // // ############################################################################################# -var vertex_create_buffer =function() { ErrorFunction("vertex_create_buffer"); }; -var vertex_create_buffer_ext = function (size) { ErrorFunction("vertex_create_buffer_ext"); }; -var vertex_delete_buffer = function (buffer) { ErrorFunction("vertex_delete_buffer"); }; -var vertex_begin = function (buffer, format) { ErrorFunction("vertex_begin"); }; -var vertex_end = function (buffer) { ErrorFunction("vertex_end"); }; -var vertex_position = function (buffer, x, y) { ErrorFunction("vertex_position"); }; -var vertex_position_3d = function (buffer, x, y, z) { ErrorFunction("vertex_position_3d"); }; -var vertex_colour = function (buffer, col, alpha) { ErrorFunction("vertex_colour"); }; -var vertex_color = function (buffer, col, alpha) { ErrorFunction("vertex_color"); }; -var vertex_rgba = function (buffer, r, g, b, a) { ErrorFunction("vertex_rgba"); }; -var vertex_argb = function (buffer, r, g, b, a) { ErrorFunction("vertex_argb"); }; -var vertex_texcoord = function (buffer, u, v) { ErrorFunction("vertex_texcoord"); }; -var vertex_normal = function (buffer, x, y, z) { ErrorFunction("vertex_normal"); }; -var vertex_float1 = function (buffer, x) { ErrorFunction("vertex_float1"); }; -var vertex_float2 = function (buffer, x, y) { ErrorFunction("vertex_float2"); }; -var vertex_float3 = function (buffer, x, y, z) { ErrorFunction("vertex_float3"); }; -var vertex_float4 = function (buffer, x, y, z, w) { ErrorFunction("vertex_float4"); }; -var vertex_ubyte4 = function (buffer, x, y, z, w) { ErrorFunction("vertex_ubyte4"); }; -var vertex_freeze = function (buffer) { ErrorFunction("vertex_freeze"); }; -var vertex_submit = function (buffer) { ErrorFunction("vertex_submit"); }; -var vertex_get_number = function (buffer) { ErrorFunction("vertex_get_number"); }; -var vertex_get_buffer_size = function (buffer) { ErrorFunction("vertex_get_buffer_size"); }; -var vertex_create_buffer_from_buffer = function (buffer) { ErrorFunction("vertex_create_buffer_from_buffer"); }; -var vertex_create_buffer_from_buffer_ext = function (buffer) { ErrorFunction("vertex_create_buffer_from_buffer_ext"); }; -var draw_flush = function () { }; +var vertex_create_buffer = GetErrorFunction("vertex_create_buffer", -1), + vertex_create_buffer_ext = GetErrorFunction("vertex_create_buffer_ext", -1), + vertex_delete_buffer = GetErrorFunction("vertex_delete_buffer"), + vertex_begin = GetErrorFunction("vertex_begin"), + vertex_end = GetErrorFunction("vertex_end"), + vertex_position = GetErrorFunction("vertex_position"), + vertex_position_3d = GetErrorFunction("vertex_position_3d"), + vertex_colour = GetErrorFunction("vertex_colour"), + vertex_color = GetErrorFunction("vertex_color"), + vertex_rgba = GetErrorFunction("vertex_rgba"), + vertex_argb = GetErrorFunction("vertex_argb"), + vertex_texcoord = GetErrorFunction("vertex_texcoord"), + vertex_normal = GetErrorFunction("vertex_normal"), + vertex_float1 = GetErrorFunction("vertex_float1"), + vertex_float2 = GetErrorFunction("vertex_float2"), + vertex_float3 = GetErrorFunction("vertex_float3"), + vertex_float4 = GetErrorFunction("vertex_float4"), + vertex_ubyte4 = GetErrorFunction("vertex_ubyte4"), + vertex_freeze = GetErrorFunction("vertex_freeze"), + vertex_submit = GetErrorFunction("vertex_submit"), + vertex_get_number = GetErrorFunction("vertex_get_number"), + vertex_get_buffer_size = GetErrorFunction("vertex_get_buffer_size"), + vertex_create_buffer_from_buffer = GetErrorFunction("vertex_create_buffer_from_buffer", -1), + vertex_create_buffer_from_buffer_ext = GetErrorFunction("vertex_create_buffer_from_buffer_ext", -1), + draw_flush = function () { }; // Constant for the default vertex buffer storage size var DEFAULT_VERTEX_BUFFER_SIZE = 8 * 1024; diff --git a/scripts/yyVertexManager.js b/scripts/yyVertexManager.js index 5ad3bd35..ad35928a 100644 --- a/scripts/yyVertexManager.js +++ b/scripts/yyVertexManager.js @@ -10,17 +10,17 @@ // // ********************************************************************************************************************** -function vertex_format_begin() { ErrorFunction("vertex_format_begin"); } -function vertex_format_end() { ErrorFunction("vertex_format_end"); } -function vertex_format_delete(format_id) { ErrorFunction("vertex_format_delete"); } -function vertex_format_add_position() { ErrorFunction("vertex_format_add_position"); } -function vertex_format_add_position_3d() { ErrorFunction("vertex_format_add_position_3d"); } -function vertex_format_add_colour() { ErrorFunction("vertex_format_add_colour"); } -function vertex_format_add_color() { ErrorFunction("vertex_format_add_color"); } -function vertex_format_add_normal() { ErrorFunction("vertex_format_add_normal"); } -function vertex_format_add_texcoord() { ErrorFunction("vertex_format_add_texcoord"); } -function vertex_format_add_textcoord() { ErrorFunction("vertex_format_add_textcoord"); } -function vertex_format_add_custom(type, usage) { ErrorFunction("vertex_format_add_custom"); } +var vertex_format_begin = GetErrorFunction("vertex_format_begin"), + vertex_format_end = GetErrorFunction("vertex_format_end"), + vertex_format_delete = GetErrorFunction("vertex_format_delete"), + vertex_format_add_position = GetErrorFunction("vertex_format_add_position"), + vertex_format_add_position_3d = GetErrorFunction("vertex_format_add_position_3d"), + vertex_format_add_colour = GetErrorFunction("vertex_format_add_colour"), + vertex_format_add_color = GetErrorFunction("vertex_format_add_color"), + vertex_format_add_normal = GetErrorFunction("vertex_format_add_normal"), + vertex_format_add_texcoord = GetErrorFunction("vertex_format_add_texcoord"), + vertex_format_add_textcoord = GetErrorFunction("vertex_format_add_textcoord"), + vertex_format_add_custom = GetErrorFunction("vertex_format_add_custom"); // --------------------------------------------------------------------------------------------- // Tracks the format currently under construction From 62c4d64a033506cf134f18ea4fef1fb1c4dcf34a Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 15:08:53 +0300 Subject: [PATCH 07/84] Removed d3d_model_* functions, pretty self-contained. --- scripts/functions/Function_D3D.js | 310 ---------- scripts/yy3DModel.js | 929 ------------------------------ 2 files changed, 1239 deletions(-) diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js index 6f02f895..a1bd42f9 100644 --- a/scripts/functions/Function_D3D.js +++ b/scripts/functions/Function_D3D.js @@ -41,37 +41,6 @@ function d3d_draw_cylinder(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,closed,steps) function d3d_draw_cone(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_draw_cone()"); } function d3d_draw_wall(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat) { ErrorFunction("d3d_draw_wall()"); } -function d3d_model_create() { ErrorFunction("d3d_model_create()"); } -function d3d_model_destroy(ind) { ErrorFunction("d3d_model_destroy()"); } -function d3d_model_clear(ind) { ErrorFunction("d3d_model_clear()"); } -function d3d_model_save(ind,fname) { ErrorFunction("d3d_model_save()"); } -function d3d_model_load(ind,fname) { ErrorFunction("d3d_model_load()"); } -function d3d_model_save_buffer(ind,fname) { ErrorFunction("d3d_model_save_buffer()"); } -function d3d_model_load_buffer(ind,fname) { ErrorFunction("d3d_model_load_buffer()"); } - - - -function d3d_model_draw(ind,x,y,z,texid) { ErrorFunction("d3d_model_draw()"); } -function d3d_model_primitive_begin(ind,kind) { ErrorFunction("d3d_model_primitive_begin()"); } -function d3d_model_vertex(ind,x,y,z) { ErrorFunction("d3d_model_vertex()"); } -function d3d_model_vertex_colour(ind, x, y, z, col, alpha) { ErrorFunction("d3d_model_vertex_colour()"); } -function d3d_model_vertex_color(ind, x, y, z, col, alpha) { ErrorFunction("d3d_model_vertex_color()"); } -function d3d_model_vertex_texture(ind,x,y,z,xtex,ytex) { ErrorFunction("d3d_model_vertex_texture()"); } -function d3d_model_vertex_texture_colour(ind, x, y, z, xtex, ytex, col, alpha) { ErrorFunction("d3d_model_vertex_texture_colour()"); } -function d3d_model_vertex_texture_color(ind, x, y, z, xtex, ytex, col, alpha) { ErrorFunction("d3d_model_vertex_texture_color()"); } -function d3d_model_vertex_normal(ind,x,y,z,nx,ny,nz) { ErrorFunction("d3d_model_vertex_normal()"); } -function d3d_model_vertex_normal_color(ind,x,y,z,nx,ny,nz,col,alpha) { ErrorFunction("d3d_model_vertex_normal_color()"); } -function d3d_model_vertex_normal_texture(ind,x,y,z,nx,ny,nz,xtex,ytex) { ErrorFunction("d3d_model_vertex_normal_texture()"); } -function d3d_model_vertex_normal_texture_color(ind, x, y, z, nx, ny, nz, xtex, ytex, col, alpha) { ErrorFunction("d3d_model_vertex_normal_texture_color()"); } -function d3d_model_vertex_normal_texture_colour(ind, x, y, z, nx, ny, nz, xtex, ytex, col, alpha) { ErrorFunction("d3d_model_vertex_normal_texture_colour()"); } -function d3d_model_primitive_end(ind) { ErrorFunction("d3d_model_primitive_end()"); } -function d3d_model_block(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { ErrorFunction("d3d_model_block()"); } -function d3d_model_cylinder(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_model_cylinder()"); } -function d3d_model_cone(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_model_cone()"); } -function d3d_model_ellipsoid(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,steps) { ErrorFunction("d3d_model_ellipsoid()"); } -function d3d_model_wall(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { ErrorFunction("d3d_model_wall()"); } -function d3d_model_floor(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { ErrorFunction("d3d_model_floor()"); } - function d3d_set_perspective(enable) { ErrorFunction("d3d_set_perspective()"); } function d3d_set_projection(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup) { ErrorFunction("d3d_set_projection()"); } function d3d_set_projection_ext(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup,angle,aspect,zn,zf) { ErrorFunction("d3d_set_projection_ext()"); } @@ -285,35 +254,6 @@ function InitD3DFunctions() { d3d_light_get = WebGL_d3d_light_get_RELEASE; d3d_light_get_ambient = WebGL_d3d_light_get_ambient_RELEASE; d3d_get_lighting = WebGL_d3d_get_lighting_RELEASE; - - // 3D models - d3d_model_create = WebGL_d3d_model_create_RELEASE; - d3d_model_destroy = WebGL_d3d_model_destroy_RELEASE; - d3d_model_clear = WebGL_d3d_model_clear_RELEASE; - d3d_model_save = WebGL_d3d_model_save_RELEASE; - d3d_model_load = WebGL_d3d_model_load_RELEASE; - d3d_model_save_buffer = WebGL_d3d_model_save_buffer_RELEASE; - d3d_model_load_buffer = WebGL_d3d_model_load_buffer_RELEASE; - d3d_model_draw = WebGL_d3d_model_draw_RELEASE; - d3d_model_primitive_begin = WebGL_d3d_model_primitive_begin_RELEASE; - d3d_model_vertex = WebGL_d3d_model_vertex_RELEASE; - d3d_model_vertex_color = WebGL_d3d_model_vertex_color_RELEASE; - d3d_model_vertex_colour = WebGL_d3d_model_vertex_color_RELEASE; - d3d_model_vertex_texture = WebGL_d3d_model_vertex_texture_RELEASE; - d3d_model_vertex_texture_color = WebGL_d3d_model_vertex_texture_color_RELEASE; - d3d_model_vertex_texture_colour = WebGL_d3d_model_vertex_texture_color_RELEASE; - d3d_model_vertex_normal = WebGL_d3d_model_vertex_normal_RELEASE; - d3d_model_vertex_normal_color = WebGL_d3d_model_vertex_normal_color_RELEASE; - d3d_model_vertex_normal_texture = WebGL_d3d_model_vertex_normal_texture_RELEASE; - d3d_model_vertex_normal_texture_color = WebGL_d3d_model_vertex_normal_texture_color_RELEASE; - d3d_model_primitive_end = WebGL_d3d_model_primitive_end_RELEASE; - - d3d_model_block = WebGL_d3d_model_block_RELEASE; - d3d_model_cylinder = WebGL_d3d_model_cylinder_RELEASE; - d3d_model_cone = WebGL_d3d_model_cone_RELEASE; - d3d_model_ellipsoid = WebGL_d3d_model_ellipsoid_RELEASE; - d3d_model_wall = WebGL_d3d_model_wall_RELEASE; - d3d_model_floor = WebGL_d3d_model_floor_RELEASE; matrix_get = WebGL_Matrix_Get; matrix_set = WebGL_Matrix_Set; @@ -1102,256 +1042,6 @@ function WebGL_d3d_set_fog_RELEASE(enable,colour,start,end) { } -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_create_RELEASE() { - - return (g_3DModels.push(new yy3DModel()) - 1); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_destroy_RELEASE(ind) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Clear(); - g_3DModels[ind] = null; - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_clear_RELEASE(ind) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Clear(); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_save_RELEASE(ind, fname) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Save(fname); - } -} - -function WebGL_d3d_model_save_buffer_RELEASE(ind, buffer_index) { - -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_load_RELEASE(ind, fname) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Load(fname); - } -} - -function WebGL_d3d_model_load_buffer_RELEASE(ind, buffer_index) { - - -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_draw_RELEASE(ind,x,y,z,texid) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Draw(x, y, z, texid); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_primitive_begin_RELEASE(ind,kind) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Begin(kind); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_vertex_RELEASE(ind,x,y,z) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Vertex(x, y, z); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_vertex_color_RELEASE(ind,x,y,z,col,alpha) { - - if (g_3DModels[ind]) { - g_3DModels[ind].VertexColor(x, y, z, col, alpha); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_vertex_texture_RELEASE(ind,x,y,z,xtex,ytex) { - - if (g_3DModels[ind]) { - g_3DModels[ind].VertexTexture(x, y, z, xtex, ytex); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_vertex_texture_color_RELEASE(ind,x,y,z,xtex,ytex,col,alpha) { - - if (g_3DModels[ind]) { - g_3DModels[ind].VertexTextureColor(x, y, z, xtex, ytex, col, alpha); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_vertex_normal_RELEASE(ind,x,y,z,nx,ny,nz) { - - if (g_3DModels[ind]) { - g_3DModels[ind].VertexNormal(x, y, z, nx, ny, nz); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_vertex_normal_color_RELEASE(ind,x,y,z,nx,ny,nz,col,alpha) { - - if (g_3DModels[ind]) { - g_3DModels[ind].VertexNormalColor(x, y, z, nx, ny, nz, col, alpha); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_vertex_normal_texture_RELEASE(ind,x,y,z,nx,ny,nz,xtex,ytex) { - - if (g_3DModels[ind]) { - g_3DModels[ind].VertexNormalTexture(x, y, z, nx, ny, nz, xtex, ytex); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_vertex_normal_texture_color_RELEASE(ind,x,y,z,nx,ny,nz,xtex,ytex,col,alpha) { - - if (g_3DModels[ind]) { - g_3DModels[ind].VertexNormalTextureColor(x, y, z, nx, ny, nz, xtex, ytex, col, alpha); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_primitive_end_RELEASE(ind) { - - if (g_3DModels[ind]) { - g_3DModels[ind].End(); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_block_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Block(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_cylinder_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Cylinder(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_cone_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Cone(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_ellipsoid_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,steps) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Ellipsoid(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,steps); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_wall_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Wall(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat); - } -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_model_floor_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { - - if (g_3DModels[ind]) { - g_3DModels[ind].Floor(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat); - } -} - // ############################################################################################# /// Function: diff --git a/scripts/yy3DModel.js b/scripts/yy3DModel.js index f0a4be43..8b723b2a 100644 --- a/scripts/yy3DModel.js +++ b/scripts/yy3DModel.js @@ -9,932 +9,3 @@ // Description: // // ********************************************************************************************************************** - -var M_PRIMITIVE_BEGIN = 0, - M_PRIMITIVE_END = 1, - M_VERTEX = 2, - M_VERTEX_COLOR = 3, - M_VERTEX_TEX = 4, - M_VERTEX_TEX_COLOR = 5, - M_VERTEX_N = 6, - M_VERTEX_N_COLOR = 7, - M_VERTEX_N_TEX = 8, - M_VERTEX_N_TEX_COLOR = 9, - M_SHAPE_BLOCK = 10, - M_SHAPE_CYLINDER = 11, - M_SHAPE_CONE = 12, - M_SHAPE_ELLIPSOID = 13, - M_SHAPE_WALL = 14, - M_SHAPE_FLOOR = 15; - -// ############################################################################################# -/// Function: -/// 3DModel Constructor -/// -// ############################################################################################# -/** @constructor */ -function yy3DModel() { - - this.Clear(); -} - -// ############################################################################################# -/// Function: -/// Reset the model's data -/// -// ############################################################################################# -yy3DModel.prototype.Clear = function() { - - // Command list set - this.CmdList = []; - this.Cached = []; -}; - -// ############################################################################################# -/// Function: -/// Generates the model data used for saving -/// -// ############################################################################################# -yy3DModel.prototype.BuildModelData = function() { - - // Write version number - var outputData = "100\n"; - - // Write number of commands - outputData += this.CmdList.length.toString() + "\n"; - for (var i = 0; i < this.CmdList.length; i++) { - - // To stay compatible with the C++, all lines should have 10 floats of data - var cmd = this.CmdList[i]; - outputData += cmd.Command.toString() + " "; - switch (cmd.Command) { - case M_PRIMITIVE_END: - break; - - case M_PRIMITIVE_BEGIN: - outputData += cmd.PrimType.toString(); - break; - - case M_VERTEX: - outputData += cmd.x.toString() + " "; - outputData += cmd.y.toString() + " "; - outputData += cmd.z.toString() + " "; - outputData += "0.0 0.0 0.0 0.0 0.0 0.0 0.0\n"; - break; - - case M_VERTEX_COLOR: - outputData += cmd.x.toString() + " "; - outputData += cmd.y.toString() + " "; - outputData += cmd.z.toString() + " "; - outputData += (cmd.color * 1.0).toString() + " "; - outputData += cmd.alpha.toString() + " "; - outputData += "0.0 0.0 0.0 0.0 0.0\n"; - break; - - case M_VERTEX_TEX: - outputData += cmd.x.toString() + " "; - outputData += cmd.y.toString() + " "; - outputData += cmd.z.toString() + " "; - outputData += cmd.u.toString() + " "; - outputData += cmd.v.toString() + " "; - outputData += "0.0 0.0 0.0 0.0 0.0\n"; - break; - - case M_VERTEX_TEX_COLOR: - outputData += cmd.x.toString() + " "; - outputData += cmd.y.toString() + " "; - outputData += cmd.z.toString() + " "; - outputData += cmd.u.toString() + " "; - outputData += cmd.v.toString() + " "; - outputData += (cmd.color * 1.0).toString() + " "; - outputData += cmd.alpha.toString() + " "; - outputData += "0.0 0.0 0.0\n"; - break; - - case M_VERTEX_N: - outputData += cmd.x.toString() + " "; - outputData += cmd.y.toString() + " "; - outputData += cmd.z.toString() + " "; - outputData += cmd.nx.toString() + " "; - outputData += cmd.ny.toString() + " "; - outputData += cmd.nz.toString() + " "; - outputData += "0.0 0.0 0.0 0.0\n"; - break; - - case M_VERTEX_N_COLOR: - outputData += cmd.x.toString() + " "; - outputData += cmd.y.toString() + " "; - outputData += cmd.z.toString() + " "; - outputData += cmd.nx.toString() + " "; - outputData += cmd.ny.toString() + " "; - outputData += cmd.nz.toString() + " "; - outputData += (cmd.color * 1.0).toString() + " "; - outputData += cmd.alpha.toString() + " "; - outputData += "0.0 0.0\n"; - break; - - case M_VERTEX_N_TEX: - outputData += cmd.x.toString() + " "; - outputData += cmd.y.toString() + " "; - outputData += cmd.z.toString() + " "; - outputData += cmd.nx.toString() + " "; - outputData += cmd.ny.toString() + " "; - outputData += cmd.nz.toString() + " "; - outputData += cmd.u.toString() + " "; - outputData += cmd.v.toString() + " "; - outputData += "0.0 0.0\n"; - break; - - case M_VERTEX_N_TEX_COLOR: - outputData += cmd.x.toString() + " "; - outputData += cmd.y.toString() + " "; - outputData += cmd.z.toString() + " "; - outputData += cmd.nx.toString() + " "; - outputData += cmd.ny.toString() + " "; - outputData += cmd.nz.toString() + " "; - outputData += cmd.u.toString() + " "; - outputData += cmd.v.toString() + " "; - outputData += (cmd.color * 1.0).toString() + " "; - outputData += cmd.alpha.toString() + " "; - outputData += "\n"; - break; - - case M_SHAPE_BLOCK: - case M_SHAPE_WALL: - case M_SHAPE_FLOOR: - outputData += cmd.x1.toString() + " "; - outputData += cmd.y1.toString() + " "; - outputData += cmd.z1.toString() + " "; - outputData += cmd.x2.toString() + " "; - outputData += cmd.y2.toString() + " "; - outputData += cmd.z2.toString() + " "; - outputData += (cmd.hrep ? 1.0 : 0.0).toString() + " "; - outputData += (cmd.vrep ? 1.0 : 0.0).toString() + " "; - outputData += "0.0 0.0\n"; - break; - - case M_SHAPE_ELLIPSOID: - outputData += cmd.x1.toString() + " "; - outputData += cmd.y1.toString() + " "; - outputData += cmd.z1.toString() + " "; - outputData += cmd.x2.toString() + " "; - outputData += cmd.y2.toString() + " "; - outputData += cmd.z2.toString() + " "; - outputData += (cmd.hrep ? 1.0 : 0.0).toString() + " "; - outputData += (cmd.vrep ? 1.0 : 0.0).toString() + " "; - outputData += (cmd.steps * 1.0).toString() + " "; - outputData += "0.0\n"; - break; - - case M_SHAPE_CYLINDER: - case M_SHAPE_CONE: - outputData += cmd.x1.toString() + " "; - outputData += cmd.y1.toString() + " "; - outputData += cmd.z1.toString() + " "; - outputData += cmd.x2.toString() + " "; - outputData += cmd.y2.toString() + " "; - outputData += cmd.z2.toString() + " "; - outputData += (cmd.hrep ? 1.0 : 0.0).toString() + " "; - outputData += (cmd.vrep ? 1.0 : 0.0).toString() + " "; - outputData += (cmd.closed ? 1.0 : 0.0).toString() + " "; - outputData += (cmd.steps * 1.0).toString() + " "; - outputData += "\n"; - break; - } - } - return outputData; -}; - -// ############################################################################################# -/// Function: -/// Store 3D model to a buffer and save to the given file -/// -// ############################################################################################# -yy3DModel.prototype.Save = function(_fname) { - - if (g_SupportsLocalStorage === true) { - - var modelData = this.BuildModelData(); - var fileid = file_text_open_write(_fname); - file_text_write_string(fileid, modelData); - file_text_close(fileid); - } - else { - debug("d3d_model_save() browser does not support local storage\n"); - } -}; - -// ############################################################################################# -/// Function: -// Used when loading a 3D model since we can't use regular expressions -/// -// ############################################################################################# -yy3DModel.prototype.StripExtraneousSpaces = function(_lineData) { - - var destLineData = ""; - var space = false; - for (var i = 0; i < _lineData.length; i++) { - - var currChar = _lineData.charAt(i); - if (currChar == ' ') { - if (!space) { - destLineData = destLineData + currChar; - } - space = true; - } - else { - space = false; - destLineData = destLineData + currChar; - } - } - return destLineData; -}; - -// ############################################################################################# -/// Function: -/// Load 3D model from the given file -/// -// ############################################################################################# -yy3DModel.prototype.ParseModelData = function(_modelData) { - - var lineDataArray = _modelData.split("\n"); - - var version = parseInt(lineDataArray[0]); - if (version == 100) { - - var modelEntries = parseInt(lineDataArray[1]); - for (var i = 2; i < lineDataArray.length; i++) { - - var cmd = {}; - - var lineData = this.StripExtraneousSpaces(lineDataArray[i]); - var lineElements = lineData.split(" "); - - cmd.Command = parseInt(lineElements[0]); - switch (cmd.Command) { - - case M_PRIMITIVE_END: - break; - - case M_PRIMITIVE_BEGIN: - { - cmd.PrimType = parseInt(lineElements[1]); - break; - } - - case M_VERTEX: - { - cmd.x = parseFloat(lineElements[1]); - cmd.y = parseFloat(lineElements[2]); - cmd.z = parseFloat(lineElements[3]); - break; - } - - case M_VERTEX_COLOR: - { - cmd.x = parseFloat(lineElements[1]); - cmd.y = parseFloat(lineElements[2]); - cmd.z = parseFloat(lineElements[3]); - cmd.color = parseInt(lineElements[4]); - cmd.alpha = parseFloat(lineElements[5]); - break; - } - - case M_VERTEX_TEX: - { - cmd.x = parseFloat(lineElements[1]); - cmd.y = parseFloat(lineElements[2]); - cmd.z = parseFloat(lineElements[3]); - cmd.u = parseFloat(lineElements[4]); - cmd.v = parseFloat(lineElements[5]); - break; - } - - case M_VERTEX_TEX_COLOR: - { - cmd.x = parseFloat(lineElements[1]); - cmd.y = parseFloat(lineElements[2]); - cmd.z = parseFloat(lineElements[3]); - cmd.u = parseFloat(lineElements[4]); - cmd.v = parseFloat(lineElements[5]); - cmd.color = parseInt(lineElements[6]); - cmd.alpha = parseFloat(lineElements[7]); - break; - } - - case M_VERTEX_N: - { - cmd.x = parseFloat(lineElements[1]); - cmd.y = parseFloat(lineElements[2]); - cmd.z = parseFloat(lineElements[3]); - cmd.nx = parseFloat(lineElements[4]); - cmd.ny = parseFloat(lineElements[5]); - cmd.nz = parseFloat(lineElements[6]); - break; - } - - case M_VERTEX_N_COLOR: - { - cmd.x = parseFloat(lineElements[1]); - cmd.y = parseFloat(lineElements[2]); - cmd.z = parseFloat(lineElements[3]); - cmd.nx = parseFloat(lineElements[4]); - cmd.ny = parseFloat(lineElements[5]); - cmd.nz = parseFloat(lineElements[6]); - cmd.color = parseInt(lineElements[7]); - cmd.alpha = parseFloat(lineElements[8]); - break; - } - - case M_VERTEX_N_TEX: - { - cmd.x = parseFloat(lineElements[1]); - cmd.y = parseFloat(lineElements[2]); - cmd.z = parseFloat(lineElements[3]); - cmd.nx = parseFloat(lineElements[4]); - cmd.ny = parseFloat(lineElements[5]); - cmd.nz = parseFloat(lineElements[6]); - cmd.u = parseFloat(lineElements[7]); - cmd.v = parseFloat(lineElements[8]); - break; - } - - case M_VERTEX_N_TEX_COLOR: - { - cmd.x = parseFloat(lineElements[1]); - cmd.y = parseFloat(lineElements[2]); - cmd.z = parseFloat(lineElements[3]); - cmd.nx = parseFloat(lineElements[4]); - cmd.ny = parseFloat(lineElements[5]); - cmd.nz = parseFloat(lineElements[6]); - cmd.u = parseFloat(lineElements[7]); - cmd.v = parseFloat(lineElements[8]); - cmd.color = parseInt(lineElements[9]); - cmd.alpha = parseFloat(lineElements[10]); - break; - } - - case M_SHAPE_BLOCK: - case M_SHAPE_WALL: - case M_SHAPE_FLOOR: - { - cmd.x1 = parseFloat(lineElements[1]); - cmd.y1 = parseFloat(lineElements[2]); - cmd.z1 = parseFloat(lineElements[3]); - cmd.x2 = parseFloat(lineElements[4]); - cmd.y2 = parseFloat(lineElements[5]); - cmd.z2 = parseFloat(lineElements[6]); - cmd.hrep = (parseFloat(lineElements[7]) >= 0.5) ? true : false; - cmd.vrep = (parseFloat(lineElements[8]) >= 0.5) ? true : false; - break; - } - - case M_SHAPE_ELLIPSOID: - { - cmd.x1 = parseFloat(lineElements[1]); - cmd.y1 = parseFloat(lineElements[2]); - cmd.z1 = parseFloat(lineElements[3]); - cmd.x2 = parseFloat(lineElements[4]); - cmd.y2 = parseFloat(lineElements[5]); - cmd.z2 = parseFloat(lineElements[6]); - cmd.hrep = (parseFloat(lineElements[7]) >= 0.5) ? true : false; - cmd.vrep = (parseFloat(lineElements[8]) >= 0.5) ? true : false; - cmd.steps = ~~parseFloat(lineElements[9]); - break; - } - - case M_SHAPE_CYLINDER: - case M_SHAPE_CONE: - { - cmd.x1 = parseFloat(lineElements[1]); - cmd.y1 = parseFloat(lineElements[2]); - cmd.z1 = parseFloat(lineElements[3]); - cmd.x2 = parseFloat(lineElements[4]); - cmd.y2 = parseFloat(lineElements[5]); - cmd.z2 = parseFloat(lineElements[6]); - cmd.hrep = (parseFloat(lineElements[7]) >= 0.5) ? true : false; - cmd.vrep = (parseFloat(lineElements[8]) >= 0.5) ? true : false; - cmd.closed = (parseFloat(lineElements[9]) >= 0.5) ? true : false; - cmd.steps = ~~parseFloat(lineElements[10]); - break; - } - } - this.CmdList.push(cmd); - } - } -}; - - -// ############################################################################################# -/// Function: -/// Load 3D model from the given file -/// -// ############################################################################################# -yy3DModel.prototype.Load = function(_fname) { - - // Check for local storage version - var pTextFile = LoadTextFile_Block(_fname, true); - if (pTextFile !== null && pTextFile !== undefined) { - this.ParseModelData(pTextFile); - } - else { - // Attempt to load it remotely - var fname = CheckWorkingDirectory(_fname); - - var self = this; - var modelXhr = new XMLHttpRequest(); - modelXhr.open("GET", fname, false); // synchronous - modelXhr.onload = function() { - if (modelXhr.readyState==4 && modelXhr.status==200) { - self.ParseModelData(modelXhr.responseText); - } - }; - modelXhr.send(null); - } -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.Begin = function (kind) { - - this.CmdList.push({ - Command: M_PRIMITIVE_BEGIN, - PrimType: kind - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.End = function () { - - this.CmdList.push({ - Command: M_PRIMITIVE_END - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.Vertex = function (x,y,z) { - - this.CmdList.push({ - Command: M_VERTEX, - x: x, - y: y, - z: z - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.VertexColor = function (x,y,z,col,alpha) { - - this.CmdList.push({ - Command: M_VERTEX_COLOR, - x: x, - y: y, - z: z, - color: col, - alpha: alpha - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.VertexTexture = function (x,y,z,xtex,ytex) { - - this.CmdList.push({ - Command: M_VERTEX_TEX, - x: x, - y: y, - z: z, - u: xtex, - v: ytex - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.VertexTextureColor = function (x,y,z,xtex,ytex,col,alpha) { - - this.CmdList.push({ - Command: M_VERTEX_TEX_COLOR, - x: x, - y: y, - z: z, - u: xtex, - v: ytex, - color: col, - alpha: alpha - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.VertexNormal = function (x,y,z,nx,ny,nz) { - - this.CmdList.push({ - Command: M_VERTEX_N, - x: x, - y: y, - z: z, - nx: nx, - ny: ny, - nz: nz - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.VertexNormalColor = function (x,y,z,nx,ny,nz,col,alpha) { - - this.CmdList.push({ - Command: M_VERTEX_N_COLOR, - x: x, - y: y, - z: z, - nx: nx, - ny: ny, - nz: nz, - color: col, - alpha: alpha - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.VertexNormalTexture = function (x,y,z,nx,ny,nz,xtex,ytex) { - - this.CmdList.push({ - Command: M_VERTEX_N_TEX, - x: x, - y: y, - z: z, - nx: nx, - ny: ny, - nz: nz, - u: xtex, - v: ytex - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.VertexNormalTextureColor = function (x,y,z,nx,ny,nz,xtex,ytex,col,alpha) { - - this.CmdList.push({ - Command: M_VERTEX_N_TEX_COLOR, - x: x, - y: y, - z: z, - nx: nx, - ny: ny, - nz: nz, - u: xtex, - v: ytex, - color: col, - alpha: alpha - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.Block = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { - - this.CmdList.push({ - Command: M_SHAPE_BLOCK, - x1: x1, - y1: y1, - z1: z1, - x2: x2, - y2: y2, - z2: z2, - hrep: hrepeat, - vrep: vrepeat - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.Cylinder = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) { - - this.CmdList.push({ - Command: M_SHAPE_CYLINDER, - x1: x1, - y1: y1, - z1: z1, - x2: x2, - y2: y2, - z2: z2, - hrep: hrepeat, - vrep: vrepeat, - closed: closed, - steps: steps - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.Cone = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) { - - this.CmdList.push({ - Command: M_SHAPE_CONE, - x1: x1, - y1: y1, - z1: z1, - x2: x2, - y2: y2, - z2: z2, - hrep: hrepeat, - vrep: vrepeat, - closed: closed, - steps: steps - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.Ellipsoid = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,steps) { - - this.CmdList.push({ - Command: M_SHAPE_ELLIPSOID, - x1: x1, - y1: y1, - z1: z1, - x2: x2, - y2: y2, - z2: z2, - hrep: hrepeat, - vrep: vrepeat, - steps: steps - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.Wall = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { - - this.CmdList.push({ - Command: M_SHAPE_WALL, - x1: x1, - y1: y1, - z1: z1, - x2: x2, - y2: y2, - z2: z2, - hrep: hrepeat, - vrep: vrepeat - }); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.Floor = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { - - this.CmdList.push({ - Command: M_SHAPE_FLOOR, - x1: x1, - y1: y1, - z1: z1, - x2: x2, - y2: y2, - z2: z2, - hrep: hrepeat, - vrep: vrepeat - }); -}; - -// ############################################################################################# -/// Function: -/// If the primtype changes or they're using a triangle fan, we need a new vbuffer. -/// This routine lets us create a new one consistently. -/// -// ############################################################################################# -yy3DModel.prototype.CreateNewVBuffer = function () { - - this.vbufferCache = new yyVBuffer(DEFAULT_VB_SIZE, g_webGL.GetVertexFormat(g_webGL.VERTEX_FORMAT_3D), false); - // Fudge in a store of the prim type - this.vbufferCache.PrimType = -1; - this.vbufferCache.PrimTexture = null; -}; - -// ############################################################################################# -/// Function: -/// Certain prim types can't share a vbuffer, so test if they can -/// -// ############################################################################################# -yy3DModel.prototype.CanConcatPrimType = function (_prim) { - - switch (_prim) { - case PrimType_POINTLIST: - case PrimType_LINELIST: - case PrimType_TRILIST: - return true; - } - return false; -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.CachePrimData = function (_cache) { - - var vbuff = this.vbufferCache; - if ((vbuff.PrimType != -1) && - ((g_PrimType != vbuff.PrimType) || - (g_PrimTexture != vbuff.PrimTexture) || - (this.CanConcatPrimType(vbuff.PrimType) === false))) - { - vbuff.Freeze(); - _cache.push({ - PrimType: WebGL_translate_primitive_builder_type(vbuff.PrimType), - PrimTexture: vbuff.PrimTexture, - PrimVBuffer: vbuff - }); - - // Create a new vbuffer for the next lot of data - this.CreateNewVBuffer(); - vbuff = this.vbufferCache; - } - vbuff.Concat(g_PrimVBuffer); - vbuff.PrimType = g_PrimType; - vbuff.PrimTexture = g_PrimTexture; - - primitive_builder_clear(); -}; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -yy3DModel.prototype.FinalisePrimDataCache = function (_cache) { - - var vbuff = this.vbufferCache; - vbuff.Freeze(); - _cache.push({ - PrimType: WebGL_translate_primitive_builder_type(vbuff.PrimType), - PrimTexture: vbuff.PrimTexture, - PrimVBuffer: vbuff - }); - primitive_builder_clear(); -}; - -// ############################################################################################# -/// Function: -/// Dispatch and record the shape being drawn -/// -// ############################################################################################# -yy3DModel.prototype.DrawShape = function (cmd, tex, _cache) { - - // Allow us to record multiple primitive blocks - var fn_d3d_primitive_end = d3d_primitive_end; - var self = this; - d3d_primitive_end = function () { - - self.CachePrimData(_cache); - }; - - switch (cmd.Command) { - case M_SHAPE_BLOCK: d3d_draw_block(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep); - break; - case M_SHAPE_CYLINDER: d3d_draw_cylinder(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep, cmd.closed, cmd.steps); - break; - case M_SHAPE_CONE: d3d_draw_cone(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep, cmd.closed, cmd.steps); - break; - case M_SHAPE_ELLIPSOID: d3d_draw_ellipsoid(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep, cmd.steps); - break; - case M_SHAPE_WALL: d3d_draw_wall(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep); - break; - case M_SHAPE_FLOOR: d3d_draw_floor(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep); - break; - } - d3d_primitive_end = fn_d3d_primitive_end; -}; - -// ############################################################################################# -/// Function: -/// Dispatch the model's draw data -/// -// ############################################################################################# -yy3DModel.prototype.Draw = function(x, y, z, tex) { - - // Set the world transform for the data - var i,mt = new Matrix(); - mt.SetTranslation(x, y, z); - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - var m = new Matrix(); - m.Multiply(mt, mo); - - WebGL_SetMatrix(MATRIX_WORLD, m); - - var colour = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff); - var texCache = this.Cached[colour]; - if (texCache === undefined) { - texCache = []; - this.Cached[colour] = texCache; - } // end if - - if (texCache[tex] === undefined) { - - // They may be multiple sets of primitive data within this model - texCache[tex] = []; - var cache = texCache[tex]; - - // As long as the prim type doesn't change we can store all data in one big vbuffer - this.CreateNewVBuffer(); - - // Dispatch the set of commands - for (var i = 0; i < this.CmdList.length; i++) { - - var cmd = this.CmdList[i]; - switch (cmd.Command) { - - case M_PRIMITIVE_BEGIN: - d3d_primitive_begin_texture(cmd.PrimType, tex); - break; - case M_PRIMITIVE_END: - this.CachePrimData(cache); - break; - case M_VERTEX: - d3d_vertex(cmd.x, cmd.y, cmd.z); - break; - case M_VERTEX_COLOR: - d3d_vertex_color(cmd.x, cmd.y, cmd.z, cmd.color, cmd.alpha); - break; - case M_VERTEX_TEX: - d3d_vertex_texture(cmd.x, cmd.y, cmd.z, cmd.u, cmd.v); - break; - case M_VERTEX_TEX_COLOR: - d3d_vertex_texture_color(cmd.x, cmd.y, cmd.z, cmd.u, cmd.v, cmd.color, cmd.alpha); - break; - case M_VERTEX_N: - d3d_vertex_normal(cmd.x, cmd.y, cmd.z, cmd.nx, cmd.ny, cmd.nz); - break; - case M_VERTEX_N_COLOR: - d3d_vertex_normal_color(cmd.x, cmd.y, cmd.z, cmd.nx, cmd.ny, cmd.nz, cmd.color, cmd.alpha); - break; - case M_VERTEX_N_TEX: - d3d_vertex_normal_texture(cmd.x, cmd.y, cmd.z, cmd.nx, cmd.ny, cmd.nz, cmd.u, cmd.v); - break; - case M_VERTEX_N_TEX_COLOR: - d3d_vertex_normal_texture_color(cmd.x, cmd.y, cmd.z, cmd.nx, cmd.ny, cmd.nz, cmd.u, cmd.v, cmd.color, cmd.alpha); - break; - case M_SHAPE_BLOCK: - case M_SHAPE_CYLINDER: - case M_SHAPE_CONE: - case M_SHAPE_ELLIPSOID: - case M_SHAPE_WALL: - case M_SHAPE_FLOOR: - this.DrawShape(cmd, tex, cache); - break; - } - } - this.FinalisePrimDataCache(cache); - this.vbufferCache = null; - } - - // Always draw the cached model (since we don't dispatch on primitive end now) - var cachedArray = texCache[tex]; - for (i = 0; i < cachedArray.length; i++) { - - var cachedData = cachedArray[i]; - var glTexture = cachedData.PrimTexture ? cachedData.PrimTexture.webgl_textureid : null; - g_webGL.DispatchVBuffer(cachedData.PrimType, glTexture, cachedData.PrimVBuffer, 0); - } - - // Restore world matrix - WebGL_SetMatrix(MATRIX_WORLD, mo); -}; \ No newline at end of file From ca6d642a877a5ebdbd3681abb8d5e13195f3db32 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 15:12:00 +0300 Subject: [PATCH 08/84] Removed d3d_draw_* functions, also self-contained. --- scripts/functions/Function_D3D.js | 316 ------------------------------ 1 file changed, 316 deletions(-) diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js index a1bd42f9..2b36e0af 100644 --- a/scripts/functions/Function_D3D.js +++ b/scripts/functions/Function_D3D.js @@ -34,13 +34,6 @@ function d3d_light_get_ambient(index) function d3d_get_lighting() { ErrorFunction("d3d_get_lighting()"); } -function d3d_draw_floor(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat) { ErrorFunction("d3d_draw_floor()"); } -function d3d_draw_ellipsoid(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,steps) { ErrorFunction("d3d_draw_ellipsoid()"); } -function d3d_draw_block(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat) { ErrorFunction("d3d_draw_block()"); } -function d3d_draw_cylinder(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_draw_cylinder()"); } -function d3d_draw_cone(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_draw_cone()"); } -function d3d_draw_wall(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat) { ErrorFunction("d3d_draw_wall()"); } - function d3d_set_perspective(enable) { ErrorFunction("d3d_set_perspective()"); } function d3d_set_projection(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup) { ErrorFunction("d3d_set_projection()"); } function d3d_set_projection_ext(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup,angle,aspect,zn,zf) { ErrorFunction("d3d_set_projection_ext()"); } @@ -235,15 +228,6 @@ function InitD3DFunctions() { d3d_transform_stack_top = WebGL_d3d_transform_stack_top_RELEASE; d3d_transform_stack_discard = WebGL_d3d_transform_stack_discard_RELEASE; - - // Stock geometry primitive drawing routines - d3d_draw_floor = WebGL_d3d_draw_floor_RELEASE; - d3d_draw_ellipsoid = WebGL_d3d_draw_ellipsoid_RELEASE; - d3d_draw_block = WebGL_d3d_draw_block_RELEASE; - d3d_draw_cylinder = WebGL_d3d_draw_cylinder_RELEASE; - d3d_draw_cone = WebGL_d3d_draw_cone_RELEASE; - d3d_draw_wall = WebGL_d3d_draw_wall_RELEASE; - // Lighting d3d_set_lighting = WebGL_d3d_set_lighting_RELEASE; d3d_light_define_direction = WebGL_d3d_light_define_direction_RELEASE; @@ -562,306 +546,6 @@ function WebGL_d3d_set_projection_perspective_RELEASE(x,y,w,h,angle) { // g_webGL.SetCullOrder((g_RenderTargetActive < 0) ? yyGL.Cull_CCW : yyGL.Cull_CW); } -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_draw_floor_RELEASE(x1, y1, z1, x2, y2, z2, texid, hrepeat, vrepeat) { - - var oldrep = texture_get_repeat(); - texture_set_repeat(true); - - // Draw the primitive - d3d_primitive_begin_texture(PrimType_TRIFAN, texid); - { - d3d_vertex_normal_texture(x1,y1,z1,0,0,1,0,0); - d3d_vertex_normal_texture(x1,y2,z1,0,0,1,0,vrepeat); - d3d_vertex_normal_texture(x2,y2,z2,0,0,1,hrepeat,vrepeat); - d3d_vertex_normal_texture(x2,y1,z2,0,0,1,hrepeat,0); - } - d3d_primitive_end(); - - // Restore things - texture_set_repeat(oldrep); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_draw_ellipsoid_RELEASE(x1, y1, z1, x2, y2, z2, texid, hrep, vrep, steps) { - - var oldrep = texture_get_repeat(); - texture_set_repeat(true); - - // Correct number of steps - if (steps < 3) { - steps = 3; - } - if (steps > 128) { - steps = 128; - } - - // Create sin and cos tables - var cc = []; // [129] - var ss = []; // [129] - for (var i = 0; i <= steps; i++) - { - cc[i] = Math.cos(i*2.0*Math.PI / steps); - ss[i] = Math.sin(i*2.0*Math.PI / steps); - } - - var mx = (x2 + x1) / 2, - my = (y2 + y1) / 2, - mz = (z2 + z1) / 2, - rx = (x2 - x1) / 2, - ry = (y2 - y1) / 2, - rz = (z2 - z1) / 2; - - // Draw the primitive in the box - var rows = (steps + 1) / 2; - for (var j= 0; j < rows; j++) - { - var rh1 = Math.cos(j * Math.PI / rows), - rd1 = Math.sin(j * Math.PI / rows), - rh2 = Math.cos((j+1) * Math.PI / rows), - rd2 = Math.sin((j+1) * Math.PI / rows); - - d3d_primitive_begin_texture(PrimType_TRISTRIP, texid); - for (var i = 0; i <= steps; i++) - { - d3d_vertex_normal_texture(mx+rx*rd1*cc[i], my+ry*rd1*ss[i], mz+rz*rh1,rd1*cc[i], rd1*ss[i], rh1, hrep*i/steps, j*vrep/rows); - d3d_vertex_normal_texture(mx+rx*rd2*cc[i], my+ry*rd2*ss[i], mz+rz*rh2,rd2*cc[i], rd2*ss[i], rh2, hrep*i/steps, (j+1)*vrep/rows); - } - d3d_primitive_end(); - } - - // Restore things - texture_set_repeat(oldrep); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_draw_block_RELEASE(x1,y1,z1,x2,y2,z2,texid,hrep,vrep) { - - var oldrep = texture_get_repeat(); - texture_set_repeat(true); - - d3d_primitive_begin_texture(PrimType_TRILIST, texid); - { - d3d_vertex_normal_texture(x1,y1,z1,0,0,-1,0,0); - d3d_vertex_normal_texture(x1,y2,z1,0,0,-1,0,vrep); - d3d_vertex_normal_texture(x2,y2,z1,0,0,-1,hrep,vrep); - - d3d_vertex_normal_texture(x2,y2,z1,0,0,-1,hrep,vrep); - d3d_vertex_normal_texture(x2,y1,z1,0,0,-1,hrep,0); - d3d_vertex_normal_texture(x1,y1,z1,0,0,-1,0,0); - } - - { - d3d_vertex_normal_texture(x1,y1,z2,0,0,1,0,0); - d3d_vertex_normal_texture(x2,y1,z2,0,0,1,hrep,0); - d3d_vertex_normal_texture(x2,y2,z2,0,0,1,hrep,vrep); - - d3d_vertex_normal_texture(x2,y2,z2,0,0,1,hrep,vrep); - d3d_vertex_normal_texture(x1,y2,z2,0,0,1,0,vrep); - d3d_vertex_normal_texture(x1,y1,z2,0,0,1,0,0); - } - - { - d3d_vertex_normal_texture(x1,y2,z1,0,1,0,0,0); - d3d_vertex_normal_texture(x1,y2,z2,0,1,0,0,vrep); - d3d_vertex_normal_texture(x2,y2,z2,0,1,0,hrep,vrep); - - d3d_vertex_normal_texture(x2,y2,z2,0,1,0,hrep,vrep); - d3d_vertex_normal_texture(x2,y2,z1,0,1,0,hrep,0); - d3d_vertex_normal_texture(x1,y2,z1,0,1,0,0,0); - } - - { - d3d_vertex_normal_texture(x2,y2,z1,1,0,0,0,0); - d3d_vertex_normal_texture(x2,y2,z2,1,0,0,0,vrep); - d3d_vertex_normal_texture(x2,y1,z2,1,0,0,hrep,vrep); - - d3d_vertex_normal_texture(x2,y1,z2,1,0,0,hrep,vrep); - d3d_vertex_normal_texture(x2,y1,z1,1,0,0,hrep,0); - d3d_vertex_normal_texture(x2,y2,z1,1,0,0,0,0); - } - - { - d3d_vertex_normal_texture(x2,y1,z1,0,-1,0,0,0); - d3d_vertex_normal_texture(x2,y1,z2,0,-1,0,0,vrep); - d3d_vertex_normal_texture(x1,y1,z2,0,-1,0,hrep,vrep); - - d3d_vertex_normal_texture(x1,y1,z2,0,-1,0,hrep,vrep); - d3d_vertex_normal_texture(x1,y1,z1,0,-1,0,hrep,0); - d3d_vertex_normal_texture(x2,y1,z1,0,-1,0,0,0); - } - - { - d3d_vertex_normal_texture(x1,y1,z1,-1,0,0,0,0); - d3d_vertex_normal_texture(x1,y1,z2,-1,0,0,0,vrep); - d3d_vertex_normal_texture(x1,y2,z2,-1,0,0,hrep,vrep); - - d3d_vertex_normal_texture(x1,y2,z2,-1,0,0,hrep,vrep); - d3d_vertex_normal_texture(x1,y2,z1,-1,0,0,hrep,0); - d3d_vertex_normal_texture(x1,y1,z1,-1,0,0,0,0); - } - d3d_primitive_end(); - - // Restore things - texture_set_repeat(oldrep); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_draw_cylinder_RELEASE(x1,y1,z1,x2,y2,z2,texid,hrep,vrep,closed,steps) { - - var cc = []; - var ss = []; - - var oldrep = texture_get_repeat(); - texture_set_repeat(true); - - // Correct number of steps - if (steps < 3) { steps = 3; } - if (steps > 128){ steps = 128; } - - - // Create sin and cos tables - for (var i = 0; i <= steps; i++) - { - cc[i] = Math.cos(i * 2.0 * Math.PI / steps); - ss[i] = Math.sin(i * 2.0 * Math.PI / steps); - } - var mx = (x2+x1)/2.0; - var my = (y2+y1)/2.0; - var rx = (x2-x1)/2.0; - var ry = (y2-y1)/2.0; - - // Draw the primitive in the box - if (true == closed) - { - d3d_primitive_begin_texture(PrimType_TRIFAN, texid); - d3d_vertex_normal_texture(mx,my,z2,0,0,1,0,vrep); - for (var i = 0; i <= steps; i++) - { - d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z2,0,0,1,0,vrep); - } - d3d_primitive_end(); - } - - - d3d_primitive_begin_texture(PrimType_TRISTRIP, texid); - for (var i = 0; i <= steps; i++) - { - d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z2,cc[i],ss[i],0,hrep*i/steps,vrep); - d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z1,cc[i],ss[i],0,hrep*i/steps,0); - } - d3d_primitive_end(); - - - if (true == closed) - { - d3d_primitive_begin_texture(PrimType_TRIFAN, texid); - d3d_vertex_normal_texture(mx,my,z1,0,0,-1,0,0); - for (var i = steps; i >= 0; i--) - { - d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z1,0,0,-1,0,0); - } - d3d_primitive_end(); - } - - // Restore things - texture_set_repeat(oldrep); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_draw_cone_RELEASE(x1,y1,z1,x2,y2,z2,texid,hrep,vrep,closed,steps) { - - var cc = []; - var ss = []; - - var oldrep = texture_get_repeat(); - texture_set_repeat(true); - - // Correct number of steps - if (steps < 3) { steps = 3; } - if (steps > 128){ steps = 128; } - - // Create sin and cos tables - for (var i = 0; i <= steps; i++) - { - cc[i] = Math.cos(i * 2.0 * Math.PI / steps); - ss[i] = Math.sin(i * 2.0 * Math.PI / steps); - } - - var mx = (x2+x1)/2.0; - var my = (y2+y1)/2.0; - var rx = (x2-x1)/2.0; - var ry = (y2-y1)/2.0; - - // Draw the primitive in the box - d3d_primitive_begin_texture(PrimType_TRISTRIP, texid); - for (var i = 0; i <= steps; i++) - { - d3d_vertex_normal_texture(mx,my,z2,0,0,1,hrep*i/steps,vrep); - d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z1,cc[i],ss[i],0,hrep*i/steps,0); - } - d3d_primitive_end(); - - if (true == closed) - { - d3d_primitive_begin_texture(PrimType_TRIFAN, texid); - d3d_vertex_normal_texture(mx,my,z1,0,0,-1,0,0); - for (var i = steps; i >= 0; i--) - { - d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z1,0,0,-1,0,0); - } - d3d_primitive_end(); - } - - // Restore things - texture_set_repeat(oldrep); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_draw_wall_RELEASE(x1,y1,z1,x2,y2,z2,texid,hrep,vrep) { - - var oldrep = texture_get_repeat(); - texture_set_repeat(true); - - // Draw the primitive - var l = Math.sqrt(Sqr(x2 - x1) + Sqr(y2 - y1)); - if (l == 0.0) { - return; - } - - var nx = (y2-y1) / l; - var ny = -(x2-x1) / l; - d3d_primitive_begin_texture(PrimType_TRIFAN, texid); - { - d3d_vertex_normal_texture(x1,y1,z1,nx,ny,0,0,0); - d3d_vertex_normal_texture(x2,y2,z1,nx,ny,0,hrep,0); - d3d_vertex_normal_texture(x2,y2,z2,nx,ny,0,hrep,vrep); - d3d_vertex_normal_texture(x1,y1,z2,nx,ny,0,0,vrep); - } - d3d_primitive_end(); - - // Restore things - texture_set_repeat(oldrep); -} - // ############################################################################################# /// Function: From 036ff0e26be5646f940e119c092531f36ecb5eca Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 15:14:23 +0300 Subject: [PATCH 09/84] Removed d3d_set_projection_* functions, *except* for WebGL_d3d_set_projection_ortho_RELEASE, which is used by surface_copy[_part] --- scripts/functions/Function_D3D.js | 71 +------------------------------ 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js index 2b36e0af..fcd3b4dd 100644 --- a/scripts/functions/Function_D3D.js +++ b/scripts/functions/Function_D3D.js @@ -35,10 +35,7 @@ function d3d_get_lighting() function d3d_set_perspective(enable) { ErrorFunction("d3d_set_perspective()"); } -function d3d_set_projection(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup) { ErrorFunction("d3d_set_projection()"); } -function d3d_set_projection_ext(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup,angle,aspect,zn,zf) { ErrorFunction("d3d_set_projection_ext()"); } -function d3d_set_projection_ortho(x,y,w,h,angle) { ErrorFunction("d3d_set_projection_ortho()"); } -function d3d_set_projection_perspective(x,y,w,h,angle) { ErrorFunction("d3d_set_projection_perspective()"); } + function d3d_transform_set_identity() { ErrorFunction("d3d_transform_set_identity()"); } function d3d_transform_set_translation(xt,yt,zt) { ErrorFunction("d3d_transform_set_translation()"); } @@ -201,10 +198,6 @@ function InitD3DFunctions() { // Matrix operations d3d_set_perspective = WebGL_d3d_set_perspective_RELEASE; - d3d_set_projection = WebGL_d3d_set_projection_RELEASE; - d3d_set_projection_ext = WebGL_d3d_set_projection_ext_RELEASE; - d3d_set_projection_ortho = WebGL_d3d_set_projection_ortho_RELEASE; - d3d_set_projection_perspective = WebGL_d3d_set_projection_perspective_RELEASE; d3d_transform_set_identity = WebGL_d3d_transform_set_identity_RELEASE; d3d_transform_set_translation = WebGL_d3d_transform_set_translation_RELEASE; @@ -465,46 +458,6 @@ function WebGL_d3d_get_lighting_RELEASE() { return GR_LightingEnabled; } -// ############################################################################################# -/// Function: -/// It's called set_project. It sets the view matrix. -/// Sometimes I don't cry myself to sleep. Sometimes. -/// -// ############################################################################################# -function WebGL_d3d_set_projection_RELEASE(xfrom, yfrom, zfrom, xto, yto, zto, xup, yup, zup) { - - var view = new Matrix(); - - var pos = new Vector3(xfrom, yfrom, zfrom); - var at = new Vector3(xto, yto, zto); - var up = new Vector3(xup, yup, zup); - view.LookAtLH(pos, at, up); - - g_webGL.SetViewMatrix(view); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_set_projection_ext_RELEASE(xfrom, yfrom, zfrom, xto, yto, zto, xup, yup, zup, angle, aspect, znear, zfar) { - - var view = new Matrix(); - - var pos = new Vector3(xfrom, yfrom, zfrom); - var at = new Vector3(xto, yto, zto); - var up = new Vector3(xup, yup, zup); - view.LookAtLH(pos, at, up); - - var proj = new Matrix(); - proj.PerspectiveFovLH(angle, aspect, znear, zfar); - proj.m[_22] *= g_RenderTargetActive; - - g_webGL.SetViewMatrix(view); - g_webGL.SetProjectionMatrix(proj); - //g_webGL.SetCullOrder((g_RenderTargetActive < 0) ? yyGL.Cull_CCW : yyGL.Cull_CW); -} - // ############################################################################################# /// Function: /// @@ -525,28 +478,6 @@ function WebGL_d3d_set_projection_ortho_RELEASE(x,y,w,h,angle) { // g_webGL.SetCullOrder((g_RenderTargetActive < 0) ? yyGL.Cull_CCW : yyGL.Cull_CW); } -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_set_projection_perspective_RELEASE(x,y,w,h,angle) { - - var view = new Matrix(); - var v1 = new Vector3(x + (w/2.0), y + (h/2.0), -w); - var v2 = new Vector3(x + (w/2.0), y + (h/2.0), 0.0); - var v3 = new Vector3(Math.sin(-angle*(Math.PI/180.0)), Math.cos(-angle*(Math.PI/180.0)), 0.0); - view.LookAtLH(v1, v2, v3); - - var proj = new Matrix(); - proj.PerspectiveLH(1.0, ( h/w), 1.0, 32000.0); - proj.m[_22] *= g_RenderTargetActive; - - g_webGL.SetViewMatrix(view); - g_webGL.SetProjectionMatrix(proj); - // g_webGL.SetCullOrder((g_RenderTargetActive < 0) ? yyGL.Cull_CCW : yyGL.Cull_CW); -} - - // ############################################################################################# /// Function: /// From c85ea217e9a2114a9974707fa42ca17719633642 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 16:01:01 +0300 Subject: [PATCH 10/84] Removed a few d3d state functions that aren't used elsewhere (start, end, hidden, culling, shading, zwriteenable) --- scripts/functions/Function_D3D.js | 86 +------------------------------ 1 file changed, 1 insertion(+), 85 deletions(-) diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js index fcd3b4dd..f6a6c76f 100644 --- a/scripts/functions/Function_D3D.js +++ b/scripts/functions/Function_D3D.js @@ -12,18 +12,11 @@ // -------------------------------------------------------------------------------------------------------------------------------------------------- // WebGL supported -function d3d_start() { ErrorFunction("d3d_start()"); } -function d3d_end() { ErrorFunction("d3d_end()"); } - -function d3d_set_hidden(enable) { ErrorFunction("d3d_set_hidden()"); } -function d3d_set_culling(cull) { ErrorFunction("d3d_set_culling()"); } -function d3d_set_shading(smooth) { ErrorFunction("d3d_set_shading()"); } -function d3d_set_zwriteenable(on_off) { ErrorFunction("d3d_set_zwriteenable()"); } function d3d_set_depth(depth) { ErrorFunction("d3d_set_depth()"); } function draw_set_color_write_enable(red, green, blue, alpha) { ErrorFunction("draw_set_color_write_enable()"); } var draw_set_colour_write_enable = draw_set_color_write_enable; -function d3d_set_lighting(enable) { ErrorFunction("d3d_set_shading()"); } +function d3d_set_lighting(enable) { ErrorFunction("d3d_set_lighting()"); } function d3d_light_define_direction(ind,dx,dy,dz,col) { ErrorFunction("d3d_light_define_direction()"); } function d3d_light_define_point(ind,x,y,z,range,col) { ErrorFunction("d3d_light_define_point()"); } function d3d_light_enable(ind,enable) { ErrorFunction("d3d_light_enable()"); } @@ -185,14 +178,7 @@ function InitD3DFunctions() { return; } // 3D state - d3d_start = WebGL_d3d_start_RELEASE; - d3d_end = WebGL_d3d_end_RELEASE; - - d3d_set_culling = WebGL_d3d_set_culling_RELEASE; - d3d_set_shading = WebGL_d3d_set_shading_RELEASE; - d3d_set_zwriteenable = WebGL_d3d_set_zwriteenable_RELEASE; d3d_set_depth = WebGL_d3d_set_depth_RELEASE; - d3d_set_hidden = WebGL_d3d_set_hidden_RELEASE; draw_set_color_write_enable = WebGL_draw_set_color_write_enable_RELEASE; draw_set_colour_write_enable = WebGL_draw_set_color_write_enable_RELEASE; @@ -330,66 +316,6 @@ function InitD3DFunctions() { g_matstack[0] = new Matrix(); // this should create a unit matrix } -// ############################################################################################# -/// Function: -/// Indicate we should use perspective projection matrices and 3D vertices -/// -// ############################################################################################# -function WebGL_d3d_start_RELEASE() { - - GR_3DMode = true; - - // Force in 3D specific states - g_webGL.SetZEnable(GR_ZEnable); - g_webGL.SetZWriteEnable(GR_ZWriteEnable); - g_webGL.SetCull(GR_Cull); -} - -// ############################################################################################# -/// Function: -/// Indicate we're dropping back to 2D rendering -/// -// ############################################################################################# -function WebGL_d3d_end_RELEASE() { - - GR_3DMode = false; - - // Force in states that're default to 2D mode - g_webGL.SetZEnable(false); - g_webGL.SetZWriteEnable(false); - g_webGL.SetCull(false); -} - -// ############################################################################################# -/// Function: -/// Set back face culling state -/// -// ############################################################################################# -function WebGL_d3d_set_culling_RELEASE(_cull) { - - GR_Cull = _cull > 0.5; - g_webGL.SetCull(GR_Cull); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_set_shading_RELEASE(_smooth) { - - // shadeModel is not available on webgl (gl_ES) -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_set_zwriteenable_RELEASE(_onoff) { - - GR_ZWriteEnable = (_onoff > 0.5); - g_webGL.SetZWriteEnable(GR_ZWriteEnable); -} - // ############################################################################################# /// Function: /// @@ -405,16 +331,6 @@ function WebGL_d3d_set_depth_RELEASE(_newdepth) { } } -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_set_hidden_RELEASE(_hidden) { - - GR_ZEnable = (_hidden > 0.5); - g_webGL.SetZEnable(GR_ZEnable); -} - // ############################################################################################# /// Function: /// From 5d1043df1a70b2c19536c4479b6a6314e5b14e4e Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 4 Aug 2023 16:16:47 +0300 Subject: [PATCH 11/84] Removed the d3d_transform_* functions and the associated g_MatrixStack legacy helpers along with them. --- scripts/functions/Function_D3D.js | 288 ------------------------------ scripts/yyWebGL.js | 107 +---------- 2 files changed, 1 insertion(+), 394 deletions(-) diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js index f6a6c76f..cc54de53 100644 --- a/scripts/functions/Function_D3D.js +++ b/scripts/functions/Function_D3D.js @@ -26,24 +26,8 @@ function d3d_light_get(index) function d3d_light_get_ambient(index) { ErrorFunction("d3d_light_get_ambient()"); } function d3d_get_lighting() { ErrorFunction("d3d_get_lighting()"); } - function d3d_set_perspective(enable) { ErrorFunction("d3d_set_perspective()"); } - -function d3d_transform_set_identity() { ErrorFunction("d3d_transform_set_identity()"); } -function d3d_transform_set_translation(xt,yt,zt) { ErrorFunction("d3d_transform_set_translation()"); } -function d3d_transform_set_scaling(xs,ys,zs) { ErrorFunction("d3d_transform_set_scaling()"); } -function d3d_transform_set_rotation_x(angle) { ErrorFunction("d3d_transform_set_rotation_x()"); } -function d3d_transform_set_rotation_y(angle) { ErrorFunction("d3d_transform_set_rotation_y()"); } -function d3d_transform_set_rotation_z(angle) { ErrorFunction("d3d_transform_set_rotation_z()"); } -function d3d_transform_set_rotation_axis(xa,ya,za,angle) { ErrorFunction("d3d_transform_set_rotation_axis()"); } -function d3d_transform_add_translation(xt,yt,zt) { ErrorFunction("d3d_transform_add_translation()"); } -function d3d_transform_add_scaling(xs,ys,zs) { ErrorFunction("d3d_transform_add_scaling()"); } -function d3d_transform_add_rotation_x(angle) { ErrorFunction("d3d_transform_add_rotation_x()"); } -function d3d_transform_add_rotation_y(angle) { ErrorFunction("d3d_transform_add_rotation_y()"); } -function d3d_transform_add_rotation_z(angle) { ErrorFunction("d3d_transform_add_rotation_axis()"); } -function d3d_transform_add_rotation_axis(xa,ya,za,angle) { ErrorFunction("d3d_transform_add_rotation_z()"); } -function d3d_transform_vertex(_x, _y, _z) { ErrorFunction("d3d_transform_vertex()"); } function matrix_get(_type) { ErrorFunction("matrix_get()"); } function matrix_set(_type, _matrix) { ErrorFunction("matrix_set()"); } // RK :: Changed these as they are mathematical in nature and not specific to WebGL @@ -66,15 +50,6 @@ var matrix_build_projection_perspective = WebGL_matrix_build_projection_perspect var matrix_build_projection_perspective_fov = WebGL_matrix_build_projection_perspective_fov; - -function d3d_transform_stack_clear() { ErrorFunction("d3d_transform_stack_clear()"); } -function d3d_transform_stack_empty() { ErrorFunction("d3d_transform_stack_empty()"); } -function d3d_transform_stack_push() { ErrorFunction("d3d_transform_stack_push()"); } -function d3d_transform_stack_pop() { ErrorFunction("d3d_transform_stack_pop()"); } -function d3d_transform_stack_top() { ErrorFunction("d3d_transform_stack_top()"); } -function d3d_transform_stack_discard() { ErrorFunction("d3d_transform_stack_discard()"); } - - function gpu_set_blendenable(enable) { ErrorFunction("gpu_set_blendenable()"); } function gpu_set_ztestenable(enable) { ErrorFunction("gpu_set_ztestenable()"); } function gpu_set_zfunc(cmp_func) { ErrorFunction("gpu_set_zfunc()"); } @@ -185,28 +160,6 @@ function InitD3DFunctions() { // Matrix operations d3d_set_perspective = WebGL_d3d_set_perspective_RELEASE; - d3d_transform_set_identity = WebGL_d3d_transform_set_identity_RELEASE; - d3d_transform_set_translation = WebGL_d3d_transform_set_translation_RELEASE; - d3d_transform_set_scaling = WebGL_d3d_transform_set_scaling_RELEASE; - d3d_transform_set_rotation_x = WebGL_d3d_transform_set_rotation_x_RELEASE; - d3d_transform_set_rotation_y = WebGL_d3d_transform_set_rotation_y_RELEASE; - d3d_transform_set_rotation_z = WebGL_d3d_transform_set_rotation_z_RELEASE; - d3d_transform_set_rotation_axis = WebGL_d3d_transform_set_rotation_axis_RELEASE; - d3d_transform_add_translation = WebGL_d3d_transform_add_translation_RELEASE; - d3d_transform_add_scaling = WebGL_d3d_transform_add_scaling_RELEASE; - d3d_transform_add_rotation_x = WebGL_d3d_transform_add_rotation_x_RELEASE; - d3d_transform_add_rotation_y = WebGL_d3d_transform_add_rotation_y_RELEASE; - d3d_transform_add_rotation_z = WebGL_d3d_transform_add_rotation_z_RELEASE; - d3d_transform_add_rotation_axis = WebGL_d3d_transform_add_rotation_axis_RELEASE; - d3d_transform_vertex = WebGL_d3d_transform_vertex_RELEASE; - - d3d_transform_stack_clear = WebGL_d3d_transform_stack_clear_RELEASE; - d3d_transform_stack_empty = WebGL_d3d_transform_stack_empty_RELEASE; - d3d_transform_stack_push = WebGL_d3d_transform_stack_push_RELEASE; - d3d_transform_stack_pop = WebGL_d3d_transform_stack_pop_RELEASE; - d3d_transform_stack_top = WebGL_d3d_transform_stack_top_RELEASE; - d3d_transform_stack_discard = WebGL_d3d_transform_stack_discard_RELEASE; - // Lighting d3d_set_lighting = WebGL_d3d_set_lighting_RELEASE; d3d_light_define_direction = WebGL_d3d_light_define_direction_RELEASE; @@ -572,247 +525,6 @@ function WebGL_d3d_set_fog_RELEASE(enable,colour,start,end) { g_webGL.SetFogData(GR_FogParameters); } - - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_set_identity_RELEASE() { - - WebGL_SetMatrix(MATRIX_WORLD, new Matrix()); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_set_translation_RELEASE(xt,yt,zt) { - - var m = new Matrix(); - m.SetTranslation(xt, yt, zt); - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_set_scaling_RELEASE(xs,ys,zs) { - - var m = new Matrix(); - m.SetScale(xs, ys, zs); - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_set_rotation_x_RELEASE(angle) { - - var m = new Matrix(); - m.SetXRotation(angle); - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_set_rotation_y_RELEASE(angle) { - - var m = new Matrix(); - m.SetYRotation(angle); - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_set_rotation_z_RELEASE(angle) { - - var m = new Matrix(); - m.SetZRotation(angle); - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_set_rotation_axis_RELEASE(xa,ya,za,angle) { - - var m = new Matrix(); - m.SetRotationAxis(new Vector3(xa, ya, za), -angle); - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_add_translation_RELEASE(xt,yt,zt) { - - var mt = new Matrix(); - mt.SetTranslation(xt, yt, zt); - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - var m = new Matrix(); - m.Multiply(mo, mt); - - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_add_scaling_RELEASE(xs,ys,zs) { - - var ms = new Matrix(); - ms.SetScale(xs, ys, zs); - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - var m = new Matrix(); - m.Multiply(mo, ms); - - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_add_rotation_x_RELEASE(angle) { - - var mr = new Matrix(); - mr.SetXRotation(angle); - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - var m = new Matrix(); - m.Multiply(mo, mr); - - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_add_rotation_y_RELEASE(angle) { - - var mr = new Matrix(); - mr.SetYRotation(angle); - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - var m = new Matrix(); - m.Multiply(mo, mr); - - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_add_rotation_z_RELEASE(angle) { - - var mr = new Matrix(); - mr.SetZRotation(angle); - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - var m = new Matrix(); - m.Multiply(mo, mr); - - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_add_rotation_axis_RELEASE(xa,ya,za,angle) { - - var mr = new Matrix(); - mr.SetRotationAxis(new Vector3(xa, ya, za), -angle); - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - var m = new Matrix(); - m.Multiply(mo, mr); - - WebGL_SetMatrix(MATRIX_WORLD, m); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_vertex_RELEASE(_x, _y, _z) { - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - var xx = (mo.m[_11]*_x) + (mo.m[_21]*_y) + (mo.m[_31]*_z) + mo.m[_41]; - var yy = (mo.m[_12]*_x) + (mo.m[_22]*_y) + (mo.m[_32]*_z) + mo.m[_42]; - var zz = (mo.m[_13]*_x) + (mo.m[_23]*_y) + (mo.m[_33]*_z) + mo.m[_43]; - - var r=[]; - r[0]=xx; - r[1]=yy; - r[2]=zz; - return r; -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_stack_clear_RELEASE() { - MatrixStackClear(); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_stack_empty_RELEASE() { - return MatrixStackEmpty(); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_stack_push_RELEASE() { - - var mo = WebGL_GetMatrix(MATRIX_WORLD); - return PushMatrix(mo); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_stack_pop_RELEASE() { - return PopMatrix(); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_stack_top_RELEASE() { - return SetTopMatrix(); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_transform_stack_discard_RELEASE() { - return DiscardTopMatrix(); -} - //matrix_get = WebGL_Matrix_Get; //matrix_set = WebGL_Matrix_Set; //matrix_build = WebGL_Matrix_Build; diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index 57e82bd3..fdc818a1 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -59,9 +59,7 @@ var GR_MarkVertCorners = false, // Store the set of shader programs created from the user's project var g_shaderPrograms = []; -var g_Matrix = null, - g_MatrixStack = null, - g_MatrixSP = 0; +var g_Matrix = null; // Constants for matrix stack var MATRIX_VIEW = 0, @@ -258,12 +256,6 @@ function InitWebGL(_canvas) { if (!InitShaders()) return false; if (!InitTextures()) return false; if (!InitLightingEnv()) return false; - - g_MatrixStack = []; - for (var i = 0; i < MATRIX_STACK_MAX; i++) { - g_MatrixStack[i] = new Matrix(); - } - g_MatrixSP = -1; g_RenderTargetActive = 1; g_pProjection = new Matrix(); @@ -868,103 +860,6 @@ function WebGL_DrawText_RELEASE(_font, _str, _x, _y, _xscale, _yscale, _angle, _ //WebGL_TextureDrawWH_RELEASE( g_webGL_textureFont, 0, 0, width, height, _x, _y, _xscale, _yscale, _angle, _col, _col, _col, _col, _alpha ); } -// ############################################################################################# -/// Function: -/// Push a matrix onto our stack -/// -/// -/// In: Matrix to push onto the stack -// ############################################################################################# -function PushMatrix(_matrix) { - - if (g_MatrixSP >= MATRIX_STACK_MAX) { - return false; - } - - g_MatrixSP++; - if (g_MatrixSP == 0) { - g_MatrixStack[g_MatrixSP] = new Matrix(_matrix); - } - else { - g_MatrixStack[g_MatrixSP].Multiply(g_MatrixStack[g_MatrixSP - 1], _matrix); - } - return true; -} - -// ############################################################################################# -/// Function: -/// Pop the top matrix off the stack -/// -/// -/// In: -/// Out: -/// -/// -// ############################################################################################# -function PopMatrix(_matrix) { - - if (g_MatrixSP < 0) { - return false; - } - - // Set Matrix to that currently on top - WebGL_SetMatrix(MATRIX_WORLD, g_MatrixStack[g_MatrixSP]); - g_MatrixSP--; - return true; -} - -// ############################################################################################# -/// Function: -/// Clear off the matrix stack altogether -/// -// ############################################################################################# -function MatrixStackClear() { - g_MatrixSP = -1; -} - -// ############################################################################################# -/// Function: -/// Checks to see if the matrix stack is empty -/// -// ############################################################################################# -function MatrixStackEmpty() { - - if (g_MatrixSP < 0) { - return true; - } - return false; -} - -// ############################################################################################# -/// Function: -/// Set the top matrix as the current one but don't remove it -/// -// ############################################################################################# -function SetTopMatrix() { - - if (g_MatrixSP < 0) { - return false; - } - // Set Matrix to that currently on top - WebGL_SetMatrix(MATRIX_WORLD, g_MatrixStack[g_MatrixSP]); - return true; -} - - -// ############################################################################################# -/// Function: -/// Discard the top matrix -/// -// ############################################################################################# -function DiscardTopMatrix() { - - if (g_MatrixSP < 0) { - return false; - } - g_MatrixSP--; - return true; -} - // ############################################################################################# /// Function: /// Draw a simple TPage entry. From e83bb4034e679d5c64ea697a3b15e30442a4c4a7 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 10:22:07 +0300 Subject: [PATCH 12/84] Some conditional tagging for bigger things that aren't used in every game --- scripts/LoadGame.js | 2 ++ scripts/_GameMaker.js | 16 ++++++++++++---- scripts/device/Gamepad.js | 2 ++ scripts/functions/Function_Debug.js | 4 ++++ scripts/functions/Function_Instance.js | 2 ++ scripts/functions/collections/ds_grid.js | 6 ++++-- scripts/jsBox2D/jsliquidfun.js | 4 +++- scripts/jsgif/GIFEncoder.js | 2 ++ scripts/jsgif/LZWEncoder.js | 2 ++ scripts/jsgif/NeuQuant.js | 2 ++ scripts/physics/yyPhysicsDebugRender.js | 3 ++- scripts/physics/yyPhysicsFixture.js | 4 +++- scripts/physics/yyPhysicsJoint.js | 4 +++- scripts/physics/yyPhysicsObject.js | 4 +++- scripts/physics/yyPhysicsWorld.js | 2 ++ scripts/yyInstance.js | 13 +++++++++---- scripts/yyObject.js | 4 ++++ scripts/yyRoom.js | 12 +++++++++++- scripts/yyVariable.js | 2 ++ 19 files changed, 74 insertions(+), 16 deletions(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index c419fbac..d19a2438 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -36,7 +36,9 @@ function InitAboyne() global = new yyGameGlobals(); g_pBuiltIn = new yyBuiltIn(); g_pIOManager = new yyIOManager(); + /// @if feature("gamepad") g_pGamepadManager = new yyGamepadManager(); + /// @endif g_pBuiltIn.pointer_null = new ArrayBuffer(1); g_pBuiltIn.pointer_invalid = new ArrayBuffer(1); diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 8d5bc8e5..72d7254d 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -1196,7 +1196,9 @@ function StartRoom( _numb, _starting ) // Some global initialization //g_pIOManager.Clear(); + /// @if feature("gamepad") g_pGamepadManager.Clear(); + /// @endif // Kill all particles currently in flight //ParticleSystem_ClearParticles(); // don't do this, to match C++ runner @@ -1274,7 +1276,9 @@ function StartRoom( _numb, _starting ) if (ispersistent === false) { // Build the physics world for this room if not persistent and one is required + // @if feature("physics") g_RunRoom.BuildPhysicsWorld(); + // @endif // Loop through all instances in the storage of the room and create the ones NOT in the persistent list... g_RunRoom.ClearInstances(false); @@ -1349,7 +1353,9 @@ function StartRoom( _numb, _starting ) for (var u=0; u < persistent.length; u++) { g_RunRoom.m_Active.Add(persistent[u]); + // @if feature("physics") persistent[u].RebuildPhysicsBody(); + // @endif // Add persistent object to layer system if (g_isZeus) @@ -1570,7 +1576,7 @@ function UpdateActiveLists() { /// // ############################################################################################# function UpdateInstancePositions() { - + // @if feature("physics") if (g_RunRoom.m_pPhysicsWorld) { if(g_isZeus) { @@ -1579,9 +1585,9 @@ function UpdateInstancePositions() { else g_RunRoom.m_pPhysicsWorld.Update(g_RunRoom.m_speed); } - else { - g_pInstanceManager.UpdatePositions(); - } + else // -> + // @endif + g_pInstanceManager.UpdatePositions(); } // ############################################################################################# @@ -1611,7 +1617,9 @@ function GameMaker_DoAStep() { g_pIOManager.StartStep(); HandleOSEvents(); + /// @if feature("gamepad") g_pGamepadManager.Update(); + /// @endif g_pInstanceManager.RememberOldPositions(); // Remember old positions g_pInstanceManager.UpdateImages(); diff --git a/scripts/device/Gamepad.js b/scripts/device/Gamepad.js index 4cf961bb..1f1a59af 100644 --- a/scripts/device/Gamepad.js +++ b/scripts/device/Gamepad.js @@ -7,6 +7,7 @@ // Project: HTML5 // Description: GameMaker HTML5 gamepad interface. // ********************************************************************************************************************** +/// @if feature("gamepad") var g_pGamepadManager = null; var g_GamePadDeadZones = []; @@ -685,3 +686,4 @@ function yyGamepadManager() { return 0; }; }; +/// @endif \ No newline at end of file diff --git a/scripts/functions/Function_Debug.js b/scripts/functions/Function_Debug.js index e6fac9d7..4cf7b8cb 100644 --- a/scripts/functions/Function_Debug.js +++ b/scripts/functions/Function_Debug.js @@ -539,6 +539,7 @@ function get_integer(_str,_def) } +/// @if function("get_login_async") // ############################################################################################# /// Function: /// Create a login dialog @@ -623,6 +624,7 @@ function createLoginDialog( _dialogData ) login_dialog_update(); g_pASyncManager.Add(_dialogData.id, null, ASYNC_USER, g_dialogName); } // end createLoginDialog +/// @endif // ############################################################################################# /// Function: @@ -872,9 +874,11 @@ function YYDialogKick() { // get the first entry and kick that one switch( g_dialogs[0].type ) { + /// @if function("get_login_async") case DIALOG_TYPE_LOGIN: // login dialog createLoginDialog( g_dialogs[0] ); break; + /// @endif case DIALOG_TYPE_INPUT: // input dialog createInputDialog( g_dialogs[0] ); break; diff --git a/scripts/functions/Function_Instance.js b/scripts/functions/Function_Instance.js index 1371b220..e66970f8 100644 --- a/scripts/functions/Function_Instance.js +++ b/scripts/functions/Function_Instance.js @@ -523,7 +523,9 @@ function instance_change_RELEASE(_inst, _objindex, _perf) _inst.UpdateSpriteIndex(_inst.pObject.SpriteIndex); // Change over the physics body if one exists/should exist + // @if feature("physics") _inst.RebuildPhysicsBody(g_RunRoom); + // @endif if( _perf ) { _inst.PerformEvent(EVENT_PRE_CREATE, 0, _inst, _inst ); diff --git a/scripts/functions/collections/ds_grid.js b/scripts/functions/collections/ds_grid.js index 8ef0f275..cc53456f 100644 --- a/scripts/functions/collections/ds_grid.js +++ b/scripts/functions/collections/ds_grid.js @@ -34,7 +34,7 @@ function ds_set_precision(_prec) g_Precsision = yyGetReal(_prec); } - +/// @if function("ds_grid_*") // ############################################################################################# /// Function: @@ -2048,4 +2048,6 @@ function ds_grid_to_mp_grid(_src, _dest, _predicate) { } } } -} \ No newline at end of file +} + +/// @endif diff --git a/scripts/jsBox2D/jsliquidfun.js b/scripts/jsBox2D/jsliquidfun.js index 83bb5c30..19fdf4c8 100644 --- a/scripts/jsBox2D/jsliquidfun.js +++ b/scripts/jsBox2D/jsliquidfun.js @@ -1,3 +1,4 @@ +// @if feature("physics") (function() { 'use strict'; @@ -21114,4 +21115,5 @@ if (typeof(module) !== "undefined") else window["b2"] = b2; } -})(); \ No newline at end of file +})(); +// @endif \ No newline at end of file diff --git a/scripts/jsgif/GIFEncoder.js b/scripts/jsgif/GIFEncoder.js index 534b28cf..ca678b69 100644 --- a/scripts/jsgif/GIFEncoder.js +++ b/scripts/jsgif/GIFEncoder.js @@ -1,3 +1,4 @@ +/// @if function("gif_*") /** * This class lets you encode animated GIF files * Base class : http://www.java2s.com/Code/Java/2D-Graphics-GUI/AnimatedGifEncoder.htm @@ -619,3 +620,4 @@ GIFEncoder = function() { return exports; }; +/// @endif diff --git a/scripts/jsgif/LZWEncoder.js b/scripts/jsgif/LZWEncoder.js index 5a37bbb3..23f59092 100644 --- a/scripts/jsgif/LZWEncoder.js +++ b/scripts/jsgif/LZWEncoder.js @@ -1,3 +1,4 @@ +/// @if function("gif_*") /** * This class handles LZW encoding * Adapted from Jef Poskanzer's Java port by way of J. M. G. Elliott. @@ -275,3 +276,4 @@ LZWEncoder = function() { LZWEncoder.apply(this, arguments); return exports; }; +/// @endif diff --git a/scripts/jsgif/NeuQuant.js b/scripts/jsgif/NeuQuant.js index 12ceede0..61997c71 100644 --- a/scripts/jsgif/NeuQuant.js +++ b/scripts/jsgif/NeuQuant.js @@ -1,3 +1,4 @@ +/// @if function("gif_*") /* * NeuQuant Neural-Net Quantization Algorithm * ------------------------------------------ @@ -527,3 +528,4 @@ NeuQuant = function() { NeuQuant.apply(this, arguments); return exports; }; +/// @endif \ No newline at end of file diff --git a/scripts/physics/yyPhysicsDebugRender.js b/scripts/physics/yyPhysicsDebugRender.js index 3736ec11..834b35ef 100644 --- a/scripts/physics/yyPhysicsDebugRender.js +++ b/scripts/physics/yyPhysicsDebugRender.js @@ -9,6 +9,7 @@ // Description: // // ********************************************************************************************************************** +// @if feature("physics") // ############################################################################################# /// Function: @@ -157,4 +158,4 @@ function yyBox2DDrawParticles(centers, radius, colors, count) { true); } } - +// @endif diff --git a/scripts/physics/yyPhysicsFixture.js b/scripts/physics/yyPhysicsFixture.js index 3ad51091..899d420e 100644 --- a/scripts/physics/yyPhysicsFixture.js +++ b/scripts/physics/yyPhysicsFixture.js @@ -13,6 +13,7 @@ // 15/02/2012 1.0 CPH 1st version // // ********************************************************************************************************************** +// @if feature("physics") /** @constructor */ function yyPhysicsFixture() { //function yyPhysicsFixture(_fixtureID) { @@ -225,4 +226,5 @@ yyPhysicsFixture.prototype.SetAwake = function(_awake) { yyPhysicsFixture.prototype.SetKinematic = function() { this.m_kinematic = true; -}; \ No newline at end of file +}; +// @endif diff --git a/scripts/physics/yyPhysicsJoint.js b/scripts/physics/yyPhysicsJoint.js index 9ae07a33..ee4630ba 100644 --- a/scripts/physics/yyPhysicsJoint.js +++ b/scripts/physics/yyPhysicsJoint.js @@ -13,6 +13,7 @@ // 15/02/2012 1.0 CPH 1st version // // ********************************************************************************************************************** +// @if feature("physics") var JOINT_ANCHOR_1_X = 0, JOINT_ANCHOR_1_Y = 1, JOINT_ANCHOR_2_X = 2, @@ -377,4 +378,5 @@ yyPhysicsJoint.prototype.SetValue = function(_field, _value) { } break; } -}; \ No newline at end of file +}; +// @endif diff --git a/scripts/physics/yyPhysicsObject.js b/scripts/physics/yyPhysicsObject.js index 0485f3eb..877402e0 100644 --- a/scripts/physics/yyPhysicsObject.js +++ b/scripts/physics/yyPhysicsObject.js @@ -13,6 +13,7 @@ // 15/02/2012 1.0 CPH 1st version // // ********************************************************************************************************************** +// @if feature("physics") /** @constructor */ function yyPhysicsObject(_b2Body, _collisionCategory, _xo, _yo) { @@ -455,4 +456,5 @@ yyPhysicsObject.prototype.SetRestitution = function(_fixtureIndex, _val) { this.m_fixtures[_fixtureIndex].SetRestitution(_val); } -}; \ No newline at end of file +}; +// @endif diff --git a/scripts/physics/yyPhysicsWorld.js b/scripts/physics/yyPhysicsWorld.js index a7449491..400ed4e2 100644 --- a/scripts/physics/yyPhysicsWorld.js +++ b/scripts/physics/yyPhysicsWorld.js @@ -13,6 +13,7 @@ // 15/02/2012 1.0 CPH 1st version // // ********************************************************************************************************************** +// @if feature("physics") var PHYSICS_DEFAULT_UPDATE_ITERATIONS = 10, PHYSICS_COLLISION_CATEGORIES = 32, PHYSICS_DEBUG_RENDER_SHAPE = (1 << 0), @@ -2385,3 +2386,4 @@ yyPhysicsWorld.prototype.SetParticleRadius = function (_radius) { this.m_wor yyPhysicsWorld.prototype.SetParticleDensity = function (_density) { this.m_world.SetParticleDensity(_density); }; yyPhysicsWorld.prototype.SetParticleDamping = function (_damping) { this.m_world.SetParticleDamping(_damping); }; yyPhysicsWorld.prototype.SetParticleGravityScale = function (_scale){ this.m_world.SetParticleGravityScale(_scale); }; +// @endif diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index 757d89cc..8173e0ea 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -610,7 +610,8 @@ yyInstance.prototype = { set timeline_loop( _loop ) { this.timeline_looped = yyGetBool(_loop); }, - + + // @if feature("physics") // phy_rotation property get phy_rotation() { return this.__phy_rotation; }, set phy_rotation(_rotation) { @@ -749,6 +750,7 @@ yyInstance.prototype = { this.RefreshPhysicalProperties(this.m_physicsObject.m_physicsBody); } }, + // @endif physics properties // layer property get layer() { return this.m_nLayerID; }, @@ -955,7 +957,7 @@ yyInstance.prototype.UpdateSpriteIndex = function (_index) { /// // ############################################################################################# yyInstance.prototype.RebuildPhysicsBody = function (_room) { - + // @if feature("physics") // Null off pre-existing bodies to ensure that the data is entirely // rebuilt either now or later in the logic (e.g. room start event) if (_room && this.m_physicsObject) { @@ -970,6 +972,7 @@ yyInstance.prototype.RebuildPhysicsBody = function (_room) { this.BuildPhysicsBody(); this.bbox_dirty = true; } + // @endif }; // ############################################################################################# @@ -978,7 +981,7 @@ yyInstance.prototype.RebuildPhysicsBody = function (_room) { /// // ############################################################################################# yyInstance.prototype.BuildPhysicsBody = function () { - + // @if feature("physics") if (!this.pObject.PhysicsData.physicsObject) { return; } @@ -1070,6 +1073,7 @@ yyInstance.prototype.BuildPhysicsBody = function () { // And bind the fixture to get the physical object for this instance physics_fixture_bind(this, fixtureID, this.id, xoffs, yoffs); + // @endif BuildPhysicsBody }; // ############################################################################################# @@ -2875,6 +2879,7 @@ yyInstance.prototype.ApplyVisualOffset = function (_angle, _visualOffs) { /// Transfer across physics data to properties the user can access /// // ############################################################################################# +// @if feature("physics") yyInstance.prototype.RefreshPhysicalProperties = function (_physicsBody) { var TargetSpeed =g_RunRoom.GetSpeed(); @@ -3059,7 +3064,7 @@ yyInstance.prototype.set_physics_active = function(_isActive) { this.m_physicsObject.SetActive(yyGetBool(_isActive)); this.RefreshPhysicalProperties(this.m_physicsObject.m_physicsBody); }; - +// @endif physics helpers // ############################################################################################# diff --git a/scripts/yyObject.js b/scripts/yyObject.js index b3aa31ff..dec856ab 100644 --- a/scripts/yyObject.js +++ b/scripts/yyObject.js @@ -15,9 +15,11 @@ // // ********************************************************************************************************************** +// @if feature("physics") var OBJECT_PHYSICS_SHAPE_CIRCLE = 0, OBJECT_PHYSICS_SHAPE_BOX = 1, OBJECT_PHYSICS_SHAPE_POLY = 2; +// @endif physics constants // ############################################################################################# /// Function: @@ -616,6 +618,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { } // Physics data + // @if feature("physics") if (_pObjectStorage.physicsObject != undefined) { pObj.PhysicsData.physicsObject = _pObjectStorage.physicsObject; @@ -631,6 +634,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { pObj.PhysicsData.physicsKinematic = _pObjectStorage.physicsKinematic; pObj.PhysicsData.physicsShapeVertices = _pObjectStorage.physicsShapeVertices; } + // @endif physics } return pObj; } diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 784a1ecf..38231563 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -185,6 +185,7 @@ yyRoom.prototype.CloneStorage = function (_pStorage) { } // Physics world + // @if feature("physics") if ( _pStorage.physicsWorld ) { this.m_pStorage.physicsWorld = _pStorage.physicsWorld; @@ -196,6 +197,7 @@ yyRoom.prototype.CloneStorage = function (_pStorage) { this.m_pStorage.physicsGravityY = _pStorage.physicsGravityY; this.m_pStorage.physicsPixToMeters = _pStorage.physicsPixToMeters; } + // @endif physics world storage clone // 1.x backgrounds for (var i = 0; i < _pStorage.backgrounds.length; i++) @@ -551,6 +553,7 @@ yyRoom.prototype.CreateRoomFromStorage = function (_pRoomStorage) /// /// // ############################################################################################# +// @if feature("physics") yyRoom.prototype.BuildPhysicsWorld = function() { // evaluates to true if value is not: null, undefined, NaN, empty string, 0, false @@ -567,6 +570,7 @@ yyRoom.prototype.BuildPhysicsWorld = function() { this.m_pPhysicsWorld.SetGravity(this.m_pStorage.physicsGravityX, this.m_pStorage.physicsGravityY); } }; +// @endif BuildPhysicsWorld // ############################################################################################# /// Function: @@ -694,7 +698,9 @@ yyRoom.prototype.CreateInstance = function (_x, _y, _id, _objindex, _scaleX, _sc g_pLayerManager.BuildElementRuntimeData(this, elandlay.layer, elandlay.element); } } + // @if feature("physics") pinst.BuildPhysicsBody(); + // @endif // g_pLayerManager.AddInstance(this,pinst); return pinst; @@ -741,8 +747,10 @@ yyRoom.prototype.AddInstance = function (_x, _y, _id, _objindex, _overridedepth, g_pLayerManager.BuildElementRuntimeData(this, elandlay.layer, elandlay.element); } } - + + // @if feature("physics") pinst.BuildPhysicsBody(); + // @endif return pinst; }; @@ -774,7 +782,9 @@ yyRoom.prototype.AddLayerInstance = function (_x, _y, _layer, _id, _objindex) this.m_Active.Add(pinst); g_pInstanceManager.Add(pinst); + // @if feature("physics") pinst.BuildPhysicsBody(); + // @endif //this.m_NewInstances.push({ inst: pinst, type: 1, layer:_layer }); diff --git a/scripts/yyVariable.js b/scripts/yyVariable.js index d0687d83..b534b189 100644 --- a/scripts/yyVariable.js +++ b/scripts/yyVariable.js @@ -542,6 +542,7 @@ function computeIterationValues(_maxLength, _rawOffset, _rawLength) { /// true for ===, false for !=== /// // ############################################################################################# +/// @if function("array_equals") function array_equals(_a, _b) { // Both arguments must be arrays @@ -568,6 +569,7 @@ function array_equals(_a, _b) } return true; } // end array_equals +/// @endif array_equals function array_create( _size, _val ) { From 667f04b2d48a7c7d4b6e11db68c7519a0e000970 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 11:00:39 +0300 Subject: [PATCH 13/84] Removed GMS1 tiles "playfield" - not to be confused with GMS1 compatibility tile layers. --- scripts/Storage.js | 18 - scripts/functions/Function_Tiles.js | 748 ---------------------------- scripts/yyPlayfield.js | 222 --------- scripts/yyRoom.js | 93 ---- scripts/yyTile.js | 172 ------- 5 files changed, 1253 deletions(-) diff --git a/scripts/Storage.js b/scripts/Storage.js index 6abf9313..0b719104 100644 --- a/scripts/Storage.js +++ b/scripts/Storage.js @@ -98,24 +98,6 @@ function YYInstancesStorage() } -/** @constructor */ -function YYTileStorage() -{ - this.x = 0; - this.y = 0; - this.index = 0; - this.xo = 0; - this.yo = 0; - this.w = 0; - this.h = 0; - this.depth = 0; - this.id = 0; - this.scaleX = 1.0; - this.scaleY = 1.0; - this.colour = -1; -} - - /** @constructor */ function YYViewStorage() { diff --git a/scripts/functions/Function_Tiles.js b/scripts/functions/Function_Tiles.js index c837c61a..a458f418 100644 --- a/scripts/functions/Function_Tiles.js +++ b/scripts/functions/Function_Tiles.js @@ -14,751 +14,3 @@ // 17/05/2011 V1.0 MJD Stub functions added // // ********************************************************************************************************************** - - - -// ############################################################################################# -/// Function: -/// Adds a new tile to the room with the indicated values (see above for their meaning). -/// The function returns the id of the tile that can be used later on. -/// -/// -/// In: Background index -/// X texel start -/// Y texel start -/// width of tile in texels -/// height of tile in texels -/// X coordinate of tile in pixels -/// Y coordinate of tile in pixels -/// Depth value of tile -/// Out: -/// Retuns tile ID. -/// -// ############################################################################################# -function tile_add(_background, _left, _top, _width, _height, _x, _y, _depth) -{ - var pTile = new yyTile(); - pTile.x = _x; - pTile.y = _y; - pTile.depth = _depth; - pTile.xo = _left; - pTile.yo = _top; - pTile.w = _width; - pTile.h = _height; - pTile.index = _background; - pTile.ClampDrawingRange(); - - g_RunRoom.AddTile(pTile); - return pTile.id; -} - -// ############################################################################################# -/// Function: -/// Deletes the tile with the given id. -/// -/// -/// In: ID of tile to delete -// ############################################################################################# -function tile_delete(_id) -{ - g_RunRoom.DeleteTile(_id); -} - -// ############################################################################################# -/// Function: -/// -/// -/// -/// In: -/// Out: -/// -/// -// ############################################################################################# -function tile_exists(_id) -{ - if( g_RunRoom.m_Tiles[_id] == null ) return false; - return true; -} - -// ############################################################################################# -/// Function: -/// -/// -/// -/// In: -/// Out: -/// -/// -// ############################################################################################# -function tile_get_x(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.x; -} - -// ############################################################################################# -/// Function: -/// Returns the y-position of the tile with the given id. -/// -/// -/// In: ID of tile -/// Out: -/// Y texel coordinate -/// -// ############################################################################################# -function tile_get_y(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.y; -} - -// ############################################################################################# -/// Function: -/// Returns the left value of the tile with the given id. -/// -/// -/// In: ID of tile -/// Out: -/// X texel coordinate -/// -// ############################################################################################# -function tile_get_left(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.xo; -} - -// ############################################################################################# -/// Function: -/// Returns the top value of the tile with the given id. -/// -/// -/// In: ID of tile -/// Out: -/// Y texel coordinate -/// -// ############################################################################################# -function tile_get_top(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.yo; -} - -// ############################################################################################# -/// Function: -/// Returns the width of the tile with the given id. -/// -// ############################################################################################# -function tile_get_width(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.w; -} - - -// ############################################################################################# -/// Function: -/// Returns the height of the tile with the given id. -/// -/// -/// In: -/// Out: -/// -/// -// ############################################################################################# -function tile_get_height(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.h; -} - -// ############################################################################################# -/// Function: -/// Returns the depth of the tile with the given id. -/// -/// -/// In: -/// Out: -/// return depth -/// -// ############################################################################################# -function tile_get_depth(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.depth; -} - -// ############################################################################################# -/// Function: -/// Returns whether the tile with the given id is visible. -/// -/// -/// In: -/// Out: -/// returns visibility -/// -// ############################################################################################# -function tile_get_visible(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.visible; -} - - -// ############################################################################################# -/// Function: -/// Returns the xscale of the tile with the given id. -/// -/// -/// In: -/// Out: -/// retutrn x scale -/// -// ############################################################################################# -function tile_get_xscale(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.xscale; -} - - -// ############################################################################################# -/// Function: -/// Returns the yscale of the tile with the given id. -/// -/// -/// In: -/// Out: -/// return y scale -/// -// ############################################################################################# -function tile_get_yscale(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if(!pTile) return 0; - - return pTile.yscale; -} - -// ############################################################################################# -/// Function: -/// Returns the background of the tile with the given id. -/// -/// -/// In: -/// Out: -/// return background id -/// -// ############################################################################################# -function tile_get_background(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if( !pTile ) return 0; - - return pTile.index; -} - -// ############################################################################################# -/// Function: -/// Returns the blending color of the tile with the given id. -/// -/// -/// In: -/// Out: -/// return tile tinting colour -/// -// ############################################################################################# -function tile_get_blend(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if( !pTile ) return 0; - - return pTile.blend; -} - -// ############################################################################################# -/// Function: -/// Returns the alpha value of the tile with the given id. -/// -/// -/// In: -/// Out: -/// return tile alpha -/// -// ############################################################################################# -function tile_get_alpha(_id) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if( !pTile ) return 0; - - return pTile.alpha; -} - - -// ############################################################################################# -/// Function: -/// Sets the position of the tile with the given id. -/// -/// -/// In: -/// -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_set_position(_id,_x,_y) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if (pTile) { - pTile.x = _x; - pTile.y = _y; - } -} - -// ############################################################################################# -/// Function: -/// Sets the region of the tile with the given id in its background. -/// UVs WILL BE CLAMPED TO TILE SPACE. -/// -/// -/// In: ID of tile to change -/// new left edge texel -/// new top edge texel -/// new width of tile -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_set_region(_id,_left,_top,_width,_height) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if (pTile) { - pTile.xo = _left; - pTile.yo = _top; - pTile.w = _width; - pTile.h = _height; - pTile.ClampDrawingRange(); - } -} - -// ############################################################################################# -/// Function: -/// Sets the background for the tile with the given id. -/// UVs WILL BE CLAMPED TO TILE SPACE. -/// -/// -/// In: -/// -/// Out: -/// set background -/// -// ############################################################################################# -function tile_set_background(_id,_background) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if (pTile) { - pTile.index = _background; - pTile.ClampDrawingRange(); - } -} - -// ############################################################################################# -/// Function: -/// Sets whether the tile with the given id is visible. -/// -/// -/// In: -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_set_visible(_id,_visible) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if (pTile) { - pTile.visible = _visible; - } -} - - -// ############################################################################################# -/// Function: -/// Sets the depth of the tile with the given id. -/// -/// -/// In: -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_set_depth(_id,_depth) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if (pTile) - { - g_RunRoom.m_PlayfieldManager.DeleteTile(pTile); - pTile.depth = _depth; - g_RunRoom.m_PlayfieldManager.Add(pTile); - } -} - - -// ############################################################################################# -/// Function: -/// Sets the scaling of the tile with the given id. -/// -/// -/// In: -/// -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_set_scale(_id,_xscale,_yscale) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if( !pTile ) return; - pTile.xscale = _xscale; - pTile.yscale = _yscale; -} - -// ############################################################################################# -/// Function: -/// Sets the blending color of the tile with the given id. -/// -/// -/// In: -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_set_blend(_id,_colour) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if( !pTile ) return; - pTile.blend = ConvertGMColour(_colour); -} - -// ############################################################################################# -/// Function: -/// Sets the alpha value of the tile with the given id. -/// -/// -/// In: -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_set_alpha(_id,_alpha) -{ - var pTile = g_RunRoom.m_Tiles[_id]; - if( !pTile ) return 0; - pTile.alpha = _alpha; -} - - - -// ############################################################################################# -/// Function: -/// Hides all tiles at the indicated depth layer. -/// -/// -/// In: -/// Out: -/// -/// -// ############################################################################################# -function tile_layer_hide(_depth) -{ - g_RunRoom.m_PlayfieldManager.SetPlayfieldVisibility(_depth,false); -} - -// ############################################################################################# -/// Function: -/// Shows all tiles at the indicated depth layer. -/// -/// -/// In: -/// Out: -/// -/// -// ############################################################################################# -function tile_layer_show(_depth) { - g_RunRoom.m_PlayfieldManager.SetPlayfieldVisibility(_depth, true); -} - -// ############################################################################################# -/// Function: -/// Deletes all tiles at the indicated depth layer. -/// -/// -/// In: -/// Out: -/// -/// -// ############################################################################################# -function tile_layer_delete(_depth) { - g_RunRoom.DeleteTileLayer(_depth); -} - -// ############################################################################################# -/// Function: -/// Shifts all tiles at the indicated depth layer over the vector x,y. Can be used to create scrolling layers of tiles. -/// -/// -/// In: -/// -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_layer_shift(_depth,_x,_y) -{ - var pPlayfield = g_RunRoom.m_PlayfieldManager.Get(_depth); - if( !pPlayfield ) return; - - var pool = pPlayfield.GetPool(); - - // Delete all tile that exist in this layer. - for (var tile = 0; tile < pool.length; tile++) - { - var pTile = pool[tile]; - if (pTile) - { - pTile.x += _x; - pTile.y += _y; - } - } -} - - -// ############################################################################################# -/// Function: -/// Returns the id of the tile with the given depth at position (x,y). When no tile -/// exists at the position -1 is returned. When multiple tiles with the given -/// depth exist at the position the first one is returned. -/// -/// -/// In: -/// -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_layer_find(_depth,_x,_y) -{ - for (var index in g_RunRoom.m_Tiles) { - if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue; - - var pTile = g_RunRoom.m_Tiles[index]; - if (pTile != null) { - if((_depth == pTile.depth) && (_x >= pTile.x) && (_x < (pTile.x + (pTile.w*pTile.xscale))) && (_y >= pTile.y) && (_y < (pTile.y + (pTile.h*pTile.yscale))) ) - { - return pTile.id; - } - } - } - return -1; -} - - -// ############################################################################################# -/// Function: -/// Deletes the tile with the given depth at position (x,y). When multiple -/// tiles with the given depth exist at the position they are all deleted. -/// -/// -/// In: -/// -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_layer_delete_at(_depth,_x,_y) -{ - var tiles = []; - for (var index in g_RunRoom.m_Tiles) { - if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue; - - // Find the tile. - var pTile = g_RunRoom.m_Tiles[index]; - if (pTile) { - if ((_depth == pTile.depth) && (_x >= pTile.x) && (_x < (pTile.x + (pTile.w * pTile.xscale))) && (_y >= pTile.y) && (_y < (pTile.y + (pTile.h * pTile.yscale)))) { - // IF found, remember it. - tiles[tiles.length] = index; - } - } - } - - - // Now nuke them all. - for (var i = 0; i < tiles.length; i++) - { - g_RunRoom.DeleteTile(tiles[i]); - } -} - -// ############################################################################################# -/// Function: -/// Changes the depth of all tiles at the indicated depth to the new depth. With this -/// function you can move whole tile layers to a new depth. -/// -/// -/// In: -/// -/// Out: -/// -/// -// ############################################################################################# -function tile_layer_depth(_depth,_newdepth) { - - // Loop through all tiles and get the ones at a specific depth - var tiles = []; - for (var index in g_RunRoom.m_Tiles) { - if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue; - - var pTile = g_RunRoom.m_Tiles[index]; - if (pTile) { - if (_depth == pTile.depth) { - tiles[tiles.length] = pTile; - } - } - } - - - // Now move them all to a new layer - for (var i = 0; i < tiles.length; i++) - { - var pTile = tiles[i]; - - g_RunRoom.m_PlayfieldManager.Delete(pTile); - pTile.depth = _newdepth; - g_RunRoom.m_PlayfieldManager.Add(pTile); - } -} - -// ############################################################################################# -/// Function: -/// Return the total number of tiles in the current room -/// -/// -/// Out: -/// the number of tiles -/// -// ############################################################################################# -function tile_get_count() -{ - // loop through all tiles and get the ACTUAL number of tiles, ignoring nulls and undefined slots - var count = 0; - for (var index in g_RunRoom.m_Tiles) - { - if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue; - - var pTile = g_RunRoom.m_Tiles[index]; - if (pTile) count++; - } - return count; -} - - -// ############################################################################################# -/// Function: -/// Return tile ID at tile index "_index" -/// -/// -/// Out: -/// the number of tiles -/// -// ############################################################################################# -function tile_get_id(_index) { - // Loop through all tiles and get the ones at a specific depth - if (_index < 0 || _index >= g_RunRoom.m_NumTiles) return -1; - - for (var index in g_RunRoom.m_Tiles) { - if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue; - - var pTile = g_RunRoom.m_Tiles[index]; - if (pTile) { - if (_index == 0) return pTile.id; - _index--; - } - } - return -1; -} - -// ############################################################################################# -/// Function: -/// Return a list if ALL tile IDs in the room -/// -/// -/// Out: -/// Array holding the tile ids -/// -// ############################################################################################# -function tile_get_ids() -{ - var tiles = []; - var index=0; - for (var tile in g_RunRoom.m_Tiles) { - if (!g_RunRoom.m_Tiles.hasOwnProperty(tile)) continue; - - var pTile = g_RunRoom.m_Tiles[tile]; - if (pTile) { - tiles[index] = pTile.id; - index++; - } - } - return tiles; -} - -// ############################################################################################# -/// Function: -/// Return a list if ALL tile IDs in the room -/// -/// -/// Out: -/// Array holding the tile ids -/// -// ############################################################################################# -function tile_get_ids_at_depth(_depth) { - var tiles = []; - var index = 0; - for (var tile in g_RunRoom.m_Tiles) { - if (!g_RunRoom.m_Tiles.hasOwnProperty(tile)) continue; - - var pTile = g_RunRoom.m_Tiles[tile]; - if (pTile && pTile.depth == _depth) { - tiles[index] = pTile.id; - index++; - } - } - return tiles; -} diff --git a/scripts/yyPlayfield.js b/scripts/yyPlayfield.js index c952c9e6..e6e0f386 100644 --- a/scripts/yyPlayfield.js +++ b/scripts/yyPlayfield.js @@ -14,225 +14,3 @@ // 17/05/2011 V1.0 MJD 1st version // // ********************************************************************************************************************** - - -// ############################################################################################# -/// Function: -/// Create a new -/// -// ############################################################################################# -/**@constructor*/ -function yyPlayfield( _depth ) -{ - this.depth = _depth; - this.visible = true; - this.Tiles = new yyList(); -} - -// ############################################################################################# -/// Function: -/// Create a tile from its "loaded" data -/// -/// -/// In: Tile data -/// -// ############################################################################################# -yyPlayfield.prototype.Add = function (_pTile) { - this.Tiles.Add(_pTile); -}; - - -// ############################################################################################# -/// Function: -/// Delete a tile from the -/// -/// -/// In: Tile data -/// -// ############################################################################################# -yyPlayfield.prototype.Delete = function (_pTile) { - this.Tiles.DeleteItem(_pTile); -}; - -// ############################################################################################# -/// Function: -/// Draw all the tiles in this playfield -/// -// ############################################################################################# -yyPlayfield.prototype.Draw = function (_rect) { - - if (!this.visible) { - return; - } - - var pool = this.Tiles.pool; - for (var index = 0; index < pool.length; index++) - { - var pTile = pool[index]; - if (pTile != null) - { - // Take into account the tile's scaling - var xB = pTile.x + (pTile.xscale*pTile.w), - yR = pTile.y + (pTile.yscale*pTile.h); - - var x1 = (pTile.x < xB) ? pTile.x : xB, - x2 = (pTile.x > xB) ? pTile.x : xB, - y1 = (pTile.y < yR) ? pTile.y : yR, - y2 = (pTile.y > yR) ? pTile.y : yR; - - if ((x1 <= _rect.right) && (y1 <= _rect.bottom) && - (x2 >= _rect.left) && (y2 >= _rect.top)) - { - pTile.Draw(); - } - } - } -}; - - -// ############################################################################################# -/// Function: -/// Get the actual POOL of tiles -/// -/// -/// Out: -/// the pool. -/// -// ############################################################################################# -yyPlayfield.prototype.GetPool = function () { - return this.Tiles.pool; -}; - - - - - - - -// ########################################################################################################################################################################################## -// ########################################################################################################################################################################################## -/// Function: -/// Create a playfield manager -/// -// ########################################################################################################################################################################################## -// ########################################################################################################################################################################################## -/**@constructor*/ -function yyPlayfieldManager() -{ - this.m_Playfields = new yyOList(); - this.m_NextIndex = -1; -} - - -// ############################################################################################# -/// Property: -/// Find the playfield with the correct depth. -/// -/// -/// In: Playfield depth -/// -// ############################################################################################# -yyPlayfieldManager.prototype.Get = function (_depth) { - var pPlayfield; - - // Find playfield at tyile depth... - for (var index = 0; index < this.m_Playfields.count; index++) - { - pPlayfield = this.m_Playfields.Get(index); - if (pPlayfield.depth == _depth) return pPlayfield; - } - return null; -}; - -// ############################################################################################# -/// Property: -/// Delete the playfield with the depth provided. -/// -/// -/// In: Playfield depth -/// -// ############################################################################################# -yyPlayfieldManager.prototype.Delete = function (_depth) { - var pPlayfield = this.Get(_depth); - if (pPlayfield) - { - this.m_Playfields.Delete(pPlayfield); - } -}; - -// ############################################################################################# -/// Function: -/// Create a tile from its "loaded" data -/// -/// -/// In: Tile data -/// -// ############################################################################################# -yyPlayfieldManager.prototype.Add = function (_pTile) { - var pPlayfield; - - // Find playfield at tyile depth... - pPlayfield = this.Get(_pTile.depth); - if(!pPlayfield) - { - pPlayfield = new yyPlayfield(_pTile.depth); - this.m_Playfields.Add(pPlayfield); - } - pPlayfield.Add(_pTile); -}; - -// ############################################################################################# -/// Function: -/// Create a tile from its "loaded" data -/// -/// -/// In: Tile data -/// -// ############################################################################################# -yyPlayfieldManager.prototype.DeleteTile = function (_pTile) { - // Find playfield at tyile depth... - var pPlayfield = this.Get(_pTile.depth); - if (pPlayfield) - { - pPlayfield.Delete(_pTile); - } -}; - - -// ############################################################################################# -/// Function: -/// Create a tile from its "loaded" data -/// -/// -/// In: Tile data -/// -// ############################################################################################# -yyPlayfieldManager.prototype.GetFirst = function () { - this.m_NextIndex = this.m_Playfields.length-1; - return this.m_Playfields.Get(this.m_NextIndex); -}; - -// ############################################################################################# -/// Function: -/// Create a tile from its "loaded" data -/// -/// -/// In: Tile data -/// -// ############################################################################################# -yyPlayfieldManager.prototype.GetNext = function () { - this.m_NextIndex--; - if( this.m_NextIndex<0 ) return null; - return this.m_Playfields.Get(this.m_NextIndex); -}; - - -// ############################################################################################# -/// Property: -/// Hide/Show a playfield -/// -// ############################################################################################# -yyPlayfieldManager.prototype.SetPlayfieldVisibility = function (_depth, _vis) { - var pPlayfield = this.Get(_depth); - if (pPlayfield) pPlayfield.visible = (_vis >= 0.5); -}; diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 38231563..7732fc79 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -70,9 +70,6 @@ yyRoom.prototype.Init = function () { //this.m_NewInstances = []; // When a new instance is added, its added to the layers at the end of the event //this.m_ParticleChanges = []; // When a particle system changes depth (this needs to be global because it can be called before there is a room) - this.m_NumTiles = 0; - this.m_Tiles = []; - this.m_PlayfieldManager = new yyPlayfieldManager(); this.m_Views = []; this.m_Marked = []; @@ -516,21 +513,6 @@ yyRoom.prototype.CreateRoomFromStorage = function (_pRoomStorage) this.SetPersistent(this.m_persistent); this.m_Views = []; - - // Make Tiles - this.m_NumTiles = 0; - for (var index = 0; index < _pRoomStorage.tiles.length; index++) - { - var pTileStorage = _pRoomStorage.tiles[index]; - if (pTileStorage != null) - { - var pTile = CreateTileFromStorage(pTileStorage); - this.m_PlayfieldManager.Add(pTile); - this.m_Tiles[pTile.id] = pTile; - this.m_NumTiles++; - } - } - if (_pRoomStorage.pCode != undefined) this.m_code = _pRoomStorage.pCode; // Create views @@ -4090,82 +4072,7 @@ yyRoom.prototype.ActivateInstance = function (_pInst) { } }; -// ############################################################################################# -/// Property: -/// Add a tile to the room. -/// -// ############################################################################################# -yyRoom.prototype.AddTile = function (_pTile) { - - this.m_PlayfieldManager.Add(_pTile); - this.m_Tiles[_pTile.id] = _pTile; - this.m_NumTiles++; -}; - - - -// ############################################################################################# -/// Property: -/// Add a tile to the room. -/// -// ############################################################################################# -yyRoom.prototype.DeleteTile = function (_id) { - var pTile = this.m_Tiles[_id]; - if (pTile) - { - this.m_PlayfieldManager.DeleteTile(pTile); - this.m_Tiles[_id] = undefined; - this.m_NumTiles--; - } -}; -// ############################################################################################# -/// Property: -/// Add a tile to the room. -/// -// ############################################################################################# -yyRoom.prototype.DeleteTileLayer = function (_depth) { - - var pPlayfield = this.m_PlayfieldManager.Get(_depth); - if (pPlayfield != null && pPlayfield != undefined) { - - var pool = pPlayfield.GetPool(); - - // Delete all tile that exist in this layer. - for (var tile = 0; tile < pool.length; tile++) - { - var pTile = pool[tile]; - if (pTile) - { - this.m_Tiles[pTile.id] = null; - this.m_NumTiles--; - } - } - } - this.m_PlayfieldManager.Delete(_depth); -}; - - -// ############################################################################################# -/// Property: -/// Remove all tiles currently in use -/// -// ############################################################################################# -yyRoom.prototype.ClearTiles = function () { - - this.m_NumTiles = 0; - this.m_Tiles = []; -}; - - -// ############################################################################################# -/// Property: -/// Remove all tiles specified in storage -/// -// ############################################################################################# -yyRoom.prototype.ClearTilesFromStorage = function () { - this.m_pStorage.tiles = []; -}; diff --git a/scripts/yyTile.js b/scripts/yyTile.js index 98bac5d3..85346392 100644 --- a/scripts/yyTile.js +++ b/scripts/yyTile.js @@ -14,175 +14,3 @@ // 17/02/2011 // // ********************************************************************************************************************** - - -// ############################################################################################# -/// Function: -/// Game Maker "ACTIVE" Room class -/// -// ############################################################################################# -/** @constructor */ -function yyTile() -{ - this.__type = "[Tile]"; - this.x = 0; // X coordinate - this.y = 0; // Y coordinate - this.index = 0; // Background index to use as the tileset - this.xo = 0; // X texel index - this.yo = 0; // Y texel index - this.w = 0; // width in texels - this.h = 0; // height in texels - this.depth = 0.0; // depth (acts as layer ID) - this.id = g_DynamicTileID++; // tile ID - this.xscale = 1.0; // tile X scale - this.yscale = 1.0; // tile Y scale - this.blend = 0xffffff; // colour blend - this.alpha = 1.0; - this.visible = true; - this.clamped = false; // used internally for fixing GM bleed-over on TPages -} - - -// ############################################################################################# -/// Function: -/// In the IDE itself (this may be legacy issues now...) it's possible to setup a -/// tile whose drawing range is outwith the actual image. Within GM there is no -/// visible problem since the tiles are held individually and drawn clamped, but once -/// the images are on a TPage any drawing outside the tile's range will potentially -/// bleed over onto adjacent entries in the TPage. Here we fix those issues... -/// -// ############################################################################################# -yyTile.prototype.ClampDrawingRange = function () { - - var pImage = g_pBackgroundManager.GetImage(this.index); - if (pImage != null) - { - var pTPE = pImage.TPEntry; - - if (pTPE.tp >= g_Textures.length) return; - if (!g_Textures[pTPE.tp].complete) return; - - - if (this.xo < 0) - { - this.w += this.xo; - this.xo = 0; - } - if (this.yo < 0) - { - this.h += this.yo; - this.yo = 0; - } - - if (pTPE != null) - { - if ((this.xo + this.w) >= pTPE.w) - { - this.w = pTPE.w - this.xo; - } - if ((this.yo + this.h) >= pTPE.h) - { - this.h = pTPE.h - this.yo; - } - } - } -}; - - -// ############################################################################################# -/// Function: -/// Create a tile from its "loaded" data -/// -/// -/// In: Tile data -/// -// ############################################################################################# -function CreateTileFromStorage( _pTileStorage ) -{ - //{ "x":0, "y":0, "index":2, "xo":320, "yo":0, "w":64, "h":64, "depth":10, "id":10000235, }, - var pTile = new yyTile(); - - if( _pTileStorage.x!=undefined ) pTile.x = _pTileStorage.x; - if ( _pTileStorage.y!=undefined ) pTile.y = _pTileStorage.y; - if( _pTileStorage.index!=undefined ) pTile.index = _pTileStorage.index; - if( _pTileStorage.xo!=undefined ) pTile.xo = _pTileStorage.xo; - if( _pTileStorage.yo!=undefined ) pTile.yo = _pTileStorage.yo; - if( _pTileStorage.w!=undefined ) pTile.w = _pTileStorage.w; - if( _pTileStorage.h!=undefined ) pTile.h= _pTileStorage.h; - if( _pTileStorage.depth!=undefined ) pTile.depth = _pTileStorage.depth; - if( _pTileStorage.id!=undefined ) pTile.id = _pTileStorage.id; - if (_pTileStorage.scaleX != undefined) pTile.xscale = _pTileStorage.scaleX; - if (_pTileStorage.scaleY != undefined) pTile.yscale = _pTileStorage.scaleY; - if (_pTileStorage.colour != undefined) { - pTile.blend = (_pTileStorage.colour&0xffffff); - pTile.alpha = ((_pTileStorage.colour>>24)&0xff)/255.0; - } - pTile.ClampDrawingRange(); - - - - if (g_DynamicTileID < _pTileStorage.id) g_DynamicTileID = _pTileStorage.id + 1; - return pTile; -} - - -// ############################################################################################# -/// Function: -/// Draw the tile. -/// -/// -/// Out: -/// -/// -// ############################################################################################# -yyTile.prototype.Draw = function() { - if (!this.visible) return false; - var pImage = g_pBackgroundManager.GetImage(this.index); - if (pImage != null) { - var pTPE = pImage.TPEntry; - - if ((pTPE.texture instanceof HTMLImageElement) - && (pTPE.tp >= g_Textures.length)) return; - if ((g_Textures[pTPE.tp] instanceof HTMLImageElement) - && (!g_Textures[pTPE.tp].complete)) return; - - var scalex = pTPE.w / pTPE.ow; - var scaley = pTPE.h / pTPE.oh; - if (!g_webGL) { - - graphics.globalAlpha = this.alpha; - if (this.blend != 0xffffff) { - var cached_image = Graphics_CacheBlock(pTPE, this.blend); - if (this.xscale <= 0 || this.yscale <= 0) { - Graphics_PushTransform(this.x, this.y, this.xscale, this.yscale, 0.0); - graphics._drawImage(cached_image, (this.xo * scalex), (this.yo * scaley), this.w * scalex, this.h * scaley, 0, 0, this.w, this.h); - Graphics_SetTransform(); - } - else { - // otherwise, draw faster - graphics._drawImage(cached_image, (this.xo * scalex), (this.yo * scaley), (this.w * scalex), (this.h * scaley), this.x, this.y, this.w * this.xscale, this.h * this.yscale); - } - } - else { - var pTexture = -1; - if (pTPE.texture instanceof HTMLImageElement) - pTexture = g_Textures[pTPE.tp]; - else - pTexture = pTPE.texture; - if (this.xscale <= 0 || this.yscale <= 0) { - - Graphics_PushTransform(this.x, this.y, this.xscale, this.yscale, 0.0); - graphics._drawImage(pTexture, pTPE.x + (this.xo * scalex), pTPE.y + (this.yo * scalex), this.w * scalex, this.h * scaley, 0, 0, this.w, this.h); - Graphics_SetTransform(); - } - else { - graphics._drawImage(pTexture, pTPE.x + (this.xo * scalex), pTPE.y + (this.yo * scalex), this.w * scalex, this.h * scaley, this.x, this.y, this.w * this.xscale, this.h * this.yscale); - } - } - } - else { - var col = this.blend | ((this.alpha * 255) << 24); - graphics._drawImage(pTPE, pTPE.x + (this.xo * scalex), pTPE.y + (this.yo * scalex), this.w * scalex, this.h * scalex, this.x, this.y, this.w * this.xscale, this.h * this.yscale, col); - } - } -}; \ No newline at end of file From 8378891f5b2f0a3f14dfd4ef740fbcc6b7688404 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 11:10:45 +0300 Subject: [PATCH 14/84] Correction: more GMS1 tile leftovers --- scripts/yyRoom.js | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 7732fc79..1a9b42f7 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -282,30 +282,6 @@ yyRoom.prototype.CloneStorage = function (_pStorage) { }; } } - - // Tiles - this.m_pStorage.tiles = new Array(_pStorage.tiles.length); - for (var i = 0; i < _pStorage.tiles.length; i++) - { - var sourceTile = _pStorage.tiles[i]; - if (sourceTile != null) - { - this.m_pStorage.tiles[i] = { - x: sourceTile.x, - y: sourceTile.y, - index: sourceTile.index, - xo: sourceTile.xo, - yo: sourceTile.yo, - w: sourceTile.w, - h: sourceTile.h, - depth: sourceTile.depth, - id: sourceTile.id, - scaleX: sourceTile.scaleX, - scaleY: sourceTile.scaleY, - colour: sourceTile.colour - }; - } - } // Layers this.m_pStorage.layers = new Array( _pStorage.layers.length ); From 7bdfd9e2b833a2a504cce558fb5af074b54288b5 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 13:45:33 +0300 Subject: [PATCH 15/84] Most of the sequence-related code is now stripped if we're not using the actual sequences --- scripts/LoadGame.js | 4 ++++ scripts/_GameMaker.js | 8 +++++++- scripts/functions/Function_Game.js | 4 ++++ scripts/yyRoom.js | 3 ++- scripts/yySequence.js | 26 +++++++++++++++++++++----- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index d19a2438..a39508b6 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -59,7 +59,9 @@ function InitAboyne() g_pPathManager = new yyPathManager(); g_pTimelineManager = new yyTimelineManager(); g_pAnimCurveManager = new yyAnimCurveManager(); + // @if feature("sequences") g_pSequenceManager = new yySequenceManager(); + // @endif g_pTagManager = new TagManager(); g_pASyncManager = new yyASyncManager(); g_pLayerManager = new LayerManager(); @@ -850,11 +852,13 @@ function LoadGame(_GameFile) } // Load Sequences + // @if feature("sequences") if (_GameFile.Sequences !== undefined) { for (index = 0; index < _GameFile.Sequences.length; index++) { g_pSequenceManager.Add(_GameFile.Sequences[index]); } } + // @endif // Load Particle System Emitters if (_GameFile.PSEmitters !== undefined) { diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 72d7254d..3f407697 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -1629,7 +1629,9 @@ function GameMaker_DoAStep() { g_pLayerManager.UpdateLayers(); // Handle events that must react to the old position + // @if feature("sequences") g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_BEGIN); + // @endif g_pInstanceManager.PerformEvent(EVENT_STEP_BEGIN, 0); UpdateActiveLists(); if (New_Room != -1) return; @@ -1670,8 +1672,10 @@ function GameMaker_DoAStep() { if (New_Room != -1) return; g_pEffectsManager.StepEffectsForRoom(g_RunRoom); + // @if feature("sequences") g_pSequenceManager.UpdateInstancesForRoom(g_RunRoom); // update this at the same time as the step event g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_NORMAL); + // @endif g_pInstanceManager.PerformEvent(EVENT_STEP_NORMAL, 0); //HandleStep(EVENT_STEP_END); UpdateActiveLists(); if (New_Room != -1) return; @@ -1694,7 +1698,9 @@ function GameMaker_DoAStep() { UpdateActiveLists(); if (New_Room != -1) return; - g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_END); + // @if feature("sequences") + g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_END); + // @endif g_pInstanceManager.PerformEvent(EVENT_STEP_END, 0); //HandleStep(EVENT_STEP_END); UpdateActiveLists(); if (New_Room != -1) return; diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index 105e876d..7d8d1013 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -1695,7 +1695,9 @@ function ResourceGetTypeIndex(_name ) if ((ret = Resource_Find(_name, g_pGMFile.Timelines)) >= 0) { typeId.type=AT_Timeline; typeId.id = ret; return typeId; } if ((ret = Resource_Find_Script(_name, g_pGMFile.ScriptNames)) >= 0) { typeId.type=AT_Script; typeId.id = ret; return typeId; } if ((ret = Resource_Find_Shader(_name, g_pGMFile.Shaders)) >= 0) { typeId.type=AT_Shader; typeId.id = ret; return typeId; } + // @if feature("sequences") if ((ret = Resource_Find(_name, g_pGMFile.Sequences)) >= 0) { typeId.type=AT_Sequence; typeId.id = ret; return typeId; } + // @endif if ((ret = Resource_Find(_name, g_pGMFile.AnimCurves)) >= 0) { typeId.type=AT_AnimCurve; typeId.id = ret; return typeId; } if ((ret = CParticleSystem.Find(_name)) >= 0) { typeId.type=AT_ParticleSystem; typeId.id = ret; return typeId; } @@ -1717,7 +1719,9 @@ function ResourceGetName( _index, _assetType ) case AT_Font: return ( font_exists(_index)) ? font_get_name(_index) : ""; case AT_Timeline: return ( timeline_exists(_index)) ? timeline_get_name(_index) : ""; case AT_Shader: return ( shader_exists(_index)) ? shader_get_name(_index) : ""; + // @if feature("sequences") case AT_Sequence: return ( _sequence_exists(_index)) ? sequence_get_name(_index) : ""; + // @endif case AT_AnimCurve: return ( _animcurve_exists(_index)) ? animcurve_get_name(_index) : ""; } return ""; diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 1a9b42f7..eef0620f 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -2098,7 +2098,7 @@ yyRoom.prototype.DrawLayerTileElement = function (_rect, _layer, _el) { yyRoom.prototype.DrawLayerSequenceElement = function (_rect, _layer, _pSequenceEl) { - + // @if feature("sequences") // Update sequence element in case there has been changes between the sequence instance update pre-step and now g_pSequenceManager.EvaluateLayerSequenceElement(_pSequenceEl, true); @@ -2151,6 +2151,7 @@ yyRoom.prototype.DrawLayerSequenceElement = function (_rect, _layer, _pSequenceE } } } + // @endif }; yyRoom.prototype.DrawSequence = function (_rect, _layer, _pSequenceEl, _evalTree, _headPosition, _lastHeadPosition, _headDirection, _sequence, _isNested, _sequenceMatrix) { diff --git a/scripts/yySequence.js b/scripts/yySequence.js index e4660129..1846db27 100644 --- a/scripts/yySequence.js +++ b/scripts/yySequence.js @@ -67,7 +67,7 @@ function CSequenceBaseClass() } - +// @if feature("sequences") eTT_Link = 0; eTT_Invisible = 1; eTT_Disable = 2; @@ -1389,8 +1389,10 @@ function yySequenceBaseTrack(_pStorage) { if(tagLink.track == null) { // Find the track if it exists + // @if feature("sequences") var track = g_pSequenceManager.GetSequenceFromID(tagLink.trackIndex); if(track != null) tagLink.track = track; + // @endif } return tagLink.track; } @@ -2968,6 +2970,7 @@ yyKeyframeStore.prototype.GetKeyframeIndexRanges = function (_loopmode, _speed, return havekeys; }; +// @endif sequence - tracks var typeToEventLut = [ @@ -3112,7 +3115,7 @@ function yySequence(_pStorage) { this.fromWAD = true; } - + // @if feature("sequences") Object.defineProperties(this, { gmlname: { enumerable: true, @@ -3274,6 +3277,7 @@ function yySequence(_pStorage) { set: function (_val) { this["event_broadcast_message"] = _val; } }, }); + // @endif } // ############################################################################################# @@ -3295,7 +3299,7 @@ yySequence.prototype.GetObjectIDs = function() { /// // ############################################################################################# yySequence.prototype.GetObjectIDsFromTrack = function(_tracks, _ids) { - + // @if feature("sequences") for (var trackIndex = 0; trackIndex < _tracks.length; ++trackIndex) { var track = _tracks[trackIndex]; @@ -3365,9 +3369,10 @@ yySequence.prototype.GetObjectIDsFromTrack = function(_tracks, _ids) { // Check subtracks this.GetObjectIDsFromTrack(track.m_tracks, _ids); } + // @endif }; - +// @if feature("sequences") // ############################################################################################# /// Function: /// Create a new Sequences management object @@ -3969,6 +3974,7 @@ yySequenceManager.prototype.HandleMomentEvents = function (_pSeqInst, _pSeq, _se } while (true); } }; +// @endif // ############################################################################################# /// Function: @@ -4032,6 +4038,7 @@ function HandleSpriteMessageEvents(_pSeq, _elementID, _fps, _speedScale, _headDi } }; +// @if feature("sequences") // ############################################################################################# /// Function: /// Handles the throwing of events which are triggered @@ -4088,6 +4095,7 @@ yySequenceManager.prototype.ProcessMomentEvents = function () } } }; +// @endif // ############################################################################################# /// Function: @@ -4202,6 +4210,7 @@ function HandleSequenceWrapping(_sequence, _retVals) return hasWrapped; } +// @if feature("sequences") // ############################################################################################# /// Function: /// Updates the tracks within the given sequence @@ -4447,6 +4456,7 @@ yySequenceManager.prototype.HandleSpriteTrackUpdate = function(_node, _srcVars, HandleSpriteSequenceMessageEvents(_node, _track, _instance, _fps, _headPosition, _lastHeadPos, _headDir, sprite.sequence, sprite, graphicKeyframe, keyframeStore); }; +// @endif function HandleSpriteSequenceMessageEvents(_node, _track, _inst, _fps, _headPosition, _lastHeadPosition, _headDirection, _sequence, _sprite, _spriteKey, _keyframes) { @@ -4528,6 +4538,7 @@ function HandleSpriteSequenceMessageEvents(_node, _track, _inst, _fps, _headPosi } +// @if feature("sequences") // ############################################################################################# /// Function: /// Updates the given sequence track @@ -5041,7 +5052,9 @@ yySequenceManager.prototype.HandleParticleTrackUpdate = function (_pEl, _pSeq, _ } } }; +// @endif sequences - manager +// @if feature("sequences") // ############################################################################################# /// Function: /// Create a new CSequenceInstance object @@ -5697,7 +5710,9 @@ CSequenceInstance.prototype.SetInstanceInSequenceStatus = function (_inSequence) } }; +// @endif sequences - instance +// @if feature("sequences") // ############################################################################################# /// Function: /// Create a new CSeqTrackAudioInfo object @@ -6495,4 +6510,5 @@ function CSeqTrackInstanceInfo() this.instanceID = -1; this.ownedBySequence = false; //bool beenCreated; -}; \ No newline at end of file +}; +// @endif sequences - tracks \ No newline at end of file From 1b354228491634400acc373e8ec3e3df34c909d6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 13:45:55 +0300 Subject: [PATCH 16/84] Strip yyBuffer MD5 implementation if buffer_md5 is not used --- scripts/yyBuffer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/yyBuffer.js b/scripts/yyBuffer.js index cbac6f56..10de85bf 100644 --- a/scripts/yyBuffer.js +++ b/scripts/yyBuffer.js @@ -537,6 +537,7 @@ function BufferSizeOf(_type) { } +// @if function("buffer_md5") function yyMD5(){ this.i = new Uint32Array(2); //[2]; //uint32 this.buf = new Uint32Array(4); //[4]; //uint32 @@ -881,6 +882,7 @@ function DoMD5(_buff, _size,_offset) MD5Final( mdContext ); return mdContext.yyb_hex(); } +// @endif buffer_md5 function crc32_init() { var poly = -306674912; From 096c69cd6c239bf745c1063cafbd092d0a3a45c8 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 15:19:28 +0300 Subject: [PATCH 17/84] Strip timeline implementation if unused (not that there's much) --- scripts/Events.js | 2 ++ scripts/LoadGame.js | 4 ++++ scripts/functions/Function_Game.js | 5 +++++ scripts/yyInstance.js | 4 ++++ scripts/yyTimeline.js | 5 +++-- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/Events.js b/scripts/Events.js index 40e74de2..12dfdabb 100644 --- a/scripts/Events.js +++ b/scripts/Events.js @@ -565,6 +565,7 @@ function HandleMouse() // ############################################################################################# function HandleTimeLine() { + // @if feature("timelines") var ind1,ind2,j; var pool = g_RunRoom.m_Active.pool; var count = g_currentCreateCounter++; @@ -616,6 +617,7 @@ function HandleTimeLine() } } } + // @endif } // ############################################################################################# diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index a39508b6..461c8f88 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -57,7 +57,9 @@ function InitAboyne() g_pFontManager = new yyFontManager(); g_pCollisionList = []; g_pPathManager = new yyPathManager(); + // @if feature("timelines") g_pTimelineManager = new yyTimelineManager(); + // @endif g_pAnimCurveManager = new yyAnimCurveManager(); // @if feature("sequences") g_pSequenceManager = new yySequenceManager(); @@ -837,11 +839,13 @@ function LoadGame(_GameFile) // Load Timelines + // @if feature("timelines") if (_GameFile.Timelines !== undefined) { for(index=0; index<_GameFile.Timelines.length; index++ ){ g_pTimelineManager.Add( _GameFile.Timelines[index]); } } + // @endif // Load AnimCurves diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index 7d8d1013..c1cfd424 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -440,6 +440,7 @@ function event_perform_async(_pInst, _pOther, _event, _ds_map) // ############################################################################################# function event_perform_timeline(_pInst, _other, _timelineInd, _eventInd) { + // @if feature("timelines") var timeline = g_pTimelineManager.Get(_timelineInd); if ((timeline != null) && (timeline != undefined)) { @@ -1692,7 +1693,9 @@ function ResourceGetTypeIndex(_name ) if ((ret = Resource_Find(_name, g_pGMFile.Backgrounds)) >= 0) { typeId.type= g_isZeus ? AT_Tiles : AT_Background, typeId.id = ret; return typeId; } if ((ret = Resource_Find(_name, g_pGMFile.Paths)) >= 0) { typeId.type=AT_Path; typeId.id = ret; return typeId; } if ((ret = Resource_Find(_name, g_pGMFile.Fonts)) >= 0) { typeId.type=AT_Font; typeId.id = ret; return typeId; } + // @if feature("timelines") if ((ret = Resource_Find(_name, g_pGMFile.Timelines)) >= 0) { typeId.type=AT_Timeline; typeId.id = ret; return typeId; } + // @endif if ((ret = Resource_Find_Script(_name, g_pGMFile.ScriptNames)) >= 0) { typeId.type=AT_Script; typeId.id = ret; return typeId; } if ((ret = Resource_Find_Shader(_name, g_pGMFile.Shaders)) >= 0) { typeId.type=AT_Shader; typeId.id = ret; return typeId; } // @if feature("sequences") @@ -1717,7 +1720,9 @@ function ResourceGetName( _index, _assetType ) case AT_Path: return ( path_exists(_index)) ? path_get_name(_index) : ""; case AT_Script: return ( script_exists(_index)) ? script_get_name(_index) : ""; case AT_Font: return ( font_exists(_index)) ? font_get_name(_index) : ""; + // @if feature("timelines") case AT_Timeline: return ( timeline_exists(_index)) ? timeline_get_name(_index) : ""; + // @endif case AT_Shader: return ( shader_exists(_index)) ? shader_get_name(_index) : ""; // @if feature("sequences") case AT_Sequence: return ( _sequence_exists(_index)) ? sequence_get_name(_index) : ""; diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index 8173e0ea..9b11f3d8 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -358,6 +358,7 @@ yyInstance.prototype = { this.__path_endaction = _val; }, + // @if feature("timelines") // timeline index property get timeline_index() { return this.__timeline_index; }, set timeline_index(_val) { @@ -384,6 +385,7 @@ yyInstance.prototype = { this.__timeline_speed = _val; }, + // @endif timelines // bbox_left property (NOTE: no setter) get bbox_left() { @@ -587,6 +589,7 @@ yyInstance.prototype = { this.m_pMaskSkeleton = null; }, + // @if feature("timelines") // timeline_running property get timeline_running() { if( this.timeline_paused ){ @@ -610,6 +613,7 @@ yyInstance.prototype = { set timeline_loop( _loop ) { this.timeline_looped = yyGetBool(_loop); }, + // @endif timeline props // @if feature("physics") // phy_rotation property diff --git a/scripts/yyTimeline.js b/scripts/yyTimeline.js index 206b1f5e..8d2fad18 100644 --- a/scripts/yyTimeline.js +++ b/scripts/yyTimeline.js @@ -15,7 +15,7 @@ // // ********************************************************************************************************************** - +// @if feature("timelines") // ############################################################################################# /// Function: /// Create a new TIMELINE object @@ -249,4 +249,5 @@ yyTimelineManager.prototype.ClearEvent = function (_ind, _timeStamp) { } } } -}; \ No newline at end of file +}; +// @endif timelines From aca71a40985b8d293b51789059ad387eff809e2b Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 15:19:48 +0300 Subject: [PATCH 18/84] Strip animation curve implementation if neither them nor sequences are used --- scripts/LoadGame.js | 4 ++++ scripts/functions/Function_Game.js | 5 +++++ scripts/yyAnimCurve.js | 2 ++ 3 files changed, 11 insertions(+) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index 461c8f88..740bae4b 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -60,7 +60,9 @@ function InitAboyne() // @if feature("timelines") g_pTimelineManager = new yyTimelineManager(); // @endif + // @if feature("animcurves") g_pAnimCurveManager = new yyAnimCurveManager(); + // @endif // @if feature("sequences") g_pSequenceManager = new yySequenceManager(); // @endif @@ -849,11 +851,13 @@ function LoadGame(_GameFile) // Load AnimCurves + // @if feature("animcurves") if (_GameFile.AnimCurves !== undefined) { for (index = 0; index < _GameFile.AnimCurves.length; index++) { g_pAnimCurveManager.Add(_GameFile.AnimCurves[index]); } } + // @endif // Load Sequences // @if feature("sequences") diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index c1cfd424..8cc9c609 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -451,6 +451,7 @@ function event_perform_timeline(_pInst, _other, _timelineInd, _eventInd) eventData.Event(_pInst, _pInst); } } + // @endif } // ############################################################################################# @@ -1701,7 +1702,9 @@ function ResourceGetTypeIndex(_name ) // @if feature("sequences") if ((ret = Resource_Find(_name, g_pGMFile.Sequences)) >= 0) { typeId.type=AT_Sequence; typeId.id = ret; return typeId; } // @endif + // @if feature("animcurves") if ((ret = Resource_Find(_name, g_pGMFile.AnimCurves)) >= 0) { typeId.type=AT_AnimCurve; typeId.id = ret; return typeId; } + // @endif if ((ret = CParticleSystem.Find(_name)) >= 0) { typeId.type=AT_ParticleSystem; typeId.id = ret; return typeId; } return typeId; @@ -1727,7 +1730,9 @@ function ResourceGetName( _index, _assetType ) // @if feature("sequences") case AT_Sequence: return ( _sequence_exists(_index)) ? sequence_get_name(_index) : ""; // @endif + // @if feature("animcurves") case AT_AnimCurve: return ( _animcurve_exists(_index)) ? animcurve_get_name(_index) : ""; + // @endif } return ""; } diff --git a/scripts/yyAnimCurve.js b/scripts/yyAnimCurve.js index 08f6f99e..81111ec2 100644 --- a/scripts/yyAnimCurve.js +++ b/scripts/yyAnimCurve.js @@ -15,6 +15,7 @@ // // ********************************************************************************************************************** +// @if feature("animcurves") // ############################################################################################# /// Function: /// Create a new AnimCurvePoint object @@ -807,3 +808,4 @@ function animcurve_get_name( _index ) return pCurve.pName; return ""; } +// @endif \ No newline at end of file From b5e7d85fcc192ca57eff7dab83a1facbddaad94f Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 16:15:18 +0300 Subject: [PATCH 19/84] Also strip Spine if unused --- scripts/LoadGame.js | 7 ++- scripts/animation/yySkeletonInstance.js | 2 + scripts/animation/yySkeletonSkin.js | 2 + scripts/animation/yySkeletonSprite.js | 3 +- scripts/functions/Function_Layers.js | 2 + scripts/functions/Function_Sprite.js | 3 +- scripts/spine/spine-core.js | 4 +- scripts/yyInstance.js | 72 ++++++++++++++++--------- scripts/yySprite.js | 20 ++++--- 9 files changed, 80 insertions(+), 35 deletions(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index 740bae4b..4cf57aa8 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -347,7 +347,7 @@ function PreLoadExtensions(_GameFile) { /// // ############################################################################################# function LoadSkeletonData(_filename) { - + // @if feature("spine") g_LoadingTotal++; var request = new XMLHttpRequest(); request.open('GET', CheckWorkingDirectory(_filename), true); @@ -357,6 +357,7 @@ function LoadSkeletonData(_filename) { g_pSpriteManager.SkeletonLoad(request.responseText); }; request.onerror = function (ev) { g_LoadingCount++; }; + // @endif spine } @@ -452,9 +453,11 @@ function LoadGame_PreLoadAssets(_GameFile) } // Load Spine data if it's present + // @if feature("spine") if ((_GameFile.Skel !== null) && (_GameFile.Skel !== undefined)) { LoadSkeletonData(_GameFile.Skel); } + // @endif // Load the particle textures if (true == g_pGMFile.Options.UseParticles) { @@ -916,6 +919,7 @@ function LoadGame(_GameFile) pTGInfo.sprites[i] = pStore.SpriteIDs[i]; } } + // @if feature("spine") if (pStore.SpineSpriteIDs !== undefined) { for(var i = 0; i < pStore.SpineSpriteIDs.length; i++) @@ -923,6 +927,7 @@ function LoadGame(_GameFile) pTGInfo.spinesprites[i] = pStore.SpineSpriteIDs[i]; } } + // @endif if (pStore.FontIDs !== undefined) { for(var i = 0; i < pStore.FontIDs.length; i++) diff --git a/scripts/animation/yySkeletonInstance.js b/scripts/animation/yySkeletonInstance.js index 31543ea5..586db10e 100644 --- a/scripts/animation/yySkeletonInstance.js +++ b/scripts/animation/yySkeletonInstance.js @@ -10,6 +10,7 @@ // // ********************************************************************************************************************** +// @if feature("spine") // ############################################################################################# /// Function: /// Initialise storage for the instance specific portion of a Skeleton animation @@ -1543,3 +1544,4 @@ yySkeletonInstance.prototype.GetSlotData = function (_list) ds_list_add(_list, map); } }; +// @endif spine diff --git a/scripts/animation/yySkeletonSkin.js b/scripts/animation/yySkeletonSkin.js index 1a7e57f7..697d8f30 100644 --- a/scripts/animation/yySkeletonSkin.js +++ b/scripts/animation/yySkeletonSkin.js @@ -15,9 +15,11 @@ /// Create a new SkeletonSkin object /// // ############################################################################################# +// @if feature("spine") /** @constructor */ function yySkeletonSkin(_skin) { this.__type = "[SkeletonSkin]"; this.m_skin = _skin; } +// @endif diff --git a/scripts/animation/yySkeletonSprite.js b/scripts/animation/yySkeletonSprite.js index 9b43c647..a5237fa0 100644 --- a/scripts/animation/yySkeletonSprite.js +++ b/scripts/animation/yySkeletonSprite.js @@ -36,7 +36,7 @@ var REGIONATTACHMENT_OY4 = 7; function SetSkeletonDrawInstance(_instance) { g_skeletonDrawInstance = _instance; }; - +// @if feature("spine") function yyImageProxy() { this.width = null; @@ -1830,3 +1830,4 @@ yySkeletonSprite.prototype.GetAttachmentsForSlot = function(_slotName) return attachmentNames; }; +// @endif spine \ No newline at end of file diff --git a/scripts/functions/Function_Layers.js b/scripts/functions/Function_Layers.js index 7a577fb9..b70745bd 100644 --- a/scripts/functions/Function_Layers.js +++ b/scripts/functions/Function_Layers.js @@ -1542,10 +1542,12 @@ LayerManager.prototype.UpdateLayers = function() HandleSpriteMessageEvents(sprite.sequence, el.m_id, fps, sprite.playbackspeed, el.m_sequenceDir, lastSequenceHead, el.m_sequencePos); } } + // @if feature("spine") else if(sprite.m_skeletonSprite !== undefined) { el.m_imageIndex += el.m_imageSpeed; } + // @endif else { var fps = g_GameTimer.GetFPS(); diff --git a/scripts/functions/Function_Sprite.js b/scripts/functions/Function_Sprite.js index 427155ff..c5f486ca 100644 --- a/scripts/functions/Function_Sprite.js +++ b/scripts/functions/Function_Sprite.js @@ -1812,6 +1812,7 @@ function sprite_get_info( _spriteIndex ) break; case 1: // SWF break; + // @if feature("spine") case 2: // SPINE if (pSpr.m_skeletonSprite != undefined) { @@ -1888,7 +1889,7 @@ function sprite_get_info( _spriteIndex ) variable_struct_set(ret, "slots", slotsArray); //ret.gmlslots = slotsArray; } // end if break; - + // @endif } // end switch variable_struct_set(ret, "nineslice", (pSpr.nineslicedata != undefined) ? pSpr.nineslicedata : undefined); //ret.gmlnineslice = (pSpr.nineslicedata != undefined) ? pSpr.nineslicedata : undefined; diff --git a/scripts/spine/spine-core.js b/scripts/spine/spine-core.js index 5a38af29..7b57a988 100644 --- a/scripts/spine/spine-core.js +++ b/scripts/spine/spine-core.js @@ -1,3 +1,4 @@ +// @if feature("spine") var spine = (() => { var __defProp = Object.defineProperty; var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); @@ -8652,4 +8653,5 @@ var spine = (() => { var SwirlEffect = _SwirlEffect; SwirlEffect.interpolation = new PowOut(2); return src_exports; -})(); \ No newline at end of file +})(); +// @endif \ No newline at end of file diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index 9b11f3d8..bf99355e 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -495,11 +495,13 @@ yyInstance.prototype = { var pSprite = g_pSpriteManager.Get(this.sprite_index); if (!pSprite) return 0; + // @if feature("spine") var skeletonAnim = this.SkeletonAnimation(); if (skeletonAnim) { return skeletonAnim.FrameCount(pSprite); } - else if ((pSprite.SWFTimeline !== null) && (pSprite.SWFTimeline !== undefined)) { + // @endif spine + if ((pSprite.SWFTimeline !== null) && (pSprite.SWFTimeline !== undefined)) { return pSprite.SWFTimeline.numFrames; } return pSprite.ppTPE.length; @@ -865,10 +867,12 @@ yyInstance.prototype.Assign = function (_pInst, _LinkToObjectType) { } // Any skeleton data needs to be not just a reference + // @if feature("spine") var skeletonAnim = this.SkeletonAnimation(); if (skeletonAnim) { this.m_pSkeletonAnimation = skeletonAnim.Clone(); - } + } + // @endif this.m_nLayerID = _pInst.layer; }; @@ -1213,13 +1217,13 @@ yyInstance.prototype.AdaptSpeed = function () { /// // ############################################################################################# yyInstance.prototype.GetImageNumber = function () { - var pSprite = g_pSpriteManager.Get(this.sprite_index); - + // @if feature("spine") var skeletonAnim = this.SkeletonAnimation(); if (skeletonAnim) { return skeletonAnim.FrameCount(pSprite); } + // @endif spine return g_pSpriteManager.GetImageCount(this.sprite_index); }; @@ -1426,6 +1430,7 @@ yyInstance.prototype.Compute_BoundingBox = function() { var maskCollisionSkel = this.MaskCollisionSkeleton(); var collisionSkel = this.GetCollisionSkeleton(); + // @if feature("spine") if(maskCollisionSkel !== null && g_pSpriteManager.Sprites[this.mask_index].bboxmode == 0 /* "Automatic" */) { if (!this.bbox) { this.bbox = new YYRECT(0, 0, 0, 0); @@ -1447,7 +1452,7 @@ yyInstance.prototype.Compute_BoundingBox = function() { this.bbox_dirty = false; return; } - else if(collisionSkel !== null && g_pSpriteManager.Sprites[this.sprite_index].bboxmode == 0 /* "Automatic" */) { + if(collisionSkel !== null && g_pSpriteManager.Sprites[this.sprite_index].bboxmode == 0 /* "Automatic" */) { if (!this.bbox) { this.bbox = new YYRECT(0, 0, 0, 0); } @@ -1468,6 +1473,7 @@ yyInstance.prototype.Compute_BoundingBox = function() { this.bbox_dirty = false; return; } + // @endif var spr, t; var ix = (this.mask_index >= 0) ? this.mask_index : this.sprite_index; @@ -1658,7 +1664,7 @@ yyInstance.prototype.Maybe_Compute_BoundingBox = function() { this.Compute_BoundingBox(); return; } - + // @if feature("spine") var collisionSkel = this.GetCollisionSkeleton(); if (collisionSkel !== null) { @@ -1674,6 +1680,7 @@ yyInstance.prototype.Maybe_Compute_BoundingBox = function() { return; } } + // @endif spine }; @@ -1732,11 +1739,13 @@ yyInstance.prototype.Collision_Point = function (_x, _y, _prec) { // handle precise collision tests var Result = false; + // @if feature("spine") var collisionSkel = this.GetCollisionSkeleton(); if (collisionSkel !== null) { Result = collisionSkel.PointCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle, _x, _y); - } - else { + } else // -> + // @endif + { Result = pSpr.PreciseCollisionPoint(Math.floor(this.image_index), bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, @@ -1839,13 +1848,15 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec) // handle precise collision tests var Result = false; + // @if feature("spine") var collisionSkel = this.GetCollisionSkeleton(); if (collisionSkel !== null) { Result = collisionSkel.RectangleCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle, _x1, _y1, _x2, _y2); - } - else { + } else // -> + // @endif + { //function Rect(ALeft, ATop, ARight, ABottom: Integer): TRect; g_rr.left = Round(yymin(_x1, _x2)); g_rr.top = Round(yymin(_y1, _y2)); @@ -1975,11 +1986,13 @@ yyInstance.prototype.Collision_Ellipse = function (_x1, _y1, _x2, _y2, _prec) { g_rr.bottom = max_y1y2; // handle precise collision tests + // @if feature("spine") var collisionSkel = this.GetCollisionSkeleton(); if (collisionSkel !== null) { return collisionSkel.EllipseCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle, g_rr); - } - else { + } else // -> + // @endif + { return pSpr.PreciseCollisionEllipse(Math.floor(this.image_index), bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, g_rr); } }; @@ -2063,13 +2076,13 @@ yyInstance.prototype.Collision_Line = function (_x1, _y1, _x2, _y2, _prec) { if (!_prec || this.colcheck === yySprite_CollisionType.AXIS_ALIGNED_RECT) { return true; } // handle precise collision tests + // @if feature("spine") var collisionSkel = this.GetCollisionSkeleton(); if (collisionSkel !== null) { return collisionSkel.LineCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle, _x1, _y1, _x2, _y2); } - else { - return pSpr.PreciseCollisionLine(this.image_index | 0, i_bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, Round(_x1), Round(_y1), Round(_x2), Round(_y2)); - } + // @endif + return pSpr.PreciseCollisionLine(this.image_index | 0, i_bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, Round(_x1), Round(_y1), Round(_x2), Round(_y2)); }; @@ -2081,6 +2094,7 @@ yyInstance.prototype.Collision_Line = function (_x1, _y1, _x2, _y2, _prec) { // ############################################################################################# yyInstance.prototype.Collision_Skeleton = function (inst, prec) { + // @if feature("spine") // Go ahead and get the bounding box for our animation this.Maybe_Compute_BoundingBox(); inst.Maybe_Compute_BoundingBox(); @@ -2117,10 +2131,9 @@ yyInstance.prototype.Collision_Skeleton = function (inst, prec) return skel1.SpriteCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle, spr2, inst.bbox, inst.CollisionImageIndex(), inst.x, inst.y, inst.image_xscale, inst.image_yscale, inst.image_angle); } - else{ - /* inst/spr2 is using bounding box collisions - no more to do. */ - return true; - } + // @endif spine + /* inst/spr2 is using bounding box collisions - no more to do. */ + return true; }; @@ -2464,12 +2477,14 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) { if (this != _pInst && !this.marked && !_pInst.marked) { // Change code path if either instance is using a Spine animation + // @if feature("spine") if (this.UseSkeletonCollision()) { return this.Collision_Skeleton(_pInst, _prec); } if (_pInst.UseSkeletonCollision()) { return _pInst.Collision_Skeleton(this, _prec); } + // @endif @@ -3078,7 +3093,7 @@ yyInstance.prototype.set_physics_active = function(_isActive) { /// // ############################################################################################# yyInstance.prototype.SkeletonAnimation = function () { - + // @if feature("spine") if (sprite_exists(this.sprite_index)) { var spr = g_pSpriteManager.Get(this.sprite_index); @@ -3090,11 +3105,13 @@ yyInstance.prototype.SkeletonAnimation = function () { } } } + // @endif return this.m_pSkeletonAnimation; }; yyInstance.prototype.MaskCollisionSkeleton = function() { + // @if feature("spine") var mask_sprite = null; var use_mask_skeleton = false; @@ -3119,6 +3136,7 @@ yyInstance.prototype.MaskCollisionSkeleton = function() this.m_pMaskSkeleton = new yySkeletonInstance(mask_sprite.m_skeletonSprite); this.bbox_dirty = true; } + // @endif return this.m_pMaskSkeleton; }; @@ -3126,7 +3144,7 @@ yyInstance.prototype.MaskCollisionSkeleton = function() yyInstance.prototype.GetCollisionSkeleton = function() { var skel = null; - + // @if feature("spine") if (this.mask_index >= 0) { skel = this.MaskCollisionSkeleton(); @@ -3145,23 +3163,24 @@ yyInstance.prototype.GetCollisionSkeleton = function() } } } - + // @endif return skel; }; yyInstance.prototype.CollisionImageIndex = function() { + // @if feature("spine") if (this.mask_index >= 0 && g_pSpriteManager.Sprites[this.mask_index].colcheck === yySprite_CollisionType.SPINE_MESH) { return 0.0; } - else{ - return this.image_index; - } + // @endif + return this.image_index; }; yyInstance.prototype.UseSkeletonCollision = function() { + // @if feature("spine") if (this.mask_index < 0) { return this.SkeletonAnimation() @@ -3170,6 +3189,9 @@ yyInstance.prototype.UseSkeletonCollision = function() else{ return g_pSpriteManager.Sprites[this.mask_index].colcheck === yySprite_CollisionType.SPINE_MESH } + // @else + return false; + // @endif }; yyInstance.prototype.GetLayerID=function() { return this.m_nLayerID; }; diff --git a/scripts/yySprite.js b/scripts/yySprite.js index 5db6c194..519c9a4b 100644 --- a/scripts/yySprite.js +++ b/scripts/yySprite.js @@ -128,6 +128,7 @@ var __floatToInt = function (x) { return ~~x; }; */ yySprite.prototype.GetSkeletonSpriteSize = function (_skeleton) { + // @if feature("spine") var bounds = new YYRECT(); _skeleton.updateWorldTransform(); @@ -152,7 +153,7 @@ yySprite.prototype.GetSkeletonSpriteSize = function (_skeleton) return [width, height]; } } - + // @endif return null; }; @@ -165,7 +166,7 @@ yySprite.prototype.GetSkeletonSpriteSize = function (_skeleton) yySprite.prototype.GetSkeletonBounds = function (_skeleton, _bounds) { var retval = false; - + // @if feature("spine") _bounds.left = Number.MAX_SAFE_INTEGER; _bounds.top = Number.MAX_SAFE_INTEGER; _bounds.right = Number.MIN_SAFE_INTEGER; @@ -221,7 +222,7 @@ yySprite.prototype.GetSkeletonBounds = function (_skeleton, _bounds) } } } - + // @endif spine return retval; }; @@ -612,6 +613,7 @@ yySprite.prototype.SetSWFDrawRoutines = function () { /// // ############################################################################################# yySprite.prototype.BuildSkeletonData = function (_skeletonData) { + // @if feature("spine") if (_skeletonData) { this.m_skeletonSprite = new yySkeletonSprite(); //this.m_skeletonSprite.Load(skeletonData.json, skeletonData.atlas, skeletonData.width, skeletonData.height); @@ -632,6 +634,7 @@ yySprite.prototype.BuildSkeletonData = function (_skeletonData) { }; this.numb = SKELETON_FRAMECOUNT; + // @endif spine }; // ############################################################################################# @@ -640,6 +643,7 @@ yySprite.prototype.BuildSkeletonData = function (_skeletonData) { /// // ############################################################################################# yySprite.prototype.LoadFromSpineAsync = function (_filename, _callback) { + // @if feature("spine") var loadFileContents = function (_filename, _callback) { var errorMessage = 'Could not load file contents!'; var request = new XMLHttpRequest(); @@ -772,6 +776,7 @@ yySprite.prototype.LoadFromSpineAsync = function (_filename, _callback) { } tryCallback(_err); }); + // @endif spine }; // ############################################################################################# @@ -933,12 +938,14 @@ function CreateSpriteFromStorage( _pStore ) } // Do this after we've set up our TPEs + // @if feature("spine") if (_pStore.skel !== undefined) { var skeletonData = g_pSpriteManager.SkeletonData ? g_pSpriteManager.SkeletonData[_pStore.skel] : undefined; pSprite.BuildSkeletonData(skeletonData); } + // @endif pSprite.CalcCullRadius(); @@ -1109,9 +1116,9 @@ yySprite.prototype.Draw = function (_ind, _x, _y, _xscale, _yscale, _angle, _col yySprite.prototype.GetSkeletonSlotsAtPoint = function(_inst, _x, _y, _list) { + // @if feature("spine") if ((this.m_skeletonSprite === undefined) || (this.m_skeletonSprite === null)) return; // not a Spine sprite - var xscale = _inst.image_xscale; var yscale = _inst.image_yscale; @@ -1128,7 +1135,7 @@ yySprite.prototype.GetSkeletonSlotsAtPoint = function(_inst, _x, _y, _list) var angle = _inst.image_angle; this.m_skeletonSprite.GetSlotsAtWorldPos(_inst, undefined, undefined, ind, x, y, xscale, yscale, angle, _x, _y, _list); - + // @endif spine }; @@ -2054,7 +2061,7 @@ yySpriteManager.prototype.SWFLoad = function (_data) { /// // ############################################################################################# yySpriteManager.prototype.SkeletonLoad = function (_spineText) { - + // @if feature("spine") function multiply_uint32(a, b) { var ah = (a >> 16) & 0xffff, al = a & 0xffff; var bh = (b >> 16) & 0xffff, bl = b & 0xffff; @@ -2158,4 +2165,5 @@ yySpriteManager.prototype.SkeletonLoad = function (_spineText) { catch (e) { debug("Cannot parse Spine data " + e.message); } + // @endif spine }; From bc4f52e5f9f347d05a608246a3d6bbe3314653f7 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 16:40:47 +0300 Subject: [PATCH 20/84] And SWF too (smaller than I thought it would be) --- scripts/LoadGame.js | 5 ++++- scripts/SWF/yySWFBitmap.js | 5 +++-- scripts/SWF/yySWFShape.js | 3 ++- scripts/SWF/yySWFTimeline.js | 4 +++- scripts/yyInstance.js | 2 ++ scripts/yySprite.js | 19 +++++++++++++------ scripts/yyWebGL.js | 24 +++++++++++++++++------- 7 files changed, 44 insertions(+), 18 deletions(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index 4cf57aa8..c544f455 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -367,7 +367,7 @@ function LoadSkeletonData(_filename) { /// // ############################################################################################# function LoadSwfData(_filename) { - + // @if feature("swf") g_LoadingTotal++; var request = new XMLHttpRequest(); request.open('GET', CheckWorkingDirectory(_filename), true); @@ -378,6 +378,7 @@ function LoadSwfData(_filename) { g_pSpriteManager.SWFLoad(request.response || request.responseText); }; request.onerror = function (ev) { g_LoadingCount++; }; + // @endif swf } // ############################################################################################# @@ -448,9 +449,11 @@ function LoadGame_PreLoadAssets(_GameFile) } // Load SWF data if it's present + // @if feature("swf") if ((_GameFile.Swfs !== null) && (_GameFile.Swfs !== undefined)) { LoadSwfData(_GameFile.Swfs); } + // @endif // Load Spine data if it's present // @if feature("spine") diff --git a/scripts/SWF/yySWFBitmap.js b/scripts/SWF/yySWFBitmap.js index c0a5b8c3..dd54237c 100644 --- a/scripts/SWF/yySWFBitmap.js +++ b/scripts/SWF/yySWFBitmap.js @@ -9,7 +9,7 @@ // Description: // // ********************************************************************************************************************** - +// @if feature("swf") var eBitmapType_JPEGNoHeader = 0, eBitmapType_JPEG = 1, eBitmapType_JPEGWithAlpha = 2, @@ -314,4 +314,5 @@ function ReplaceTextureAlpha(_pTPE, _alpha) { _pTPE.texture.m_Height = glTexture.Height; return _pTPE.texture; -} \ No newline at end of file +} +// @endif \ No newline at end of file diff --git a/scripts/SWF/yySWFShape.js b/scripts/SWF/yySWFShape.js index 1d3dee01..1f9db4c7 100644 --- a/scripts/SWF/yySWFShape.js +++ b/scripts/SWF/yySWFShape.js @@ -9,7 +9,7 @@ // Description: // // ********************************************************************************************************************** - +// @if feature("swf") var eDIType_Invalid = 0, eDIType_Shape = 1, eDIType_Bitmap = 2; @@ -524,3 +524,4 @@ yySWFShape.prototype.BuildSubShapes = function (_styleGroup, _dataView, _byteOff } return _byteOffset; }; +// @endif \ No newline at end of file diff --git a/scripts/SWF/yySWFTimeline.js b/scripts/SWF/yySWFTimeline.js index 6c88cda4..632da32f 100644 --- a/scripts/SWF/yySWFTimeline.js +++ b/scripts/SWF/yySWFTimeline.js @@ -10,6 +10,7 @@ // // ********************************************************************************************************************** +// @if feature("swf") // convert from twips to pixels (each twip is 20 pixels) var g_SWF_twipscale = 1.0 / 20.0; @@ -165,4 +166,5 @@ yySWFTimeline.prototype.BuildTimelineData = function (_dataView, _byteOffset, _l } } return _byteOffset; -}; \ No newline at end of file +}; +// @endif \ No newline at end of file diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index bf99355e..19864f78 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -501,9 +501,11 @@ yyInstance.prototype = { return skeletonAnim.FrameCount(pSprite); } // @endif spine + // @if feature("swf") if ((pSprite.SWFTimeline !== null) && (pSprite.SWFTimeline !== undefined)) { return pSprite.SWFTimeline.numFrames; } + // @endif return pSprite.ppTPE.length; }, diff --git a/scripts/yySprite.js b/scripts/yySprite.js index 519c9a4b..1b737b06 100644 --- a/scripts/yySprite.js +++ b/scripts/yySprite.js @@ -427,7 +427,7 @@ yySprite.prototype.CalcCullRadius = function () { /// // ############################################################################################# yySprite.prototype.BuildSWFData = function (_swfIndex, _xo, _yo) { - + // @if feature("swf") try { if (g_pSpriteManager.swfSpriteData !== undefined) { @@ -528,6 +528,7 @@ yySprite.prototype.BuildSWFData = function (_swfIndex, _xo, _yo) { catch (e) { debug("Cannot build SWF data " + e.message); } + // @endif }; @@ -537,7 +538,7 @@ yySprite.prototype.BuildSWFData = function (_swfIndex, _xo, _yo) { /// // ############################################################################################# yySprite.prototype.SetupSWFCollisionMasks = function (_dataView, _byteOffset, _littleEndian) { - + // @if feature("swf") if (this.colcheck !== yySprite_CollisionType.PRECISE) { return; } @@ -584,6 +585,7 @@ yySprite.prototype.SetupSWFCollisionMasks = function (_dataView, _byteOffset, _l _byteOffset = offsetStore + ((colMaskSize + 3) & ~3); } this.maskcreated = true; + // @endif swf return _byteOffset; }; @@ -593,7 +595,7 @@ yySprite.prototype.SetupSWFCollisionMasks = function (_dataView, _byteOffset, _l /// // ############################################################################################# yySprite.prototype.SetSWFDrawRoutines = function () { - + // @if feature("swf") this.Draw = function (_ind, _x, _y, _xscale, _yscale, _angle, _colour, _alpha) { Graphics_SWFDraw( this.SWFDictionaryItems, this.SWFTimeline, _ind, this.xOrigin, this.yOrigin, _x, _y, _xscale, _yscale, _angle, _colour, _alpha, this.ppTPE); @@ -603,6 +605,7 @@ yySprite.prototype.SetSWFDrawRoutines = function () { Graphics_SWFDraw( this.SWFDictionaryItems, this.SWFTimeline, _ind, this.xOrigin, this.yOrigin, _x, _y, 1.0, 1.0, 0.0, 0xffffffff, _alpha, this.ppTPE); }; + // @endif swf }; @@ -901,11 +904,12 @@ function CreateSpriteFromStorage( _pStore ) pSprite.Masks = null; - + // @if feature("swf") if (_pStore.swf !== undefined) { pSprite.m_LoadedFromChunk = true; pSprite.BuildSWFData(_pStore.swf, pSprite.xOrigin, pSprite.yOrigin); } + // @endif if (_pStore.sequence !== undefined) { pSprite.BuildSequenceData(_pStore.sequence); @@ -1919,9 +1923,11 @@ yySpriteManager.prototype.AddSprite = function (_pSprite) { yySpriteManager.prototype.GetImageCount = function (_spr_number) { var sprite = this.Sprites[_spr_number]; if (!sprite) return null; + // @if feature("swf") if ((sprite.SWFTimeline !== null) && (sprite.SWFTimeline !== undefined)) { return sprite.SWFTimeline.numFrames; - } + } + // @endif return sprite.ppTPE.length; }; @@ -1996,7 +2002,7 @@ yySpriteManager.prototype.Delete = function(_id) { /// // ############################################################################################# yySpriteManager.prototype.SWFLoad = function (_data) { - + // @if feature("swf") try { // header consists of: // "rswf"; @@ -2052,6 +2058,7 @@ yySpriteManager.prototype.SWFLoad = function (_data) { catch (e) { debug("Cannot parse SWF data " + e.message); } + // @endif swf }; diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index fdc818a1..3998423f 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -137,8 +137,10 @@ function InitWebGLFunctions() { Graphics_TextureDrawTiled = WebGL_TextureDrawTiled_RELEASE; Graphics_TextureDraw = WebGL_TextureDraw_RELEASE; Graphics_TextureDrawPos = WebGL_TextureDrawPos_RELEASE; + // @if feature("swf") Graphics_SWFDraw = WebGL_DrawSWF_RELEASE; Graphics_SWFDrawObject = WebGL_DrawSWFObject_RELEASE; + // @endif swf Graphics_DrawPart = WebGL_DrawPart_RELEASE; draw_rectangle = WebGL_draw_rectangle_RELEASE; draw_roundrect_color_ext = WebGL_draw_roundrect_color_EXT_RELEASE; @@ -1202,7 +1204,8 @@ function WebGL_TextureDrawTiled_RELEASE( _pTPE, _x, _y, _xsc, _ysc, vtiled, htil /// // ############################################################################################# function WebGL_DrawSWF_RELEASE(SWFDictionary, SWFTimeline, ind, xorig, yorig, x, y, xscale, yscale, angle, color, alpha, TPEs) -{ +{ + // @if feature("swf") var oldColourWriteEnable = GR_ColourWriteEnable; var oldZWriteEnable = GR_3DMode; @@ -1353,7 +1356,8 @@ function WebGL_DrawSWF_RELEASE(SWFDictionary, SWFTimeline, ind, xorig, yorig, x, // Restore render states g_webGL.SetStencilEnable(false); g_webGL.SetColorWriteEnable(oldColourWriteEnable.red, oldColourWriteEnable.green, oldColourWriteEnable.blue, oldColourWriteEnable.alpha); - g_webGL.SetZWriteEnable(oldZWriteEnable); + g_webGL.SetZWriteEnable(oldZWriteEnable); + // @endif } // ############################################################################################# @@ -1363,6 +1367,8 @@ function WebGL_DrawSWF_RELEASE(SWFDictionary, SWFTimeline, ind, xorig, yorig, x, // ############################################################################################# function WebGL_DrawSWFObject_RELEASE(SWFDictionaryItems, _pObject, _pPostMat, _pGradTransMat, _mulcolour, _colvals, _aa, TPEs) { + var numtris = 0; + // @if feature("swf") // Work out alpha colour for AA var transcolvals = []; transcolvals[0] = _colvals[0], @@ -1388,7 +1394,6 @@ function WebGL_DrawSWFObject_RELEASE(SWFDictionaryItems, _pObject, _pPostMat, _p transcoladd[i] = _pObject.colTransAddZeroAlpha[i]; } - var numtris = 0; // Could potentially optimise this a bit by collapsing all the style groups into a single contiguous list, storing an explicit colour for each triangle vertex and chaining untextured geometry together // We'd still have to maintain rendering order so we couldn't chain *all* untextured geometry - just contiguous sections // If we also precalculate how long each run is we could reduce the amount of conditionals and calls to AllocVerts @@ -1587,6 +1592,7 @@ function WebGL_DrawSWFObject_RELEASE(SWFDictionaryItems, _pObject, _pPostMat, _p } } } + // @endif return numtris; } @@ -1599,6 +1605,8 @@ function WebGL_DrawSWFObject_RELEASE(SWFDictionaryItems, _pObject, _pPostMat, _p function WebGL_Draw_BitmapGradientSWFShape( SWFDictionaryItems, _pObject, _filltype, _pFillStyleData, _pSubShape, _pGradTransMat, _combinedMat, _colvals, _transcolvals, _mulcolour, _colmul, _coladd, _transcoladd, _aa, TPEs) { + var numtris = 0; + // @if feature("swf") var pCoords, pColours, pUVs, @@ -1701,7 +1709,6 @@ function WebGL_Draw_BitmapGradientSWFShape( } } - var numtris = 0; if (pTPE !== null) { if (!pTPE.texture.webgl_textureid) { @@ -1878,6 +1885,7 @@ function WebGL_Draw_BitmapGradientSWFShape( currVert += stride; } } + // @endif return numtris; } @@ -1887,7 +1895,8 @@ function WebGL_Draw_BitmapGradientSWFShape( /// // ############################################################################################# function WebGL_Draw_SolidSWFShape(_pObject, _pFillStyleData, _pSubShape, _combinedMat, _colvals, _transcolvals, _colmul, _coladd, _transcoladd, _aa) { - + var numtris = 0; + // @if feature("swf") var aascale = 1.0; if (_aa) { aascale = WebGL_BuildAAScale(_pObject, _combinedMat) * GR_SWFAAScale; @@ -1902,7 +1911,6 @@ function WebGL_Draw_SolidSWFShape(_pObject, _pFillStyleData, _pSubShape, _combin // Get simpler access var pFillData = _pFillStyleData, col = pFillData.col, - numtris = 0, t = 0; // Multiply our material colour and mul colour together using good old fashioned fixed point maths @@ -2070,6 +2078,7 @@ function WebGL_Draw_SolidSWFShape(_pObject, _pFillStyleData, _pSubShape, _combin currVert += stride; } + // @endif return numtris; } @@ -2079,7 +2088,7 @@ function WebGL_Draw_SolidSWFShape(_pObject, _pFillStyleData, _pSubShape, _combin /// // ############################################################################################# function WebGL_BuildAAScale(_pObject, _combinedMat) { - + // @if feature("swf") // Work out the AA scaling required if (GR_SWFAAEnabled) { @@ -2165,6 +2174,7 @@ function WebGL_BuildAAScale(_pObject, _combinedMat) { _pObject.aascale = aascale; return aascale; } + // @endif swf return 1.0; } From 1c987c3c89b4c295380e4e19d3ba7b3d3e8824d3 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 17:43:17 +0300 Subject: [PATCH 21/84] Cleaned up some long-unused `YoYo_` function aliases --- scripts/Globals.js | 4 +- scripts/functions/Function_Game.js | 4 +- scripts/functions/Function_Layers.js | 6 +- scripts/functions/Function_YoYo.js | 249 +-------------------------- scripts/yyBuiltIn.js | 8 +- scripts/yyEffects.js | 4 +- 6 files changed, 20 insertions(+), 255 deletions(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index 571fdbba..285363e2 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1442,12 +1442,12 @@ function ConvertGMColour( _col ){ return (((_col&0xff)<<16) | (_col&0xff00) | // ############################################################################################# function Timing_Wait( _slp ) { - var StartTime = YoYo_GetTimer(); + var StartTime = get_timer(); // very simple delay loop - a proper sleep would be better. while(_slp>0) { - var CurrTime= YoYo_GetTimer(); + var CurrTime= get_timer(); _slp -= (CurrTime-StartTime); StartTime = CurrTime; } diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index 8cc9c609..a8b5021f 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -1859,7 +1859,7 @@ CTimingSource.prototype.Reset= function() this.m_elapsed_micros = 0; if(this.m_fps >0.0) { - this.m_last_micros = YoYo_GetTimer(); + this.m_last_micros = get_timer(); } else { @@ -1878,7 +1878,7 @@ CTimingSource.prototype.Update=function() current = this.m_last_micros + 1000000.0/this.m_fps; } else - current = YoYo_GetTimer(); + current = get_timer(); this.m_delta_micros = current - this.m_last_micros; diff --git a/scripts/functions/Function_Layers.js b/scripts/functions/Function_Layers.js index b70745bd..f0ea88a0 100644 --- a/scripts/functions/Function_Layers.js +++ b/scripts/functions/Function_Layers.js @@ -701,7 +701,7 @@ LayerManager.prototype.BuildRoomLayerRuntimeData = function(_room) for(var i=0;i<_room.m_Layers.length;i++) { var player = _room.m_Layers.Get(i); - player.m_timer = YoYo_GetTimer(); + player.m_timer = get_timer(); for(var j=0;j // ############################################################################################# -var YoYo_AchievementsAvailable = achievement_available; function achievement_available() { return false; @@ -121,7 +120,6 @@ function achievement_available() /// Log into achievement system /// // ############################################################################################# -var YoYo_LoginAchievements = achievement_login; function achievement_login() { } @@ -131,50 +129,36 @@ function achievement_login() /// Log out of online achievements /// // ############################################################################################# -var YoYo_LogoutAchievements = achievement_logout; function achievement_logout() { } -var YoYo_achievement_login_status = achievement_login_status; function achievement_login_status() { } -var YoYo_achievement_reset = achievement_reset; function achievement_reset() { } -var YoYo_achievement_show_achievements = achievement_show_achievements; function achievement_show_achievements() { } -var YoYo_achievement_show_leaderboards = achievement_show_leaderboards; function achievement_show_leaderboards() { } -var YoYo_achievement_load_friends = achievement_load_friends; function achievement_load_friends() { } -var YoYo_achievement_load_leaderboard = achievement_load_leaderboard; function achievement_load_leaderboard(){} -var YoYo_achievement_get_pic = achievement_get_pic; function achievement_get_pic(){} -var YoYo_achievement_load_progress = achievement_load_progress; function achievement_load_progress() { } -var YoYo_achievement_send_challenge = achievement_send_challenge; function achievement_send_challenge() { } -var YoYo_os_get_info = os_get_info; function os_get_info() {return -1; } -var YoYo_achievement_event = achievement_event; function achievement_event() { } -var YoYo_achievement_show = achievement_show; function achievement_show() { } -var YoYo_achievement_get_info = achievement_get_info; function achievement_get_info() { } // ############################################################################################# @@ -186,86 +170,11 @@ function achievement_get_info() { } /// /// // ############################################################################################# -var YoYo_GetConfig = os_get_config; function os_get_config() { return g_YoYoConfig; //"YOYO_PAID"; } - -// ############################################################################################# -/// Function: -/// Get the platform we're running on (if known) -/// -/// -/// Out: -/// BROWSER_UNKNOWN = -1, -/// BROWSER_WIN32 = 0, -/// BROWSER_WIN64 = 1, -/// BROWSER_MACOSX = 2, -/// BROWSER_PSP = 3, -/// BROWSER_IOS = 4, -/// BROWSER_ANDROID = 5, -/// BROWSER_LINUX = 6, -/// -// ############################################################################################# -function YoYo_GetPlatform() { - return g_OSPlatform; -} - -// ############################################################################################# -/// Function: -/// Get the "device" type - if knowns -/// -/// -/// Out: -/// BROWSER_TYPE = 0, -/// BROWSER_TYPE_UNKNOWN = 255, -/// BROWSER_IPHONE = 0, -/// BROWSER_IPHONE_RETENA = 1, -/// BROWSER_IPAD = 2, -/// -// ############################################################################################# -function YoYo_GetDevice(){ - return g_DeviceType; -} - - -// ############################################################################################# -/// Function: -/// Get the browser type. -/// -/// -/// Out: -/// BROWSER_NOT_A_BROWSER = -1, // game is not being played in a browser. -/// BROWSER_UNKNOWN = 0, // Unknown browser... -/// BROWSER_IE = 1, -/// BROWSER_FIREFOX = 2, -/// BROWSER_CHROME = 3, -/// BROWSER_SAFARI = 4, -/// BROWSER_OPERA = 5, -/// BROWSER_SAFARI_MOBILE = 6, -/// BROWSER_DEFAULT_ANDROID = 7, -/// BROWSER_WINDOWS_STORE = 8 -/// -// ############################################################################################# -function YoYo_GetBrowser() { - return g_OSBrowser; -} - -// ############################################################################################# -/// Function: -/// Return the OS version number -/// -/// -/// Out: -/// The OS version, or -1 -/// -// ############################################################################################# -function YoYo_GetVersion() { - return g_OSVersion; -} - // ############################################################################################# /// Function: /// @@ -278,10 +187,9 @@ function YoYo_GetVersion() { /// /// // ############################################################################################# -var YoYo_OpenURL_full = url_open_full; function url_open_full(_url, _target, _options) { if (_target != "_self" && _target != "_blank" && _target != "_parent" && _target != "_top"){ - yyError("Error: invalid TARGET specified. Only '_self', '_blank', 'parent' or '_top' supported. (YoYo_OpenURL)"); + yyError("Error: invalid TARGET specified. Only '_self', '_blank', 'parent' or '_top' supported. (url_open)"); return; } var loaded = window.open(yyGetString(_url), yyGetString(_target), yyGetString(_options)); @@ -296,9 +204,8 @@ function url_open_full(_url, _target, _options) { /// Target to open in /// // ############################################################################################# -var YoYo_OpenURL_ext = url_open_ext; function url_open_ext(_url, _target) { - YoYo_OpenURL_full(_url, _target, "scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=yes,status=yes"); + url_open_full(_url, _target, "scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=yes,status=yes"); } // ############################################################################################# @@ -309,9 +216,8 @@ function url_open_ext(_url, _target) { /// In: URL to open /// // ############################################################################################# -var YoYo_OpenURL = url_open; function url_open(_url) { - YoYo_OpenURL_ext(_url, "_self"); + url_open_ext(_url, "_self"); } @@ -324,7 +230,6 @@ function url_open(_url) { /// Score to post /// // ############################################################################################# -var YoYo_PostScore = achievement_post_score; function achievement_post_score(_scoreboard, _score) { } @@ -338,7 +243,6 @@ function achievement_post_score(_scoreboard, _score) /// Score to post /// // ############################################################################################# -var YoYo_PostAchievement = achievement_post; function achievement_post( _scoreboard, _achivement ) { } @@ -360,7 +264,6 @@ function achievement_post( _scoreboard, _achivement ) /// /// // ############################################################################################# -var YoYo_LeaveRating = shop_leave_rating; function shop_leave_rating(_text, _yes, _no, _URL) { } @@ -374,23 +277,9 @@ function shop_leave_rating(_text, _yes, _no, _URL) /// time value since start of app /// // ############################################################################################# -var get_timer = (performance.now) ? function() { - return performance.now() * 1000; - } : - function() { - var t = new Date().getTime() * 1000; - return t - g_YoYoTimerStart; - }; - -var YoYo_GetTimer = get_timer; - - - - - - - - +var get_timer = typeof performance !== "undefined" && performance.now + ? function() { return performance.now() * 1000; } + : function() { return new Date().getTime() * 1000 - g_YoYoTimerStart; }; // ############################################################################################# /// Function: @@ -406,7 +295,6 @@ var YoYo_GetTimer = get_timer; /// virtual key "id" /// // ############################################################################################# -var YoYo_AddVirtualKey = virtual_key_add; function virtual_key_add(_x, _y, _w, _h, _keycode) { _x = yyGetInt32(_x); @@ -440,7 +328,6 @@ function virtual_key_add(_x, _y, _w, _h, _keycode) /// /// // ############################################################################################# -var YoYo_DeleteVirtualKey = virtual_key_delete; function virtual_key_delete(_id) { _id = yyGetInt32(_id); @@ -482,7 +369,6 @@ function UpdateVirtualKeyDrawList() { /// /// // ############################################################################################# -var YoYo_ShowVirtualKey = virtual_key_show; function virtual_key_show(_id) { _id = yyGetInt32(_id); @@ -505,7 +391,6 @@ function virtual_key_show(_id) { /// /// // ############################################################################################# -var YoYo_HideVirtualKey = virtual_key_hide; function virtual_key_hide(_id) { _id = yyGetInt32(_id); @@ -527,7 +412,6 @@ function virtual_key_hide(_id) { /// -1 to 1 tilt value /// // ############################################################################################# -var YoYo_GetTiltX = device_get_tilt_x; function device_get_tilt_x() { return 0; @@ -543,7 +427,6 @@ function device_get_tilt_x() /// -1 to 1 tilt value /// // ############################################################################################# -var YoYo_GetTiltY = device_get_tilt_y; function device_get_tilt_y() { return 0; @@ -559,7 +442,6 @@ function device_get_tilt_y() /// -1 to 1 tilt value /// // ############################################################################################# -var YoYo_GetTiltZ = device_get_tilt_z; function device_get_tilt_z() { return 0; @@ -574,7 +456,6 @@ function device_get_tilt_z() /// /// // ############################################################################################# -var YoYo_SelectPicture = device_ios_get_imagename; function device_ios_get_imagename() { MissingFunction("device_ios_get_imagename()"); @@ -589,7 +470,6 @@ function device_ios_get_imagename() /// /// // ############################################################################################# -var YoYo_GetPictureSprite = device_ios_get_image; function device_ios_get_image() { MissingFunction("device_ios_get_image()"); @@ -604,7 +484,6 @@ function device_ios_get_image() /// /// // ############################################################################################# -var YoYo_OF_StartDashboard = openfeint_start; function openfeint_start() { MissingFunction("openfeint_start()"); @@ -620,7 +499,6 @@ function openfeint_start() /// /// // ############################################################################################# -var YoYo_OF_AddAchievement = achievement_map_achievement; function achievement_map_achievement(_a, _b) { MissingFunction("achievement_map_achievement()"); @@ -637,7 +515,6 @@ function achievement_map_achievement(_a, _b) /// /// // ############################################################################################# -var YoYo_OF_AddLeaderboard = achievement_map_leaderboard; function achievement_map_leaderboard(_a, _b, _c) { MissingFunction("achievement_map_leaderboard()"); @@ -654,7 +531,6 @@ function achievement_map_leaderboard(_a, _b, _c) /// /// // ############################################################################################# -var YoYo_OF_SendChallenge = openfeint_send_challenge; function openfeint_send_challenge(_a, _b, _c) { MissingFunction("openfeint_send_challenge()"); @@ -669,7 +545,6 @@ function openfeint_send_challenge(_a, _b, _c) /// /// // ############################################################################################# -var YoYo_OF_SendInvite = openfeint_send_invite; function openfeint_send_invite(_a) { MissingFunction("openfeint_send_invite()"); @@ -686,7 +561,6 @@ function openfeint_send_invite(_a) /// /// // ############################################################################################# -var YoYo_OF_SendSocial = openfeint_send_social; function openfeint_send_social(_a, _b, _c) { MissingFunction("openfeint_send_social()"); @@ -701,7 +575,6 @@ function openfeint_send_social(_a, _b, _c) /// /// // ############################################################################################# -var YoYo_OF_SetURL = openfeint_set_url; function openfeint_set_url(_a) { MissingFunction("openfeint_set_url()"); @@ -715,7 +588,6 @@ function openfeint_set_url(_a) /// /// // ############################################################################################# -var YoYo_OF_AcceptChallenge = openfeint_accept_challenge; function openfeint_accept_challenge() { MissingFunction("openfeint_accept_challenge()"); @@ -730,7 +602,6 @@ function openfeint_accept_challenge() /// /// // ############################################################################################# -var YoYo_OF_IsOnline = achievement_is_online; function achievement_is_online() { MissingFunction("achievement_is_online()"); @@ -747,7 +618,6 @@ function achievement_is_online() /// /// // ############################################################################################# -var YoYo_OF_SendChallengeResult = openfeint_send_result; function openfeint_send_result(_a, _b) { MissingFunction("openfeint_send_result()"); @@ -763,7 +633,6 @@ function openfeint_send_result(_a, _b) /// /// // ############################################################################################# -var YoYo_IsKeypadOpen = device_is_keypad_open; function device_is_keypad_open() { return false; } @@ -803,100 +672,6 @@ function YoYo_Init() leaderboard_type_time_mins_secs = 1; } -// ############################################################################################# -/// Function: -/// What to do if the end user fails the security key check (grief the user) -/// -// ############################################################################################# -function YoYo_SecurityFail() -{ - var t = setTimeout(function() { - for (var sprIndex in g_pSpriteManager.Sprites) - { - if (!g_pSpriteManager.Sprites.hasOwnProperty(sprIndex)) continue; - - g_pSpriteManager.Delete(sprIndex); - break; - } - // And recurse... - YoYo_SecurityFail(); - - }, 1000); // delete a sprite every second -} - -// ############################################################################################# -/// Function: -/// Read the session key from the document element as set by the server .php -/// -// ############################################################################################# -function YoYo_GetSessionKey() -{ - if (!document.getElementById('b4f6074452b74d86ce6d00904fcd389c')) { - // NM-156 is an arbitrary choice (Queensryche song if you must know...) - var sessionKeyElement = document.getElementById('NM-156'); - if (sessionKeyElement) - { - sessionKey = sessionKeyElement.innerHTML; - sessionKeyElement.parentNode.removeChild(sessionKeyElement); - } - else { - YoYo_SecurityFail(); - } - } -} - -// ############################################################################################# -/// Function: -/// On intialisation this grabs the security key from the server -/// -// ############################################################################################# -function YoYo_CheckSecurity(_url) -{ - if (!document.getElementById('42f28d8caa0d96b967645dce4278ed50')) - { - // Construct the final url that includes the request data used by the server to check the session state - var finalUrl = _url + "?" + sessionKey + "=2239"; - // var finalUrl = "http://localhost:80/check_purchase.php?" + sessionKey + "=2239"; - - // If a prior security check is in flight then do nothing - if (!g_securityCheck.securityRequestInFlight) - { - g_securityCheck.securityRequestInFlight = true; - var t = setTimeout(function() { - g_securityCheck.securityRequest.open("GET", finalUrl, true); - g_securityCheck.securityRequest.onreadystatechange = function () { - if (g_securityCheck.securityRequest.readyState == 4) - { - switch (g_securityCheck.securityRequest.status) - { - case 200: - { - // Check response against our session key - if (g_securityCheck.securityRequest.responseText != sessionKey) - { - // Do something unpleasant to the user - YoYo_SecurityFail(); - } - g_securityCheck.securityRequestInFlight = false; - } - break; - default: - alert("ERROR: The game has lost connection to the server. " + g_securityCheck.securityRequest.statusText); - // Enact a reload of the page. Don't use window.location.reload() as that requests the user - // resubmits data and allows them to deny the request and carry on playing - window.location.href = window.location.href; - break; - } - } - }; - g_securityCheck.securityRequest.send(null); - }, 5000); // delay sending for 5 seconds - } - } -} - - - // ############################################################################################# /// Function: /// Return the domain the page has been loaded from. @@ -906,9 +681,8 @@ function YoYo_CheckSecurity(_url) /// The domain (127.0.0.1, www.blah.com etc.) /// // ############################################################################################# -var YoYo_GetDomain = url_get_domain; function url_get_domain() { - return document.domain; + return location.hostname; } // ############################################################################################# @@ -947,7 +721,6 @@ function getAsyncRequestObject() { /// 0 or 1 /// // ############################################################################################# -var YoYo_MouseCheckButton = device_mouse_check_button; function device_mouse_check_button(_dev, _button) { _dev = yyGetInt32(_dev); @@ -978,7 +751,6 @@ function device_mouse_check_button(_dev, _button) { /// 0 or 1 /// // ############################################################################################# -var YoYo_MouseCheckButtonPressed = device_mouse_check_button_pressed; function device_mouse_check_button_pressed(_dev, _button) { _dev = yyGetInt32(_dev); @@ -1009,7 +781,6 @@ function device_mouse_check_button_pressed(_dev, _button) { /// 0 or 1 /// // ############################################################################################# -var YoYo_MouseCheckButtonReleased = device_mouse_check_button_released; function device_mouse_check_button_released(_dev, _button) { _dev = yyGetInt32(_dev); @@ -1039,7 +810,6 @@ function device_mouse_check_button_released(_dev, _button) { /// mouse coordinate /// // ############################################################################################# -var YoYo_MouseX = device_mouse_x; function device_mouse_x(_dev) { _dev = yyGetInt32(_dev); @@ -1063,7 +833,6 @@ function device_mouse_x(_dev) { /// /// // ############################################################################################# -var YoYo_MouseXRaw = device_mouse_raw_x; function device_mouse_raw_x(_dev) { _dev = yyGetInt32(_dev); @@ -1085,7 +854,6 @@ function device_mouse_raw_x(_dev) { /// mouse coordinate /// // ############################################################################################# -var YoYo_MouseY = device_mouse_y; function device_mouse_y(_dev) { _dev = yyGetInt32(_dev); @@ -1109,7 +877,6 @@ function device_mouse_y(_dev) { /// mouse coordinate /// // ############################################################################################# -var YoYo_MouseYRaw = device_mouse_raw_y; function device_mouse_raw_y(_dev) { _dev = yyGetInt32(_dev); @@ -1189,13 +956,11 @@ function device_mouse_y_to_gui(_dev) { /// Checks to see if a pause activity came from the OS activity in this frame /// // ############################################################################################# -var YoYo_OSPauseEvent = os_is_paused; function os_is_paused() { return g_OSPauseEvent; } -var YoYo_OSHasFocusEvent = window_has_focus; function window_has_focus() { return g_GameFocus; } diff --git a/scripts/yyBuiltIn.js b/scripts/yyBuiltIn.js index a26e13f2..f445c1a7 100644 --- a/scripts/yyBuiltIn.js +++ b/scripts/yyBuiltIn.js @@ -181,10 +181,10 @@ yyBuiltIn.prototype.get_browser_height = function () { return GetBrowserHeight() yyBuiltIn.prototype.get_delta_time = function () { return this.delta_time; }; -yyBuiltIn.prototype.get_os_type = function () { return g_OSPlatform; }; //{ return YoYo_GetPlatform(); }; -yyBuiltIn.prototype.get_os_device = function () { return YoYo_GetDevice(); }; -yyBuiltIn.prototype.get_os_browser = function () { return YoYo_GetBrowser(); }; -yyBuiltIn.prototype.get_os_version = function () { return YoYo_GetVersion(); }; +yyBuiltIn.prototype.get_os_type = function () { return g_OSPlatform; }; +yyBuiltIn.prototype.get_os_device = function () { return g_DeviceType; }; +yyBuiltIn.prototype.get_os_browser = function () { return g_OSBrowser; }; +yyBuiltIn.prototype.get_os_version = function () { return g_OSVersion; }; yyBuiltIn.prototype.get_async_load = function () { return this.async_load; }; yyBuiltIn.prototype.get_event_data = function () { return this.event_data; }; yyBuiltIn.prototype.get_display_aa = function () { return 0; }; diff --git a/scripts/yyEffects.js b/scripts/yyEffects.js index 26c0f7a8..580bfdc8 100644 --- a/scripts/yyEffects.js +++ b/scripts/yyEffects.js @@ -319,11 +319,11 @@ yyFilterHost.prototype.Step = function () { if (this.startTime == -1) { - this.startTime = YoYo_GetTimer(); + this.startTime = get_timer(); } else { - this.elapsedTime = YoYo_GetTimer() - this.startTime; + this.elapsedTime = get_timer() - this.startTime; } }; From 0c0f76a742d8eda7066f4953ccc4447f3090952a Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 11:50:51 +0300 Subject: [PATCH 22/84] Removed the seemingly-long-unused Fingerprint.js + YYUDID --- scripts/_GameMaker.js | 16 -- scripts/fingerprintjs/fingerprint.js | 285 --------------------------- 2 files changed, 301 deletions(-) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 3f407697..7da7f09d 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -2039,22 +2039,6 @@ function IntToHex(_val) } return s; } -function YYUDID() -{ - //Needs to return a udid for the machine we are running on - - var fingerprint = new Fingerprint().get(); - - - return fingerprint; - - // return "e2770c0a-928f-4985-b331-cf6e2c3c56b5"; -} -// ############################################################################################# -/// Function: -/// Process HTML5 "pingback" -/// -// ############################################################################################# function StringToArray8(str) { diff --git a/scripts/fingerprintjs/fingerprint.js b/scripts/fingerprintjs/fingerprint.js index bd1dff15..e69de29b 100644 --- a/scripts/fingerprintjs/fingerprint.js +++ b/scripts/fingerprintjs/fingerprint.js @@ -1,285 +0,0 @@ -/* -* fingerprintJS 0.5.4 - Fast browser fingerprint library -* https://github.com/Valve/fingerprintjs -* Copyright (c) 2013 Valentin Vasilyev (valentin.vasilyev@outlook.com) -* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -;(function (name, context, definition) { - if (typeof module !== 'undefined' && module.exports) { module.exports = definition(); } - else if (typeof define === 'function' && define.amd) { define(definition); } - else { context[name] = definition(); } -})('Fingerprint', this, function () { - 'use strict'; - - var Fingerprint = function (options) { - var nativeForEach, nativeMap; - nativeForEach = Array.prototype.forEach; - nativeMap = Array.prototype.map; - - this.each = function (obj, iterator, context) { - if (obj === null) { - return; - } - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, l = obj.length; i < l; i++) { - if (iterator.call(context, obj[i], i, obj) === {}) return; - } - } else { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - if (iterator.call(context, obj[key], key, obj) === {}) return; - } - } - } - }; - - this.map = function(obj, iterator, context) { - var results = []; - // Not using strict equality so that this acts as a - // shortcut to checking for `null` and `undefined`. - if (obj == null) return results; - if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); - this.each(obj, function(value, index, list) { - results[results.length] = iterator.call(context, value, index, list); - }); - return results; - }; - - if (typeof options == 'object'){ - this.hasher = options.hasher; - this.screen_resolution = options.screen_resolution; - this.screen_orientation = options.screen_orientation; - this.canvas = options.canvas; - this.ie_activex = options.ie_activex; - } else if(typeof options == 'function'){ - this.hasher = options; - } - }; - - Fingerprint.prototype = { - get: function(){ - var keys = []; - keys.push(navigator.userAgent); - keys.push(navigator.language); - keys.push(screen.colorDepth); - if (this.screen_resolution) { - var resolution = this.getScreenResolution(); - if (typeof resolution !== 'undefined'){ // headless browsers, such as phantomjs - keys.push(resolution.join('x')); - } - } - keys.push(new Date().getTimezoneOffset()); - keys.push(this.hasSessionStorage()); - keys.push(this.hasLocalStorage()); - keys.push(!!window.indexedDB); - //body might not be defined at this point or removed programmatically - if(document.body){ - keys.push(typeof(document.body.addBehavior)); - } else { - keys.push(typeof undefined); - } - keys.push(typeof(window.openDatabase)); - keys.push(navigator.cpuClass); - keys.push(navigator.platform); - keys.push(navigator.doNotTrack); - keys.push(this.getPluginsString()); - if(this.canvas && this.isCanvasSupported()){ - keys.push(this.getCanvasFingerprint()); - } - if(this.hasher){ - return this.hasher(keys.join('###'), 31); - } else { - return this.murmurhash3_32_gc(keys.join('###'), 31); - } - }, - - /** - * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011) - * - * @author Gary Court - * @see http://github.com/garycourt/murmurhash-js - * @author Austin Appleby - * @see http://sites.google.com/site/murmurhash/ - * - * @param {string} key ASCII only - * @param {number} seed Positive integer only - * @return {number} 32-bit positive integer hash - */ - - murmurhash3_32_gc: function(key, seed) { - var remainder, bytes, h1, h1b, c1, c2, k1, i; - - remainder = key.length & 3; // key.length % 4 - bytes = key.length - remainder; - h1 = seed; - c1 = 0xcc9e2d51; - c2 = 0x1b873593; - i = 0; - - while (i < bytes) { - k1 = - ((key.charCodeAt(i) & 0xff)) | - ((key.charCodeAt(++i) & 0xff) << 8) | - ((key.charCodeAt(++i) & 0xff) << 16) | - ((key.charCodeAt(++i) & 0xff) << 24); - ++i; - - k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff; - k1 = (k1 << 15) | (k1 >>> 17); - k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff; - - h1 ^= k1; - h1 = (h1 << 13) | (h1 >>> 19); - h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff; - h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16)); - } - - k1 = 0; - - switch (remainder) { - case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16; - case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8; - case 1: k1 ^= (key.charCodeAt(i) & 0xff); - - k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff; - k1 = (k1 << 15) | (k1 >>> 17); - k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff; - h1 ^= k1; - } - - h1 ^= key.length; - - h1 ^= h1 >>> 16; - h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff; - h1 ^= h1 >>> 13; - h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; - h1 ^= h1 >>> 16; - - return h1 >>> 0; - }, - - // https://bugzilla.mozilla.org/show_bug.cgi?id=781447 - hasLocalStorage: function () { - try{ - return !!window.localStorage; - } catch(e) { - return true; // SecurityError when referencing it means it exists - } - }, - - hasSessionStorage: function () { - try{ - return !!window.sessionStorage; - } catch(e) { - return true; // SecurityError when referencing it means it exists - } - }, - - isCanvasSupported: function () { - var elem = document.createElement('canvas'); - return !!(elem.getContext && elem.getContext('2d')); - }, - - isIE: function () { - if(navigator.appName === 'Microsoft Internet Explorer') { - return true; - } else if(navigator.appName === 'Netscape' && new RegExp('Trident').test(navigator.userAgent)){// IE 11 - return true; - } - return false; - }, - - getPluginsString: function () { - if(this.isIE() && this.ie_activex){ - return this.getIEPluginsString(); - } else { - return this.getRegularPluginsString(); - } - }, - - getRegularPluginsString: function () { - return this.map(navigator.plugins, function (p) { - var mimeTypes = this.map(p, function(mt){ - return [mt.type, mt.suffixes].join('~'); - }).join(','); - return [p.name, p.description, mimeTypes].join('::'); - }, this).join(';'); - }, - - getIEPluginsString: function () { - if(window.ActiveXObject){ - var names = ['ShockwaveFlash.ShockwaveFlash',//flash plugin - 'AcroPDF.PDF', // Adobe PDF reader 7+ - 'PDF.PdfCtrl', // Adobe PDF reader 6 and earlier, brrr - 'QuickTime.QuickTime', // QuickTime - // 5 versions of real players - 'rmocx.RealPlayer G2 Control', - 'rmocx.RealPlayer G2 Control.1', - 'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)', - 'RealVideo.RealVideo(tm) ActiveX Control (32-bit)', - 'RealPlayer', - 'SWCtl.SWCtl', // ShockWave player - 'WMPlayer.OCX', // Windows media player - 'AgControl.AgControl', // Silverlight - 'Skype.Detection']; - - // starting to detect plugins in IE - return this.map(names, function(name){ - try{ - new ActiveXObject(name); - return name; - } catch(e){ - return null; - } - }).join(';'); - } else { - return ""; // behavior prior version 0.5.0, not breaking backwards compat. - } - }, - - getScreenResolution: function () { - var resolution; - if(this.screen_orientation){ - resolution = (screen.height > screen.width) ? [screen.height, screen.width] : [screen.width, screen.height]; - }else{ - resolution = [screen.height, screen.width]; - } - return resolution; - }, - - getCanvasFingerprint: function () { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - // https://www.browserleaks.com/canvas#how-does-it-work - var txt = 'http://valve.github.io'; - ctx.textBaseline = "top"; - ctx.font = "14px 'Arial'"; - ctx.textBaseline = "alphabetic"; - ctx.fillStyle = "#f60"; - ctx.fillRect(125,1,62,20); - ctx.fillStyle = "#069"; - ctx.fillText(txt, 2, 15); - ctx.fillStyle = "rgba(102, 204, 0, 0.7)"; - ctx.fillText(txt, 4, 17); - return canvas.toDataURL(); - } - }; - - - return Fingerprint; - -}); From d7c9a444d227ead610471e9633d3eb0ea23999c6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 19:42:26 +0300 Subject: [PATCH 23/84] Some corrections to conditional compilation in sequences (after testing sprite broadcasts more) --- scripts/animation/yySkeletonInstance.js | 4 +++ scripts/yySequence.js | 39 +++++++++++++++++++------ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/scripts/animation/yySkeletonInstance.js b/scripts/animation/yySkeletonInstance.js index 586db10e..96f5669c 100644 --- a/scripts/animation/yySkeletonInstance.js +++ b/scripts/animation/yySkeletonInstance.js @@ -153,6 +153,8 @@ yySkeletonInstance.prototype.FrameCount = function (_sprite, _track) { return ~~((updatesCount * this.m_animationState.tracks[_track].animation.duration) + 0.5); }; +// @endif + function fwrap(_val, _div) { // _div needs to be positive @@ -166,6 +168,8 @@ function fwrap(_val, _div) return scaledfrac; } +// @if feature("spine") + // ############################################################################################# /// Function: /// Get the index of the animation on the specified track diff --git a/scripts/yySequence.js b/scripts/yySequence.js index 1846db27..9471e910 100644 --- a/scripts/yySequence.js +++ b/scripts/yySequence.js @@ -66,8 +66,6 @@ function CSequenceBaseClass() }; } - -// @if feature("sequences") eTT_Link = 0; eTT_Invisible = 1; eTT_Disable = 2; @@ -106,6 +104,8 @@ eSTT_Text = 17; eSTT_Particle = 18; eSTT_Max = 19; +// @if feature("sequences") + function TrackIsParameter(type) { return (type == eSTT_Real || type == eSTT_Color || type == eSTT_Bool || type == eSTT_String); } eT_UserDefined = 0; @@ -167,15 +167,14 @@ SEQ_KEY_LENGTH_EPSILON = -0.0001; g_CurrSequenceID = 0; g_CurrAnimCurveID = 0; -g_CurrTrackID = 0; +// @endif // used to track which sequences have been changed and need to be recomputed -g_CurrSeqObjChangeIndex = 1; - g_CurrSequenceObjectID = 0; g_SeqStack = []; +g_CurrTrackID = 0; // ############################################################################################# /// Function: /// Returns a new Track ID @@ -186,6 +185,8 @@ function GetTrackID() return g_CurrTrackID++; } +g_CurrSeqObjChangeIndex = 1; + // ############################################################################################# /// Function: /// Returns the current sequence object change index @@ -206,6 +207,8 @@ function GetNextSeqObjChangeIndex() return g_CurrSeqObjChangeIndex++; } +// @if feature("sequences") + // ############################################################################################# /// Function: /// Multiplies the given matrix by a matrix composed of the given x, y, @@ -262,6 +265,8 @@ function GetTrackKeyRanges(_headPos, _lastHeadPos, _headDir, _speedscale, _pTrac return _pTrack.m_keyframeStore.GetKeyframeIndexRanges(_pSeq.m_playback, playbackspeed, _pSeq.m_length, _lastHeadPos, _headPos, headDir, _startKeys, _endKeys, false); } +// @endif + // ############################################################################################# /// Function: /// Parses the give storage data and return a new Track object @@ -297,6 +302,8 @@ function SequenceBaseTrack_Load(_pStorage) { } } +// @if feature("sequences") + // ############################################################################################# /// Function: /// Create a new Real Track object @@ -1006,6 +1013,8 @@ function yySequenceColourTrack(_pStorage) { }; } +// @endif + // ############################################################################################# /// Function: /// Create a new Sprite Frames Track object @@ -1072,6 +1081,8 @@ function yySequenceSpriteFramesTrack(_pStorage) { }; } +// @if feature("sequences") + // ############################################################################################# /// Function: /// Create a new Sequence Track object @@ -1226,6 +1237,8 @@ function yySequenceBoolTrack(_pStorage) { this.m_type = eSTT_Bool; } +// @endif + // ############################################################################################# /// Function: /// Create a new Track object @@ -1646,6 +1659,7 @@ function yySequenceBaseTrack(_pStorage) { }; } + // ############################################################################################# /// Function: /// Constrctor for the abstract TrackKeyBase object @@ -1706,6 +1720,8 @@ function yyMessageEventTrackKey(_pStorage) }); } +// @if feature("sequences") + // ############################################################################################# /// Function: /// Create a new Code Event Track Key object @@ -2302,6 +2318,8 @@ function yySequenceTrackKey(_pStorage) this.__type = "[SequenceTrackKey]"; } +// @endif sequence - tracks + // ############################################################################################# /// Function: /// Create a new SpriteFrames Track Key object @@ -2466,7 +2484,6 @@ function yyKeyframe(_type, _pStorage) { }); } - // ############################################################################################# /// Function: /// Create a new KeyframeStore object @@ -2970,7 +2987,6 @@ yyKeyframeStore.prototype.GetKeyframeIndexRanges = function (_loopmode, _speed, return havekeys; }; -// @endif sequence - tracks var typeToEventLut = [ @@ -3574,7 +3590,6 @@ yySequenceManager.prototype.GetNewInstance = function () var g_pMessageEvents = []; var g_pMomentEvents = []; -var g_pSpriteMessageEvents = []; function AddMessageEvent(_pKey, _seqElementID) { @@ -3592,6 +3607,8 @@ function AddMomentEvent(_pKey, _pSeqInst) g_pMomentEvents[g_pMomentEvents.length] = newEvt; } +// @endif + function AddSpriteMessageEvent(_pKey, _elementID) { var newEvt = new Object(); @@ -3607,11 +3624,14 @@ function AddSpriteMessageEvent(_pKey, _elementID) /// // ############################################################################################# +var g_pSpriteMessageEvents = []; function ResetSpriteMessageEvents() { g_pSpriteMessageEvents = []; } +// @if feature("sequences") + yySequenceManager.prototype.EvaluateLayerSequenceElement = function(_pSeqEl, _preDrawUpdate) { if (_pSeqEl == null) @@ -4120,8 +4140,9 @@ function ProcessSpriteMessageEvents() ds_map_add(map, "event_type", "sprite event"); ds_map_add(map, "element_id", g_pSpriteMessageEvents[i].elementID); ds_map_add(map, "message", eventlist.m_events[j]); - + // @if feature("sequences") g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_OTHER_BROADCAST_MESSAGE); + // @endif //g_pObjectManager.ThrowEvent(EVENT_OTHER_SYSTEM_EVENT, 0); g_pObjectManager.ThrowEvent(EVENT_OTHER_BROADCAST_MESSAGE, 0); From 0f2939b3bec8db13307696e3cae78bf9215036dc Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 8 Aug 2023 19:44:04 +0300 Subject: [PATCH 24/84] Strip some of the TTF helpers if font_add is never called --- scripts/fontjs/Font.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/fontjs/Font.js b/scripts/fontjs/Font.js index 82d02f5f..70847e80 100644 --- a/scripts/fontjs/Font.js +++ b/scripts/fontjs/Font.js @@ -1,3 +1,4 @@ +// @if function("font_add") /** Font.js v2012.01.25 @@ -824,4 +825,5 @@ */ window.Font = Font; -} (window)); \ No newline at end of file +} (window)); +// @endif \ No newline at end of file From d7afdfa6ad8c0122e93a2eacefeb8aa45e8a3c10 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 11:49:00 +0300 Subject: [PATCH 25/84] Strip virtual_key_ helpers if unused --- scripts/Globals.js | 2 ++ scripts/_GameMaker.js | 2 ++ scripts/yyIOManager.js | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index 285363e2..86c22f42 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1205,7 +1205,9 @@ function InitAboyneGlobals() { g_RootDir = g_pGMFile.Options.GameDir + '/'; } } + // @if function("virtual_key_*") g_VirtualKeyDrawList = []; + // @endif g_HighScoreValues = []; g_HighScoreNames = []; diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 7da7f09d..301dcc88 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -1131,7 +1131,9 @@ function StartRoom( _numb, _starting ) ParticleSystem_RemoveAllFromLayers(); + // @if function("virtual_key_*") DeleteAllVirtualKeys(); + // @endif // Extract all persistent instances from the room currently in use. // NB: This is done first since clearing the rooms m_Active list means that if diff --git a/scripts/yyIOManager.js b/scripts/yyIOManager.js index 248e23f3..c460ecaf 100644 --- a/scripts/yyIOManager.js +++ b/scripts/yyIOManager.js @@ -18,9 +18,11 @@ var MAX_KEYS = 256; var MAX_BUTTONS = 5; var MAX_INPUT_STRING = 1024; +// @if function("virtual_key_*") var VIRTUALKEY_ACTIVE = 1; var VIRTUALKEY_DRAW = 2; var VIRTUALKEY_OUTLINE = 4; +// @endif var NEW_INPUT_EVENT = 1; // this is a new event var TOUCH_INPUT_EVENT = 2; // this was done via mouse or touch @@ -53,13 +55,17 @@ var g_KeyPressed = []; var g_KeyUp = []; // Used for virtual key-press tracking +// @if function("virtual_key_*") var g_VirtualKeys = []; +// @endif var g_InputEvents = []; // Collects together the current set of input events, including holding onto the mouse down state var g_CurrentInputEvents = []; +// @if function("virtual_key_*") var g_LastVirtualKeys = 0; +// @endif // Collects together all touch events as single-button mice var g_TouchEvents = []; @@ -1060,7 +1066,9 @@ function yyIOManager( ) this.HandleKeyDown = IO_HandleKeyDown; this.HandleKeyPressed= IO_HandleKeyPressed; this.HandleKeyReleased= IO_HandleKeyReleased; + // @if function("virtual_key_*") this.ProcessVirtualKeys = ProcessVirtualKeys; + // @endif // going from 0 to max makes it a "proper" packed array, and is much faster for some Javascript engines. for (var l = 0; l < MAX_KEYS; l++){ @@ -1813,7 +1821,9 @@ function IO_Update() g_pBuiltIn.mouse_button = g_EventButtonDown + 1; g_pBuiltIn.mouse_lastbutton = g_EventLastButtonDown + 1; + // @if function("virtual_key_*") this.ProcessVirtualKeys(); + // @endif } // ############################################################################################# @@ -1822,6 +1832,7 @@ function IO_Update() /// // ############################################################################################# /** @this {yyIOManager} */ +// @if function("virtual_key_*") function ProcessVirtualKeys() { var CurrentVirtualKeyEvents = 0; @@ -1895,6 +1906,7 @@ function ProcessVirtualKeys() g_LastVirtualKeys = CurrentVirtualKeyEvents; } +// @endif virtualkey // ############################################################################################# /// Function: @@ -2194,6 +2206,7 @@ function HandleKeyboard() g_pIOManager.HandleKeyReleased(); } +// @if function("virtual_key_*") // ############################################################################################# /// Function: /// Constructor for a VirtualKey object @@ -2261,6 +2274,8 @@ function DeleteAllVirtualKeys() { g_VirtualKeys[l].flags = 0; } } +// @endif virtualkey helpers + // ############################################################################################# /// Property: /// Render IO specific stuff. @@ -2283,7 +2298,7 @@ yyIOManager.prototype.Render = function () { Graphics_SetTransform(trans); //graphics._setTransform(trans[0], trans[1], trans[2], trans[3], trans[4], trans[5]); - + // @if function("virtual_key_*") var oldalpha = draw_get_alpha(); var oldcolour = draw_get_color(); @@ -2300,4 +2315,5 @@ yyIOManager.prototype.Render = function () { draw_set_color(oldcolour); draw_set_alpha(oldalpha); Graphics_Restore(); + // @endif virtualkey draw }; From 72ab7d4ac04fbef4eb38cd0d73b7ab2aa9741792 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 11:50:25 +0300 Subject: [PATCH 26/84] Strip ds_priority_ class if unused --- scripts/functions/collections/ds_priority.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/functions/collections/ds_priority.js b/scripts/functions/collections/ds_priority.js index bec1f5ac..326ba2fa 100644 --- a/scripts/functions/collections/ds_priority.js +++ b/scripts/functions/collections/ds_priority.js @@ -15,7 +15,7 @@ // // ********************************************************************************************************************** - +// @if function("ds_priority_*") // ############################################################################################# /** @constructor */ function yyPriorityQueue_Save(_depth, _obj) { @@ -586,4 +586,4 @@ function ds_priority_read(_id, _pJSON) return true; } - +// @endif From b0054ea5c4548490380cb200e091e9a6b11277e6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 13:05:31 +0300 Subject: [PATCH 27/84] Strip mp_grid_ if unused --- scripts/functions/Function_MotionPlanning.js | 4 ++-- scripts/yyWebGL.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/functions/Function_MotionPlanning.js b/scripts/functions/Function_MotionPlanning.js index 18a5fccc..13f3f548 100644 --- a/scripts/functions/Function_MotionPlanning.js +++ b/scripts/functions/Function_MotionPlanning.js @@ -764,7 +764,7 @@ function mp_potential_path_object(_pInst, _path,_xg,_yg,_stepsize,_factor,_obj) - +// @if function("mp_grid_*") // ########################################################################################################################################################################################## // ########################################################################################################################################################################################## @@ -1405,4 +1405,4 @@ function mp_grid_to_ds_grid(_src, _dest) } } - +// @endif mp_grid diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index 3998423f..b7cebf32 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -172,7 +172,9 @@ function InitWebGLFunctions() { draw_enable_alphablend = WEBGL_draw_enable_alpha_blend_RELEASE; draw_surface = WebGL_draw_surface_RELEASE; draw_path = WEBGL_draw_path; + // @if function("mp_grid_*") mp_grid_draw = WEBGL_mp_grid_draw; + // @endif g_webGL._drawImage = WebGL_drawImage_Replacement_RELEASE; // Surfaces From 534d7a63e8f3298b3668e28746da6df804ca8dc6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 13:21:35 +0300 Subject: [PATCH 28/84] Removed GMS1-era `d3d_primitive_*` functions --- scripts/Builders/yyPrimBuilder.js | 263 ------------------------------ 1 file changed, 263 deletions(-) diff --git a/scripts/Builders/yyPrimBuilder.js b/scripts/Builders/yyPrimBuilder.js index 5d52ac39..f6c61036 100644 --- a/scripts/Builders/yyPrimBuilder.js +++ b/scripts/Builders/yyPrimBuilder.js @@ -20,22 +20,6 @@ var draw_primitive_begin = GetErrorFunction("draw_primitive_begin"), draw_vertex_texture_colour = draw_vertex_texture_color, draw_primitive_end = GetErrorFunction("draw_primitive_end"); -var d3d_primitive_begin = GetErrorFunction("d3d_primitive_begin"), - d3d_primitive_begin_texture = GetErrorFunction("d3d_primitive_begin_texture"), - d3d_vertex = GetErrorFunction("d3d_vertex"), - d3d_vertex_color = GetErrorFunction("d3d_vertex_color"), - d3d_vertex_colour = d3d_vertex_color, - d3d_vertex_texture = GetErrorFunction("d3d_vertex_texture"), - d3d_vertex_texture_color = GetErrorFunction("d3d_vertex_texture_color"), - d3d_vertex_texture_colour = d3d_vertex_texture_color, - d3d_vertex_normal = GetErrorFunction("d3d_vertex_normal"), - d3d_vertex_normal_color = GetErrorFunction("d3d_vertex_normal_color"), - d3d_vertex_normal_colour = d3d_vertex_normal_color, - d3d_vertex_normal_texture = GetErrorFunction("d3d_vertex_normal_texture"), - d3d_vertex_normal_texture_color = GetErrorFunction("d3d_vertex_normal_texture_color"), - d3d_vertex_normal_texture_colour = d3d_vertex_normal_texture_color, - d3d_primitive_end = GetErrorFunction("d3d_primitive_end"); - // ---------------------------------------------------------------------------------------------------------------------------------------- var g_PrimBuffer = null; // raw ArrayBuffer data @@ -68,23 +52,6 @@ function InitPrimBuilderFunctions() { draw_vertex_texture_color = WebGL_draw_vertex_texture_color_RELEASE; draw_vertex_texture_colour = WebGL_draw_vertex_texture_color_RELEASE; draw_primitive_end = WebGL_draw_primitive_end_RELEASE; - - // 3D primitives - d3d_primitive_begin = WebGL_d3d_primitive_begin_RELEASE; - d3d_primitive_begin_texture = WebGL_d3d_primitive_begin_texture_RELEASE; - d3d_vertex = WebGL_d3d_vertex_RELEASE; - d3d_vertex_color = WebGL_d3d_vertex_color_RELEASE; - d3d_vertex_colour = WebGL_d3d_vertex_color_RELEASE; - d3d_vertex_texture = WebGL_d3d_vertex_texture_RELEASE; - d3d_vertex_texture_color = WebGL_d3d_vertex_texture_color_RELEASE; - d3d_vertex_texture_colour = WebGL_d3d_vertex_texture_color_RELEASE; - d3d_vertex_normal = WebGL_d3d_vertex_normal_RELEASE; - d3d_vertex_normal_color = WebGL_d3d_vertex_normal_color_RELEASE; - d3d_vertex_normal_colour = WebGL_d3d_vertex_normal_color_RELEASE; - d3d_vertex_normal_texture = WebGL_d3d_vertex_normal_texture_RELEASE; - d3d_vertex_normal_texture_color = WebGL_d3d_vertex_normal_texture_color_RELEASE; - d3d_vertex_normal_texture_colour = WebGL_d3d_vertex_normal_texture_color_RELEASE; - d3d_primitive_end = WebGL_d3d_primitive_end_RELEASE; } // ############################################################################################# @@ -251,42 +218,6 @@ function WebGL_draw_primitive_end_RELEASE() { pBuff.Current += g_PrimVBuffer.Current; } -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_primitive_begin_RELEASE(kind) { - - d3d_primitive_begin_texture(kind, -1); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_primitive_begin_texture_RELEASE(_kind, _tex) { - - g_PrimType = _kind; - g_PrimTexture = null; - g_PrimTPE = null; - - // The texture provided might be an actual texture object or an index - if (typeof(_tex) == "object") { - g_PrimTexture = _tex.WebGLTexture; - g_PrimTPE = _tex.TPE; - } - else if ((_tex != -1) && g_Textures[_tex]) { - g_PrimTexture = g_Textures[_tex]; - } - - // If they've managed to find a path through the code without this texture being bound... - if (g_PrimTexture && !g_PrimTexture.webgl_textureid) { - WebGL_BindTexture({texture: g_PrimTexture}); - } - - g_PrimVBuffer = new yyVBuffer(DEFAULT_VB_SIZE, g_webGL.GetVertexFormat(g_webGL.VERTEX_FORMAT_3D), false); -} - // ############################################################################################# /// Function: /// If we have a TPE available, adjust the UV accordingly @@ -304,197 +235,3 @@ function vertex_uv(_u, _v) { return ({ u: _u, v: _v }); } }; - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_vertex_RELEASE(_x, _y, _z) { - - var stride = g_PrimVBuffer.GetStride() >> 2; - var index = g_PrimVBuffer.Current * stride; - g_PrimVBuffer.IncreaseCurrent(1); - - g_PrimVBuffer.Coords[index + 0] = _x; - g_PrimVBuffer.Coords[index + 1] = _y; - g_PrimVBuffer.Coords[index + 2] = _z; - g_PrimVBuffer.Normals[index + 0] = 0; - g_PrimVBuffer.Normals[index + 1] = 0; - g_PrimVBuffer.Normals[index + 2] = 0; - g_PrimVBuffer.UVs[index + 0] = 0; - g_PrimVBuffer.UVs[index + 1] = 0; - g_PrimVBuffer.Colours[index] = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_vertex_color_RELEASE(_x, _y, _z, _col, _alpha) { - - var stride = g_PrimVBuffer.GetStride() >> 2; - var index = g_PrimVBuffer.Current * stride; - g_PrimVBuffer.IncreaseCurrent(1); - - g_PrimVBuffer.Coords[index + 0] = _x; - g_PrimVBuffer.Coords[index + 1] = _y; - g_PrimVBuffer.Coords[index + 2] = _z; - g_PrimVBuffer.Normals[index + 0] = 0; - g_PrimVBuffer.Normals[index + 1] = 0; - g_PrimVBuffer.Normals[index + 2] = 0; - g_PrimVBuffer.UVs[index + 0] = 0; - g_PrimVBuffer.UVs[index + 1] = 0; - g_PrimVBuffer.Colours[index] = ((_alpha * 255.0) << 24) | ConvertGMColour(_col); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_vertex_texture_RELEASE(_x, _y, _z, _xtex, _ytex) { - - var stride = g_PrimVBuffer.GetStride() >> 2; - var index = g_PrimVBuffer.Current * stride; - g_PrimVBuffer.IncreaseCurrent(1); - - g_PrimVBuffer.Coords[index + 0] = _x; - g_PrimVBuffer.Coords[index + 1] = _y; - g_PrimVBuffer.Coords[index + 2] = _z; - g_PrimVBuffer.Normals[index + 0] = 0; - g_PrimVBuffer.Normals[index + 1] = 0; - g_PrimVBuffer.Normals[index + 2] = 0; - var uv = vertex_uv(_xtex, _ytex); - g_PrimVBuffer.UVs[index + 0] = uv.u; - g_PrimVBuffer.UVs[index + 1] = uv.v; - g_PrimVBuffer.Colours[index] = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_vertex_texture_color_RELEASE(_x, _y, _z, _xtex, _ytex, _col, _alpha) { - - var stride = g_PrimVBuffer.GetStride() >> 2; - var index = g_PrimVBuffer.Current * stride; - g_PrimVBuffer.IncreaseCurrent(1); - - g_PrimVBuffer.Coords[index + 0] = _x; - g_PrimVBuffer.Coords[index + 1] = _y; - g_PrimVBuffer.Coords[index + 2] = _z; - g_PrimVBuffer.Normals[index + 0] = 0; - g_PrimVBuffer.Normals[index + 1] = 0; - g_PrimVBuffer.Normals[index + 2] = 0; - var uv = vertex_uv(_xtex, _ytex); - g_PrimVBuffer.UVs[index + 0] = uv.u; - g_PrimVBuffer.UVs[index + 1] = uv.v; - g_PrimVBuffer.Colours[index] = ((_alpha * 255.0) << 24) | ConvertGMColour(_col); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_vertex_normal_RELEASE(_x, _y, _z, _nx, _ny, _nz) { - - var stride = g_PrimVBuffer.GetStride() >> 2; - var index = g_PrimVBuffer.Current * stride; - g_PrimVBuffer.IncreaseCurrent(1); - - g_PrimVBuffer.Coords[index + 0] = _x; - g_PrimVBuffer.Coords[index + 1] = _y; - g_PrimVBuffer.Coords[index + 2] = _z; - g_PrimVBuffer.Normals[index + 0] = _nx; - g_PrimVBuffer.Normals[index + 1] = _ny; - g_PrimVBuffer.Normals[index + 2] = _nz; - g_PrimVBuffer.UVs[index + 0] = 0; - g_PrimVBuffer.UVs[index + 1] = 0; - g_PrimVBuffer.Colours[index] = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_vertex_normal_color_RELEASE(_x, _y, _z, _nx, _ny, _nz, _col, _alpha) { - - var stride = g_PrimVBuffer.GetStride() >> 2; - var index = g_PrimVBuffer.Current * stride; - g_PrimVBuffer.IncreaseCurrent(1); - - g_PrimVBuffer.Coords[index + 0] = _x; - g_PrimVBuffer.Coords[index + 1] = _y; - g_PrimVBuffer.Coords[index + 2] = _z; - g_PrimVBuffer.Normals[index + 0] = _nx; - g_PrimVBuffer.Normals[index + 1] = _ny; - g_PrimVBuffer.Normals[index + 2] = _nz; - g_PrimVBuffer.UVs[index + 0] = 0; - g_PrimVBuffer.UVs[index + 1] = 0; - g_PrimVBuffer.Colours[index] = ((_alpha * 255.0) << 24) | ConvertGMColour(_col); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_vertex_normal_texture_RELEASE(_x, _y, _z, _nx, _ny, _nz, _xtex, _ytex) { - - var stride = g_PrimVBuffer.GetStride() >> 2; - var index = g_PrimVBuffer.Current * stride; - g_PrimVBuffer.IncreaseCurrent(1); - - g_PrimVBuffer.Coords[index + 0] = _x; - g_PrimVBuffer.Coords[index + 1] = _y; - g_PrimVBuffer.Coords[index + 2] = _z; - g_PrimVBuffer.Normals[index + 0] = _nx; - g_PrimVBuffer.Normals[index + 1] = _ny; - g_PrimVBuffer.Normals[index + 2] = _nz; - var uv = vertex_uv(_xtex, _ytex); - g_PrimVBuffer.UVs[index + 0] = uv.u; - g_PrimVBuffer.UVs[index + 1] = uv.v; - g_PrimVBuffer.Colours[index] = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_vertex_normal_texture_color_RELEASE(_x, _y, _z, _nx, _ny, _nz, _xtex, _ytex, _col, _alpha) { - - var stride = g_PrimVBuffer.GetStride() >> 2; - var index = g_PrimVBuffer.Current * stride; - g_PrimVBuffer.IncreaseCurrent(1); - - g_PrimVBuffer.Coords[index + 0] = _x; - g_PrimVBuffer.Coords[index + 1] = _y; - g_PrimVBuffer.Coords[index + 2] = _z; - g_PrimVBuffer.Normals[index + 0] = _nx; - g_PrimVBuffer.Normals[index + 1] = _ny; - g_PrimVBuffer.Normals[index + 2] = _nz; - var uv = vertex_uv(_xtex, _ytex); - g_PrimVBuffer.UVs[index + 0] = uv.u; - g_PrimVBuffer.UVs[index + 1] = uv.v; - g_PrimVBuffer.Colours[index] = ((_alpha * 255.0) << 24) | ConvertGMColour(_col); -} - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_d3d_primitive_end_RELEASE() { - - var prim = WebGL_translate_primitive_builder_type(g_PrimType); - if (prim == -1) { - return; - } - - // Transfer the stored primitive block to the vbuffer manager - var vertexData = g_PrimVBuffer.VertexData.subarray(0, g_PrimVBuffer.Current * g_PrimVBuffer.GetStride()); - - // Alloc vertices - var glTexture = g_PrimTexture ? g_PrimTexture.webgl_textureid : null; - var pBuff = g_webGL.AllocVerts(prim, glTexture, g_webGL.VERTEX_FORMAT_3D, g_PrimVBuffer.Current); - - pBuff.VertexData.set(vertexData, pBuff.Current * pBuff.GetStride()); - pBuff.Current += g_PrimVBuffer.Current; -} \ No newline at end of file From f59250e4e3c665665f5e7f941121c20101072472 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 16:07:51 +0300 Subject: [PATCH 29/84] Strip path_ functions and properties if unused --- scripts/LoadGame.js | 2 ++ scripts/functions/Function_Path.js | 3 ++- scripts/yyInstance.js | 10 ++++++---- scripts/yyPath.js | 3 ++- scripts/yyWebGL.js | 2 ++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index c544f455..80a964b1 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -56,7 +56,9 @@ function InitAboyne() g_pSoundManager = new yySoundManager(); g_pFontManager = new yyFontManager(); g_pCollisionList = []; + // @if feature("paths") g_pPathManager = new yyPathManager(); + // @endif // @if feature("timelines") g_pTimelineManager = new yyTimelineManager(); // @endif diff --git a/scripts/functions/Function_Path.js b/scripts/functions/Function_Path.js index 58ee226b..f90a435d 100644 --- a/scripts/functions/Function_Path.js +++ b/scripts/functions/Function_Path.js @@ -15,7 +15,7 @@ // // ********************************************************************************************************************** - +// @if feature("paths") // ############################################################################################# /// Function: @@ -767,4 +767,5 @@ function path_clear_points(_ind) { pPath.Clear(); } +// @endif diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index 19864f78..47d98918 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -304,6 +304,7 @@ yyInstance.prototype = { } }, + // @if feature("paths") // path position property get path_position() { return this.__path_position; }, set path_position(_val) { @@ -357,6 +358,7 @@ yyInstance.prototype = { this.__path_endaction = _val; }, + // @endif // @if feature("timelines") // timeline index property @@ -2586,7 +2588,7 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) { - +// @if feature("paths") // ############################################################################################# /// Function: @@ -2646,7 +2648,7 @@ yyInstance.prototype.Assign_Path = function (_ind, _speed, _scale, _orient, _abs this.path_xstart = this.x; this.path_ystart = this.y; }; - +// @endif // ############################################################################################# /// Function: @@ -2658,6 +2660,7 @@ yyInstance.prototype.Assign_Path = function (_ind, _speed, _scale, _orient, _abs /// // ############################################################################################# yyInstance.prototype.Adapt_Path = function () { + // @if feature("paths") var sp, xx, yy; @@ -2781,10 +2784,9 @@ yyInstance.prototype.Adapt_Path = function () { this.SetPosition(newx, newy); return atPathEnd; + // @endif }; - - // ############################################################################################# /// Function: /// get the alarm timer for the given index diff --git a/scripts/yyPath.js b/scripts/yyPath.js index 53b762a2..2ffa98fd 100644 --- a/scripts/yyPath.js +++ b/scripts/yyPath.js @@ -15,6 +15,7 @@ // // ********************************************************************************************************************** +// @if feature("paths") var P_STRAIGHT = 0, P_CURVED = 1; @@ -849,4 +850,4 @@ yyPathManager.prototype.Delete = function (_pPath) { this.Paths[_pPath.id] = undefined; }; - +// @endif diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index b7cebf32..0ebe1570 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -171,7 +171,9 @@ function InitWebGLFunctions() { draw_set_blend_mode_ext = WEBGL_draw_set_blend_mode_ext_RELEASE; draw_enable_alphablend = WEBGL_draw_enable_alpha_blend_RELEASE; draw_surface = WebGL_draw_surface_RELEASE; + // @if feature("paths") draw_path = WEBGL_draw_path; + // @endif // @if function("mp_grid_*") mp_grid_draw = WEBGL_mp_grid_draw; // @endif From 9ec53da914c8dccdbe50170ab18c8e27a5083231 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 16:08:39 +0300 Subject: [PATCH 30/84] Strip debug window when not running in debug mode --- scripts/_GameMaker.js | 6 ++++++ scripts/functions/Function_Debug.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 301dcc88..7da46fda 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -297,6 +297,7 @@ function ToggleDebugPause() { /// /// // ############################################################################################# +// @if feature("debug") function CreateDebugConsole() { try @@ -356,6 +357,7 @@ function CreateDebugConsole() { debug(e.message); } } +// @endif @@ -678,10 +680,12 @@ function GameMaker_Init() console.log("using internal runtime facebook"); YoYoFBInit(g_pGMFile.Options.Facebook); } + // @if feature("debug") else if (g_pGMFile.Options && g_pGMFile.Options.debugMode) { CreateDebugConsole(); } + // @endif // Remember these settings, as FULLSCREEN will mess them up. RememberCanvasSettings(); @@ -2333,7 +2337,9 @@ function GameMaker_Tick() } // if in DEBUG mode, do debug "stuff" + // @if feature("debug") if (g_pGMFile.Options && g_pGMFile.Options.debugMode) { UpdateDebugWindow(); } + // @endif } diff --git a/scripts/functions/Function_Debug.js b/scripts/functions/Function_Debug.js index 4cf7b8cb..6ff03bc3 100644 --- a/scripts/functions/Function_Debug.js +++ b/scripts/functions/Function_Debug.js @@ -1182,7 +1182,7 @@ function getStacktraceArray(_error) { return ret; } - +// @if feature("debug") // ############################################################################################# /// Function: /// Update the debug windows "instance" list @@ -1358,3 +1358,5 @@ function UpdateDebugWindow() { UpdateDebugInstanceList(); UpdateInsanceData(); } + +// @endif From 36429b6f0dcbc779a7586ce61c5491d206a2f22c Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 15:19:25 +0300 Subject: [PATCH 31/84] Strip video_ functions when unused --- scripts/yyVideo.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/yyVideo.js b/scripts/yyVideo.js index 7b63ac78..7b72a4dc 100644 --- a/scripts/yyVideo.js +++ b/scripts/yyVideo.js @@ -10,6 +10,7 @@ // // ********************************************************************************************************************** +// @if function("video_") var g_VideoUserEnded = false; //For some reason I can't figure this from the video player... function video_get_format() { @@ -543,4 +544,5 @@ function video_get_volume() } return 0; -} \ No newline at end of file +} +// @endif From e7b644cf15c967ae02e6eef97f727b900f0b0cf7 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 15:22:18 +0300 Subject: [PATCH 32/84] A slightly better structure for ErrorFunction/GetErrorFunction --- scripts/functions/Function_Debug.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/functions/Function_Debug.js b/scripts/functions/Function_Debug.js index 6ff03bc3..511d9840 100644 --- a/scripts/functions/Function_Debug.js +++ b/scripts/functions/Function_Debug.js @@ -176,7 +176,7 @@ function ErrorOnce(_text) { /// /// // ############################################################################################# -function ErrorFunction(_text) +function ErrorFunction(_text, _returnValue) { if( !g_MissingFunction_done[_text] ) { @@ -184,14 +184,11 @@ function ErrorFunction(_text) var txt = "Error: function " + _text + " is not supported."; debug( txt ); } + return _returnValue; } function GetErrorFunction(name, returnValue) { - return function() - { - ErrorFunction(name); - return returnValue; - } + return () => ErrorFunction(name, returnValue); } From 47ecff7e7ceb6eb71cde4f91c4be49d507265072 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 15:48:01 +0300 Subject: [PATCH 33/84] Primitive and vertex_ functions are now stripped if unused --- scripts/Builders/yyPrimBuilder.js | 89 +++++++++++++++++------------ scripts/yyBufferVertex.js | 94 ++++++++++++++++++++++--------- scripts/yyVertexManager.js | 49 ++++++++++++---- scripts/yyWebGL.js | 6 +- 4 files changed, 162 insertions(+), 76 deletions(-) diff --git a/scripts/Builders/yyPrimBuilder.js b/scripts/Builders/yyPrimBuilder.js index f6c61036..1bed8eed 100644 --- a/scripts/Builders/yyPrimBuilder.js +++ b/scripts/Builders/yyPrimBuilder.js @@ -10,24 +10,9 @@ // // ********************************************************************************************************************* -var draw_primitive_begin = GetErrorFunction("draw_primitive_begin"), - draw_primitive_begin_texture = GetErrorFunction("draw_primitive_begin_texture"), - draw_vertex = GetErrorFunction("draw_vertex"), - draw_vertex_color = GetErrorFunction("draw_vertex_color"), - draw_vertex_colour = draw_vertex_color, - draw_vertex_texture = GetErrorFunction("draw_vertex_texture"), - draw_vertex_texture_color = GetErrorFunction("draw_vertex_texture_color"), - draw_vertex_texture_colour = draw_vertex_texture_color, - draw_primitive_end = GetErrorFunction("draw_primitive_end"); - -// ---------------------------------------------------------------------------------------------------------------------------------------- -var g_PrimBuffer = null; // raw ArrayBuffer data - -var g_PrimType = 0, - g_PrimTexture = -1, - g_PrimTPE = null, - g_PrimVBuffer = null; +// @if feature("gl") && (function("draw_primitive_*") || function("draw_vertex*") || function("vertex_*")) +// primitive type translation is shared between draw_primitive_* and vertex_submit var PrimType_POINTLIST = 1, PrimType_LINELIST = 2, PrimType_LINESTRIP = 3, @@ -36,6 +21,55 @@ var PrimType_POINTLIST = 1, PrimType_TRIFAN = 6, PrimType_SPRITE = 7; +function WebGL_translate_primitive_builder_type(_prim) { + + switch (_prim) { + case PrimType_POINTLIST: return yyGL.PRIM_POINT; + case PrimType_LINELIST: return yyGL.PRIM_LINE; + case PrimType_LINESTRIP: return yyGL.PRIM_LINESTRIP; + case PrimType_TRILIST: return yyGL.PRIM_TRIANGLE; + case PrimType_TRISTRIP: return yyGL.PRIM_TRISTRIP; + case PrimType_TRIFAN: return yyGL.PRIM_TRIFAN; + case PrimType_SPRITE: return yyGL.PRIM_TRIANGLE; + } + return -1; +} + +// @endif primitives or vertex buffers on WebGL + +// @if function("draw_primitive_*") || function("draw_vertex*") +var draw_primitive_begin, + draw_primitive_begin_texture, + draw_vertex, + draw_vertex_color, + draw_vertex_colour, + draw_vertex_texture, + draw_vertex_texture_color, + draw_vertex_texture_colour, + draw_primitive_end; + +// @if feature("2d") +(() => { + let _stub = (_name) => () => ErrorFunction(_name); + draw_primitive_begin = _stub("draw_primitive_begin"); + draw_primitive_begin_texture = _stub("draw_primitive_begin_texture"); + draw_vertex = _stub("draw_vertex"); + draw_vertex_color = _stub("draw_vertex_color"); + draw_vertex_colour = draw_vertex_color; + draw_vertex_texture = _stub("draw_vertex_texture"); + draw_vertex_texture_color = _stub("draw_vertex_texture_color"); + draw_vertex_texture_colour = draw_vertex_texture_color; + draw_primitive_end = _stub("draw_primitive_end"); +})(); +// @endif 2d + +// @if feature("gl") + +var g_PrimType = 0, + g_PrimTexture = -1, + g_PrimTPE = null, + g_PrimVBuffer = null; + // ############################################################################################# /// Function: /// Bind primitive building functions to WebGL versions @@ -53,24 +87,6 @@ function InitPrimBuilderFunctions() { draw_vertex_texture_colour = WebGL_draw_vertex_texture_color_RELEASE; draw_primitive_end = WebGL_draw_primitive_end_RELEASE; } - -// ############################################################################################# -/// Function: -/// -// ############################################################################################# -function WebGL_translate_primitive_builder_type(_prim) { - - switch (_prim) { - case PrimType_POINTLIST: return yyGL.PRIM_POINT; - case PrimType_LINELIST: return yyGL.PRIM_LINE; - case PrimType_LINESTRIP: return yyGL.PRIM_LINESTRIP; - case PrimType_TRILIST: return yyGL.PRIM_TRIANGLE; - case PrimType_TRISTRIP: return yyGL.PRIM_TRISTRIP; - case PrimType_TRIFAN: return yyGL.PRIM_TRIFAN; - case PrimType_SPRITE: return yyGL.PRIM_TRIANGLE; - } - return -1; -} // ############################################################################################# /// Function: @@ -235,3 +251,6 @@ function vertex_uv(_u, _v) { return ({ u: _u, v: _v }); } }; +// @endif draw_primitive GL + +// @endif draw_primitive diff --git a/scripts/yyBufferVertex.js b/scripts/yyBufferVertex.js index da84f761..b5f25b8f 100644 --- a/scripts/yyBufferVertex.js +++ b/scripts/yyBufferVertex.js @@ -10,43 +10,77 @@ // // ********************************************************************************************************************** +// Global storage for vertex buffers +var g_vertexBuffers = []; + +// @if function("vertex_*") // ############################################################################################# // // Function definitions for Canvas mode // // ############################################################################################# -var vertex_create_buffer = GetErrorFunction("vertex_create_buffer", -1), - vertex_create_buffer_ext = GetErrorFunction("vertex_create_buffer_ext", -1), - vertex_delete_buffer = GetErrorFunction("vertex_delete_buffer"), - vertex_begin = GetErrorFunction("vertex_begin"), - vertex_end = GetErrorFunction("vertex_end"), - vertex_position = GetErrorFunction("vertex_position"), - vertex_position_3d = GetErrorFunction("vertex_position_3d"), - vertex_colour = GetErrorFunction("vertex_colour"), - vertex_color = GetErrorFunction("vertex_color"), - vertex_rgba = GetErrorFunction("vertex_rgba"), - vertex_argb = GetErrorFunction("vertex_argb"), - vertex_texcoord = GetErrorFunction("vertex_texcoord"), - vertex_normal = GetErrorFunction("vertex_normal"), - vertex_float1 = GetErrorFunction("vertex_float1"), - vertex_float2 = GetErrorFunction("vertex_float2"), - vertex_float3 = GetErrorFunction("vertex_float3"), - vertex_float4 = GetErrorFunction("vertex_float4"), - vertex_ubyte4 = GetErrorFunction("vertex_ubyte4"), - vertex_freeze = GetErrorFunction("vertex_freeze"), - vertex_submit = GetErrorFunction("vertex_submit"), - vertex_get_number = GetErrorFunction("vertex_get_number"), - vertex_get_buffer_size = GetErrorFunction("vertex_get_buffer_size"), - vertex_create_buffer_from_buffer = GetErrorFunction("vertex_create_buffer_from_buffer", -1), - vertex_create_buffer_from_buffer_ext = GetErrorFunction("vertex_create_buffer_from_buffer_ext", -1), - draw_flush = function () { }; +var vertex_create_buffer, + vertex_create_buffer_ext, + vertex_delete_buffer, + vertex_begin, + vertex_end, + vertex_position, + vertex_position_3d, + vertex_colour, + vertex_color, + vertex_rgba, + vertex_argb, + vertex_texcoord, + vertex_normal, + vertex_float1, + vertex_float2, + vertex_float3, + vertex_float4, + vertex_ubyte4, + vertex_freeze, + vertex_submit, + vertex_get_number, + vertex_get_buffer_size, + vertex_create_buffer_from_buffer, + vertex_create_buffer_from_buffer_ext, + draw_flush; + +// @if feature("2d") +(() => { + let _stub = (_name, _val) => () => ErrorFunction(_name, _val); + vertex_create_buffer = _stub("vertex_create_buffer", -1); + vertex_create_buffer_ext = _stub("vertex_create_buffer_ext", -1); + vertex_delete_buffer = _stub("vertex_delete_buffer"); + vertex_begin = _stub("vertex_begin"); + vertex_end = _stub("vertex_end"); + vertex_position = _stub("vertex_position"); + vertex_position_3d = _stub("vertex_position_3d"); + vertex_colour = _stub("vertex_colour"); + vertex_color = vertex_colour; + vertex_rgba = _stub("vertex_rgba"); + vertex_argb = _stub("vertex_argb"); + vertex_texcoord = _stub("vertex_texcoord"); + vertex_normal = _stub("vertex_normal"); + vertex_float1 = _stub("vertex_float1"); + vertex_float2 = _stub("vertex_float2"); + vertex_float3 = _stub("vertex_float3"); + vertex_float4 = _stub("vertex_float4"); + vertex_ubyte4 = _stub("vertex_ubyte4"); + vertex_freeze = _stub("vertex_freeze"); + vertex_submit = _stub("vertex_submit"); + vertex_get_number = _stub("vertex_get_number"); + vertex_get_buffer_size = _stub("vertex_get_buffer_size"); + vertex_create_buffer_from_buffer = _stub("vertex_create_buffer_from_buffer", -1); + vertex_create_buffer_from_buffer_ext = _stub("vertex_create_buffer_from_buffer_ext", -1); + draw_flush = ()=>{}; +})(); +// @endif + +// @if feature("gl") // Constant for the default vertex buffer storage size var DEFAULT_VERTEX_BUFFER_SIZE = 8 * 1024; -// Global storage for vertex buffers -var g_vertexBuffers = []; - // ############################################################################################# /// Function: /// Initialise the vertex buffer function pointers. @@ -434,3 +468,7 @@ function WebGL_vertex_get_buffer_size_RELEASE(_buffer) return 0; } + +// @endif gl + +// @endif vertex_ diff --git a/scripts/yyVertexManager.js b/scripts/yyVertexManager.js index ad35928a..60def0fb 100644 --- a/scripts/yyVertexManager.js +++ b/scripts/yyVertexManager.js @@ -10,17 +10,38 @@ // // ********************************************************************************************************************** -var vertex_format_begin = GetErrorFunction("vertex_format_begin"), - vertex_format_end = GetErrorFunction("vertex_format_end"), - vertex_format_delete = GetErrorFunction("vertex_format_delete"), - vertex_format_add_position = GetErrorFunction("vertex_format_add_position"), - vertex_format_add_position_3d = GetErrorFunction("vertex_format_add_position_3d"), - vertex_format_add_colour = GetErrorFunction("vertex_format_add_colour"), - vertex_format_add_color = GetErrorFunction("vertex_format_add_color"), - vertex_format_add_normal = GetErrorFunction("vertex_format_add_normal"), - vertex_format_add_texcoord = GetErrorFunction("vertex_format_add_texcoord"), - vertex_format_add_textcoord = GetErrorFunction("vertex_format_add_textcoord"), - vertex_format_add_custom = GetErrorFunction("vertex_format_add_custom"); +// @if function("vertex_*") + +var vertex_format_begin, + vertex_format_end, + vertex_format_delete, + vertex_format_add_position, + vertex_format_add_position_3d, + vertex_format_add_colour, + vertex_format_add_color, + vertex_format_add_normal, + vertex_format_add_texcoord, + vertex_format_add_textcoord, + vertex_format_add_custom; + +// @if feature("2d") +(() => { + let _stub = (_name, _val) => () => ErrorFunction(_name, _val); + vertex_format_begin = _stub("vertex_format_begin"); + vertex_format_end = _stub("vertex_format_end", -1); + vertex_format_delete = _stub("vertex_format_delete"); + vertex_format_add_position = _stub("vertex_format_add_position"); + vertex_format_add_position_3d = _stub("vertex_format_add_position_3d"); + vertex_format_add_colour = _stub("vertex_format_add_colour"); + vertex_format_add_color = _stub("vertex_format_add_color"); + vertex_format_add_normal = _stub("vertex_format_add_normal"); + vertex_format_add_texcoord = _stub("vertex_format_add_texcoord"); + vertex_format_add_textcoord = _stub("vertex_format_add_textcoord"); + vertex_format_add_custom = _stub("vertex_format_add_custom"); +})(); +// @endif 2d + +// @if feature("gl") // --------------------------------------------------------------------------------------------- // Tracks the format currently under construction @@ -173,4 +194,8 @@ function WebGL_vertex_format_delete_RELEASE(_format_id) { // BM: Stubbed as the underlying system shares vertex formats but DOESN'T reference count. debug("WARNING vertex_format_delete not implemented on HTML5 (System shares vertex formats but doesn't reference count)"); -} \ No newline at end of file +} + +// @endif gl + +// @endif vertex_ diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index 0ebe1570..8ceacf0e 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -107,9 +107,13 @@ var g_AppendDerivativesExtToShader = false; function InitWebGLFunctions() { InitD3DFunctions(); + // @if function("vertex_*") InitFVFFunctions(); InitBufferVertexFunctions(); + // @endif + // @if function("draw_primitive_*") || function("draw_vertex*") InitPrimBuilderFunctions(); + // @endif DrawCirclePrecision(g_circleSteps); @@ -3722,7 +3726,7 @@ function DrawIt_Color(tex, var z =(GR_Depth); - var prim = WebGL_translate_primitive_builder_type(PrimType_TRISTRIP); + var prim = yyGL.PRIM_TRISTRIP; var vvv = g_webGL.AllocVerts(prim, tex, g_webGL.VERTEX_FORMAT_2D, 6); From 02c9f04acc6c661bb01c3ded44aa52c020e6a36d Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 18:57:16 +0300 Subject: [PATCH 34/84] Nineslice-related logic is now stripped if unused. --- scripts/functions/Function_Sprite.js | 8 ++++---- scripts/functions/Function_Texture.js | 14 ++++++++------ scripts/yyInstance.js | 20 +++++++++++--------- scripts/yyNineSliceData.js | 8 +++++++- scripts/yyRoom.js | 6 +++++- scripts/yySprite.js | 25 ++++++++++++++++--------- 6 files changed, 51 insertions(+), 30 deletions(-) diff --git a/scripts/functions/Function_Sprite.js b/scripts/functions/Function_Sprite.js index c5f486ca..fcfa619f 100644 --- a/scripts/functions/Function_Sprite.js +++ b/scripts/functions/Function_Sprite.js @@ -1488,9 +1488,7 @@ function sprite_get_texture(_spriteIndex, _frameIndex) { WebGLTexture: pTPE.texture, TPE: pTPE, - toString: () => { - return "Texture:" + pTPE.texture.URL; - } + toString: () => "Texture:" + pTPE.texture.URL } ); } @@ -1891,8 +1889,10 @@ function sprite_get_info( _spriteIndex ) break; // @endif } // end switch - + + // @if feature("nineslice") variable_struct_set(ret, "nineslice", (pSpr.nineslicedata != undefined) ? pSpr.nineslicedata : undefined); //ret.gmlnineslice = (pSpr.nineslicedata != undefined) ? pSpr.nineslicedata : undefined; + // @endif if (pSpr.sequence != undefined) { // get broadcast messages diff --git a/scripts/functions/Function_Texture.js b/scripts/functions/Function_Texture.js index a854c682..8a715a65 100644 --- a/scripts/functions/Function_Texture.js +++ b/scripts/functions/Function_Texture.js @@ -120,11 +120,12 @@ function draw_sprite_stretched(_pInst, _sprite, _sub_index, _x, _y, _w,_h) _sub_index = (~ ~_sub_index) % pSpr.numb; if (_sub_index < 0) _sub_index = _sub_index + pSpr.numb; - if ((pSpr.nineslicedata != null) && (pSpr.nineslicedata.enabled == true)) + // @if feature("nineslice") + if ((pSpr.nineslicedata != null) && (pSpr.nineslicedata.enabled == true)) { pSpr.nineslicedata.Draw(yyGetReal(_x), yyGetReal(_y), yyGetReal(_w), yyGetReal(_h), 0, 0xffffff, g_GlobalAlpha, _sub_index, pSpr, true); - } - else + } else // -> + // @endif { Graphics_DrawStretchedExt(pSpr.ppTPE[_sub_index], yyGetReal(_x), yyGetReal(_y), yyGetReal(_w), yyGetReal(_h), 0xffffff, g_GlobalAlpha); } @@ -160,11 +161,12 @@ function draw_sprite_stretched_ext( _pInst, _sprite, _sub_index, _x,_y, _w, _ _sub_index = (~ ~_sub_index) % pSpr.numb; if (_sub_index < 0) _sub_index = _sub_index + pSpr.numb; - if ((pSpr.nineslicedata != null) && (pSpr.nineslicedata.enabled == true)) + // @if feature("nineslice") + if ((pSpr.nineslicedata != null) && (pSpr.nineslicedata.enabled == true)) { pSpr.nineslicedata.Draw(yyGetReal(_x), yyGetReal(_y), yyGetReal(_w), yyGetReal(_h), 0, ConvertGMColour(yyGetInt32(_colour)), yyGetReal(_alpha), _sub_index, pSpr, true); - } - else + } else // -> + // @endif { Graphics_DrawStretchedExt(pSpr.ppTPE[_sub_index], yyGetReal(_x), yyGetReal(_y), yyGetReal(_w), yyGetReal(_h), ConvertGMColour(yyGetInt32(_colour)), yyGetReal(_alpha)); } diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index 47d98918..6175a91e 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -1498,7 +1498,7 @@ yyInstance.prototype.Compute_BoundingBox = function() { var bbox = this.bbox; spr = g_pSpriteManager.Sprites[ix]; if (this.image_angle == 0) { - + // @if feature("nineslice") if ((spr.nineslicedata != null) && (spr.nineslicedata.GetEnabled())) { bbox = spr.GetScaledBoundingBox(this.image_xscale, this.image_yscale); @@ -1508,8 +1508,8 @@ yyInstance.prototype.Compute_BoundingBox = function() { bbox.top += this.y; bbox.bottom += this.y; - } - else + } else // -> + // @endif { var pRect = spr.bbox; var width = (pRect.right+1) - pRect.left; @@ -1561,7 +1561,8 @@ yyInstance.prototype.Compute_BoundingBox = function() { else { var xmin, xmax; var ymin, ymax; - + + // @if feature("nineslice") if ((spr.nineslicedata != null) && (spr.nineslicedata.GetEnabled())) { bbox = spr.GetScaledBoundingBox(this.image_xscale, this.image_yscale); @@ -1577,8 +1578,8 @@ yyInstance.prototype.Compute_BoundingBox = function() { xmax += 1; } - } - else + } else + // @endif { var pRect = spr.bbox; @@ -2243,7 +2244,8 @@ function getPoints(i1) var spr = g_pSpriteManager.Sprites[ix]; var xmin, xmax; var ymin, ymax; - + + // @if feature("nineslice") if ((spr.nineslicedata != null) && (spr.nineslicedata.GetEnabled())) { var bbox = spr.GetScaledBoundingBox(i1.image_xscale, i1.image_yscale); @@ -2253,8 +2255,8 @@ function getPoints(i1) ymin = bbox.top; ymax = bbox.bottom + 1; - } - else + } else // -> + // @endif { var pRect = spr.bbox; diff --git a/scripts/yyNineSliceData.js b/scripts/yyNineSliceData.js index 5d34b752..a8712128 100644 --- a/scripts/yyNineSliceData.js +++ b/scripts/yyNineSliceData.js @@ -14,6 +14,7 @@ // // ********************************************************************************************************************** +// @if feature("nineslice") var NINESLICE_TILE_STRETCH = 0, NINESLICE_TILE_REPEAT = 1, NINESLICE_TILE_MIRROR = 2, @@ -1941,6 +1942,7 @@ yyNineSliceData.prototype.Draw = function (_x, _y, _width, _height, _rot, _colou if (g_webGL) { + // @if feature("gl") for (i = 0; i < 4; i++) { // Rescale texture coordinates into texture space @@ -2117,9 +2119,11 @@ yyNineSliceData.prototype.Draw = function (_x, _y, _width, _height, _rot, _colou bindex += stride; } } + // @endif } else { + // @if feature("2d") graphics.globalAlpha = _alpha; if (_colour != g_CacheWhite) @@ -2165,6 +2169,8 @@ yyNineSliceData.prototype.Draw = function (_x, _y, _width, _height, _rot, _colou Graphics_SetTransform(); } } + // @endif } } -}; \ No newline at end of file +}; +// @endif \ No newline at end of file diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index eef0620f..adb9fbf7 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -2393,7 +2393,8 @@ yyRoom.prototype.HandleSequenceGraphic = function (_rect, _layer, _pSequenceEl, var oldworldmat; var restorematrix = false; - + + // @if feature("gl") && feature("nineslice") if ((g_webGL) && (sprite.nineslicedata != null) && (sprite.nineslicedata.enabled == true)) { var spriteScaleX = Math.sqrt((_node.value.matrix.m[0] * _node.value.matrix.m[0]) + (_node.value.matrix.m[1] * _node.value.matrix.m[1])); @@ -2421,6 +2422,7 @@ yyRoom.prototype.HandleSequenceGraphic = function (_rect, _layer, _pSequenceEl, WebGL_SetMatrix(MATRIX_WORLD, normalisedworldmat); } } + // @endif gl nineslice //if (_node.value.Overrides(eT_Width)) { @@ -2434,6 +2436,7 @@ yyRoom.prototype.HandleSequenceGraphic = function (_rect, _layer, _pSequenceEl, if (!g_webGL) { + // @if feature("2d") // extract sprite rotation, scale, and translation from the world matrix var worldMatrix = g_Matrix[MATRIX_WORLD]; var spriteRotationZ = Math.atan2(worldMatrix.m[1], worldMatrix.m[0]) * (-180 / Math.PI); @@ -2456,6 +2459,7 @@ yyRoom.prototype.HandleSequenceGraphic = function (_rect, _layer, _pSequenceEl, // Reset the world matrix WebGL_SetMatrix(MATRIX_WORLD, worldMatrix); + // @endif 2d } else { diff --git a/scripts/yySprite.js b/scripts/yySprite.js index 1b737b06..d7d1e287 100644 --- a/scripts/yySprite.js +++ b/scripts/yySprite.js @@ -240,7 +240,8 @@ yySprite.prototype.GetScaledBoundingBox = function(_xscale, _yscale) tempBB.right = this.bbox.right + 1; tempBB.top = this.bbox.top; tempBB.bottom = this.bbox.bottom + 1; - + + // @if feature("nineslice") if ((this.nineslicedata != null) && (this.nineslicedata.GetEnabled())) { // If bounding box covers entire sprite then we don't need to do anything clever @@ -356,8 +357,8 @@ yySprite.prototype.GetScaledBoundingBox = function(_xscale, _yscale) scaledBB.top -= this.yOrigin * abs_yscale; scaledBB.bottom -= this.yOrigin * abs_yscale; - } - else + } else // -> + // @endif nineslice { scaledBB.left = (tempBB.left - this.xOrigin) * abs_xscale; scaledBB.right = (tempBB.right - this.xOrigin) * abs_xscale; @@ -802,7 +803,9 @@ yySprite.prototype.BuildSequenceData = function (_sequenceData) { // ############################################################################################# yySprite.prototype.BuildNineSliceData = function (_ninesliceData) { + // @if feature("nineslice") this.nineslicedata = new yyNineSliceData(_ninesliceData); + // @endif }; // ############################################################################################# @@ -915,9 +918,11 @@ function CreateSpriteFromStorage( _pStore ) pSprite.BuildSequenceData(_pStore.sequence); } + // @if feature("nineslice") if (_pStore.nineslice !== undefined) { pSprite.BuildNineSliceData(_pStore.nineslice); } + // @endif if(_pStore.Masks !== undefined) pSprite.Masks = _pStore.Masks; @@ -1029,13 +1034,14 @@ yySprite.prototype.DrawSimple = function (_sub_image, _x, _y, _alpha) { // Make sure we're not dealing with a texture that's been downsized to fit the tpage var pTPE = this.ppTPE[_sub_image]; if (!pTPE) return; // no loaded? texture group etc? - + + // @if feature("nineslice") if ((this.nineslicedata != null) && (this.nineslicedata.enabled == true)) { var col = 0xffffffff; this.nineslicedata.Draw(_x, _y, this.width, this.height, 0, col, 1, _sub_image, this); - } - else + } else // -> + // @endif nineslice { if ((pTPE.w == pTPE.CropWidth) && (pTPE.h == pTPE.CropHeight)) { @@ -1104,12 +1110,13 @@ yySprite.prototype.Draw = function (_ind, _x, _y, _xscale, _yscale, _angle, _col if (_ind < 0) _ind += this.numb; _angle = fmod(_angle, 360.0); - + + // @if feature("nineslice") if ((this.nineslicedata != null) && (this.nineslicedata.enabled == true)) { this.nineslicedata.Draw(_x, _y, this.width * _xscale, this.height * _yscale, _angle, _colour, _alpha, _ind, this); - } - else + } else // -> + // @endif { // undefined forces colour+alpha into ALL verts Graphics_TextureDraw(this.ppTPE[_ind], this.xOrigin, this.yOrigin, _x, _y, _xscale, _yscale, _angle * Math.PI / 180.0, _colour, undefined, undefined, undefined, _alpha); From ecaedde5070923b47828480cb4904b76a854a1d3 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 19:00:08 +0300 Subject: [PATCH 35/84] INI-related functions are now stripped if unused (and why is there a whole bunch of helpers in this same file) --- scripts/yyIniFile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/yyIniFile.js b/scripts/yyIniFile.js index 8a3f1a89..61dbe2a7 100644 --- a/scripts/yyIniFile.js +++ b/scripts/yyIniFile.js @@ -15,7 +15,7 @@ // // ********************************************************************************************************************** - +// @if function("ini_*") var g_LastFileSize = 0, g_LastErrorStatus = 0; @@ -636,7 +636,7 @@ yyIniFile.prototype.WriteIniFile = function() { return pFile; }; - +// @endif // ########################################################################################################################################################################################## From a89165113fee2318d89d4f84e192d04410a1fa57 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 23:08:39 +0300 Subject: [PATCH 36/84] Exclude the rest of the dialog helpers if unused --- scripts/functions/Function_Debug.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/functions/Function_Debug.js b/scripts/functions/Function_Debug.js index 511d9840..f4ebd472 100644 --- a/scripts/functions/Function_Debug.js +++ b/scripts/functions/Function_Debug.js @@ -628,6 +628,7 @@ function createLoginDialog( _dialogData ) /// Create an input dialog /// // ############################################################################################# +// @if function("get_integer_async") || function("get_string_async") function createInputDialog( _dialogData ) { //show_debug_message( "createInputDialog = " + _dialogData ); @@ -701,12 +702,14 @@ function createInputDialog( _dialogData ) login_dialog_update(); g_pASyncManager.Add(_dialogData.id, null, ASYNC_USER, g_dialogName); } // end createInputDialog +// @endif // ############################################################################################# /// Function: /// Create a question dialog /// // ############################################################################################# +// @if function("show_question_async") function createQuestionDialog( _dialogData ) { //show_debug_message( "createQuestionDialog = " + _dialogData ); @@ -773,12 +776,14 @@ function createQuestionDialog( _dialogData ) login_dialog_update(); g_pASyncManager.Add(_dialogData.id, null, ASYNC_USER, g_dialogName); } // end createQuestionDialog +// @endif // ############################################################################################# /// Function: /// Create a message dialog /// // ############################################################################################# +// @if function("show_message_async") function createMessageDialog( _dialogData ) { //show_debug_message( "createMessageDialog = " + _dialogData ); @@ -845,6 +850,7 @@ function createMessageDialog( _dialogData ) login_dialog_update(); g_pASyncManager.Add(_dialogData.id, null, ASYNC_USER, g_dialogName); } // end createMessageDialog +// @endif // ############################################################################################# /// Function: @@ -871,20 +877,26 @@ function YYDialogKick() { // get the first entry and kick that one switch( g_dialogs[0].type ) { - /// @if function("get_login_async") + // @if function("get_login_async") case DIALOG_TYPE_LOGIN: // login dialog createLoginDialog( g_dialogs[0] ); break; - /// @endif + // @endif + // @if function("get_integer_async") || function("get_string_async") case DIALOG_TYPE_INPUT: // input dialog createInputDialog( g_dialogs[0] ); break; + // @endif + // @if function("show_question_async") case DIALOG_TYPE_QUESTION: // show question createQuestionDialog( g_dialogs[0] ); break; + // @endif + // @if function("show_message_async") case DIALOG_TYPE_MESSAGE: // show message createMessageDialog( g_dialogs[0] ); break; + // @endif } // end switch } // end if From 7624424bba80023a91b2830c148cec4a1db07d42 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 10:46:23 +0300 Subject: [PATCH 37/84] Exclude highscore_ functions if unused --- scripts/Globals.js | 4 ++- scripts/LoadGame.js | 2 ++ scripts/functions/Function_Game.js | 49 +++++------------------------- 3 files changed, 13 insertions(+), 42 deletions(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index 86c22f42..b1f34854 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1222,8 +1222,10 @@ function InitAboyneGlobals() { g_HiscoreFontSize = 16; g_HiscoreFontStyle = ""; g_HiscoreFontBorder = true; - + + // @if function("draw_highscore") || function("highscore_*") highscore_clear(); + // @endif g_GUIWidth = -1; g_GUIHeight = -1; diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index 80a964b1..569bfb5f 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -955,8 +955,10 @@ function LoadGame(_GameFile) } // Load the games hiscore table + // @if function("draw_highscore") || function("highscore_*") highscore_clear(); highscore_load(); + // @endif diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index a8b5021f..03da1f89 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -81,20 +81,7 @@ function display_set_timing_method(_method){ function display_get_timing_method() { return TimingMethod; } -// ############################################################################################# -/// Function: -/// get a list of instances for this object (recursive) -/// -/// -/// In: object ID to use -/// Out: -/// list of active instances - recursive -/// -// ############################################################################################# -//function instance_number( _obj ) -//{ -// return g_pObjectManager.Get(_obj).Instances_Recursive.length; -//} + // ############################################################################################# @@ -108,7 +95,7 @@ function yy_HiScoreContainer(_value, _name) { this.value = _value; } - +// @if function("draw_highscore") || function("highscore_*") // ############################################################################################# /// Function: @@ -152,8 +139,6 @@ function highscore_save() { var file = JSON.stringify(HighScores); SaveTextFile_Block("hiscores_data_", file); } - - // ############################################################################################# /// Function: /// Draws the highscore table in the room in the indicated box, using the current font. @@ -189,9 +174,6 @@ function draw_highscore(_x1, _y1, _x2, _y2) g_pFontManager.halign = halign; } - - - // ############################################################################################# /// Function: /// Clears the highscore list. @@ -203,26 +185,11 @@ function draw_highscore(_x1, _y1, _x2, _y2) // ############################################################################################# function highscore_clear() { - g_HighScoreValues[0]= - g_HighScoreValues[1]= - g_HighScoreValues[2]= - g_HighScoreValues[3]= - g_HighScoreValues[4]= - g_HighScoreValues[5]= - g_HighScoreValues[6]= - g_HighScoreValues[7]= - g_HighScoreValues[8]= - g_HighScoreValues[9]=0; - g_HighScoreNames[0]= - g_HighScoreNames[1]= - g_HighScoreNames[2]= - g_HighScoreNames[3]= - g_HighScoreNames[4]= - g_HighScoreNames[5]= - g_HighScoreNames[6]= - g_HighScoreNames[7]= - g_HighScoreNames[8]= - g_HighScoreNames[9] = g_HighscoreNobody; + for (var i = 0; i < 10; i++) + { + g_HighScoreValues[i] = 0; + g_HighScoreNames[i] = g_HighscoreNobody; + } } // ############################################################################################# @@ -300,7 +267,7 @@ function highscore_name(_place) if (_place < 1 || _place > MAX_HIGHSCORE) return ""; return g_HighScoreNames[_place-1]; } - +// @endif // ############################################################################################# /// Function: From ce189cd351cfcc1006993f470f19e22f0793c62e Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 9 Aug 2023 23:09:49 +0300 Subject: [PATCH 38/84] Exclude md5_ functions if unused --- scripts/functions/Function_Game.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index 03da1f89..cbe8ced4 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -1056,6 +1056,7 @@ function sha1_file(_fname) { return "unsupported"; } * See http://pajhome.org.uk/crypt/md5 for more info. */ +// @if function("md5_*") /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. @@ -1111,6 +1112,7 @@ function rstr_hmac_md5(key, data) var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8); return binl2rstr(binl_md5(opad.concat(hash), 512 + 128)); } +// @endif md5 /* * Convert a raw string to a hex string @@ -1287,6 +1289,7 @@ function binl2rstr(input) return output; } +// @if function("md5_*") /* * Calculate the MD5 of an array of little-endian words, and a bit length. */ @@ -1407,6 +1410,7 @@ function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } +// @endif md5 /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally From d34113f9867b701d228d2371ffe379e8b946911c Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 02:01:20 +0300 Subject: [PATCH 39/84] Exclude those countless keyboard event constants and object init checks if keyboard events aren't used (per-type) --- scripts/Globals.js | 8 +++++++- scripts/yyObject.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index b1f34854..bd0b1f9c 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -424,7 +424,8 @@ GML_EVENT_STEP_NORMAL = 0, GML_EVENT_OTHER_BROADCAST_MESSAGE = 76, - GML_EVENT_KEYPRESS_NOKEY = EVENT_KEYPRESS|0, + // @if eventType("KeyPress") + GML_EVENT_KEYPRESS_NOKEY = EVENT_KEYPRESS|0, GML_EVENT_KEYPRESS_ANY = EVENT_KEYPRESS|1, GML_EVENT_KEYPRESS_ANYKEY = EVENT_KEYPRESS | 1, GML_EVENT_KEYPRESS_BACKSPACE = EVENT_KEYPRESS | 8, @@ -529,9 +530,11 @@ GML_EVENT_STEP_NORMAL = 0, GML_EVENT_KEYPRESS_NUM_MINUS = EVENT_KEYPRESS | 109, GML_EVENT_KEYPRESS_NUM_DOT = EVENT_KEYPRESS | 110, GML_EVENT_KEYPRESS_NUM_DIV = EVENT_KEYPRESS | 111, + // @endif // KeyDOWN events... + // @if eventType("Keyboard") GML_EVENT_KEYBOARD_NOKEY = EVENT_KEYBOARD | 0, GML_EVENT_KEYBOARD_ANY = EVENT_KEYBOARD | 1, GML_EVENT_KEYBOARD_ANYKEY = EVENT_KEYBOARD | 1, @@ -637,9 +640,11 @@ GML_EVENT_STEP_NORMAL = 0, GML_EVENT_KEYBOARD_NUM_MINUS = EVENT_KEYBOARD | 109, GML_EVENT_KEYBOARD_NUM_DOT = EVENT_KEYBOARD | 110, GML_EVENT_KEYBOARD_NUM_DIV = EVENT_KEYBOARD | 111, + // @endif // Key Released + // @if eventType("KeyRelease") GML_EVENT_KEYRELEASE_NOKEY = EVENT_KEYRELEASE | 0, GML_EVENT_KEYRELEASE_ANY = EVENT_KEYRELEASE | 1, GML_EVENT_KEYRELEASE_ANYKEY = EVENT_KEYRELEASE | 1, @@ -745,6 +750,7 @@ GML_EVENT_STEP_NORMAL = 0, GML_EVENT_KEYRELEASE_NUM_MINUS = EVENT_KEYRELEASE | 109, GML_EVENT_KEYRELEASE_NUM_DOT = EVENT_KEYRELEASE | 110, GML_EVENT_KEYRELEASE_NUM_DIV = EVENT_KEYRELEASE | 111, + // @endif diff --git a/scripts/yyObject.js b/scripts/yyObject.js index dec856ab..8ca2371b 100644 --- a/scripts/yyObject.js +++ b/scripts/yyObject.js @@ -290,6 +290,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { // Keyboard Pressed events (horrible but here we go....) + // @if eventType("KeyPress") //if( _pObjectStorage.KeyPressed_) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_] = _pObjectStorage.KeyPressed_; pObj.Event[GML_EVENT_KEYPRESS_] = true; } if( _pObjectStorage.KeyPressed_NOKEY) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_NOKEY] = _pObjectStorage.KeyPressed_NOKEY; pObj.Event[GML_EVENT_KEYPRESS_NOKEY] = true; } if( _pObjectStorage.KeyPressed_ANYKEY) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_ANYKEY] = _pObjectStorage.KeyPressed_ANYKEY; pObj.Event[GML_EVENT_KEYPRESS_ANYKEY] = true; } @@ -381,9 +382,11 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.KeyPressed_NUM_MINUS) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_NUM_MINUS] = (_pObjectStorage.KeyPressed_NUM_MINUS); pObj.Event[GML_EVENT_KEYPRESS_NUM_MINUS] = true; } if( _pObjectStorage.KeyPressed_NUM_DOT ) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_NUM_DOT ] = (_pObjectStorage.KeyPressed_NUM_DOT ); pObj.Event[GML_EVENT_KEYPRESS_NUM_DOT ] = true; } if( _pObjectStorage.KeyPressed_NUM_DIV ) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_NUM_DIV ] = (_pObjectStorage.KeyPressed_NUM_DIV ); pObj.Event[GML_EVENT_KEYPRESS_NUM_DIV ] = true; } + // @endif // Keyboard (key down) events + // @if eventType("Keyboard") if( _pObjectStorage.Key_NOKEY) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_NOKEY] = (_pObjectStorage.Key_NOKEY); pObj.Event[GML_EVENT_KEYBOARD_NOKEY] = true; } if( _pObjectStorage.Key_ANYKEY) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_ANYKEY] = (_pObjectStorage.Key_ANYKEY); pObj.Event[GML_EVENT_KEYBOARD_ANYKEY] = true; } if( _pObjectStorage.Key_BACKSPACE) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_BACKSPACE] = (_pObjectStorage.Key_BACKSPACE); pObj.Event[GML_EVENT_KEYBOARD_BACKSPACE] = true; } @@ -474,10 +477,12 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.Key_NUM_MINUS) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_NUM_MINUS] = (_pObjectStorage.Key_NUM_MINUS); pObj.Event[GML_EVENT_KEYBOARD_NUM_MINUS] = true; } if( _pObjectStorage.Key_NUM_DOT ) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_NUM_DOT ] = (_pObjectStorage.Key_NUM_DOT ); pObj.Event[GML_EVENT_KEYBOARD_NUM_DOT ] = true; } if( _pObjectStorage.Key_NUM_DIV ) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_NUM_DIV ] = (_pObjectStorage.Key_NUM_DIV ); pObj.Event[GML_EVENT_KEYBOARD_NUM_DIV ] = true; } + // @endif // Key Released events + // @if eventType("KeyRelease") if( _pObjectStorage.KeyReleased_NOKEY) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_NOKEY] = (_pObjectStorage.KeyReleased_NOKEY); pObj.Event[GML_EVENT_KEYRELEASE_NOKEY] = true; } if( _pObjectStorage.KeyReleased_ANYKEY) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_ANYKEY] = (_pObjectStorage.KeyReleased_ANYKEY); pObj.Event[GML_EVENT_KEYRELEASE_ANYKEY] = true; } if( _pObjectStorage.KeyReleased_BACKSPACE) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_BACKSPACE] = (_pObjectStorage.KeyReleased_BACKSPACE); pObj.Event[GML_EVENT_KEYRELEASE_BACKSPACE] = true; } @@ -569,6 +574,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.KeyReleased_NUM_MINUS) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_NUM_MINUS] = (_pObjectStorage.KeyReleased_NUM_MINUS); pObj.Event[GML_EVENT_KEYRELEASE_NUM_MINUS] = true; } if( _pObjectStorage.KeyReleased_NUM_DOT ) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_NUM_DOT ] = (_pObjectStorage.KeyReleased_NUM_DOT ); pObj.Event[GML_EVENT_KEYRELEASE_NUM_DOT ] = true; } if( _pObjectStorage.KeyReleased_NUM_DIV ) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_NUM_DIV ] = (_pObjectStorage.KeyReleased_NUM_DIV ); pObj.Event[GML_EVENT_KEYRELEASE_NUM_DIV ] = true; } + // @endif From d17aeb3e02e261fd2d73684773b8be0ae481e44e Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 02:04:09 +0300 Subject: [PATCH 40/84] Also apply the event check to some other event types that might be ignored by the user --- scripts/Events.js | 4 +++- scripts/yyObject.js | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/scripts/Events.js b/scripts/Events.js index 12dfdabb..33144aa3 100644 --- a/scripts/Events.js +++ b/scripts/Events.js @@ -416,6 +416,7 @@ function DoPointToInstance( _event, _sub_event, _x,_y ) // ############################################################################################# function HandleMouse() { + // @if eventType("Mouse") if (g_RunRoom) { var ind; @@ -554,7 +555,8 @@ function HandleMouse() { g_pInstanceManager.PerformEvent(EVENT_MOUSE_WHEEL_DOWN,0); } - } + } + // @endif mouse events } diff --git a/scripts/yyObject.js b/scripts/yyObject.js index 8ca2371b..d407d04e 100644 --- a/scripts/yyObject.js +++ b/scripts/yyObject.js @@ -171,6 +171,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if (_pObjectStorage.DrawResize) { pObj.DrawResize = _pObjectStorage.DrawResize; pObj.Event[EVENT_DRAW_RESIZE] = true; } + // @if eventType("Mouse") if( _pObjectStorage.NoButtonPressed) {pObj.NoButtonPressed = _pObjectStorage.NoButtonPressed; pObj.Event[EVENT_MOUSE_NOBUTTON] = true; } if( _pObjectStorage.LeftButtonDown) {pObj.LeftButtonDown = _pObjectStorage.LeftButtonDown; pObj.Event[EVENT_MOUSE_LBUTTON_DOWN] = true; } if( _pObjectStorage.RightButtonDown) {pObj.RightButtonDown = _pObjectStorage.RightButtonDown; pObj.Event[EVENT_MOUSE_RBUTTON_DOWN] = true; } @@ -196,7 +197,9 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.MouseEnter) {pObj.MouseEnter = _pObjectStorage.MouseEnter; pObj.Event[EVENT_MOUSE_ENTER] = true; } if (_pObjectStorage.MouseLeave) { pObj.MouseLeave = _pObjectStorage.MouseLeave; pObj.Event[EVENT_MOUSE_LEAVE] = true; } + // @endif + // @if eventType("Gesture") if (_pObjectStorage.GestureTapEvent) { pObj.GestureTapEvent = _pObjectStorage.GestureTapEvent; pObj.Event[EVENT_GESTURE_TAP] = true; } if (_pObjectStorage.GestureDoubleTapEvent) { pObj.GestureDoubleTapEvent = _pObjectStorage.GestureDoubleTapEvent; pObj.Event[EVENT_GESTURE_DOUBLE_TAP] = true; } if (_pObjectStorage.GestureDragStartEvent) { pObj.GestureDragStartEvent = _pObjectStorage.GestureDragStartEvent; pObj.Event[EVENT_GESTURE_DRAG_START] = true; } @@ -210,6 +213,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if (_pObjectStorage.GestureGlobalDragMoveEvent) { pObj.GestureGlobalDragMoveEvent = _pObjectStorage.GestureGlobalDragMoveEvent; pObj.Event[EVENT_GESTURE_GLOBAL_DRAG_MOVE] = true; } if (_pObjectStorage.GestureGlobalDragEndEvent) { pObj.GestureGlobalDragEndEvent = _pObjectStorage.GestureGlobalDragEndEvent; pObj.Event[EVENT_GESTURE_GLOBAL_DRAG_END] = true; } if (_pObjectStorage.GestureGlobalFlickEvent) { pObj.GestureGlobalFlickEvent = _pObjectStorage.GestureGlobalFlickEvent; pObj.Event[EVENT_GESTURE_GLOBAL_FLICK] = true; } + // @endif if( _pObjectStorage.OutsideEvent) {pObj.OutsideEvent = _pObjectStorage.OutsideEvent; pObj.Event[EVENT_OTHER_OUTSIDE] = true; } if( _pObjectStorage.BoundaryEvent) {pObj.BoundaryEvent = _pObjectStorage.BoundaryEvent; pObj.Event[EVENT_OTHER_BOUNDARY] = true; } @@ -275,6 +279,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if (_pObjectStorage.SystemEvent) { pObj.SystemEvent = _pObjectStorage.SystemEvent; pObj.Event[EVENT_OTHER_SYSTEM_EVENT] = true; } if (_pObjectStorage.BroadcastMessageEvent) { pObj.BroadcastMessageEvent = _pObjectStorage.BroadcastMessageEvent; pObj.Event[EVENT_OTHER_BROADCAST_MESSAGE] = true; } + // @if eventType("Alarm") if( _pObjectStorage.ObjAlarm0) {pObj.ObjAlarm[0] = _pObjectStorage.ObjAlarm0; pObj.Event[EVENT_ALARM_0] = true; } if( _pObjectStorage.ObjAlarm1) {pObj.ObjAlarm[1] = _pObjectStorage.ObjAlarm1; pObj.Event[EVENT_ALARM_1] = true; } if( _pObjectStorage.ObjAlarm2) {pObj.ObjAlarm[2] = _pObjectStorage.ObjAlarm2; pObj.Event[EVENT_ALARM_2] = true; } @@ -287,6 +292,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.ObjAlarm9) {pObj.ObjAlarm[9] = _pObjectStorage.ObjAlarm9; pObj.Event[EVENT_ALARM_9] = true; } if( _pObjectStorage.ObjAlarm10) {pObj.ObjAlarm[10] = _pObjectStorage.ObjAlarm10; pObj.Event[EVENT_ALARM_10] = true; } if( _pObjectStorage.ObjAlarm11) {pObj.ObjAlarm[11] = _pObjectStorage.ObjAlarm11; pObj.Event[EVENT_ALARM_11] = true; } + // @endif // Keyboard Pressed events (horrible but here we go....) @@ -579,9 +585,10 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { // Triggers... - var i = 0; + // @if eventType("Trigger") if( _pObjectStorage.TriggerEvents != undefined ) { + var i = 0; while (i < _pObjectStorage.TriggerEvents.length) { var key = parseInt(_pObjectStorage.TriggerEvents[i]) + 1; // get the object ID (no trigger 0 here) @@ -600,13 +607,15 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { i += 2; } } + // @endif // Collisions... - i = 0; + // @if eventType("Collision") if( _pObjectStorage.CollisionEvents != undefined ) { + var i = 0; while (i < _pObjectStorage.CollisionEvents.length) { pObj.Event[EVENT_COLLISION] = true; @@ -622,6 +631,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { i += 2; } } + // @endif // Physics data // @if feature("physics") @@ -794,7 +804,8 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_OTHER_USER15: if (this.UserEvent15) this.UserEvent15(_pInst, _pOther); else done = false; break; - case EVENT_MOUSE_NOBUTTON: if (this.NoButtonPressed) this.NoButtonPressed(_pInst, _pOther); else done = false; break; + // @if eventType("Mouse") + case EVENT_MOUSE_NOBUTTON: if (this.NoButtonPressed) this.NoButtonPressed(_pInst, _pOther); else done = false; break; case EVENT_MOUSE_LBUTTON_DOWN: if (this.LeftButtonDown) this.LeftButtonDown(_pInst, _pOther); else done = false; break; case EVENT_MOUSE_RBUTTON_DOWN: if (this.RightButtonDown) this.RightButtonDown(_pInst, _pOther); else done = false; break; case EVENT_MOUSE_MBUTTON_DOWN: if (this.MiddleButtonDown) this.MiddleButtonDown(_pInst, _pOther); else done = false; break; @@ -819,8 +830,10 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_MOUSE_ENTER: if (this.MouseEnter) this.MouseEnter(_pInst, _pOther); else done = false; break; case EVENT_MOUSE_LEAVE: if (this.MouseLeave) this.MouseLeave(_pInst, _pOther); else done = false; break; + // @endif - case EVENT_GESTURE_TAP: if (this.GestureTapEvent) this.GestureTapEvent(_pInst, _pOther); else done = false; break; + // @if eventType("Gesture") + case EVENT_GESTURE_TAP: if (this.GestureTapEvent) this.GestureTapEvent(_pInst, _pOther); else done = false; break; case EVENT_GESTURE_DOUBLE_TAP: if (this.GestureDoubleTapEvent) this.GestureDoubleTapEvent(_pInst, _pOther); else done = false; break; case EVENT_GESTURE_DRAG_START: if (this.GestureDragStartEvent) this.GestureDragStartEvent(_pInst, _pOther); else done = false; break; case EVENT_GESTURE_DRAG_MOVE: if (this.GestureDragMoveEvent) this.GestureDragMoveEvent(_pInst, _pOther); else done = false; break; @@ -833,8 +846,10 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_GESTURE_GLOBAL_DRAG_MOVE: if (this.GestureGlobalDragMoveEvent) this.GestureGlobalDragMoveEvent(_pInst, _pOther); else done = false; break; case EVENT_GESTURE_GLOBAL_DRAG_END: if (this.GestureGlobalDragEndEvent) this.GestureGlobalDragEndEvent(_pInst, _pOther); else done = false; break; case EVENT_GESTURE_GLOBAL_FLICK: if (this.GestureGlobalFlickEvent) this.GestureGlobalFlickEvent(_pInst, _pOther); else done = false; break; + // @endif - case EVENT_ALARM_0: if (this.ObjAlarm[0] != null) this.ObjAlarm[0](_pInst, _pOther); else done = false; break; + // @if eventType("Alarm") + case EVENT_ALARM_0: if (this.ObjAlarm[0] != null) this.ObjAlarm[0](_pInst, _pOther); else done = false; break; case EVENT_ALARM_1: if (this.ObjAlarm[1] != null) this.ObjAlarm[1](_pInst, _pOther); else done = false; break; case EVENT_ALARM_2: if (this.ObjAlarm[2] != null) this.ObjAlarm[2](_pInst, _pOther); else done = false; break; case EVENT_ALARM_3: if (this.ObjAlarm[3] != null) this.ObjAlarm[3](_pInst, _pOther); else done = false; break; @@ -846,6 +861,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_ALARM_9: if (this.ObjAlarm[9] != null) this.ObjAlarm[9](_pInst, _pOther); else done = false; break; case EVENT_ALARM_10: if (this.ObjAlarm[10] != null) this.ObjAlarm[10](_pInst, _pOther); else done = false; break; case EVENT_ALARM_11: if (this.ObjAlarm[11] != null) this.ObjAlarm[11](_pInst, _pOther); else done = false; break; + // @endif default: done = false; @@ -963,6 +979,7 @@ function ConvertEvent(_event) case EVENT_OTHER_USER15: return GML_EVENT_OTHER; + // @if eventType("Mouse") case EVENT_MOUSE_NOBUTTON: return GML_EVENT_MOUSE; case EVENT_MOUSE_LBUTTON_DOWN: return GML_EVENT_MOUSE; case EVENT_MOUSE_RBUTTON_DOWN: return GML_EVENT_MOUSE; @@ -988,7 +1005,9 @@ function ConvertEvent(_event) case EVENT_MOUSE_ENTER: return GML_EVENT_MOUSE; case EVENT_MOUSE_LEAVE: return GML_EVENT_MOUSE; + // @endif + // @if eventType("Gesture") case EVENT_GESTURE_TAP: return GML_EVENT_GESTURE; case EVENT_GESTURE_DOUBLE_TAP: return GML_EVENT_GESTURE; case EVENT_GESTURE_DRAG_START: return GML_EVENT_GESTURE; @@ -1002,7 +1021,9 @@ function ConvertEvent(_event) case EVENT_GESTURE_GLOBAL_DRAG_MOVE: return GML_EVENT_GESTURE; case EVENT_GESTURE_GLOBAL_DRAG_END: return GML_EVENT_GESTURE; case EVENT_GESTURE_GLOBAL_FLICK: return GML_EVENT_GESTURE; + // @endif + // @if eventType("Alarm") case EVENT_ALARM_0: return GML_EVENT_ALARM; case EVENT_ALARM_1: return GML_EVENT_ALARM; case EVENT_ALARM_2: return GML_EVENT_ALARM; @@ -1015,6 +1036,7 @@ function ConvertEvent(_event) case EVENT_ALARM_9: return GML_EVENT_ALARM; case EVENT_ALARM_10: return GML_EVENT_ALARM; case EVENT_ALARM_11: return GML_EVENT_ALARM; + // @endif default: return -1; // who knows @@ -1139,6 +1161,7 @@ function ConvertSubEvent(_event, _subevent) case EVENT_OTHER_USER15: return GML_EVENT_OTHER_USER15; + // @if eventType("Mouse") case EVENT_MOUSE_NOBUTTON: return GML_MOUSE_NoButton; case EVENT_MOUSE_LBUTTON_DOWN: return GML_MOUSE_LeftButton; case EVENT_MOUSE_RBUTTON_DOWN: return GML_MOUSE_RightButton; @@ -1164,7 +1187,9 @@ function ConvertSubEvent(_event, _subevent) case EVENT_MOUSE_ENTER: return GML_MOUSE_MOUSEEnter; case EVENT_MOUSE_LEAVE: return GML_MOUSE_MOUSELeave; + // @endif + // @if eventType("Gesture") case EVENT_GESTURE_TAP: return GML_EVENT_GESTURE_TAP; case EVENT_GESTURE_DOUBLE_TAP: return GML_EVENT_GESTURE_DOUBLE_TAP; case EVENT_GESTURE_DRAG_START: return GML_EVENT_GESTURE_DRAG_START; @@ -1178,7 +1203,9 @@ function ConvertSubEvent(_event, _subevent) case EVENT_GESTURE_GLOBAL_DRAG_MOVE: return GML_EVENT_GESTURE_GLOBAL_DRAG_MOVE; case EVENT_GESTURE_GLOBAL_DRAG_END: return GML_EVENT_GESTURE_GLOBAL_DRAG_END; case EVENT_GESTURE_GLOBAL_FLICK: return GML_EVENT_GESTURE_GLOBAL_FLICK; + // @endif + // @if eventType("Alarm") case EVENT_ALARM_0: return 0; case EVENT_ALARM_1: return 1; case EVENT_ALARM_2: return 2; @@ -1191,6 +1218,7 @@ function ConvertSubEvent(_event, _subevent) case EVENT_ALARM_9: return 9; case EVENT_ALARM_10: return 10; case EVENT_ALARM_11: return 11; + // @endif default: return 0; // who knows From 4473bf930ae489a510827218679ccb364f4d5b59 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 02:18:26 +0300 Subject: [PATCH 41/84] Updated D3D/GPU function init to be DCE-friendly. A better way to handle this would be to NOT call GML-facing aliases inside engine code - especially since these might do yyGet* unpacking that we're not interested in --- scripts/functions/Function_D3D.js | 473 +++++++++++++++++------------- 1 file changed, 277 insertions(+), 196 deletions(-) diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js index cc54de53..dc8d27c6 100644 --- a/scripts/functions/Function_D3D.js +++ b/scripts/functions/Function_D3D.js @@ -12,24 +12,206 @@ // -------------------------------------------------------------------------------------------------------------------------------------------------- // WebGL supported -function d3d_set_depth(depth) { ErrorFunction("d3d_set_depth()"); } -function draw_set_color_write_enable(red, green, blue, alpha) { ErrorFunction("draw_set_color_write_enable()"); } -var draw_set_colour_write_enable = draw_set_color_write_enable; - -function d3d_set_lighting(enable) { ErrorFunction("d3d_set_lighting()"); } -function d3d_light_define_direction(ind,dx,dy,dz,col) { ErrorFunction("d3d_light_define_direction()"); } -function d3d_light_define_point(ind,x,y,z,range,col) { ErrorFunction("d3d_light_define_point()"); } -function d3d_light_enable(ind,enable) { ErrorFunction("d3d_light_enable()"); } -function d3d_light_define_ambient( colour ) { ErrorFunction("d3d_light_define_ambient()"); } -function d3d_set_fog(enable,color,start,end) { ErrorFunction("d3d_set_fog()"); } -function d3d_light_get(index) { ErrorFunction("d3d_light_get()"); } -function d3d_light_get_ambient(index) { ErrorFunction("d3d_light_get_ambient()"); } -function d3d_get_lighting() { ErrorFunction("d3d_get_lighting()"); } - -function d3d_set_perspective(enable) { ErrorFunction("d3d_set_perspective()"); } - -function matrix_get(_type) { ErrorFunction("matrix_get()"); } -function matrix_set(_type, _matrix) { ErrorFunction("matrix_set()"); } +function d3d_set_depth(){} +function draw_set_color_write_enable(){} +function draw_set_colour_write_enable(){} + +function d3d_set_lighting(){} +function d3d_light_define_direction(){} +function d3d_light_define_point(){} +function d3d_light_enable(){} +function d3d_light_define_ambient(){} +function d3d_set_fog(){} +function d3d_light_get(){} +function d3d_light_get_ambient(){} +function d3d_get_lighting(){} +function d3d_set_perspective(){} + +function matrix_get(){} +function matrix_set(){} + +function gpu_set_blendenable(){} +function gpu_set_ztestenable(){} +function gpu_set_zfunc(){} +function gpu_set_zwriteenable(){} +function gpu_set_fog(){} +function gpu_set_cullmode(){} +function gpu_set_blendmode(){} +function gpu_set_blendmode_ext(){} +function gpu_set_blendmode_ext_sepalpha(){} +function gpu_set_colorwriteenable(){} +function gpu_set_colourwriteenable(){} +function gpu_set_alphatestenable(){} +function gpu_set_alphatestref(){} +function gpu_set_texfilter(){} +function gpu_set_texfilter_ext(){} +function gpu_set_texrepeat(){} +function gpu_set_texrepeat_ext(){} +function gpu_set_tex_filter(){} +function gpu_set_tex_filter_ext(){} +function gpu_set_tex_repeat(){} +function gpu_set_tex_repeat_ext(){} + +function gpu_set_tex_mip_filter(){} +function gpu_set_tex_mip_filter_ext(){} +function gpu_set_tex_mip_bias(){} +function gpu_set_tex_mip_bias_ext(){} +function gpu_set_tex_min_mip(){} +function gpu_set_tex_min_mip_ext(){} +function gpu_set_tex_max_mip(){} +function gpu_set_tex_max_mip_ext(){} +function gpu_set_tex_max_aniso(){} +function gpu_set_tex_max_aniso_ext(){} +function gpu_set_tex_mip_enable(){} +function gpu_set_tex_mip_enable_ext(){} + +function gpu_get_blendenable(){} +function gpu_get_ztestenable(){} +function gpu_get_zfunc(){} +function gpu_get_zwriteenable(){} +function gpu_get_fog(){} +function gpu_get_cullmode(){} +function gpu_get_blendmode(){} +function gpu_get_blendmode_ext(){} +function gpu_get_blendmode_ext_sepalpha(){} +function gpu_get_blendmode_src(){} +function gpu_get_blendmode_dest(){} +function gpu_get_blendmode_srcalpha(){} +function gpu_get_blendmode_destalpha(){} +function gpu_get_colorwriteenable(){} +function gpu_get_colourwriteenable(){} +function gpu_get_alphatestenable(){} +function gpu_get_alphatestref(){} +function gpu_get_texfilter(){} +function gpu_get_texfilter_ext(){} +function gpu_get_texrepeat(){} +function gpu_get_texrepeat_ext(){} +function gpu_get_tex_filter(){} +function gpu_get_tex_filter_ext(){} +function gpu_get_tex_repeat(){} +function gpu_get_tex_repeat_ext(){} + +function gpu_get_tex_mip_filter(){} +function gpu_get_tex_mip_filter_ext(){} +function gpu_get_tex_mip_bias(){} +function gpu_get_tex_mip_bias_ext(){} +function gpu_get_tex_min_mip(){} +function gpu_get_tex_min_mip_ext(){} +function gpu_get_tex_max_mip(){} +function gpu_get_tex_max_mip_ext(){} +function gpu_get_tex_max_aniso(){} +function gpu_get_tex_max_aniso_ext(){} +function gpu_get_tex_mip_enable(){} +function gpu_get_tex_mip_enable_ext(){} + +function gpu_push_state(){} +function gpu_pop_state(){} +function gpu_get_state(){} +function gpu_set_state(){} + +// @if feature("2d") +(() => { + let _stub = (_name, _val) => () => ErrorFunction(_name, _val); + compile_if_used(d3d_set_depth = _stub("d3d_set_depth")); + compile_if_used(draw_set_color_write_enable = _stub("draw_set_color_write_enable")); + compile_if_used(draw_set_colour_write_enable = _stub("draw_set_colour_write_enable")); + + d3d_set_lighting = _stub("d3d_set_lighting"); + d3d_light_define_direction = _stub("d3d_light_define_direction"); + d3d_light_define_point = _stub("d3d_light_define_point"); + d3d_light_enable = _stub("d3d_light_enable"); + d3d_light_define_ambient = _stub("d3d_light_define_ambient"); + d3d_light_get = _stub("d3d_light_get"); + d3d_light_get_ambient = _stub("d3d_light_get_ambient"); + d3d_get_lighting = _stub("d3d_get_lighting"); + + compile_if_used(d3d_set_perspective = _stub("d3d_set_perspective")); + d3d_set_fog = _stub("d3d_set_fog"); // used by yyWebGL + + compile_if_used(matrix_get = _stub("matrix_get")); + compile_if_used(matrix_set = _stub("matrix_set")); + + compile_if_used(gpu_set_blendenable = _stub("gpu_set_blendenable")); + compile_if_used(gpu_set_ztestenable = _stub("gpu_set_ztestenable")); + compile_if_used(gpu_set_zfunc = _stub("gpu_set_zfunc")); + compile_if_used(gpu_set_zwriteenable = _stub("gpu_set_zwriteenable")); + compile_if_used(gpu_set_fog = _stub("gpu_set_fog")); + compile_if_used(gpu_set_cullmode = _stub("gpu_set_cullmode")); + compile_if_used(gpu_set_blendmode = _stub("gpu_set_blendmode")); + compile_if_used(gpu_set_blendmode_ext = _stub("gpu_set_blendmode_ext")); + compile_if_used(gpu_set_blendmode_ext_sepalpha = _stub("gpu_set_blendmode_ext_sepalpha")); + compile_if_used(gpu_set_colorwriteenable = _stub("gpu_set_colorwriteenable")); + compile_if_used(gpu_set_colourwriteenable = _stub("gpu_set_colourwriteenable")); + compile_if_used(gpu_set_alphatestenable = _stub("gpu_set_alphatestenable")); + compile_if_used(gpu_set_alphatestref = _stub("gpu_set_alphatestref")); + compile_if_used(gpu_set_texfilter = _stub("gpu_set_texfilter")); + gpu_set_texfilter_ext = _stub("gpu_set_texfilter_ext"); // used by SDF + compile_if_used(gpu_set_texrepeat = _stub("gpu_set_texrepeat")); + gpu_set_texrepeat_ext = _stub("gpu_set_texrepeat_ext"); // used by yyEffects + compile_if_used(gpu_set_tex_filter = _stub("gpu_set_tex_filter")); + gpu_set_tex_filter_ext = _stub("gpu_set_tex_filter_ext"); // used by yyEffects + compile_if_used(gpu_set_tex_repeat = _stub("gpu_set_tex_repeat")); + compile_if_used(gpu_set_tex_repeat_ext = _stub("gpu_set_tex_repeat_ext")); + + compile_if_used(gpu_set_tex_mip_filter = _stub("gpu_set_tex_mip_filter")); + compile_if_used(gpu_set_tex_mip_filter_ext = _stub("gpu_set_tex_mip_filter_ext")); + compile_if_used(gpu_set_tex_mip_bias = _stub("gpu_set_tex_mip_bias")); + compile_if_used(gpu_set_tex_mip_bias_ext = _stub("gpu_set_tex_mip_bias_ext")); + compile_if_used(gpu_set_tex_min_mip = _stub("gpu_set_tex_min_mip")); + compile_if_used(gpu_set_tex_min_mip_ext = _stub("gpu_set_tex_min_mip_ext")); + compile_if_used(gpu_set_tex_max_mip = _stub("gpu_set_tex_max_mip")); + compile_if_used(gpu_set_tex_max_mip_ext = _stub("gpu_set_tex_max_mip_ext")); + compile_if_used(gpu_set_tex_max_aniso = _stub("gpu_set_tex_max_aniso")); + compile_if_used(gpu_set_tex_max_aniso_ext = _stub("gpu_set_tex_max_aniso_ext")); + compile_if_used(gpu_set_tex_mip_enable = _stub("gpu_set_tex_mip_enable")); + compile_if_used(gpu_set_tex_mip_enable_ext = _stub("gpu_set_tex_mip_enable_ext")); + + compile_if_used(gpu_get_blendenable = _stub("gpu_get_blendenable")); + gpu_get_ztestenable = _stub("gpu_get_ztestenable"); // used in a few places + compile_if_used(gpu_get_zfunc = _stub("gpu_get_zfunc")); + gpu_get_zwriteenable = _stub("gpu_get_zwriteenable"); + compile_if_used(gpu_get_fog = _stub("gpu_get_fog")); + gpu_get_cullmode = _stub("gpu_get_cullmode"); + compile_if_used(gpu_get_blendmode = _stub("gpu_get_blendmode")); + compile_if_used(gpu_get_blendmode_ext = _stub("gpu_get_blendmode_ext")); + compile_if_used(gpu_get_blendmode_ext_sepalpha = _stub("gpu_get_blendmode_ext_sepalpha")); + compile_if_used(gpu_get_blendmode_src = _stub("gpu_get_blendmode_src")); + compile_if_used(gpu_get_blendmode_dest = _stub("gpu_get_blendmode_dest")); + compile_if_used(gpu_get_blendmode_srcalpha = _stub("gpu_get_blendmode_srcalpha")); + compile_if_used(gpu_get_blendmode_destalpha = _stub("gpu_get_blendmode_destalpha")); + compile_if_used(gpu_get_colorwriteenable = _stub("gpu_get_colorwriteenable")); + compile_if_used(gpu_get_colourwriteenable = _stub("gpu_get_colourwriteenable")); + gpu_get_alphatestenable = _stub("gpu_get_alphatestenable"); // used by application_surface drawer + compile_if_used(gpu_get_alphatestref = _stub("gpu_get_alphatestref")); + compile_if_used(gpu_get_texfilter = _stub("gpu_get_texfilter")); + compile_if_used(gpu_get_texfilter_ext = _stub("gpu_get_texfilter_ext")); + compile_if_used(gpu_get_texrepeat = _stub("gpu_get_texrepeat")); + compile_if_used(gpu_get_texrepeat_ext = _stub("gpu_get_texrepeat_ext")); + compile_if_used(gpu_get_tex_filter = _stub("gpu_get_tex_filter")); + compile_if_used(gpu_get_tex_filter_ext = _stub("gpu_get_tex_filter_ext")); + compile_if_used(gpu_get_tex_repeat = _stub("gpu_get_tex_repeat")); + compile_if_used(gpu_get_tex_repeat_ext = _stub("gpu_get_tex_repeat_ext")); + + compile_if_used(gpu_get_tex_mip_filter = _stub("gpu_get_tex_mip_filter")); + compile_if_used(gpu_get_tex_mip_filter_ext = _stub("gpu_get_tex_mip_filter_ext")); + compile_if_used(gpu_get_tex_mip_bias = _stub("gpu_get_tex_mip_bias")); + compile_if_used(gpu_get_tex_mip_bias_ext = _stub("gpu_get_tex_mip_bias_ext")); + compile_if_used(gpu_get_tex_min_mip = _stub("gpu_get_tex_min_mip")); + compile_if_used(gpu_get_tex_min_mip_ext = _stub("gpu_get_tex_min_mip_ext")); + compile_if_used(gpu_get_tex_max_mip = _stub("gpu_get_tex_max_mip")); + compile_if_used(gpu_get_tex_max_mip_ext = _stub("gpu_get_tex_max_mip_ext")); + compile_if_used(gpu_get_tex_max_aniso = _stub("gpu_get_tex_max_aniso")); + compile_if_used(gpu_get_tex_max_aniso_ext = _stub("gpu_get_tex_max_aniso_ext")); + compile_if_used(gpu_get_tex_mip_enable = _stub("gpu_get_tex_mip_enable")); + compile_if_used(gpu_get_tex_mip_enable_ext = _stub("gpu_get_tex_mip_enable_ext")); + + compile_if_used(gpu_push_state = _stub("gpu_push_state")); + compile_if_used(gpu_pop_state = _stub("gpu_pop_state")); + compile_if_used(gpu_get_state = _stub("gpu_get_state")); + compile_if_used(gpu_set_state = _stub("gpu_set_state")); +})(); +// @endif + // RK :: Changed these as they are mathematical in nature and not specific to WebGL // These should be separated out from WebGL to a new maths class var matrix_build = WebGL_Matrix_Build; @@ -50,92 +232,7 @@ var matrix_build_projection_perspective = WebGL_matrix_build_projection_perspect var matrix_build_projection_perspective_fov = WebGL_matrix_build_projection_perspective_fov; -function gpu_set_blendenable(enable) { ErrorFunction("gpu_set_blendenable()"); } -function gpu_set_ztestenable(enable) { ErrorFunction("gpu_set_ztestenable()"); } -function gpu_set_zfunc(cmp_func) { ErrorFunction("gpu_set_zfunc()"); } -function gpu_set_zwriteenable(enable) { ErrorFunction("gpu_set_zwriteenable()"); } -//function gpu_set_lightingenable(enable) { ErrorFunction("gpu_set_lightingenable()"); } -function gpu_set_fog(enable,col,start,end) { ErrorFunction("gpu_set_fog()"); } -function gpu_set_cullmode(cullmode) { ErrorFunction("gpu_set_cullmode()"); } -function gpu_set_blendmode(mode) { ErrorFunction("gpu_set_blendmode()"); } -function gpu_set_blendmode_ext(src,dest) { ErrorFunction("gpu_set_blendmode_ext()"); } -function gpu_set_blendmode_ext_sepalpha(src,dest,srcalpha,destalpha) { ErrorFunction("gpu_set_blendmode_ext_sepalpha()"); } -function gpu_set_colorwriteenable(red,green,blue,alpha) { ErrorFunction("gpu_set_colorwriteenable()"); } -function gpu_set_colourwriteenable(red,green,blue,alpha) { ErrorFunction("gpu_set_colourwriteenable()"); } -function gpu_set_alphatestenable(enable) { ErrorFunction("gpu_set_alphatestenable()"); } -function gpu_set_alphatestref(value) { ErrorFunction("gpu_set_alphatestref()"); } -function gpu_set_texfilter(linear) { ErrorFunction("gpu_set_texfilter()"); } -function gpu_set_texfilter_ext(sampler_id,linear) { ErrorFunction("gpu_set_texfilter_ext()"); } -function gpu_set_texrepeat(repeat) { ErrorFunction("gpu_set_texrepeat()"); } -function gpu_set_texrepeat_ext(sampler_id,repeat) { ErrorFunction("gpu_set_texrepeat_ext()"); } -function gpu_set_tex_filter(linear) { ErrorFunction("gpu_set_tex_filter()"); } -function gpu_set_tex_filter_ext(sampler_id, linear) { ErrorFunction("gpu_set_tex_filter_ext()"); } -function gpu_set_tex_repeat(repeat) { ErrorFunction("gpu_set_tex_repeat()"); } -function gpu_set_tex_repeat_ext(sampler_id, repeat) { ErrorFunction("gpu_set_tex_repeat_ext()"); } - -function gpu_set_tex_mip_filter(filter) { ErrorFunction("gpu_set_tex_mip_filter(filter)"); } -function gpu_set_tex_mip_filter_ext(sampler_id, filter) { ErrorFunction("gpu_set_tex_mip_filter_ext(sampler_id, filter)"); } -function gpu_set_tex_mip_bias(bias) { ErrorFunction("gpu_set_tex_mip_bias(bias)"); } -function gpu_set_tex_mip_bias_ext(sampler_id, bias) { ErrorFunction("gpu_set_tex_mip_bias_ext(sampler_id, bias)"); } -function gpu_set_tex_min_mip(minmip) { ErrorFunction("gpu_set_tex_min_mip(minmip)"); } -function gpu_set_tex_min_mip_ext(sampler_id, minmip) { ErrorFunction("gpu_set_tex_min_mip_ext(sampler_id, minmip)"); } -function gpu_set_tex_max_mip(maxmip) { ErrorFunction("gpu_set_tex_max_mip(maxmip)"); } -function gpu_set_tex_max_mip_ext(sampler_id, maxmip) { ErrorFunction("gpu_set_tex_max_mip_ext(sampler_id, maxmip)"); } -function gpu_set_tex_max_aniso(maxaniso) { ErrorFunction("gpu_set_tex_max_aniso(maxaniso)"); } -function gpu_set_tex_max_aniso_ext(sampler_id, maxaniso) { ErrorFunction("gpu_set_tex_max_aniso_ext(sampler_id, maxaniso)"); } -function gpu_set_tex_mip_enable(setting) { ErrorFunction("gpu_set_tex_mip_enable(setting)"); } -function gpu_set_tex_mip_enable_ext(sampler_id, setting) { ErrorFunction("gpu_set_tex_mip_enable_ext(sampler_id, setting)"); } - - -function gpu_get_blendenable() { ErrorFunction("gpu_get_blendenable()"); } -function gpu_get_ztestenable() { ErrorFunction("gpu_get_ztestenable()"); } -function gpu_get_zfunc() { ErrorFunction("gpu_get_zfunc()"); } -function gpu_get_zwriteenable() { ErrorFunction("gpu_get_zwriteenable()"); } -//function gpu_get_lightingenable() { ErrorFunction("gpu_get_lightingenable()"); } -function gpu_get_fog() { ErrorFunction("gpu_get_fog()"); } -function gpu_get_cullmode() { ErrorFunction("gpu_get_cullmode()"); } -function gpu_get_blendmode() { ErrorFunction("gpu_get_blendmode()"); } -function gpu_get_blendmode_ext() { ErrorFunction("gpu_get_blendmode_ext()"); } -function gpu_get_blendmode_ext_sepalpha() { ErrorFunction("gpu_get_blendmode_ext_sepalpha()"); } -function gpu_get_blendmode_src() { ErrorFunction("gpu_get_blendmode_src()"); } -function gpu_get_blendmode_dest() { ErrorFunction("gpu_get_blendmode_dest()"); } -function gpu_get_blendmode_srcalpha() { ErrorFunction("gpu_get_blendmode_srcalpha()"); } -function gpu_get_blendmode_destalpha() { ErrorFunction("gpu_get_blendmode_destalpha()"); } -function gpu_get_colorwriteenable() { ErrorFunction("gpu_get_colorwriteenable()"); } -function gpu_get_colourwriteenable() { ErrorFunction("gpu_get_colourwriteenable()"); } -function gpu_get_alphatestenable() { ErrorFunction("gpu_get_alphatestenable()"); } -function gpu_get_alphatestref() { ErrorFunction("gpu_get_alphatestref()"); } -function gpu_get_texfilter() { ErrorFunction("gpu_get_texfilter()"); } -function gpu_get_texfilter_ext(sampler_id) { ErrorFunction("gpu_get_texfilter_ext()"); } -function gpu_get_texrepeat() { ErrorFunction("gpu_get_texrepeat()"); } -function gpu_get_texrepeat_ext(sampler_id) { ErrorFunction("gpu_get_texrepeat_ext()"); } -function gpu_get_tex_filter() { ErrorFunction("gpu_get_tex_filter()"); } -function gpu_get_tex_filter_ext(sampler_id) { ErrorFunction("gpu_get_tex_filter_ext()"); } -function gpu_get_tex_repeat() { ErrorFunction("gpu_get_tex_repeat()"); } -function gpu_get_tex_repeat_ext(sampler_id) { ErrorFunction("gpu_get_tex_repeat_ext()"); } - -function gpu_get_tex_mip_filter() { ErrorFunction("gpu_get_tex_mip_filter()"); } -function gpu_get_tex_mip_filter_ext(sampler_id) { ErrorFunction("gpu_get_tex_mip_filter_ext(sampler_id)"); } -function gpu_get_tex_mip_bias() { ErrorFunction("gpu_get_tex_mip_bias()"); } -function gpu_get_tex_mip_bias_ext(sampler_id) { ErrorFunction("gpu_get_tex_mip_bias_ext(sampler_id)"); } -function gpu_get_tex_min_mip() { ErrorFunction("gpu_get_tex_min_mip()"); } -function gpu_get_tex_min_mip_ext(sampler_id) { ErrorFunction("gpu_get_tex_min_mip_ext(sampler_id)"); } -function gpu_get_tex_max_mip() { ErrorFunction("gpu_get_tex_max_mip()"); } -function gpu_get_tex_max_mip_ext(sampler_id) { ErrorFunction("gpu_get_tex_max_mip_ext(sampler_id)"); } -function gpu_get_tex_max_aniso() { ErrorFunction("gpu_get_tex_max_aniso()"); } -function gpu_get_tex_max_aniso_ext(sampler_id) { ErrorFunction("gpu_get_tex_max_aniso_ext(sampler_id)"); } -function gpu_get_tex_mip_enable() { ErrorFunction("gpu_get_tex_mip_enable()"); } -function gpu_get_tex_mip_enable_ext(sampler_id) { ErrorFunction("gpu_get_tex_mip_enable_ext(sampler_id)"); } - -function gpu_push_state() { ErrorFunction("gpu_push_state()"); } -function gpu_pop_state() { ErrorFunction("gpu_pop_state()"); } - -function gpu_get_state() { ErrorFunction("gpu_get_state()"); } -function gpu_set_state(map) { ErrorFunction("gpu_set_state()"); } - // -------------------------------------------------------------------------------------------------------------------------------------------------- - -var g_3DModels = []; var g_maxmatstack = 50; var g_matstacktop = 0; @@ -154,8 +251,8 @@ function InitD3DFunctions() { } // 3D state d3d_set_depth = WebGL_d3d_set_depth_RELEASE; - draw_set_color_write_enable = WebGL_draw_set_color_write_enable_RELEASE; - draw_set_colour_write_enable = WebGL_draw_set_color_write_enable_RELEASE; + compile_if_used(draw_set_color_write_enable = WebGL_draw_set_color_write_enable_RELEASE); + compile_if_used(draw_set_colour_write_enable = WebGL_draw_set_color_write_enable_RELEASE); // Matrix operations d3d_set_perspective = WebGL_d3d_set_perspective_RELEASE; @@ -171,100 +268,91 @@ function InitD3DFunctions() { d3d_light_get_ambient = WebGL_d3d_light_get_ambient_RELEASE; d3d_get_lighting = WebGL_d3d_get_lighting_RELEASE; - matrix_get = WebGL_Matrix_Get; - matrix_set = WebGL_Matrix_Set; - matrix_build = WebGL_Matrix_Build; - matrix_multiply = WebGL_Matrix_Multiply; - matrix_transform_vertex = WebGL_Matrix_Transform_Vertex; - - matrix_stack_push = WebGL_matrix_stack_push; - matrix_stack_pop = WebGL_matrix_stack_pop; - matrix_stack_set = WebGL_matrix_stack_set; - matrix_stack_clear = WebGL_matrix_stack_clear; - matrix_stack_top = WebGL_matrix_stack_top; - matrix_stack_is_empty = WebGL_matrix_stack_is_empty; + compile_if_used(matrix_get = WebGL_Matrix_Get); + compile_if_used(matrix_set = WebGL_Matrix_Set); + // rest of the matrix functions are already assigned // GPU functions - gpu_set_blendmode = WebGL_gpu_set_blendmode; - gpu_set_blendenable = WebGL_gpu_set_blendenable; - gpu_set_ztestenable = WebGL_gpu_set_ztestenable; - gpu_set_zfunc = WebGL_gpu_set_zfunc; - gpu_set_zwriteenable = WebGL_gpu_set_zwriteenable; - gpu_set_fog = WebGL_gpu_set_fog; - gpu_set_cullmode = WebGL_gpu_set_cullmode; - gpu_set_blendmode = WebGL_gpu_set_blendmode; - gpu_set_blendmode_ext = WebGL_gpu_set_blendmode_ext; - gpu_set_blendmode_ext_sepalpha = WebGL_gpu_set_blendmode_ext_sepalpha; - gpu_set_colorwriteenable = WebGL_gpu_set_colorwriteenable; - gpu_set_colourwriteenable = WebGL_gpu_set_colourwriteenable; - gpu_set_alphatestenable = WebGL_gpu_set_alphatestenable; - gpu_set_alphatestref = WebGL_gpu_set_alphatestref; - gpu_set_texfilter = WebGL_gpu_set_texfilter; + compile_if_used(gpu_set_blendmode = WebGL_gpu_set_blendmode); + compile_if_used(gpu_set_blendenable = WebGL_gpu_set_blendenable); + compile_if_used(gpu_set_ztestenable = WebGL_gpu_set_ztestenable); + compile_if_used(gpu_set_zfunc = WebGL_gpu_set_zfunc); + compile_if_used(gpu_set_zwriteenable = WebGL_gpu_set_zwriteenable); + compile_if_used(gpu_set_fog = WebGL_gpu_set_fog); + compile_if_used(gpu_set_cullmode = WebGL_gpu_set_cullmode); + compile_if_used(gpu_set_blendmode = WebGL_gpu_set_blendmode); + compile_if_used(gpu_set_blendmode_ext = WebGL_gpu_set_blendmode_ext); + compile_if_used(gpu_set_blendmode_ext_sepalpha = WebGL_gpu_set_blendmode_ext_sepalpha); + compile_if_used(gpu_set_colorwriteenable = WebGL_gpu_set_colorwriteenable); + compile_if_used(gpu_set_colourwriteenable = WebGL_gpu_set_colourwriteenable); + compile_if_used(gpu_set_alphatestenable = WebGL_gpu_set_alphatestenable); + compile_if_used(gpu_set_alphatestref = WebGL_gpu_set_alphatestref); + compile_if_used(gpu_set_texfilter = WebGL_gpu_set_texfilter); gpu_set_texfilter_ext = WebGL_gpu_set_texfilter_ext; - gpu_set_texrepeat = WebGL_gpu_set_texrepeat; + compile_if_used(gpu_set_texrepeat = WebGL_gpu_set_texrepeat); gpu_set_texrepeat_ext = WebGL_gpu_set_texrepeat_ext; - gpu_set_tex_filter = WebGL_gpu_set_texfilter; + compile_if_used(gpu_set_tex_filter = WebGL_gpu_set_texfilter); gpu_set_tex_filter_ext = WebGL_gpu_set_texfilter_ext; - gpu_set_tex_repeat = WebGL_gpu_set_texrepeat; - gpu_set_tex_repeat_ext = WebGL_gpu_set_texrepeat_ext; - - gpu_set_tex_mip_filter = WebGL_gpu_set_tex_mip_filter; - gpu_set_tex_mip_filter_ext = WebGL_gpu_set_tex_mip_filter_ext; - gpu_set_tex_mip_bias = WebGL_gpu_set_tex_mip_bias; - gpu_set_tex_mip_bias_ext = WebGL_gpu_set_tex_mip_bias_ext; - gpu_set_tex_min_mip = WebGL_gpu_set_tex_min_mip; - gpu_set_tex_min_mip_ext = WebGL_gpu_set_tex_min_mip_ext; - gpu_set_tex_max_mip = WebGL_gpu_set_tex_max_mip; - gpu_set_tex_max_mip_ext = WebGL_gpu_set_tex_max_mip_ext; - gpu_set_tex_max_aniso = WebGL_gpu_set_tex_max_aniso; - gpu_set_tex_max_aniso_ext = WebGL_gpu_set_tex_max_aniso_ext; - gpu_set_tex_mip_enable = WebGL_gpu_set_tex_mip_enable; - gpu_set_tex_mip_enable_ext = WebGL_gpu_set_tex_mip_enable_ext; - - gpu_get_blendenable = WebGL_gpu_get_blendenable; + compile_if_used(gpu_set_tex_repeat = WebGL_gpu_set_texrepeat); + compile_if_used(gpu_set_tex_repeat_ext = WebGL_gpu_set_texrepeat_ext); + + compile_if_used(gpu_set_tex_mip_filter = WebGL_gpu_set_tex_mip_filter); + compile_if_used(gpu_set_tex_mip_filter_ext = WebGL_gpu_set_tex_mip_filter_ext); + compile_if_used(gpu_set_tex_mip_bias = WebGL_gpu_set_tex_mip_bias); + compile_if_used(gpu_set_tex_mip_bias_ext = WebGL_gpu_set_tex_mip_bias_ext); + compile_if_used(gpu_set_tex_min_mip = WebGL_gpu_set_tex_min_mip); + compile_if_used(gpu_set_tex_min_mip_ext = WebGL_gpu_set_tex_min_mip_ext); + compile_if_used(gpu_set_tex_max_mip = WebGL_gpu_set_tex_max_mip); + compile_if_used(gpu_set_tex_max_mip_ext = WebGL_gpu_set_tex_max_mip_ext); + compile_if_used(gpu_set_tex_max_aniso = WebGL_gpu_set_tex_max_aniso); + compile_if_used(gpu_set_tex_max_aniso_ext = WebGL_gpu_set_tex_max_aniso_ext); + compile_if_used(gpu_set_tex_mip_enable = WebGL_gpu_set_tex_mip_enable); + compile_if_used(gpu_set_tex_mip_enable_ext = WebGL_gpu_set_tex_mip_enable_ext); + + compile_if_used(gpu_get_blendenable = WebGL_gpu_get_blendenable); gpu_get_ztestenable = WebGL_gpu_get_ztestenable; - gpu_get_zfunc = WebGL_gpu_get_zfunc; + compile_if_used(gpu_get_zfunc = WebGL_gpu_get_zfunc); gpu_get_zwriteenable = WebGL_gpu_get_zwriteenable; - gpu_get_fog = WebGL_gpu_get_fog; + compile_if_used(gpu_get_fog = WebGL_gpu_get_fog); gpu_get_cullmode = WebGL_gpu_get_cullmode; - gpu_get_blendmode = WebGL_gpu_get_blendmode; - gpu_get_blendmode_ext = WebGL_gpu_get_blendmode_ext; - gpu_get_blendmode_ext_sepalpha = WebGL_gpu_get_blendmode_ext_sepalpha; - gpu_get_blendmode_src = WebGL_gpu_get_blendmode_src; - gpu_get_blendmode_dest = WebGL_gpu_get_blendmode_dest; - gpu_get_blendmode_srcalpha = WebGL_gpu_get_blendmode_srcalpha; - gpu_get_blendmode_destalpha = WebGL_gpu_get_blendmode_destalpha; - gpu_get_colorwriteenable = WebGL_gpu_get_colorwriteenable; - gpu_get_colourwriteenable = WebGL_gpu_get_colourwriteenable; + compile_if_used(gpu_get_blendmode = WebGL_gpu_get_blendmode); + compile_if_used(gpu_get_blendmode_ext = WebGL_gpu_get_blendmode_ext); + compile_if_used(gpu_get_blendmode_ext_sepalpha = WebGL_gpu_get_blendmode_ext_sepalpha); + compile_if_used(gpu_get_blendmode_src = WebGL_gpu_get_blendmode_src); + compile_if_used(gpu_get_blendmode_dest = WebGL_gpu_get_blendmode_dest); + compile_if_used(gpu_get_blendmode_srcalpha = WebGL_gpu_get_blendmode_srcalpha); + compile_if_used(gpu_get_blendmode_destalpha = WebGL_gpu_get_blendmode_destalpha); + compile_if_used(gpu_get_colorwriteenable = WebGL_gpu_get_colorwriteenable); + compile_if_used(gpu_get_colourwriteenable = WebGL_gpu_get_colourwriteenable); gpu_get_alphatestenable = WebGL_gpu_get_alphatestenable; - gpu_get_alphatestref = WebGL_gpu_get_alphatestref; - gpu_get_texfilter = WebGL_gpu_get_texfilter; + compile_if_used(gpu_get_alphatestref = WebGL_gpu_get_alphatestref); + compile_if_used(gpu_get_texfilter = WebGL_gpu_get_texfilter); gpu_get_texfilter_ext = WebGL_gpu_get_texfilter_ext; - gpu_get_texrepeat = WebGL_gpu_get_texrepeat; - gpu_get_texrepeat_ext = WebGL_gpu_get_texrepeat_ext; - gpu_get_tex_filter = WebGL_gpu_get_texfilter; - gpu_get_tex_filter_ext = WebGL_gpu_get_texfilter_ext; - gpu_get_tex_repeat = WebGL_gpu_get_texrepeat; - gpu_get_tex_repeat_ext = WebGL_gpu_get_texrepeat_ext; - - gpu_get_tex_mip_filter = WebGL_gpu_get_tex_mip_filter; - gpu_get_tex_mip_filter_ext = WebGL_gpu_get_tex_mip_filter_ext; - gpu_get_tex_mip_bias = WebGL_gpu_get_tex_mip_bias; - gpu_get_tex_mip_bias_ext = WebGL_gpu_get_tex_mip_bias_ext; - gpu_get_tex_min_mip = WebGL_gpu_get_tex_min_mip; - gpu_get_tex_min_mip_ext = WebGL_gpu_get_tex_min_mip_ext; - gpu_get_tex_max_mip = WebGL_gpu_get_tex_max_mip; - gpu_get_tex_max_mip_ext = WebGL_gpu_get_tex_max_mip_ext; - gpu_get_tex_max_aniso = WebGL_gpu_get_tex_max_aniso; - gpu_get_tex_max_aniso_ext = WebGL_gpu_get_tex_max_aniso_ext; - gpu_get_tex_mip_enable = WebGL_gpu_get_tex_mip_enable; - gpu_get_tex_mip_enable_ext = WebGL_gpu_get_tex_mip_enable_ext; - - gpu_push_state = WebGL_gpu_push_state; - gpu_pop_state = WebGL_gpu_pop_state; - - gpu_get_state = WebGL_gpu_get_state; - gpu_set_state = WebGL_gpu_set_state; + compile_if_used(gpu_get_texrepeat = WebGL_gpu_get_texrepeat); + + compile_if_used(gpu_get_tex_filter = WebGL_gpu_get_texfilter); + compile_if_used(gpu_get_tex_filter_ext = WebGL_gpu_get_texfilter_ext); + compile_if_used(gpu_get_tex_repeat = WebGL_gpu_get_texrepeat); + compile_if_used(gpu_get_tex_repeat_ext = WebGL_gpu_get_texrepeat_ext); + + compile_if_used(gpu_get_tex_mip_filter = WebGL_gpu_get_tex_mip_filter); + compile_if_used(gpu_get_tex_mip_filter_ext = WebGL_gpu_get_tex_mip_filter_ext); + compile_if_used(gpu_get_tex_mip_bias = WebGL_gpu_get_tex_mip_bias); + compile_if_used(gpu_get_tex_mip_bias_ext = WebGL_gpu_get_tex_mip_bias_ext); + compile_if_used(gpu_get_tex_min_mip = WebGL_gpu_get_tex_min_mip); + compile_if_used(gpu_get_tex_min_mip_ext = WebGL_gpu_get_tex_min_mip_ext); + compile_if_used(gpu_get_tex_max_mip = WebGL_gpu_get_tex_max_mip); + compile_if_used(gpu_get_tex_max_mip_ext = WebGL_gpu_get_tex_max_mip_ext); + compile_if_used(gpu_get_tex_max_aniso = WebGL_gpu_get_tex_max_aniso); + compile_if_used(gpu_get_tex_max_aniso_ext = WebGL_gpu_get_tex_max_aniso_ext); + compile_if_used(gpu_get_tex_mip_enable = WebGL_gpu_get_tex_mip_enable); + compile_if_used(gpu_get_tex_mip_enable_ext = WebGL_gpu_get_tex_mip_enable_ext); + + compile_if_used(gpu_push_state = WebGL_gpu_push_state); + compile_if_used(gpu_pop_state = WebGL_gpu_pop_state); + + compile_if_used(gpu_get_state = WebGL_gpu_get_state); + compile_if_used(gpu_set_state = WebGL_gpu_set_state); g_matstack[0] = new Matrix(); // this should create a unit matrix } @@ -525,11 +613,6 @@ function WebGL_d3d_set_fog_RELEASE(enable,colour,start,end) { g_webGL.SetFogData(GR_FogParameters); } -//matrix_get = WebGL_Matrix_Get; -//matrix_set = WebGL_Matrix_Set; -//matrix_build = WebGL_Matrix_Build; -//matrix_multiply = WebGL_Matrix_Multiply; - // ############################################################################################# /// Function: @@ -854,7 +937,6 @@ function WebGL_gpu_set_zwriteenable(_enable) g_webGL.RSMan.SetRenderState(yyGL.RenderState_ZWriteEnable, yyGetInt32(_enable) >= 0.5); } -//function WebGL_gpu_set_lightingenable(_enable) { ErrorFunction("gpu_set_lightingenable()"); } function WebGL_gpu_set_fog(_enable,_col,_start,_end) { if (Array.isArray(_enable)) @@ -1292,7 +1374,6 @@ function WebGL_gpu_get_zwriteenable() return g_webGL.RSMan.GetRenderState(yyGL.RenderState_ZWriteEnable) ? 1.0 : 0.0; } -//function WebGL_gpu_get_lightingenable() { ErrorFunction("gpu_get_lightingenable()"); } function WebGL_gpu_get_fog() { var params = new Array(); From 27e9463c794b876eaf2d2f20163f9530566a8ef8 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 10:30:44 +0300 Subject: [PATCH 42/84] Remove 2d canvas versions of drawing functions when using "WebGL required"; This also removes several GM8 `_gradient` functions. The thing with `function name(){} ... name = otherFunc` is due to fact that DCE can strip unused functions, but it cannot strip variable declarations (and I don't want to touch that right now) --- scripts/CameraManager.js | 2 + scripts/functions/Function_Graphics.js | 231 ++++++++++--------------- scripts/functions/Function_Sprite.js | 15 +- scripts/functions/Function_Surface.js | 5 +- scripts/functions/Function_YoYo.js | 3 +- scripts/yyGraphics.js | 8 +- scripts/yyRoom.js | 13 +- scripts/yyWebGL.js | 67 +++---- 8 files changed, 149 insertions(+), 195 deletions(-) diff --git a/scripts/CameraManager.js b/scripts/CameraManager.js index 1317ea97..c90115a7 100644 --- a/scripts/CameraManager.js +++ b/scripts/CameraManager.js @@ -519,6 +519,7 @@ CCamera.prototype.ApplyMatrices = function () { WebGL_SetMatrix(MATRIX_VIEW, this.m_viewMat); } else { + // @if feature("2d") WebGL_SetMatrix(MATRIX_VIEW, this.m_viewMat); // Work out port scaling var wscale = g_clipw / g_worldw; @@ -535,6 +536,7 @@ CCamera.prototype.ApplyMatrices = function () { // for some reason this function takes the matrix transposed graphics._setTransform(g_transform[0], g_transform[3], g_transform[1], g_transform[4], g_transform[2], g_transform[5]); + // @endif } if (g_RenderTargetActive == -1) { diff --git a/scripts/functions/Function_Graphics.js b/scripts/functions/Function_Graphics.js index 4dd90afa..e16a13f5 100644 --- a/scripts/functions/Function_Graphics.js +++ b/scripts/functions/Function_Graphics.js @@ -218,9 +218,9 @@ function draw_clear( _col ) /// /// // ############################################################################################# -var draw_clear_alpha = draw_clear_alpha_RELEASE; -function draw_clear_alpha_RELEASE(_col, _alpha) -{ +function draw_clear_alpha(){} +// @if feature("2d") +draw_clear_alpha = (_col, _alpha) => { _col = yyGetInt32(_col); _alpha = yyGetReal(_alpha); @@ -251,6 +251,7 @@ function draw_clear_alpha_RELEASE(_col, _alpha) Graphics_Restore(); } +// @endif // ############################################################################################# @@ -270,9 +271,7 @@ function make_color_rgb(_red,_green,_blue) { return (yyGetInt32(_red)) | (yyGetInt32(_green) << 8) | (yyGetInt32(_blue) << 16); } -function make_color(_r, _g, _b) { return make_color_rgb(_r, _g, _b); } var make_colour_rgb = make_color_rgb; -var make_colour = make_color; // ############################################################################################# /// Function: @@ -457,7 +456,8 @@ function merge_color(_col1,_col2,_amount) return ((r<<16)&0xff0000) | ((g<<8)&0xff00) | (b&0xff); } -var merge_colour = merge_color; +function merge_colour(){} +compile_if_used(merge_colour = merge_color); // ############################################################################################# /// Function: @@ -523,7 +523,8 @@ function make_color_hsv( _hue,_saturation,_value ) return Result; } -var make_colour_hsv = make_color_hsv; +function make_colour_hsv(){} +compile_if_used(make_colour_hsv = make_color_hsv); // ############################################################################################# @@ -539,10 +540,7 @@ function draw_set_alpha( _alpha ) _alpha = yyGetReal(_alpha); // cap _alpha to between 0 and 1 - if (_alpha < 0) { _alpha = 0; } - if (_alpha > 1) { _alpha = 1; } - - g_GlobalAlpha = _alpha; + g_GlobalAlpha = _alpha < 0 ? 0 : (_alpha > 1 ? 1 : _alpha); g_GlobalColour_HTML_RGBA = GetHTMLRGBA(g_GlobalColour, g_GlobalAlpha); } @@ -573,7 +571,8 @@ function draw_get_color( ) { return g_GlobalColour_GM; } -var draw_get_colour = draw_get_color; +function draw_get_colour(){} +compile_if_used(draw_get_colour = draw_get_color); // ############################################################################################# /// Function: @@ -696,8 +695,9 @@ var draw_roundrect_colour = draw_roundrect_color; /// Outline the rect? /// // ############################################################################################# -var draw_roundrect_color_ext = draw_roundrect_color_EXT_RELEASE; -var draw_roundrect_colour_ext = draw_roundrect_color_EXT_RELEASE; +function draw_roundrect_color_ext(){} +function draw_roundrect_colour_ext(){} +// @if feature("2d") function draw_roundrect_color_EXT_RELEASE(_x1, _y1, _x2, _y2, _radx, _rady, _col1, _col2, _outline) { _x1 = yyGetReal(_x1); @@ -758,6 +758,9 @@ function draw_roundrect_color_EXT_RELEASE(_x1, _y1, _x2, _y2, _radx, _rady, _col graphics.fill(); } } +draw_roundrect_color_ext = draw_roundrect_color_EXT_RELEASE; +compile_if_used(draw_roundrect_colour_ext = draw_roundrect_color_EXT_RELEASE); +// @endif // ############################################################################################# /// Function: @@ -771,7 +774,8 @@ function draw_roundrect_color_EXT_RELEASE(_x1, _y1, _x2, _y2, _radx, _rady, _col /// Outline the rect? /// // ############################################################################################# -var draw_rectangle = draw_rectangle_RELEASE; +function draw_rectangle(){} +// @if feature("2d") function draw_rectangle_RELEASE ( _x1,_y1, _x2,_y2, _outline ) { _x1 = yyGetReal(_x1); @@ -807,6 +811,8 @@ function draw_rectangle_RELEASE ( _x1,_y1, _x2,_y2, _outline ) graphics._fillRect(_x1,_y1, _x2-_x1+1,_y2-_y1+1); } } +draw_rectangle = draw_rectangle_RELEASE; // used for vkeys +// @endif // ############################################################################################# /// Function: @@ -821,8 +827,9 @@ function draw_rectangle_RELEASE ( _x1,_y1, _x2,_y2, _outline ) /// Whether or not to draw the rect as an outline /// // ############################################################################################# -var draw_rectangle_color = draw_rectangle_color_RELEASE; -var draw_rectangle_colour = draw_rectangle_color_RELEASE; +function draw_rectangle_color(){} +function draw_rectangle_colour(){} +// @if feature("2d") function draw_rectangle_color_RELEASE( _x1,_y1, _x2,_y2, _col1, _col2,_col3,_col4, _outline ) { //return; @@ -866,74 +873,9 @@ function draw_rectangle_color_RELEASE( _x1,_y1, _x2,_y2, _col1, _col2,_col3,_ graphics._fillRect(_x1 + 0.5, _y1 + 0.5, (_x2 - _x1), (_y2 - _y1)); } } - -// ############################################################################################# -/// Function: -/// Draw a rectangle with a gradient -/// -/// -/// In: Top X coordinate -/// Top Y coordinate -/// Bottom X coordinate -/// Bottom X coordinate -/// Start colour of the rect as a number -/// End colour of the rect as a number -/// Whether or not the gradient should be vertical (or horizontal) -/// Whether or not to draw the rect as an outline -/// -// ############################################################################################# -var draw_rectangle_gradient = draw_rectangle_gradient_RELEASE; -function draw_rectangle_gradient_RELEASE(_x1, _y1, _x2, _y2, _col1, _col2, _vert, _outline) -{ - _x1 = yyGetReal(_x1); - _y1 = yyGetReal(_y1); - _x2 = yyGetReal(_x2); - _y2 = yyGetReal(_y2); - _col1 = yyGetInt32(_col1); - _col2 = yyGetInt32(_col2); - _vert = yyGetBool(_vert); - _outline = yyGetBool(_outline); - - graphics.globalAlpha = g_GlobalAlpha; - graphics.lineWidth = 1; - - var col1 = GetHTMLRGBA( ConvertGMColour(_col1), 1.0 ); - var col2 = GetHTMLRGBA( ConvertGMColour(_col2), 1.0 ); - var gradient; - if (_vert) { - gradient = graphics.createLinearGradient(_x1, _y1, _x1, _y2); - } - else { - gradient = graphics.createLinearGradient(_x1, _y1, _x2, _y1); - } - gradient.addColorStop(0, col1 ); - gradient.addColorStop(1, col2 ); - - if (_outline) - { - if (offsethack != 0.0) - { - _x1 += offsethack; - _y1 += offsethack; - _x2 += offsethack; - _y2 += offsethack; - } - - graphics.strokeStyle = gradient; - graphics._strokeRect(_x1 + 0.5, _y1 + 0.5, _x2 - _x1, _y2 - _y1); - } - else - { - if (offsethack != 0.0) - { - _x2 += offsethack; - _y2 += offsethack; - } - - graphics.fillStyle = gradient; - graphics._fillRect(_x1 + 0.5, _y1 + 0.5, _x2 - _x1, _y2 - _y1); - } -} +draw_rectangle_color = draw_rectangle_color_RELEASE; +compile_if_used(draw_rectangle_colour = draw_rectangle_color_RELEASE); +// @endif // ############################################################################################# /// Function: @@ -946,9 +888,9 @@ function draw_rectangle_gradient_RELEASE(_x1, _y1, _x2, _y2, _col1, _col2, _vert /// /// // ############################################################################################# -var draw_point = draw_point_RELEASE; -function draw_point_RELEASE(_x, _y) -{ +function draw_point(){} +// @if feature("2d") +draw_point = (_x, _y) => { _x = yyGetReal(_x); _y = yyGetReal(_y); @@ -962,7 +904,7 @@ function draw_point_RELEASE(_x, _y) graphics.fillStyle = g_GlobalColour_HTML_RGBA; graphics._fillRect(_x, _y, 1, 1); } - +// @endif // ############################################################################################# @@ -977,7 +919,9 @@ function draw_point_RELEASE(_x, _y) /// /// // ############################################################################################# -function draw_line_width(_x1, _y1, _x2, _y2, _w) { +function draw_line_width(){} +// @if feature("2d") +draw_line_width = (_x1, _y1, _x2, _y2, _w) => { _x1 = yyGetReal(_x1); _y1 = yyGetReal(_y1); @@ -1004,7 +948,7 @@ function draw_line_width(_x1, _y1, _x2, _y2, _w) { graphics._stroke(); graphics._fillRect(_x2, _y2, 1, 1); // CHROME doesn't fill in the bottom pixel! } - +// @endif @@ -1037,13 +981,10 @@ function draw_line(_x1,_y1,_x2,_y2) /// The colour of the pixel, or 0 for off screen/canvas. /// // ############################################################################################# -var draw_getpixel = draw_getpixel_RELEASE; -var draw_getpixel_ext = draw_getpixel_ext_RELEASE; -function draw_getpixel_RELEASE(_x, _y) -{ - return draw_getpixel_ext_RELEASE(yyGetReal(_x), yyGetReal(_y)) & 0x00ffffff; -} +function draw_getpixel(){} +function draw_getpixel_ext(){} +// @if feature("2d") function draw_getpixel_ext_RELEASE(_x, _y) { var ws = canvas.width / g_OriginalWidth; @@ -1053,6 +994,9 @@ function draw_getpixel_ext_RELEASE(_x, _y) var col = GetCanvasPixel(canvas, yyGetReal(_x) * ws, yyGetReal(_y) * hs); return col; } +compile_if_used(draw_getpixel = (_x, _y) => draw_getpixel_ext_RELEASE(yyGetReal(_x), yyGetReal(_y)) & 0x00ffffff); +compile_if_used(draw_getpixel_ext = draw_getpixel_ext_RELEASE); +// @endif // ############################################################################################# /// Function: @@ -1070,7 +1014,8 @@ function draw_getpixel_ext_RELEASE(_x, _y) /// /// // ############################################################################################# -var draw_triangle = draw_triangle_RELEASE; +function draw_triangle(){} +// @if feature("2d") function draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) { _x1 = yyGetReal(_x1); @@ -1128,6 +1073,8 @@ function draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) { } } +compile_if_used(draw_triangle = draw_triangle_RELEASE); +// @endif // ############################################################################################# /// Function: @@ -1148,8 +1095,9 @@ function draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) { /// /// // ############################################################################################# -var draw_triangle_color = draw_triangle_color_RELEASE; -var draw_triangle_colour = draw_triangle_color_RELEASE; +function draw_triangle_color(){} +function draw_triangle_colour(){} +// @if feature("2d") function draw_triangle_color_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2, _col3, _outline) { var col1 = GetHTMLRGB(ConvertGMColour(_col1)|0xff000000); @@ -1160,7 +1108,6 @@ function draw_triangle_color_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2, _col1 = yyGetInt32(_col1); _col2 = yyGetInt32(_col2); _col3 = yyGetInt32(_col3); - _col4 = yyGetInt32(_col4); _outline = yyGetBool(_outline); /*_x1 += 0.5; @@ -1210,6 +1157,9 @@ function draw_triangle_color_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2, graphics.lineJoin = "miter"; } } +compile_if_used(draw_triangle_color = draw_triangle_color_RELEASE); +compile_if_used(draw_triangle_colour = draw_triangle_color_RELEASE); +// @endif // ############################################################################################# /// Function: @@ -1233,8 +1183,7 @@ function draw_triangle_color_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2, /// /// // ############################################################################################# -var draw_healthbar_ex = draw_healthbar_ex_RELEASE; -function draw_healthbar_ex_RELEASE(_x1, _y1, _x2, _y2, _amount, _backcol, _mincol, _midcol, _maxcol, _direction, _showback, _showborder) +function draw_healthbar_ex(_x1, _y1, _x2, _y2, _amount, _backcol, _mincol, _midcol, _maxcol, _direction, _showback, _showborder) { _x1 = yyGetReal(_x1); _y1 = yyGetReal(_y1); @@ -1369,8 +1318,7 @@ function draw_get_circle_precision() /// /// // ############################################################################################# -var draw_arrow = draw_arrow_RELEASE; -function draw_arrow_RELEASE(x1, y1, x2, y2, size) +function draw_arrow(x1, y1, x2, y2, size) { x1 = yyGetReal(x1); y1 = yyGetReal(y1); @@ -1427,8 +1375,9 @@ function draw_ellipse(_x1, _y1, _x2, _y2, _outline) { /// /// // ############################################################################################# -var draw_ellipse_color = draw_ellipse_color_RELEASE; -var draw_ellipse_colour = draw_ellipse_color_RELEASE; +function draw_ellipse_color(){} +function draw_ellipse_colour(){} +// @if feature("2d") function draw_ellipse_color_RELEASE(x, y, x1, y1, _col1, _col2, outline) { x = yyGetReal(x); @@ -1486,6 +1435,11 @@ function draw_ellipse_color_RELEASE(x, y, x1, y1, _col1, _col2, outline) graphics.fill(); } } +// @if function("draw_ellipse") || function("draw_ellipse_color") +draw_ellipse_color = draw_ellipse_color_RELEASE; +// @endif +compile_if_used(draw_ellipse_colour = draw_ellipse_color_RELEASE); +// @endif // ############################################################################################# @@ -1502,10 +1456,10 @@ function draw_ellipse_color_RELEASE(x, y, x1, y1, _col1, _col2, outline) /// /// // ############################################################################################# -var draw_circle_color = draw_circle_color_RELEASE; -var draw_circle_colour = draw_circle_color_RELEASE; -function draw_circle_color_RELEASE(_x, _y, _r, _col1, _col2, _outline) -{ +function draw_circle_color(){} +function draw_circle_colour(){} +// @if feature("2d") +function draw_circle_color_RELEASE(_x, _y, _r, _col1, _col2, _outline) { _x = yyGetReal(_x); _y = yyGetReal(_y); _r = yyGetReal(_r); @@ -1542,6 +1496,11 @@ function draw_circle_color_RELEASE(_x, _y, _r, _col1, _col2, _outline) } graphics._closePath(); } +// @if function("draw_circle") || function("draw_circle_color") +draw_circle_color = draw_circle_color_RELEASE; // used for draw_circle +// @endif +compile_if_used(draw_circle_colour = draw_circle_color_RELEASE); +// @endif // ############################################################################################# /// Function: @@ -1573,10 +1532,10 @@ function draw_circle(_x,_y,_r,_outline) { /// /// // ############################################################################################# -var draw_point_color = draw_point_color_RELEASE; -var draw_point_colour = draw_point_color_RELEASE; -function draw_point_color_RELEASE(_x, _y, _col) -{ +function draw_point_color(){}; +function draw_point_colour(){}; +// @if feature("2d") +function draw_point_color_RELEASE(_x, _y, _col) { _x = yyGetReal(_x); _y = yyGetReal(_y); @@ -1592,8 +1551,9 @@ function draw_point_color_RELEASE(_x, _y, _col) graphics.fillStyle = col1; graphics._fillRect(_x,_y,1,1); } - - +compile_if_used(draw_point_color = draw_point_color_RELEASE); +compile_if_used(draw_point_colour = draw_point_color_RELEASE); +// @endif // ############################################################################################# @@ -1608,10 +1568,10 @@ function draw_point_color_RELEASE(_x, _y, _col) /// /// // ############################################################################################# -var draw_line_width_color = draw_line_width_color_RELEASE; -var draw_line_width_colour = draw_line_width_color_RELEASE; -function draw_line_width_color_RELEASE(_x1, _y1, _x2, _y2, _w, _col1, _col2) -{ +function draw_line_width_color(){} +function draw_line_width_colour(){} +// @if feature("2d") +function draw_line_width_color_RELEASE(_x1, _y1, _x2, _y2, _w, _col1, _col2) { _x1 = yyGetReal(_x1); _y1 = yyGetReal(_y1); _x2 = yyGetReal(_x2); @@ -1646,6 +1606,9 @@ function draw_line_width_color_RELEASE(_x1, _y1, _x2, _y2, _w, _col1, _col2) graphics._stroke(); graphics._closePath(); } +draw_line_width_color = draw_line_width_color_RELEASE; +compile_if_used(draw_line_width_colour = draw_line_width_color_RELEASE); +// @endif // ############################################################################################# @@ -1664,7 +1627,9 @@ function draw_line_color(_x1,_y1,_x2,_y2,_col1,_col2) { draw_line_width_color(_x1,_y1, _x2,_y2, 1, _col1,_col2); } +// @if function("draw_line_colour") var draw_line_colour = draw_line_color; +// @endif // ############################################################################################# @@ -1716,27 +1681,6 @@ function draw_button(_x1, _y1, _x2, _y2, _down) draw_rectangle_color(_x1,_y1, _x2,_y2, g_GlobalColour_GM, g_GlobalColour_GM, g_GlobalColour_GM, g_GlobalColour_GM, false); } - -// ############################################################################################# -/// Function: -/// Draws an ellipse with the given bounding box with a gradient from the centre -/// of the ellipse to the max radius of the ellipse -/// -/// -/// In: -/// -/// -/// -/// -/// Out: -/// -/// -// ############################################################################################# -function draw_ellipse_gradient(x, y, x1, y1, col1, col2, outline) -{ - draw_ellipse_color(x, y, x1, y1, col1, col2, outline); -} - // ############################################################################################# /// Function: /// Indicates what blend mode to use. The following values are possible: @@ -1783,8 +1727,7 @@ function draw_set_blend_mode(_blend) /// /// // ############################################################################################# -var draw_set_blend_mode_ext = draw_set_blend_mode_ext_html5; -function draw_set_blend_mode_ext_html5(src, dest) { +function draw_set_blend_mode_ext(src, dest) { ErrorFunction("Blend modes only available in WebGL mode."); } diff --git a/scripts/functions/Function_Sprite.js b/scripts/functions/Function_Sprite.js index fcfa619f..f840c718 100644 --- a/scripts/functions/Function_Sprite.js +++ b/scripts/functions/Function_Sprite.js @@ -381,7 +381,8 @@ function sprite_set_alpha_from_sprite( _dest, _src ) /// /// // ############################################################################################# -var sprite_add_from_screen = sprite_add_from_screen_RELEASE; +function sprite_add_from_screen(){} +// @if feature("2d") function sprite_add_from_screen_RELEASE(_ind, _x, _y, _w, _h, _removeback, _smooth) { _ind = yyGetInt32(_ind); @@ -433,6 +434,8 @@ function sprite_add_from_screen_RELEASE(_ind, _x, _y, _w, _h, _removeback, _smoo return _ind; } +compile_if_used(sprite_add_from_screen = sprite_add_from_screen_RELEASE); +// @endif // ############################################################################################# @@ -453,7 +456,8 @@ function sprite_add_from_screen_RELEASE(_ind, _x, _y, _w, _h, _removeback, _smoo /// /// // ############################################################################################# -var sprite_create_from_surface = sprite_create_from_surface_RELEASE; +function sprite_create_from_surface(){} +// @if feature("2d") function sprite_create_from_surface_RELEASE(_id, _x, _y, _w, _h, _removeback, _smooth, _xorig, _yorig) { _id = yyGetInt32(_id); @@ -531,6 +535,8 @@ function sprite_create_from_surface_RELEASE(_id, _x, _y, _w, _h, _removeback, _s return newindex; } +compile_if_used(sprite_create_from_surface = sprite_create_from_surface_RELEASE); +// @endif @@ -551,7 +557,8 @@ function sprite_create_from_surface_RELEASE(_id, _x, _y, _w, _h, _removeback, _s /// /// // ############################################################################################# -var sprite_add_from_surface = sprite_add_from_surface_RELEASE; +function sprite_add_from_surface(){} +// @if feature("2d") function sprite_add_from_surface_RELEASE(_ind, _id, _x, _y, _w, _h, _removeback, _smooth) { _ind = yyGetInt32(_ind); @@ -603,6 +610,8 @@ function sprite_add_from_surface_RELEASE(_ind, _id, _x, _y, _w, _h, _removeback, return _ind; } +compile_if_used(sprite_add_from_surface = sprite_add_from_surface_RELEASE); +// @endif diff --git a/scripts/functions/Function_Surface.js b/scripts/functions/Function_Surface.js index d382a154..db258de9 100644 --- a/scripts/functions/Function_Surface.js +++ b/scripts/functions/Function_Surface.js @@ -775,7 +775,8 @@ function surface_save_part(_id,_fname,_x,_y,_w,_h) /// /// // ############################################################################################# -var draw_surface = draw_surface_RELEASE; +function draw_surface(){} +// @if feature("2d") function draw_surface_RELEASE(_id, _x, _y) { var pSurf = g_Surfaces.Get(yyGetInt32(_id)); @@ -793,6 +794,8 @@ function draw_surface_RELEASE(_id, _x, _y) } graphics.globalAlpha = alpha; } +compile_if_used(draw_surface = draw_surface_RELEASE); +// @endif // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_YoYo.js b/scripts/functions/Function_YoYo.js index 4d531157..f7acab83 100644 --- a/scripts/functions/Function_YoYo.js +++ b/scripts/functions/Function_YoYo.js @@ -96,8 +96,7 @@ function code_is_compiled() { return true; } /// In: /// // ############################################################################################# -var draw_enable_alphablend = draw_enable_alphablend_html5; -function draw_enable_alphablend_html5(_on_off) +function draw_enable_alphablend(_on_off) { } diff --git a/scripts/yyGraphics.js b/scripts/yyGraphics.js index 317b358e..5402f528 100644 --- a/scripts/yyGraphics.js +++ b/scripts/yyGraphics.js @@ -180,7 +180,7 @@ function Graphics_Init( _canvas ) g_transform[5] = 0; if( !g_webGL ){ - + // @if feature("2d") // Fill in RELEASE function pointers. if (CACHE_SINGLE_IMAGE) @@ -225,7 +225,8 @@ function Graphics_Init( _canvas ) } Graphics_TextureDrawTiled = Graphics_TextureDrawTiled_RELEASE; Graphics_TextureDraw = Graphics_TextureDraw_DEBUG; - } + } + // @endif }else{ InitWebGLFunctions(); } @@ -1225,6 +1226,8 @@ function Graphics_ColouriseImage( _texture, _x, _y, _w, _h, _col ) /// /// // ############################################################################################# +function Graphics_TextureDrawPos(){} +// @if feature("2d") function Graphics_TextureDrawPos(_pTPE, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha) { var pTexture = _pTPE.texture; @@ -1336,6 +1339,7 @@ function drawTexturedTriangle(im, x0, y0, x1, y1, x2, y2, sx0, sy0, sx1, sy1, sx graphics._drawImage(im, 0, 0); Graphics_Restore(); } +// @endif diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index adb9fbf7..a87e01d8 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -1769,6 +1769,7 @@ yyRoom.prototype.DrawLayerTilemapElement = function(_rect,_layer,_el,_xpos,_ypos if(g_webGL) { + // @if feature("gl") for(var y=miny;y0) pVerts.Current -= tilesinthisrun * 6; - + // @endif } else { + // @if feature("2d") //Non Web-GL for(var y=miny;y // ############################################################################################# function InitWebGLFunctions() { - + // VD: a lot of conditionals here, but oh well + InitD3DFunctions(); // @if function("vertex_*") InitFVFFunctions(); @@ -149,32 +150,39 @@ function InitWebGLFunctions() { draw_rectangle = WebGL_draw_rectangle_RELEASE; draw_roundrect_color_ext = WebGL_draw_roundrect_color_EXT_RELEASE; draw_rectangle_color = WebGL_draw_rectangle_color_RELEASE; - draw_roundrect_colour_ext = WebGL_draw_roundrect_color_EXT_RELEASE; + compile_if_used(draw_roundrect_colour_ext = WebGL_draw_roundrect_color_EXT_RELEASE); draw_rectangle_colour = WebGL_draw_rectangle_color_RELEASE; - draw_rectangle_gradient = WebGL_draw_rectangle_gradient_RELEASE; - draw_point = WebGL_draw_point_RELEASE; - draw_getpixel = WebGL_draw_getpixel_RELEASE; - draw_getpixel_ext = WebGL_draw_getpixel_ext_RELEASE; + compile_if_used(draw_point = WebGL_draw_point_RELEASE); + compile_if_used(draw_getpixel = WebGL_draw_getpixel_RELEASE); + compile_if_used(draw_getpixel_ext = WebGL_draw_getpixel_ext_RELEASE); draw_triangle = WebGL_draw_triangle_RELEASE; - draw_triangle_color = WebGL_draw_triangle_color_RELEASE; + + compile_if_used(draw_triangle_color = WebGL_draw_triangle_color_RELEASE); + // @if function("draw_ellipse") || function("draw_ellipse_color") draw_ellipse_color = WebGL_draw_ellipse_color_RELEASE; + // @endif + // @if function("draw_circle") || function("draw_circle_color") draw_circle_color = WebGL_draw_circle_color_RELEASE; - draw_point_color = WebGL_draw_point_color_RELEASE; + // @endif + compile_if_used(draw_point_color = WebGL_draw_point_color_RELEASE); + draw_triangle_colour = WebGL_draw_triangle_color_RELEASE; - draw_ellipse_colour = WebGL_draw_ellipse_color_RELEASE; - draw_circle_colour = WebGL_draw_circle_color_RELEASE; - draw_point_colour = WebGL_draw_point_color_RELEASE; + compile_if_used(draw_ellipse_colour = WebGL_draw_ellipse_color_RELEASE); + compile_if_used(draw_circle_colour = WebGL_draw_circle_color_RELEASE); + compile_if_used(draw_point_colour = WebGL_draw_point_color_RELEASE); + + // line functions are used a lot, don't trim these draw_line = WebGL_draw_line_RELEASE; draw_line_width = WebGL_draw_line_width_RELEASE; draw_line_width_color = WebGL_draw_line_width_color_RELEASE; - draw_line_width_colour = WebGL_draw_line_width_color_RELEASE; - draw_clear_alpha = WebGL_draw_clear_alpha_RELEASE; + compile_if_used(draw_line_width_colour = WebGL_draw_line_width_color_RELEASE); + draw_clear_alpha = WebGL_draw_clear_alpha_RELEASE; // used by yyEffects draw_set_color = WebGL_draw_set_color_RELEASE; draw_set_colour = WebGL_draw_set_color_RELEASE; - draw_set_alpha = WebGL_draw_set_alpha_RELEASE; + draw_set_alpha = WebGL_draw_set_alpha_RELEASE; // used for vkeys draw_set_blend_mode_ext = WEBGL_draw_set_blend_mode_ext_RELEASE; draw_enable_alphablend = WEBGL_draw_enable_alpha_blend_RELEASE; - draw_surface = WebGL_draw_surface_RELEASE; + compile_if_used(draw_surface = WebGL_draw_surface_RELEASE); // @if feature("paths") draw_path = WEBGL_draw_path; // @endif @@ -196,8 +204,8 @@ function InitWebGLFunctions() { background_create_from_surface = WebGL_background_create_from_surface_RELEASE; // Sprites - sprite_add_from_screen = WebGL_sprite_add_from_screen_RELEASE; - sprite_create_from_surface = WebGL_sprite_create_from_surface_RELEASE; + compile_if_used(sprite_add_from_screen = WebGL_sprite_add_from_screen_RELEASE); + compile_if_used(sprite_create_from_surface = WebGL_sprite_create_from_surface_RELEASE); sprite_add_from_surface = WebGL_sprite_add_from_surface_RELEASE; CopyImageToAlpha = WEBGL_CopyImageToAlpha_RELEASE; @@ -3041,31 +3049,6 @@ function WebGL_draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) { pColours[v0] = pColours[v1] = pColours[v2] = pColours[v3] = ((g_GlobalAlpha * 255.0) << 24) | g_GlobalColour; } -// ############################################################################################# -/// Function: -/// Draw a rectangle with a gradient -/// -/// -/// In: Top X coordinate -/// Top Y coordinate -/// Bottom X coordinate -/// Bottom X coordinate -/// Start colour of the rect as a number -/// End colour of the rect as a number -/// Whether or not the gradient should be vertical (or horizontal) -/// Whether or not to draw the rect as an outline -/// -// ############################################################################################# -function WebGL_draw_rectangle_gradient_RELEASE(_x1, _y1, _x2, _y2, _col1, _col2, _vert, _outline) { - - if (_vert) { - WebGL_draw_rectangle_color_RELEASE(_x1, _y1, _x2, _y2, _col1, _col1, _col2, _col2, _outline); - } - else { - WebGL_draw_rectangle_color_RELEASE(_x1, _y1, _x2, _y2, _col1, _col2, _col2, _col1, _outline); - } -} - // ############################################################################################# /// Function: /// Plot a single point From 1babeb903cd221ecd06949994b326bcbc55f2742 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 10:43:16 +0300 Subject: [PATCH 43/84] Trim the underlying sprite functions if draw_sprite_pos is unused --- scripts/yySprite.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/yySprite.js b/scripts/yySprite.js index d7d1e287..7137f2f0 100644 --- a/scripts/yySprite.js +++ b/scripts/yySprite.js @@ -1161,6 +1161,7 @@ yySprite.prototype.GetSkeletonSlotsAtPoint = function(_inst, _x, _y, _list) /// The sprite data or null /// // ############################################################################################# +// @if function("draw_sprite_pos") yySprite.prototype.Sprite_DrawSimplePos = function (_sub_image, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha) { if (this.numb <= 0) return; @@ -1170,6 +1171,7 @@ yySprite.prototype.Sprite_DrawSimplePos = function (_sub_image, _x1, _y1, _x2, _ if (!this.ppTPE) return; Graphics_TextureDrawPos(this.ppTPE[_sub_image], _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha); }; +// @endif From 3adeb1e4a4cdd4ea0df15f3a3c73bbeb4d7daf57 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 14:44:40 +0300 Subject: [PATCH 44/84] Added more conditionals around British spelling versions of functions so that they don't cause their US spelling counterpart to be left in the build. It is very tempting to just remap all functions to one spelling during compile but that will definitely backfire. --- scripts/functions/Function_Background.js | 2 ++ scripts/functions/Function_Font.js | 18 ++++++++++++------ scripts/functions/Function_Graphics.js | 17 ++++++++++++++++- scripts/functions/Function_Maths.js | 4 ++++ scripts/functions/Function_Window.js | 4 ++++ 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/scripts/functions/Function_Background.js b/scripts/functions/Function_Background.js index e1d2d4b8..065cc6d3 100644 --- a/scripts/functions/Function_Background.js +++ b/scripts/functions/Function_Background.js @@ -245,7 +245,9 @@ function background_create_color(_w,_h,_colour) return g_pBackgroundManager.AddBackgroundImage(pNew); } +// @if function("background_create_colour") var background_create_colour = background_create_color; +// @endif // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_Font.js b/scripts/functions/Function_Font.js index 588a73b7..9445968a 100644 --- a/scripts/functions/Function_Font.js +++ b/scripts/functions/Function_Font.js @@ -80,7 +80,6 @@ function draw_text(_x, _y, _text) { /// /// // ############################################################################################# -var draw_text_colour = draw_text_color; function draw_text_color(_x, _y, _text, _c1, _c2, _c3, _c4, _alpha) { if (!g_webGL) WarningFunction("draw_text_color() only uses the 1st colour"); @@ -106,6 +105,9 @@ function draw_text_color(_x, _y, _text, _c1, _c2, _c3, _c4, _alpha) g_GlobalAlpha = oldalpha; draw_set_color(oldcol); } +// @if function("draw_text_colour") +var draw_text_colour = draw_text_color; +// @endif // ############################################################################################# /// Function: @@ -126,7 +128,6 @@ function draw_text_color(_x, _y, _text, _c1, _c2, _c3, _c4, _alpha) /// /// // ############################################################################################# -var draw_text_ext_colour = draw_text_ext_color; function draw_text_ext_color(_x, _y, _text, _sep, _w, _c1, _c2, _c3, _c4, _alpha) { if (!g_webGL) WarningFunction("draw_text_ext_color() only uses the 1st colour"); @@ -151,7 +152,9 @@ function draw_text_ext_color(_x, _y, _text, _sep, _w, _c1, _c2, _c3, _c4, _alpha g_GlobalAlpha = oldalpha; draw_set_color(oldcol); } - +// @if function("draw_text_ext_colour") +var draw_text_ext_colour = draw_text_ext_color; +// @endif @@ -245,7 +248,6 @@ function draw_text_ext_transformed(_x, _y, _text, _sep, _w, _xscale, _yscale, _a /// /// // ############################################################################################# -var draw_text_ext_transformed_colour = draw_text_ext_transformed_color; function draw_text_ext_transformed_color(_x, _y, _text, _sep, _w, _xscale, _yscale, _angle, _c1, _c2, _c3, _c4, _alpha) { if (!g_webGL) WarningFunction("draw_text_ext_transformed_color() only uses the 1st colour"); @@ -262,6 +264,9 @@ function draw_text_ext_transformed_color(_x, _y, _text, _sep, _w, _xscale, _ysca g_GlobalAlpha = oldalpha; draw_set_color(oldcol); } +// @if function("draw_text_ext_transformed_colour") +var draw_text_ext_transformed_colour = draw_text_ext_transformed_color; +// @endif // ############################################################################################# @@ -284,7 +289,6 @@ function draw_text_ext_transformed_color(_x, _y, _text, _sep, _w, _xscale, _ysca /// /// // ############################################################################################# -var draw_text_transformed_colour = draw_text_transformed_color; function draw_text_transformed_color(_x, _y, _text, _xscale, _yscale, _angle, _c1, _c2, _c3, _c4, _alpha) { if (!g_webGL) WarningFunction("draw_text_transformed_color() only uses the 1st colour"); @@ -301,7 +305,9 @@ function draw_text_transformed_color(_x, _y, _text, _xscale, _yscale, _angle, _c g_GlobalAlpha = oldalpha; draw_set_color(oldcol); } - +// @if function("draw_text_transformed_colour") +var draw_text_transformed_colour = draw_text_transformed_color; +// @endif // ############################################################################################# diff --git a/scripts/functions/Function_Graphics.js b/scripts/functions/Function_Graphics.js index e16a13f5..f0d5fa25 100644 --- a/scripts/functions/Function_Graphics.js +++ b/scripts/functions/Function_Graphics.js @@ -122,8 +122,9 @@ function display_set_gui_maximise(_xscale, _yscale, _xoffset, _yoffset) Calc_GUI_Scale(); } } - +// @if function("display_set_gui_maximize") var display_set_gui_maximize = display_set_gui_maximise; +// @endif // ############################################################################################# /// Function: @@ -271,7 +272,9 @@ function make_color_rgb(_red,_green,_blue) { return (yyGetInt32(_red)) | (yyGetInt32(_green) << 8) | (yyGetInt32(_blue) << 16); } +// @if function("make_colour_rgb") var make_colour_rgb = make_color_rgb; +// @endif // ############################################################################################# /// Function: @@ -287,7 +290,9 @@ function color_get_blue(_col) { return (yyGetInt32(_col) >> 16) & 0xff; } +// @if function("colour_get_blue") var colour_get_blue = color_get_blue; +// @endif // ############################################################################################# /// Function: @@ -303,7 +308,9 @@ function color_get_green(_col) { return (yyGetInt32(_col) >> 8) & 0xff; } +// @if function("colour_get_green") var colour_get_green = color_get_green; +// @endif // ############################################################################################# @@ -320,7 +327,9 @@ function color_get_red(_col) { return (yyGetInt32(_col) & 0xff); } +// @if function("colour_get_red") var colour_get_red = color_get_red; +// @endif // ############################################################################################# @@ -384,7 +393,9 @@ function color_get_hue(_col) var hsv = Color_RGBtoHSV(_col); return hsv.h; } +// @if function("colour_get_hue") var colour_get_hue = color_get_hue; +// @endif // ############################################################################################# /// Function: @@ -401,7 +412,9 @@ function color_get_saturation(_col) var hsv = Color_RGBtoHSV(_col); return hsv.s; } +// @if function("colour_get_saturation") var colour_get_saturation = color_get_saturation; +// @endif // ############################################################################################# /// Function: @@ -418,7 +431,9 @@ function color_get_value(_col) var hsv = Color_RGBtoHSV(_col); return hsv.v; } +// @if function("colour_get_value") var colour_get_value = color_get_value; +// @endif // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_Maths.js b/scripts/functions/Function_Maths.js index f6b49fbb..5fc29ea4 100644 --- a/scripts/functions/Function_Maths.js +++ b/scripts/functions/Function_Maths.js @@ -1120,7 +1120,9 @@ function dot_product_normalised(_x1,_y1,_x2,_y2) // return DOT product return (_x1 * _x2 + _y1 * _y2) / (mag1 * mag2); } +// @if function("dot_product_normalized") var dot_product_normalized = dot_product_normalised; +// @endif // ############################################################################################# /// Function: @@ -1154,7 +1156,9 @@ function dot_product_3d_normalised(_x1, _y1, _z1, _x2, _y2, _z2) { // return DOT product return (_x1 * _x2 + _y1 * _y2 + _z1 * _z2) / (mag1 * mag2); } +// @if function("dot_product_3d_normalized") var dot_product_3d_normalized = dot_product_3d_normalised; +// @endif // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_Window.js b/scripts/functions/Function_Window.js index 7990c769..23c899a0 100644 --- a/scripts/functions/Function_Window.js +++ b/scripts/functions/Function_Window.js @@ -385,7 +385,9 @@ function window_set_color(_colour) { g_WindowColour = ConvertGMColour(yyGetInt32(_colour)); } +// @if function("window_set_colour") var window_set_colour = window_set_color; +// @endif @@ -402,7 +404,9 @@ function window_get_color() { return ConvertGMColour( g_WindowColour ); } +// @if function("window_get_colour") var window_get_colour = window_get_color; +// @endif // ############################################################################################# From dbaee2520ccaf47193b854db16cf47c42909c78f Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 14:46:02 +0300 Subject: [PATCH 45/84] Small cleanup for things that shouldn't be there at all --- scripts/functions/Function_Maths.js | 9 ++--- scripts/functions/Function_MotionPlanning.js | 10 ++--- scripts/functions/Function_Movement.js | 2 - scripts/functions/Function_YoYo.js | 39 -------------------- 4 files changed, 9 insertions(+), 51 deletions(-) diff --git a/scripts/functions/Function_Maths.js b/scripts/functions/Function_Maths.js index 5fc29ea4..1894f793 100644 --- a/scripts/functions/Function_Maths.js +++ b/scripts/functions/Function_Maths.js @@ -282,7 +282,6 @@ function point_direction(_x1,_y1, _x2,_y2) } } } -function ComputeDir(_x1,_y1, _x2,_y2){ return point_direction(_x1,_y1, _x2,_y2); } // ############################################################################################# @@ -987,8 +986,8 @@ function radtodeg(_x) { // ############################################################################################# function mean() { - var args = mean.arguments; - var argc = mean.arguments.length; + var args = arguments; + var argc = arguments.length; if (argc == 0) return 0; @@ -1012,8 +1011,8 @@ function mean() // ############################################################################################# function median() { - var args = median.arguments; - var argc = median.arguments.length; + var args = arguments; + var argc = arguments.length; if (argc == 0) return 0; diff --git a/scripts/functions/Function_MotionPlanning.js b/scripts/functions/Function_MotionPlanning.js index 13f3f548..2f09510f 100644 --- a/scripts/functions/Function_MotionPlanning.js +++ b/scripts/functions/Function_MotionPlanning.js @@ -269,7 +269,7 @@ function mp_potential_step_common(_pInst, _x,_y, _stepsize, _objindex, _checkall { if (TestFree(_pInst, _x, _y, _objindex, _checkall)) { - _pInst.direction = ComputeDir(_pInst.x, _pInst.y, _x, _y); + _pInst.direction = point_direction(_pInst.x, _pInst.y, _x, _y); _pInst.SetPosition(_x, _y); } Result = true; @@ -277,7 +277,7 @@ function mp_potential_step_common(_pInst, _x,_y, _stepsize, _objindex, _checkall } // Try directions as much as possible towards the goal - goaldir = ComputeDir(_pInst.x, _pInst.y, _x, _y); + goaldir = point_direction(_pInst.x, _pInst.y, _x, _y); curdir = 0; Result = false; while ( curdir < 180 ) @@ -416,7 +416,7 @@ function Motion_Linear_Step(_inst, _x, _y, _speed, _objind, _checkall) { return Result; } - _inst.direction = ComputeDir(_inst.x, _inst.y, newx, newy); + _inst.direction = point_direction(_inst.x, _inst.y, newx, newy); _inst.SetPosition( newx, newy ); return Result; @@ -599,14 +599,14 @@ function Motion_Potential_Step(_inst, _x, _y, _speed,_objind, _checkall) { if (true == TestFree(_inst, _x, _y, _objind, _checkall)) { - _inst.direction = ComputeDir(_inst.x,_inst.y,_x,_y); + _inst.direction = point_direction(_inst.x,_inst.y,_x,_y); _inst.SetPosition(_x,_y); } return true; } // Try directions as much as possible towards the goal - goaldir = ComputeDir(_inst.x, _inst.y,_x,_y); + goaldir = point_direction(_inst.x, _inst.y,_x,_y); curdir = 0; Result = false; while ( curdir < 180 ) diff --git a/scripts/functions/Function_Movement.js b/scripts/functions/Function_Movement.js index 13b6fba3..21d38134 100644 --- a/scripts/functions/Function_Movement.js +++ b/scripts/functions/Function_Movement.js @@ -454,8 +454,6 @@ function move_bounce_all(_pInst, _adv) Command_Bounce( _pInst, yyGetBool(_adv), true ); } -var move_bounce = move_bounce_solid; - // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_YoYo.js b/scripts/functions/Function_YoYo.js index f7acab83..1b28d43d 100644 --- a/scripts/functions/Function_YoYo.js +++ b/scripts/functions/Function_YoYo.js @@ -44,45 +44,6 @@ var eDS_TypeMap=1, var g_GameMakerIdentifier = aa_1241_kz(); function aa_1241_kz() { return 0x87155211; } -// ############################################################################################# -/// Function: -/// Create a security request object that works out the type of http request to -/// create and allows us to send security checks -/// -/// -/// In: The canvcas handle -/// Out: -/// -/// -// ############################################################################################# -/** @constructor */ -function SecurityCheck() -{ - var xmlHttp = null; - if (window.XMLHttpRequest) { - //for firefox, opera and safari browswers - xmlHttp = new XMLHttpRequest(); - } - if (typeof(XMLHttpRequest) == "undefined") - { - xmlHttp = function () { - try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } - catch (e) {} - try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } - catch (e) {} - try { return new ActiveXObject("Msxml2.XMLHTTP"); } - catch (e) {} - //Microsoft.XMLHTTP points to Msxml2.XMLHTTP.3.0 and is redundant - throw new yyError("This browser does not support XMLHttpRequest."); - }; - } - this.securityRequest = xmlHttp; - this.securityRequestInFlight = false; -} - -// Global security check object and session key -var g_securityCheck = new SecurityCheck(); - function YYPushEventsDispatch() { } From b1461c554a7db7c8e41975e081191887d9891568 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 14:46:46 +0300 Subject: [PATCH 46/84] Backgrounds are no longer used in their original sense so we can skip defining WebGL functions for them --- scripts/yyWebGL.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index 3fcc27c0..b53e0437 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -199,9 +199,9 @@ function InitWebGLFunctions() { surface_copy = WebGL_surface_copy_RELEASE; surface_copy_part = WebGL_surface_copy_part_RELEASE; - // Backgrounds - background_create_from_screen = WebGL_background_create_from_screen_RELEASE; - background_create_from_surface = WebGL_background_create_from_surface_RELEASE; + // Backgrounds (no longer needed..?) + //background_create_from_screen = WebGL_background_create_from_screen_RELEASE; + //background_create_from_surface = WebGL_background_create_from_surface_RELEASE; // Sprites compile_if_used(sprite_add_from_screen = WebGL_sprite_add_from_screen_RELEASE); @@ -457,7 +457,7 @@ function InitWebGLTextureGetFunctions() { return texture; }; - // And again for background textures + /*// And again for background textures var fn_background_get_texture = background_get_texture; background_get_texture = function(_ind) { @@ -467,7 +467,7 @@ function InitWebGLTextureGetFunctions() { WebGL_BindTexture(texture.TPE); } return texture; - }; + };*/ WebGL_StartFrame_RELEASE();// Call this to setup defaults.. } From ff8a13bb1e2c0d936f1c68cb7f7cd4c7c2dcc160 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 14:49:14 +0300 Subject: [PATCH 47/84] Some more conditions to omit 2d functions when only using GL --- scripts/functions/Function_Sprite.js | 3 +-- scripts/functions/Function_Surface.js | 23 ++++++++++++++--------- scripts/yyGraphics.js | 5 ++++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/scripts/functions/Function_Sprite.js b/scripts/functions/Function_Sprite.js index f840c718..acaea3ee 100644 --- a/scripts/functions/Function_Sprite.js +++ b/scripts/functions/Function_Sprite.js @@ -661,8 +661,7 @@ function sprite_save(_ind,_subimg,_fname) /// /// // ############################################################################################# -var sprite_duplicate = sprite_duplicate_RELEASE; -function sprite_duplicate_RELEASE(_ind) +function sprite_duplicate(_ind) { var pSpr = g_pSpriteManager.Get(yyGetInt32(_ind)); if (pSpr == null) return 0; diff --git a/scripts/functions/Function_Surface.js b/scripts/functions/Function_Surface.js index db258de9..ae896e3e 100644 --- a/scripts/functions/Function_Surface.js +++ b/scripts/functions/Function_Surface.js @@ -687,12 +687,9 @@ function GetCanvasPixel(_buffer, _x, _y) /// /// // ############################################################################################# -var surface_getpixel = surface_getpixel_RELEASE; -var surface_getpixel_ext = surface_getpixel_ext_RELEASE; -function surface_getpixel_RELEASE(_id, _x, _y) -{ - return surface_getpixel_ext_RELEASE(_id, _x, _y) &0xffffff; -} +function surface_getpixel(){} +function surface_getpixel_ext(){} +// @if feature("2d") function surface_getpixel_ext_RELEASE(_id, _x, _y) { var pSurf = g_Surfaces.Get(yyGetInt32(_id)); @@ -702,6 +699,9 @@ function surface_getpixel_ext_RELEASE(_id, _x, _y) } return 0x00000000; } +compile_if_used(surface_getpixel = (_id, _x, _y) => surface_getpixel_ext_RELEASE(_id, _x, _y) & 0xffffff); +compile_if_used(surface_getpixel_ext = surface_getpixel_ext_RELEASE); +// @endif @@ -1103,7 +1103,9 @@ function draw_surface_general(_id,_left,_top,_width,_height,_x,_y,_xscale,_yscal /// /// // ############################################################################################# -function surface_copy(_destination,_x,_y,_source) { +function surface_copy(){} +// @if feature("2d") && function("surface_copy") +surface_copy = (_destination,_x,_y,_source) => { var pDest = g_Surfaces.Get(yyGetInt32(_destination)); var pSrc = g_Surfaces.Get(yyGetInt32(_source)); @@ -1117,6 +1119,7 @@ function surface_copy(_destination,_x,_y,_source) { pImg.restore(); } } +// @endif // ############################################################################################# /// Function: @@ -1136,8 +1139,9 @@ function surface_copy(_destination,_x,_y,_source) { /// /// // ############################################################################################# -function surface_copy_part(_destination,_x,_y, _source,_xs,_ys,_ws,_hs) -{ +function surface_copy_part(){} +// @if feature("2d") && function("surface_copy_part") +surface_copy_part = (_destination,_x,_y, _source,_xs,_ys,_ws,_hs) => { var pDest = g_Surfaces.Get(yyGetInt32(_destination)); var pSrc = g_Surfaces.Get(yyGetInt32(_source)); if( pDest!=null && pSrc!=null) @@ -1171,6 +1175,7 @@ function surface_copy_part(_destination,_x,_y, _source,_xs,_ys,_ws,_hs) pImg.restore(); } } +// @endif function SurfaceFormatSupported(_format) { diff --git a/scripts/yyGraphics.js b/scripts/yyGraphics.js index 5402f528..dae4769b 100644 --- a/scripts/yyGraphics.js +++ b/scripts/yyGraphics.js @@ -1566,7 +1566,8 @@ function Graphics_DrawGeneral(_pTPE, _left,_top,_width,_height, _x,_y,_xscale /// true for okay, false for error /// // ############################################################################################# -var CopyImageToAlpha = CopyImageToAlpha_RELEASE; +function CopyImageToAlpha(){} +// @if feature("2d") function CopyImageToAlpha_RELEASE(_pDestTPE, _pSrcTPE) { if ( g_webGL ) @@ -1612,6 +1613,8 @@ function CopyImageToAlpha_RELEASE(_pDestTPE, _pSrcTPE) pDestImg.putImageData(DestDataLock, 0, 0); return true; } +compile_if_used(sprite_set_alpha_from_sprite, CopyImageToAlpha = CopyImageToAlpha_RELEASE); +// @endif From e272de2ba878f802317de82cc66f61d6abd48007 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 14:49:44 +0300 Subject: [PATCH 48/84] And some more conditions based on functions/groups --- scripts/functions/Function_Game.js | 3 +- scripts/functions/Function_Instance.js | 4 ++- scripts/functions/Function_Networking.js | 3 ++ scripts/functions/Function_YoYo.js | 20 ++++++----- scripts/yyBuffer.js | 4 +++ scripts/yyRoom.js | 2 ++ scripts/yyWebGL.js | 42 +++++++++++++----------- 7 files changed, 48 insertions(+), 30 deletions(-) diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index cbe8ced4..e0b07a54 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -1431,7 +1431,7 @@ function bit_rol(num, cnt) return (num << cnt) | (num >>> (32 - cnt)); } - +// @if function("sha1_string_*") || function("ds_map_secure_*") || function("buffer_sha1") //and the sha-1 version from same place function hex_sha1(s) { return rstr2hex(rstr_sha1(str2rstr_utf8(s))); } @@ -1593,6 +1593,7 @@ function sha1_kt(t) return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : (t < 60) ? -1894007588 : -899497514; } +// @endif sha1 // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_Instance.js b/scripts/functions/Function_Instance.js index e66970f8..baca515b 100644 --- a/scripts/functions/Function_Instance.js +++ b/scripts/functions/Function_Instance.js @@ -510,6 +510,7 @@ function instance_copy(_inst, _performevent) /// Perform destroy and create events? /// // ############################################################################################# +// @if function("position_change") || function("instance_change") function instance_change_RELEASE(_inst, _objindex, _perf) { _perf = yyGetBool(_perf); @@ -543,7 +544,8 @@ function instance_change_DEBUG(_inst, _objindex, _perf) } instance_change_RELEASE(_inst, _objindex, yyGetBool(_perf)); } -var instance_change = instance_change_DEBUG; +var instance_change = instance_change_DEBUG; +// @endif // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_Networking.js b/scripts/functions/Function_Networking.js index b9d7812a..ee767405 100644 --- a/scripts/functions/Function_Networking.js +++ b/scripts/functions/Function_Networking.js @@ -14,6 +14,7 @@ // // ********************************************************************************************************************** +// @if function("network_*") var NETWORK_SOCKET_WS = 6; var NETWORK_SOCKET_WSS = 7; @@ -506,3 +507,5 @@ function network_destroy(_socket) { yyWebSocketList_remove(wrap); return 0; } + +// @endif diff --git a/scripts/functions/Function_YoYo.js b/scripts/functions/Function_YoYo.js index 1b28d43d..afecb314 100644 --- a/scripts/functions/Function_YoYo.js +++ b/scripts/functions/Function_YoYo.js @@ -1137,19 +1137,23 @@ function script_execute_ext( _self, _other, _index, _array, _offset, _length ) // ############################################################################################# function gml_release_mode(_enable) { if (yyGetBool(_enable)) { + // @if function("position_change") || function("instance_change") instance_change = instance_change_RELEASE; + // @endif yyInst = yyInst_RELEASE; - ds_grid_get = ds_grid_get_RELEASE; - ds_grid_set = ds_grid_set_RELEASE; - ds_grid_set_pre = ds_grid_set_pre_RELEASE; - ds_grid_set_post = ds_grid_set_post_RELEASE; + compile_if_used(ds_grid_get = ds_grid_get_RELEASE); + compile_if_used(ds_grid_set = ds_grid_set_RELEASE); + compile_if_used(ds_grid_set_pre = ds_grid_set_pre_RELEASE); + compile_if_used(ds_grid_set_post = ds_grid_set_post_RELEASE); } else { + // @if function("position_change") || function("instance_change") instance_change = instance_change_DEBUG; + // @endif yyInst = yyInst_DEBUG; - ds_grid_get = ds_grid_get_DEBUG; - ds_grid_set = ds_grid_set_DEBUG; - ds_grid_set_pre = ds_grid_set_pre_DEBUG; - ds_grid_set_post = ds_grid_set_post_DEBUG; + compile_if_used(ds_grid_get = ds_grid_get_DEBUG); + compile_if_used(ds_grid_set = ds_grid_set_DEBUG); + compile_if_used(ds_grid_set_pre = ds_grid_set_pre_DEBUG); + compile_if_used(ds_grid_set_post = ds_grid_set_post_DEBUG); } } diff --git a/scripts/yyBuffer.js b/scripts/yyBuffer.js index 10de85bf..5eb00ee9 100644 --- a/scripts/yyBuffer.js +++ b/scripts/yyBuffer.js @@ -956,6 +956,7 @@ yyBuffer.prototype.yyb_crc32 = function(_offset, _size) /// Function: /// // ############################################################################################# +// @if function("buffer_md5") yyBuffer.prototype.yyb_md5 = function(_offset, _size) { if (this.m_Size == 0) @@ -990,12 +991,14 @@ yyBuffer.prototype.yyb_md5 = function(_offset, _size) { return DoMD5( new Uint8Array(this.m_pRAWUnderlyingBuffer, _offset, _size),_size, 0 ); } }; +// @endif // ############################################################################################# /// Function: /// // ############################################################################################# +// @if function("buffer_sha1") yyBuffer.prototype.yyb_sha1 = function(_offset, _size) { if (this.m_Size == 0) @@ -1029,6 +1032,7 @@ yyBuffer.prototype.yyb_sha1 = function(_offset, _size) { else return sha1_string_utf8(String.fromCharCode.apply(null, new Uint8Array(this.m_pRAWUnderlyingBuffer, _offset, _size))); }; +// @endif // ############################################################################################# diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index a87e01d8..25effcc7 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -2157,6 +2157,7 @@ yyRoom.prototype.DrawLayerSequenceElement = function (_rect, _layer, _pSequenceE // @endif }; +// @if feature("sequences") yyRoom.prototype.DrawSequence = function (_rect, _layer, _pSequenceEl, _evalTree, _headPosition, _lastHeadPosition, _headDirection, _sequence, _isNested, _sequenceMatrix) { if (_sequence == null) @@ -3149,6 +3150,7 @@ yyRoom.prototype.HandleSequenceText = function (_rect, _layer, _pSequenceEl, _no draw_set_color(oldCol); draw_set_alpha(oldAlpha); }; +// @endif sequences diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index b53e0437..60b72ad7 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -194,10 +194,10 @@ function InitWebGLFunctions() { // Surfaces surface_create = WebGL_surface_create_RELEASE; surface_free = WebGL_surface_free_RELEASE; - surface_getpixel = WebGL_surface_getpixel_RELEASE; - surface_getpixel_ext = WebGL_surface_getpixel_ext_RELEASE; - surface_copy = WebGL_surface_copy_RELEASE; - surface_copy_part = WebGL_surface_copy_part_RELEASE; + compile_if_used(surface_getpixel = WebGL_surface_getpixel_RELEASE); + compile_if_used(surface_getpixel_ext = WebGL_surface_getpixel_ext_RELEASE); + compile_if_used(surface_copy = WebGL_surface_copy_RELEASE); + compile_if_used(surface_copy_part = WebGL_surface_copy_part_RELEASE); // Backgrounds (no longer needed..?) //background_create_from_screen = WebGL_background_create_from_screen_RELEASE; @@ -206,9 +206,9 @@ function InitWebGLFunctions() { // Sprites compile_if_used(sprite_add_from_screen = WebGL_sprite_add_from_screen_RELEASE); compile_if_used(sprite_create_from_surface = WebGL_sprite_create_from_surface_RELEASE); - sprite_add_from_surface = WebGL_sprite_add_from_surface_RELEASE; + compile_if_used(sprite_add_from_surface = WebGL_sprite_add_from_surface_RELEASE); - CopyImageToAlpha = WEBGL_CopyImageToAlpha_RELEASE; + compile_if_used(sprite_set_alpha_from_sprite, CopyImageToAlpha = WEBGL_CopyImageToAlpha_RELEASE); // Shaders fn_texture_get_texel_width = WebGL_texture_get_texel_width_RELEASE; @@ -230,25 +230,27 @@ function InitWebGLFunctions() { fn_shader_get_name = WebGL_shader_get_name_RELEASE; // textures - texture_set_blending = WebGL_texture_set_blending_RELEASE; - texture_set_repeat = WebGL_texture_set_repeat_RELEASE; - texture_set_repeat_ext = WebGL_texture_set_repeat_ext_RELEASE; - texture_set_interpolation = WebGL_texture_set_interpolation_RELEASE; - texture_set_interpolation_ext = WebGL_texture_set_interpolation_ext_RELEASE; - texture_get_repeat = WebGL_texture_get_repeat_RELEASE; - texture_get_width = WebGL_texture_get_width_RELEASE; - texture_get_height = WebGL_texture_get_height_RELEASE; - texture_get_uvs = WebGL_texture_get_uvs_RELEASE; + compile_if_used(texture_set_blending = WebGL_texture_set_blending_RELEASE); + compile_if_used(texture_set_repeat = WebGL_texture_set_repeat_RELEASE); + compile_if_used(texture_set_repeat_ext = WebGL_texture_set_repeat_ext_RELEASE); + compile_if_used(texture_set_interpolation = WebGL_texture_set_interpolation_RELEASE); + compile_if_used(texture_set_interpolation_ext = WebGL_texture_set_interpolation_ext_RELEASE); + compile_if_used(texture_get_repeat = WebGL_texture_get_repeat_RELEASE); + compile_if_used(texture_get_width = WebGL_texture_get_width_RELEASE); + compile_if_used(texture_get_height = WebGL_texture_get_height_RELEASE); + compile_if_used(texture_get_uvs = WebGL_texture_get_uvs_RELEASE); // alpha test - draw_set_alpha_test = WebGL_draw_set_alpha_test_RELEASE; - draw_set_alpha_test_ref_value = WebGL_draw_set_alpha_test_ref_value_RELEASE; - draw_get_alpha_test = WebGL_draw_get_alpha_test_RELEASE; - draw_get_alpha_test_ref_value = WebGL_draw_get_alpha_test_ref_value_RELEASE; + compile_if_used(draw_set_alpha_test = WebGL_draw_set_alpha_test_RELEASE); + compile_if_used(draw_set_alpha_test_ref_value = WebGL_draw_set_alpha_test_ref_value_RELEASE); + compile_if_used(draw_get_alpha_test = WebGL_draw_get_alpha_test_RELEASE); + compile_if_used(draw_get_alpha_test_ref_value = WebGL_draw_get_alpha_test_ref_value_RELEASE); // Buffer surface stuff - buffer_get_surface = WEBGL_buffer_get_surface; + compile_if_used(buffer_get_surface = WEBGL_buffer_get_surface); + // @if function("buffer_set_surface") || function("video_*") buffer_set_surface = WEBGL_buffer_set_surface; + // @endif // PostInitWebGLFunctions(); } From 13a1583820b6886f04c1f55e7bea355a9b670fee Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 22:47:46 +0300 Subject: [PATCH 49/84] Fixed a typo in yyRoom.cloneStorage (EffectProperties vs effectProperties) --- scripts/yyRoom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 25effcc7..c290bdd9 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -312,7 +312,7 @@ yyRoom.prototype.CloneStorage = function (_pStorage) { var effectPropIdx; for (effectPropIdx = 0; effectPropIdx < sourceLayer.effectProperties.length; effectPropIdx++) { - newLayer.EffectProperties[effectPropIdx] = + newLayer.effectProperties[effectPropIdx] = { type: sourceLayer.effectProperties[effectPropIdx].type, name: sourceLayer.effectProperties[effectPropIdx].name, From 41e198c1811fb658f93973add5b1bcd7cf757cc0 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Fri, 11 Aug 2023 22:54:00 +0300 Subject: [PATCH 50/84] fx_-related helpers are now stripped if the feature isn't used --- scripts/LoadGame.js | 4 ++++ scripts/_GameMaker.js | 12 ++++++++++-- scripts/functions/Function_Layers.js | 4 +++- scripts/yyEffects.js | 4 +++- scripts/yyRoom.js | 19 +++++++++++++------ 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index 569bfb5f..ea9f85a2 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -71,7 +71,9 @@ function InitAboyne() g_pTagManager = new TagManager(); g_pASyncManager = new yyASyncManager(); g_pLayerManager = new LayerManager(); + // @if feature("layerEffects") g_pEffectsManager = new yyEffectsManager(); + // @endif g_pCameraManager = new CameraManager(); InitAboyneGlobals(); @@ -889,12 +891,14 @@ function LoadGame(_GameFile) } // Load Effect Defs + // @if feature("layerEffects") if (_GameFile.FiltersAndEffectDefs !== undefined) { for (index = 0; index < _GameFile.FiltersAndEffectDefs.length; index++) { var def = _GameFile.FiltersAndEffectDefs[index]; g_pEffectsManager.AddEffectInfo(def.name, def.json); } } + // @endif //Load Tags if( Tags !== undefined && IDToTagList !== undefined ) { diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 7da46fda..fe56306f 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -1128,8 +1128,10 @@ function StartRoom( _numb, _starting ) New_Room = -1; effect_clear(); - + + // @if feature("layerEffects") g_pEffectsManager.ExecuteEffectEventsForRoom(EFFECT_ROOM_END_FUNC, g_RunRoom); + // @endif g_pInstanceManager.PerformEvent(EVENT_OTHER_ENDROOM, 0); @@ -1269,7 +1271,9 @@ function StartRoom( _numb, _starting ) CreateRoomBackgrounds( g_RunRoom ); // Initialise effects + // @if feature("layerEffects") g_pEffectsManager.Init(); + // @endif // Set up runtime data for this room's layers if(g_pLayerManager!=null) @@ -1418,7 +1422,9 @@ function StartRoom( _numb, _starting ) } g_pInstanceManager.PerformEvent(EVENT_OTHER_STARTROOM,0); + // @if feature("layerEffects") g_pEffectsManager.ExecuteEffectEventsForRoom(EFFECT_ROOM_START_FUNC, g_RunRoom); + // @endif g_RunRoom.m_Initialised = true; @@ -1676,8 +1682,10 @@ function GameMaker_DoAStep() { HandleMouse(); UpdateActiveLists(); if (New_Room != -1) return; - + + // @if feature("layerEffects") g_pEffectsManager.StepEffectsForRoom(g_RunRoom); + // @endif // @if feature("sequences") g_pSequenceManager.UpdateInstancesForRoom(g_RunRoom); // update this at the same time as the step event g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_NORMAL); diff --git a/scripts/functions/Function_Layers.js b/scripts/functions/Function_Layers.js index f0ea88a0..6ad8d733 100644 --- a/scripts/functions/Function_Layers.js +++ b/scripts/functions/Function_Layers.js @@ -1647,8 +1647,9 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers) if( pLayer.hspeed!=undefined ) NewLayer.m_hspeed = pLayer.hspeed; if( pLayer.vspeed!=undefined ) NewLayer.m_vspeed = pLayer.vspeed; if( pLayer.visible!=undefined ) NewLayer.m_visible = pLayer.visible; + + // @if feature("layerEffects") if( pLayer.effectEnabled!=undefined) NewLayer.m_effectEnabled = NewLayer.m_effectToBeEnabled = pLayer.effectEnabled; - if (( pLayer.effectType != undefined) && (pLayer.effectType != "")) { var pEffectInfo = new CLayerEffectInfo(); @@ -1753,6 +1754,7 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers) pEffectInfo.bAffectsSingleLayerOnly = true; NewLayer.m_pInitialEffectInfo = pEffectInfo; } + // @endif if(pLayer.type === YYLayerType_Background) { diff --git a/scripts/yyEffects.js b/scripts/yyEffects.js index 580bfdc8..ecad57e1 100644 --- a/scripts/yyEffects.js +++ b/scripts/yyEffects.js @@ -15,6 +15,7 @@ // // ********************************************************************************************************************** +// @if feature("layerEffects") var EFFECT_CLEANUP_FUNC = "cleanup", EFFECT_STEP_FUNC = "step", EFFECT_LAYER_BEGIN_FUNC = "layer_begin", @@ -1609,4 +1610,5 @@ yyEffectsManager.prototype.CleanupOldTempSurfaces = function() } } } -}; \ No newline at end of file +}; +// @endif diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index c290bdd9..74830fa3 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -307,6 +307,7 @@ yyRoom.prototype.CloneStorage = function (_pStorage) { }; // Copy effect properties + // @if feature("layerEffects") newLayer.effectProperties = new Array( sourceLayer.effectProperties.length ); var effectPropIdx; @@ -319,6 +320,7 @@ yyRoom.prototype.CloneStorage = function (_pStorage) { value: sourceLayer.effectProperties[effectPropIdx].value }; } + // @endif // Type-specific properties switch(sourceLayer.type) @@ -3179,15 +3181,12 @@ yyRoom.prototype.DrawRoomLayers = function(_rect){ else { WebGL_d3d_set_depth_RELEASE(player.depth); - } - - - // GR_Depth = player.depth; - //TODO SetLayerShader - //TODO ExecuteLayerScript + } + // @if feature("layerEffects") if (player.m_effectEnabled) ExecuteEffectFunction(player, EFFECT_LAYER_BEGIN_FUNC, EVENT_DRAW, 0); + // @endif SetLayerShader(player.m_shaderId); ExecuteLayerScript(player.m_id, player.m_beginScript); @@ -3235,8 +3234,10 @@ yyRoom.prototype.DrawRoomLayers = function(_rect){ ExecuteLayerScript(player.m_id, player.m_endScript); ResetLayerShader(player.m_shaderId); + // @if feature("layerEffects") if (player.m_effectEnabled) ExecuteEffectFunction(player, EFFECT_LAYER_END_FUNC, EVENT_DRAW, 0); + // @endif } Current_Event_Type = oldtype; @@ -3343,6 +3344,7 @@ yyRoom.prototype.ClearEffectLayerIDs = function () { function ExecuteEffectFunction(_pLayer, _funcname, _etype, _enumb) { + // @if feature("layerEffects") if (_pLayer === null) return; @@ -3384,6 +3386,7 @@ function ExecuteEffectFunction(_pLayer, _funcname, _etype, _enumb) Current_Event_Type = oldtype; Current_Event_Number = oldnumb; */ + // @endif }; function ExecuteLayerScript(layerid,script) @@ -3450,8 +3453,10 @@ yyRoom.prototype.ExecuteDrawEvent = function (_rect, _event) { Current_Event_Number = EVENT_DRAW_BEGIN; + // @if feature("layerEffects") if (player.m_effectEnabled) ExecuteEffectFunction(player, EFFECT_LAYER_BEGIN_FUNC, EVENT_DRAW_BEGIN, 0); + // @endif SetLayerShader(player.m_shaderId); ExecuteLayerScript(player.m_id, player.m_beginScript); @@ -3483,8 +3488,10 @@ yyRoom.prototype.ExecuteDrawEvent = function (_rect, _event) { ExecuteLayerScript(player.m_id,player.m_endScript); ResetLayerShader(player.m_shaderId); + // @if feature("layerEffects") if (player.m_effectEnabled) ExecuteEffectFunction(player, EFFECT_LAYER_END_FUNC, EVENT_DRAW_BEGIN, 0); + // @endif } } From b781244fa5b2d1c9f8c7097c6657eb6de5559825 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Sat, 12 Aug 2023 00:39:47 +0300 Subject: [PATCH 51/84] *mostly* strip particle-related code if unused --- scripts/LoadGame.js | 4 ++++ scripts/_GameMaker.js | 8 ++++++++ scripts/functions/Function_Game.js | 2 ++ scripts/functions/Function_Layers.js | 5 ++++- scripts/functions/Function_Particles.js | 3 +++ scripts/yyParticle.js | 2 ++ scripts/yyRoom.js | 4 ++++ 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index ea9f85a2..3a043cb4 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -467,6 +467,7 @@ function LoadGame_PreLoadAssets(_GameFile) // @endif // Load the particle textures + // @if feature("particles") && feature("particle_images") if (true == g_pGMFile.Options.UseParticles) { for (var i = 2; i < 16; i++){ g_LoadingTotal++; @@ -478,6 +479,7 @@ function LoadGame_PreLoadAssets(_GameFile) g_Textures[t].URL = "particles/IDR_GIF" + i + ".png"; } } + // @endif // Now load WAV files (not mp3/ogg) @@ -879,6 +881,7 @@ function LoadGame(_GameFile) // @endif // Load Particle System Emitters + // @if feature("particles") if (_GameFile.PSEmitters !== undefined) { ParticleSystem_Emitters_Load(_GameFile); } @@ -889,6 +892,7 @@ function LoadGame(_GameFile) CParticleSystem.CreateFromJSON(_GameFile.ParticleSystems[index]); } } + // @endif // Load Effect Defs // @if feature("layerEffects") diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index fe56306f..c3b6adac 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -1127,7 +1127,9 @@ function StartRoom( _numb, _starting ) // This must be set before performing the room_end event else the event will be blocked New_Room = -1; + // @if feature("particles") && function("effect_") effect_clear(); + // @endif // @if feature("layerEffects") g_pEffectsManager.ExecuteEffectEventsForRoom(EFFECT_ROOM_END_FUNC, g_RunRoom); @@ -1135,7 +1137,9 @@ function StartRoom( _numb, _starting ) g_pInstanceManager.PerformEvent(EVENT_OTHER_ENDROOM, 0); + // @if feature("particles") ParticleSystem_RemoveAllFromLayers(); + // @endif // @if function("virtual_key_*") DeleteAllVirtualKeys(); @@ -1279,7 +1283,9 @@ function StartRoom( _numb, _starting ) if(g_pLayerManager!=null) g_pLayerManager.BuildRoomLayerRuntimeData(g_RunRoom); + // @if feature("particles") ParticleSystem_AddAllToLayers(); + // @endif // If this room is NOT persistent then we need to recreate all instances EXCEPT those that already exist in the persistent list // Any instance created in here will perform the create event... including "new" PERSISTENT instances @@ -1720,7 +1726,9 @@ function GameMaker_DoAStep() { if (New_Room != -1) return; // Handle the particle systems + // @if feature("particles") ParticleSystem_UpdateAll(); + // @endif // Bookkeeping && drawing diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index e0b07a54..701e3640 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -1677,7 +1677,9 @@ function ResourceGetTypeIndex(_name ) // @if feature("animcurves") if ((ret = Resource_Find(_name, g_pGMFile.AnimCurves)) >= 0) { typeId.type=AT_AnimCurve; typeId.id = ret; return typeId; } // @endif + // @if feature("particles") if ((ret = CParticleSystem.Find(_name)) >= 0) { typeId.type=AT_ParticleSystem; typeId.id = ret; return typeId; } + // @endif return typeId; } diff --git a/scripts/functions/Function_Layers.js b/scripts/functions/Function_Layers.js index 6ad8d733..662b5d55 100644 --- a/scripts/functions/Function_Layers.js +++ b/scripts/functions/Function_Layers.js @@ -628,11 +628,12 @@ LayerManager.prototype.BuildTilemapElementRuntimeData = function( _room ,_layer, LayerManager.prototype.BuildParticleElementRuntimeData = function( _room ,_layer,_element) { + // @if feature("particles") if (_element.m_ps != -1 && _element.m_systemID == -1) { CParticleSystem.Get(_element.m_ps).MakeInstance(_layer.m_id, false, _element); } - + // @endif _element.m_bRuntimeDataInitialised=true; }; @@ -1928,6 +1929,7 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers) } // Particles + // @if feature("particles") var numparticles = 0; if (pLayer.pcount != undefined) numparticles = pLayer.pcount; @@ -1951,6 +1953,7 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers) this.AddNewElement(_room, NewLayer, NewParticle, false); } } + // @endif } else if(pLayer.type === YYLayerType_Tile) { diff --git a/scripts/functions/Function_Particles.js b/scripts/functions/Function_Particles.js index d09a2b99..1ebcb4ba 100644 --- a/scripts/functions/Function_Particles.js +++ b/scripts/functions/Function_Particles.js @@ -123,6 +123,7 @@ function particle_get_info(_ind) return pPSI; } +// @if feature("particles") // ############################################################################################# /// Function: /// Creates a new particle system. It returns the index of the system. @@ -1046,6 +1047,8 @@ var part_emitter_interval = ParticleSystem_Emitter_Interval; // ############################################################################################# var part_emitter_relative = ParticleSystem_Emitter_Relative; +// @endif particles + // ############################################################################################# /// Function: /// Creates an effect of the given kind (see above) at the indicated position. diff --git a/scripts/yyParticle.js b/scripts/yyParticle.js index 8ce5b92e..a7c9279e 100644 --- a/scripts/yyParticle.js +++ b/scripts/yyParticle.js @@ -65,6 +65,7 @@ var persistentsystemlayernames = []; /// like. We will discuss the settings below. /// // ############################################################################################# +// @if feature("particles") /**@constructor*/ function yyParticleType() { @@ -432,6 +433,7 @@ CParticleSystem.prototype.MakeInstance = function (_layerID, _persistent, _pPart return ps; }; +// @endif particles // ############################################################################################# /// Function: diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 74830fa3..4a7f9676 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -2014,6 +2014,7 @@ yyRoom.prototype.DrawLayerTilemapElement = function(_rect,_layer,_el,_xpos,_ypos yyRoom.prototype.DrawLayerParticleSystem = function(_rect,_layer,_el) { + // @if feature("particles") var ps = _el.m_systemID; if (!ParticleSystem_Exists(ps)) return; @@ -2044,6 +2045,7 @@ yyRoom.prototype.DrawLayerParticleSystem = function(_rect,_layer,_el) ParticleSystem_SetMatrix(ps, matWorldNew); ParticleSystem_Draw(ps, _el.m_imageBlend, _el.m_imageAlpha); WebGL_SetMatrix(MATRIX_WORLD, matWorldOld); + // @endif }; yyRoom.prototype.DrawLayerTileElement = function (_rect, _layer, _el) { @@ -4149,6 +4151,7 @@ yyRoom.prototype.ProcessNewInstanceList = function () { */ yyRoom.prototype.ProcessParticleDepthChange = function () { + // @if feature("particles") // Particle systems changing depth if (g_isZeus) { var len = g_ParticleChanges.length; @@ -4170,6 +4173,7 @@ yyRoom.prototype.ProcessParticleDepthChange = function () { } } if( g_ParticleChanges.length!=0 ) g_ParticleChanges = []; // wipe array + // @endif }; From 6ab6559a292ce343b049b6624ce601d85ad685f0 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Sat, 12 Aug 2023 00:57:03 +0300 Subject: [PATCH 52/84] Still unhappy with how much sequence code is included just for sprites --- scripts/functions/Function_Layers.js | 8 ++++++++ scripts/yySequence.js | 22 ++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/scripts/functions/Function_Layers.js b/scripts/functions/Function_Layers.js index 662b5d55..a298c510 100644 --- a/scripts/functions/Function_Layers.js +++ b/scripts/functions/Function_Layers.js @@ -644,6 +644,7 @@ LayerManager.prototype.BuildTileElementRuntimeData = function( _room ,_layer,_el LayerManager.prototype.BuildSequenceElementRuntimeData = function (_room, _layer, _element) { + // @if feature("sequences") var sequenceInstance = g_pSequenceManager.GetNewInstance(); sequenceInstance.m_sequenceIndex = _element.m_sequenceIndex; @@ -659,6 +660,7 @@ LayerManager.prototype.BuildSequenceElementRuntimeData = function (_room, _layer g_pSequenceManager.HandleInstanceEvent(sequenceInstance, EVENT_CREATE); _element.m_bRuntimeDataInitialised = true; + // @endif }; LayerManager.prototype.BuildElementRuntimeData = function( _room ,_layer,_element) @@ -685,7 +687,9 @@ LayerManager.prototype.BuildElementRuntimeData = function( _room ,_layer,_elemen case eLayerElementType_Tilemap: this.BuildTilemapElementRuntimeData(_room, _layer, _element); break; case eLayerElementType_ParticleSystem: this.BuildParticleElementRuntimeData(_room, _layer, _element); break; case eLayerElementType_Tile: this.BuildTileElementRuntimeData(_room, _layer, _element); break; + // @if feature("sequences") case eLayerElementType_Sequence: this.BuildSequenceElementRuntimeData(_room, _layer, _element); break; + // @endif } }; @@ -872,10 +876,12 @@ LayerManager.prototype.CleanElementRuntimeData = function(_element) { this.CleanTileElementRuntimeData(_element); } break; + // @if feature("sequences") case eLayerElementType_Sequence: { this.CleanSequenceElementRuntimeData(_element); } break; + // @endif } _element.m_bRuntimeDataInitialised = false; @@ -1902,6 +1908,7 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers) } // Sequences + // @if feature("sequences") var numsequences = 0; if (pLayer.ecount != undefined) numsequences = pLayer.ecount; if (numsequences > 0) { @@ -1927,6 +1934,7 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers) this.AddNewElement(_room, NewLayer, NewSequence, false); } } + // @endif // Particles // @if feature("particles") diff --git a/scripts/yySequence.js b/scripts/yySequence.js index 9471e910..d8eaba47 100644 --- a/scripts/yySequence.js +++ b/scripts/yySequence.js @@ -279,12 +279,13 @@ function SequenceBaseTrack_Load(_pStorage) { var newTrack; switch (modelName) { + case "GMSpriteFramesTrack": newTrack = new yySequenceSpriteFramesTrack(_pStorage); break; + // @if feature("sequences") case "GMRealTrack": newTrack = new yySequenceRealTrack(_pStorage); break; case "GMGraphicTrack": newTrack = new yySequenceGraphicTrack(_pStorage); break; case "GMInstanceTrack": newTrack = new yySequenceInstanceTrack(_pStorage); break; case "GMParticleTrack": newTrack = new yySequenceParticleTrack(_pStorage); break; case "GMColourTrack": newTrack = new yySequenceColourTrack(_pStorage); break; - case "GMSpriteFramesTrack": newTrack = new yySequenceSpriteFramesTrack(_pStorage); break; case "GMSequenceTrack": newTrack = new yySequenceSequenceTrack(_pStorage); break; case "GMAudioTrack": newTrack = new yySequenceAudioTrack(_pStorage); break; case "GMTextTrack": newTrack = new yySequenceTextTrack(_pStorage); break; @@ -294,6 +295,7 @@ function SequenceBaseTrack_Load(_pStorage) { case "GMClipMask_Subject": newTrack = new yySequenceClipMask_SubjectTrack(_pStorage); break; case "GMStringTrack": newTrack = new yySequenceStringTrack(_pStorage); break; case "GMBoolTrack": newTrack = new yySequenceBoolTrack(_pStorage); break; + // @endif } newTrack.m_keyframeStore = new yyKeyframeStore(newTrack.m_type, _pStorage.keyframeStore); @@ -1300,6 +1302,7 @@ function yySequenceBaseTrack(_pStorage) { } } + // @if feature("sequences") Object.defineProperties(this, { gmlname: { enumerable: true, @@ -1386,6 +1389,7 @@ function yySequenceBaseTrack(_pStorage) { } } }); + // @endif // ############################################################################################# /// Function: @@ -1420,6 +1424,7 @@ function yySequenceBaseTrack(_pStorage) { /// being pointed to along the track. /// // ############################################################################################# + // @if feature("sequences") this.EvaluateTrack = function (_head, _length, _result, _creationmask) { @@ -1625,7 +1630,7 @@ function yySequenceBaseTrack(_pStorage) { tempcreationvalue &= _creationmask; _result.hascreationvalue = tempcreationvalue; }; - + this.AssignBuiltinTrackName = function() { if (this.pName == null) { this.builtinName = eT_UserDefined; @@ -1657,9 +1662,11 @@ function yySequenceBaseTrack(_pStorage) { else if (this.pName == "paragraph_spacing") this.builtinName = eT_ParagraphSpacing; // alias for paragraphSpacing else this.builtinName = eT_UserDefined; }; + // @endif } + // ############################################################################################# /// Function: /// Constrctor for the abstract TrackKeyBase object @@ -2379,6 +2386,10 @@ function yyKeyframe(_type, _pStorage) { switch(_type) { + case eSTT_SpriteFrames: + newKeyframe = new yySpriteFramesTrackKey(data); + break; + // @if feature("sequences") case eSTT_Graphic: newKeyframe = new yyGraphicTrackKey(data); break; @@ -2406,12 +2417,10 @@ function yyKeyframe(_type, _pStorage) { case eSTT_Sequence: newKeyframe = new yySequenceTrackKey(data); break; - case eSTT_SpriteFrames: - newKeyframe = new yySpriteFramesTrackKey(data); - break; case eSTT_Particle: newKeyframe = new yyParticleTrackKey(data); break; + // @endif } if(newKeyframe != null) @@ -2428,7 +2437,7 @@ function yyKeyframe(_type, _pStorage) { } this.SignalChange(); - + // @if feature("sequences") Object.defineProperties(this, { gmlframe: { enumerable: true, @@ -2482,6 +2491,7 @@ function yyKeyframe(_type, _pStorage) { } } }); + // @endif } // ############################################################################################# From 937d5a8b5d2c7418b342c39fe510dead170cfcdb Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Sat, 12 Aug 2023 15:41:01 +0300 Subject: [PATCH 53/84] More tweaks for British spelling aliases and conditions for functions that are used in multiple spots --- scripts/Globals.js | 2 +- scripts/functions/Function_Graphics.js | 11 ++++++++--- scripts/functions/Function_Room.js | 2 ++ scripts/yyWebGL.js | 8 +++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index bd0b1f9c..d1f6c027 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1278,7 +1278,7 @@ function InitAboyneGlobals() { if(g_isZeus) { - draw_set_colour(g_pGMFile.Options.DrawColour); + draw_set_color(g_pGMFile.Options.DrawColour); } else { diff --git a/scripts/functions/Function_Graphics.js b/scripts/functions/Function_Graphics.js index f0d5fa25..416072ff 100644 --- a/scripts/functions/Function_Graphics.js +++ b/scripts/functions/Function_Graphics.js @@ -606,8 +606,9 @@ function draw_set_color( _colour ) g_GlobalColour_HTML_RGB = GetHTMLRGB(g_GlobalColour); g_GlobalColour_HTML_RGBA = GetHTMLRGBA(g_GlobalColour,g_GlobalAlpha); } - +// @if function("draw_set_colour") var draw_set_colour = draw_set_color; +// @endif function draw_set_lighting(_enable) { @@ -696,7 +697,9 @@ function draw_roundrect_ext(_x1, _y1, _x2, _y2, _radx, _rady, _outline) { function draw_roundrect_color(_x1, _y1, _x2, _y2, _col1, _col2, _outline) { draw_roundrect_color_ext(_x1, _y1, _x2, _y2, 10, 10, _col1, _col2, _outline); } +// @if function("draw_roundrect_colour") var draw_roundrect_colour = draw_roundrect_color; +// @endif // ############################################################################################# /// Function: @@ -888,7 +891,7 @@ function draw_rectangle_color_RELEASE( _x1,_y1, _x2,_y2, _col1, _col2,_col3,_ graphics._fillRect(_x1 + 0.5, _y1 + 0.5, (_x2 - _x1), (_y2 - _y1)); } } -draw_rectangle_color = draw_rectangle_color_RELEASE; +draw_rectangle_color = draw_rectangle_color_RELEASE; // NB! used to clear screen compile_if_used(draw_rectangle_colour = draw_rectangle_color_RELEASE); // @endif @@ -1088,7 +1091,9 @@ function draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) { } } -compile_if_used(draw_triangle = draw_triangle_RELEASE); +// @if function("draw_triangle") || function("draw_arrow") || function("physics_world_draw_debug") +draw_triangle = draw_triangle_RELEASE; +// @endif // @endif // ############################################################################################# diff --git a/scripts/functions/Function_Room.js b/scripts/functions/Function_Room.js index 20358755..f134839f 100644 --- a/scripts/functions/Function_Room.js +++ b/scripts/functions/Function_Room.js @@ -139,7 +139,9 @@ function room_set_background_color(_ind,_colour,_show) pRoom.m_pStorage.showColour = yyGetBool(_show); } +// @if function("room_set_background_colour") var room_set_background_colour = room_set_background_color; +// @endif diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index 60b72ad7..ed51f9d7 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -149,13 +149,15 @@ function InitWebGLFunctions() { Graphics_DrawPart = WebGL_DrawPart_RELEASE; draw_rectangle = WebGL_draw_rectangle_RELEASE; draw_roundrect_color_ext = WebGL_draw_roundrect_color_EXT_RELEASE; - draw_rectangle_color = WebGL_draw_rectangle_color_RELEASE; + draw_rectangle_color = WebGL_draw_rectangle_color_RELEASE; // NB! used to clear screen compile_if_used(draw_roundrect_colour_ext = WebGL_draw_roundrect_color_EXT_RELEASE); - draw_rectangle_colour = WebGL_draw_rectangle_color_RELEASE; + compile_if_used(draw_rectangle_colour = WebGL_draw_rectangle_color_RELEASE); compile_if_used(draw_point = WebGL_draw_point_RELEASE); compile_if_used(draw_getpixel = WebGL_draw_getpixel_RELEASE); compile_if_used(draw_getpixel_ext = WebGL_draw_getpixel_ext_RELEASE); + // @if function("draw_triangle") || function("draw_arrow") || function("physics_world_draw_debug") draw_triangle = WebGL_draw_triangle_RELEASE; + // @endif compile_if_used(draw_triangle_color = WebGL_draw_triangle_color_RELEASE); // @if function("draw_ellipse") || function("draw_ellipse_color") @@ -178,7 +180,7 @@ function InitWebGLFunctions() { compile_if_used(draw_line_width_colour = WebGL_draw_line_width_color_RELEASE); draw_clear_alpha = WebGL_draw_clear_alpha_RELEASE; // used by yyEffects draw_set_color = WebGL_draw_set_color_RELEASE; - draw_set_colour = WebGL_draw_set_color_RELEASE; + compile_if_used(draw_set_colour = WebGL_draw_set_color_RELEASE); draw_set_alpha = WebGL_draw_set_alpha_RELEASE; // used for vkeys draw_set_blend_mode_ext = WEBGL_draw_set_blend_mode_ext_RELEASE; draw_enable_alphablend = WEBGL_draw_enable_alpha_blend_RELEASE; From 952da5526012deda5812157ef1e37490ba41e064 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Sat, 12 Aug 2023 14:26:47 +0300 Subject: [PATCH 54/84] Tweaks for things that shouldn't be there / don't have to be done like that: - There were duplicate definitions for DiffDir/TryDir - A Reference to GM8-era object_name - Optional chaining can replace the if-chain in CheckJSON_Game - buffer_set_surface can peek bytes directly - shader_set_uniform_f_buffer can have its own peek_f32 function instead of going the long way --- scripts/functions/Function_MotionPlanning.js | 64 -------------------- scripts/functions/Function_Object.js | 1 - scripts/yyBuffer.js | 3 +- scripts/yyIOManager.js | 22 ++----- 4 files changed, 7 insertions(+), 83 deletions(-) diff --git a/scripts/functions/Function_MotionPlanning.js b/scripts/functions/Function_MotionPlanning.js index 2f09510f..c81edc52 100644 --- a/scripts/functions/Function_MotionPlanning.js +++ b/scripts/functions/Function_MotionPlanning.js @@ -20,32 +20,6 @@ var MPPot_Maxrot = 30, MPPot_Ahead = 3, MPPot_OnSpot = true; -// ############################################################################################# -/// Function: -/// Computes the difference between the directions (positive <= 180) -/// -/// -/// In: -/// -/// Out: -/// -/// -// ############################################################################################# -function DiffDir( _dir1 , _dir2) -{ - var Result = 0.0; - - while ( _dir1 <= 0.0 ) { _dir1 = _dir1 + 360; } - while ( _dir1 >= 360.0 ) { _dir1 = _dir1 - 360; } - while ( _dir2 < 0.0 ) { _dir2 = _dir2 + 360; } - while ( _dir2 >= 360. ) { _dir2 = _dir2 - 360; } - Result = _dir2 - _dir1; - if ( Result < 0 ) { Result = -Result; } - if ( Result > 180 ) { Result = 360-Result; } - - return Result; -} - // ############################################################################################# /// Function: @@ -191,44 +165,6 @@ function mp_linear_step_object( _pInst, _x,_y,_stepsize,_obj) return mp_linear_step_common( _pInst, _x,_y,_stepsize, _obj, true); } - -// ############################################################################################# -/// Function: -/// Take a step towards the indicated position with the given speed -/// avoiding obstacles using some potential field approach -/// returns whether the goal was reached -/// -// ############################################################################################# -function TryDir(_dir, _pInst, _speed, _objind, _checkall) -{ - var Result = false; - - var xnew = 0.0; - var ynew = 0.0; - - // see whether angle is acceptable - if (DiffDir(_dir, _pInst.direction) > MPPot_Maxrot) { - return Result; - } - // check position a bit ahead - xnew = _pInst.x + _speed * MPPot_Ahead * cos( Pi * _dir / 180 ); - ynew = _pInst.y - _speed * MPPot_Ahead * sin( Pi * _dir / 180 ); - if (true != TestFree(_pInst, xnew, ynew, _objind, _checkall)) { - return Result; - } - //check next position - xnew = _pInst.x + _speed * cos(Pi * _dir / 180); - ynew = _pInst.y - _speed * sin(Pi * _dir / 180); - if (true != TestFree(_pInst, xnew, ynew, _objind, _checkall)) { - return Result; - } - // OK, so set the position - _pInst.direction = _dir; - _pInst.SetPosition(xnew, ynew); - Result = true; - return Result; -} - // ############################################################################################# /// Function: /// Common functionality for mp_potential_step* calls diff --git a/scripts/functions/Function_Object.js b/scripts/functions/Function_Object.js index 2fee4a84..f2fc0cab 100644 --- a/scripts/functions/Function_Object.js +++ b/scripts/functions/Function_Object.js @@ -51,7 +51,6 @@ function object_get_name(_ind) if( !pObj ) return ""; return pObj.Name; } -var object_name = object_get_name; // ############################################################################################# /// Function: diff --git a/scripts/yyBuffer.js b/scripts/yyBuffer.js index 5eb00ee9..a3ad26a0 100644 --- a/scripts/yyBuffer.js +++ b/scripts/yyBuffer.js @@ -2665,11 +2665,12 @@ function buffer_set_surface(_buffer, _surface, _offset) // Make new image data with space for the data var imgData = pImg.createImageData(pSurf.m_Width, pSurf.m_Height); var data = imgData.data; + var dataView = pBuff.m_DataView; // Copy in data var len = pSurf.m_Width * pSurf.m_Height * 4; for (var i = 0; i < len; i++) { - data[i] = pBuff.yyb_peek(eBuffer_U8, i+_offset); + data[i] = dataView.getUint8(i+_offset); } // SET the image data diff --git a/scripts/yyIOManager.js b/scripts/yyIOManager.js index c460ecaf..f3c685fe 100644 --- a/scripts/yyIOManager.js +++ b/scripts/yyIOManager.js @@ -345,23 +345,11 @@ function hideshow(which) function CheckJSON_Game(_ifr, _can) { try { - if (_ifr) - { - if (_ifr.JSON_game) - { - if (_ifr.JSON_game.Options) - { - if (_ifr.JSON_game.Options.gameGuid) - { - if (_ifr.JSON_game.Options.gameGuid == JSON_game.Options.gameGuid) - { - _ifr.focus(); - _can.focus(); - return true; - } - } - } - } + let _guid = _ifr?.JSON_game?.Options?.gameGuid; + if (_guid && _guid == JSON_game.Options.gameGuid) { + _ifr.focus(); + _can.focus(); + return true; } } catch (err) { From 714e7bb0731722b60ae34fd0b9916b14b5718cf4 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Sat, 12 Aug 2023 15:29:34 +0300 Subject: [PATCH 55/84] Strip audio effects if unused --- scripts/sound/AudioEffect.js | 2 ++ scripts/sound/effects/Bitcrusher.js | 2 ++ scripts/sound/effects/Compressor.js | 4 +++- scripts/sound/effects/Delay.js | 2 ++ scripts/sound/effects/EQ.js | 2 ++ scripts/sound/effects/Gain.js | 2 ++ scripts/sound/effects/HPF2.js | 2 ++ scripts/sound/effects/HiShelf.js | 2 ++ scripts/sound/effects/LPF2.js | 2 ++ scripts/sound/effects/LoShelf.js | 2 ++ scripts/sound/effects/PeakEQ.js | 2 ++ scripts/sound/effects/Reverb1.js | 2 ++ scripts/sound/effects/Tremolo.js | 2 ++ 13 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/sound/AudioEffect.js b/scripts/sound/AudioEffect.js index f12ababc..943fe602 100644 --- a/scripts/sound/AudioEffect.js +++ b/scripts/sound/AudioEffect.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function AudioEffect() {} AudioEffect.PARAM_TIME_CONSTANT = 0.005; // 5ms @@ -135,3 +136,4 @@ AudioEffectStruct.prototype.removeNode = function(_node) { this.nodes.splice(idx, 1); } }; +// @endif \ No newline at end of file diff --git a/scripts/sound/effects/Bitcrusher.js b/scripts/sound/effects/Bitcrusher.js index 9815ee11..cf1f825f 100644 --- a/scripts/sound/effects/Bitcrusher.js +++ b/scripts/sound/effects/Bitcrusher.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function BitcrusherEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.Bitcrusher); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -72,3 +73,4 @@ BitcrusherEffectStruct.paramDescriptors = () => ({ resolution: { name: "resolution", integer: true, defaultValue: 8, minValue: 2, maxValue: 16 }, mix: { name: "mix", integer: false, defaultValue: 0.8, minValue: 0.0, maxValue: 1.0 } }); +// @endif diff --git a/scripts/sound/effects/Compressor.js b/scripts/sound/effects/Compressor.js index fa3772b5..5cdf5872 100644 --- a/scripts/sound/effects/Compressor.js +++ b/scripts/sound/effects/Compressor.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function CompressorEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.Compressor); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -100,4 +101,5 @@ CompressorEffectStruct.paramDescriptors = () => ({ attack: { name: "attack", integer: false, defaultValue: 0.05, minValue: 1e-3, maxValue: 1e-1}, release: { name: "release", integer: false, defaultValue: 0.25, minValue: 1e-2, maxValue: 1 }, outgain: { name: "outgain", integer: false, defaultValue: 1, minValue: 1e-6, maxValue: Number.MAX_VALUE } -}); \ No newline at end of file +}); +// @endif diff --git a/scripts/sound/effects/Delay.js b/scripts/sound/effects/Delay.js index 864f5c5a..a38aa50d 100644 --- a/scripts/sound/effects/Delay.js +++ b/scripts/sound/effects/Delay.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function DelayEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.Delay); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -57,3 +58,4 @@ DelayEffectStruct.paramDescriptors = () => ({ feedback: { name: "feedback", integer: false, defaultValue: 0.5, minValue: 0.0, maxValue: 1.0 }, mix: { name: "mix", integer: false, defaultValue: 0.35, minValue: 0.0, maxValue: 1.0 } }); +// @endif diff --git a/scripts/sound/effects/EQ.js b/scripts/sound/effects/EQ.js index 366c21ce..19a052de 100644 --- a/scripts/sound/effects/EQ.js +++ b/scripts/sound/effects/EQ.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function EQEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.EQ); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -178,3 +179,4 @@ function EQEffectStruct(_params) { EQEffectStruct.paramDescriptors = () => ({ bypass: AudioEffectStruct.paramDescriptors().bypass }); +// @endif diff --git a/scripts/sound/effects/Gain.js b/scripts/sound/effects/Gain.js index 1c62a8fe..d717f9ab 100644 --- a/scripts/sound/effects/Gain.js +++ b/scripts/sound/effects/Gain.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function GainEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.Gain); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -27,3 +28,4 @@ GainEffectStruct.paramDescriptors = () => ({ bypass: AudioEffectStruct.paramDescriptors().bypass, gain: { name: "gain", integer: false, defaultValue: 0.5, minValue: 0.0, maxValue: Number.MAX_VALUE } }); +// @endif diff --git a/scripts/sound/effects/HPF2.js b/scripts/sound/effects/HPF2.js index 3f23423f..1b27f20c 100644 --- a/scripts/sound/effects/HPF2.js +++ b/scripts/sound/effects/HPF2.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function HPF2EffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.HPF2); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -48,3 +49,4 @@ HPF2EffectStruct.paramDescriptors = () => ({ return this.freq; } }); +// @endif diff --git a/scripts/sound/effects/HiShelf.js b/scripts/sound/effects/HiShelf.js index 892d6271..50d23837 100644 --- a/scripts/sound/effects/HiShelf.js +++ b/scripts/sound/effects/HiShelf.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function HiShelfEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.HiShelf); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -63,3 +64,4 @@ HiShelfEffectStruct.paramDescriptors = () => ({ return this.__freq; } }); +// @endif diff --git a/scripts/sound/effects/LPF2.js b/scripts/sound/effects/LPF2.js index 9a31d277..01bbe940 100644 --- a/scripts/sound/effects/LPF2.js +++ b/scripts/sound/effects/LPF2.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function LPF2EffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.LPF2); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -48,3 +49,4 @@ LPF2EffectStruct.paramDescriptors = () => ({ return this.freq; } }); +// @endif diff --git a/scripts/sound/effects/LoShelf.js b/scripts/sound/effects/LoShelf.js index 152f530f..3e5cee25 100644 --- a/scripts/sound/effects/LoShelf.js +++ b/scripts/sound/effects/LoShelf.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function LoShelfEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.LoShelf); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -63,3 +64,4 @@ LoShelfEffectStruct.paramDescriptors = () => ({ return this.__freq; } }); +// @endif diff --git a/scripts/sound/effects/PeakEQ.js b/scripts/sound/effects/PeakEQ.js index 2064474a..5a2a3a59 100644 --- a/scripts/sound/effects/PeakEQ.js +++ b/scripts/sound/effects/PeakEQ.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function PeakEQEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.PeakEQ); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -63,3 +64,4 @@ PeakEQEffectStruct.paramDescriptors = () => ({ return this.__freq; } }); +// @endif diff --git a/scripts/sound/effects/Reverb1.js b/scripts/sound/effects/Reverb1.js index 19bd1850..a7733d85 100644 --- a/scripts/sound/effects/Reverb1.js +++ b/scripts/sound/effects/Reverb1.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function Reverb1EffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.Reverb1); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -57,3 +58,4 @@ Reverb1EffectStruct.paramDescriptors = () => ({ damp: { name: "damp", integer: false, defaultValue: 0.1, minValue: 0.0, maxValue: 1.0 }, mix: { name: "mix", integer: false, defaultValue: 0.35, minValue: 0.0, maxValue: 1.0 } }); +// @endif diff --git a/scripts/sound/effects/Tremolo.js b/scripts/sound/effects/Tremolo.js index 76f82c9a..2106c004 100644 --- a/scripts/sound/effects/Tremolo.js +++ b/scripts/sound/effects/Tremolo.js @@ -1,3 +1,4 @@ +// @if feature("audio_effects") function TremoloEffectStruct(_params) { AudioEffectStruct.call(this, AudioEffect.Type.Tremolo); Object.setPrototypeOf(this, AudioEffectStruct.prototype); @@ -72,3 +73,4 @@ TremoloEffectStruct.paramDescriptors = () => ({ offset: { name: "offset", integer: false, defaultValue: 0.0, minValue: 0.0, maxValue: 1.0 }, shape: { name: "shape", integer: true, defaultValue: 0, minValue: 0, maxValue: 4 } }); +// @endif From ca79a990b6c782a7e3ed7822988c5bc258ca7eae Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Sat, 12 Aug 2023 15:34:35 +0300 Subject: [PATCH 56/84] Strip contents of some of the yyFont methods depending on whether 2d/GL/SDF are used. --- scripts/yyFont.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/yyFont.js b/scripts/yyFont.js index cd4003e1..9d8664c3 100644 --- a/scripts/yyFont.js +++ b/scripts/yyFont.js @@ -477,6 +477,7 @@ function getKerningInfo( ch, pGlyph) // ############################################################################################# yyFont.prototype.Draw_String_GL_Full = function (_x, _y, _pStr, _xscale, _yscale, _angle, _col1, _col2,_col3,_col4, _charSpacing, _wordSpacing) //, _alpha) { { + // @if feature("gl") var TP = this.TPEntry; //g_Textures[this.TPEntry.tp]; if (!TP.texture.complete) return; // if texture hasn't loaded, return... var len = _pStr.length; @@ -531,6 +532,7 @@ yyFont.prototype.Draw_String_GL_Full = function (_x, _y, _pStr, _xscale, _yscale } } //if (Math.abs(_angle) > 0.001) Graphics_SetTransform(); + // @endif }; // ############################################################################################# @@ -564,6 +566,7 @@ yyFont.prototype.BuildWorldMatrix = function(_x, _y, _angle) { // ############################################################################################# yyFont.prototype.Draw_String_GL = function (_x, _y, _pStr, _xscale, _yscale, _angle, _col1, _col2,_col3,_col4, _charSpacing, _wordSpacing) //, _alpha) { + // @if feature("gl") if( this.runtime_created) { //original @@ -753,6 +756,7 @@ yyFont.prototype.Draw_String_GL = function (_x, _y, _pStr, _xscale, _yscale, _an if (worldMatrix != undefined) { WebGL_SetMatrix(MATRIX_WORLD, worldMatrix); } + // @endif }; @@ -772,6 +776,7 @@ yyFont.prototype.Draw_String_GL = function (_x, _y, _pStr, _xscale, _yscale, _an // ############################################################################################# yyFont.prototype.Draw_String = function (_x, _y, _pStr, _xscale, _yscale, _angle, _col1, _col2, _col3, _col4, _charSpacing, _wordSpacing) //, _alpha) { { + // @if feature("2d") var cached_image = null; var ch; var TP = g_Textures[this.TPEntry.tp]; @@ -940,6 +945,7 @@ yyFont.prototype.Draw_String = function (_x, _y, _pStr, _xscale, _yscale, _angle } // end else } // end else graphics.globalAlpha = la; + // @endif }; @@ -960,6 +966,7 @@ yyFont.prototype.Draw_String = function (_x, _y, _pStr, _xscale, _yscale, _angle // ############################################################################################# yyFont.prototype.Draw_Sprite_String = function (_x, _y, _pStr, _xscale, _yscale, _angle, _col1, _col2, _col3, _col4, _charSpacing, _wordSpacing) { + // @if feature("2d") if (this.pSprites == null) return; var charSpacing = 0.0; @@ -1028,6 +1035,7 @@ yyFont.prototype.Draw_Sprite_String = function (_x, _y, _pStr, _xscale, _yscale, if (Math.abs(_angle) >= 0.001) Graphics_SetTransform(); graphics.globalAlpha = la; + // @endif }; @@ -1050,6 +1058,7 @@ yyFont.prototype.Draw_Sprite_String = function (_x, _y, _pStr, _xscale, _yscale, // ############################################################################################# yyFont.prototype.Draw_Sprite_String_GL = function (_x, _y, _pStr, _xscale, _yscale, _angle, _c1, _c2, _c3, _c4, _charSpacing, _wordSpacing) { + // @if feature("gl") if (this.pSprites == null) return; var charSpacing = 0.0; @@ -1150,6 +1159,7 @@ yyFont.prototype.Draw_Sprite_String_GL = function (_x, _y, _pStr, _xscale, _ysca if (worldmat !== undefined) { WebGL_SetMatrix(MATRIX_WORLD, worldmat); } + // @endif }; @@ -1210,6 +1220,7 @@ function yyFontManager( ) yyFontManager.prototype.Start_Rendering_SDF = function() { + // @if function("font_enable_sdf") && feature("gl") if (g_webGL) { if (shader_current() != -1) @@ -1221,19 +1232,21 @@ yyFontManager.prototype.Start_Rendering_SDF = function() if (this.SDF_State.usingSDFShader) return; // already enabled - shader_set(this.SDF_State.SDFShader); + WebGL_shader_set_RELEASE(this.SDF_State.SDFShader); var basetexstage = 0; // we always force the default texture sampler index to be 0 - this.SDF_State.currTexFilter = gpu_get_texfilter_ext(basetexstage); // we always force the default texture sampler index to be 0 - gpu_set_texfilter_ext(basetexstage, true); + this.SDF_State.currTexFilter = WebGL_gpu_get_texfilter_ext(basetexstage); // we always force the default texture sampler index to be 0 + WebGL_gpu_set_texfilter_ext(basetexstage, true); this.SDF_State.usingSDFShader = true; } + // @endif }; yyFontManager.prototype.End_Rendering_SDF = function() { + // @if function("font_enable_sdf") && feature("gl") if (g_webGL) { if (this.SDF_State.usingSDFShader) @@ -1241,11 +1254,12 @@ yyFontManager.prototype.End_Rendering_SDF = function() shader_reset(); var basetexstage = 0; // we always force the default texture sampler index to be 0 - gpu_set_texfilter_ext(basetexstage, this.SDF_State.currTexFilter); + WebGL_gpu_set_texfilter_ext(basetexstage, this.SDF_State.currTexFilter); this.SDF_State.usingSDFShader = false; } } + // @endif }; // ############################################################################################# From e7cdde0096f0d7db124a1b6f90ee93d9ed594e71 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Mon, 14 Aug 2023 14:30:52 +0300 Subject: [PATCH 57/84] Removed duplicate definitions for user event constants (GML_ev_userX vs GML_EVENT_OTHER_USERX) --- scripts/Events.js | 32 +++++++++++++++--------------- scripts/Globals.js | 18 +---------------- scripts/functions/Function_Game.js | 2 +- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/scripts/Events.js b/scripts/Events.js index 33144aa3..854a147c 100644 --- a/scripts/Events.js +++ b/scripts/Events.js @@ -820,22 +820,22 @@ function event_lookup(_event, _subevent) case GML_EVENT_OTHER_BOUNDARY_VIEW5: return EVENT_OTHER_BOUNDARY_VIEW5; case GML_EVENT_OTHER_BOUNDARY_VIEW6: return EVENT_OTHER_BOUNDARY_VIEW6; case GML_EVENT_OTHER_BOUNDARY_VIEW7: return EVENT_OTHER_BOUNDARY_VIEW7; - case GML_ev_user0: return EVENT_OTHER_USER0; - case GML_ev_user1: return EVENT_OTHER_USER1; - case GML_ev_user2: return EVENT_OTHER_USER2; - case GML_ev_user3: return EVENT_OTHER_USER3; - case GML_ev_user4: return EVENT_OTHER_USER4; - case GML_ev_user5: return EVENT_OTHER_USER5; - case GML_ev_user6: return EVENT_OTHER_USER6; - case GML_ev_user7: return EVENT_OTHER_USER7; - case GML_ev_user8: return EVENT_OTHER_USER8; - case GML_ev_user9: return EVENT_OTHER_USER9; - case GML_ev_user10: return EVENT_OTHER_USER10; - case GML_ev_user11: return EVENT_OTHER_USER11; - case GML_ev_user12: return EVENT_OTHER_USER12; - case GML_ev_user13: return EVENT_OTHER_USER13; - case GML_ev_user14: return EVENT_OTHER_USER14; - case GML_ev_user15: return EVENT_OTHER_USER15; + case GML_EVENT_OTHER_USER0: return EVENT_OTHER_USER0; + case GML_EVENT_OTHER_USER1: return EVENT_OTHER_USER1; + case GML_EVENT_OTHER_USER2: return EVENT_OTHER_USER2; + case GML_EVENT_OTHER_USER3: return EVENT_OTHER_USER3; + case GML_EVENT_OTHER_USER4: return EVENT_OTHER_USER4; + case GML_EVENT_OTHER_USER5: return EVENT_OTHER_USER5; + case GML_EVENT_OTHER_USER6: return EVENT_OTHER_USER6; + case GML_EVENT_OTHER_USER7: return EVENT_OTHER_USER7; + case GML_EVENT_OTHER_USER8: return EVENT_OTHER_USER8; + case GML_EVENT_OTHER_USER9: return EVENT_OTHER_USER9; + case GML_EVENT_OTHER_USER10: return EVENT_OTHER_USER10; + case GML_EVENT_OTHER_USER11: return EVENT_OTHER_USER11; + case GML_EVENT_OTHER_USER12: return EVENT_OTHER_USER12; + case GML_EVENT_OTHER_USER13: return EVENT_OTHER_USER13; + case GML_EVENT_OTHER_USER14: return EVENT_OTHER_USER14; + case GML_EVENT_OTHER_USER15: return EVENT_OTHER_USER15; case GML_EVENT_OTHER_ANIMATIONUPDATE: return EVENT_OTHER_ANIMATIONUPDATE; case GML_EVENT_OTHER_ANIMATIONEVENT: return EVENT_OTHER_ANIMATIONEVENT; case GML_EVENT_OTHER_WEB_IMAGE_LOAD: return EVENT_OTHER_WEB_IMAGE_LOAD; diff --git a/scripts/Globals.js b/scripts/Globals.js index d1f6c027..a95e18ea 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -389,23 +389,7 @@ GML_EVENT_STEP_NORMAL = 0, GML_EVENT_OTHER_ANIMATIONUPDATE = 58, GML_EVENT_OTHER_ANIMATIONEVENT = 59, - - GML_ev_user0 = 10, - GML_ev_user1 = 11, - GML_ev_user2 = 12, - GML_ev_user3 = 13, - GML_ev_user4 = 14, - GML_ev_user5 = 15, - GML_ev_user6 = 16, - GML_ev_user7 = 17, - GML_ev_user8 = 18, - GML_ev_user9 = 19, - GML_ev_user10 = 20, - GML_ev_user11 = 21, - GML_ev_user12 = 22, - GML_ev_user13 = 23, - GML_ev_user14 = 24, - GML_ev_user15 = 25, + GML_EVENT_OTHER_WEB_IMAGE_LOAD = 60, GML_EVENT_OTHER_WEB_SOUND_LOAD = 61, diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index 701e3640..8864122e 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -499,7 +499,7 @@ function event_user(_pInst, _pOther, _subevent) { { yyError("Error: illegal user event ID: " + _subevent); } - _subevent += GML_ev_user0; + _subevent += GML_EVENT_OTHER_USER0; event_perform(_pInst, _pOther, GML_EVENT_OTHER, _subevent); } From ddada8f8286590c12ad7bb0a3df2265c86c426fe Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Mon, 14 Aug 2023 14:36:43 +0300 Subject: [PATCH 58/84] More code related to event groups (user events, Outside Room/View, Intersect Room/View) is now stripped if unused. --- scripts/Events.js | 19 ++++++++++++- scripts/Globals.js | 21 ++++++++++---- scripts/functions/Function_Game.js | 2 ++ scripts/yyObject.js | 44 +++++++++++++++++++++++++++--- 4 files changed, 76 insertions(+), 10 deletions(-) diff --git a/scripts/Events.js b/scripts/Events.js index 854a147c..65b5640d 100644 --- a/scripts/Events.js +++ b/scripts/Events.js @@ -93,6 +93,7 @@ function HandleOSEvents() { // ############################################################################################# function HandleOther() { + // @if event("OutsideEvent") || event("BoundaryEvent") || event("OutsideView*") || event("BoundaryView*") var bbox, i, viewIndex; var pViews = null; if (g_RunRoom.m_enableviews) @@ -111,6 +112,7 @@ function HandleOther() if (!inst.marked && (inst.createCounter <= count)) { // Outside events + // @if event("OutsideEvent") if (pObject.REvent[EVENT_OTHER_OUTSIDE]) { var outside = false; @@ -131,8 +133,10 @@ function HandleOther() } inst.fOutsideRoom = outside; } + // @endif OutsideEvent // Boundary events + // @if event("BoundaryEvent") if (pObject.REvent[EVENT_OTHER_BOUNDARY]) { if (sprite_exists(inst.sprite_index) || sprite_exists(inst.mask_index)) @@ -151,10 +155,12 @@ function HandleOther() } } } + // @endif // Handle view related "other" events //for (i in pViews) + // @if event("OutsideView*") || event("BoundaryView*") if (pViews) { for (viewIndex = 0; viewIndex < pViews.length; viewIndex++) { //if (!pViews.hasOwnProperty(i)) continue; @@ -179,6 +185,7 @@ function HandleOther() } // Outside view events + // @if event("OutsideView*") if (pObject.REvent[EVENT_OTHER_OUTSIDE_VIEW0 + viewIndex]) { // Make a distinction whether the instance has a mask (or sprite) || not @@ -200,8 +207,10 @@ function HandleOther() } } } + // @endif OutsideView // Boundary view events + // @if event("BoundaryView*") if (pObject.REvent[EVENT_OTHER_BOUNDARY_VIEW0 + viewIndex]) { if (sprite_exists(inst.sprite_index) || sprite_exists(inst.mask_index)) { @@ -238,12 +247,14 @@ function HandleOther() }*/ } } + // @endif BoundaryView } } } + // @endif OutsideView || BoundaryView } } - + // @endif Outside || Boundary || OutsideView || BoundaryView } @@ -804,6 +815,7 @@ function event_lookup(_event, _subevent) case GML_EVENT_OTHER_ENDOFPATH: return EVENT_OTHER_ENDOFPATH; case GML_EVENT_OTHER_NOHEALTH: return EVENT_OTHER_NOHEALTH; case GML_EVENT_OTHER_CLOSEBUTTON: return EVENT_OTHER_CLOSEBUTTON; + // @if event("OutsideView*") case GML_EVENT_OTHER_OUTSIDE_VIEW0: return EVENT_OTHER_OUTSIDE_VIEW0; case GML_EVENT_OTHER_OUTSIDE_VIEW1: return EVENT_OTHER_OUTSIDE_VIEW1; case GML_EVENT_OTHER_OUTSIDE_VIEW2: return EVENT_OTHER_OUTSIDE_VIEW2; @@ -812,6 +824,8 @@ function event_lookup(_event, _subevent) case GML_EVENT_OTHER_OUTSIDE_VIEW5: return EVENT_OTHER_OUTSIDE_VIEW5; case GML_EVENT_OTHER_OUTSIDE_VIEW6: return EVENT_OTHER_OUTSIDE_VIEW6; case GML_EVENT_OTHER_OUTSIDE_VIEW7: return EVENT_OTHER_OUTSIDE_VIEW7; + // @endif + // @if event("BoundaryView*") case GML_EVENT_OTHER_BOUNDARY_VIEW0: return EVENT_OTHER_BOUNDARY_VIEW0; case GML_EVENT_OTHER_BOUNDARY_VIEW1: return EVENT_OTHER_BOUNDARY_VIEW1; case GML_EVENT_OTHER_BOUNDARY_VIEW2: return EVENT_OTHER_BOUNDARY_VIEW2; @@ -820,6 +834,8 @@ function event_lookup(_event, _subevent) case GML_EVENT_OTHER_BOUNDARY_VIEW5: return EVENT_OTHER_BOUNDARY_VIEW5; case GML_EVENT_OTHER_BOUNDARY_VIEW6: return EVENT_OTHER_BOUNDARY_VIEW6; case GML_EVENT_OTHER_BOUNDARY_VIEW7: return EVENT_OTHER_BOUNDARY_VIEW7; + // @endif + // @if event("UserEvent*") case GML_EVENT_OTHER_USER0: return EVENT_OTHER_USER0; case GML_EVENT_OTHER_USER1: return EVENT_OTHER_USER1; case GML_EVENT_OTHER_USER2: return EVENT_OTHER_USER2; @@ -836,6 +852,7 @@ function event_lookup(_event, _subevent) case GML_EVENT_OTHER_USER13: return EVENT_OTHER_USER13; case GML_EVENT_OTHER_USER14: return EVENT_OTHER_USER14; case GML_EVENT_OTHER_USER15: return EVENT_OTHER_USER15; + // @endif case GML_EVENT_OTHER_ANIMATIONUPDATE: return EVENT_OTHER_ANIMATIONUPDATE; case GML_EVENT_OTHER_ANIMATIONEVENT: return EVENT_OTHER_ANIMATIONEVENT; case GML_EVENT_OTHER_WEB_IMAGE_LOAD: return EVENT_OTHER_WEB_IMAGE_LOAD; diff --git a/scripts/Globals.js b/scripts/Globals.js index a95e18ea..c7f40332 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -112,7 +112,8 @@ EVENT_OTHER_NOHEALTH = EVENT_OTHER|10, EVENT_OTHER_CLOSEBUTTON = EVENT_OTHER|11, - EVENT_OTHER_USER0 = EVENT_OTHER|14, + EVENT_OTHER_USER0 = EVENT_OTHER|14, + // @if event("UserEvent*") EVENT_OTHER_USER1 = EVENT_OTHER|15, EVENT_OTHER_USER2 = EVENT_OTHER|16, EVENT_OTHER_USER3 = EVENT_OTHER|17, @@ -127,8 +128,10 @@ EVENT_OTHER_USER12= EVENT_OTHER|26, EVENT_OTHER_USER13= EVENT_OTHER|27, EVENT_OTHER_USER14= EVENT_OTHER|28, - EVENT_OTHER_USER15= EVENT_OTHER|29, + EVENT_OTHER_USER15= EVENT_OTHER|29, + // @endif + // @if event("OutsideView*") EVENT_OTHER_OUTSIDE_VIEW0 = EVENT_OTHER|30, EVENT_OTHER_OUTSIDE_VIEW1 = EVENT_OTHER|31, EVENT_OTHER_OUTSIDE_VIEW2 = EVENT_OTHER|32, @@ -137,7 +140,9 @@ EVENT_OTHER_OUTSIDE_VIEW5 = EVENT_OTHER|35, EVENT_OTHER_OUTSIDE_VIEW6 = EVENT_OTHER|36, EVENT_OTHER_OUTSIDE_VIEW7 = EVENT_OTHER|37, + // @endif + // @if event("BoundaryView*") EVENT_OTHER_BOUNDARY_VIEW0 = EVENT_OTHER|40, EVENT_OTHER_BOUNDARY_VIEW1 = EVENT_OTHER|41, EVENT_OTHER_BOUNDARY_VIEW2 = EVENT_OTHER|42, @@ -146,6 +151,7 @@ EVENT_OTHER_BOUNDARY_VIEW5 = EVENT_OTHER|45, EVENT_OTHER_BOUNDARY_VIEW6 = EVENT_OTHER|46, EVENT_OTHER_BOUNDARY_VIEW7 = EVENT_OTHER|47, + // @endif EVENT_OTHER_ANIMATIONUPDATE = EVENT_OTHER | 58, EVENT_OTHER_ANIMATIONEVENT = EVENT_OTHER | 59, @@ -263,6 +269,7 @@ EVENT_GESTURE_GLOBAL_ROTATE_END = EVENT_GESTURE | 77, GML_EVENT_OTHER_USER0 = 10, + // @if event("UserEvent*") GML_EVENT_OTHER_USER1 = 11, GML_EVENT_OTHER_USER2 = 12, GML_EVENT_OTHER_USER3 = 13, @@ -277,7 +284,8 @@ EVENT_GESTURE_GLOBAL_ROTATE_END = EVENT_GESTURE | 77, GML_EVENT_OTHER_USER12 =22, GML_EVENT_OTHER_USER13 =23, GML_EVENT_OTHER_USER14 =24, - GML_EVENT_OTHER_USER15= 25, + GML_EVENT_OTHER_USER15= 25, + // @endif GML_MOUSE_LeftButton = 0, GML_MOUSE_RightButton = 1, @@ -370,6 +378,7 @@ GML_EVENT_STEP_NORMAL = 0, GML_EVENT_OTHER_ENDOFPATH = 8, GML_EVENT_OTHER_NOHEALTH = 9, GML_EVENT_OTHER_CLOSEBUTTON = 30, + // @if event("OutsideView*") GML_EVENT_OTHER_OUTSIDE_VIEW0 = 40, GML_EVENT_OTHER_OUTSIDE_VIEW1 = 41, GML_EVENT_OTHER_OUTSIDE_VIEW2 = 42, @@ -378,6 +387,8 @@ GML_EVENT_STEP_NORMAL = 0, GML_EVENT_OTHER_OUTSIDE_VIEW5 = 45, GML_EVENT_OTHER_OUTSIDE_VIEW6 = 46, GML_EVENT_OTHER_OUTSIDE_VIEW7 = 47, + // @endif + // @if event("BoundaryView*") GML_EVENT_OTHER_BOUNDARY_VIEW0 = 50, GML_EVENT_OTHER_BOUNDARY_VIEW1 = 51, GML_EVENT_OTHER_BOUNDARY_VIEW2 = 52, @@ -385,12 +396,12 @@ GML_EVENT_STEP_NORMAL = 0, GML_EVENT_OTHER_BOUNDARY_VIEW4 = 54, GML_EVENT_OTHER_BOUNDARY_VIEW5 = 55, GML_EVENT_OTHER_BOUNDARY_VIEW6 = 56, - GML_EVENT_OTHER_BOUNDARY_VIEW7 = 57, + GML_EVENT_OTHER_BOUNDARY_VIEW7 = 57, + // @endif GML_EVENT_OTHER_ANIMATIONUPDATE = 58, GML_EVENT_OTHER_ANIMATIONEVENT = 59, - GML_EVENT_OTHER_WEB_IMAGE_LOAD = 60, GML_EVENT_OTHER_WEB_SOUND_LOAD = 61, GML_EVENT_OTHER_WEB_ASYNC = 62, diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index 8864122e..1ad8c218 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -499,8 +499,10 @@ function event_user(_pInst, _pOther, _subevent) { { yyError("Error: illegal user event ID: " + _subevent); } + // @if event("UserEvent*") _subevent += GML_EVENT_OTHER_USER0; event_perform(_pInst, _pOther, GML_EVENT_OTHER, _subevent); + // @endif } diff --git a/scripts/yyObject.js b/scripts/yyObject.js index d407d04e..57f7764e 100644 --- a/scripts/yyObject.js +++ b/scripts/yyObject.js @@ -215,8 +215,12 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if (_pObjectStorage.GestureGlobalFlickEvent) { pObj.GestureGlobalFlickEvent = _pObjectStorage.GestureGlobalFlickEvent; pObj.Event[EVENT_GESTURE_GLOBAL_FLICK] = true; } // @endif + // @if event("OutsideEvent") if( _pObjectStorage.OutsideEvent) {pObj.OutsideEvent = _pObjectStorage.OutsideEvent; pObj.Event[EVENT_OTHER_OUTSIDE] = true; } + // @endif + // @if event("BoundaryEvent") if( _pObjectStorage.BoundaryEvent) {pObj.BoundaryEvent = _pObjectStorage.BoundaryEvent; pObj.Event[EVENT_OTHER_BOUNDARY] = true; } + // @endif if( _pObjectStorage.StartGameEvent) {pObj.StartGameEvent = _pObjectStorage.StartGameEvent; pObj.Event[EVENT_OTHER_STARTGAME] = true; } if( _pObjectStorage.EndGameEvent) {pObj.EndGameEvent = _pObjectStorage.EndGameEvent; pObj.Event[EVENT_OTHER_ENDGAME] = true; } if( _pObjectStorage.StartRoomEvent) {pObj.StartRoomEvent = _pObjectStorage.StartRoomEvent; pObj.Event[EVENT_OTHER_STARTROOM] = true; } @@ -226,6 +230,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.EndOfPathEvent) {pObj.EndOfPathEvent = _pObjectStorage.EndOfPathEvent; pObj.Event[EVENT_OTHER_ENDOFPATH] = true; } if( _pObjectStorage.NoHealthEvent) {pObj.NoHealthEvent = _pObjectStorage.NoHealthEvent; pObj.Event[EVENT_OTHER_NOHEALTH] = true; } if( _pObjectStorage.CloseButtonEvent) {pObj.CloseButtonEvent = _pObjectStorage.CloseButtonEvent; pObj.Event[EVENT_OTHER_CLOSEBUTTON] = true; } + // @if event("OutsideView*") if( _pObjectStorage.OutsideView0Event) {pObj.OutsideView0Event = _pObjectStorage.OutsideView0Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW0] = true; } if( _pObjectStorage.OutsideView1Event) {pObj.OutsideView1Event = _pObjectStorage.OutsideView1Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW1] = true; } if( _pObjectStorage.OutsideView2Event) {pObj.OutsideView2Event = _pObjectStorage.OutsideView2Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW2] = true; } @@ -234,6 +239,8 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.OutsideView5Event) {pObj.OutsideView5Event = _pObjectStorage.OutsideView5Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW5] = true; } if( _pObjectStorage.OutsideView6Event) {pObj.OutsideView6Event = _pObjectStorage.OutsideView6Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW6] = true; } if( _pObjectStorage.OutsideView7Event) {pObj.OutsideView7Event = _pObjectStorage.OutsideView7Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW7] = true; } + // @endif + // @if event("BoundaryView*") if( _pObjectStorage.BoundaryView0Event) {pObj.BoundaryView0Event = _pObjectStorage.BoundaryView0Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW0] = true; } if( _pObjectStorage.BoundaryView1Event) {pObj.BoundaryView1Event = _pObjectStorage.BoundaryView1Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW1] = true; } if( _pObjectStorage.BoundaryView2Event) {pObj.BoundaryView2Event = _pObjectStorage.BoundaryView2Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW2] = true; } @@ -242,10 +249,12 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.BoundaryView5Event) {pObj.BoundaryView5Event = _pObjectStorage.BoundaryView5Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW5] = true; } if( _pObjectStorage.BoundaryView6Event) {pObj.BoundaryView6Event = _pObjectStorage.BoundaryView6Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW6] = true; } if( _pObjectStorage.BoundaryView7Event) {pObj.BoundaryView7Event = _pObjectStorage.BoundaryView7Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW7] = true; } + // @endif if( _pObjectStorage.AnimationUpdateEvent) {pObj.AnimationUpdateEvent = _pObjectStorage.AnimationUpdateEvent; pObj.Event[EVENT_OTHER_ANIMATIONUPDATE] = true; } + // @if event("UserEvent*") if( _pObjectStorage.UserEvent0) {pObj.UserEvent0 = _pObjectStorage.UserEvent0; pObj.Event[EVENT_OTHER_USER0] = true; } if( _pObjectStorage.UserEvent1) {pObj.UserEvent1 = _pObjectStorage.UserEvent1; pObj.Event[EVENT_OTHER_USER1] = true; } if( _pObjectStorage.UserEvent2) {pObj.UserEvent2 = _pObjectStorage.UserEvent2; pObj.Event[EVENT_OTHER_USER2] = true; } @@ -262,6 +271,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if( _pObjectStorage.UserEvent13) {pObj.UserEvent13 = _pObjectStorage.UserEvent13; pObj.Event[EVENT_OTHER_USER13] = true; } if( _pObjectStorage.UserEvent14) {pObj.UserEvent14 = _pObjectStorage.UserEvent14; pObj.Event[EVENT_OTHER_USER14] = true; } if( _pObjectStorage.UserEvent15) {pObj.UserEvent15 = _pObjectStorage.UserEvent15; pObj.Event[EVENT_OTHER_USER15] = true; } + // @endif if (_pObjectStorage.WebImageLoadedEvent) { pObj.WebImageLoadedEvent = _pObjectStorage.WebImageLoadedEvent; pObj.Event[EVENT_OTHER_WEB_IMAGE_LOAD] = true; } if (_pObjectStorage.WebSoundLoadedEvent) { pObj.WebSoundLoadedEvent = _pObjectStorage.WebSoundLoadedEvent; pObj.Event[EVENT_OTHER_WEB_SOUND_LOAD] = true; } @@ -270,8 +280,10 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { if (_pObjectStorage.WebIAPEvent) { pObj.WebIAPEvent = _pObjectStorage.WebIAPEvent; pObj.Event[EVENT_OTHER_WEB_IAP] = true; } if (_pObjectStorage.SocialEvent) { pObj.SocialEvent = _pObjectStorage.SocialEvent; pObj.Event[EVENT_OTHER_SOCIAL] = true; } if (_pObjectStorage.PushNotificationEvent) { pObj.PushNotificationEvent = _pObjectStorage.PushNotificationEvent; pObj.Event[EVENT_OTHER_PUSH_NOTIFICATION] = true; } - if (_pObjectStorage.AsyncSaveLoadEvent) { pObj.AsyncSaveLoadEvent = _pObjectStorage.AsyncSaveLoadEvent; pObj.Event[EVENT_OTHER_ASYNC_SAVE_LOAD] = true; } - if (_pObjectStorage.NetworkingEvent) { pObj.NetworkingEvent = _pObjectStorage.NetworkingEvent; pObj.Event[EVENT_OTHER_NETWORKING] = true; } + if (_pObjectStorage.AsyncSaveLoadEvent) { pObj.AsyncSaveLoadEvent = _pObjectStorage.AsyncSaveLoadEvent; pObj.Event[EVENT_OTHER_ASYNC_SAVE_LOAD] = true; } + // @if event("NetworkingEvent") + if (_pObjectStorage.NetworkingEvent) { pObj.NetworkingEvent = _pObjectStorage.NetworkingEvent; pObj.Event[EVENT_OTHER_NETWORKING] = true; } + // @endif if (_pObjectStorage.AudioPlaybackEvent) { pObj.AudioPlaybackEvent = _pObjectStorage.AudioPlaybackEvent; pObj.Event[EVENT_OTHER_AUDIO_PLAYBACK] = true; } if (_pObjectStorage.AudioPlaybackEndedEvent) { pObj.AudioPlaybackEndedEvent = _pObjectStorage.AudioPlaybackEndedEvent; pObj.Event[EVENT_OTHER_AUDIO_PLAYBACK_ENDED] = true; } if (_pObjectStorage.AudioRecordingEvent) { pObj.AudioRecordingEvent = _pObjectStorage.AudioRecordingEvent; pObj.Event[EVENT_OTHER_AUDIO_RECORDING] = true; } @@ -714,6 +726,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_DRAW: if (this.DrawEvent) this.DrawEvent(_pInst, _pOther); else done = false; break; case EVENT_KEYPRESS: if (this.ObjKeyPressed[_event | index]) this.ObjKeyPressed[_event | index](_pInst, _pOther); else done = false; break; case EVENT_KEYRELEASE: if (this.ObjKeyReleased[_event | index]) this.ObjKeyReleased[_event | index](_pInst, _pOther); else done = false; break; + // @if eventType("Trigger") case EVENT_TRIGGER: if (this.Triggers[_event | index]) { var pTriggerEvent = this.Triggers[_event | index]; // 1st get the trigger event block @@ -725,6 +738,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ } } break; + // @endif trigger case EVENT_DRAW_GUI: if (this.DrawGUI) this.DrawGUI(_pInst, _pOther); else done = false; break; case EVENT_DRAW_BEGIN: if (this.DrawEventBegin) this.DrawEventBegin(_pInst, _pOther); else done = false; break; @@ -739,8 +753,12 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_STEP_NORMAL: if (this.StepNormalEvent) this.StepNormalEvent(_pInst, _pOther); else done = false; break; case EVENT_STEP_END: if (this.StepEndEvent) this.StepEndEvent(_pInst, _pOther); else done = false; break; - case EVENT_OTHER_OUTSIDE: if (this.OutsideEvent) this.OutsideEvent(_pInst, _pOther); else done = false; break; + // @if event("OutsideEvent") + case EVENT_OTHER_OUTSIDE: if (this.OutsideEvent) this.OutsideEvent(_pInst, _pOther); else done = false; break; + // @endif + // @if event("BoundaryEvent") case EVENT_OTHER_BOUNDARY: if (this.BoundaryEvent) this.BoundaryEvent(_pInst, _pOther); else done = false; break; + // @endif case EVENT_OTHER_STARTGAME: if (this.StartGameEvent) this.StartGameEvent(_pInst, _pOther); else done = false; break; case EVENT_OTHER_ENDGAME: if (this.EndGameEvent) this.EndGameEvent(_pInst, _pOther); else done = false; break; case EVENT_OTHER_STARTROOM: if (this.StartRoomEvent) this.StartRoomEvent(_pInst, _pOther); else done = false; break; @@ -750,6 +768,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_OTHER_ENDOFPATH: if (this.EndOfPathEvent) this.EndOfPathEvent(_pInst, _pOther); else done = false; break; case EVENT_OTHER_NOHEALTH: if (this.NoHealthEvent) this.NoHealthEvent(_pInst, _pOther); else done = false; break; case EVENT_OTHER_CLOSEBUTTON: if (this.CloseButtonEvent) this.CloseButtonEvent(_pInst, _pOther); else done = false; break; + // @if event("OutsideView*") case EVENT_OTHER_OUTSIDE_VIEW0: if (this.OutsideView0Event) this.OutsideView0Event(_pInst, _pOther); else done = false; break; case EVENT_OTHER_OUTSIDE_VIEW1: if (this.OutsideView1Event) this.OutsideView1Event(_pInst, _pOther); else done = false; break; case EVENT_OTHER_OUTSIDE_VIEW2: if (this.OutsideView2Event) this.OutsideView2Event(_pInst, _pOther); else done = false; break; @@ -758,6 +777,8 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_OTHER_OUTSIDE_VIEW5: if (this.OutsideView5Event) this.OutsideView5Event(_pInst, _pOther); else done = false; break; case EVENT_OTHER_OUTSIDE_VIEW6: if (this.OutsideView6Event) this.OutsideView6Event(_pInst, _pOther); else done = false; break; case EVENT_OTHER_OUTSIDE_VIEW7: if (this.OutsideView7Event) this.OutsideView7Event(_pInst, _pOther); else done = false; break; + // @endif + // @if event("BoundaryView*") case EVENT_OTHER_BOUNDARY_VIEW0: if (this.BoundaryView0Event) this.BoundaryView0Event(_pInst, _pOther); else done = false; break; case EVENT_OTHER_BOUNDARY_VIEW1: if (this.BoundaryView1Event) this.BoundaryView1Event(_pInst, _pOther); else done = false; break; case EVENT_OTHER_BOUNDARY_VIEW2: if (this.BoundaryView2Event) this.BoundaryView2Event(_pInst, _pOther); else done = false; break; @@ -766,6 +787,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_OTHER_BOUNDARY_VIEW5: if (this.BoundaryView5Event) this.BoundaryView5Event(_pInst, _pOther); else done = false; break; case EVENT_OTHER_BOUNDARY_VIEW6: if (this.BoundaryView6Event) this.BoundaryView6Event(_pInst, _pOther); else done = false; break; case EVENT_OTHER_BOUNDARY_VIEW7: if (this.BoundaryView7Event) this.BoundaryView7Event(_pInst, _pOther); else done = false; break; + // @endif case EVENT_OTHER_ANIMATIONUPDATE: if (this.AnimationUpdateEvent) this.AnimationUpdateEvent(_pInst, _pOther); else done = false; break; case EVENT_OTHER_ANIMATIONEVENT: if (this.AnimationEventEvent) this.AnimationEventEvent(_pInst, _pOther); else done = false; break; @@ -786,7 +808,8 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_OTHER_BROADCAST_MESSAGE: if (this.BroadcastMessageEvent) this.BroadcastMessageEvent(_pInst, _pOther); else done = false; break; - case EVENT_OTHER_USER0: if (this.UserEvent0) this.UserEvent0(_pInst, _pOther); else done = false; break; + // @if event("UserEvent*") + case EVENT_OTHER_USER0: if (this.UserEvent0) this.UserEvent0(_pInst, _pOther); else done = false; break; case EVENT_OTHER_USER1: if (this.UserEvent1) this.UserEvent1(_pInst, _pOther); else done = false; break; case EVENT_OTHER_USER2: if (this.UserEvent2) this.UserEvent2(_pInst, _pOther); else done = false; break; case EVENT_OTHER_USER3: if (this.UserEvent3) this.UserEvent3(_pInst, _pOther); else done = false; break; @@ -802,6 +825,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_OTHER_USER13: if (this.UserEvent13) this.UserEvent13(_pInst, _pOther); else done = false; break; case EVENT_OTHER_USER14: if (this.UserEvent14) this.UserEvent14(_pInst, _pOther); else done = false; break; case EVENT_OTHER_USER15: if (this.UserEvent15) this.UserEvent15(_pInst, _pOther); else done = false; break; + // @endif // @if eventType("Mouse") @@ -927,6 +951,7 @@ function ConvertEvent(_event) case EVENT_OTHER_ENDOFPATH: return GML_EVENT_OTHER; case EVENT_OTHER_NOHEALTH: return GML_EVENT_OTHER; case EVENT_OTHER_CLOSEBUTTON: return GML_EVENT_OTHER; + // @if event("OutsideView*") case EVENT_OTHER_OUTSIDE_VIEW0: return GML_EVENT_OTHER; case EVENT_OTHER_OUTSIDE_VIEW1: return GML_EVENT_OTHER; case EVENT_OTHER_OUTSIDE_VIEW2: return GML_EVENT_OTHER; @@ -935,6 +960,8 @@ function ConvertEvent(_event) case EVENT_OTHER_OUTSIDE_VIEW5: return GML_EVENT_OTHER; case EVENT_OTHER_OUTSIDE_VIEW6: return GML_EVENT_OTHER; case EVENT_OTHER_OUTSIDE_VIEW7: return GML_EVENT_OTHER; + // @endif + // @if event("BoundaryView*") case EVENT_OTHER_BOUNDARY_VIEW0: return GML_EVENT_OTHER; case EVENT_OTHER_BOUNDARY_VIEW1: return GML_EVENT_OTHER; case EVENT_OTHER_BOUNDARY_VIEW2: return GML_EVENT_OTHER; @@ -943,6 +970,7 @@ function ConvertEvent(_event) case EVENT_OTHER_BOUNDARY_VIEW5: return GML_EVENT_OTHER; case EVENT_OTHER_BOUNDARY_VIEW6: return GML_EVENT_OTHER; case EVENT_OTHER_BOUNDARY_VIEW7: return GML_EVENT_OTHER; + // @endif case EVENT_OTHER_ANIMATIONUPDATE: return GML_EVENT_OTHER; case EVENT_OTHER_ANIMATIONEVENT: return GML_EVENT_OTHER; @@ -961,6 +989,7 @@ function ConvertEvent(_event) case EVENT_OTHER_AUDIO_RECORDING: return GML_EVENT_OTHER; case EVENT_OTHER_SYSTEM_EVENT: return GML_EVENT_OTHER; + // @if event("UserEvent*") case EVENT_OTHER_USER0: return GML_EVENT_OTHER; case EVENT_OTHER_USER1: return GML_EVENT_OTHER; case EVENT_OTHER_USER2: return GML_EVENT_OTHER; @@ -977,6 +1006,7 @@ function ConvertEvent(_event) case EVENT_OTHER_USER13: return GML_EVENT_OTHER; case EVENT_OTHER_USER14: return GML_EVENT_OTHER; case EVENT_OTHER_USER15: return GML_EVENT_OTHER; + // @endif // @if eventType("Mouse") @@ -1107,6 +1137,7 @@ function ConvertSubEvent(_event, _subevent) case EVENT_OTHER_ENDOFPATH: return GML_EVENT_OTHER_ENDOFPATH; case EVENT_OTHER_NOHEALTH: return GML_EVENT_OTHER_NOHEALTH; case EVENT_OTHER_CLOSEBUTTON: return GML_EVENT_OTHER_CLOSEBUTTON; + // @if event("OutsideView*") case EVENT_OTHER_OUTSIDE_VIEW0: return GML_EVENT_OTHER_OUTSIDE_VIEW0; case EVENT_OTHER_OUTSIDE_VIEW1: return GML_EVENT_OTHER_OUTSIDE_VIEW1; case EVENT_OTHER_OUTSIDE_VIEW2: return GML_EVENT_OTHER_OUTSIDE_VIEW2; @@ -1115,6 +1146,8 @@ function ConvertSubEvent(_event, _subevent) case EVENT_OTHER_OUTSIDE_VIEW5: return GML_EVENT_OTHER_OUTSIDE_VIEW5; case EVENT_OTHER_OUTSIDE_VIEW6: return GML_EVENT_OTHER_OUTSIDE_VIEW6; case EVENT_OTHER_OUTSIDE_VIEW7: return GML_EVENT_OTHER_OUTSIDE_VIEW7; + // @endif + // @if event("BoundaryView*") case EVENT_OTHER_BOUNDARY_VIEW0: return GML_EVENT_OTHER_BOUNDARY_VIEW0; case EVENT_OTHER_BOUNDARY_VIEW1: return GML_EVENT_OTHER_BOUNDARY_VIEW1; case EVENT_OTHER_BOUNDARY_VIEW2: return GML_EVENT_OTHER_BOUNDARY_VIEW2; @@ -1123,6 +1156,7 @@ function ConvertSubEvent(_event, _subevent) case EVENT_OTHER_BOUNDARY_VIEW5: return GML_EVENT_OTHER_BOUNDARY_VIEW5; case EVENT_OTHER_BOUNDARY_VIEW6: return GML_EVENT_OTHER_BOUNDARY_VIEW6; case EVENT_OTHER_BOUNDARY_VIEW7: return GML_EVENT_OTHER_BOUNDARY_VIEW7; + // @endif case EVENT_OTHER_ANIMATIONUPDATE: return GML_EVENT_OTHER_ANIMATIONUPDATE; case EVENT_OTHER_ANIMATIONEVENT: return GML_EVENT_OTHER_ANIMATIONEVENT; @@ -1143,6 +1177,7 @@ function ConvertSubEvent(_event, _subevent) case EVENT_OTHER_BROADCAST_MESSAGE: return GML_EVENT_OTHER_BROADCAST_MESSAGE; + // @if event("UserEvent*") case EVENT_OTHER_USER0: return GML_EVENT_OTHER_USER0; case EVENT_OTHER_USER1: return GML_EVENT_OTHER_USER1; case EVENT_OTHER_USER2: return GML_EVENT_OTHER_USER2; @@ -1159,6 +1194,7 @@ function ConvertSubEvent(_event, _subevent) case EVENT_OTHER_USER13: return GML_EVENT_OTHER_USER13; case EVENT_OTHER_USER14: return GML_EVENT_OTHER_USER14; case EVENT_OTHER_USER15: return GML_EVENT_OTHER_USER15; + // @endif // @if eventType("Mouse") From fec6633e8918bc960a057eb72f27a2dcd6cc56f6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 15:14:41 +0300 Subject: [PATCH 59/84] Keyboard events are no longer bound if we're not doing any keyboard input. --- scripts/_GameMaker.js | 4 +++- scripts/yyIOManager.js | 20 +++++++++++++++++--- scripts/yyObject.js | 10 ++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index c3b6adac..3731792c 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -1678,7 +1678,9 @@ function GameMaker_DoAStep() { UpdateActiveLists(); if (New_Room != -1) return; - HandleKeyboard(); + // @if feature("keyboard") + HandleKeyboard(); + // @endif UpdateActiveLists(); if (New_Room != -1) return; diff --git a/scripts/yyIOManager.js b/scripts/yyIOManager.js index f3c685fe..b71277d5 100644 --- a/scripts/yyIOManager.js +++ b/scripts/yyIOManager.js @@ -69,7 +69,7 @@ var g_LastVirtualKeys = 0; // Collects together all touch events as single-button mice var g_TouchEvents = []; - +// @if feature("keyboard") var g_UnshiftedKeyboardMapping = { 8: String.fromCharCode(8), 9:0, @@ -286,7 +286,7 @@ var g_ShiftedKeyboardMapping = { 222: "~", //single quote 222 223: "¬" }; - +// @endif // ############################################################################################# @@ -664,6 +664,7 @@ function CancelFullScreenMode() { // ############################################################################################# function CaptureBrowserInput() { if (g_InputCaught) return; + // @if feature("keyboard") window.onkeyup = function () { yyKeyUpCallback(arguments[0] || window.event); }; window.onkeydown = function () { @@ -689,6 +690,7 @@ function CaptureBrowserInput() { return false; } }; + // @endif window.onmouseup = onMouseUp; g_InputCaught = true; } @@ -701,8 +703,10 @@ function CaptureBrowserInput() { // ############################################################################################# function ReleaseBrowserInput() { if (g_InputCaught == false) return; + // @if feature("keyboard") window.onkeydown = null; window.onkeyup = null; + // @endif window.onmouseup = null; g_InputCaught = false; @@ -1032,6 +1036,7 @@ function yyIOManager( ) this.Update = IO_Update; //this.Clear = IO_Clear; this.StartStep = IO_StartStep; + // @if feature("keyboard") this.Char_Last_Get = Char_Last_Get; this.Char_Last_Set = Char_Last_Set; this.Key_Last_Get = Key_Last_Get; @@ -1041,7 +1046,8 @@ function yyIOManager( ) this.Key_Down = Key_Down; this.Key_Pressed = Key_Pressed; this.Key_Released = Key_Released; - this.Key_Clear = Key_Clear; + this.Key_Clear = Key_Clear; + // @endif keyboard this.Button_Last_Get = Button_Last_Get; this.Button_Current_Get = Button_Current_Get; this.Button_Last_Set = Button_Last_Set; @@ -1051,9 +1057,11 @@ function yyIOManager( ) this.Button_Released = Button_Released; this.Button_Clear = Button_Clear; this.Button_Clear_All = Button_Clear_All; + // @if feature("keyboard") this.HandleKeyDown = IO_HandleKeyDown; this.HandleKeyPressed= IO_HandleKeyPressed; this.HandleKeyReleased= IO_HandleKeyReleased; + // @endif // @if function("virtual_key_*") this.ProcessVirtualKeys = ProcessVirtualKeys; // @endif @@ -1193,7 +1201,9 @@ function yyInputEvent() // ############################################################################################# function Clear_Pressed() { + // @if feature("keyboard") IO_Key_Clear_All(); + // @endif keyboard IO_Button_Clear_All(); g_pBuiltIn.keyboard_key = 0; g_pBuiltIn.keyboard_key = ""; @@ -1215,7 +1225,9 @@ function Clear_Pressed() //function IO_Clear() yyIOManager.prototype.Clear = function () { //String_Clear(); + // @if feature("keyboard") this.Key_Clear_All(); + // @endif keyboard this.Button_Clear_All(); g_pBuiltIn.keyboard_key = 0; @@ -1678,6 +1690,7 @@ function IO_Update() g_CurrentInputEvents[eventIndex].Flags &= ~NEW_INPUT_EVENT; } + // @if feature("keyboard") if (g_LastKeyPressed_code) { if (g_LastKeyPressed) @@ -1713,6 +1726,7 @@ function IO_Update() g_pBuiltIn.keyboard_lastkey = g_pBuiltIn.keyboard_key; g_pBuiltIn.keyboard_key = 0; } + // @endif this.MouseX = g_EventMouseX; this.MouseY = g_EventMouseY; diff --git a/scripts/yyObject.js b/scripts/yyObject.js index 57f7764e..4b4958bd 100644 --- a/scripts/yyObject.js +++ b/scripts/yyObject.js @@ -720,12 +720,18 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_ALARM: done = false; break; // Shouldn't get called directly case EVENT_STEP: done = false; break; case EVENT_COLLISION: if (this.Collisions[index]) this.Collisions[index].m_pFunction(_pInst, _pOther); break; + // @if eventType("Keyboard") case EVENT_KEYBOARD: if (this.ObjKeyDown[_event | index]) this.ObjKeyDown[_event | index](_pInst, _pOther); else done = false; break; - case EVENT_MOUSE: done = false; break; // Shouldn't get called directly + // @endif + case EVENT_MOUSE: done = false; break; // Shouldn't get called directly case EVENT_OTHER: done = false; break; // Shouldn't get called directly case EVENT_DRAW: if (this.DrawEvent) this.DrawEvent(_pInst, _pOther); else done = false; break; + // @if eventType("KeyPress") case EVENT_KEYPRESS: if (this.ObjKeyPressed[_event | index]) this.ObjKeyPressed[_event | index](_pInst, _pOther); else done = false; break; - case EVENT_KEYRELEASE: if (this.ObjKeyReleased[_event | index]) this.ObjKeyReleased[_event | index](_pInst, _pOther); else done = false; break; + // @endif + // @if eventType("KeyRelease") + case EVENT_KEYRELEASE: if (this.ObjKeyReleased[_event | index]) this.ObjKeyReleased[_event | index](_pInst, _pOther); else done = false; break; + // @endif // @if eventType("Trigger") case EVENT_TRIGGER: if (this.Triggers[_event | index]) { From 87622070afe42ede327a7eab3b90e7e9b72fb720 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 11:50:27 +0300 Subject: [PATCH 60/84] We can use a regex instead of a whole parser for GetLocalStorageRoot. --- scripts/LocalStorage.js | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/scripts/LocalStorage.js b/scripts/LocalStorage.js index 7f0151d3..f210d3a8 100644 --- a/scripts/LocalStorage.js +++ b/scripts/LocalStorage.js @@ -35,25 +35,8 @@ function SupportsLocalStorage() function GetLocalStorageRoot() { // Only use alpha-numeric characters, and underbars, from the display name - var displayName = ""; - if (g_pGMFile.Options.DisplayName !== null && g_pGMFile.Options.DisplayName !== undefined) { - - for (var i = 0; i < g_pGMFile.Options.DisplayName.length; i++) { - - var chr = g_pGMFile.Options.DisplayName[i]; - if ((chr >= 'a' && chr <= 'z') || - (chr >= 'A' && chr <= 'Z') || - (chr >= '0' && chr <= '9') || - (chr === '_')) - { - displayName = displayName + g_pGMFile.Options.DisplayName[i]; - } - } - } - if (displayName.length === 0) { - displayName = "GameMaker"; - } - return displayName + "." + g_pBuiltIn.game_id + "."; + let _displayName = (g_pGMFile.Options.DisplayName || "").replace(new RegExp("[^\\w]", "g"), ""); + return (_displayName || "GameMaker") + "." + g_pBuiltIn.game_id + "."; } // ############################################################################################# From ca504fccd9012cb09b9676ed1aea87b93c952196 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 11:51:19 +0300 Subject: [PATCH 61/84] Why would internal code use chr() for linebreaks..? --- scripts/Globals.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index c7f40332..b77d5938 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1999,8 +1999,7 @@ function DetectBrowser() { if (document.URL.substring(0, 5) == "file:") { - alert("WARNING: Running this via a file and not a web server is not advised as the browser will enable additional security, and things like files and colours won't work correctly. " + - chr(13) + chr(13) + "Please check the FAQ for more details. " + chr(13) + chr(13) + "https://help.yoyogames.com/hc/en-us/articles/360011372851"); + alert("WARNING: Running this via a file and not a web server is not advised as the browser will enable additional security, and things like files and colours won't work correctly.\r\rPlease check the FAQ for more details.\r\rhttps://help.yoyogames.com/hc/en-us/articles/360011372851"); } } } From 9da9d165b8d984a0ffbd980f17d632857c5416aa Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 11:52:18 +0300 Subject: [PATCH 62/84] One collision function implementation can be omitted based on "collision system compatibility" flag. --- scripts/yyInstance.js | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index 6175a91e..c10ba354 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -1334,23 +1334,6 @@ yyInstance.prototype.PerformEventInherited = function (_event, _index, _pOther) } }; -// ############################################################################################# -/// Function: -/// Perform an event on this instance. -/// -/// -/// In: the event to perform -/// the THIS to use in the event -/// the OTHER to use in the event -// ############################################################################################# -/*yyInstance.prototype.PerformEvent = function (_event, _index, _pInst, _pOther) { - - //if( pObject.Name == "oAssessmentBack" & _event==EVENT_DRAW){ - // this.testcode = 1; - //} - return this.PerformEvent_Common(_event, _index, _pInst, _pOther, _pInst.pObject); -};*/ - // ############################################################################################# /// Function: @@ -2566,6 +2549,7 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) { if (g_Collision_Compatibility_Mode) { + // @if feature("collision_compatibility") return pSpr1.OrigPreciseCollision(this.image_index | 0, this.bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, @@ -2573,9 +2557,11 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) { _pInst.image_index | 0, _pInst.bbox, Round(_pInst.x), Round(_pInst.y), _pInst.image_xscale, _pInst.image_yscale, _pInst.image_angle); + // @endif } else { + // @if !feature("collision_compatibility") return pSpr1.PreciseCollision(this.image_index | 0, this.bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, @@ -2583,6 +2569,7 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) { _pInst.image_index | 0, _pInst.bbox, Round(_pInst.x), Round(_pInst.y), _pInst.image_xscale, _pInst.image_yscale, _pInst.image_angle); + // @endif } } return false; From a4473069eadbcd87381d7aeb946b85c71a5cdc2c Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 11:53:10 +0300 Subject: [PATCH 63/84] More tweaks to omit unused shader functions --- scripts/functions/Function_D3D.js | 32 +++++++-------- scripts/functions/Function_Shaders.js | 54 ++++++++++++++++++-------- scripts/functions/Function_Surface.js | 3 +- scripts/yyFont.js | 4 +- scripts/yyRoom.js | 4 ++ scripts/yyWebGL.js | 56 +++++++++++---------------- 6 files changed, 83 insertions(+), 70 deletions(-) diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js index dc8d27c6..268979f1 100644 --- a/scripts/functions/Function_D3D.js +++ b/scripts/functions/Function_D3D.js @@ -116,14 +116,14 @@ function gpu_set_state(){} compile_if_used(draw_set_color_write_enable = _stub("draw_set_color_write_enable")); compile_if_used(draw_set_colour_write_enable = _stub("draw_set_colour_write_enable")); - d3d_set_lighting = _stub("d3d_set_lighting"); - d3d_light_define_direction = _stub("d3d_light_define_direction"); - d3d_light_define_point = _stub("d3d_light_define_point"); - d3d_light_enable = _stub("d3d_light_enable"); - d3d_light_define_ambient = _stub("d3d_light_define_ambient"); - d3d_light_get = _stub("d3d_light_get"); - d3d_light_get_ambient = _stub("d3d_light_get_ambient"); - d3d_get_lighting = _stub("d3d_get_lighting"); + compile_if_used(draw_set_lighting, d3d_set_lighting = _stub("d3d_set_lighting")); + compile_if_used(draw_light_define_direction, d3d_light_define_direction = _stub("d3d_light_define_direction")); + compile_if_used(draw_light_define_point, d3d_light_define_point = _stub("d3d_light_define_point")); + compile_if_used(draw_light_enable, d3d_light_enable = _stub("d3d_light_enable")); + compile_if_used(draw_light_define_ambient, d3d_light_define_ambient = _stub("d3d_light_define_ambient")); + compile_if_used(draw_light_get, d3d_light_get = _stub("d3d_light_get")); + compile_if_used(draw_light_get_ambient, d3d_light_get_ambient = _stub("d3d_light_get_ambient")); + compile_if_used(draw_get_lighting, d3d_get_lighting = _stub("d3d_get_lighting")); compile_if_used(d3d_set_perspective = _stub("d3d_set_perspective")); d3d_set_fog = _stub("d3d_set_fog"); // used by yyWebGL @@ -258,15 +258,15 @@ function InitD3DFunctions() { d3d_set_perspective = WebGL_d3d_set_perspective_RELEASE; // Lighting - d3d_set_lighting = WebGL_d3d_set_lighting_RELEASE; - d3d_light_define_direction = WebGL_d3d_light_define_direction_RELEASE; - d3d_light_define_point = WebGL_d3d_light_define_point_RELEASE; - d3d_light_enable = WebGL_d3d_light_enable_RELEASE; - d3d_light_define_ambient = WebGL_d3d_light_define_ambient_RELEASE; + compile_if_used(draw_set_lighting, d3d_set_lighting = WebGL_d3d_set_lighting_RELEASE); + compile_if_used(draw_light_define_direction, d3d_light_define_direction = WebGL_d3d_light_define_direction_RELEASE); + compile_if_used(draw_light_define_point, d3d_light_define_point = WebGL_d3d_light_define_point_RELEASE); + compile_if_used(draw_light_enable, d3d_light_enable = WebGL_d3d_light_enable_RELEASE); + compile_if_used(draw_light_define_ambient, d3d_light_define_ambient = WebGL_d3d_light_define_ambient_RELEASE); + compile_if_used(draw_light_get, d3d_light_get = WebGL_d3d_light_get_RELEASE); + compile_if_used(draw_light_get_ambient, d3d_light_get_ambient = WebGL_d3d_light_get_ambient_RELEASE); + compile_if_used(draw_get_lighting, d3d_get_lighting = WebGL_d3d_get_lighting_RELEASE); d3d_set_fog = WebGL_d3d_set_fog_RELEASE; - d3d_light_get = WebGL_d3d_light_get_RELEASE; - d3d_light_get_ambient = WebGL_d3d_light_get_ambient_RELEASE; - d3d_get_lighting = WebGL_d3d_get_lighting_RELEASE; compile_if_used(matrix_get = WebGL_Matrix_Get); compile_if_used(matrix_set = WebGL_Matrix_Set); diff --git a/scripts/functions/Function_Shaders.js b/scripts/functions/Function_Shaders.js index 64182664..64401849 100644 --- a/scripts/functions/Function_Shaders.js +++ b/scripts/functions/Function_Shaders.js @@ -11,23 +11,43 @@ // ********************************************************************************************************************** // WebGL.js redefines these to useful functions -var fn_texture_get_texel_width = GetErrorFunction("fn_texture_get_texel_width",0), - fn_texture_get_texel_height = GetErrorFunction("fn_texture_get_texel_height",0), - fn_texture_set_stage = GetErrorFunction("fn_texture_set_stage"); - -var fn_shader_is_compiled = GetErrorFunction("fn_shader_is_compiled",0), - fn_shader_set = GetErrorFunction("fn_shader_set"), - fn_shader_get_uniform = GetErrorFunction("fn_shader_get_uniform",-1), - fn_shader_set_uniform_i = GetErrorFunction("fn_shader_set_uniform_i"), - fn_shader_set_uniform_f = GetErrorFunction("fn_shader_set_uniform_f"), - fn_shader_set_uniform_matrix = GetErrorFunction("fn_shader_set_uniform_matrix"), - fn_shader_get_sampler_index = GetErrorFunction("fn_shader_get_sampler_index"), - fn_shader_enable_corner_id = GetErrorFunction("fn_shader_enable_corner_id"), - fn_shader_set_uniform_i_array = GetErrorFunction("fn_shader_set_uniform_i_array"), - fn_shader_set_uniform_f_array = GetErrorFunction("fn_shader_set_uniform_f_array"), - fn_shader_set_uniform_f_buffer = GetErrorFunction("fn_shader_set_uniform_f_buffer"), - fn_shader_set_uniform_matrix_array = GetErrorFunction("fn_shader_set_uniform_matrix_array"), - fn_shader_get_name = GetErrorFunction("fn_shader_get_name",""); +function fn_texture_get_texel_width(){} +function fn_texture_get_texel_height(){} +function fn_texture_set_stage(){} +function fn_shader_is_compiled(){} +function fn_shader_set(){} +function fn_shader_get_uniform(){} +function fn_shader_set_uniform_i(){} +function fn_shader_set_uniform_f(){} +function fn_shader_set_uniform_matrix(){} +function fn_shader_get_sampler_index(){} +function fn_shader_enable_corner_id(){} +function fn_shader_set_uniform_i_array(){} +function fn_shader_set_uniform_f_array(){} +function fn_shader_set_uniform_f_buffer(){} +function fn_shader_set_uniform_matrix_array(){} +function fn_shader_get_name(){} +// @if feature("2d") && (function("shader_*") || function("texture_get_texel_*") || function("texture_set_stage")) +(() => { + let _stub = (_name, _val) => () => ErrorFunction(_name, _val); + compile_if_used(texture_get_texel_width, fn_texture_get_texel_width = _stub("fn_texture_get_texel_width", 0)); + compile_if_used(texture_get_texel_height, fn_texture_get_texel_height = _stub("fn_texture_get_texel_height", 0)); + compile_if_used(texture_set_stage, fn_texture_set_stage = _stub("fn_texture_set_stage")); + compile_if_used(shader_is_compiled, fn_shader_is_compiled = _stub("fn_shader_is_compiled", 0)); + fn_shader_set = _stub("fn_shader_set"); + compile_if_used(shader_get_uniform, fn_shader_get_uniform = _stub("fn_shader_get_uniform", -1)); + compile_if_used(shader_set_uniform_i, fn_shader_set_uniform_i = _stub("fn_shader_set_uniform_i")); + compile_if_used(shader_set_uniform_f, fn_shader_set_uniform_f = _stub("fn_shader_set_uniform_f")); + compile_if_used(shader_set_uniform_matrix, fn_shader_set_uniform_matrix = _stub("fn_shader_set_uniform_matrix")); + compile_if_used(shader_get_sampler_index, fn_shader_get_sampler_index = _stub("fn_shader_get_sampler_index", -1)); + compile_if_used(shader_enable_corner_id, fn_shader_enable_corner_id = _stub("fn_shader_enable_corner_id")); + compile_if_used(shader_set_uniform_i_array, fn_shader_set_uniform_i_array = _stub("fn_shader_set_uniform_i_array")); + compile_if_used(shader_set_uniform_f_array, fn_shader_set_uniform_f_array = _stub("fn_shader_set_uniform_f_array")); + compile_if_used(shader_set_uniform_f_buffer, fn_shader_set_uniform_f_buffer = _stub("fn_shader_set_uniform_f_buffer")); + compile_if_used(shader_set_uniform_matrix_array, fn_shader_set_uniform_matrix_array = _stub("fn_shader_set_uniform_matrix_array")); + compile_if_used(shader_get_name, fn_shader_get_name = _stub("fn_shader_get_name", "")); +})(); +// @endif var g_CurrentShader = -1; // -------------------------------------------------------------------------------------------------------------------- diff --git a/scripts/functions/Function_Surface.js b/scripts/functions/Function_Surface.js index ae896e3e..0c0edace 100644 --- a/scripts/functions/Function_Surface.js +++ b/scripts/functions/Function_Surface.js @@ -30,8 +30,7 @@ var g_createsurfacedepthbuffers = true; /// /// // ############################################################################################# -var surface_resize = surface_resize_RELEASE; -function surface_resize_RELEASE(_id, _w, _h) +function surface_resize(_id, _w, _h) { _id = yyGetInt32(_id); _w = yyGetInt32(_w); diff --git a/scripts/yyFont.js b/scripts/yyFont.js index 9d8664c3..0b682581 100644 --- a/scripts/yyFont.js +++ b/scripts/yyFont.js @@ -1226,7 +1226,7 @@ yyFontManager.prototype.Start_Rendering_SDF = function() if (shader_current() != -1) return; // don't override existing user shader - if ((this.SDF_State.SDFShader == -1) || (shader_is_compiled(this.SDF_State.SDFShader) == false)) + if ((this.SDF_State.SDFShader == -1) || (!WebGL_shader_is_compiled_RELEASE(this.SDF_State.SDFShader))) return; // our SDF shader either doesn't exist or hasn't been compiled if (this.SDF_State.usingSDFShader) @@ -1251,7 +1251,7 @@ yyFontManager.prototype.End_Rendering_SDF = function() { if (this.SDF_State.usingSDFShader) { - shader_reset(); + WebGL_shader_set_RELEASE(-1); var basetexstage = 0; // we always force the default texture sampler index to be 0 WebGL_gpu_set_texfilter_ext(basetexstage, this.SDF_State.currTexFilter); diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 4a7f9676..66bb31e8 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -3412,18 +3412,22 @@ function ExecuteLayerScript(layerid,script) function SetLayerShader(shaderid) { + // @if feature("shaders") if(shaderid!=-1) { shader_set(shaderid); } + // @endif }; function ResetLayerShader(shaderid) { + // @if feature("shaders") if(shaderid!=-1) { shader_reset(); } + // @endif }; // ############################################################################################# /// Function: diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index ed51f9d7..f1ce4eff 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -213,23 +213,23 @@ function InitWebGLFunctions() { compile_if_used(sprite_set_alpha_from_sprite, CopyImageToAlpha = WEBGL_CopyImageToAlpha_RELEASE); // Shaders - fn_texture_get_texel_width = WebGL_texture_get_texel_width_RELEASE; - fn_texture_get_texel_height = WebGL_texture_get_texel_height_RELEASE; - fn_texture_set_stage = WebGL_texture_set_stage_RELEASE; - fn_shader_is_compiled = WebGL_shader_is_compiled_RELEASE; + compile_if_used(texture_get_texel_width, fn_texture_get_texel_width = WebGL_texture_get_texel_width_RELEASE); + compile_if_used(texture_get_texel_height, fn_texture_get_texel_height = WebGL_texture_get_texel_height_RELEASE); + compile_if_used(texture_set_stage, fn_texture_set_stage = WebGL_texture_set_stage_RELEASE); + compile_if_used(shader_is_compiled, fn_shader_is_compiled = WebGL_shader_is_compiled_RELEASE); fn_shader_set = WebGL_shader_set_RELEASE; - fn_shader_get_uniform = WebGL_shader_get_uniform_RELEASE; - fn_shader_set_uniform_i = WebGL_shader_set_uniform_i_RELEASE; - fn_shader_set_uniform_f = WebGL_shader_set_uniform_f_RELEASE; - fn_shader_set_uniform_matrix = WebGL_shader_set_uniform_matrix_RELEASE; - fn_shader_get_sampler_index = WebGL_shader_get_sampler_index_RELEASE; - fn_shader_enable_corner_id = WebGL_shader_enable_corner_id_RELEASE; - fn_shader_set_uniform_i_array = WebGL_shader_set_uniform_i_array_RELEASE; - fn_shader_set_uniform_f_array = WebGL_shader_set_uniform_f_array_RELEASE; - fn_shader_set_uniform_f_buffer = WebGL_shader_set_uniform_f_buffer_RELEASE; - fn_shader_set_uniform_matrix_array = WebGL_shader_set_uniform_matrix_array_RELEASE; - shaders_are_supported = WebGL_shaders_are_supported_RELEASE; - fn_shader_get_name = WebGL_shader_get_name_RELEASE; + compile_if_used(shader_get_uniform, fn_shader_get_uniform = WebGL_shader_get_uniform_RELEASE); + compile_if_used(shader_set_uniform_i, fn_shader_set_uniform_i = WebGL_shader_set_uniform_i_RELEASE); + compile_if_used(shader_set_uniform_f, fn_shader_set_uniform_f = WebGL_shader_set_uniform_f_RELEASE); + compile_if_used(shader_set_uniform_matrix, fn_shader_set_uniform_matrix = WebGL_shader_set_uniform_matrix_RELEASE); + compile_if_used(shader_get_sampler_index, fn_shader_get_sampler_index = WebGL_shader_get_sampler_index_RELEASE); + compile_if_used(shader_enable_corner_id, fn_shader_enable_corner_id = WebGL_shader_enable_corner_id_RELEASE); + compile_if_used(shader_set_uniform_i_array, fn_shader_set_uniform_i_array = WebGL_shader_set_uniform_i_array_RELEASE); + compile_if_used(shader_set_uniform_f_array, fn_shader_set_uniform_f_array = WebGL_shader_set_uniform_f_array_RELEASE); + compile_if_used(shader_set_uniform_f_buffer, fn_shader_set_uniform_f_buffer = WebGL_shader_set_uniform_f_buffer_RELEASE); + compile_if_used(shader_set_uniform_matrix_array, fn_shader_set_uniform_matrix_array = WebGL_shader_set_uniform_matrix_array_RELEASE); + compile_if_used(shaders_are_supported = WebGL_shaders_are_supported_RELEASE); + compile_if_used(shader_get_name, fn_shader_get_name = WebGL_shader_get_name_RELEASE); // textures compile_if_used(texture_set_blending = WebGL_texture_set_blending_RELEASE); @@ -4513,12 +4513,7 @@ function WebGL_texture_set_stage_RELEASE(_stage, _texture) { /// // ############################################################################################# function WebGL_shader_is_compiled_RELEASE(_shaderIndex) { - - _shaderIndex = yyGetInt32(_shaderIndex); - if (g_shaderPrograms[_shaderIndex] && g_shaderPrograms[_shaderIndex].program) { - return 1; - } - return 0; + return g_shaderPrograms[yyGetInt32(_shaderIndex)]?.program ? 1 : 0; } @@ -4604,17 +4599,12 @@ function WebGL_shader_set_uniform_matrix_RELEASE(_handle, _shaderData) { /// // ############################################################################################# function WebGL_shader_get_sampler_index_RELEASE(_shaderIndex, _texture) { - - _shaderIndex = yyGetInt32(_shaderIndex); - if (g_shaderPrograms[_shaderIndex]) { - - var shaderProgram = g_shaderPrograms[_shaderIndex]; - if (shaderProgram) { - for (var i = 0; i < shaderProgram.texture_stages.length; i++) { - - if (shaderProgram.texture_stages[i] == _texture) { - return Number(i); - } + var shaderProgram = g_shaderPrograms[yyGetInt32(_shaderIndex)]; + if (shaderProgram) { + for (var i = 0; i < shaderProgram.texture_stages.length; i++) { + + if (shaderProgram.texture_stages[i] == _texture) { + return Number(i); } } } From f1adcfa4fc267d55427c706bfb53665d45d0fe2f Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 11:53:38 +0300 Subject: [PATCH 64/84] CRC32 implementation can be omitted if buffer_crc32 is not used. --- scripts/yyBuffer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/yyBuffer.js b/scripts/yyBuffer.js index a3ad26a0..0d293618 100644 --- a/scripts/yyBuffer.js +++ b/scripts/yyBuffer.js @@ -884,6 +884,7 @@ function DoMD5(_buff, _size,_offset) } // @endif buffer_md5 +// @if function("buffer_crc32") function crc32_init() { var poly = -306674912; var tab = new Array(256); @@ -910,6 +911,7 @@ function crc32(b, pos, len) { crc = (tab[(crc ^ b[i]) & 255] ^ ((crc >>> 8) & 0x00ffffff)) >>> 0; return crc; } +// @endif // ############################################################################################# From 6cbe6d3397a40c863508e4f6e73249aeab2ac7de Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 16 Aug 2023 11:33:55 +0300 Subject: [PATCH 65/84] Audio system can be stripped if the project doesn't use audio (primarily of interest for interactive elements in websites) --- scripts/Globals.js | 4 +++- scripts/LoadGame.js | 13 +++++++++++-- scripts/_GameMaker.js | 12 ++++++++++-- scripts/functions/Function_Sound.js | 4 ++++ scripts/sound/AudioBus.js | 2 ++ scripts/sound/AudioEmitter.js | 2 ++ scripts/sound/AudioPlaybackProps.js | 2 ++ scripts/sound/AudioPropsCalc.js | 2 ++ scripts/yyASync.js | 10 ++++++++-- scripts/yyObject.js | 8 ++++++++ 10 files changed, 52 insertions(+), 7 deletions(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index b77d5938..a86dc707 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1115,7 +1115,8 @@ function InitAboyneGlobals() { InitFastCRC(); DetectBrowser(); - if(g_AudioModel!= Audio_NoAudio) { + // @if feature("audio") + if(g_AudioModel!= Audio_NoAudio) { try { var pAudioTest = new Audio(); @@ -1133,6 +1134,7 @@ function InitAboyneGlobals() { } } + // @endif audio if (g_canPlayMp3) debug("Browser CAN play MP3"); if (g_canPlayOgg) debug("Browser CAN play OGG"); diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index 3a043cb4..c8cc2215 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -53,7 +53,9 @@ function InitAboyne() g_pSpriteManager = new yySpriteManager(); g_pTextureGroupInfoManager = new yyTextureGroupInfoManager(); g_pBackgroundManager = new yyBackgroundManager(); + // @if feature("audio") g_pSoundManager = new yySoundManager(); + // @endif audio g_pFontManager = new yyFontManager(); g_pCollisionList = []; // @if feature("paths") @@ -77,7 +79,9 @@ function InitAboyne() g_pCameraManager = new CameraManager(); InitAboyneGlobals(); - Audio_Init(); + // @if feature("audio") + Audio_Init(); + // @endif audio if (g_isZeus) { @@ -182,6 +186,7 @@ function LoadedGame_ExtensionError(_event) { /// Callbacks for sound loading... (this is set to the image) /// // ############################################################################################# +// @if feature("audio") function ClearEventListeners(_snd) { _snd.removeEventListener('canplaythrough', LoadGame_SoundLoad, false); _snd.removeEventListener('error', LoadGame_SoundLoad_Error, false); @@ -239,7 +244,7 @@ function LoadGame_SoundLoad_Suspended(_event) { function LoadGame_SoundLoad_Stalled(_event) { //debug(this.URL + ' loading stalled'); } - +// @endif audio // ############################################################################################# @@ -483,6 +488,7 @@ function LoadGame_PreLoadAssets(_GameFile) // Now load WAV files (not mp3/ogg) + // @if feature("audio") if(g_AudioModel == Audio_WebAudio) { for (index = 0; index < _GameFile.Sounds.length; index++) @@ -551,6 +557,7 @@ function LoadGame_PreLoadAssets(_GameFile) } } } + // @endif audio load } @@ -847,9 +854,11 @@ function LoadGame(_GameFile) // Load Sounds + // @if feature("audio") for(index=0; index<_GameFile.Sounds.length; index++ ){ g_pSoundManager.Add( _GameFile.Sounds[index]); } + // @endif audio // Load Timelines diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 3731792c..3f7c1254 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -640,9 +640,11 @@ function GameMaker_Init() g_LastCanvasWidth = canvas.width; g_LastCanvasHeight = canvas.height; + // @if feature("audio") if ((g_pGMFile.Options.UseNewAudio == true) || g_isZeus) { g_AudioModel = Audio_WebAudio; } + // @endif audio @@ -1483,11 +1485,13 @@ function StartGame() g_pBuiltIn.fps = Fps; g_pBuiltIn.fps_real = Fps; + // @if feature("audio") if(g_AudioModel == Audio_WebAudio) { // Audio: Report current device status to the newly created room Audio_EngineReportState(); } + // @endif audio } // ############################################################################################# @@ -1546,13 +1550,15 @@ function Run_EndGame(_reset) { } g_pInstanceManager.Clear(); - if (_reset) { + // @if feature("audio") + if (_reset) { // Just stops all audio instances. audio_stop_all(); } else { // Destroys the AudioContext instance. Audio_Quit(); } + // @endif audio } @@ -1753,7 +1759,9 @@ function GameMaker_DoAStep() { RenderSystemOverlays(); - audio_update(); + // @if feature("audio") + audio_update(); + // @endif audio } diff --git a/scripts/functions/Function_Sound.js b/scripts/functions/Function_Sound.js index 2e417b03..b9d79686 100644 --- a/scripts/functions/Function_Sound.js +++ b/scripts/functions/Function_Sound.js @@ -14,6 +14,7 @@ // // ********************************************************************************************************************** +// @if feature("audio") var audio_sounds = []; var BASE_SOUND_INDEX = 300000; var audio_sounds_index = BASE_SOUND_INDEX; @@ -1059,6 +1060,7 @@ function Audio_EngineReportState() ds_map_destroy(map); g_pBuiltIn.async_load = -1; } +// @endif audio function audio_system_is_available() { @@ -2408,6 +2410,7 @@ function audio_get_listener_info(index) } function audio_debug(trueFalse) {} +// @if feature("audio") //loading ------------------------- /** @this {XMLHttpRequest} */ function Audio_SoundError(e) @@ -2908,6 +2911,7 @@ function AudioGroups_Init() } } } +// @endif audio function audio_group_load( _groupId ) { diff --git a/scripts/sound/AudioBus.js b/scripts/sound/AudioBus.js index 74c3304c..a7199526 100644 --- a/scripts/sound/AudioBus.js +++ b/scripts/sound/AudioBus.js @@ -1,3 +1,4 @@ +// @if feature("audio") function AudioBus() { // GML object props this.__type = "[AudioBus]"; @@ -217,3 +218,4 @@ DummyAudioBus.prototype.handleValue = function(_value) throw new Error("Value must be Struct.AudioEffect or undefined"); }; +// @endif audio diff --git a/scripts/sound/AudioEmitter.js b/scripts/sound/AudioEmitter.js index 454855a5..a54a9d02 100644 --- a/scripts/sound/AudioEmitter.js +++ b/scripts/sound/AudioEmitter.js @@ -1,3 +1,4 @@ +// @if feature("audio") class AudioEmitter { constructor() { if (Audio_IsMainBusInitialised() === false) { @@ -100,3 +101,4 @@ AudioEmitter.prototype.setPosition = function(_x, _y, _z) { this.pannerNode.positionY.value = _y; this.pannerNode.positionZ.value = _z; }; +// @endif audio diff --git a/scripts/sound/AudioPlaybackProps.js b/scripts/sound/AudioPlaybackProps.js index 597569d7..2283fce5 100644 --- a/scripts/sound/AudioPlaybackProps.js +++ b/scripts/sound/AudioPlaybackProps.js @@ -1,3 +1,4 @@ +// @if feature("audio") var AudioPlaybackType = { NON_POSITIONAL: 0, POSITIONAL_SPECIFIED: 1, @@ -91,3 +92,4 @@ AudioPlaybackProps.prototype.invalid = function() { return false; }; +// @endif audio diff --git a/scripts/sound/AudioPropsCalc.js b/scripts/sound/AudioPropsCalc.js index 07b2daeb..1a2f0230 100644 --- a/scripts/sound/AudioPropsCalc.js +++ b/scripts/sound/AudioPropsCalc.js @@ -1,3 +1,4 @@ +// @if feature("audio") function AudioPropsCalc() {} AudioPropsCalc.invalid_index = -1; @@ -81,3 +82,4 @@ AudioPropsCalc.GetGroupProps = function(_assetIndex) { gain: new TimeRampedParamLinear(AudioPropsCalc.default_gain), }))(); }; +// @endif audio diff --git a/scripts/yyASync.js b/scripts/yyASync.js index eb9708f7..fe66c2de 100644 --- a/scripts/yyASync.js +++ b/scripts/yyASync.js @@ -349,7 +349,9 @@ yyASyncManager.prototype.Process = function () { ds_map_add(map, "result", pFile.result); ds_map_add(map, "value", pFile.value); ds_map_add(map, "http_status", 0); - } else if (pFile.m_Type == ASYNC_AUDIO_PLAYBACK) { + } + // @if feature("audio") + else if (pFile.m_Type == ASYNC_AUDIO_PLAYBACK) { ds_map_add(map, "queue_id", pFile.queue_id); ds_map_add(map, "buffer_id", pFile.buffer_id); ds_map_add(map, "queue_shutdown", pFile.queue_shutdown); @@ -357,7 +359,9 @@ yyASyncManager.prototype.Process = function () { ds_map_add(map, "sound_id", pFile.voiceHandle); ds_map_add(map, "asset_id", pFile.assetIndex); ds_map_add(map, "was_stopped", pFile.wasStopped); - } else if (pFile.m_Type == ASYNC_SYSTEM_EVENT) { + } + // @endif audio + else if (pFile.m_Type == ASYNC_SYSTEM_EVENT) { ds_map_add(map, "event_type", pFile.event_type); ds_map_add(map, "pad_index", pFile.pad_index); }else{ @@ -382,8 +386,10 @@ yyASyncManager.prototype.Process = function () { else if (pFile.m_Type == ASYNC_USER) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_USER_INTERACTION, 0, true); else if (pFile.m_Type == ASYNC_BINARY) g_pObjectManager.ThrowEvent(EVENT_OTHER_ASYNC_SAVE_LOAD, 0, true); else if (pFile.m_Type == ASYNC_NETWORKING) g_pObjectManager.ThrowEvent(EVENT_OTHER_NETWORKING, 0, true); + // @if feature("audio") else if (pFile.m_Type == ASYNC_AUDIO_PLAYBACK) g_pObjectManager.ThrowEvent(EVENT_OTHER_AUDIO_PLAYBACK, 0, true); else if (pFile.m_Type == ASYNC_AUDIO_PLAYBACK_ENDED) g_pObjectManager.ThrowEvent(EVENT_OTHER_AUDIO_PLAYBACK_ENDED, 0, true); + // @endif audio else if (pFile.m_Type == ASYNC_SYSTEM_EVENT) g_pObjectManager.ThrowEvent(EVENT_OTHER_SYSTEM_EVENT, 0, true); // Done load, so delete handle. diff --git a/scripts/yyObject.js b/scripts/yyObject.js index 4b4958bd..9d47e536 100644 --- a/scripts/yyObject.js +++ b/scripts/yyObject.js @@ -284,9 +284,11 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) { // @if event("NetworkingEvent") if (_pObjectStorage.NetworkingEvent) { pObj.NetworkingEvent = _pObjectStorage.NetworkingEvent; pObj.Event[EVENT_OTHER_NETWORKING] = true; } // @endif + // @if feature("audio") if (_pObjectStorage.AudioPlaybackEvent) { pObj.AudioPlaybackEvent = _pObjectStorage.AudioPlaybackEvent; pObj.Event[EVENT_OTHER_AUDIO_PLAYBACK] = true; } if (_pObjectStorage.AudioPlaybackEndedEvent) { pObj.AudioPlaybackEndedEvent = _pObjectStorage.AudioPlaybackEndedEvent; pObj.Event[EVENT_OTHER_AUDIO_PLAYBACK_ENDED] = true; } if (_pObjectStorage.AudioRecordingEvent) { pObj.AudioRecordingEvent = _pObjectStorage.AudioRecordingEvent; pObj.Event[EVENT_OTHER_AUDIO_RECORDING] = true; } + // @endif audio if (_pObjectStorage.AnimationEventEvent) { pObj.AnimationEventEvent = _pObjectStorage.AnimationEventEvent; pObj.Event[EVENT_OTHER_ANIMATIONEVENT] = true; } if (_pObjectStorage.SystemEvent) { pObj.SystemEvent = _pObjectStorage.SystemEvent; pObj.Event[EVENT_OTHER_SYSTEM_EVENT] = true; } if (_pObjectStorage.BroadcastMessageEvent) { pObj.BroadcastMessageEvent = _pObjectStorage.BroadcastMessageEvent; pObj.Event[EVENT_OTHER_BROADCAST_MESSAGE] = true; } @@ -807,9 +809,11 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_ case EVENT_OTHER_PUSH_NOTIFICATION: if( this.PushNotificationEvent) this.PushNotificationEvent( _pInst, _pOther); else done =false; break; case EVENT_OTHER_ASYNC_SAVE_LOAD: if( this.AsyncSaveLoadEvent) this.AsyncSaveLoadEvent( _pInst, _pOther); else done =false; break; case EVENT_OTHER_NETWORKING: if( this.NetworkingEvent) this.NetworkingEvent( _pInst, _pOther); else done =false; break; + // @if feature("audio") case EVENT_OTHER_AUDIO_PLAYBACK: if (this.AudioPlaybackEvent) this.AudioPlaybackEvent( _pInst, _pOther); else done = false; break; case EVENT_OTHER_AUDIO_PLAYBACK_ENDED: if (this.AudioPlaybackEndedEvent) this.AudioPlaybackEndedEvent( _pInst, _pOther); else done = false; break; case EVENT_OTHER_AUDIO_RECORDING: if (this.AudioRecordingEvent) this.AudioRecordingEvent( _pInst, _pOther); else done = false; break; + // @endif audio case EVENT_OTHER_SYSTEM_EVENT: if (this.SystemEvent) this.SystemEvent(_pInst, _pOther); else done = false; break; case EVENT_OTHER_BROADCAST_MESSAGE: if (this.BroadcastMessageEvent) this.BroadcastMessageEvent(_pInst, _pOther); else done = false; break; @@ -990,9 +994,11 @@ function ConvertEvent(_event) case EVENT_OTHER_PUSH_NOTIFICATION: return GML_EVENT_OTHER; case EVENT_OTHER_ASYNC_SAVE_LOAD: return GML_EVENT_OTHER; case EVENT_OTHER_NETWORKING: return GML_EVENT_OTHER; + // @if feature("audio") case EVENT_OTHER_AUDIO_PLAYBACK: return GML_EVENT_OTHER; case EVENT_OTHER_AUDIO_PLAYBACK_ENDED: return GML_EVENT_OTHER; case EVENT_OTHER_AUDIO_RECORDING: return GML_EVENT_OTHER; + // @endif audio case EVENT_OTHER_SYSTEM_EVENT: return GML_EVENT_OTHER; // @if event("UserEvent*") @@ -1176,9 +1182,11 @@ function ConvertSubEvent(_event, _subevent) case EVENT_OTHER_PUSH_NOTIFICATION: return GML_EVENT_OTHER_PUSH_NOTIFICATION; case EVENT_OTHER_ASYNC_SAVE_LOAD: return GML_EVENT_OTHER_ASYNC_SAVE_LOAD; case EVENT_OTHER_NETWORKING: return GML_EVENT_OTHER_NETWORKING; + // @if feature("audio") case EVENT_OTHER_AUDIO_PLAYBACK: return GML_EVENT_OTHER_AUDIO_PLAYBACK; case EVENT_OTHER_AUDIO_PLAYBACK_ENDED: return GML_EVENT_OTHER_AUDIO_PLAYBACK_ENDED; case EVENT_OTHER_AUDIO_RECORDING: return EVENT_OTHER_AUDIO_RECORDING; + // @endif audio case EVENT_OTHER_SYSTEM_EVENT: return GML_EVENT_OTHER_SYSTEM_EVENT; case EVENT_OTHER_BROADCAST_MESSAGE: return GML_EVENT_OTHER_BROADCAST_MESSAGE; From fcbec36cb6792b0d9fa91535a818063180a035d5 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 15:11:22 +0300 Subject: [PATCH 66/84] Don't have to expose an extension API if there are no extensions --- scripts/_GameMaker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 3f7c1254..49030536 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -209,6 +209,7 @@ window.addEventListener( "unhandledrejection", yyUnhandledRejectionHandler ); //external access for js extensions +// @if feature("js_extensions") var GMS_API = { "debug_msg": show_debug_message, "ds_list_size": ds_list_size, @@ -220,6 +221,7 @@ var GMS_API = { "get_facebook_app_id": YYGetFacebookAppId, "get_app_version_string": YYGetAppVersionString }; +// @endif function YYGetFacebookAppId() { return g_pGMFile.Options.Facebook; From 9367df060b5dc0eca393ecc513d58c5d71bd67c9 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 15:11:56 +0300 Subject: [PATCH 67/84] And don't have to parse parameters if the game's not reading them. --- scripts/_GameMaker.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 49030536..e749facd 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -566,8 +566,10 @@ function GameMaker_Init() graphics = null; if( !canvas) return; + // @if function("parameter_*") ParseURL( window.location ); - g_pGMFile = JSON_game; + // @endif + g_pGMFile = JSON_game; // initialise the map of obfuscated names to var if (typeof g_var2obf !== "undefined") { From 7c2a11f6476fd63ea9e082f5886b31c3d97a5dd0 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 15 Aug 2023 15:13:06 +0300 Subject: [PATCH 68/84] Apparently `a = ()=>{}function b(){}` is illegal --- scripts/functions/Function_Graphics.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/functions/Function_Graphics.js b/scripts/functions/Function_Graphics.js index 416072ff..37dffc56 100644 --- a/scripts/functions/Function_Graphics.js +++ b/scripts/functions/Function_Graphics.js @@ -251,7 +251,7 @@ draw_clear_alpha = (_col, _alpha) => { } Graphics_Restore(); -} +}; // @endif @@ -921,7 +921,7 @@ draw_point = (_x, _y) => { graphics.globalAlpha = g_GlobalAlpha; graphics.fillStyle = g_GlobalColour_HTML_RGBA; graphics._fillRect(_x, _y, 1, 1); -} +}; // @endif @@ -965,7 +965,7 @@ draw_line_width = (_x1, _y1, _x2, _y2, _w) => { graphics._closePath(); graphics._stroke(); graphics._fillRect(_x2, _y2, 1, 1); // CHROME doesn't fill in the bottom pixel! -} +}; // @endif From efad9c733515459955f635ec703125af8c03884a Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 16 Aug 2023 11:27:16 +0300 Subject: [PATCH 69/84] Omit some WebGL bits if using strictly 2d render. --- scripts/_GameMaker.js | 2 ++ scripts/yyGraphics.js | 2 ++ scripts/yyWebGL.js | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index e749facd..38172728 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -822,7 +822,9 @@ function animate() { case -2: { if (g_LoadingCanvasCreated) DeleteLoadingCanvas(); + // @if feature("gl") yyWebGLRequiredError(graphics, DISPLAY_WIDTH, DISPLAY_HEIGHT); + // @endif gl break; } diff --git a/scripts/yyGraphics.js b/scripts/yyGraphics.js index dae4769b..287c2428 100644 --- a/scripts/yyGraphics.js +++ b/scripts/yyGraphics.js @@ -228,7 +228,9 @@ function Graphics_Init( _canvas ) } // @endif }else{ + // @if feature("gl") InitWebGLFunctions(); + // @endif gl } diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index f1ce4eff..a2ec5c67 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -262,7 +262,7 @@ function InitWebGLFunctions() { /// // ############################################################################################# function InitWebGL(_canvas) { - + // @if feature("gl") var options = { Stencil: ((g_pGMFile.Swfs !== undefined) ? true : false), PreserveDrawingBuffer: (g_pGMFile.Options.WebGLPreserveDrawingBuffer ? true : false), @@ -288,6 +288,7 @@ function InitWebGL(_canvas) { GR_TextureRepeat[i] = false; } return true; + // @endif gl } // ############################################################################################# @@ -4896,6 +4897,7 @@ function WebGL_SetMatrix(_type, _matrix) { g_ViewFrustumDirty |= (_type == MATRIX_VIEW || _type == MATRIX_PROJECTION); + // @if feature("gl") if(g_webGL==null) return; switch (_type) { @@ -4912,7 +4914,8 @@ function WebGL_SetMatrix(_type, _matrix) { g_webGL.SetWorldMatrix(g_Matrix[_type]); break; } - g_webGL.Flush(); + g_webGL.Flush(); + // @endif gl } // ############################################################################################# From d8ea93a2ed67f42fd99679b0d3db1fa3ee1a23cf Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 16 Aug 2023 11:29:41 +0300 Subject: [PATCH 70/84] Some trimming for draw_sprite_pos --- scripts/yyGraphics.js | 4 ++-- scripts/yyWebGL.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/yyGraphics.js b/scripts/yyGraphics.js index 287c2428..dab29e06 100644 --- a/scripts/yyGraphics.js +++ b/scripts/yyGraphics.js @@ -1229,8 +1229,8 @@ function Graphics_ColouriseImage( _texture, _x, _y, _w, _h, _col ) /// // ############################################################################################# function Graphics_TextureDrawPos(){} -// @if feature("2d") -function Graphics_TextureDrawPos(_pTPE, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha) { +// @if feature("2d") && function("draw_sprite_pos") +Graphics_TextureDrawPos = function(_pTPE, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha) { var pTexture = _pTPE.texture; diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index a2ec5c67..a6364e59 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -141,7 +141,9 @@ function InitWebGLFunctions() { Graphics_TextureDrawSimple = WebGL_TextureDrawSimple_RELEASE; Graphics_TextureDrawTiled = WebGL_TextureDrawTiled_RELEASE; Graphics_TextureDraw = WebGL_TextureDraw_RELEASE; + // @if function("draw_sprite_pos") Graphics_TextureDrawPos = WebGL_TextureDrawPos_RELEASE; + // @endif // @if feature("swf") Graphics_SWFDraw = WebGL_DrawSWF_RELEASE; Graphics_SWFDrawObject = WebGL_DrawSWFObject_RELEASE; From d1a503fa9a18574993fc2899140fcdc01de83ade Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 16 Aug 2023 11:31:08 +0300 Subject: [PATCH 71/84] zlib can be omitted if none of the functions are used. --- scripts/zlib/deflate.min.js | 2 ++ scripts/zlib/inflate.min.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/zlib/deflate.min.js b/scripts/zlib/deflate.min.js index 510a86d4..976694b4 100644 --- a/scripts/zlib/deflate.min.js +++ b/scripts/zlib/deflate.min.js @@ -1,3 +1,4 @@ +// @if function("buffer_compress") /** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';var n=void 0,w=!0,aa=this;function ba(f,d){var c=f.split("."),e=aa;!(c[0]in e)&&e.execScript&&e.execScript("var "+c[0]);for(var b;c.length&&(b=c.shift());)!c.length&&d!==n?e[b]=d:e=e[b]?e[b]:e[b]={}};var C="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;function K(f,d){this.index="number"===typeof d?d:0;this.e=0;this.buffer=f instanceof(C?Uint8Array:Array)?f:new (C?Uint8Array:Array)(32768);if(2*this.buffer.length<=this.index)throw Error("invalid index");this.buffer.length<=this.index&&ca(this)}function ca(f){var d=f.buffer,c,e=d.length,b=new (C?Uint8Array:Array)(e<<1);if(C)b.set(d);else for(c=0;c>>8&255]<<16|L[f>>>16&255]<<8|L[f>>>24&255])>>32-d:L[f]>>8-d);if(8>d+a)g=g<>d-m-1&1,8===++a&&(a=0,e[b++]=L[g],g=0,b===e.length&&(e=ca(this)));e[b]=g;this.buffer=e;this.e=a;this.index=b};K.prototype.finish=function(){var f=this.buffer,d=this.index,c;0M;++M){for(var N=M,S=N,ea=7,N=N>>>1;N;N>>>=1)S<<=1,S|=N&1,--ea;da[M]=(S<>>0}var L=da;function ia(f){this.buffer=new (C?Uint16Array:Array)(2*f);this.length=0}ia.prototype.getParent=function(f){return 2*((f-2)/4|0)};ia.prototype.push=function(f,d){var c,e,b=this.buffer,a;c=this.length;b[this.length++]=d;for(b[this.length++]=f;0b[e])a=b[c],b[c]=b[e],b[e]=a,a=b[c+1],b[c+1]=b[e+1],b[e+1]=a,c=e;else break;return this.length}; @@ -24,3 +25,4 @@ function qa(f){var d=new (C?Uint16Array:Array)(f.length),c=[],e=[],b=0,a,g,m,k;a Ka.prototype.f=function(){var f,d,c,e,b,a,g=0;a=this.a;switch(8){case 8:f=Math.LOG2E*Math.log(32768)-8;break;default:throw Error("invalid compression method");}d=f<<4|8;a[g++]=d;switch(8){case 8:switch(this.d){case V.NONE:e=0;break;case V.h:e=1;break;case V.g:e=2;break;default:throw Error("unsupported compression type");}break;default:throw Error("invalid compression method");}c=e<<6|0;a[g++]=c|31-(256*d+c)%31;var m=this.input;if("string"===typeof m){var k=m.split(""),p,t;p=0;for(t=k.length;p>>0;m=k}for(var u=1,l=0,h=m.length,q,s=0;0>>0;this.j.c=g;a=this.j.f();g=a.length;C&&(a=new Uint8Array(a.buffer),a.length<=g+4&&(this.a=new Uint8Array(a.length+4),this.a.set(a),a=this.a),a=a.subarray(0,g+4));a[g++]=b>>24&255;a[g++]=b>>16&255;a[g++]=b>>8&255;a[g++]=b&255;return a};ba("Zlib.Deflate",Ka);ba("Zlib.Deflate.compress",function(f,d){return(new Ka(f,d)).f()});ba("Zlib.Deflate.prototype.compress",Ka.prototype.f);var Ma={NONE:V.NONE,FIXED:V.h,DYNAMIC:V.g},Na,Oa,W,Pa;if(Object.keys)Na=Object.keys(Ma);else for(Oa in Na=[],W=0,Ma)Na[W++]=Oa;W=0;for(Pa=Na.length;Wa&&(a=b[p]),b[p]>=1;for(t=l;t>>=1;switch(b){case 0:var d=this.input,a=this.a,c=this.c,f=this.b,e=n,g=n,h=n,k=c.length,l=n;this.d=this.f=0;e=d[a++];e===n&&m(Error("invalid uncompressed block header: LEN (first byte)"));g=e;e=d[a++];e===n&&m(Error("invalid uncompressed block header: LEN (second byte)"));g|=e<<8;e=d[a++];e===n&&m(Error("invalid uncompressed block header: NLEN (first byte)"));h=e;e=d[a++];e===n&&m(Error("invalid uncompressed block header: NLEN (second byte)"));h|= @@ -13,4 +14,5 @@ w.prototype.e=function(){var b=new (u?Uint8Array:Array)(this.b-32768),d=this.b-3 w.prototype.z=function(b){var d,a=this.input.length/this.a+1|0,c,f,e,g=this.input,h=this.c;b&&("number"===typeof b.p&&(a=b.p),"number"===typeof b.u&&(a+=b.u));2>a?(c=(g.length-this.a)/this.o[2],e=258*(c/2)|0,f=ed&&(this.c.length=d),b=this.c);return this.buffer=b};function U(b,d){var a,c;this.input=b;this.a=0;if(d||!(d={}))d.index&&(this.a=d.index),d.verify&&(this.A=d.verify);a=b[this.a++];c=b[this.a++];switch(a&15){case V:this.method=V;break;default:m(Error("unsupported compression method"))}0!==((a<<8)+c)%31&&m(Error("invalid fcheck flag:"+((a<<8)+c)%31));c&32&&m(Error("fdict flag is not supported"));this.q=new w(b,{index:this.a,bufferSize:d.bufferSize,bufferType:d.bufferType,resize:d.resize})} -U.prototype.k=function(){var b=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(b[this.a++]<<24|b[this.a++]<<16|b[this.a++]<<8|b[this.a++])>>>0;var c=d;if("string"===typeof c){var f=c.split(""),e,g;e=0;for(g=f.length;e>>0;c=f}for(var h=1,k=0,l=c.length,q,p=0;0>>0&&m(Error("invalid adler-32 checksum"))}return d};var V=8;s("Zlib.Inflate",U);s("Zlib.Inflate.prototype.decompress",U.prototype.k);var W={ADAPTIVE:z.s,BLOCK:z.t},X,Y,Z,$;if(Object.keys)X=Object.keys(W);else for(Y in X=[],Z=0,W)X[Z++]=Y;Z=0;for($=X.length;Z<$;++Z)Y=X[Z],s("Zlib.Inflate.BufferType."+Y,W[Y]);}).call(this); //@ sourceMappingURL=inflate.min.js.map \ No newline at end of file +U.prototype.k=function(){var b=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(b[this.a++]<<24|b[this.a++]<<16|b[this.a++]<<8|b[this.a++])>>>0;var c=d;if("string"===typeof c){var f=c.split(""),e,g;e=0;for(g=f.length;e>>0;c=f}for(var h=1,k=0,l=c.length,q,p=0;0>>0&&m(Error("invalid adler-32 checksum"))}return d};var V=8;s("Zlib.Inflate",U);s("Zlib.Inflate.prototype.decompress",U.prototype.k);var W={ADAPTIVE:z.s,BLOCK:z.t},X,Y,Z,$;if(Object.keys)X=Object.keys(W);else for(Y in X=[],Z=0,W)X[Z++]=Y;Z=0;for($=X.length;Z<$;++Z)Y=X[Z],s("Zlib.Inflate.BufferType."+Y,W[Y]);}).call(this); //@ sourceMappingURL=inflate.min.js.map +// @endif From 62e336b685c2a7f3cb2f0e98c342f1c3a3acd081 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 16 Aug 2023 11:31:57 +0300 Subject: [PATCH 72/84] Apparently yyQueue is used solely for mp_grid_path, so can be omitted otherwise. --- scripts/yyQueue.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/yyQueue.js b/scripts/yyQueue.js index 1188f82d..2aa7f5d9 100644 --- a/scripts/yyQueue.js +++ b/scripts/yyQueue.js @@ -14,6 +14,7 @@ // // ********************************************************************************************************************** +// @if function("mp_grid_path") // ############################################################################################# /// Function: /// Create a new QUEUE @@ -98,4 +99,4 @@ yyQueue.prototype.peek = function () { return undefined; } }; - +// @endif mp From c09c24b2575866a1d04516dd23ecd8466c1c6267 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 16 Aug 2023 16:12:00 +0300 Subject: [PATCH 73/84] All these highscore variables aren't used. --- scripts/Globals.js | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index a86dc707..5abf3df3 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -869,12 +869,7 @@ Audio_WebAudio=1, g_pTempTPE =null, g_VirtualKeyDrawList =null, g_HighScoreValues =null, - g_HighScoreNames =null, - g_HiscoreCaption =null, g_HighscoreNobody =null, - g_HighscoreEscape =null, - g_HiscoreFont =null, - g_HiscoreFontStyle =null, g_Arguments =null, g_ArgumentIndex =null, g_ArgumentValue =null, @@ -914,7 +909,6 @@ Audio_WebAudio=1, g_AudioModel = Audio_Sound, // assign to true - g_HiscoreFontBorder =true, Draw_Automatic = true, // Whether to automatically draw the room each step // assign to false @@ -964,11 +958,6 @@ Audio_WebAudio=1, g_LastCanvasWidth = 0, g_LastCanvasHeight = 0, g_DynamicTileID = 0, - g_HiscoreBackgroundColour = 0, - g_HiscoreNewColour = 0, - g_HiscoreOtherColour = 0, - g_HiscoreFontSize = 0, - g_HiscoreBackground = 0, g_AsyncUserID = 0, g_LastEventpObject = 0, @@ -1214,17 +1203,7 @@ function InitAboyneGlobals() { g_HighScoreValues = []; g_HighScoreNames = []; - g_HiscoreCaption = "Hiscore Table"; g_HighscoreNobody = ""; - g_HighscoreEscape ="Press to Continue"; - g_HiscoreBackgroundColour = 0x000000; - g_HiscoreBackground = -1; - g_HiscoreNewColour = 0xffff00; - g_HiscoreOtherColour = 0xffffff; - g_HiscoreFont = "verdana"; - g_HiscoreFontSize = 16; - g_HiscoreFontStyle = ""; - g_HiscoreFontBorder = true; // @if function("draw_highscore") || function("highscore_*") highscore_clear(); From fafc082113be4f112e19382eae02c0a67a07dbd3 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 16 Aug 2023 16:13:30 +0300 Subject: [PATCH 74/84] No need to run splitter for show_message/show_question - no more hashtags. --- scripts/functions/Function_Debug.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/functions/Function_Debug.js b/scripts/functions/Function_Debug.js index f4ebd472..38ccf56f 100644 --- a/scripts/functions/Function_Debug.js +++ b/scripts/functions/Function_Debug.js @@ -437,7 +437,7 @@ function show_message(_txt) { var msg = yyGetString(_txt); if (!msg) return; - alert(SplitText(msg)); + alert(msg); } // ############################################################################################# @@ -487,13 +487,8 @@ function show_question_async(_str) { /// // ############################################################################################# function show_question(_str) { - _str = yyGetString(_str); - - if (!_str) { - _str = ""; - } if (window.confirm) { - return confirm(SplitText(_str)) ? 1.0 : 0.0; + return confirm(yyGetString(_str) || "") ? 1.0 : 0.0; } ErrorFunction("show_question()"); return 0; From 9b2c0d4c4508fe9ccedebbcd13b515a3ff9dc5e5 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Wed, 16 Aug 2023 16:14:41 +0300 Subject: [PATCH 75/84] Fonts are now optional --- scripts/LoadGame.js | 6 ++++++ scripts/functions/Function_Font.js | 1 - scripts/functions/Function_Game.js | 2 ++ scripts/functions/Function_String.js | 4 ++++ scripts/yyFont.js | 6 ++++++ scripts/yyGraphics.js | 2 ++ scripts/yyRoom.js | 3 ++- scripts/yyWebGL.js | 2 ++ 8 files changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index c8cc2215..9346674f 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -56,7 +56,9 @@ function InitAboyne() // @if feature("audio") g_pSoundManager = new yySoundManager(); // @endif audio + // @if feature("fonts") g_pFontManager = new yyFontManager(); + // @endif fonts g_pCollisionList = []; // @if feature("paths") g_pPathManager = new yyPathManager(); @@ -786,6 +788,7 @@ function LoadGame(_GameFile) } // Load Fonts + // @if feature("fonts") for(index=0; index<_GameFile.Fonts.length; index++ ){ g_pFontManager.Add( _GameFile.Fonts[index]); } @@ -798,6 +801,7 @@ function LoadGame(_GameFile) g_pFontManager.AddEmbedded(_GameFile.EmbeddedFonts[index]); } } + // @endif fonts //Make Rooms for (var index = 0; index < _GameFile.GMRooms.length; index++) @@ -950,6 +954,7 @@ function LoadGame(_GameFile) } } // @endif + // @if feature("fonts") if (pStore.FontIDs !== undefined) { for(var i = 0; i < pStore.FontIDs.length; i++) @@ -957,6 +962,7 @@ function LoadGame(_GameFile) pTGInfo.fonts[i] = pStore.FontIDs[i]; } } + // @endif fonts if (pStore.TilesetIDs !== undefined) { for(var i = 0; i < pStore.TilesetIDs.length; i++) diff --git a/scripts/functions/Function_Font.js b/scripts/functions/Function_Font.js index 9445968a..d4a09b0d 100644 --- a/scripts/functions/Function_Font.js +++ b/scripts/functions/Function_Font.js @@ -458,7 +458,6 @@ function font_get_name(_id) { if (!pFont) return ""; return pFont.pName; } -var font_name = font_get_name; // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js index 1ad8c218..66d59fd8 100644 --- a/scripts/functions/Function_Game.js +++ b/scripts/functions/Function_Game.js @@ -154,6 +154,7 @@ function highscore_save() { // ############################################################################################# function draw_highscore(_x1, _y1, _x2, _y2) { + // @if feature("fonts") _x1 = yyGetInt32(_x1); _y1 = yyGetInt32(_y1); _x2 = yyGetInt32(_x2); @@ -172,6 +173,7 @@ function draw_highscore(_x1, _y1, _x2, _y2) _y1 += dy; } g_pFontManager.halign = halign; + // @endif fonts } // ############################################################################################# diff --git a/scripts/functions/Function_String.js b/scripts/functions/Function_String.js index 187c57e0..d6abc80e 100644 --- a/scripts/functions/Function_String.js +++ b/scripts/functions/Function_String.js @@ -945,7 +945,11 @@ function string_count(_substr,_str) // ############################################################################################# function string_hash_to_newline( _str ) { + // @if feature("fonts") return String_Replace_Hash(yyGetString(_str), g_pFontManager.Font_Get(g_pFontManager.fontid), true); + // @else + return String_Replace_Hash(yyGetString(_str), null, true); + // @endif fonts } // ############################################################################################# diff --git a/scripts/yyFont.js b/scripts/yyFont.js index 0b682581..a72941cf 100644 --- a/scripts/yyFont.js +++ b/scripts/yyFont.js @@ -21,6 +21,7 @@ /// /// In: // ############################################################################################# +// @if feature("fonts") /** @constructor */ function yyFont( ) { @@ -1161,6 +1162,7 @@ yyFont.prototype.Draw_Sprite_String_GL = function (_x, _y, _pStr, _xscale, _ysca } // @endif }; +// @endif fonts @@ -1194,6 +1196,7 @@ yyFont.prototype.Draw_Sprite_String_GL = function (_x, _y, _pStr, _xscale, _ysca /// Create a new Font manager /// // ############################################################################################# +// @if feature("fonts") /** @constructor */ function yyFontManager( ) { @@ -1370,6 +1373,7 @@ yyFontManager.prototype.Get = function( _id ) { } return null; }; +// @endif fonts // ############################################################################################# @@ -1437,6 +1441,7 @@ function String_Replace_Hash(str, thefont, _override_zeus) /// /// // ############################################################################################# +// @if feature("fonts") yyFontManager.prototype.Split_TextBlock = function (_pStr, linewidth, thefont) { if (_pStr == null) return; @@ -2202,3 +2207,4 @@ yyFontManager.prototype.GR_Text_Sizes = function (_str, x, y, linesep, linewidth w = thefont.TextWidth(pStr, true); if (g_ActualTextWidth < w) g_ActualTextWidth = w; }; +// @endif fonts diff --git a/scripts/yyGraphics.js b/scripts/yyGraphics.js index dab29e06..daca4e6c 100644 --- a/scripts/yyGraphics.js +++ b/scripts/yyGraphics.js @@ -202,7 +202,9 @@ function Graphics_Init( _canvas ) Graphics_DrawPart = Graphics_DrawPart_RELEASE; Graphics_Save = Graphics_Save_RELEASE; Graphics_Restore = Graphics_Restore_RELEASE; + // @if feature("fonts") Graphics_DrawText = Graphics_DrawText_RELEASE; + // @endif fonts Graphics_StartFrame = Graphics_StartFrame_RELEASE; Graphics_EndFrame = Graphics_EndFrame_RELEASE; Graphics_DrawComment = Graphics_DrawComment_RELEASE; diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 66bb31e8..2396e77d 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -2901,7 +2901,7 @@ yyRoom.prototype.HandleSequenceParticle = function (_rect, _layer, _pSequenceEl, }; yyRoom.prototype.HandleSequenceText = function (_rect, _layer, _pSequenceEl, _node, _track, _headPosition, _lastHeadPosition, _headDirection, _sequence) { - + // @if feature("fonts") var keyframeStore = _track.m_keyframeStore; var keyframeIndex = keyframeStore.GetKeyframeIndexAtFrame(_headPosition, _sequence.m_length); @@ -3153,6 +3153,7 @@ yyRoom.prototype.HandleSequenceText = function (_rect, _layer, _pSequenceEl, _no draw_set_font(oldFontID); draw_set_color(oldCol); draw_set_alpha(oldAlpha); + // @endif fonts }; // @endif sequences diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index a6364e59..e520563c 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -131,7 +131,9 @@ function InitWebGLFunctions() { Graphics_PushMatrix = WebGL_PushMatrix_RELEASE; Graphics_Save = WebGL_Save_RELEASE; Graphics_Restore = WebGL_Restore_RELEASE; + // @if feature("fonts") Graphics_DrawText = WebGL_DrawText_RELEASE; + // @endif fonts Graphics_StartFrame = WebGL_StartFrame_RELEASE; Graphics_EndFrame = WebGL_EndFrame_RELEASE; Graphics_DrawComment = WEBGL_DrawComment_RELEASE; From 6e8c5f14ef8d3841d4d8b4b6cc430e38d28da54f Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Thu, 17 Aug 2023 17:37:23 +0300 Subject: [PATCH 76/84] Sprites (along with the rest of sequence code) are now optional --- scripts/LoadGame.js | 6 + scripts/Storage.js | 2 + scripts/_GameMaker.js | 4 + scripts/functions/Function_Layers.js | 13 +- scripts/functions/Function_Physics.js | 6 +- scripts/functions/Function_Sprite.js | 19 +- scripts/yyASync.js | 5 +- scripts/yyEffects.js | 6 + scripts/yyInstance.js | 240 ++++++++++++++------------ scripts/yyParticle.js | 3 +- scripts/yyRoom.js | 20 ++- scripts/yySequence.js | 11 +- scripts/yySprite.js | 2 + 13 files changed, 211 insertions(+), 126 deletions(-) diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index 9346674f..00d211df 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -50,7 +50,9 @@ function InitAboyne() g_pInstanceManager = new yyInstanceManager(); g_pObjectManager = new yyObjectManager(); g_pRoomManager = new yyRoomManager(); + // @if feature("sprites") g_pSpriteManager = new yySpriteManager(); + // @endif sprites g_pTextureGroupInfoManager = new yyTextureGroupInfoManager(); g_pBackgroundManager = new yyBackgroundManager(); // @if feature("audio") @@ -770,6 +772,7 @@ function LoadGame(_GameFile) Graphics_SetEntryTable(_GameFile.TPageEntries); // Load Sprites + // @if feature("sprites") for(index=0; index<_GameFile.Sprites.length; index++ ){ if( _GameFile.Sprites[index]===null ){ g_pSpriteManager.AddSprite( null ); @@ -778,6 +781,7 @@ function LoadGame(_GameFile) g_pSpriteManager.AddSprite( pSprite ); } } + // @endif sprites // Load Backgrounds @@ -938,6 +942,7 @@ function LoadGame(_GameFile) pTGInfo.textures[i] = g_YYTextures[pStore.TextureIDs[i]]; // need to remap the texture IDs here } } + // @if feature("sprites") if (pStore.SpriteIDs !== undefined) { for(var i = 0; i < pStore.SpriteIDs.length; i++) @@ -945,6 +950,7 @@ function LoadGame(_GameFile) pTGInfo.sprites[i] = pStore.SpriteIDs[i]; } } + // @endif sprites // @if feature("spine") if (pStore.SpineSpriteIDs !== undefined) { diff --git a/scripts/Storage.js b/scripts/Storage.js index 0b719104..f1289273 100644 --- a/scripts/Storage.js +++ b/scripts/Storage.js @@ -52,6 +52,7 @@ function TPE_Copy(_pTPE) } +// @if feature("sprites") /** @constructor */ function YYSprite() { @@ -71,6 +72,7 @@ function YYSprite() this.yOrigin = 0; this.TPageEntrys = []; // followed by count * (YYTPageEntry*) } +// @endif sprites /** @constructor */ diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 38172728..912bcbbd 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -1642,7 +1642,9 @@ function GameMaker_DoAStep() { g_pBuiltIn.delta_time = (g_CurrentTime - g_pBuiltIn.last_time)*1000; g_pBuiltIn.last_time = g_CurrentTime; + // @if feature("sequences_min") ResetSpriteMessageEvents(); + // @endif sequences_min g_pIOManager.StartStep(); HandleOSEvents(); @@ -1714,7 +1716,9 @@ function GameMaker_DoAStep() { UpdateActiveLists(); if (New_Room != -1) return; + // @if feature("sequences_min") ProcessSpriteMessageEvents(); + // @endif sequences_min UpdateInstancePositions(); diff --git a/scripts/functions/Function_Layers.js b/scripts/functions/Function_Layers.js index a298c510..32a2dddb 100644 --- a/scripts/functions/Function_Layers.js +++ b/scripts/functions/Function_Layers.js @@ -452,9 +452,11 @@ LayerManager.prototype.RemoveElementFromLayer= function(_room,_el,_layer,_remove case eLayerElementType_OldTilemap: this.RemoveOldTilemapElement(layer,element); break; + // @if feature("sprites") case eLayerElementType_Sprite: this.RemoveSpriteElement(layer,element); break; + // @endif sprites case eLayerElementType_Tilemap: this.RemoveTilemapElement(layer,element); break; @@ -464,9 +466,11 @@ LayerManager.prototype.RemoveElementFromLayer= function(_room,_el,_layer,_remove case eLayerElementType_Tile: this.RemoveTileElement(layer,element); break; + // @if feature("sequences") case eLayerElementType_Sequence: this.RemoveSequenceElement(layer,element); - break; + break; + // @endif }; // This doesn't exist just now - need to implement @@ -1516,8 +1520,10 @@ LayerManager.prototype.UpdateLayers = function() //el.m_pBackground.image_index += el.m_pBackground.image_speed; } } + // @if feature("sprites") else if (type == eLayerElementType_Sprite) { + var sprite = g_pSpriteManager.Get(el.m_spriteIndex); if (sprite.sequence != null) @@ -1566,6 +1572,7 @@ LayerManager.prototype.UpdateLayers = function() } } } + // @endif sprites else if( type == eLayerElementType_Tilemap) { var back = g_pBackgroundManager.GetImage(el.m_backgroundIndex); @@ -1875,6 +1882,7 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers) this.AddNewElement(_room,NewLayer,NewTileLayer,false);*/ } + // @if feature("sprites") var numsprites = 0; if(pLayer.scount!=undefined) numsprites = pLayer.scount; if(numsprites>0) @@ -1906,6 +1914,7 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers) } } + // @endif sprites // Sequences // @if feature("sequences") @@ -2807,6 +2816,7 @@ function layer_sprite_index( arg1,arg2) el.m_imageIndex = yyGetInt32(arg2); var frame = yyGetInt32(arg2); + // @if feature("sprites") var sprite = g_pSpriteManager.Get(el.m_spriteIndex); if (sprite != null) @@ -2842,6 +2852,7 @@ function layer_sprite_index( arg1,arg2) } } else + // @endif sprites { el.m_imageIndex = frame; // just use value as-is } diff --git a/scripts/functions/Function_Physics.js b/scripts/functions/Function_Physics.js index b9320f36..d067cb36 100644 --- a/scripts/functions/Function_Physics.js +++ b/scripts/functions/Function_Physics.js @@ -1025,11 +1025,12 @@ function physics_particle_group_delete(ind) { /// // ############################################################################################# function physics_particle_draw(typemask, category, sprite, subimg) { - + // @if feature("sprites") var pSpr = g_pSpriteManager.Get(yyGetInt32(sprite)); if (pSpr !== null) { g_RunRoom.m_pPhysicsWorld.DrawParticles(yyGetInt32(typemask), yyGetInt32(category), pSpr, yyGetInt32(subimg)); } + // @endif sprites } // ############################################################################################# @@ -1037,11 +1038,12 @@ function physics_particle_draw(typemask, category, sprite, subimg) { /// // ############################################################################################# function physics_particle_draw_ext(typemask, category, sprite, subimg, xscale, yscale, angle, col, alpha) { - + // @if feature("sprites") var pSpr = g_pSpriteManager.Get(yyGetInt32(sprite)); if (pSpr !== null) { g_RunRoom.m_pPhysicsWorld.DrawParticlesExt(yyGetInt32(typemask), yyGetInt32(category), pSpr, yyGetInt32(subimg), yyGetReal(xscale), yyGetReal(yscale), yyGetReal(angle), yyGetInt32(col), yyGetReal(alpha)); } + // @endif sprites } // ############################################################################################# diff --git a/scripts/functions/Function_Sprite.js b/scripts/functions/Function_Sprite.js index acaea3ee..a1d4493b 100644 --- a/scripts/functions/Function_Sprite.js +++ b/scripts/functions/Function_Sprite.js @@ -33,8 +33,11 @@ var MASK_PRECISE = 0, // ############################################################################################# function sprite_exists( _index ) { - if( g_pSpriteManager.Get(yyGetInt32(_index)) == null ) return false; - return true; + // @if feature("sprites") + return g_pSpriteManager.Get(yyGetInt32(_index)) != null; + // @else + return false; + // @endif sprites } @@ -51,9 +54,11 @@ function sprite_exists( _index ) // ############################################################################################# function sprite_get_width( _index ) { + // @if feature("sprites") var pSpr = g_pSpriteManager.Get(yyGetInt32(_index)); - if( pSpr==null) return 0; - return pSpr.width; + if( pSpr!=null) return pSpr.width; + // @endif sprites + return 0; } @@ -69,9 +74,11 @@ function sprite_get_width( _index ) // ############################################################################################# function sprite_get_height( _index ) { + // @if feature("sprites") var pSpr = g_pSpriteManager.Get(yyGetInt32(_index)); - if( pSpr==null) return 0; - return pSpr.height; + if( pSpr!=null) return pSpr.height;; + // @endif sprites + return 0; } diff --git a/scripts/yyASync.js b/scripts/yyASync.js index fe66c2de..71aecdca 100644 --- a/scripts/yyASync.js +++ b/scripts/yyASync.js @@ -104,7 +104,7 @@ function ASync_ImageLoad_Callback(_event) { pFile.m_Complete = true; pFile.m_Status = ASYNC_STATUS_LOADED; - + // @if feature("sprites") if( pFile.m_Type == ASYNC_SPRITE ) { // Now actually UPDATE the sprite and TPage stuff. @@ -170,6 +170,7 @@ function ASync_ImageLoad_Callback(_event) { } return; } + // @endif sprites if( pFile.m_Type == ASYNC_BACKGROUND ) { @@ -379,7 +380,9 @@ yyASyncManager.prototype.Process = function () { } if (pFile.m_Type == ASYNC_IMAGE) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_IMAGE_LOAD, 0, true); // Throw an event for the image + // @if feature("sprites") else if (pFile.m_Type == ASYNC_SPRITE) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_IMAGE_LOAD, 0, true); // Throw an event for the image + // @endif sprites else if (pFile.m_Type == ASYNC_BACKGROUND) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_IMAGE_LOAD, 0, true); // Throw an event for the image else if (pFile.m_Type == ASYNC_SOUND) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_SOUND_LOAD, 0, true); else if (pFile.m_Type == ASYNC_WEB) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_ASYNC, 0, true); diff --git a/scripts/yyEffects.js b/scripts/yyEffects.js index ecad57e1..973b9b86 100644 --- a/scripts/yyEffects.js +++ b/scripts/yyEffects.js @@ -543,6 +543,7 @@ yyFilterHost.prototype.LayerEnd = function (_layerID) } break; case FAE_PARAM_SAMPLER: { + // @if feature("sprites") var spriteID = pVar; var pSprite = g_pSpriteManager.Get(spriteID); if ((pSprite != null) && (pSprite.SWFTimeline === undefined) && (pSprite.m_skeletonSprite === undefined)) @@ -581,6 +582,7 @@ yyFilterHost.prototype.LayerEnd = function (_layerID) args[1].kind = VALUE_PTR; args[1].ptr = YYGetPtr(pVar, 0); F_Shader_Set_Texture(res, NULL, NULL, 2, args);*/ + // @endif sprites } break; } } @@ -831,12 +833,14 @@ yyEffectInstance.prototype.SetParam = function (_pParamName, _type, _elements, _ case FAE_PARAM_FLOAT: pEntry = _data[j]; break; case FAE_PARAM_INT: pEntry = _data[j]; break; case FAE_PARAM_BOOL: pEntry = _data[j] ? 1 : 0; break; + // @if feature("sprites") case FAE_PARAM_SAMPLER: { var spriteID = g_pSpriteManager.Sprite_Find(_data[j]); pEntry = spriteID; break; } + // @endif sprites } pVar.push(pEntry); @@ -849,12 +853,14 @@ yyEffectInstance.prototype.SetParam = function (_pParamName, _type, _elements, _ case FAE_PARAM_FLOAT: pVar = _data[0]; break; case FAE_PARAM_INT: pVar = _data[0]; break; case FAE_PARAM_BOOL: pVar = _data[0] ? 1 : 0; break; + // @if feature("sprites") case FAE_PARAM_SAMPLER: { var spriteID = g_pSpriteManager.Sprite_Find(_data[0]); pVar = spriteID; break; } + // @endif sprites } } diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index c10ba354..5ea01d73 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -431,7 +431,7 @@ yyInstance.prototype = { set image_index(_frame) { _frame = yyGetReal(_frame); - + // @if feature("sprites") var sprite = g_pSpriteManager.Get(this.sprite_index); if (sprite != null) @@ -468,6 +468,7 @@ yyInstance.prototype = { } } else + // @endif sprites { this.__image_index = _frame; // just use value as-is } @@ -494,50 +495,57 @@ yyInstance.prototype = { // image_number property (no setter) get image_number() { + // @if feature("sprites") var pSprite = g_pSpriteManager.Get(this.sprite_index); - if (!pSprite) return 0; - - // @if feature("spine") - var skeletonAnim = this.SkeletonAnimation(); - if (skeletonAnim) { - return skeletonAnim.FrameCount(pSprite); - } - // @endif spine - // @if feature("swf") - if ((pSprite.SWFTimeline !== null) && (pSprite.SWFTimeline !== undefined)) { - return pSprite.SWFTimeline.numFrames; + if (pSprite) { + // @if feature("spine") + var skeletonAnim = this.SkeletonAnimation(); + if (skeletonAnim) return skeletonAnim.FrameCount(pSprite); + // @endif spine + // @if feature("swf") + if (pSprite.SWFTimeline != null) return pSprite.SWFTimeline.numFrames; + // @endif + return pSprite.ppTPE.length; } - // @endif - return pSprite.ppTPE.length; + // @endif sprites + return 0; }, // sprite_width property get sprite_width() { + // @if feature("sprites") var pSprite = g_pSpriteManager.Get(this.sprite_index); - if (!pSprite) return 0; - return pSprite.width * this.image_xscale; + if (pSprite) return pSprite.width * this.image_xscale; + // @endif sprites + return 0; }, // sprite_height property get sprite_height() { + // @if feature("sprites") var pSprite = g_pSpriteManager.Get(this.sprite_index); - if (!pSprite) return 0; - return pSprite.height * this.image_yscale; + if (pSprite) return pSprite.height * this.image_yscale; + // @endif sprites + return 0; }, // sprite_xoffset property get sprite_xoffset() { + // @if feature("sprites") var pSprite = g_pSpriteManager.Get(this.sprite_index); - if (!pSprite) return 0; - return pSprite.xOrigin * this.image_xscale; + if (pSprite) return pSprite.xOrigin * this.image_xscale; + // @endif sprites + return 0; }, // sprite_yoffset property get sprite_yoffset() { + // @if feature("sprites") var pSprite = g_pSpriteManager.Get(this.sprite_index); - if (!pSprite) return 0; - return pSprite.yOrigin * this.image_yscale; + if (pSprite) return pSprite.yOrigin * this.image_yscale; + // @endif sprites + return 0; }, // image_xscale property @@ -945,7 +953,7 @@ yyInstance.prototype.SetObjectIndex = function (_objindex, _LinkToObjectType, _S /// // ############################################################################################# yyInstance.prototype.UpdateSpriteIndex = function (_index) { - + // @if feature("sprites") var pSprite = g_pSpriteManager.Get(_index); if (pSprite) { this.bbox.left = pSprite.bbox.left; @@ -953,6 +961,7 @@ yyInstance.prototype.UpdateSpriteIndex = function (_index) { this.bbox.top = pSprite.bbox.top; this.bbox.bottom = pSprite.bbox.bottom; } + // @endif sprites this.sprite_index = _index; this.m_pSkeletonAnimation = null; @@ -1002,7 +1011,6 @@ yyInstance.prototype.BuildPhysicsBody = function () { if (!sprite_exists(this.sprite_index)) { return; } - var spr = g_pSpriteManager.Get(this.sprite_index); // Without a physics world we won't get far if (!g_RunRoom.m_pPhysicsWorld) { @@ -1221,14 +1229,18 @@ yyInstance.prototype.AdaptSpeed = function () { /// // ############################################################################################# yyInstance.prototype.GetImageNumber = function () { - var pSprite = g_pSpriteManager.Get(this.sprite_index); + // @if feature("sprites") // @if feature("spine") var skeletonAnim = this.SkeletonAnimation(); if (skeletonAnim) { + var pSprite = g_pSpriteManager.Get(this.sprite_index); return skeletonAnim.FrameCount(pSprite); } // @endif spine return g_pSpriteManager.GetImageCount(this.sprite_index); + // @else + return 0; + // @endif sprites }; // ############################################################################################# @@ -1464,7 +1476,9 @@ yyInstance.prototype.Compute_BoundingBox = function() { var spr, t; var ix = (this.mask_index >= 0) ? this.mask_index : this.sprite_index; + // @if feature("sprites") if (ix < 0 || ix > g_pSpriteManager.Sprites.length) { + // @endif sprites if (!this.bbox) { this.bbox = new YYRECT(0, 0, 0, 0); @@ -1475,6 +1489,7 @@ yyInstance.prototype.Compute_BoundingBox = function() { this.bbox.bottom = this.y; this.colcheck = yySprite_CollisionType.AXIS_ALIGNED_RECT; + // @if feature("sprites") } else { @@ -1632,7 +1647,8 @@ yyInstance.prototype.Compute_BoundingBox = function() { this.colcheck = spr.colcheck; } this.bbox = bbox; - } + } + // @endif sprites this.bbox_dirty = false; }; @@ -1710,6 +1726,8 @@ yyInstance.prototype.Collision_Point = function (_x, _y, _prec) { return false; } } + var Result = false; + // @if feature("sprites") var pSpr; if (this.mask_index < 0) { @@ -1726,7 +1744,6 @@ yyInstance.prototype.Collision_Point = function (_x, _y, _prec) { // handle precise collision tests - var Result = false; // @if feature("spine") var collisionSkel = this.GetCollisionSkeleton(); if (collisionSkel !== null) { @@ -1741,6 +1758,7 @@ yyInstance.prototype.Collision_Point = function (_x, _y, _prec) { Round(_x), Round(_y) ); } + // @endif sprites return Result; }; @@ -1765,6 +1783,7 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec) this.Maybe_Compute_BoundingBox(); // easy cases first + var Result = false; var bbox = this.bbox; var col_delta = 0; //To avoid floating point inaccuracies @@ -1801,6 +1820,7 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec) return Result; } + // @if feature("sprites") var pSpr; if (this.mask_index < 0) { pSpr = g_pSpriteManager.Get(this.sprite_index); @@ -1835,8 +1855,7 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec) } // handle precise collision tests - var Result = false; - // @if feature("spine") + // @if feature("spine") var collisionSkel = this.GetCollisionSkeleton(); if (collisionSkel !== null) { Result = collisionSkel.RectangleCollision(this.CollisionImageIndex(), this.x, this.y, @@ -1854,6 +1873,7 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec) Result = pSpr.PreciseCollisionRectangle(Math.floor(this.image_index), bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, g_rr); } + // @endif sprites return Result; }; @@ -1952,6 +1972,7 @@ yyInstance.prototype.Collision_Ellipse = function (_x1, _y1, _x2, _y2, _prec) { return false; } + // @if feature("sprites") var pSpr; if (this.mask_index < 0) { pSpr = g_pSpriteManager.Get(this.sprite_index); @@ -1983,6 +2004,8 @@ yyInstance.prototype.Collision_Ellipse = function (_x1, _y1, _x2, _y2, _prec) { { return pSpr.PreciseCollisionEllipse(Math.floor(this.image_index), bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, g_rr); } + // @endif sprites + return false; }; @@ -2044,6 +2067,7 @@ yyInstance.prototype.Collision_Line = function (_x1, _y1, _x2, _y2, _prec) { if ((_y1 < i_bbox.top) && (_y2 < i_bbox.top)) { return false; } if ((_y1 >= i_bbox.bottom + 1) && (_y2 >= i_bbox.bottom + 1)) { return false; } + // @if feature("sprites") var pSpr; if (this.mask_index < 0) { pSpr = g_pSpriteManager.Get(this.sprite_index); @@ -2071,6 +2095,8 @@ yyInstance.prototype.Collision_Line = function (_x1, _y1, _x2, _y2, _prec) { } // @endif return pSpr.PreciseCollisionLine(this.image_index | 0, i_bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, Round(_x1), Round(_y1), Round(_x2), Round(_y2)); + // @endif sprites + return false; }; @@ -2095,7 +2121,7 @@ yyInstance.prototype.Collision_Skeleton = function (inst, prec) // If the other instance doesn't actually have a sprite then we can't do precise collision testing with it - var spr1 = g_pSpriteManager.Get(this.sprite_index); + // @if feature("sprites") var spr2 = (inst.mask_index < 0) ? g_pSpriteManager.Get(inst.sprite_index) : g_pSpriteManager.Get(inst.mask_index); @@ -2122,11 +2148,13 @@ yyInstance.prototype.Collision_Skeleton = function (inst, prec) // @endif spine /* inst/spr2 is using bounding box collisions - no more to do. */ return true; + // @endif sprites + return false; }; yyInstance.prototype.Animate = function() { - + // @if feature("sprites") if(g_isZeus) { var pImage = g_pSpriteManager.Get( this.sprite_index ); @@ -2148,6 +2176,7 @@ yyInstance.prototype.Animate = function() { return; } } + // @endif sprites // BUGFIX: 30634 If we have no valid image set, increment image_index anyway just like in the Win32 runner this.image_index += this.image_speed; @@ -2504,6 +2533,7 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) { } // dealing with precise collision checking + // @if feature("sprites") var pSpr1 = null; var pSpr2 = null; if (this.mask_index < 0) { @@ -2571,6 +2601,7 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) { _pInst.image_angle); // @endif } + // @endif sprites } return false; }; @@ -2826,19 +2857,17 @@ yyInstance.prototype.get_bbox = function () { // ############################################################################################# yyInstance.prototype.wrap = function(_hor, _vert) { - var w, h; + var w = 0, h = 0; // find the sprite size - if (!sprite_exists(this.sprite_index)) - { - w = h =0; - } - else + // @if feature("sprites") + if (sprite_exists(this.sprite_index)) { var pSpr = g_pSpriteManager.Get(this.sprite_index); w = pSpr.width * this.image_xscale; h = pSpr.height * this.image_yscale; } + // @endif sprites // do horizontal wrap if (_hor) @@ -3507,86 +3536,79 @@ yyInstanceManager.prototype.UpdateImages = function () { if (pInst.marked) continue; if (!pInst.active) continue; + // @if feature("sprites") var sprite = g_pSpriteManager.Get(pInst.sprite_index); - - var usesSpriteSequences = false; - - if (sprite != null) + if (sprite?.sequence != null) { - if(sprite.sequence != null) - { - /* - var sequence_image_index = pInst.sequence_pos; - if ((sprite.sequence.m_tracks != null) && (sprite.sequence.m_tracks[0].m_type == eSTT_SpriteFrames)) - { - var pTrack = sprite.sequence.m_tracks[0]; - var pKey = pTrack.m_keyframeStore.GetKeyframeAtFrame(pInst.sequence_pos, sprite.sequence.m_length); - if (pKey == null) - { - pInst.SetImageIndex(-1); // no key at this time - } - else if(pTrack.m_numTracks > 0) - { - sequence_image_index = pTrack.m_tracks[0].getValue(0, pInst.sequence_pos, sprite.sequence.m_length); - - if (Math.abs(pInst.image_index - sequence_image_index) > g_GMLMathEpsilon) - { - var newseqpos = ConvertImageIndexToSequencePos(pInst, sprite, pInst.image_index); - SetNewSequencePosition(pInst, sprite, newseqpos, true); - } - } - } - */ - var sequence_image_index = pInst.sequence_pos; - if ((sprite.sequence.m_tracks != null) && (sprite.sequence.m_tracks[0].m_type == eSTT_SpriteFrames)) - { - var pTrack = sprite.sequence.m_tracks[0]; - if (pTrack != null) - { - sequence_image_index = pTrack.getValue(pInst.sequence_pos); - - if (Math.abs(pInst.image_index - sequence_image_index)>g_GMLMathEpsilon) - { - var numkeyframes = pTrack.m_keyframeStore.numKeyframes; - if (numkeyframes > 0) { - var keyindex = ~~(pInst.image_index); - var fracval = pInst.image_index - keyindex; - - var newseqpos = pInst.image_index; - if (keyindex >= numkeyframes) - { - newseqpos = pTrack.m_keyframeStore.keyframes[numkeyframes - 1].m_key + (pInst.image_index - (numkeyframes - 1)); - } - else if (keyindex < 0) - { - newseqpos = pInst.image_index; - } - else - newseqpos = (pTrack.m_keyframeStore.keyframes[keyindex].m_key + (fracval * pTrack.m_keyframeStore.keyframes[keyindex].m_length)); - - newseqpos = ConvertImageIndexToSequencePos(pInst, sprite, pInst.image_index); - SetNewSequencePosition(pInst, sprite, newseqpos, true); - } // end if - } - - } + /* + var sequence_image_index = pInst.sequence_pos; + if ((sprite.sequence.m_tracks != null) && (sprite.sequence.m_tracks[0].m_type == eSTT_SpriteFrames)) + { + var pTrack = sprite.sequence.m_tracks[0]; + var pKey = pTrack.m_keyframeStore.GetKeyframeAtFrame(pInst.sequence_pos, sprite.sequence.m_length); + if (pKey == null) + { + pInst.SetImageIndex(-1); // no key at this time + } + else if(pTrack.m_numTracks > 0) + { + sequence_image_index = pTrack.m_tracks[0].getValue(0, pInst.sequence_pos, sprite.sequence.m_length); + + if (Math.abs(pInst.image_index - sequence_image_index) > g_GMLMathEpsilon) + { + var newseqpos = ConvertImageIndexToSequencePos(pInst, sprite, pInst.image_index); + SetNewSequencePosition(pInst, sprite, newseqpos, true); + } } + } + */ + var sequence_image_index = pInst.sequence_pos; + if ((sprite.sequence.m_tracks != null) && (sprite.sequence.m_tracks[0].m_type == eSTT_SpriteFrames)) + { + var pTrack = sprite.sequence.m_tracks[0]; + if (pTrack != null) + { + sequence_image_index = pTrack.getValue(pInst.sequence_pos); + + if (Math.abs(pInst.image_index - sequence_image_index)>g_GMLMathEpsilon) + { + var numkeyframes = pTrack.m_keyframeStore.numKeyframes; + if (numkeyframes > 0) { + var keyindex = ~~(pInst.image_index); + var fracval = pInst.image_index - keyindex; + + var newseqpos = pInst.image_index; + if (keyindex >= numkeyframes) + { + newseqpos = pTrack.m_keyframeStore.keyframes[numkeyframes - 1].m_key + (pInst.image_index - (numkeyframes - 1)); + } + else if (keyindex < 0) + { + newseqpos = pInst.image_index; + } + else + newseqpos = (pTrack.m_keyframeStore.keyframes[keyindex].m_key + (fracval * pTrack.m_keyframeStore.keyframes[keyindex].m_length)); + + newseqpos = ConvertImageIndexToSequencePos(pInst, sprite, pInst.image_index); + SetNewSequencePosition(pInst, sprite, newseqpos, true); + } // end if + } - usesSpriteSequences = true; + } + } - var fps = g_GameTimer.GetFPS(); + var fps = g_GameTimer.GetFPS(); - // Get sequence length - var length = sprite.sequence.m_length; - - var seqSpeed = sprite.sequence.m_playbackSpeed; - if (sprite.sequence.m_playbackSpeedType == ePlaybackSpeedType_FramesPerSecond) seqSpeed /= fps; + // Get sequence length + var length = sprite.sequence.m_length; + + var seqSpeed = sprite.sequence.m_playbackSpeed; + if (sprite.sequence.m_playbackSpeedType == ePlaybackSpeedType_FramesPerSecond) seqSpeed /= fps; - SetNewSequencePosition(pInst, sprite, (pInst.sequence_pos + (pInst.sequence_dir * pInst.image_speed * seqSpeed)), false); - } + SetNewSequencePosition(pInst, sprite, (pInst.sequence_pos + (pInst.sequence_dir * pInst.image_speed * seqSpeed)), false); } - - if(!usesSpriteSequences) + else + // @endif sprites { var num = pInst.GetImageNumber(); if (pInst.image_index >= num) { diff --git a/scripts/yyParticle.js b/scripts/yyParticle.js index a7c9279e..64a0f6c7 100644 --- a/scripts/yyParticle.js +++ b/scripts/yyParticle.js @@ -2912,8 +2912,9 @@ function DrawParticle(_pPartSys, _pParticle, _xoff, _yoff, _color, _alpha) if ( _pParticle.lifetime <= 0 ) return; var pParType = g_ParticleTypes[ _pParticle.parttype ]; - + // @if feature("sprites") spr = g_pSpriteManager.Get( pParType.sprite ); + // @endif sprites if( spr == null ) { var shape = pParType.shape; diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 2396e77d..ecca24d2 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -1078,6 +1078,7 @@ yyRoom.prototype.DrawLayerInstanceElement = function(_rect,_layer,_el) g_skeletonDrawInstance = null; } + // @if feature("sprites") else { @@ -1103,6 +1104,7 @@ yyRoom.prototype.DrawLayerInstanceElement = function(_rect,_layer,_el) } } + // @endif sprites } } // end if } @@ -1187,6 +1189,7 @@ yyRoom.prototype.DrawLayerBackgroundElement = function(_rect,_layer,_el) // Does this background have a sprite? + // @if feature("sprites") if (sprite_exists(back.index)) { // get sprite details @@ -1209,6 +1212,7 @@ yyRoom.prototype.DrawLayerBackgroundElement = function(_rect,_layer,_el) } } else + // @endif sprites { // Don't "just" clear - it doesn't respect the current viewport var oldAlpha = g_GlobalAlpha; @@ -1232,6 +1236,7 @@ yyRoom.prototype.DrawLayerBackgroundElement = function(_rect,_layer,_el) // ############################################################################################# yyRoom.prototype.DrawLayerSpriteElement = function(_rect,_layer,_el) { + // @if feature("sprites") if (sprite_exists(_el.m_spriteIndex)) { var pImage = g_pSpriteManager.Get( _el.m_spriteIndex ); @@ -1260,6 +1265,7 @@ yyRoom.prototype.DrawLayerSpriteElement = function(_rect,_layer,_el) } } } + // @endif sprites }; var g_DefaultCameraID = -1; @@ -2050,6 +2056,7 @@ yyRoom.prototype.DrawLayerParticleSystem = function(_rect,_layer,_el) yyRoom.prototype.DrawLayerTileElement = function (_rect, _layer, _el) { // TODO - cull according to screen rect + // @if feature("sprites") if (!_el.m_visible) return false; var pImage = g_pSpriteManager.Get(_el.m_index); if (pImage != null) { @@ -2101,6 +2108,7 @@ yyRoom.prototype.DrawLayerTileElement = function (_rect, _layer, _el) { graphics._drawImage(pTPE, pTPE.x + (_el.m_xo * scalex), pTPE.y + (_el.m_yo * scalex), _el.m_w * scalex, _el.m_h * scalex, _el.m_x, _el.m_y, _el.m_w * _el.m_imageScaleX, _el.m_h * _el.m_imageScaleY, col); }*/ } + // @endif sprites }; @@ -2291,7 +2299,7 @@ yyRoom.prototype.DrawTrackList = function (_rect, _layer, _pSequenceEl, _evalTre }; yyRoom.prototype.HandleSequenceGraphic = function (_rect, _layer, _pSequenceEl, _node, _track, _headPosition, _lastHeadPosition, _headDirection, _sequence) { - + // @if feature("sprites") var keyframeStore = _track.m_keyframeStore; var keyframeIndex = keyframeStore.GetKeyframeIndexAtFrame(_headPosition, _sequence.m_length); @@ -2478,6 +2486,7 @@ yyRoom.prototype.HandleSequenceGraphic = function (_rect, _layer, _pSequenceEl, { WebGL_SetMatrix(MATRIX_WORLD, oldworldmat); } + // @endif sprites }; @@ -2787,6 +2796,7 @@ yyRoom.prototype.HandleSequenceInstance = function (_rect, _layer, _pSequenceEl, //if (!pInst.PerformEvent(EVENT_DRAW, 0, pInst, pInst)) if( !pInst.REvent[EVENT_DRAW] ) { + // @if feature("sprites") // Otherwise just DRAW it.. var pSprite = g_pSpriteManager.Get(pInst.sprite_index); if (pSprite) @@ -2806,6 +2816,7 @@ yyRoom.prototype.HandleSequenceInstance = function (_rect, _layer, _pSequenceEl, ); } } + // @endif sprites } else { @@ -3211,10 +3222,12 @@ yyRoom.prototype.DrawRoomLayers = function(_rect){ { this.DrawLayerOldTilemapElement(_rect,player,el); } + // @if feature("sprites") else if(el.m_type === eLayerElementType_Sprite) { this.DrawLayerSpriteElement(_rect,player,el,0,0,0); } + // @endif sprites else if(el.m_type === eLayerElementType_Tilemap) { this.DrawLayerTilemapElement(_rect,player,el); @@ -3289,6 +3302,7 @@ yyRoom.prototype.DrawTheRoom = function (_rect) { // ############################################################################################# yyRoom.prototype.DrawUserCursor = function () { // Draw USER curser + // @if feature("sprites") if (g_CurrentCursor >= 0) { var pSpr = g_pSpriteManager.Get(g_CurrentCursor); @@ -3299,6 +3313,7 @@ yyRoom.prototype.DrawUserCursor = function () { g_CurrentCursorFrame++; if (g_CurrentCursorFrame > pSpr.numb) g_CurrentCursorFrame -= pSpr.numb; } + // @endif sprites }; // ############################################################################################# @@ -3438,7 +3453,7 @@ function ResetLayerShader(shaderid) /// In: Rect to "fit" in // ############################################################################################# yyRoom.prototype.ExecuteDrawEvent = function (_rect, _event) { - var pSprite, pInst, i, pool, pSprites; + var pSprite, pInst, i, pool; Current_Event_Type = _event; @@ -3507,7 +3522,6 @@ yyRoom.prototype.ExecuteDrawEvent = function (_rect, _event) { pool = this.m_Active.pool; - pSprites = g_pSpriteManager.Sprites; for (i = pool.length - 1; i >= 0; i--) { diff --git a/scripts/yySequence.js b/scripts/yySequence.js index d8eaba47..b4351e73 100644 --- a/scripts/yySequence.js +++ b/scripts/yySequence.js @@ -34,6 +34,7 @@ function CHashMapCalculateHash(snap) /// dirtiness and signals when instances need to be updated due to changes. /// // ############################################################################################# +// @if feature("sequences_min") /** @constructor */ function CSequenceBaseClass() { @@ -167,7 +168,7 @@ SEQ_KEY_LENGTH_EPSILON = -0.0001; g_CurrSequenceID = 0; g_CurrAnimCurveID = 0; -// @endif +// @endif sequences // used to track which sequences have been changed and need to be recomputed g_CurrSequenceObjectID = 0; @@ -4467,7 +4468,7 @@ yySequenceManager.prototype.HandleUpdateTracks = function (_el, _sequence, _inst /// // ############################################################################################# yySequenceManager.prototype.HandleSpriteTrackUpdate = function(_node, _srcVars, _instance, _track, _fps, _headDir, _lastHeadPos, _headPosition, _seqlength) { - + // @if feature("sprites") _srcVars.spriteIndex = -1; var keyframeStore = _track.m_keyframeStore; @@ -4486,6 +4487,7 @@ yySequenceManager.prototype.HandleSpriteTrackUpdate = function(_node, _srcVars, if (!_srcVars.Overrides(eT_OriginY)) _srcVars.yOrigin += sprite.yOrigin; HandleSpriteSequenceMessageEvents(_node, _track, _instance, _fps, _headPosition, _lastHeadPos, _headDir, sprite.sequence, sprite, graphicKeyframe, keyframeStore); + // @endif sprites }; // @endif @@ -4968,6 +4970,7 @@ yySequenceManager.prototype.HandleInstanceTrackUpdate = function (_pEl, _pSeq, _ else if (_srcVars.paramset & (1< /// Create a new SPRITE object @@ -2183,3 +2184,4 @@ yySpriteManager.prototype.SkeletonLoad = function (_spineText) { } // @endif spine }; +// @endif sprites From 78442e6387d621b6f7c45362ea55f5b456e5d628 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Thu, 17 Aug 2023 17:37:55 +0300 Subject: [PATCH 77/84] json_encode/json_decode helpers are now omitted if unused --- scripts/_GameMaker.js | 2 +- scripts/functions/Function_File.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 912bcbbd..8316dba8 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -209,7 +209,7 @@ window.addEventListener( "unhandledrejection", yyUnhandledRejectionHandler ); //external access for js extensions -// @if feature("js_extensions") +// @if feature("extension_api") var GMS_API = { "debug_msg": show_debug_message, "ds_list_size": ds_list_size, diff --git a/scripts/functions/Function_File.js b/scripts/functions/Function_File.js index acf0150c..605da83a 100644 --- a/scripts/functions/Function_File.js +++ b/scripts/functions/Function_File.js @@ -1023,6 +1023,7 @@ const _regexp_int64_parse = new RegExp("@i64@([0-9a-f]+?)\\$i64\\$", "i"); // ########### JSON_ENCODE & JSON_DECODE ########### +// @if feature("extension_api") || function("json_decode") function _json_decode_value(value) { switch (typeof (value)) { @@ -1135,7 +1136,9 @@ function json_decode(_string) { } return _json_decode_object(pObj); } // end json_decode +// @endif json_decode +// @if feature("extension_api") || function("json_encode") var g_ENCODE_VISITED_LIST = new Map(); function _json_encode_value(value) { @@ -1256,6 +1259,7 @@ function json_encode(_map, _prettify) { return JSON.stringify(obj, null, _prettify ? 2 : 0); } // end json_encode +// @endif json_encode // ########### JSON_STRINGIFY & JSON_PARSE ########### From 406bbf95ffe25304f0a8a54cb8e9a5a2302f4e4d Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Sat, 19 Aug 2023 15:32:05 +0300 Subject: [PATCH 78/84] A simpler `string_replace_hash` (tested on `@"1\\#2#3\#4"`) --- scripts/functions/Function_String.js | 21 ++++++++--- scripts/yyFont.js | 54 ---------------------------- 2 files changed, 16 insertions(+), 59 deletions(-) diff --git a/scripts/functions/Function_String.js b/scripts/functions/Function_String.js index d6abc80e..03846e78 100644 --- a/scripts/functions/Function_String.js +++ b/scripts/functions/Function_String.js @@ -945,11 +945,22 @@ function string_count(_substr,_str) // ############################################################################################# function string_hash_to_newline( _str ) { - // @if feature("fonts") - return String_Replace_Hash(yyGetString(_str), g_pFontManager.Font_Get(g_pFontManager.fontid), true); - // @else - return String_Replace_Hash(yyGetString(_str), null, true); - // @endif fonts + let _result = "", + _start = 0, + i = 0, c, lc; + for (; i < _str.length; i++) { + c = _str[i]; + if (c == "#") { + if (lc != "\\") { + _result += _str.substring(_start, i) + "\r\n"; + } else { + _result += _str.substring(_start, i - 1) + "#"; + } + _start = i + 1; + } + lc = c; + } + return _result + _str.substring(_start, i); } // ############################################################################################# diff --git a/scripts/yyFont.js b/scripts/yyFont.js index a72941cf..903d9d5a 100644 --- a/scripts/yyFont.js +++ b/scripts/yyFont.js @@ -1376,58 +1376,6 @@ yyFontManager.prototype.Get = function( _id ) { // @endif fonts -// ############################################################################################# -/// Function: -/// replaces hash marks with newline characters -/// -/// -/// In: Start to parse -/// font to get sizes and mapping from -/// In: override the GMS2 setting? -/// Out: -/// converted string or the original one back again -/// -// ############################################################################################# -function String_Replace_Hash(str, thefont, _override_zeus) -{ - // don't convert anything in ZEUS - unless we come from string_hash_to_newline() function... - if (_override_zeus === undefined) _override_zeus = false; - if( _override_zeus==false && g_isZeus) return str; - - if ( str == null) return 0; - - var pS = str; - var pD = ""; - var i=0; - var si = 0; - - while(si 0) && (pS[si-1] == '\\')) - { - pD = pD.substring(0,pD.length-1)+'#'; // the length doesn't change here, so we don't need curr++ - } - else - { - pD += String.fromCharCode(0x0d); - pD += String.fromCharCode(0x0a); - i++; - } - } - else - { - pD += s; - i++; - } - si++; - } - return pD; -} - - // ############################################################################################# /// Function: @@ -1455,7 +1403,6 @@ yyFontManager.prototype.Split_TextBlock = function (_pStr, linewidth, thefont) { var sl_index = 0; // put newlines in - if(!g_isZeus) _pStr = String_Replace_Hash(_pStr, thefont); var len = _pStr.length; // Allocate new space @@ -1599,7 +1546,6 @@ yyFontManager.prototype.Split_TextBlock_IDEstyle = function (_pStr, _boundsWidth var sl = []; // put newlines in - if(!g_isZeus) _pStr = String_Replace_Hash(_pStr, this.thefont); var len = _pStr.length; // Allocate new space From 7a9a5103f280371e8af08915a3ecc9d2e0f23ad8 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Sat, 19 Aug 2023 15:42:14 +0300 Subject: [PATCH 79/84] Removed some of the GMS1-specific code sitting behind a flag --- scripts/Effects.js | 32 ++--- scripts/Events.js | 39 ------ scripts/Globals.js | 12 +- scripts/LoadGame.js | 7 +- scripts/_GameMaker.js | 13 +- scripts/functions/Function_D3D.js | 7 +- scripts/functions/Function_Physics.js | 21 +--- scripts/functions/Function_Surface.js | 32 ++--- scripts/yyBuiltIn.js | 4 +- scripts/yyInstance.js | 24 +--- scripts/yyRoom.js | 170 +++----------------------- scripts/yyView.js | 65 ++++------ scripts/yyWebGL.js | 29 ++--- 13 files changed, 84 insertions(+), 371 deletions(-) diff --git a/scripts/Effects.js b/scripts/Effects.js index 66f76c9f..e0a4efce 100644 --- a/scripts/Effects.js +++ b/scripts/Effects.js @@ -58,32 +58,14 @@ var types_created = false, // whether the types have been create // ############################################################################################# function Speed_Factor() { - if(g_isZeus) - { - - if( ( g_GameTimer.GetFPS() <= 30) || (Fps <= 30) ){ - return 1.0; - } - - if( (g_GameTimer.GetFPS()/ Fps) < 1.2 ){ - return 30.0/g_GameTimer.GetFPS(); - }else{ - return 30.0/Fps; - } - } - else - { - - - if( ( g_RunRoom.GetSpeed() <= 30) || (Fps <= 30) ){ - return 1.0; - } + if( ( g_GameTimer.GetFPS() <= 30) || (Fps <= 30) ){ + return 1.0; + } - if( (g_RunRoom.GetSpeed() / Fps) < 1.2 ){ - return 30.0/g_RunRoom.GetSpeed(); - }else{ - return 30.0/Fps; - } + if( (g_GameTimer.GetFPS()/ Fps) < 1.2 ){ + return 30.0/g_GameTimer.GetFPS(); + }else{ + return 30.0/Fps; } } diff --git a/scripts/Events.js b/scripts/Events.js index 65b5640d..0ffc7559 100644 --- a/scripts/Events.js +++ b/scripts/Events.js @@ -380,45 +380,6 @@ function HandleCollision() }*/ -// ############################################################################################# -/// Function: -/// Given a point, do a collision test with each instance that has the desired -/// event. (mouse click etc). -/// -/// -/// In: Primary event -/// Secondary event -/// X Point to test with -/// Y Point to test with -/// -// ############################################################################################# -function DoPointToInstance( _event, _sub_event, _x,_y ) -{ - // First scale the coordinate into the current screen scale. - //_x = _x * scale; - - // Might be better to loop through objects, rather than active instances... less getSprite stuff... - for(var i=g_RunRoom.m_Active.length-1;i>=0;i-- ) - { - var pInst = g_RunRoom.m_Active.Get(i); - // with( pInst ) - { - if (pInst.bbox_dirty) pInst.Compute_BoundingBox(); - if (!pInst.marked && pInst.pObject.REvent[_event | _sub_event]) - { - var pSprite = g_pSpriteManager.Get( pInst.sprite_index ); - var ox = pSprite.xOrigin; - var oy = pSprite.yOrigin; - if ((_x >= pInst.bbox.left) && (_x < pInst.bbox.right) && (_y >= pInst.bbox.top) && (_y < pInst.bbox.bottom)) - { - pInst.PerformEvent(_event, _sub_event, pInst, pInst); // timer enum starts at 1.. - } - } - } - } -} - - // ############################################################################################# /// Function: diff --git a/scripts/Globals.js b/scripts/Globals.js index 5abf3df3..b43b55c5 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1252,17 +1252,7 @@ function InitAboyneGlobals() { g_room_maxid = 100000; g_GlobalAlpha = 1.0; - if(g_isZeus) - { - draw_set_color(g_pGMFile.Options.DrawColour); - } - else - { - g_GlobalColour_GM = 0x00000000; - g_GlobalColour = 0x000000; // 0xffffff; - g_GlobalColour_HTML_RGB = GetHTMLRGB(g_GlobalColour); - g_GlobalColour_HTML_RGBA = GetHTMLRGBA(g_GlobalColour,g_GlobalAlpha); - } + draw_set_color(g_pGMFile.Options.DrawColour); c_black = GetHTMLRGB(0x000000); c_white = GetHTMLRGB(0xffffff); diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js index 00d211df..a665d559 100644 --- a/scripts/LoadGame.js +++ b/scripts/LoadGame.js @@ -87,11 +87,8 @@ function InitAboyne() Audio_Init(); // @endif audio - if (g_isZeus) - { - g_pCameraManager.Clean(); - CreateDefaultCamera(); - } + g_pCameraManager.Clean(); + CreateDefaultCamera(); } diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 8316dba8..8eb8d984 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -2244,17 +2244,8 @@ function GameMaker_Tick() } // - var TargetSpeed; - if (g_isZeus) { - g_GameTimer.Update(); - TargetSpeed = g_GameTimer.GetFPS(); - } else { - TargetSpeed = g_RunRoom.GetSpeed(); - if (TargetSpeed <= 0) { - TargetSpeed = 1; - g_RunRoom.SetSpeed(1); - } - } + g_GameTimer.Update(); + var TargetSpeed = g_GameTimer.GetFPS(); const last_time_ms = g_CurrentTime; g_CurrentTime = Date.now(); diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js index 268979f1..49e2fc7e 100644 --- a/scripts/functions/Function_D3D.js +++ b/scripts/functions/Function_D3D.js @@ -364,12 +364,7 @@ function InitD3DFunctions() { function WebGL_d3d_set_depth_RELEASE(_newdepth) { // _depth is a new depth value used for drawing... - if (GR_3DMode || g_isZeus) { - GR_Depth = Math.min(16000.0, Math.max(-16000.0, _newdepth) ); - } - else { - GR_Depth = 0.0; - } + GR_Depth = Math.min(16000.0, Math.max(-16000.0, _newdepth) ); } // ############################################################################################# diff --git a/scripts/functions/Function_Physics.js b/scripts/functions/Function_Physics.js index d067cb36..9d9d3ca0 100644 --- a/scripts/functions/Function_Physics.js +++ b/scripts/functions/Function_Physics.js @@ -28,26 +28,11 @@ function physics_world_create(_pixelToMetreScale) { if (g_RunRoom.m_pPhysicsWorld) { g_RunRoom.m_pPhysicsWorld.SetPixelToMetreScale(_pixelToMetreScale); - if(g_isZeus) - { - g_RunRoom.m_pPhysicsWorld.SetUpdateSpeed(g_GameTimer.GetFPS()); - } - else - { - g_RunRoom.m_pPhysicsWorld.SetUpdateSpeed(g_RunRoom.GetSpeed()); - } + g_RunRoom.m_pPhysicsWorld.SetUpdateSpeed(g_GameTimer.GetFPS()); } else { - if(g_isZeus) - { - var physicsWorld = new yyPhysicsWorld(_pixelToMetreScale, g_GameTimer.GetFPS()); - g_RunRoom.m_pPhysicsWorld = physicsWorld; - } - else - { - var physicsWorld = new yyPhysicsWorld(_pixelToMetreScale, g_RunRoom.GetSpeed()); - g_RunRoom.m_pPhysicsWorld = physicsWorld; - } + var physicsWorld = new yyPhysicsWorld(_pixelToMetreScale, g_GameTimer.GetFPS()); + g_RunRoom.m_pPhysicsWorld = physicsWorld; } } diff --git a/scripts/functions/Function_Surface.js b/scripts/functions/Function_Surface.js index 0c0edace..45470158 100644 --- a/scripts/functions/Function_Surface.js +++ b/scripts/functions/Function_Surface.js @@ -525,12 +525,7 @@ function surface_set_target_RELEASE(_id) Graphics_SetViewPort(0, 0, pSurf.m_Width, pSurf.m_Height); - if (g_isZeus) { - UpdateDefaultCamera(0, 0, pSurf.m_Width, pSurf.m_Height, 0); - } - else { - Graphics_SetViewArea(0, 0, pSurf.m_Width, pSurf.m_Height, 0); - } + UpdateDefaultCamera(0, 0, pSurf.m_Width, pSurf.m_Height, 0); if (g_webGL) g_webGL.Flush(); DirtyRoomExtents(); @@ -606,22 +601,17 @@ function surface_reset_target_RELEASE() Calc_GUI_Scale(); } else { Graphics_SetViewPort(g_clipx, g_clipy, g_clipw, g_cliph); - if (g_isZeus) { - var currcam = g_pCameraManager.GetActiveCamera(); - if ((activeCam == true) && (currcam != null)) - { - UpdateCamera(camx, camy, camw, camh, cama, currcam); - currcam.SetViewMat(new Matrix(camviewmat)); - currcam.SetProjMat(new Matrix(camprojmat)); - currcam.ApplyMatrices(); - } - else - { - UpdateDefaultCamera(g_worldx, g_worldy, g_worldw, g_worldh, 0); - } + var currcam = g_pCameraManager.GetActiveCamera(); + if ((activeCam == true) && (currcam != null)) + { + UpdateCamera(camx, camy, camw, camh, cama, currcam); + currcam.SetViewMat(new Matrix(camviewmat)); + currcam.SetProjMat(new Matrix(camprojmat)); + currcam.ApplyMatrices(); } - else { - Graphics_SetViewArea(g_worldx, g_worldy, g_worldw, g_worldh, 0); + else + { + UpdateDefaultCamera(g_worldx, g_worldy, g_worldw, g_worldh, 0); } } } diff --git a/scripts/yyBuiltIn.js b/scripts/yyBuiltIn.js index f445c1a7..71aa7f94 100644 --- a/scripts/yyBuiltIn.js +++ b/scripts/yyBuiltIn.js @@ -278,8 +278,8 @@ yyBuiltIn.prototype.getbackground_blend = function () { return g_pBuiltIn.backgr yyBuiltIn.prototype.getbackground_alpha = function () { return g_pBuiltIn.background_alpha[0]; }; -yyBuiltIn.prototype.set_room_speed = function (_val) { _val = yyGetReal(_val); if (g_isZeus) { return g_GameTimer.SetFrameRate(_val); } else { return g_RunRoom.SetSpeed(_val); } }; -yyBuiltIn.prototype.get_room_speed = function (_val) { if (g_isZeus) { return g_GameTimer.GetFPS(_val); } else { return g_RunRoom.m_speed; } }; +yyBuiltIn.prototype.set_room_speed = function (_val) { _val = yyGetReal(_val); return g_GameTimer.SetFrameRate(yyGetReal(_val)); }; +yyBuiltIn.prototype.get_room_speed = function (_val) { return g_GameTimer.GetFPS(_val); }; yyBuiltIn.prototype.set_room_caption = function (_val) { return g_RunRoom.SetCaption(yyGetString(_val)); }; yyBuiltIn.prototype.set_room_width = function (_val) { return g_RunRoom.SetWidth(yyGetReal(_val)); }; diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js index 5ea01d73..9d6d5b1c 100644 --- a/scripts/yyInstance.js +++ b/scripts/yyInstance.js @@ -925,18 +925,6 @@ yyInstance.prototype.SetObjectIndex = function (_objindex, _LinkToObjectType, _S // and copy the data over... this.mask_index = this.pObject.SpriteMask; - if(!g_isZeus) - { - //Zeus, no object has a depth defined - if (_SetDepthNow) - { - // RK :: set the underlying variable rather than going through the property - this.__depth = this.pObject.Depth; - } else - { - this.depth = this.pObject.Depth; - } - } this.solid = this.pObject.Solid; this.visible = this.pObject.Visible; this.persistent = this.pObject.Persistent; @@ -2923,9 +2911,7 @@ yyInstance.prototype.ApplyVisualOffset = function (_angle, _visualOffs) { // @if feature("physics") yyInstance.prototype.RefreshPhysicalProperties = function (_physicsBody) { - var TargetSpeed =g_RunRoom.GetSpeed(); - if(g_isZeus) - TargetSpeed = g_GameTimer.GetFPS(); + var TargetSpeed = g_GameTimer.GetFPS(); var metreToPixelScale = 1.0 / g_RunRoom.m_pPhysicsWorld.m_pixelToMetreScale; @@ -3028,9 +3014,7 @@ yyInstance.prototype.set_physics_linear_velocity_y = function(_vel) { // ############################################################################################# yyInstance.prototype.set_physics_speed_x = function(_speed) { - var TargetSpeed = g_RunRoom.GetSpeed(); - if(g_isZeus) - TargetSpeed = g_GameTimer.GetFPS(); + var TargetSpeed = g_GameTimer.GetFPS(); this.m_physicsObject.SetLinearVelocityX(yyGetReal(_speed) * g_RunRoom.m_pPhysicsWorld.m_pixelToMetreScale * TargetSpeed); this.RefreshPhysicalProperties(this.m_physicsObject.m_physicsBody); @@ -3044,9 +3028,7 @@ yyInstance.prototype.set_physics_speed_x = function(_speed) { yyInstance.prototype.set_physics_speed_y = function(_speed) { - var TargetSpeed = g_RunRoom.GetSpeed(); - if(g_isZeus) - TargetSpeed = g_GameTimer.GetFPS(); + var TargetSpeed = g_GameTimer.GetFPS(); this.m_physicsObject.SetLinearVelocityY(yyGetReal(_speed) * g_RunRoom.m_pPhysicsWorld.m_pixelToMetreScale * TargetSpeed); this.RefreshPhysicalProperties(this.m_physicsObject.m_physicsBody); }; diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index ecca24d2..486a3f27 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -518,15 +518,7 @@ yyRoom.prototype.BuildPhysicsWorld = function() { // evaluates to true if value is not: null, undefined, NaN, empty string, 0, false if (this.m_pStorage.physicsWorld) { - - if(g_isZeus) - { - this.m_pPhysicsWorld = new yyPhysicsWorld(this.m_pStorage.physicsPixToMeters, g_GameTimer.GetFPS()); - } - else - { - this.m_pPhysicsWorld = new yyPhysicsWorld(this.m_pStorage.physicsPixToMeters, this.GetSpeed()); - } + this.m_pPhysicsWorld = new yyPhysicsWorld(this.m_pStorage.physicsPixToMeters, g_GameTimer.GetFPS()); this.m_pPhysicsWorld.SetGravity(this.m_pStorage.physicsGravityX, this.m_pStorage.physicsGravityY); } }; @@ -943,87 +935,6 @@ yyRoom.prototype.UpdateViews = function () { } } } - else if ((pView.visible) && (pView.objid >= 0)) - { - // Find the pInstance to follow - pInst = null; - if (pView.objid < 100000) - { - // if they selected an OBJECT, then pick the 1st unmarked one! - var pObj = g_pObjectManager.Get(pView.objid); - if (pObj != null) - { - var pool = pObj.GetRPool(); - for (var o = 0; o < pool.length; o++) - { - pInst = pool[o]; - if (!pInst.marked) break; // if NOT marked, use this one! - pInst = null; // makes sure we can tell we found one - } - } - - } - else // pView object is an pInstance - { - pInst = g_pInstanceManager.Get(pView.objid); - if (!pInst && pInst.marked) pInst = null; - } - - // if we have an object to follow.... then follow it! - if (pInst != null) - { - // Find the new position - l = pView.worldx; - t = pView.worldy; - ix = pInst.x; - iy = pInst.y; - - if (2 * pView.hborder >= pView.worldw) - { - l = ix - pView.worldw / 2; - } else if (ix - pView.hborder < pView.worldx) - { - l = ix - pView.hborder; - } else if (ix + pView.hborder > pView.worldx + pView.worldw) - { - l = ix + pView.hborder - pView.worldw; - } - - if (2 * pView.vborder >= pView.worldh) - { - t = iy - pView.worldh / 2; - } else if (iy - pView.vborder < pView.worldy) - { - t = iy - pView.vborder; - } else if (iy + pView.vborder > pView.worldy + pView.worldh) - { - t = iy + pView.vborder - pView.worldh; - } - - - // Make sure it does not extend beyond the room - if (l < 0) l = 0; - if (l + pView.worldw > this.m_width) l = this.m_width - pView.worldw; - if (t < 0) t = 0; - if (t + pView.worldh > this.m_height) t = this.m_height - pView.worldh; - - // Restrict motion speed - if (pView.hspeed >= 0) - { - if ((l < pView.worldx) && (pView.worldx - l > pView.hspeed)) l = pView.worldx - pView.hspeed; - if ((l > pView.worldx) && (l - pView.worldx > pView.hspeed)) l = pView.worldx + pView.hspeed; - } - if (pView.vspeed >= 0) - { - if ((t < pView.worldy) && (pView.worldy - t > pView.vspeed)) t = pView.worldy - pView.vspeed; - if ((t > pView.worldy) && (t - pView.worldy > pView.vspeed)) t = pView.worldy + pView.vspeed; - } - pView.worldx = l; - pView.worldy = t; - - } //if (pInst != null) - - } // if((pView.visible) && (pView.objid>=0)) } @@ -3634,13 +3545,8 @@ yyRoom.prototype.DrawViews = function (r) { Graphics_SetViewPort(0, 0, g_ApplicationWidth, g_ApplicationHeight); - if (g_isZeus) { - g_DefaultView.cameraID = g_DefaultCameraID; - UpdateDefaultCamera(0, 0, g_RunRoom.m_width, g_RunRoom.m_height, 0); - } - else { - Graphics_SetViewArea(0, 0, g_RunRoom.m_width, g_RunRoom.m_height, 0); - } + g_DefaultView.cameraID = g_DefaultCameraID; + UpdateDefaultCamera(0, 0, g_RunRoom.m_width, g_RunRoom.m_height, 0); } else { @@ -3701,51 +3607,17 @@ yyRoom.prototype.DrawViews = function (r) { g_pCurrentView.portw * sx, g_pCurrentView.porth * sy ); } - if(g_isZeus/* && (g_webGL!=null)*/) - { - g_pCameraManager.SetActiveCamera(g_pCurrentView.cameraID); - var pCam = g_pCameraManager.GetActiveCamera(); - if(pCam!=null) - { - pCam.Begin(); - pCam.ApplyMatrices(); - } - } - else - Graphics_SetViewArea(g_pCurrentView.worldx, g_pCurrentView.worldy, g_pCurrentView.worldw, g_pCurrentView.worldh, g_pCurrentView.angle); - - if(/*(g_webGL==null) || */(!g_isZeus)) - { - // no Angle allowed on view....unless it's webgl... - if( Math.abs( g_pCurrentView.angle) < 0.001) - { - r.left = g_pCurrentView.worldx; - r.top = g_pCurrentView.worldy; - r.right = g_pCurrentView.worldx + g_pCurrentView.worldw; - r.bottom = g_pCurrentView.worldy + g_pCurrentView.worldh; - } - else - { - // We need a larger area here to make sure we draw enough - calculate extents from rotation - var rad = g_pCurrentView.angle * (Pi/180); - var s = Math.abs( Math.sin(rad)); - var c = Math.abs( Math.cos(rad)); - var ex = (c * g_pCurrentView.worldw) + (s * g_pCurrentView.worldh); - var ey = (s * g_pCurrentView.worldw) + (c * g_pCurrentView.worldh); - r.left = g_pCurrentView.worldx + (g_pCurrentView.worldw - ex)/2; - r.right = g_pCurrentView.worldx + (g_pCurrentView.worldw + ex)/2; - r.top = g_pCurrentView.worldy + (g_pCurrentView.worldh - ey)/2; - r.bottom = g_pCurrentView.worldy + (g_pCurrentView.worldh + ey)/2; - } - g_pBuiltIn.view_current = i; - this.DrawTheRoom(r); - } - else - { + g_pCameraManager.SetActiveCamera(g_pCurrentView.cameraID); + var pCam = g_pCameraManager.GetActiveCamera(); + if(pCam!=null) + { + pCam.Begin(); + pCam.ApplyMatrices(); + } - g_pBuiltIn.view_current = i; - this.DrawTheRoom(g_roomExtents); - } + + g_pBuiltIn.view_current = i; + this.DrawTheRoom(g_roomExtents); if (g_pCurrentView.surface_id != -1) { @@ -3754,16 +3626,12 @@ yyRoom.prototype.DrawViews = function (r) { Current_View++; - if (g_isZeus) - { - - var pCam = g_pCameraManager.GetActiveCamera(); - if(pCam!=null) - { - pCam.End(); - } - g_pCameraManager.SetActiveCamera(-1); // no active camera - } + var pCam = g_pCameraManager.GetActiveCamera(); + if(pCam!=null) + { + pCam.End(); + } + g_pCameraManager.SetActiveCamera(-1); // no active camera } Graphics_Restore(); diff --git a/scripts/yyView.js b/scripts/yyView.js index 43cdc31b..b687accf 100644 --- a/scripts/yyView.js +++ b/scripts/yyView.js @@ -103,35 +103,25 @@ yyView.prototype.GetMouseCoord = function(_x,_y,_horizontal) { _x = (_x - pRect.left - this.scaledportx) / (pRect.scaleX || 1); _y = (_y - pRect.top - this.scaledporty) / (pRect.scaleY || 1); - if (g_isZeus) { - var cam = g_pCameraManager.GetCamera(this.cameraID); - if (cam == null) return 0; - // - var clipX = _x / this.scaledportw; - var clipY = _y / this.scaledporth; - clipX = clipX * 2.0 - 1.0; - clipY = clipY * 2.0 - 1.0; - - // Now backtransform into room space - var invViewProj = cam.GetInvViewProjMat(); + var cam = g_pCameraManager.GetCamera(this.cameraID); + if (cam == null) return 0; + // + var clipX = _x / this.scaledportw; + var clipY = _y / this.scaledporth; + clipX = clipX * 2.0 - 1.0; + clipY = clipY * 2.0 - 1.0; + + // Now backtransform into room space + var invViewProj = cam.GetInvViewProjMat(); - // we're treating z as 0 and w as 1 - var out; - if (_horizontal) { - out = ((clipX * invViewProj.m[_11]) + (clipY * invViewProj.m[_21]) + invViewProj.m[_41]); - } else { - out = ((clipX * invViewProj.m[_12]) + (clipY * invViewProj.m[_22]) + invViewProj.m[_42]); - } - return Math.floor(out); + // we're treating z as 0 and w as 1 + var out; + if (_horizontal) { + out = ((clipX * invViewProj.m[_11]) + (clipY * invViewProj.m[_21]) + invViewProj.m[_41]); } else { - if (_horizontal) { - _x /= this.WorldViewScaleX; - return _x + this.worldx; - } else { - _y /= this.WorldViewScaleY; - return _y + this.worldy; - } + out = ((clipX * invViewProj.m[_12]) + (clipY * invViewProj.m[_22]) + invViewProj.m[_42]); } + return Math.floor(out); }; // ############################################################################################# @@ -182,20 +172,17 @@ function CreateViewFromStorage( _pViewStorage ) if( _pViewStorage.vspeed!=undefined ) view.vspeed = _pViewStorage.vspeed; if( _pViewStorage.index!=undefined ) view.objid = _pViewStorage.index; - if (g_isZeus) + // if we have a camera stored in the "storage" view, then clone that + if ( _pViewStorage.cameraID !== undefined && _pViewStorage.cameraID>=0) { + // Already been setup, so clone it... don't mess around with the storage one + view.cameraID = g_pCameraManager.CloneCamera(_pViewStorage.cameraID); + } + else { - // if we have a camera stored in the "storage" view, then clone that - if ( _pViewStorage.cameraID !== undefined && _pViewStorage.cameraID>=0) { - // Already been setup, so clone it... don't mess around with the storage one - view.cameraID = g_pCameraManager.CloneCamera(_pViewStorage.cameraID); - } - else - { - // Create camera and attach it to the view - var pCam = g_pCameraManager.CreateCameraFromView(view); - pCam.SetCloned(true); - view.cameraID = pCam.GetID(); - } + // Create camera and attach it to the view + var pCam = g_pCameraManager.CreateCameraFromView(view); + pCam.SetCloned(true); + view.cameraID = pCam.GetID(); } return view; diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js index e520563c..f4434061 100644 --- a/scripts/yyWebGL.js +++ b/scripts/yyWebGL.js @@ -535,12 +535,9 @@ function WebGL_Save_RELEASE(_storeSettings) { g_savedWebGLState.GR_LightingEnabled = GR_LightingEnabled; g_savedWebGLState.GR_FogParameters = new Float32Array(GR_FogParameters); - if(g_isZeus) - { - g_savedWebGLState.GR_Cull=gpu_get_cullmode(); - g_savedWebGLState.GR_ZEnable=gpu_get_ztestenable(); - g_savedWebGLState.GR_ZWriteEnable=gpu_get_zwriteenable(); - } + g_savedWebGLState.GR_Cull=gpu_get_cullmode(); + g_savedWebGLState.GR_ZEnable=gpu_get_ztestenable(); + g_savedWebGLState.GR_ZWriteEnable=gpu_get_zwriteenable(); // Set to defaults GR_3DMode = false; @@ -579,22 +576,10 @@ function WebGL_Restore_RELEASE(_restoreSettings) { g_webGL.SetFogData(GR_FogParameters); // Setting either of these will flush the vertex buffer - if (GR_3DMode || g_isZeus) { - - - if(g_isZeus) - { - g_webGL.SetCull(g_savedWebGLState.GR_Cull); - g_webGL.SetZEnable(g_savedWebGLState.GR_ZEnable); - g_webGL.SetZWriteEnable(g_savedWebGLState.GR_ZWriteEnable); - } - else - { - g_webGL.SetZEnable(GR_ZEnable); - g_webGL.SetZWriteEnable(GR_ZWriteEnable); - g_webGL.SetCull(GR_Cull); - } - } + g_webGL.SetCull(g_savedWebGLState.GR_Cull); + g_webGL.SetZEnable(g_savedWebGLState.GR_ZEnable); + g_webGL.SetZWriteEnable(g_savedWebGLState.GR_ZWriteEnable); + g_webGL.SetShader(WebGL_GetDefaultShader()); } if (_restoreSettings.RestoreState) { From a3b34c7f7c9cf98b9950f76e9c72b868a1c0293e Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 22 Aug 2023 11:52:10 +0300 Subject: [PATCH 80/84] A few more conditions for various helper functions --- scripts/Globals.js | 2 ++ scripts/functions/Function_MotionPlanning.js | 2 ++ scripts/functions/Function_Physics.js | 2 ++ scripts/functions/Function_YoYo.js | 4 ++++ scripts/sound/WorkletNodeManager.js | 2 ++ scripts/utils/TimeRampedParamLinear.js | 2 ++ scripts/yyRoom.js | 14 ++++++++++---- scripts/yySound.js | 2 ++ 8 files changed, 26 insertions(+), 4 deletions(-) diff --git a/scripts/Globals.js b/scripts/Globals.js index b43b55c5..44353223 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1155,7 +1155,9 @@ function InitAboyneGlobals() { g_ParticleTextures = []; g_ParticleTypes = []; g_ParticleSystems = []; + // @if function("ds_grid_*") g_ActiveGrids = new yyAllocate(5); + // @endif g_ActivePriorityQueues = new yyAllocate(5); g_BufferStorage = new yyAllocate(5); g_ListCollection = new yyAllocate(5); diff --git a/scripts/functions/Function_MotionPlanning.js b/scripts/functions/Function_MotionPlanning.js index c81edc52..0fb7dba9 100644 --- a/scripts/functions/Function_MotionPlanning.js +++ b/scripts/functions/Function_MotionPlanning.js @@ -1298,6 +1298,7 @@ function mp_grid_path(_pInst, _id, _path, _xstart, _ystart, _xgoal, _ygoal, _all function mp_grid_to_ds_grid(_src, _dest) { + // @if function("ds_grid_*") _src = yyGetInt32(_src); _dest = yyGetInt32(_dest); @@ -1339,6 +1340,7 @@ function mp_grid_to_ds_grid(_src, _dest) pGrid.m_pGrid[x + (y * pGrid.m_Width)] = pMPGrid.m_cells[(x * pMPGrid.m_vcells) + y]; } } + // @endif } // @endif mp_grid diff --git a/scripts/functions/Function_Physics.js b/scripts/functions/Function_Physics.js index 9d9d3ca0..cfb78d2d 100644 --- a/scripts/functions/Function_Physics.js +++ b/scripts/functions/Function_Physics.js @@ -13,9 +13,11 @@ // 15/02/2012 1.0 CPH 1st version // // ********************************************************************************************************************** +// @if feature("physics") var g_physicsFixtures = new yyAllocate(); var g_physicsObjects = new yyAllocate(); var g_physicsJoints = new yyAllocate(); +// @endif // ############################################################################################# /// Function: diff --git a/scripts/functions/Function_YoYo.js b/scripts/functions/Function_YoYo.js index afecb314..44cfa2a0 100644 --- a/scripts/functions/Function_YoYo.js +++ b/scripts/functions/Function_YoYo.js @@ -943,7 +943,9 @@ function ds_exists(_ind, _type) { case eDS_TypeList: return (g_ListCollection.Get(_ind) ? 1.0 : 0.0); case eDS_TypeStack: return (g_StackCollection.Get(_ind) ? 1.0 : 0.0); case eDS_TypeQueue: return (g_ActiveQueues.Get(_ind) ? 1.0 : 0.0); + // @if function("ds_grid_*") case eDS_TypeGrid: return (g_ActiveGrids.Get(_ind) ? 1.0 : 0.0); + // @endif case eDS_TypePriority: return (g_ActivePriorityQueues.Get(_ind) ? 1.0 : 0.0); } return 0; @@ -1059,7 +1061,9 @@ function script_execute( _self, _other, _index ) return 0; } // end script_execute +// @if function("method_call") var method_call = script_execute_ext; +// @endif function script_execute_ext( _self, _other, _index, _array, _offset, _length ) { _offset = _offset || 0; diff --git a/scripts/sound/WorkletNodeManager.js b/scripts/sound/WorkletNodeManager.js index dc1842c1..229f645c 100644 --- a/scripts/sound/WorkletNodeManager.js +++ b/scripts/sound/WorkletNodeManager.js @@ -1,3 +1,4 @@ +// @if feature("audio") function WorkletNodeManager() { this.nodes = []; this.handle = setInterval(() => this.cleanup(), 5000); @@ -87,3 +88,4 @@ WorkletNodeManager.prototype.killNode = function(_node) { }; var g_WorkletNodeManager = new WorkletNodeManager(); +// @endif diff --git a/scripts/utils/TimeRampedParamLinear.js b/scripts/utils/TimeRampedParamLinear.js index ea5f4d86..2c7fd715 100644 --- a/scripts/utils/TimeRampedParamLinear.js +++ b/scripts/utils/TimeRampedParamLinear.js @@ -1,3 +1,4 @@ +// @if feature("audio") function TimeRampedParamLinear(_initialVal) { this.__val = _initialVal; this.__origin = _initialVal; @@ -46,3 +47,4 @@ TimeRampedParamLinear.prototype.update = function() { return this.__val; }; +// @endif diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 486a3f27..13a7a4bb 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -1581,6 +1581,7 @@ function draw_tile(_inst,_back,_tileindex,_frame,_x,_y) yyRoom.prototype.DrawLayerTilemapElement = function(_rect,_layer,_el,_xpos,_ypos,_depth) { + // @if feature("tilemaps") if(background_exists(_el.m_backgroundIndex)) { var backwidth = background_get_width(_el.m_backgroundIndex); @@ -1927,6 +1928,7 @@ yyRoom.prototype.DrawLayerTilemapElement = function(_rect,_layer,_el,_xpos,_ypos } } } + // @endif }; yyRoom.prototype.DrawLayerParticleSystem = function(_rect,_layer,_el) @@ -3129,20 +3131,22 @@ yyRoom.prototype.DrawRoomLayers = function(_rect){ { this.DrawLayerInstanceElement(_rect,player,el); } - else if(el.m_type === eLayerElementType_OldTilemap) - { - this.DrawLayerOldTilemapElement(_rect,player,el); - } + //else if(el.m_type === eLayerElementType_OldTilemap) + //{ + // this.DrawLayerOldTilemapElement(_rect,player,el); + //} // @if feature("sprites") else if(el.m_type === eLayerElementType_Sprite) { this.DrawLayerSpriteElement(_rect,player,el,0,0,0); } // @endif sprites + // @if feature("tilemaps") else if(el.m_type === eLayerElementType_Tilemap) { this.DrawLayerTilemapElement(_rect,player,el); } + // @endif else if(el.m_type === eLayerElementType_ParticleSystem) { this.DrawLayerParticleSystem(_rect,player,el); @@ -3151,10 +3155,12 @@ yyRoom.prototype.DrawRoomLayers = function(_rect){ { this.DrawLayerTileElement(_rect,player,el); } + // @if feature("sequences") else if (el.m_type === eLayerElementType_Sequence) { this.DrawLayerSequenceElement(_rect, player, el); } + // @endif } } diff --git a/scripts/yySound.js b/scripts/yySound.js index ca920dfd..d12975ed 100644 --- a/scripts/yySound.js +++ b/scripts/yySound.js @@ -60,6 +60,7 @@ function canPlayAudioMP3(callback) } } +// @if feature("audio") // ############################################################################################# /// Function: /// Initialise a Sound from storage @@ -728,3 +729,4 @@ yySoundManager.prototype.Create = function () { this.Sounds[this.Sounds.length] = pSnd; return this.Sounds.length - 1; }; +// @endif audio From 4cc14f8580be70c029c858347a6037487ad378a6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 22 Aug 2023 11:52:42 +0300 Subject: [PATCH 81/84] DrawLayerOldTilemapElement does nothing anyway, might as well move the comment. --- scripts/yyRoom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js index 13a7a4bb..a61a1287 100644 --- a/scripts/yyRoom.js +++ b/scripts/yyRoom.js @@ -1022,7 +1022,7 @@ yyRoom.prototype.DrawLayerInstanceElement = function(_rect,_layer,_el) }; yyRoom.prototype.DrawLayerOldTilemapElement = function(_rect,_layer,_el) { - //Don't have one of these in our project, so bit hard to test... +/* //Don't have one of these in our project, so bit hard to test... // LinkedList::iterator slabiter = _pOldTilemapEl->m_tiles.GetIterator(); // while (*slabiter != NULL) @@ -1040,7 +1040,7 @@ yyRoom.prototype.DrawLayerOldTilemapElement = function(_rect,_layer,_el) } -/* { + { CTileSlab* pSlab = *slabiter; RTile* pTiles = pSlab->m_Tiles; int numTiles = pSlab->m_nTilesUsed; From 22d19dd2273137bf4fe40c5b8ad21e180a2237fe Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 22 Aug 2023 13:04:06 +0300 Subject: [PATCH 82/84] A few more forgotten semicolons --- scripts/functions/Function_Surface.js | 4 ++-- scripts/yyGraphics.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/functions/Function_Surface.js b/scripts/functions/Function_Surface.js index 45470158..8a93f80f 100644 --- a/scripts/functions/Function_Surface.js +++ b/scripts/functions/Function_Surface.js @@ -1107,7 +1107,7 @@ surface_copy = (_destination,_x,_y,_source) => { pImg.drawImage(pSrc, yyGetInt32(_x), yyGetInt32(_y)); pImg.restore(); } -} +}; // @endif // ############################################################################################# @@ -1163,7 +1163,7 @@ surface_copy_part = (_destination,_x,_y, _source,_xs,_ys,_ws,_hs) => { pImg.drawImage(pSrc, _xs,_ys,_ws,_hs, _x, _y, _ws,_hs); pImg.restore(); } -} +}; // @endif function SurfaceFormatSupported(_format) diff --git a/scripts/yyGraphics.js b/scripts/yyGraphics.js index daca4e6c..286920ad 100644 --- a/scripts/yyGraphics.js +++ b/scripts/yyGraphics.js @@ -1242,7 +1242,7 @@ Graphics_TextureDrawPos = function(_pTPE, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4 graphics.globalAlpha = _alpha; drawTexturedTriangle(pTexture, _x1, _y1, _x2, _y2, _x3, _y3, _pTPE.x, _pTPE.y, _pTPE.x + _pTPE.w, _pTPE.y, _pTPE.x + _pTPE.w, _pTPE.y + _pTPE.h); drawTexturedTriangle(pTexture, _x3, _y3, _x4, _y4, _x1, _y1, _pTPE.x + _pTPE.w, _pTPE.y + _pTPE.h, _pTPE.x, _pTPE.y + _pTPE.h, _pTPE.x, _pTPE.y); -} +}; // ############################################################################################# From b034e657041fae3a30da165c0b377d19eb8d025a Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Tue, 19 Sep 2023 15:52:47 +0300 Subject: [PATCH 83/84] Added `compile_if_used`/`compile_if_weak_ref` pseudo-functions so that changes are compatible with old GMAC --- scripts/Globals.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/Globals.js b/scripts/Globals.js index a2a48d59..33197107 100644 --- a/scripts/Globals.js +++ b/scripts/Globals.js @@ -1031,6 +1031,13 @@ Audio_WebAudio=1, g_CanvasName = 'canvas', g_Hex='0123456789ABCDEF'; +/// With conditional compilation enabled, the call will be replaced with `expr` +/// if `ident` (typically the function name) is used in GML code and will be stripped otherwise. +/// If called with one argument, `expr` is presumed to be `ident` and `ident` is the first token +/// of the expression (like `fun` in `compile_if_used(fun = fun_impl)`) +function compile_if_used(ident, expr) {} +/// Akin to above, but works based on referenes in final JS code. +function compile_if_weak_ref(ident, expr) {} // ############################################################################################# /// Function: From 1d23edda163a0cd4cf7e6b970742112d4c63eab6 Mon Sep 17 00:00:00 2001 From: YellowAfterlife Date: Thu, 21 Sep 2023 12:26:25 +0300 Subject: [PATCH 84/84] Fixed a one-off error with using the runtime with current GMAC due to function definition order --- scripts/yyGraphics.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/yyGraphics.js b/scripts/yyGraphics.js index 286920ad..3f0946e9 100644 --- a/scripts/yyGraphics.js +++ b/scripts/yyGraphics.js @@ -1617,7 +1617,9 @@ function CopyImageToAlpha_RELEASE(_pDestTPE, _pSrcTPE) pDestImg.putImageData(DestDataLock, 0, 0); return true; } -compile_if_used(sprite_set_alpha_from_sprite, CopyImageToAlpha = CopyImageToAlpha_RELEASE); +// @if function("sprite_set_alpha_from_sprite") +CopyImageToAlpha = CopyImageToAlpha_RELEASE; +// @endif // @endif