void OnGUI() { // Title Group GUI.BeginGroup(new Rect(120, 10, 300, 100)); GUILayout.Label("TRACK PAD PLACEMENT", EditorStyles.boldLabel); GUI.EndGroup(); isPlacing = EditorGUILayout.BeginToggleGroup("Enabled", isPlacing); GUI.BeginGroup(new Rect(0, 20, 400, 600)); currentPad = (Pads)EditorGUILayout.EnumPopup("Place:", currentPad); SpeedPrefab = (GameObject)EditorGUILayout.ObjectField("Speed Prefab:", SpeedPrefab, typeof(GameObject), true); WeaponPrefab = (GameObject)EditorGUILayout.ObjectField("Weapon Prefab:", WeaponPrefab, typeof(GameObject), true); StartPrefab = (GameObject)EditorGUILayout.ObjectField("Start Prefab:", StartPrefab, typeof(GameObject), true); EditorGUILayout.Separator(); GUILayout.Label("This tool is not for accurate placement."); GUILayout.Label("You use this tool to quickly place pads where you want them,"); GUILayout.Label("it will rotate the pad to the track normal but you will have"); GUILayout.Label("to apply the final rotations yourself (I reccomend you have"); GUILayout.Label("the handle space set to local when doing so)."); GUI.EndGroup(); EditorGUILayout.EndToggleGroup(); }
public void UpdateValues() { if (!IsHandleCreated || IsDisposed) { return; } Pads.ForEach(p => p.SetPrevious(null)); // Not the cleanest way to clear this every frame if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) { Readonly = true; Pads.ForEach(p => p.Set(Global.MovieSession.CurrentInput)); } else { if (Global.MovieSession.Movie.IsRecording) { Pads.ForEach(p => p.SetPrevious(Global.MovieSession.PreviousFrame)); } Readonly = false; } if (!Readonly && !StickyPads && !Control.MouseButtons.HasFlag(MouseButtons.Left)) { Pads.ForEach(pad => pad.Clear()); } Pads.ForEach(pad => pad.UpdateValues()); }
public void FastUpdate() { // TODO: SetPrevious logic should go here too or that will get out of whack if (!Readonly && !StickyPads) { Pads.ForEach(pad => pad.Clear()); } }
public void ClearVirtualPadHolds() { if (Global.Config.VirtualPadClearClearsAnalog) { Pads.ForEach(pad => pad.Clear()); } else { Pads.ForEach(pad => pad.ClearBoolean()); } }
public void ClearVirtualPadHolds() { if (ClearAlsoClearsAnalog) { Pads.ForEach(pad => pad.Clear()); } else { Pads.ForEach(pad => pad.ClearBoolean()); } }
/// <summary> /// Creates, initializes pads and populates the Pads list. /// </summary> protected virtual void CreatePads() { Pads.Clear(); ErrorsPad = new ErrorListPad(Platform.Project); Pads.Add(ErrorsPad); TasksPad = new TaskListPad(Platform.Project); Pads.Add(TasksPad); ProjectPad = new ProjectPad(Platform.Project); ProjectPad.ItemDoubleClicked += () => MainForm.ShowEditorFor(ProjectPad.SelectedItem); ProjectPad.AddNewItemClicked += () => AddNewProjectItem(); ProjectPad.AddExistingItemClicked += () => AddExistingProjectItem(); ProjectPad.RemoveClicked += () => RemoveProjectItem(ProjectPad.SelectedItem); Pads.Add(ProjectPad); }
/// <summary> /// Creates, initializes pads and populates the Pads list. /// </summary> protected override void CreatePads() { base.CreatePads(); WatchPad = new WatchPad(Platform.Project); WatchPad.WatchAdded += new Action <WatchPad.WatchItem>(UpdateWatchItem); WatchPad.WatchValueEdited += new Action <WatchPad.WatchItem, long>(EditWatchValue); Pads.Add(WatchPad); BreakpointsPad = new BreakpointsPad(Platform.Project); BreakpointsPad.BreakpointController = Platform.DebuggerController.BreakpointController; Pads.Add(BreakpointsPad); HardwarePad = new HardwarePad(Platform.Project); Pads.Add(HardwarePad); }
/// <summary> /// Creates, initializes pads and populates the Pads list. /// </summary> protected override void CreatePads() { base.CreatePads(); WatchPad.Types = new string[] { "Signed", "Unsigned" }; (BreakpointsPad.NewIOBreakpointDialog as NewIOBreakpointForm).SetAddress(0, false); var newRegBp = BreakpointsPad.NewRegisterBreakpointDialog as NewRegisterBreakpointForm; newRegBp.SetRegisterNames(new string[] { "SP", "PC" }); newRegBp.SetOnRead(false, false); newRegBp.SetOnWrite(true, true); ConsolePad = new ConsolePad(Platform.Project); var dc = Platform.DebuggerController as PicoDebuggerController; dc.IODevice = ConsolePad; Pads.Add(ConsolePad); }
Pad WrapPad(PadCodon padContent) { if (pads == null) { foreach (Pad p in Pads) { if (p.InternalContent == padContent) { return(p); } } } Pad pad = new Pad(workbench, padContent); Pads.Add(pad); pad.Window.PadDestroyed += delegate { Pads.Remove(pad); }; return(pad); }
public void Load() { bool settingsLoaded = false; // If configuration file not exists then... var settingsFi = new System.IO.FileInfo(InitialFile.FullName); if (settingsFi.Exists) { while (true) { SettingsFile data; // Deserialize and load data. lock (saveReadFileLock) { try { data = Serializer.DeserializeFromXmlFile <SettingsFile>(InitialFile.FullName); if (data == null) { return; } Programs.Clear(); if (data.Programs != null) { // Make sure default settings have unique by file name. var distinctPrograms = data.Programs .GroupBy(p => p.FileName.ToLower()) .Select(g => g.First()) .ToList(); for (int i = 0; i < distinctPrograms.Count; i++) { Programs.Add(distinctPrograms[i]); } } Games.Clear(); if (data.Games != null) { // Make sure default settings have unique by file name. var distinctGames = data.Games .GroupBy(p => p.FileName.ToLower()) .Select(g => g.First()) .ToList(); for (int i = 0; i < distinctGames.Count; i++) { Games.Add(distinctGames[i]); } } Pads.Clear(); if (data.Pads != null) { for (int i = 0; i < data.Pads.Count; i++) { Pads.Add(data.Pads[i]); } } settingsLoaded = true; break; } catch (Exception) { var form = new MessageBoxForm(); var backupFile = InitialFile.FullName + ".bak"; form.StartPosition = FormStartPosition.CenterParent; var result = form.ShowForm( "User settings file has become corrupted.\r\n" + "Program must reset your user settings in order to continue.\r\n\r\n" + " Click [Yes] to reset your user settings and continue.\r\n" + " Click [No] if you wish to attempt manual repair.\r\n\r\n" + "Settings File: " + InitialFile.FullName, "Corrupt user settings of " + Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { if (System.IO.File.Exists(backupFile)) { System.IO.File.Copy(backupFile, InitialFile.FullName, true); settingsFi.Refresh(); } else { System.IO.File.Delete(InitialFile.FullName); break; } } else { // Avoid the inevitable crash by killing application first. Process.GetCurrentProcess().Kill(); return; } } } } } // If settings failed to load then... if (!settingsLoaded) { var resource = EngineHelper.GetResource("x360ce_Games.xml.gz"); // If internal preset was found. if (resource != null) { var sr = new StreamReader(resource); var compressedBytes = default(byte[]); using (var memstream = new MemoryStream()) { sr.BaseStream.CopyTo(memstream); compressedBytes = memstream.ToArray(); } var bytes = EngineHelper.Decompress(compressedBytes); var xml = System.Text.Encoding.UTF8.GetString(bytes); var programs = Serializer.DeserializeFromXmlString <List <x360ce.Engine.Data.Program> >(xml); Programs.Clear(); for (int i = 0; i < programs.Count; i++) { Programs.Add(programs[i]); } } } // Check if current app doesn't exist in the list then... var currentFile = new System.IO.FileInfo(Application.ExecutablePath); var currentGame = Games.FirstOrDefault(x => x.FileName == currentFile.Name); if (currentGame == null) { // Add x360ce.exe var item = x360ce.Engine.Data.Game.FromDisk(currentFile.Name); var program = Programs.FirstOrDefault(x => x.FileName == currentFile.Name); item.LoadDefault(program); SettingsFile.Current.Games.Add(item); } else { currentGame.FullPath = currentFile.FullName; } }
public override string ToString() { // OutputString($"outputting {Name}"); try { PadComparer pc = new PadComparer(); // put pads in numerical order (not really necessary) Pads.Sort(pc); if (Attr == "smd") { foreach (var pad in Pads) { if (pad.Type == "thru_hole") { Attr = ""; } } } StringBuilder ret = new StringBuilder(""); //X -= Globals.MinX; //Y -= Globals.MaxY; string LOCKED = (Locked) ? "locked" : ""; ret.Append($" (module \"{Name}\" {LOCKED} (layer {Layer}) {Tedit} {Tstamp}\n"); ret.Append($" (at {X} {-(Y)} {Rotation})\n"); if (Attr != "") { ret.Append($" (attr {Attr})\n"); } // this bit is for a particular test board where the idiot had put the Comment as .designator if (Strings != null) { foreach (var str in Strings) { if (str.Value.ToLower() == ".comment") { str.Value = Comment; } if (str.Value.ToLower() == ".designator") { str.Value = Designator; } } } if (Strings != null) { ret.Append(Strings.ToString(X, Y, Rotation)); } if (Pads != null) { ret.Append(Pads.ToString(X, Y, Rotation)); } // ret += Vias.ToString(X, Y, Rotation); // vias not allowed in modules...yet if (Lines != null) { ret.Append(Lines.ToString(X, Y, -Rotation)); } if (Arcs != null) { ret.Append(Arcs.ToString(X, Y, -Rotation)); } if (Fills != null) { ret.Append(Fills.ToString(X, Y, -Rotation)); } if (Polygons != null) { ret.Append(Polygons.ToString()); } if (Regions != null) { ret.Append(Regions.ToString(X, Y, -Rotation)); } CurrentLayer = Layer; if (ComponentBodies != null) { ret.Append(ComponentBodies.ToString(X, Y, Rotation)); // (Layer=="F.Cu")?-Rotation:-(Rotation-180)); } if (ShapeBasedModels != null) { ret.Append(ShapeBasedModels.ToString(X, Y, -Rotation)); } ret.Append(" )\n"); return(ret.ToString()); } catch (Exception Ex) { CheckThreadAbort(Ex); return(""); } }
public async Task <PagedCollection <PadSeriesReadModel> > ReadAll(PagingOptions paging) { using (var conn = OpenConnection()) { // Pull in the parent records first var series = await conn.QueryAsync <PadSeriesRow, BrandRow, PadSeriesReadModel>( @" select * from pad_series ps join brands b on ps.brand_id = b.id order by b.name limit @Limit offset @Offset; ", (ps, b) => new PadSeriesReadModel( ps.Id, ps.Name, new BrandReadModel( b.Id, b.Name ), ps.PolisherTypes.ToList() ), new { Limit = paging.PageSize, Offset = paging.Offset } ); var seriesLookup = new Dictionary <Guid, PadSeriesReadModel>(series.Select(p => new KeyValuePair <Guid, PadSeriesReadModel>(p.Id, p))); // Now get the rest using (var reader = await conn.QueryMultipleAsync( @" select count(*) from pad_series; select * from pad_sizes where pad_series_id = any(@Series); select pi.* from pad_images pi join pads p on pi.pad_id = p.id where pad_series_id = any(@Series); select p.* from pads p where pad_series_id = any(@Series) group by p.id order by name; select po.* from pad_options po left join pads p on po.pad_id = p.id; select po.id as pad_option_id, pn.* from part_numbers pn join pad_option_part_numbers popn on pn.id = popn.part_number_id join pad_options po on po.id = popn.pad_option_id; " , new { Series = series.Select(s => s.Id).ToArray() // We only want series that we got back. })) { var totalCount = reader.ReadFirst <int>(); var sizes = reader.Read <PadSizeRow>(); foreach (var size in sizes) { PadSeriesReadModel?s; if (seriesLookup.TryGetValue(size.PadSeriesId, out s)) { s.Sizes.Add(new PadSizeReadModel( size.Id, new MeasurementReadModel(size.DiameterAmount, size.DiameterUnit), size.ThicknessAmount != null ? new MeasurementReadModel(size.ThicknessAmount ?? 0, size.ThicknessUnit !) : null ) ); } } var images = reader.Read <(Guid PadId, Guid ImageId)>(); var pads = new Dictionary <Guid, PadReadModel>(); var rawPads = reader.Read(); foreach (var raw in rawPads) { Guid?imageId = images.Where(i => i.PadId == raw.id).FirstOrDefault().ImageId; if (imageId == Guid.Empty) { imageId = null; } var pad = new PadReadModel( raw.id, raw.name, ((PadCategoryBitwise)raw.category).ToList(), raw.material, raw.texture, raw.color, raw.has_center_hole, imageId, new List <PadOptionReadModel>() ); pads.Add(pad.Id, pad); PadSeriesReadModel?s; if (seriesLookup.TryGetValue(raw.pad_series_id, out s)) { s !.Pads.Add(pad); } } var options = reader.Read <PadOptionRow>(); var optionDict = new Dictionary <Guid, PadOptionReadModel>(); foreach (var opt in options) { PadReadModel?pad; if (pads.TryGetValue(opt.PadId, out pad)) { var po = new PadOptionReadModel(opt.Id, opt.PadSizeId); pad.Options.Add(po); optionDict.Add(opt.Id, po); } } var partNumbers = reader.Read <Guid, PartNumberRow, (Guid PadOptionId, PartNumberRow PartNumber)>((id, pn) => (id, pn)); foreach (var partNumber in partNumbers) { PadOptionReadModel?option; if (optionDict.TryGetValue(partNumber.PadOptionId, out option)) { option.PartNumbers.Add(new PartNumberReadModel(partNumber.PartNumber.Id, partNumber.PartNumber.Value, partNumber.PartNumber.Notes)); } } return(new PagedCollection <PadSeriesReadModel>(new Paging(paging, totalCount), seriesLookup.Values)); } } }
public override string ToString() { // OutputString($"outputting {Name}"); try { string ret = ""; ret = $" (module \"{Name}\" (layer {Layer}) {Tedit} {Tstamp}\n"; ret += $" (at {X} {-Y} {Rotation})\n"; ret += $" (attr {Attr})\n"; // this bit is for a particular test board where the idiot had put the Comment as .designator if (Strings != null) { foreach (var str in Strings) { if (str.Value.ToLower() == ".comment") { str.Value = Comment; } if (str.Value.ToLower() == ".designator") { str.Value = Designator; } } } if (Strings != null) { ret += Strings.ToString(X, Y, Rotation); } PadComparer pc = new PadComparer(); // put pads in numerical order (not really necessary) Pads.Sort(pc); if (Pads != null) { ret += Pads.ToString(X, Y, Rotation); } // ret += Vias.ToString(X, Y, Rotation); // vias not allowed in modules...yet if (Lines != null) { ret += Lines.ToString(X, Y, -Rotation); } if (Arcs != null) { ret += Arcs.ToString(X, Y, -Rotation); } if (Fills != null) { ret += Fills.ToString(X, Y, -Rotation); } if (Polygons != null) { ret += Polygons.ToString(); } if (Regions != null) { ret += Regions.ToString(X, Y, -Rotation); } CurrentLayer = Layer; if (ComponentBodies != null) { ret += ComponentBodies.ToString(X, Y, Rotation); // (Layer=="F.Cu")?-Rotation:-(Rotation-180)); } if (ShapeBasedModels != null) { ret += ShapeBasedModels.ToString(X, Y, -Rotation); } ret += " )\n"; return(ret); } catch (Exception Ex) { CheckThreadAbort(Ex); return(""); } }
public void UpdatePads() { EncryptKVS("pads", JsonConvert.SerializeObject(Pads.Select(x => x.Name))); }
void AddPad(Type type) { PadDescriptor descriptor = WorkbenchSingleton.Workbench.GetPad(type); Pads.Add(new PadViewModel(descriptor)); }
private void addPads() { Pads.Add(new Point(1, 6), Instantiate(grounds[10], Grid[new Point(1, 6)].transform.position, rotation: Quaternion.identity)); }
public void BumpAnalogValue(int?x, int?y) // TODO: multi-player { Pads.ForEach(pad => pad.BumpAnalog(x, y)); }
void AddPad(Pad pad) { Pads.Add(pad); }