public void RestrictPosition(Transform box) { if (!turning) { SCR_Box scrBox = box.GetComponent <SCR_Box>(); if (scrBox != null) { WallDirection wallDirection = scrBox.wallDirection; if (wallDirection == WallDirection.NEGATIVE_X || wallDirection == WallDirection.POSITIVE_X) { transform.position = new Vector3(transform.position.x, transform.position.y, box.position.z); } if (wallDirection == WallDirection.NEGATIVE_Z || wallDirection == WallDirection.POSITIVE_Z) { transform.position = new Vector3(box.position.x, transform.position.y, transform.position.z); } } } }
public SAV_Database(Main f1) { m_parent = f1; InitializeComponent(); PKXBOXES = new[] { bpkx1, bpkx2, bpkx3, bpkx4, bpkx5, bpkx6, bpkx7, bpkx8, bpkx9, bpkx10, bpkx11, bpkx12, bpkx13, bpkx14, bpkx15, bpkx16, bpkx17, bpkx18, bpkx19, bpkx20, bpkx21, bpkx22, bpkx23, bpkx24, bpkx25, bpkx26, bpkx27, bpkx28, bpkx29, bpkx30, bpkx31, bpkx32, bpkx33, bpkx34, bpkx35, bpkx36, bpkx37, bpkx38, bpkx39, bpkx40, bpkx41, bpkx42, bpkx43, bpkx44, bpkx45, bpkx46, bpkx47, bpkx48, bpkx49, bpkx50, bpkx51, bpkx52, bpkx53, bpkx54, bpkx55, bpkx56, bpkx57, bpkx58, bpkx59, bpkx60, bpkx61, bpkx62, bpkx63, bpkx64, bpkx65, bpkx66, }; // Enable Scrolling when hovered over PAN_Box.MouseHover += (sender, args) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; foreach (var slot in PKXBOXES) { slot.MouseEnter += (sender, args) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; // Enable Click slot.MouseClick += (sender, args) => { if (ModifierKeys == Keys.Control) { clickView(sender, args); } else if (ModifierKeys == Keys.Alt) { clickDelete(sender, args); } else if (ModifierKeys == Keys.Shift) { clickSet(sender, args); } }; } Counter = L_Count.Text; Viewed = L_Viewed.Text; L_Viewed.Text = ""; // invis for now populateComboBoxes(); ContextMenuStrip mnu = new ContextMenuStrip(); ToolStripMenuItem mnuView = new ToolStripMenuItem("View"); ToolStripMenuItem mnuDelete = new ToolStripMenuItem("Delete"); // Assign event handlers mnuView.Click += clickView; mnuDelete.Click += clickDelete; // Add to main context menu mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuDelete }); // Assign to datagridview foreach (PictureBox p in PKXBOXES) { p.ContextMenuStrip = mnu; } // Load initial database Database.Add(new DatabaseList { Version = 0, Title = "Misc", Description = "Individual pk6 files present in the db/sav.", }); // Load databases foreach (string file in Directory.GetFiles(DatabasePath, "*", SearchOption.AllDirectories)) { if (new FileInfo(file).Extension == ".pk6") { Database[0].Slot.Add(new PK6(File.ReadAllBytes(file), file)); } else { loadDatabase(File.ReadAllBytes(file)); } } // Fetch from save file foreach (var pk6 in Main.SAV.BoxData.Where(pk => pk.Species != 0)) { Database[0].Slot.Add(pk6); } // Prepare Database prepareDBForSearch(); }
public SAV_MysteryGiftDB(Main f1) { m_parent = f1; InitializeComponent(); // Preset Filters to only show PKM available for loaded save CB_FormatComparator.SelectedIndex = 3; // <= PKXBOXES = new[] { bpkx1, bpkx2, bpkx3, bpkx4, bpkx5, bpkx6, bpkx7, bpkx8, bpkx9, bpkx10, bpkx11, bpkx12, bpkx13, bpkx14, bpkx15, bpkx16, bpkx17, bpkx18, bpkx19, bpkx20, bpkx21, bpkx22, bpkx23, bpkx24, bpkx25, bpkx26, bpkx27, bpkx28, bpkx29, bpkx30, bpkx31, bpkx32, bpkx33, bpkx34, bpkx35, bpkx36, bpkx37, bpkx38, bpkx39, bpkx40, bpkx41, bpkx42, bpkx43, bpkx44, bpkx45, bpkx46, bpkx47, bpkx48, bpkx49, bpkx50, bpkx51, bpkx52, bpkx53, bpkx54, bpkx55, bpkx56, bpkx57, bpkx58, bpkx59, bpkx60, bpkx61, bpkx62, bpkx63, bpkx64, bpkx65, bpkx66, }; // Enable Scrolling when hovered over PAN_Box.MouseHover += (sender, args) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; foreach (var slot in PKXBOXES) { slot.MouseEnter += (sender, args) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; // Enable Click slot.MouseClick += (sender, args) => { if (ModifierKeys == Keys.Control) { clickView(sender, args); } }; } Counter = L_Count.Text; Viewed = L_Viewed.Text; L_Viewed.Text = ""; // invis for now ContextMenuStrip mnu = new ContextMenuStrip(); ToolStripMenuItem mnuView = new ToolStripMenuItem("View"); // Assign event handlers mnuView.Click += clickView; // Add to main context menu mnu.Items.AddRange(new ToolStripItem[] { mnuView }); // Assign to datagridview foreach (PictureBox p in PKXBOXES) { p.ContextMenuStrip = mnu; } // Load Data RawDB = new List <MysteryGift>(); RawDB.AddRange(Legal.MGDB_G6); RawDB.AddRange(Legal.MGDB_G7); if (Directory.Exists(DatabasePath)) { foreach (string file in Directory.GetFiles(DatabasePath, "*", SearchOption.AllDirectories)) { FileInfo fi = new FileInfo(file); if (!MysteryGift.getIsMysteryGift(fi.Length)) { continue; } var mg = MysteryGift.getMysteryGift(File.ReadAllBytes(file), fi.Extension); if (mg != null) { RawDB.Add(mg); } } } RawDB = new List <MysteryGift>(RawDB.Where(mg => !mg.IsItem && mg.IsPokémon && mg.Species > 0).Distinct().OrderBy(mg => mg.Species)); foreach (var mg in RawDB) { mg.GiftUsed = false; } setResults(RawDB); Menu_SearchSettings.DropDown.Closing += (sender, e) => { if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) { e.Cancel = true; } }; populateComboBoxes(); CenterToParent(); }
public SAV_Database(Main f1) { m_parent = f1; InitializeComponent(); // Preset Filters to only show PKM available for loaded save CB_FormatComparator.SelectedIndex = 3; // <= PKXBOXES = new[] { bpkx1, bpkx2, bpkx3, bpkx4, bpkx5, bpkx6, bpkx7, bpkx8, bpkx9, bpkx10, bpkx11, bpkx12, bpkx13, bpkx14, bpkx15, bpkx16, bpkx17, bpkx18, bpkx19, bpkx20, bpkx21, bpkx22, bpkx23, bpkx24, bpkx25, bpkx26, bpkx27, bpkx28, bpkx29, bpkx30, bpkx31, bpkx32, bpkx33, bpkx34, bpkx35, bpkx36, bpkx37, bpkx38, bpkx39, bpkx40, bpkx41, bpkx42, bpkx43, bpkx44, bpkx45, bpkx46, bpkx47, bpkx48, bpkx49, bpkx50, bpkx51, bpkx52, bpkx53, bpkx54, bpkx55, bpkx56, bpkx57, bpkx58, bpkx59, bpkx60, bpkx61, bpkx62, bpkx63, bpkx64, bpkx65, bpkx66, }; // Enable Scrolling when hovered over PAN_Box.MouseHover += (sender, args) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; foreach (var slot in PKXBOXES) { slot.MouseEnter += (sender, args) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; // Enable Click slot.MouseClick += (sender, args) => { if (ModifierKeys == Keys.Control) { clickView(sender, args); } else if (ModifierKeys == Keys.Alt) { clickDelete(sender, args); } else if (ModifierKeys == Keys.Shift) { clickSet(sender, args); } }; } Counter = L_Count.Text; Viewed = L_Viewed.Text; L_Viewed.Text = ""; // invis for now populateComboBoxes(); ContextMenuStrip mnu = new ContextMenuStrip(); ToolStripMenuItem mnuView = new ToolStripMenuItem("View"); ToolStripMenuItem mnuDelete = new ToolStripMenuItem("Delete"); // Assign event handlers mnuView.Click += clickView; mnuDelete.Click += clickDelete; // Add to main context menu mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuDelete }); // Assign to datagridview foreach (PictureBox p in PKXBOXES) { p.ContextMenuStrip = mnu; } // Load Data var dbTemp = new ConcurrentBag <PKM>(); var files = Directory.GetFiles(DatabasePath, "*", SearchOption.AllDirectories); Parallel.ForEach(files, file => { FileInfo fi = new FileInfo(file); if (!fi.Extension.Contains(".pk") || !PKX.getIsPKM(fi.Length)) { return; } var pk = PKMConverter.getPKMfromBytes(File.ReadAllBytes(file), file); if (pk != null) { dbTemp.Add(pk); } }); // Prepare Database RawDB = new List <PKM>(dbTemp.OrderBy(pk => pk.Identifier) .Concat(Main.SAV.BoxData.Where(pk => pk.Species != 0)) // Fetch from save file .Where(pk => pk.ChecksumValid && pk.Species != 0 && pk.Sanity == 0) .Distinct()); setResults(RawDB); Menu_SearchSettings.DropDown.Closing += (sender, e) => { if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) { e.Cancel = true; } }; CenterToParent(); }
public SAV_Database(PKMEditor f1, SAVEditor saveditor) { SAV = saveditor.SAV; BoxView = saveditor; PKME_Tabs = f1; InitializeComponent(); // Preset Filters to only show PKM available for loaded save CB_FormatComparator.SelectedIndex = 3; // <= PKXBOXES = new[] { bpkx1, bpkx2, bpkx3, bpkx4, bpkx5, bpkx6, bpkx7, bpkx8, bpkx9, bpkx10, bpkx11, bpkx12, bpkx13, bpkx14, bpkx15, bpkx16, bpkx17, bpkx18, bpkx19, bpkx20, bpkx21, bpkx22, bpkx23, bpkx24, bpkx25, bpkx26, bpkx27, bpkx28, bpkx29, bpkx30, bpkx31, bpkx32, bpkx33, bpkx34, bpkx35, bpkx36, bpkx37, bpkx38, bpkx39, bpkx40, bpkx41, bpkx42, bpkx43, bpkx44, bpkx45, bpkx46, bpkx47, bpkx48, bpkx49, bpkx50, bpkx51, bpkx52, bpkx53, bpkx54, bpkx55, bpkx56, bpkx57, bpkx58, bpkx59, bpkx60, bpkx61, bpkx62, bpkx63, bpkx64, bpkx65, bpkx66, }; // Enable Scrolling when hovered over PAN_Box.MouseWheel += (sender, e) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; foreach (var slot in PKXBOXES) { slot.MouseWheel += (sender, e) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; // Enable Click slot.MouseClick += (sender, e) => { if (ModifierKeys == Keys.Control) { ClickView(sender, e); } else if (ModifierKeys == Keys.Alt) { ClickDelete(sender, e); } else if (ModifierKeys == Keys.Shift) { ClickSet(sender, e); } }; } Counter = L_Count.Text; Viewed = L_Viewed.Text; L_Viewed.Text = ""; // invis for now var hover = new ToolTip(); L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text); PopulateComboBoxes(); ContextMenuStrip mnu = new ContextMenuStrip(); ToolStripMenuItem mnuView = new ToolStripMenuItem("View"); ToolStripMenuItem mnuDelete = new ToolStripMenuItem("Delete"); // Assign event handlers mnuView.Click += ClickView; mnuDelete.Click += ClickDelete; // Add to main context menu mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuDelete }); // Assign to datagridview foreach (PictureBox p in PKXBOXES) { p.ContextMenuStrip = mnu; } // Load Data var dbTemp = new ConcurrentBag <PKM>(); var files = Directory.GetFiles(DatabasePath, "*", SearchOption.AllDirectories); Parallel.ForEach(files, file => { FileInfo fi = new FileInfo(file); if (!fi.Extension.Contains(".pk") || !PKX.IsPKM(fi.Length)) { return; } var pk = PKMConverter.GetPKMfromBytes(File.ReadAllBytes(file), file, prefer: (fi.Extension.Last() - 0x30) & 7); if (pk != null) { dbTemp.Add(pk); } }); #if DEBUG if (SaveUtil.GetSavesFromFolder(Main.BackupPath, false, out IEnumerable <string> result)) { Parallel.ForEach(result, file => { var sav = SaveUtil.GetVariantSAV(File.ReadAllBytes(file)); var path = EXTERNAL_SAV + new FileInfo(file).Name; if (sav.HasBox) { foreach (var pk in sav.BoxData) { addPKM(pk); } } void addPKM(PKM pk) { pk.Identifier = Path.Combine(path, pk.Identifier); dbTemp.Add(pk); } }); } #endif // Prepare Database RawDB = new List <PKM>(dbTemp.OrderBy(pk => pk.Identifier) .Concat(SAV.BoxData.Where(pk => pk.Species != 0)) // Fetch from save file .Where(pk => pk.ChecksumValid && pk.Species != 0 && pk.Sanity == 0) .Distinct()); SetResults(RawDB); Menu_SearchSettings.DropDown.Closing += (sender, e) => { if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) { e.Cancel = true; } }; CenterToParent(); }
public SAV_MysteryGiftDB(PKMEditor tabs, SAVEditor sav) { SAV = sav.SAV; PKME_Tabs = tabs; InitializeComponent(); // Preset Filters to only show PKM available for loaded save CB_FormatComparator.SelectedIndex = 3; // <= PKXBOXES = new[] { bpkx1, bpkx2, bpkx3, bpkx4, bpkx5, bpkx6, bpkx7, bpkx8, bpkx9, bpkx10, bpkx11, bpkx12, bpkx13, bpkx14, bpkx15, bpkx16, bpkx17, bpkx18, bpkx19, bpkx20, bpkx21, bpkx22, bpkx23, bpkx24, bpkx25, bpkx26, bpkx27, bpkx28, bpkx29, bpkx30, bpkx31, bpkx32, bpkx33, bpkx34, bpkx35, bpkx36, bpkx37, bpkx38, bpkx39, bpkx40, bpkx41, bpkx42, bpkx43, bpkx44, bpkx45, bpkx46, bpkx47, bpkx48, bpkx49, bpkx50, bpkx51, bpkx52, bpkx53, bpkx54, bpkx55, bpkx56, bpkx57, bpkx58, bpkx59, bpkx60, bpkx61, bpkx62, bpkx63, bpkx64, bpkx65, bpkx66, }; // Enable Scrolling when hovered over PAN_Box.MouseWheel += (sender, e) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; foreach (var slot in PKXBOXES) { slot.MouseWheel += (sender, e) => { if (ActiveForm == this) { SCR_Box.Focus(); } }; // Enable Click slot.MouseClick += (sender, e) => { if (ModifierKeys == Keys.Control) { ClickView(sender, e); } }; } Counter = L_Count.Text; Viewed = L_Viewed.Text; L_Viewed.Text = ""; // invis for now var hover = new ToolTip(); L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text); ContextMenuStrip mnu = new ContextMenuStrip(); ToolStripMenuItem mnuView = new ToolStripMenuItem("View"); ToolStripMenuItem mnuSaveMG = new ToolStripMenuItem("Save Gift"); ToolStripMenuItem mnuSavePK = new ToolStripMenuItem("Save PKM"); // Assign event handlers mnuView.Click += ClickView; mnuSaveMG.Click += ClickSaveMG; mnuSavePK.Click += ClickSavePK; // Add to main context menu mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuSaveMG, mnuSavePK }); // Assign to datagridview foreach (PictureBox p in PKXBOXES) { p.ContextMenuStrip = mnu; } // Load Data RawDB = new List <MysteryGift>(); RawDB.AddRange(Legal.MGDB_G4); RawDB.AddRange(Legal.MGDB_G5); RawDB.AddRange(Legal.MGDB_G6); RawDB.AddRange(Legal.MGDB_G7); RawDB = new List <MysteryGift>(RawDB.Where(mg => !mg.IsItem && mg.IsPokémon && mg.Species > 0).Distinct().Concat(Legal.MGDB_G3).OrderBy(mg => mg.Species)); foreach (var mg in RawDB) { mg.GiftUsed = false; } SetResults(RawDB); Menu_SearchSettings.DropDown.Closing += (sender, e) => { if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) { e.Cancel = true; } }; PopulateComboBoxes(); CenterToParent(); }
public void GenerateNextBox(bool fade = true) { count++; Transform next = null; float width = 1; float length = 1; if (count < nextCount) { next = Instantiate(PFB_BOX); if (lastBox.tag == "Box") { width = 1; float r = Random.Range(0f, 1f); if (r < rateShort) { length = 1.5f; next.GetComponent <SCR_Box>().SetLength(BoxLength.SHORT); } else if (r < rateShort + rateMedium) { length = 2.5f; next.GetComponent <SCR_Box>().SetLength(BoxLength.MEDIUM); } else { length = 3.5f; next.GetComponent <SCR_Box>().SetLength(BoxLength.LONG); } key++; float shortRange = 0.666f; float shortMin = 0.333f; float shortAccelRev = 10.0f; rateShort = (key * shortRange) / (key + shortAccelRev) + shortMin; /* * float mediumRange = 0.166f; * float mediumMin = 0.333f; * float mediumAccelRev = 50.0f; * rateMedium = (key * mediumRange) / (key + mediumAccelRev) + mediumMin; */ Time.timeScale = (key * speedRange) / (key + speedAccelRev) + speedMin; } if (lastBox.tag == "Corner") { width = 1; length = 2.2f; next.GetComponent <SCR_Box>().SetLength(BoxLength.MEDIUM); } } else { next = Instantiate(PFB_CORNER); /* * float r = Random.Range(0f, 1f); * if (r < 0.5f) { * next.GetComponent<SCR_Corner>().turnDirection = TurnDirection.LEFT; * } * else { * next.GetComponent<SCR_Corner>().turnDirection = TurnDirection.RIGHT; * } */ next.GetComponent <SCR_Corner>().turnDirection = nextTurnDirection; if (nextTurnDirection == TurnDirection.LEFT) { nextTurnDirection = TurnDirection.RIGHT; } else { nextTurnDirection = TurnDirection.LEFT; } width = 1; length = 2.2f; next.GetComponent <SCR_Box>().SetLength(BoxLength.MEDIUM); count = 0; float r = Random.Range(0f, 1f); if (r < 0.3f) { nextCount = 2; } else { nextCount = Random.Range(3, 7); } } float x = lastBox.position.x; float y = lastBox.position.y; float z = lastBox.position.z; SCR_Box scrBoxLast = lastBox.GetComponent <SCR_Box>(); SCR_Box scrBoxNext = next.GetComponent <SCR_Box>(); if (lastBox.tag == "Box") { WallDirection wallDirection = scrBoxLast.wallDirection; if (wallDirection == WallDirection.NONE) { wallDirection = savedWallDirection; } if (wallDirection == WallDirection.NEGATIVE_X) { next.localScale = new Vector3(length, PFB_BOX.localScale.y, width); x += lastBox.localScale.x * 0.5f + next.localScale.x * 0.5f; y += PFB_BOX.localScale.y; } if (wallDirection == WallDirection.POSITIVE_X) { next.localScale = new Vector3(length, PFB_BOX.localScale.y, width); x -= lastBox.localScale.x * 0.5f + next.localScale.x * 0.5f; y += PFB_BOX.localScale.y; } if (wallDirection == WallDirection.NEGATIVE_Z) { next.localScale = new Vector3(width, PFB_BOX.localScale.y, length); y += PFB_BOX.localScale.y; z += lastBox.localScale.z * 0.5f + next.localScale.z * 0.5f; } if (wallDirection == WallDirection.POSITIVE_Z) { next.localScale = new Vector3(width, PFB_BOX.localScale.y, length); y += PFB_BOX.localScale.y; z -= lastBox.localScale.z * 0.5f + next.localScale.z * 0.5f; } scrBoxNext.wallDirection = wallDirection; } if (lastBox.tag == "Corner") { SCR_Corner scrCorner = lastBox.GetComponent <SCR_Corner>(); scrBoxNext.wallDirection = WallDirection.NONE; Transform cylinder = Instantiate(PFB_CYLINDER); scrBoxNext.cylinder = cylinder; if (scrBoxLast.wallDirection == WallDirection.NEGATIVE_X) { next.localScale = new Vector3(width, PFB_BOX.localScale.y, length); x += lastBox.localScale.x * 0.5f; if (scrCorner.turnDirection == TurnDirection.LEFT) { z += next.localScale.z * 0.5f; savedWallDirection = WallDirection.NEGATIVE_Z; } if (scrCorner.turnDirection == TurnDirection.RIGHT) { z -= next.localScale.z * 0.5f; savedWallDirection = WallDirection.POSITIVE_Z; } cylinder.position = new Vector3(lastBox.position.x + lastBox.localScale.x * 0.5f, lastBox.position.y, lastBox.position.z); } if (scrBoxLast.wallDirection == WallDirection.POSITIVE_X) { next.localScale = new Vector3(width, PFB_BOX.localScale.y, length); x -= lastBox.localScale.x * 0.5f; if (scrCorner.turnDirection == TurnDirection.LEFT) { z -= next.localScale.z * 0.5f; savedWallDirection = WallDirection.POSITIVE_Z; } if (scrCorner.turnDirection == TurnDirection.RIGHT) { z += next.localScale.z * 0.5f; savedWallDirection = WallDirection.NEGATIVE_Z; } cylinder.position = new Vector3(lastBox.position.x - lastBox.localScale.x * 0.5f, lastBox.position.y, lastBox.position.z); } if (scrBoxLast.wallDirection == WallDirection.NEGATIVE_Z) { next.localScale = new Vector3(length, PFB_BOX.localScale.y, width); z += lastBox.localScale.z * 0.5f; if (scrCorner.turnDirection == TurnDirection.LEFT) { x -= next.localScale.x * 0.5f; savedWallDirection = WallDirection.POSITIVE_X; } if (scrCorner.turnDirection == TurnDirection.RIGHT) { x += next.localScale.x * 0.5f; savedWallDirection = WallDirection.NEGATIVE_X; } cylinder.position = new Vector3(lastBox.position.x, lastBox.position.y, lastBox.position.z + lastBox.localScale.z * 0.5f); } if (scrBoxLast.wallDirection == WallDirection.POSITIVE_Z) { next.localScale = new Vector3(length, PFB_BOX.localScale.y, width); z -= lastBox.localScale.z * 0.5f; if (scrCorner.turnDirection == TurnDirection.LEFT) { x += next.localScale.x * 0.5f; savedWallDirection = WallDirection.NEGATIVE_X; } if (scrCorner.turnDirection == TurnDirection.RIGHT) { x -= next.localScale.x * 0.5f; savedWallDirection = WallDirection.POSITIVE_X; } cylinder.position = new Vector3(lastBox.position.x, lastBox.position.y, lastBox.position.z - lastBox.localScale.z * 0.5f); } } next.position = new Vector3(x, y, z); //if (fade) { //iTween.FadeFrom(next.gameObject, iTween.Hash("alpha", 0, "time", 0.5f)); //} scrBoxNext.GenerateGem(); lastBox = next; }