fixed crash with crafting load since 1.66

This commit is contained in:
vbawol 2016-12-02 09:59:01 -06:00
parent a4f0ab80ec
commit 84eb6fc8a8

View File

@ -13,137 +13,143 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/craftingv2/EPOCH_crafting_load.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/craftingv2/EPOCH_crafting_load.sqf
*/ */
if (rmx_var_craftingENABLED) exitWith {false}; if (rmx_var_craftingENABLED) exitWith {false};
disableSerialization;
private ["_in","_cfg","_3DCTRL","_recipeCTRL","_recipeConfigs"];
_in = param [0,""];
createDialog "rmx_craftingUI"; createDialog "rmx_craftingUI";
call EPOCH_crafting_ctrl_collector; _this spawn {
private ["_in","_cfg","_3DCTRL","_recipeCTRL","_recipeConfigs"];
//Var defs disableSerialization;
rmx_var_craftQTY = 0;
rmx_var_craftQTYOut = 0;
rmx_var_craftInProgress = false;
//Defines _in = param [0,""];
_cfg = 'CfgCrafting' call EPOCH_returnConfig;
_cfg call EPOCH_crafting_colorScheme; waitUntil {!isNull findDisplay 77700};
call EPOCH_crafting_ctrl_collector;
_3DCTRL = rmx_var_crafting_ctrl_DEVMisc select 0; //Var defs
_recipeCTRL = rmx_var_crafting_ctrl_main select 0; rmx_var_craftQTY = 0;
rmx_var_craftQTYOut = 0;
rmx_var_craftInProgress = false;
//First Launch //Defines
_recipeConfigs = "true" configClasses _cfg; _cfg = 'CfgCrafting' call EPOCH_returnConfig;
_recipeConfigs deleteRange [0,6]; //delete main templates as they are not real items
rmx_var_crafting_FullConfigData = _recipeConfigs call EPOCH_crafting_getConfig; _cfg call EPOCH_crafting_colorScheme;
rmx_var_crafting_SearchConfigData = rmx_var_crafting_FullConfigData;
[_3DCTRL] call Epoch_3DctrlSpin; _3DCTRL = rmx_var_crafting_ctrl_DEVMisc select 0;
_3DCTRL ctrlEnable false; _recipeCTRL = rmx_var_crafting_ctrl_main select 0;
call EPOCH_crafting_LB_defaults; //Default state //First Launch
_recipeConfigs = "true" configClasses _cfg;
_recipeConfigs deleteRange [0,6]; //delete main templates as they are not real items
//Basic EH setup rmx_var_crafting_FullConfigData = _recipeConfigs call EPOCH_crafting_getConfig;
if (getNumber (_cfg >> "DeveloperMode") > 0) then { rmx_var_crafting_SearchConfigData = rmx_var_crafting_FullConfigData;
private "_ctrlDevMain";
_ctrlDevMain = rmx_var_crafting_ctrl_DEVMisc select 1;
_ctrlDevMain ctrlEnable true;
_ctrlDevMain ctrlShow true;
};
rmx_var_crafting_progressClicked = false;
ctrlSetFocus _recipeCTRL; [_3DCTRL] call Epoch_3DctrlSpin;
_3DCTRL ctrlEnable false;
//puts arguments into search field call EPOCH_crafting_LB_defaults; //Default state
if (_in isEqualType "STRING") then {
if (count _in > 0) then { //required, empty string crashes game for some reason
(rmx_var_crafting_ctrl_Interact select 4) ctrlSetText _in;
};
};
//Post Processing //Basic EH setup
rmx_var_crafting_PP_CC = ["colorCorrections",11] call epoch_postProcessCreate; if (getNumber (_cfg >> "DeveloperMode") > 0) then {
rmx_var_crafting_PP_DB = ["dynamicBlur",11] call epoch_postProcessCreate; private "_ctrlDevMain";
_ctrlDevMain = rmx_var_crafting_ctrl_DEVMisc select 1;
_ctrlDevMain ctrlEnable true;
_ctrlDevMain ctrlShow true;
};
rmx_var_crafting_progressClicked = false;
[rmx_var_crafting_PP_CC, 0, [1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0.296494,1]] call epoch_postprocessAdjust; ctrlSetFocus _recipeCTRL;
[rmx_var_crafting_PP_DB, 1, [1]] call epoch_postprocessAdjust;
//Custom textures //puts arguments into search field
if (_in isEqualType "STRING") then {
if (count _in > 0) then { //required, empty string crashes game for some reason
(rmx_var_crafting_ctrl_Interact select 4) ctrlSetText _in;
};
};
//Post Processing
rmx_var_crafting_PP_CC = ["colorCorrections",11] call epoch_postProcessCreate;
rmx_var_crafting_PP_DB = ["dynamicBlur",11] call epoch_postProcessCreate;
[rmx_var_crafting_PP_CC, 0, [1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0.296494,1]] call epoch_postprocessAdjust;
[rmx_var_crafting_PP_DB, 1, [1]] call epoch_postprocessAdjust;
//Custom textures
//Manages quantity slider //Manages quantity slider
[] spawn { [] spawn {
private ["_pos","_txt"]; private ["_pos","_txt"];
while {rmx_var_craftingLOOPS} do { while {rmx_var_craftingLOOPS} do {
_pos = progressPosition (rmx_var_crafting_ctrl_Interact select 2); _pos = progressPosition (rmx_var_crafting_ctrl_Interact select 2);
rmx_var_craftQTYOut = round (_pos * rmx_var_craftQTY); rmx_var_craftQTYOut = round (_pos * rmx_var_craftQTY);
_txt = format ["[%1/%2]",rmx_var_craftQTYOut,rmx_var_craftQTY]; _txt = format ["[%1/%2]",rmx_var_craftQTYOut,rmx_var_craftQTY];
(rmx_var_crafting_ctrl_Interact select 3) ctrlSetText _txt; (rmx_var_crafting_ctrl_Interact select 3) ctrlSetText _txt;
}; };
}; };
//Search box //Search box
[] spawn { [] spawn {
disableSerialization; disableSerialization;
private ["_searchCTRL","_searchTextTEMP"]; private ["_searchCTRL","_searchTextTEMP"];
_searchCTRL = rmx_var_crafting_ctrl_Interact select 4; _searchCTRL = rmx_var_crafting_ctrl_Interact select 4;
_searchTextTEMP = ""; _searchTextTEMP = "";
while {rmx_var_craftingLOOPS} do { while {rmx_var_craftingLOOPS} do {
uiSleep 0.5; //speed of search, should be less or equal to unload delay uiSleep 0.5; //speed of search, should be less or equal to unload delay
if !(_searchTextTEMP isEqualTo (ctrlText _searchCTRL)) then { if !(_searchTextTEMP isEqualTo (ctrlText _searchCTRL)) then {
rmx_var_crafting_SearchConfigData = []; rmx_var_crafting_SearchConfigData = [];
{ {
_idx = toLower(_x select 1) find toLower (ctrlText _searchCTRL); _idx = toLower(_x select 1) find toLower (ctrlText _searchCTRL);
if !(_idx isEqualTo -1) then { if !(_idx isEqualTo -1) then {
rmx_var_crafting_SearchConfigData pushBack _x; rmx_var_crafting_SearchConfigData pushBack _x;
}; };
} forEach rmx_var_crafting_FullConfigData; } forEach rmx_var_crafting_FullConfigData;
_searchTextTEMP = ctrlText _searchCTRL; _searchTextTEMP = ctrlText _searchCTRL;
call EPOCH_crafting_LB_defaults; call EPOCH_crafting_LB_defaults;
(rmx_var_crafting_ctrl_main select 0) lbSetCurSel 0; (rmx_var_crafting_ctrl_main select 0) lbSetCurSel 0;
ctrlSetFocus _searchCTRL; ctrlSetFocus _searchCTRL;
}; };
}; };
}; };
//Craft button states //Craft button states
[] spawn { [] spawn {
private ["_btn","_btn_cancel","_btn_craft","_btn_close"]; private ["_btn","_btn_cancel","_btn_craft","_btn_close"];
disableSerialization; disableSerialization;
_btn = rmx_var_crafting_ctrl_Interact select 0; _btn = rmx_var_crafting_ctrl_Interact select 0;
_btn ctrlEnable true; _btn ctrlEnable true;
_btn_cancel = rmx_var_crafting_colorScheme select 0; _btn_cancel = rmx_var_crafting_colorScheme select 0;
_btn_craft = rmx_var_crafting_colorScheme select 1; _btn_craft = rmx_var_crafting_colorScheme select 1;
_btn_close = rmx_var_crafting_colorScheme select 2; _btn_close = rmx_var_crafting_colorScheme select 2;
while {rmx_var_craftingLOOPS} do { while {rmx_var_craftingLOOPS} do {
uiSleep 0.1; uiSleep 0.1;
if (rmx_var_craftInProgress) then { if (rmx_var_craftInProgress) then {
_btn ctrlSetText _btn_cancel; _btn ctrlSetText _btn_cancel;
} else { } else {
if (rmx_var_craftQTYOut > 0) then { if (rmx_var_craftQTYOut > 0) then {
_btn ctrlSetText _btn_craft; _btn ctrlSetText _btn_craft;
} else { } else {
_btn ctrlSetText _btn_close; _btn ctrlSetText _btn_close;
}; };
} }
}; };
}; };
[] spawn { [] spawn {
private "_pos"; private "_pos";
_pos = position player; _pos = position player;
while {rmx_var_craftingLOOPS} do { while {rmx_var_craftingLOOPS} do {
if ((_pos distance (position player)) > 1) exitWith {closeDialog 0;}; if ((_pos distance (position player)) > 1) exitWith {closeDialog 0;};
}; };
};
}; };
true true