Skip to content

Instantly share code, notes, and snippets.

@BaldarSilveraxe
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BaldarSilveraxe/520f41972be9f3b4492d to your computer and use it in GitHub Desktop.
Save BaldarSilveraxe/520f41972be9f3b4492d to your computer and use it in GitHub Desktop.
SpaceTest
var SpaceIndustryTiles = (function () {
'use strict';
var textures = [];
textures['space'] = [
{key: '001', url: 'https://s3.amazonaws.com/files.d20.io/images/10242180/lfUyZAeGDrxAhNxZvyShXw/thumb.jpg?1434626840', w: 840, h: 840},
{key: '002', url: 'https://s3.amazonaws.com/files.d20.io/images/10242168/Y-M1W0io3XRhVNY_9cG2Kw/thumb.jpg?1434626836', w: 840, h: 840},
{key: '003', url: 'https://s3.amazonaws.com/files.d20.io/images/10242175/7VTy7MQPF0utcQFsq_76zA/thumb.jpg?1434626838', w: 840, h: 840},
{key: '004', url: 'https://s3.amazonaws.com/files.d20.io/images/10242164/PUjMZwsFbYRnBC01lilM7A/thumb.jpg?1434626834', w: 840, h: 840},
{key: '005', url: 'https://s3.amazonaws.com/files.d20.io/images/10242167/UjwTYXjE1dC4XDx3AC7ekg/thumb.jpg?1434626836', w: 840, h: 840},
{key: '006', url: 'https://s3.amazonaws.com/files.d20.io/images/10242174/XE-xsN5vjJSG6c0u4FDaqw/thumb.jpg?1434626838', w: 840, h: 840},
{key: '007', url: 'https://s3.amazonaws.com/files.d20.io/images/10242170/hMllWCwUf1WFMFEaY0XnAA/thumb.jpg?1434626837', w: 840, h: 840},
{key: '008', url: 'https://s3.amazonaws.com/files.d20.io/images/10242173/b4JOmK7QzcYFVfvjOc3b8w/thumb.jpg?1434626838', w: 840, h: 840},
{key: '009', url: 'https://s3.amazonaws.com/files.d20.io/images/10242171/KVviIlgS5sZa5nGxqDScyw/thumb.jpg?1434626837', w: 840, h: 840},
{key: '010', url: 'https://s3.amazonaws.com/files.d20.io/images/10242163/GwqJRObrPrPbnp7H7m4PKA/thumb.jpg?1434626834', w: 840, h: 840},
{key: '011', url: 'https://s3.amazonaws.com/files.d20.io/images/10242151/RkTSIA4XqUi_wl7HlDnOBg/thumb.jpg?1434626831', w: 840, h: 840},
{key: '012', url: 'https://s3.amazonaws.com/files.d20.io/images/10242146/wvaT38C_BeRrjNzPc5_Q0w/thumb.jpg?1434626829', w: 840, h: 840},
{key: '013', url: 'https://s3.amazonaws.com/files.d20.io/images/10242147/Guo5xIOum_MItclQ4nGvvQ/thumb.jpg?1434626829', w: 840, h: 840},
{key: '014', url: 'https://s3.amazonaws.com/files.d20.io/images/10242150/GBl62JqhmS03MHQoPcVNRA/thumb.jpg?1434626831', w: 840, h: 840},
{key: '015', url: 'https://s3.amazonaws.com/files.d20.io/images/10242152/zqNlnKcWTfadhysvkz__AQ/thumb.jpg?1434626831', w: 840, h: 840},
{key: '016', url: 'https://s3.amazonaws.com/files.d20.io/images/10242144/PEhb2buC1HXHOMCg6CsaXw/thumb.jpg?1434626828', w: 840, h: 840},
{key: '017', url: 'https://s3.amazonaws.com/files.d20.io/images/10242143/5t1eOJ2vFy1xUyhDiuMdow/thumb.jpg?1434626828', w: 840, h: 840},
{key: '018', url: 'https://s3.amazonaws.com/files.d20.io/images/10242169/A5bZgy1vy-j0a9Pk67isng/thumb.jpg?1434626836', w: 840, h: 840},
{key: '019', url: 'https://s3.amazonaws.com/files.d20.io/images/10242154/Ds_z90ZqP0gOZQDXv25K-g/thumb.jpg?1434626831', w: 840, h: 840},
{key: '020', url: 'https://s3.amazonaws.com/files.d20.io/images/10242153/eUl9isjg2FpQnROHrJ0TLA/thumb.jpg?1434626831', w: 840, h: 840},
{key: '021', url: 'https://s3.amazonaws.com/files.d20.io/images/10242157/NQ9o_ICwYsZd_N3H1-NYFw/thumb.jpg?1434626833', w: 840, h: 840},
{key: '022', url: 'https://s3.amazonaws.com/files.d20.io/images/10242156/ifapAZoNMW2HvvEJFNS1Mw/thumb.jpg?1434626833', w: 840, h: 840},
{key: '023', url: 'https://s3.amazonaws.com/files.d20.io/images/10242159/qdB6-tMbFrFk0QyzawYDkw/thumb.jpg?1434626833', w: 840, h: 840},
{key: '024', url: 'https://s3.amazonaws.com/files.d20.io/images/10242162/U6K01plxKusNEvQZOn2KLw/thumb.jpg?1434626834', w: 840, h: 840},
{key: '025', url: 'https://s3.amazonaws.com/files.d20.io/images/10242165/XtonmXLrvW4u21zFWkn10Q/thumb.jpg?1434626835', w: 840, h: 840},
{key: '029', url: 'https://s3.amazonaws.com/files.d20.io/images/10242166/oTms1FsRuvLyNIWBFxT7xQ/thumb.jpg?1434626836', w: 840, h: 840},
{key: '030', url: 'https://s3.amazonaws.com/files.d20.io/images/10242211/4YznL2l_rh18HB7F_JpXUQ/thumb.jpg?1434626851', w: 840, h: 840},
{key: '031', url: 'https://s3.amazonaws.com/files.d20.io/images/10242206/-0iBTDInshCgUqGILuaFaQ/thumb.jpg?1434626848', w: 840, h: 840},
{key: '032', url: 'https://s3.amazonaws.com/files.d20.io/images/10242209/TIcFMe88LBBjjmUz1ixtqg/thumb.jpg?1434626849', w: 840, h: 840},
{key: '033', url: 'https://s3.amazonaws.com/files.d20.io/images/10242208/nkdoFuImP6TMvm5mPMf3_Q/thumb.jpg?1434626849', w: 840, h: 840},
{key: '034', url: 'https://s3.amazonaws.com/files.d20.io/images/10242141/BDQ9KHYOQW5lLImfQJphPQ/thumb.jpg?1434626823', w: 840, h: 840},
{key: '035', url: 'https://s3.amazonaws.com/files.d20.io/images/10242189/DZ-NDfwtCc_NMfUi2shu4w/thumb.jpg?1434626842', w: 840, h: 840},
{key: '036', url: 'https://s3.amazonaws.com/files.d20.io/images/10242155/PxMD3YOqqT6g2v6cZHnmKQ/thumb.jpg?1434626832', w: 840, h: 840},
{key: '037', url: 'https://s3.amazonaws.com/files.d20.io/images/10242142/Mk1LYt3K0rrST-sfHp_1BQ/thumb.jpg?1434626823', w: 840, h: 840},
{key: '038', url: 'https://s3.amazonaws.com/files.d20.io/images/10242145/85fhqGOrx7OTcF5Hq2N-xQ/thumb.jpg?1434626829', w: 840, h: 840},
{key: '039', url: 'https://s3.amazonaws.com/files.d20.io/images/10242139/ih5luZxIpP1T8OqjbV8O4w/thumb.jpg?1434626816', w: 840, h: 840},
{key: '040', url: 'https://s3.amazonaws.com/files.d20.io/images/10242133/Mw4EeQPLZgWxaTmBk-S5Wg/thumb.jpg?1434626785', w: 840, h: 420},
{key: '041', url: 'https://s3.amazonaws.com/files.d20.io/images/10242127/gWtTrnXYTJTDiocmpy2cnw/thumb.jpg?1434626758', w: 420, h: 420},
{key: '042', url: 'https://s3.amazonaws.com/files.d20.io/images/10242128/Mj71cu_74c-vKc8x9yPqsQ/thumb.jpg?1434626758', w: 420, h: 420},
{key: 'bkg', url: 'https://s3.amazonaws.com/files.d20.io/images/10242138/ZCO0LYE5fiDCADnvxyMmvw/thumb.jpg?1434626809', w: 840, h: 840},
];
textures['industry'] = [
{key: '001', url: 'https://s3.amazonaws.com/files.d20.io/images/10242179/7wkxX7ndMnXr4aYyZ3F91A/thumb.jpg?1434626840', w: 840, h: 840},
{key: '002', url: 'https://s3.amazonaws.com/files.d20.io/images/10242182/GXV5uvteFs6AK05ozSglLw/thumb.jpg?1434626840', w: 840, h: 840},
{key: '003', url: 'https://s3.amazonaws.com/files.d20.io/images/10242187/A_vazVcTvh9nFG534pwgEA/thumb.jpg?1434626842', w: 840, h: 840},
{key: '004', url: 'https://s3.amazonaws.com/files.d20.io/images/10242176/dNYm80lMjAOJYvBguYqaFw/thumb.jpg?1434626839', w: 840, h: 840},
{key: '005', url: 'https://s3.amazonaws.com/files.d20.io/images/10242177/WsOwS-IGr4WlkK-7BM8tJw/thumb.jpg?1434626839', w: 840, h: 840},
{key: '006', url: 'https://s3.amazonaws.com/files.d20.io/images/10242184/PgwYEErH6fHdPFAspaJ4fA/thumb.jpg?1434626841', w: 840, h: 840},
{key: '007', url: 'https://s3.amazonaws.com/files.d20.io/images/10242185/PoMfDSc9RNNusxq-n9HN7Q/thumb.jpg?1434626841', w: 840, h: 840},
{key: '008', url: 'https://s3.amazonaws.com/files.d20.io/images/10242183/xVSAiMnOMvgxxHyo0Pl6oA/thumb.jpg?1434626840', w: 840, h: 840},
{key: '009', url: 'https://s3.amazonaws.com/files.d20.io/images/10242194/gNUkgE41rcHtO-xcmcUO4g/thumb.jpg?1434626844', w: 840, h: 840},
{key: '010', url: 'https://s3.amazonaws.com/files.d20.io/images/10242188/GznMH1h9iNbc6Junw0qYWQ/thumb.jpg?1434626842', w: 840, h: 840},
{key: '011', url: 'https://s3.amazonaws.com/files.d20.io/images/10242195/pksd5drR7cerLgAuiTML2A/thumb.jpg?1434626844', w: 840, h: 840},
{key: '012', url: 'https://s3.amazonaws.com/files.d20.io/images/10242198/KR7riwDUVW0EfA9yiRrhtA/thumb.jpg?1434626845', w: 840, h: 840},
{key: '013', url: 'https://s3.amazonaws.com/files.d20.io/images/10242197/RIaq1t72qLTAUwsIR59qyg/thumb.jpg?1434626845', w: 840, h: 840},
{key: '014', url: 'https://s3.amazonaws.com/files.d20.io/images/10242186/ga0x_xa_3XLiP0UlMwdAGA/thumb.jpg?1434626842', w: 840, h: 840},
{key: '015', url: 'https://s3.amazonaws.com/files.d20.io/images/10242140/gbI6a-xsaooHe_EVkebQ_A/thumb.jpg?1434626822', w: 840, h: 840},
{key: '016', url: 'https://s3.amazonaws.com/files.d20.io/images/10242149/QiTM_FU3aQtEgEoIORLI9Q/thumb.jpg?1434626830', w: 840, h: 840},
{key: '017', url: 'https://s3.amazonaws.com/files.d20.io/images/10242158/HAsGB2CgK6lrRVz4m-cfUw/thumb.jpg?1434626833', w: 840, h: 840},
{key: '018', url: 'https://s3.amazonaws.com/files.d20.io/images/10242148/9lBWinM5HZDXTIcbBVBYOA/thumb.jpg?1434626830', w: 840, h: 840},
{key: '019', url: 'https://s3.amazonaws.com/files.d20.io/images/10242178/k7wtemJKS0XtkU813juFKA/thumb.jpg?1434626839', w: 840, h: 840},
{key: '020', url: 'https://s3.amazonaws.com/files.d20.io/images/10242205/DBz6Yp6vm4hjpLYsRPmfkw/thumb.jpg?1434626848', w: 840, h: 840},
{key: '021', url: 'https://s3.amazonaws.com/files.d20.io/images/10242193/Il6krwEcWVh7sqaEhzXmFg/thumb.jpg?1434626844', w: 840, h: 840},
{key: '022', url: 'https://s3.amazonaws.com/files.d20.io/images/10242192/gWtC6vXjtHqlpriPh1ZWPA/thumb.jpg?1434626844', w: 840, h: 840},
{key: '023', url: 'https://s3.amazonaws.com/files.d20.io/images/10242196/DJMd5M3Vdzlb7_6GH5e1sQ/thumb.jpg?1434626845', w: 840, h: 840},
{key: '024', url: 'https://s3.amazonaws.com/files.d20.io/images/10242160/FDd3Y_CY1kYWdd4z9-Cd7Q/thumb.jpg?1434626834', w: 840, h: 840},
{key: '025', url: 'https://s3.amazonaws.com/files.d20.io/images/10242161/huuHV_sMEPa4AVJubVWoqQ/thumb.jpg?1434626834', w: 840, h: 840},
{key: '029', url: 'https://s3.amazonaws.com/files.d20.io/images/10242172/_-3MYXyYPAGqcndt6tUciQ/thumb.jpg?1434626837', w: 840, h: 840},
{key: '030', url: 'https://s3.amazonaws.com/files.d20.io/images/10242202/1Stj8yBw_THHv2nqRIkSNw/thumb.jpg?1434626847', w: 840, h: 840},
{key: '031', url: 'https://s3.amazonaws.com/files.d20.io/images/10242204/Oo-oEs6uCgx7JSjTnk2XCw/thumb.jpg?1434626848', w: 840, h: 840},
{key: '032', url: 'https://s3.amazonaws.com/files.d20.io/images/10242212/yS1VhMWdnpn_5w3rSl9o4A/thumb.jpg?1434626853', w: 840, h: 840},
{key: '033', url: 'https://s3.amazonaws.com/files.d20.io/images/10242207/Irgn-lzZtzf1HMvxefocXg/thumb.jpg?1434626849', w: 840, h: 840},
{key: '034', url: 'https://s3.amazonaws.com/files.d20.io/images/10242210/urKxAL12W4J1dseHyjDGeg/thumb.jpg?1434626850', w: 840, h: 840},
{key: '035', url: 'https://s3.amazonaws.com/files.d20.io/images/10242190/s5s76HWh20yCBIaKZwC4Eg/thumb.jpg?1434626843', w: 840, h: 840},
{key: '036', url: 'https://s3.amazonaws.com/files.d20.io/images/10242191/gaWmQLXCuY7uZ3J37O34DQ/thumb.jpg?1434626843', w: 840, h: 840},
{key: '037', url: 'https://s3.amazonaws.com/files.d20.io/images/10242200/Z45IsLekOZnip_bh0XLlBA/thumb.jpg?1434626846', w: 840, h: 840},
{key: '038', url: 'https://s3.amazonaws.com/files.d20.io/images/10242199/uMsdtU_I-bypLBhpr56faw/thumb.jpg?1434626846', w: 840, h: 840},
{key: '039', url: 'https://s3.amazonaws.com/files.d20.io/images/10242201/dovpV-zy8qP5B95ma68YDQ/thumb.jpg?1434626847', w: 840, h: 840},
{key: '040', url: 'https://s3.amazonaws.com/files.d20.io/images/10242134/E22612YjRC0FFVLuFjAC8g/thumb.jpg?1434626785', w: 840, h: 420},
{key: '041', url: 'https://s3.amazonaws.com/files.d20.io/images/10242126/Jo6H0l_TUkgGCkrQqLkCHg/thumb.jpg?1434626757', w: 420, h: 420},
{key: '042', url: 'https://s3.amazonaws.com/files.d20.io/images/10242129/GmxVUcQNfBKHPxGQ8evd8A/thumb.jpg?1434626758', w: 420, h: 420},
{key: 'bkg', url: 'https://s3.amazonaws.com/files.d20.io/images/10242203/aabHkZ8nKeR-HNsRJYp8ig/thumb.jpg?1434626847', w: 840, h: 840},
];
return textures;
}());
var spaceIndustryMain = spaceIndustryMain || (function(){
'use strict';
var defaultTexture = 'space',
cssButtonAnchor = ' style="border: 1px solid AliceBlue; background-color: SteelBlue; color: white;" ',
cssButtonSpan = ' style="color: white; font-weight: normal; display: block; width: 150px;" ',
cssButtonAnchorImg = ' style="border: 1px solid Black; background-color: White; color: white;" ',
cssButtonImg = ' style="padding: 0px 0px 0px 0px; outline: none; border: none;" ',
tintColor = '00FF00',
mapName = "RandomMap",
deferred = {
batchSize: 30,
initialDefer: 10,
batchDefer: 10
},
version = 2.0,
lastUpdate = 1430236079, //Unix timestamp
schemaVersion = 2.0,
currentTextureName,
currentPageId,
installedTextures = [],
currentTiles = [],
allTexturesTiles = [],
center = false,
middle = false,
tiles = [],
pathingData = [
{keys: '001,002,003,004,005,006,007,008,009,010,018,024,025,029,030,031,032,033,035,040,041',
path: [[-1,105],[35,105],[35,35],[105,35],[105,-1]]},
{keys: '001,002,003,004,005,006,007,008,009,010,018,024,025,029,030,031,032,033,035,040',
path: [[315,-1],[315,35],[525,35],[525,-1]]},
{keys: '001,002,003,004,005,006,007,008,009,010,018,024,025,029,030,031,032,033,035,038,040',
path: [[735,-1],[735,35],[805,35],[805,105],[841,105]]},
{keys: '001,002,003,004,005,006,007,008,009,010,018,024,02,0305,031,032,033,035,038',
path: [[841,315],[805,315],[805,525],[841,525]]},
{keys: '001,002,003,004,005,006,007,008,009,010,018,024,025,030,031,032,033,034,035,036,038',
path: [[841,735],[805,735],[805,805],[735,805],[735,841]]},
{keys: '001,002,003,004,005,006,007,008,009,010,018,024,025,030,031,032,033,034,035,036,038',
path: [[525,841],[525,805],[315,805],[315,841]]},
{keys: '001,002,003,004,005,006,007,008,009,010,018,024,025,030,031,032,033,034,035,036,038,039',
path: [[105,841],[105,805],[35,805],[35,735],[-1,735]]},
{keys: '001,002,003,004,005,006,007,008,009,010,018,024,025,030,031,032,033,035',
path: [[-1,525],[35,525],[35,315],[-1,315]]},
{keys: '025', path: [[105,35],[315,35]]},
{keys: '025', path: [[525,35],[735,35]]},
{keys: '001,005,007,008,009,010,033', path: [[805,524],[805,736]]},
{keys: '001,004,005,006,007,008,009,010,033', path: [[736,805],[524,805]]},
{keys: '001,004,005,006,008,009,010,033', path: [[104,805],[316,805]]},
{keys: '001,004,005,006,007,008,009,010,024,025,030,033', path: [[35,736],[35,524]]},
{keys: '024,025,030', path: [[35,105],[35,315]]},
{keys: '001,002,033,035', path: [[315,595],[245,595],[245,245],[595,245],[595,595],[525,595]]},
{keys: '003', path: [[315,34],[315,105]]},
{keys: '003', path: [[525,34],[525,525]]},
{keys: '003,004,005,006,007,008,009', path: [[841,315],[735,315]]},
{keys: '003', path: [[841,525],[315,525]]},
{keys: '003', path: [[525,841],[525,735]]},
{keys: '003', path: [[315,841],[315,315]]},
{keys: '003,006,007,008', path: [[-1,525],[105,525]]},
{keys: '003', path: [[-1,315],[525,315]]},
{keys: '004,005,006,007,008,009', path: [[-1,315],[105,315]]},
{keys: '004,005,006,007,008,009', path: [[315,315],[525,315]]},
{keys: '006,007,008,009', path: [[385,805],[385,525]]},
{keys: '006,007,008', path: [[315,525],[455,525],[455,315]]},
{keys: '006,007,008,009', path: [[385,525],[455,525],[455,315]]},
{keys: '011,012,013,014,015,016,017,019,021,022', path: [[-1,105],[105,105],[105,-1]]},
{keys: '011,012,013,014,015,016,017,019,020,021,022', path: [[735,-1],[735,105],[841,105]]},
{keys: '011,012,013,014,015,016,017,019,021,022,029', path: [[841,735],[735,735],[735,841]]},
{keys: '011,012,013,014,015,016,017,019,020,021,022,029', path: [[105,841],[105,735],[-1,735]]},
{keys: '011,012,013,014,015,019', path: [[315,-1],[315,105],[525,105],[525,-1]]},
{keys: '013,014,015,017,019', path: [[841,315],[735,315],[735,525],[841,525]]},
{keys: '011,012,014,015,019,029', path: [[315,841],[315,735],[525,735],[525,841]]},
{keys: '014,015,019', path: [[-1,315],[105,315],[105,525],[-1,525]]},
{keys: '011', path: [[841,315],[525,315],[525,525],[841,525]]},
{keys: '011', path: [[-1,315],[315,315],[315,525],[-1,525]]},
{keys: '019', path: [[-1,105],[841,105]]},
{keys: '012,019', path: [[-1,315],[841,315]]},
{keys: '012,019', path: [[-1,525],[841,525]]},
{keys: '019,029', path: [[-1,735],[841,735]]},
{keys: '013,015', path: [[-1,315],[525,315],[525,841]]},
{keys: '016,017', path: [[-1,315],[315,315],[315,-1]]},
{keys: '016,020,021', path: [[525,-1],[525,315],[841,315]]},
{keys: '016', path: [[841,525],[525,525],[525,841]]},
{keys: '013,016,017,020,021', path: [[-1,525],[315,525],[315,841]]},
{keys: '014', path: [[525,735],[525,315],[455,315]]},
{keys: '014', path: [[105,315],[245,315]]},
{keys: '017', path: [[525,-1],[525,841]]},
{keys: '019', path: [[315,315],[315,525]]},
{keys: '019', path: [[525,315],[525,525]]},
{keys: '020,023', path: [[105,-1],[105,35],[315,35],[315,-1]]},
{keys: '023', path: [[525,-1],[525,35],[735,35],[735,-1]]},
{keys: '020,023', path: [[525,841],[525,805],[735,805],[735,841]]},
{keys: '020,023', path: [[105,841],[105,805],[315,805],[315,841]]},
{keys: '020', path: [[-1,105],[245,105],[665,525],[841,525]]},
{keys: '020', path: [[-1,315],[175,315],[590,735],[841,735]]},
{keys: '021', path: [[315,-1],[315,175],[665,525],[841,525]]},
{keys: '021', path: [[-1,315],[175,315],[525,665],[525,841]]},
{keys: '022', path: [[315,-1],[315,175],[420,280],[525,175],[525,-1]]},
{keys: '022,023', path: [[841,315],[665,315],[560,420],[665,525],[841,525]]},
{keys: '022,023', path: [[-1,315],[175,315],[280,420],[175,525],[-1,525]]},
{keys: '022', path: [[315,841],[315,665],[420,560],[525,665],[525,841]]},
{keys: '022,023', path: [[560,420],[420,560]]},
{keys: '022,023', path: [[280,420],[420,280]]},
{keys: '023', path: [[-1,105],[245,105],[420,280],[590,105],[841,105]]},
{keys: '023', path: [[-1,735],[245,735],[420,560],[590,735],[841,735]]},
{keys: '029', path: [[-1,525],[315,525],[315,445]]},
{keys: '029', path: [[841,525],[525,525],[525,445]]},
{keys: '029', path: [[-1,315],[35,315],[35,455],[105,455],[105,525]]},
{keys: '029', path: [[841,315],[805,315],[805,455],[735,455],[735,525]]},
{keys: '034', path: [[-1,525],[35,525],[35,455],[805,455],[805,525],[841,525]]},
{keys: '036', path: [[-1,525],[35,525],[35,455],[105,455]]},
{keys: '036', path: [[841,525],[805,525],[805,455],[735,455]]},
{keys: '036', path: [[315,455],[525,455]]},
{keys: '038', path: [[-1,525],[35,525],[35,455],[455,455],[455,35],[525,35],[525,-1]]},
{keys: '040,041,042', path: [[-1,315],[35,315],[35,385],[105,385],[105,421]]},
{keys: '040', path: [[315,421],[315,385],[525,385],[525,421]]},
{keys: '040', path: [[735,421],[735,385],[805,385],[805,315],[841,315]]},
{keys: '041', path: [[315,-1],[315,35],[385,35],[385,105],[421,105]]},
{keys: '041', path: [[315,421],[315,385],[385,385],[385,315],[421,315]]},
{keys: '042', path: [[-1,105],[35,105],[35,35],[385,35],[385,385],[315,385],[315,421]]},
{keys: '039', path: [[-1,525],[35,525],[35,455],[385,455],[385,805],[315,805],[315,841]]},
],
deferredCreateObj = (function(){
var queue = [],
creator,
doCreates = function(){
var done = 0,
request;
while(queue.length && ++done < deferred.batchSize ){
request = queue.shift();
createObj(request.type,request.properties);
}
if( queue.length ){
creator = setTimeout(doCreates, deferred.batchDefer );
} else {
creator = false;
}
};
return function(type,properties){
queue.push({type: type, properties: properties});
if(!creator){
creator = setTimeout(doCreates, deferred.initialDefer );
}
};
}()),
pathingRotation = function(angle, point,width,height) {
var pointX = point[0], pointY = point[1], originX = (width/2), originY = (height/2);
angle = angle * Math.PI / 180.0;
return [
Math.cos(angle) * (pointX-originX) - Math.sin(angle) * (pointY-originY) + originX,
Math.sin(angle) * (pointX-originX) + Math.cos(angle) * (pointY-originY) + originY
];
},
placeRotatedFlipPaths = function(givenPathData) {
var temp, i, newX, newY, inputPath, angle, Xoffset, Yoffset, PathArray, maxX, minX, maxY, minY, objectWidth, objectHeight,
objectTop, objectLeft, pathString, graphicID;
_.each(givenPathData, function(given) {
temp = [];
for(i = 0; i < given.path.length; i = i + 1) {
newX = given.path[i][0];
newY = given.path[i][1];
if(given.fliph){newX = given.width - given.path[i][0]; }
if(given.flipv){newY = given.height - given.path[i][1]; }
temp.push([newX, newY]);
}
given.path = temp;
graphicID = given.forID;
inputPath = given.path;
angle = given.rotation;
Xoffset = given.left - (given.width/2);
Yoffset = given.top - (given.height/2);
PathArray = [];
if(!angle) {angle = 0; }
if(!Xoffset) {Xoffset = 0; }
if(!Yoffset) {Yoffset = 0; }
maxX = 0;
minX = false;
maxY = 0;
minY = false;
for(i = 0; i < inputPath.length; i = i + 1) {
PathArray.push([inputPath[i][0], inputPath[i][1]]);
PathArray[i] = pathingRotation(angle, PathArray[i],given.width,given.height);
if(PathArray[i][0] > maxX) {maxX = PathArray[i][0]; }
if(minX === false || Number(PathArray[i][0]) < Number(minX)) {minX = PathArray[i][0]; }
if(PathArray[i][1] > maxY) {maxY = PathArray[i][1]; }
if(minY === false || PathArray[i][1] < minY) {minY = PathArray[i][1]; }
}
objectWidth = maxX - minX;
objectHeight = maxY - minY;
objectTop = minY + (objectHeight/2);
objectLeft = minX + (objectWidth/2);
for(i = 0; i < PathArray.length; i = i + 1) {
PathArray[i][0] = PathArray[i][0] - minX;
PathArray[i][1] = PathArray[i][1] - minY;
}
pathString = "";
for(i = 0; i < PathArray.length; i = i + 1) {
if(i !== 0) {
pathString += ",[\"L\"," + PathArray[i][0] + "," + PathArray[i][1] + "]";
} else {
pathString = "[\[\"M\"," + PathArray[i][0] + "," + PathArray[i][1] + "]";
}
}
pathString += "\]";
objectTop = objectTop + Yoffset;
objectLeft = objectLeft + Xoffset;
given.path = pathString;
given.left = objectLeft;
given.top = objectTop;
createObj('path',{
pageid: currentPageId,
layer: 'walls', //gmlayer
path: given.path,
left: given.left,
top: given.top,
width: objectWidth,
height: objectHeight,
rotation: 0,
fliph: false,
flipv: false,
stroke: given.stroke,
stroke_width: given.strokewidth,
controlledby: graphicID
});
});
},
buildPathArray = function(obj) {
var featurePathArray = [],
id = obj.get('id'),
key = obj.get('name'),
n;
_.each( findObjs({type: 'path', controlledby: id}), function(eachPath) {
eachPath.remove();
});
_.each(pathingData, function(pathEach) {
n = pathEach.keys.indexOf(key)
if(n != -1){
featurePathArray.push({
width: obj.get('width'),
height: obj.get('height'),
top: obj.get('top'),
left: obj.get('left'),
rotation: obj.get('rotation'),
fliph: obj.get('fliph'),
flipv: obj.get('flipv'),
path: pathEach.path,
stroke: '#00FF00',
strokewidth: 3,
forID: id
});
};
});
placeRotatedFlipPaths(featurePathArray);
},
directTokenAdd = function(key) {
var page = getObj('page', currentPageId),
thisTile = _.where(currentTiles, {key: key}),
newObj;
if( false === center ) {center = ((page.get('width')/2) * 70) - 35; }
if( false === middle ) {middle = ((page.get('height')/2) * 70) - 35; }
if( !_.isEmpty(thisTile) ) {
newObj = createObj('graphic', {
type: 'graphic', subtype: 'token',
pageid: currentPageId, layer: 'map',
width: thisTile[0].w, height: thisTile[0].h,
left: center, top: middle,
imgsrc: thisTile[0].url,
name: key, controlledby: 'NewAdd',
tint_color: tintColor
});
}
},
help = function(href,aStyle,url,imgStyle) {
sendChat('Help', '/w ' + state.SpaceIndustry.who + ' '
+'<div style="border: 1px solid black; background-color: white; padding: 3px 3px;">'
+'<div style="font-weight: bold; border-bottom: 1px solid black; font-size: 100%;">'
+'Space Industry v'+version
+'</div>'
+'<b style="font-size: 90%;">Overview</b>'
+'<div style="padding-left:10px;margin:3px; font-size: 90%;">'
+'<p>Fast and flexible, geomorphic map tiles are a design technique that defines and locates set features on the edge of the tile so any tile can connect to any other tile without concern for orientation.</p>'
+'<p>Complete help information can be found here:<ul><li><a href="https://wiki.roll20.net/Geomorphic_Map_Tiles" style="color: blue;" ><u>Wiki Geomorphic Map Tiles</u></a>.</li></ul>'
+'</div>'
+'<b style="font-size: 90%;">Commands</b>'
+'<div style="padding-left:10px;margin:3px; font-size: 90%;">'
+'<p>This script uses whisper chat pane commands with the exception of:</p>'
+'<hr><p>Call menu to chat pane.</p>'
+'<pre style="white-space:normal;word-break:normal;word-wrap:normal;">'
+'!SpaceIndustryMenu'
+'</pre>'
+'<hr><p>Take control of script.</p>'
+'<pre style="white-space:normal;word-break:normal;word-wrap:normal;">'
+'!SpaceIndustryControl'
+'</pre>'
+'</div>'
+'</div>'
);
sendChat('Main Menu', '/w ' + state.SpaceIndustry.who + ' <a href="!SpaceIndustryMenu"' + cssButtonAnchor + ' ><span' + cssButtonSpan + '>Space Industry Menu</span></a>');
},
cellhtml = function(href,aStyle,url,imgStyle) {
var html = '<div style="display: table-cell; border-collapse: collapse; padding-left: 0px; padding-right: 0px;" >'
+'<a href="' + href + '"' + aStyle + '>'
+'<img src="' + url + '" height="50" width="50" border="0"' + imgStyle + '>'
+'</a>'
+'</div>';
return html;
},
spaceIndustryMenu = function() {
var tilesDataUniq, tableText, i = 0, menuText;
tilesDataUniq = _.chain(currentTiles)
.reduce(function(m,e){
m[e.key+e.url.split(/\?/)[0]]={key: e.key, url: e.url};
return m;
},{})
.values()
.value();
sendChat('Space Industry Tools', '/w ' + state.SpaceIndustry.who + ' ');
tableText = '/w ' + state.SpaceIndustry.who + ' '
+ '<div style="display: table;" >'
while (i < tilesDataUniq.length) {
tableText += '<div style="display: table-row;" >'
+ cellhtml('!SpaceIndustryNumber ' + tilesDataUniq[i].key, cssButtonAnchorImg,tilesDataUniq[i].url,cssButtonImg)
+ cellhtml('!SpaceIndustryNumber ' + tilesDataUniq[i + 1].key, cssButtonAnchorImg,tilesDataUniq[i + 1].url,cssButtonImg)
+ cellhtml('!SpaceIndustryNumber ' + tilesDataUniq[i + 2].key, cssButtonAnchorImg,tilesDataUniq[i + 2].url,cssButtonImg)
+ cellhtml('!SpaceIndustryNumber ' + tilesDataUniq[i + 3].key, cssButtonAnchorImg,tilesDataUniq[i + 3].url,cssButtonImg)
+ '</div>';
i = i + 4;
}
sendChat('Current Tiles', tableText);
menuText = '/w ' + state.SpaceIndustry.who + ' '
+ '<br><a href="!SpaceIndustryRandom"' + cssButtonAnchor + ' ><span' + cssButtonSpan + '>╔╣-Random Map</span></a>'
+ '<br><a href="!SpaceIndustryHelp"' + cssButtonAnchor + ' ><span' + cssButtonSpan + '>?-Help</span></a>'
+ '<br><a href="!SpaceIndustryChange"' + cssButtonAnchor + ' ><span' + cssButtonSpan + '>⊞-Change-Texture</span></a>';
if( true === state.SpaceIndustry.drawMode ){
menuText += '<br><a href="!SpaceIndustryMode" style="border: 1px solid Black; background-color: PaleGreen; color: Black;" ><span style="color: white; font-weight: normal; display: block; width: 150px;" >◯-Draw-Is-<b>ON</b></span>';
}else{
menuText += '<br><a href="!SpaceIndustryMode" style="border: 1px solid DarkGray; background-color: DarkGray; color: white;" ><span style="color: white; font-weight: normal; display: block; width: 150px;" >◯-Draw-Is-<b>OFF</b></span>';
}
sendChat('Main Menu', menuText);
},
checkMap = function() {
var targetMap = findObjs({ name: mapName, _type: 'page'}),
targetMapImages, targetMapPaths, w, h, errorLog = [];
if( 0 === targetMap.length ) {
errorLog.push({
typeError: 'Critical',
textError: 'Campaign Page named <b>"' + mapName + '"</b> not found. Please add the <b>"' + mapName + '"</b> page to the campaign.',
detailError: 'Map'
});
}
if( 1 < targetMap.length ) {
errorLog.push({
typeError: 'Critical',
textError: 'More than one Campaign Page named <b>"' + mapName + '"</b> found. Please ensure only one map named <b>"' + mapName + '"</b> to the campaign.',
detailError: 'Map'
});
}
if( 1 === targetMap.length ) {
targetMapImages = findObjs({pageid: targetMap[0].get('id'), _type: 'graphic'});
targetMapPaths = findObjs({pageid: targetMap[0].get('id'), _type: 'path'});
if( 0 !== targetMapImages.length ){
errorLog.push({
typeError: 'Warning',
textError: mapName + ' has images on it. Please remove the <b>images.</b>',
detailError: 'Image'
});
}
if( 0 !== targetMapPaths.length ){
errorLog.push({
typeError: 'Warning',
textError: mapName + ' has paths on it. Please remove the <b>paths.</b>',
detailError: 'Path'
});
}
var elvisLives = Math.PI > 4 ? "Yep" : "Nope";
w = 36 > targetMap[0].get('width') ? 36 : Math.ceil(targetMap[0].get('width')/12) * 12;
h = 36 > targetMap[0].get('height') ? 36 : Math.ceil(targetMap[0].get('height')/12) * 12;
targetMap[0].set({width: w, height: h});
}
return errorLog;
},
errors = function(errorLog) {
_.each(errorLog, function(eachError) {
switch (eachError.typeError) {
case "Critical":
sendChat('Error','/w ' + state.SpaceIndustry.who + ' '
+'<div style="padding:1px 3px;border: 1px solid #FF0000; background: #FFBABA; color: #D8000C; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422880/SIjBHWJNC8f9a73Rg_VkOQ/thumb.png?14164996807" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+eachError.textError
);
break;
case "Warning":
sendChat('Error','/w ' + state.SpaceIndustry.who + ' '
+'<div style="padding:1px 3px;border: 1px solid #9F6000; background: #FEEFB3; color: #9F6000; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422879/M-oWEvMt1bhC2M-bdi28tA/thumb.png?1416499678" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+eachError.textError
);
break;
default:
sendChat('Error','/w ' + state.SpaceIndustry.who + ' '
+'<div style="padding:1px 3px;border: 1px solid #00529B; background: #BDE5F8; color: #00529B; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422881/TSnHqUi-Y3TjRjqM1P_GsQ/thumb.png?1416499690" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+eachError.textError
);
break;
}
});
},
queueRandomTile = function(tile) {
deferredCreateObj('graphic', {
subtype: 'token',
pageid: tile.pageid,
layer: 'map',
width: tile.width,
height: tile.height,
left: tile.left,
top: tile.top,
rotation: tile.rotation,
flipv: tile.flipv,
fliph: tile.fliph,
imgsrc: tile.imgsrc,
name: tile.name,
controlledby: 'SpaceIndustry'
});
},
getTile = function(id,r,c,rows,cols) {
var foundTile,
randomTile = Math.floor(Math.random() * 24),
randomVflip = Math.random() < 0.5 ? true : false,
randomHflip = Math.random() < 0.5 ? true : false,
rot = Math.floor(Math.random() * 360),
randomAngle = (Math.round(rot/90)*90)%360 + (rot<0 ? 360 : 0);
foundTile = currentTiles[randomTile];
if( 0 === r && 0 === c ){
foundTile = _.where(currentTiles, {key: '039'})[0];
randomAngle = 0;
randomVflip = false;
randomHflip = true;
}
if( 0 === r && c === cols ){
foundTile = _.where(currentTiles, {key: '039'})[0];
randomAngle = 0;
randomVflip = false;
randomHflip = false;
}
if( r === rows && c === cols ){
foundTile = _.where(currentTiles, {key: '039'})[0];
randomAngle = 0;
randomVflip = true;
randomHflip = false;
}
if( r === rows && 0 === c ){
foundTile = _.where(currentTiles, {key: '039'})[0];
randomAngle = 0;
randomVflip = true;
randomHflip = true;
}
if( 0 === r && 0 !== c && c !== cols ){
foundTile = _.where(currentTiles, {key: '034'})[0];
randomAngle = 0;
randomVflip = false;
randomHflip = false;
}
if( 0 !== r && r !== rows && c === cols ){
foundTile = _.where(currentTiles, {key: '034'})[0];
randomAngle = 90;
randomVflip = false;
randomHflip = false;
}
if( r === rows && 0 !== c && c !== cols ){
foundTile = _.where(currentTiles, {key: '034'})[0];
randomAngle = 0;
randomVflip = true;
randomHflip = false;
}
if( 0 !== r && r !== rows && 0 === c ){
foundTile = _.where(currentTiles, {key: '034'})[0];
randomAngle = 270;
randomVflip = false;
randomHflip = false;
}
tiles.push({
pageid: id, width: foundTile.w, height: foundTile.h,
left: (c * 840) + 420, top: (r * 840) + 420,
rotation: randomAngle, flipv: randomVflip, fliph: randomHflip,
imgsrc: foundTile.url, name: foundTile.key,
});
},
spaceIndustryRandom = function() {
var rows, cols, r, c, errorLog = checkMap(),
targetMap = findObjs({ name: mapName, _type: 'page'})[0];
if( 0 !== errorLog.length ) {errors(errorLog); return; }
rows = targetMap.get('height') / 12;
cols = targetMap.get('width') / 12;
tiles = [];
for( r = 0; r < rows; r = r + 1 ){
for( c = 0; c < cols; c = c + 1 ){
getTile(targetMap.get('id'),r,c,rows - 1,cols - 1 );
}
}
_.each(tiles, function(eachTile) {
queueRandomTile(eachTile);
});
},
checkOwnerName = function(players,ownerId) {
var whoToTest = _.where(players, {id: ownerId})[0].get('displayname').split(' ')[0];
return _.chain(players)
.map(function(p){
return p.get('displayname').split(' ')[0];
})
.filter(function(n){
return n === whoToTest;
})
.value()
.length>0;
},
setTexture = function(message) {
var pack = message.replace('!SpaceIndustrySetTexture ', ''),
switchPack = defaultTexture,
messageArguments;
_.each(installedTextures, function(eachTextures) {
messageArguments = eachTextures.split('|');
if( messageArguments[0] === pack ) {switchPack = eachTextures; }
});
state.SpaceIndustry.currentTextureName = switchPack;
currentTiles = _.clone(SpaceIndustryTiles[state.SpaceIndustry.currentTextureName]);
currentTextureName = state.SpaceIndustry.currentTextureName;
spaceIndustryMenu();
},
selectTexture = function() {
var text = '/w ' + state.SpaceIndustry.who + ' ',
args;
if( 0 === installedTextures.length) {return; }
_.each(installedTextures, function(eachTextures) {
args = eachTextures.split('|');
if( 2 !== args.length){return; }
});
_.each(installedTextures, function(eachTextures) {
args = eachTextures.split('|');
text += '<br><a href="!SpaceIndustrySetTexture ' + args[0] + '"><span style="color: white; font-weight: normal; display: block; width: 150px;" >▹ ' + args[0] + '</span></a>';
});
sendChat('Select Texture', text);
},
refreshData = function(){
var playerPages = Campaign().get('playerspecificpages'),
ownerPage = playerPages[state.SpaceIndustry.owner],
tempPack,
i;
if( undefined === ownerPage ){
currentPageId = Campaign().get('playerpageid');
sendChat('Space Industry', '/w ' + state.SpaceIndustry.who + ' '
+'<div style="padding:1px 3px;border: 1px solid #9F6000; background: #FEEFB3; color: #9F6000; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422879/M-oWEvMt1bhC2M-bdi28tA/thumb.png?1416499678" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Current page is the player book mark page. Recommend using the party split feature to select the page you wish to edit.'
);
}else{
currentPageId = ownerPage;
}
Object.keys(SpaceIndustryTiles).forEach(function(key) {
installedTextures.push(key);
});
currentTiles = _.clone(SpaceIndustryTiles[state.SpaceIndustry.currentTextureName]);
allTexturesTiles = [];
for (i = 0; i < installedTextures.length; i = i + 1) {
tempPack = _.clone(SpaceIndustryTiles[installedTextures[i]]);
_.each(tempPack, function(eachTile) {
allTexturesTiles.push({
url: eachTile.url,
key: eachTile.key,
value: eachTile.value,
mask: eachTile.mask,
dlBits: eachTile.dlBits,
diag: eachTile.diag,
pack: installedTextures[i]
});
});
}
currentTextureName = state.SpaceIndustry.currentTextureName;
state.SpaceIndustry.processing = false;
state.SpaceIndustry.drawMode = true;
},
initializeResetState = function(action) {
var players, ownerId, nameTruncated;
switch(action){
case 'initialize':
players = findObjs({type: 'player'});
ownerId = _.find(_.pluck(players,'id'),playerIsGM);
if( !ownerId || !checkOwnerName(players,ownerId)) {return; }
log('SpaceIndustry: Initialize State');
state.SpaceIndustry = {
version: schemaVersion,
currentTextureName: defaultTexture,
drawMode: false,
processing: false,
owner: ownerId,
who: getObj('player',ownerId).get('_displayname').split(' ')[0]
};
return;
case 'reset':
log('SpaceIndustry: Resetting State');
state.SpaceIndustry.version = schemaVersion;
state.SpaceIndustry.currentTextureName = defaultTexture;
state.SpaceIndustry.drawMode = false;
state.SpaceIndustry.processing = false;
return;
}
},
checkInstall = function() {
delete state.SpaceIndustry;
if( ! _.has(state,'SpaceIndustry') ) {
initializeResetState('initialize');
}
if( ! _.has(state,'SpaceIndustry') ) {
sendChat('Space Industry','/direct '
+'<div style="padding:1px 3px;border: 1px solid #FF0000; background: #FFBABA; color: #D8000C; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422880/SIjBHWJNC8f9a73Rg_VkOQ/thumb.png?14164996807" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'<b>Script Halted.</b> Script halted. State failed to initialize. Likely due to no GM being found or GMs do not having unique names.'
);
return;
}
if( state.SpaceIndustry.version !== schemaVersion ) {
initializeResetState('reset')
}
refreshData();
sendChat('Main Menu', '/w ' + state.SpaceIndustry.who + ' <a href="!SpaceIndustryMenu"' + cssButtonAnchor + ' ><span' + cssButtonSpan + '>Space Industry Menu</span></a>');
},
control = function(id) {
var players = findObjs({type: 'player'});
if( !checkOwnerName(players,id) ) {
sendChat('Space Industry', '/direct '
+'<div style="padding:1px 3px;border: 1px solid #9F6000; background: #FEEFB3; color: #9F6000; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422879/M-oWEvMt1bhC2M-bdi28tA/thumb.png?1416499678" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Transfer of control failed. Name conflict.'
);
return;
}
state.SpaceIndustry.owner = id;
state.SpaceIndustry.who = getObj('player',id).get('_displayname').split(' ')[0];
refreshData();
sendChat('Main Menu', '/w ' + state.SpaceIndustry.who + ' <a href="!SpaceIndustryMenu"' + cssButtonAnchor + ' ><span' + cssButtonSpan + '>Space Industry Menu</span></a>');
},
handleInput = function(msg) {
var message = _.clone(msg), messageArguments = msg.content.split(/\s+/);
if ( ('api' !== message.type) || (true === state.SpaceIndustry.processing) || (false === playerIsGM(message.playerid)) ) {
return;
}
if ( messageArguments[0] === '!SpaceIndustryMode') {
state.SpaceIndustry.drawMode = (state.SpaceIndustry.drawMode === true ? false : true);
}
if( (messageArguments[0] === '!SpaceIndustryMenu') || (messageArguments[0] === '!SpaceIndustryMode') ){
spaceIndustryMenu();
return;
}
state.SpaceIndustry.processing = true;
if( false === state.SpaceIndustry.drawMode ) {
sendChat('Space Industry', '/w ' + state.SpaceIndustry.who + ' '
+'<div style="padding:1px 3px;border: 1px solid #9F6000; background: #FEEFB3; color: #9F6000; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422879/M-oWEvMt1bhC2M-bdi28tA/thumb.png?1416499678" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Map making is turned off. Got to the main menu to turn it on.'
);
sendChat('Main Menu', '/w ' + state.SpaceIndustry.who + ' <a href="!SpaceIndustryMenu"' + cssButtonAnchor + ' ><span' + cssButtonSpan + '>Space Industry Menu</span></a>');
state.SpaceIndustry.processing = false;
return;
}
switch(messageArguments[0]) {
case '!SpaceIndustryRandom': spaceIndustryRandom(); break;
case '!SpaceIndustryNumber': directTokenAdd(messageArguments[1]); break;
case '!SpaceIndustryChange': selectTexture(); break;
case '!SpaceIndustrySetTexture': setTexture(message.content); break;
case '!SpaceIndustryControl': control(message.playerid); break;
default: help(); break;
}
state.SpaceIndustry.processing = false;
},
handlePageChange = function(obj) {
refreshData();
},
handleGraphicChange = function(obj) {
var url = obj.get('imgsrc'),
rot = obj.get('rotation'),
thisTile = _.where(currentTiles, {url: url});
if( _.isEmpty(thisTile) ) {return; }
if( ('NewAdd' !== obj.get('controlledby')) && tintColor === obj.get('tint_color') ) {
obj.set('tint_color', 'transparent');
}
if( 'NewAdd' === obj.get('controlledby') ) {
obj.set('controlledby', 'SpaceIndustry');
setTimeout(function() {toFront(obj); }, 100);
}
obj.set({
rotation: (Math.round(rot/90)*90)%360 + (rot<0 ? 360 : 0),
width: thisTile[0].w,
height: thisTile[0].h
});
buildPathArray(obj);
},
handleGraphicDestroy = function(obj) {
var url = obj.get('imgsrc'),
thisTile = _.where(currentTiles, {url: url});
if( _.isEmpty(thisTile) ) {return; }
_.each(findObjs({_type: 'path', controlledby: obj.get('_id') }), function(eachPath) {
eachPath.remove();
});
},
registerEventHandlers = function() {
on('change:campaign:playerpageid', handlePageChange);
on('change:campaign:playerspecificpages', handlePageChange);
on('chat:message', handleInput);
on('change:graphic', handleGraphicChange);
on('destroy:graphic', handleGraphicDestroy);
checkInstall();
};
return {
CheckInstall: checkInstall,
RegisterEventHandlers: registerEventHandlers
};
}());
on('ready',function(){
'use strict';
spaceIndustryMain.RegisterEventHandlers();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment