cleanup move some code to includes

This commit is contained in:
[VB]AWOL
2013-11-22 09:13:40 -06:00
parent fc5733fd29
commit ac1a64d682
3 changed files with 270 additions and 272 deletions

View File

@@ -420,277 +420,11 @@ if (!isDedicated) then {
dayz_originalPlayer = player;
// trader menu code
call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_traderMenu.sqf";
// trader menu gui by maca134
TraderDialogCatList = 12000;
TraderDialogItemList = 12001;
TraderDialogBuyPrice = 12002;
TraderDialogSellPrice = 12003;
TraderCurrentCatIndex = -1;
TraderCatList = -1;
TraderItemList = -1;
TraderDialogLoadItemList = {
private ["_index", "_trader_id", "_activatingPlayer"];
TraderItemList = -1;
_index = _this select 0;
if (_index < 0 or TraderCurrentCatIndex == _index) exitWith {};
TraderCurrentCatIndex = _index;
_trader_id = TraderCatList select _index;
_activatingPlayer = player;
lbClear TraderDialogItemList;
ctrlSetText [TraderDialogBuyPrice, ""];
ctrlSetText [TraderDialogSellPrice, ""];
lbAdd [TraderDialogItemList, "Loading items..."];
PVDZE_plr_TradeMenuResult = call compile format["tcacheBuy_%1;",_trader_id];
if(isNil "PVDZE_plr_TradeMenuResult") then {
PVDZE_plr_TradeMenu = [_activatingPlayer,_trader_id];
publicVariableServer "PVDZE_plr_TradeMenu";
waitUntil {!isNil "PVDZE_plr_TradeMenuResult"};
};
lbClear TraderDialogItemList;
_item_list = [];
{
private ["_header", "_item", "_name", "_type", "_textPart", "_qty", "_buy", "_bqty", "_bname", "_btype", "_btextCurrency", "_sell", "_sqty", "_sname", "_stype", "_stextCurrency", "_order", "_order", "_afile", "_File", "_count", "_bag", "_bagclass", "_index", "_image"];
_header = _x select 0; // "TRD"
_item = _x select 1;
_name = _item select 0;
_type = _item select 1;
switch (true) do {
case (_type == 1): {
_type = "CfgMagazines";
};
case (_type == 2): {
_type = "CfgVehicles";
};
case (_type == 3): {
_type = "CfgWeapons";
};
};
// Display Name of item
_textPart = getText(configFile >> _type >> _name >> "displayName");
// Total in stock
_qty = _x select 2;
// Buy Data from array
_buy = _x select 3;
_bqty = _buy select 0;
_bname = _buy select 1;
_btype = _buy select 2;
switch(true)do{
case (_btype == 1): {
_btype = "CfgMagazines";
};
case (_btype == 2): {
_btype = "CfgVehicles";
};
case (_btype == 3): {
_btype = "CfgWeapons";
};
};
// Display Name of buy item
_btextCurrency = getText(configFile >> _btype >> _bname >> "displayName");
_sell = _x select 4;
_sqty = _sell select 0;
_sname = _sell select 1;
_stype = _sell select 2;
switch(true)do{
case (_stype == 1): {
_stype = "CfgMagazines";
};
case (_stype == 2): {
_stype = "CfgVehicles";
};
case (_stype == 3): {
_stype = "CfgWeapons";
};
};
// Display Name of sell item
_stextCurrency = getText(configFile >> _stype >> _sname >> "displayName");
// Menu sort order
_order = _x select 5;
// Action file to use for trade
_afile = _x select 7;
_File = "\z\addons\dayz_code\actions\" + _afile + ".sqf";
_count = 0;
if(_type == "CfgVehicles") then {
if (_afile == "trade_backpacks") then {
_bag = unitBackpack player;
_bagclass = typeOf _bag;
if(_name == _bagclass) then {
_count = 1;
};
} else {
_count = {(typeOf _x) == _name} count (nearestObjects [player, [_name], 20]);
}
};
if(_type == "CfgMagazines") then {
_count = {_x == _name} count magazines player;
};
if(_type == "CfgWeapons") then {
_count = {_x == _name} count weapons player;
};
_index = lbAdd [TraderDialogItemList, format["%1 (%2)", _textPart, _name]];
if (_count > 0) then {
lbSetColor [TraderDialogItemList, _index, [0, 1, 0, 1]];
};
_image = getText(configFile >> _type >> _name >> "picture");
lbSetPicture [TraderDialogItemList, _index, _image];
_item_list set [count _item_list, [
_name,
_textPart,
_bqty,
_bname,
_btextCurrency,
_sqty,
_sname,
_stextCurrency,
_header,
_File
]];
} forEach PVDZE_plr_TradeMenuResult;
TraderItemList = _item_list;
};
TraderDialogShowPrices = {
private ["_index", "_item"];
_index = _this select 0;
if (_index < 0) exitWith {};
while {count TraderItemList < 1} do { sleep 1; };
_item = TraderItemList select _index;
ctrlSetText [TraderDialogBuyPrice, format["%1 %2", _item select 2, _item select 4]];
ctrlSetText [TraderDialogSellPrice, format["%1 %2", _item select 5, _item select 7]];
};
TraderDialogBuy = {
private ["_index", "_item", "_data"];
_index = _this select 0;
if (_index < 0) exitWith {
cutText [(localize "str_epoch_player_6") , "PLAIN DOWN"];
};
_item = TraderItemList select _index;
_data = [_item select 0, _item select 3, 1, _item select 2, "buy", _item select 4, _item select 1, _item select 8];
[0, player, '', _data] execVM (_item select 9);
TraderItemList = -1;
};
TraderDialogSell = {
private ["_index", "_item", "_data"];
_index = _this select 0;
if (_index < 0) exitWith {
cutText [(localize "str_epoch_player_6") , "PLAIN DOWN"];
};
_item = TraderItemList select _index;
_data = [_item select 6, _item select 0, _item select 5, 1, "sell", _item select 1, _item select 7, _item select 8];
[0, player, '', _data] execVM (_item select 9);
TraderItemList = -1;
};
// murder message boards by maca134
/*
_death_record = [
0_victimName,
1_killerName,
2_weapon,
3_distance,
4ServerCurrentTime
];
*/
EpochDeathBoardDialogList = 21000;
EpochDeathBoardDialogSText = 21001;
EpochDeathBoardDeaths = [];
EpochDeathBoardLoad = {
createdialog "EpochDeathBoardDialog";
/*PVDZE_plr_DeathBResult = [
["maca134","Bob","AK_107_Kobra",100,[8,30]],
["Fred","Jonny","FN_FAL",42,[8,32]],
["maca134","Bob","M9SD",100,[5,30]],
["Fred","Jonny","BAF_AS50_scoped",42,[8,34]]
];*/
{
lbAdd [EpochDeathBoardDialogList, (_x select 0)];
} forEach PVDZE_plr_DeathBResult;
};
EpochDeathBoardClick = {
disableSerialization;
private ["_i", "_record", "_output", "_record_stxt", "_name", "_image", "_h", "_m", "_format"];
_quotes = [
"Death is God's way of telling you not to be such a wise guy.",
"What happens if you get scared half to death, twice?",
"Don't upset me.. I'm running out of places to hide the bodies.",
"Don't run, you'll just die tired.",
"Give me immortality or give me death.",
"I can't live with death; he's always leaving the toilet seat up.",
"Why won't you die?!?!",
"Guns don't kill people; death kills people. It's a proven medical fact."
];
_i = _this select 0;
if (_i < 0) exitWith {};
_output = _this select 1;
_record = PVDZE_plr_DeathBResult select _i;
_record_stxt = call compile format["epoch_death_board_record_%1;",_i];
if(isNil "_record_stxt") then {
_record_stxt = format["<t size='1.6' align='left'>%1</t><br /><br />", (_record select 0)];
_format = {
private ["_codeCount", "_str"];
_str = format["%1", _this];
_codeCount = (count (toArray _str));
if (_codeCount == 1) then {
_str = format["0%1", _str];
};
_str;
};
_h = ((_record select 4) select 0)+timezoneswitch;
_m = (_record select 4) select 1;
_record_stxt = format["%1<t size='1' align='left'>Died at %2:%3</t><br /><br />", _record_stxt, (_h call _format), (_m call _format)];
if ((_record select 1) != 'unknown') then {
_record_stxt = format["%1<t size='1' align='left'>Was killed by %2</t><br /><br />", _record_stxt, (_record select 1)];
};
if ((_record select 2) != 'unknown') then {
_name = getText(configFile >> "cfgWeapons" >> (_record select 2) >> "displayName");
_image = getText(configFile >> "cfgWeapons" >> (_record select 2) >> "picture");
_record_stxt = format["%1<t size='1' align='left'>With a %2<br /><img size='3' image='%3' /></t><br /><br />", _record_stxt, _name, _image];
};
if (format["%1", (_record select 3)] != 'unknown') then {
_record_stxt = format["%1<t size='1' align='left'>At a distance of %2m</t><br /><br />", _record_stxt, (_record select 3)];
};
_record_stxt = format["%1<t font='Bitstream'>%2</t>", _record_stxt, (_quotes call BIS_fnc_selectRandom)];
call compile format["epoch_death_board_record_%1 = ""%2"";" ,_i , _record_stxt];
};
_output ctrlSetStructuredText parseText _record_stxt;
};
// recent murders menu code
call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_murderMenu.sqf";
};
progressLoadingScreen 0.8;
@@ -775,7 +509,6 @@ if (!isDedicated) then {
_medical
};
//Server Only
if (isServer) then {
call compile preprocessFileLineNumbers "\z\addons\dayz_server\init\server_functions.sqf";
@@ -783,4 +516,4 @@ if (!isDedicated) then {
eh_localCleanup = {};
};
initialized = true;
initialized = true;