private void MainForm_Load(object sender, EventArgs e) { comboBoxRotation.SelectedIndex = 0; comboBoxFlipping.SelectedIndex = 0; comboBoxEnvironment.DataSource = Level.EnvironmentsNames; ClipboardNotification.ClipboardUpdate += ClipboardNotification_ClipboardUpdate; ClipboardNotification_ClipboardUpdate(null, EventArgs.Empty); foreach (Control ctrl in panelAllowedBlocks.Controls) { ((CheckBox)ctrl).CheckedChanged += new EventHandler(checkBoxBlocks_CheckedChanged); } LevelsManager = new LevelsManager(LevelsManager.SteamUsers().FirstOrDefault()); LoadLevels(); BlockInfosManager = new BlockInfosManager(); formBlockReference = new FormBlockReference(); formBlockReference.Owner = this; formAxisHelp = new FormAxisHelp(); formImageConverter = new FormColors(); formImageConverter.Owner = this; formScripting = new FormScripting(); formScripting.Owner = this; }
private void FormBlockReference_Load(object sender, EventArgs e) { bim = ((FormMain)Owner).BlockInfosManager; lvis = new List <ListViewItem>(); backgroundWorker.RunWorkerAsync(); ResetViewer(); }
public void Flip(Axis axis, BlockInfosManager bim) { var blocks = new Dictionary <Vec, Block>(); foreach (var block in blocksDict) { block.Value.Flip(axis, bim.BlockInfosList.FirstOrDefault(i => i.Type == block.Value.Type)); blocks.Add(block.Key | axis, block.Value); } blocksDict = blocks; if (ClipboardReady) { ToClipboard(); } }
private void FormColors_Load(object sender, EventArgs e) { bim = ((FormMain)Owner).BlockInfosManager; IEnumerable <XElement> colors = XDocument.Load(@"blocks\BlockColors.xml").Root.Elements(); colorTranslation = new Dictionary <Color, BlockInfo>(); foreach (XElement color in colors) { BlockColor bc = new BlockColor(); bc.BlockInfo = bim.BlockInfosList.First(i => !i.Decal && i.Type == (int)color.Attribute("Type")); bc.Color = ColorTranslator.FromHtml((string)color.Attribute("Color")); bc.Click += Bc_Click; flowLayoutPanel.Controls.Add(bc); colorTranslation.Add(bc.Color, bc.BlockInfo); } Bc_Click(null, EventArgs.Empty); }
private void Run() { BlocksCollection ClipboardBlocks = ((FormMain)Owner).ClipboardBlocks; BlocksCollection PuzzleBlocks = ((FormMain)Owner).OpenedLevel == null ? null : ((FormMain)Owner).OpenedLevel.Blocks; string res = ""; try { Lua state = new Lua(); state.LoadCLRPackage(); state.DoString(@" import ('InfiniEditor', 'InfiniEditor')"); state.DoString(@"import = function () end"); state["Clipboard"] = ClipboardBlocks; state["Puzzle"] = PuzzleBlocks; state.DoString(@"enumDict = function(dict) local e = dict:GetEnumerator() return function() if e:MoveNext() then return e.Current.Key, e.Current.Value end end end"); BlockInfosManager bim = new BlockInfosManager(); state.RegisterFunction("BlockInfo", bim, typeof(BlockInfosManager).GetMethod("BlockInfo")); state.RegisterFunction("DecalInfo", bim, typeof(BlockInfosManager).GetMethod("DecalInfo")); state["BIM"] = bim; state.DoString(@"dictToTable = function (dict) table = {} for k, v in enumDict(dict) do table[k]=v end return table end"); state.DoString(@"BlockInfos = function(cond) return dictToTable(BIM:BlockInfos(cond)) end"); state.DoString(@"DecalInfos = function(cond) return dictToTable(BIM:DecalInfos(cond)) end"); state["World"] = Block.Roles.World; state["Input"] = Block.Roles.In; state["Output"] = Block.Roles.Out; state["NegX"] = Direction.NegX; state["PosX"] = Direction.PosX; state["NegZ"] = Direction.NegZ; state["PosZ"] = Direction.PosZ; state["PosY"] = Direction.PosY; state["NegY"] = Direction.NegY; state.DoString(@"Directions = {PosX, NegX, PosY, NegY, PosZ, NegZ}"); state.DoString(@"BlockDirections = {PosX, NegX, PosZ, NegZ}"); state.DoString(@"Blocks = function(x) return enumDict(x.blocksDict) end"); state.DoString(@"Decals = function(x) return enumDict(x.Decals) end"); state.RegisterFunction("print", this, typeof(FormScripting).GetMethod("LogConsole")); state.DoString(richTextBoxCode.Text); ClipboardBlocks.ToClipboard(); res = "Code ran successfully."; ((FormMain)Owner).SaveButtonUpdate(true); ((FormMain)Owner).UpdateBlockCount(); } catch (NLua.Exceptions.LuaScriptException ex) { res = "There was an error executing the code. " + ex.Message.Replace("[string \"chunk\"]:", "line "); } ((FormMain)Owner).Status(res); LogConsole(res); }