Skip to content

Commit

Permalink
Fix to load/save issue and bootstrap object requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
lostastro committed May 3, 2021
1 parent 5e6da07 commit 829efed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
8 changes: 5 additions & 3 deletions objects/o_InputCandy_startup_example/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Init_InputCandy_Advanced();


Init_InputCandy_Advanced({
init: function () {
// Setup actions for our test game

__IC.Action( "Jump", IC_B, IC_space, IC_mouse_right );
Expand All @@ -19,3 +18,6 @@ __IC.Action( "Dodge Low", IC_hat0_D, IC_key_S, IC_none );
__IC.Action( "Special", IC_Ltrigger, IC_key_E, IC_none );
__IC.Action( "Inventory", IC_Rshoulder, IC_key_I, IC_none );
__IC.Action( "Help/Menu", IC_back_select, IC_f1, IC_none );
}
}
);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions scripts/InputCandy/InputCandy.gml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See Notes > Note1 for more information
#macro __ICI __INPUTCANDY.internal

// 1. Initialize the "Advanced mode" with the following function call in a Room Creation or during initial game startup.
function Init_InputCandy_Advanced() { __Private_Init_InputCandy(); }
function Init_InputCandy_Advanced( bootstrap ) { __Private_Init_InputCandy(bootstrap); }

/*
InputCandy's advanced mode is relatively easy to use.
Expand Down Expand Up @@ -503,7 +503,7 @@ function ICDeviceTypeString(i) {

// Called "once" to initialize everything.

function __Private_Init_InputCandy() {
function __Private_Init_InputCandy( bootstrap ) {

global.SDLDB_Entries=0;
global.SDLDB=[];
Expand Down Expand Up @@ -829,6 +829,7 @@ __INPUTCANDY.directionals=[

__INPUTCANDY.SDL_GameControllerDB = [];

bootstrap.init();
__ICI.LoadSettings();

__ICI.Init();
Expand Down Expand Up @@ -2682,9 +2683,10 @@ function New_InputCandy_Private() {

PostLoadBinding: function( binding ) {
var new_json=json_parse(json_stringify(binding));
var action_for_index = __IC.GetAction( binding.action, binding.group );
new_json.action = action_for_index.index;
new_json.bound_action.index = action_for_index.index;
var action_index = __IC.GetAction( binding.action, binding.group );
if ( action_index < 0 ) return false;
new_json.action = action_index;
new_json.bound_action.index = action_index;
return new_json;
},

Expand All @@ -2693,7 +2695,6 @@ function New_InputCandy_Private() {
var new_jsonifiable={
action: action.name,
group: action.group,
rotate: binding.rotate,
calibrations: binding.calibrations,
bound_action: json_parse(json_stringify(binding.bound_action))
};
Expand Down Expand Up @@ -2741,6 +2742,10 @@ function New_InputCandy_Private() {
var k=0;
for ( var j=0; j<blen; j++ ) {
var res=__ICI.PostLoadBinding(a[i].bindings[j]);
if ( !res ) {
show_debug_message("__ICI.LoadSettings: Could not locate an action for "+json_stringify(a[i].bindings[j]));
continue;
}
if ( res.index == none ) continue;
s.bindings[k]=res;
k++;
Expand Down

0 comments on commit 829efed

Please sign in to comment.