public CDDesignerCommandSet(ComponentDesigner componentDesigner) { this.componentDesigner = componentDesigner; }
public ListControlUnboundActionList(ComponentDesigner designer) : base(designer.Component) { _designer = designer; }
// Methods public ListBoxItem(DataGridViewColumn column, ExtDataGridColumnCollectionDialog owner, ComponentDesigner compDesigner) { this.column = column; this.owner = owner; this.compDesigner = compDesigner; if (this.compDesigner != null) { this.compDesigner.Initialize(column); TypeDescriptor.CreateAssociation(this.column, this.compDesigner); } ToolboxBitmapAttribute attribute = TypeDescriptor.GetAttributes(column)[ExtDataGridColumnCollectionDialog.toolboxBitmapAttributeType] as ToolboxBitmapAttribute; if (attribute != null) { this.toolboxBitmap = attribute.GetImage(column, false); } else { //this.toolboxBitmap = this.owner.SelectedColumnsItemBitmap; } DataGridViewColumnDesigner designer = compDesigner as DataGridViewColumnDesigner; if (designer != null) { //designer.LiveDataGridView = this.owner.liveDataGridView; } }
public static void RefreshHighlights() { try { if (bSkipHighlighting) { return; } if (variablesToolWindowControl == null) { return; } #if DENALI || SQL2014 packageDesigner = (ComponentDesigner)variablesToolWindowControl.GetType().GetProperty("PackageDesigner", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance).GetValue(variablesToolWindowControl, null); #else packageDesigner = (ComponentDesigner)variablesToolWindowControl.GetType().InvokeMember("PackageDesigner", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, variablesToolWindowControl, null); #endif if (packageDesigner == null) { return; } Package package = packageDesigner.Component as Package; if (package == null) { return; } List <string> listConfigPaths; lock (HighlightingToDo.cacheConfigPaths) { if (HighlightingToDo.cacheConfigPaths.ContainsKey(package)) { listConfigPaths = HighlightingToDo.cacheConfigPaths[package]; } else { listConfigPaths = new List <string>(); } } for (int iRow = 0; iRow < grid.RowsNumber; iRow++) { GridCell cell = grid.GetCellInfo(iRow, 0); if (cell.CellData != null) { System.Diagnostics.Debug.WriteLine(cell.CellData.GetType().FullName); Variable variable = GetVariableForRow(iRow); #if DENALI || SQL2014 // Denali doesn't need variable highlighting, it is built in. This is a quick fix to disable the highlighting // for Denali only. The other code stays the same for backward compatability when compiled as 2005 or 2008 projects. // We will retain the configuration highlighting though. bool bHasExpression = false; #else bool bHasExpression = variable.EvaluateAsExpression && !string.IsNullOrEmpty(variable.Expression); #endif bool bHasConfiguration = false; string sVariablePath = variable.GetPackagePath(); foreach (string configPath in listConfigPaths) { if (configPath.StartsWith(sVariablePath)) { bHasConfiguration = true; break; } } System.Drawing.Bitmap icon = (System.Drawing.Bitmap)cell.CellData; if (!bHasExpression && !bHasConfiguration && icon.Tag != null) { // Reset the icon because this one doesn't have an expression anymore cell.CellData = icon.Tag; icon.Tag = null; try { bSkipHighlighting = true; grid.Invalidate(true); } finally { bSkipHighlighting = false; } System.Diagnostics.Debug.WriteLine("un-highlighted variable"); } else if ((bHasExpression || bHasConfiguration)) { //save what the icon looked like originally so we can go back if they remove the expression if (icon.Tag == null) { icon.Tag = icon.Clone(); } //now update the icon to note this one has an expression if (bHasExpression && !bHasConfiguration) { HighlightingToDo.ModifyIcon(icon, HighlightingToDo.expressionColor); } else if (bHasConfiguration && !bHasExpression) { HighlightingToDo.ModifyIcon(icon, HighlightingToDo.configurationColor); } else { HighlightingToDo.ModifyIcon(icon, HighlightingToDo.expressionColor, HighlightingToDo.configurationColor); } cell.CellData = icon; try { bSkipHighlighting = true; grid.Invalidate(true); } finally { bSkipHighlighting = false; } System.Diagnostics.Debug.WriteLine("highlighted variable"); } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message + "\r\n\r\n" + ex.StackTrace); } }
// Methods public ListViewActionList(ComponentDesigner designer) : base(designer.Component) { this._designer = designer; }
internal override void Display() { if (IsActive && ImGui.Begin("Component Design", ref IsActive, _flags)) { GuiDesignUI(); //Part design ImGui.Columns(2, "Main"); //Col 1 contains list of comp types, col 2 contains the cost int numelements = Convert.ToInt32((ImGui.GetContentRegionAvail().Y - 20) / 17); if (numelements < 4) { numelements = 4; } else if (numelements > _designTypes.Length) { numelements = _designTypes.Length; } ImGui.PushItemWidth(-1); if (ImGui.ListBox("", ref _designType, _designTypes, _designTypes.Length, numelements))//Lists the possible comp types { var factionTech = _state.Faction.GetDataBlob <FactionTechDB>(); var staticdata = StaticRefLib.StaticData; _componentDesigner = new ComponentDesigner(_designables[_designType], factionTech); _nameInputBuffer = ImGuiSDL2CSHelper.BytesFromString(_componentDesigner.Name, 32); } ImGui.NextColumn(); GuiCostText();//Print cost ImGui.End(); } void GuiDesignUI()//Creates all UI elements need for designing the Component { ImGui.Text("Component Specifications"); ImGui.SameLine(ImGui.GetWindowWidth() - 70); if (ImGui.Button("Compact")) { compactmod = !compactmod; } ImGui.NewLine(); if (_componentDesigner != null) //Make sure comp is selected { foreach (ComponentDesignAttribute attribute in _componentDesigner.ComponentDesignAttributes.Values) //For each property of the comp type { switch (attribute.GuiHint) //Either { case GuiHint.None: break; case GuiHint.GuiTechSelectionList: //Let the user pick a type from a list GuiHintTechSelection(attribute); break; case GuiHint.GuiSelectionMaxMin: //Set a value GuiHintMaxMin(attribute); break; case GuiHint.GuiTextDisplay: //Display a stat GuiHintText(attribute); break; default: throw new ArgumentOutOfRangeException(); } } ImGui.Text("Name"); ImGui.InputText("", _nameInputBuffer, 32); if (ImGui.Button("Create Design")) { _componentDesigner.Name = ImGuiSDL2CSHelper.StringFromBytes(_nameInputBuffer); _componentDesigner.CreateDesign(_state.Faction); //we reset the designer here, so we don't end up trying to edit the precious design. var factionTech = _state.Faction.GetDataBlob <FactionTechDB>(); _componentDesigner = new ComponentDesigner(_designables[_designType], factionTech); } ImGui.NewLine(); } else//Tell the user they don't have a comp type selected { ImGui.NewLine(); ImGui.Text("No component type selected"); ImGui.NewLine(); } } void GuiCostText()//Prints a 2 col table with the costs of the part { ImGui.BeginChild("Cost"); if (_componentDesigner != null)//If a part time is selected { ImGui.Columns(2); ImGui.BeginTabItem("Cost"); ImGui.Text("Mass"); ImGui.Text("Volume"); ImGui.Text("Crew Requred"); ImGui.Text("Cost"); ImGui.Text("Research Cost"); ImGui.Text("Build Cost"); ImGui.Text("Resource Costs"); ImGui.NextColumn();//Add all the cost names to col 1 ImGui.Text(_componentDesigner.MassValue.ToString()); ImGui.Text(_componentDesigner.VolumeValue.ToString()); ImGui.Text(_componentDesigner.CrewReqValue.ToString()); ImGui.Text(_componentDesigner.CreditCostValue.ToString()); ImGui.Text(_componentDesigner.ResearchCostValue.ToString()); ImGui.Text(_componentDesigner.IndustryPointCostsValue.ToString()); ImGui.NextColumn();//Add all the price values to col 2 foreach (var kvp in _componentDesigner.ResourceCostValues) { var resource = StaticRefLib.StaticData.CargoGoods.GetAny(kvp.Key); if (resource == null) { resource = (ICargoable)_state.Faction.GetDataBlob <FactionInfoDB>().IndustryDesigns[kvp.Key]; } var xpos = ImGui.GetCursorPosX(); ImGui.SetCursorPosX(xpos + 12); ImGui.Text(resource.Name); ImGui.NextColumn(); ImGui.Text(kvp.Value.ToString()); ImGui.NextColumn(); } //Old Cost code I think if (false) { /* * foreach (var mineral in _componentDesigner.MineralCostValues) * { * var mineralSD = StaticRefLib.StaticData.CargoGoods.GetMineral(mineral.Key); * var xpos = ImGui.GetCursorPosX(); * ImGui.SetCursorPosX(xpos + 12); * ImGui.Text(mineralSD.Name); * ImGui.NextColumn(); * ImGui.Text(mineral.Value.ToString()); * ImGui.NextColumn(); * } * foreach (var material in _componentDesigner.MaterialCostValues) * { * var matSD = StaticRefLib.StaticData.CargoGoods.GetMaterial(material.Key); * var xpos = ImGui.GetCursorPosX(); * ImGui.SetCursorPosX(xpos + 12); * ImGui.Text(matSD.Name); * ImGui.NextColumn(); * ImGui.Text(material.Value.ToString()); * ImGui.NextColumn(); * } * foreach (var component in _componentDesigner.ComponentCostValues) * { * var compSD = StaticRefLib.StaticData.CargoGoods.GetMaterial(component.Key); * var xpos = ImGui.GetCursorPosX(); * ImGui.SetCursorPosX(xpos + 12); * ImGui.Text(compSD.Name); * ImGui.NextColumn(); * ImGui.Text(component.Value.ToString()); * ImGui.NextColumn(); * } */ /* * ImGui.Text("Materials"); * ImGui.NextColumn(); * ImGui.Text(_componentDesigner.MassValue.ToString()); * ImGui.NextColumn(); * * ImGui.Text("Components"); * ImGui.NextColumn(); * ImGui.Text(_componentDesigner.MassValue.ToString()); * ImGui.NextColumn(); */ } } ImGui.EndChild(); } void GuiHintText(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Value.ToString()); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Value.ToString()); ImGui.NewLine(); } } void GuiHintMaxMin(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } attribute.SetMax(); attribute.SetMin(); attribute.SetValue(); attribute.SetStep(); var max = attribute.MaxValue; var min = attribute.MinValue; double val = attribute.Value; double step = attribute.StepValue; double fstep = step * 10; IntPtr valPtr; IntPtr maxPtr; IntPtr minPtr; IntPtr stepPtr; IntPtr fstepPtr; unsafe { valPtr = new IntPtr(&val); maxPtr = new IntPtr(&max); minPtr = new IntPtr(&min); stepPtr = new IntPtr(&step); fstepPtr = new IntPtr(&fstep); } //ImGui.DragScalar("##slider" + attribute.Name, ImGuiDataType.Double, valPtr, 1f, minPtr, maxPtr); if (compactmod) { } else { ImGui.PushItemWidth(-1); if (ImGui.SliderScalar("##scaler" + attribute.Name, ImGuiDataType.Double, valPtr, minPtr, maxPtr)) { attribute.SetValueFromInput(val); } } ImGui.PushItemWidth(-1); if (ImGui.InputScalar("##input" + attribute.Name, ImGuiDataType.Double, valPtr, stepPtr, fstepPtr)) { attribute.SetValueFromInput(val); } ImGui.NewLine(); } void GuiHintTechSelection(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } //StaticRefLib.StaticData.Techs[attribute.Value] ImGui.TextWrapped(attribute.Value.ToString()); /* * int techSelection; * List<string> techs = attribute.GuidDictionary * * if (ImGui.ListBox("Tech" + attribute.Name, ref _designType, _designTypes, _designTypes.Length)) * { * var factionTech = _uiState.Faction.GetDataBlob<FactionTechDB>(); * var staticdata = StaticRefLib.StaticData; * _componentDesign = GenericComponentFactory.StaticToDesign(_designables[_designType], factionTech, staticdata); * }*/ ImGui.NewLine(); } }
/// <summary>Shows a form tied to a designer.</summary> /// <param name="designer">The designer for a component.</param> /// <param name="dialog">A form instance.</param> /// <returns>The result of calling ShowDialog on the form.</returns> public static DialogResult ShowDialog(this ComponentDesigner designer, Form dialog) { var context = new EditorServiceContext(designer); return(context.ShowDialog(dialog)); }
public AdvancedScadaListItem(ComponentDesigner owner) : base(owner.Component) { shape = (HMIAdvancedScada)owner.Component; }
/// <summary> /// Initializes a new instance of the <see cref="EditorServiceContext"/> class. /// </summary> /// <param name="designer">The designer.</param> internal NuGenEditorServiceContext(ComponentDesigner designer) { _designer = designer; }
protected AttributedDesignerActionList(ComponentDesigner designer, IComponent component) : base(component) { ParentDesigner = designer; AutoShow = true; }
public XmlElement ComponentSerialization(XmlDocument doc, IComponent currentCom) { if (currentCom is ABCView && currentCom == this.Surface.DesignerHost.RootComponent) { ((ABCView)currentCom).Location = new Point(0, 0); } Type type = currentCom.GetType(); XmlElement ele = ABCPresentHelper.Serialization(doc, currentCom, "C"); if (currentCom is ABCView) { if (currentCom == this.Surface.DesignerHost.RootComponent) { ele.SetAttribute("isRoot", "true"); } else { ele.SetAttribute("ID", ((ABCView)currentCom).ViewID.ToString()); CompNameList.Add(currentCom.Site.Name); return(ele); } } #region Get ChildrenNode if (currentCom is ABCGridControl) { ((ABCGridControl)currentCom).GetChildrenXMLLayout(ele); } else if (currentCom is ABCGridBandedControl) { ((ABCGridBandedControl)currentCom).GetChildrenXMLLayout(ele); } else if (currentCom is ABCPivotGridControl) { ((ABCPivotGridControl)currentCom).GetChildrenXMLLayout(ele); } else if (currentCom is ABCTreeList) { ((ABCTreeList)currentCom).GetChildrenXMLLayout(ele); } else if (currentCom is ABCChartBaseControl) { ((ABCChartBaseControl)currentCom).GetChildrenXMLLayout(ele); } else if (currentCom is DevExpress.XtraBars.Docking.DockPanel) { ABCDockPanel.GetChildrenXMLLayout(this, (DevExpress.XtraBars.Docking.DockPanel)currentCom, ele); } else if (currentCom is ABCBindingBaseEdit) { ((ABCBindingBaseEdit)currentCom).GetChildrenXMLLayout(ele); } else if (currentCom is ABCSearchPanel) { ((ABCSearchPanel)currentCom).GetChildrenXMLLayout(this, ele); } //else if ( currentCom is ABCDataPanel ) //{ // ( (ABCDataPanel)currentCom ).GetChildrenXMLLayout( this , ele ); //} else { #region Default Component if (OwnerView != null && OwnerView.Mode == ViewMode.Design) { ComponentDesigner designer = (ComponentDesigner)this.Surface.DesignerHost.GetDesigner(currentCom); if (designer != null && designer.AssociatedComponents != null) { List <XmlElement> lstTemp = new List <XmlElement>(); foreach (object associatedComponent in designer.AssociatedComponents) { XmlElement eleChild = ComponentSerialization(doc, (IComponent)associatedComponent); if (eleChild != null) { ele.AppendChild(eleChild); } } } } else { List <XmlElement> lstTemp = new List <XmlElement>(); foreach (object associatedComponent in (currentCom as Control).Controls) { XmlElement eleChild = ComponentSerialization(doc, (IComponent)associatedComponent); if (eleChild != null) { ele.AppendChild(eleChild); } } } #endregion } #endregion if (OwnerView != null && OwnerView.Mode == ViewMode.Design) { CompNameList.Add(currentCom.Site.Name); } else { CompNameList.Add((currentCom as Control).Name); } return(ele); }
internal override void Display() { if (IsActive && ImGui.Begin(_windowname, ref IsActive, _flags)) { GuiDesignUI(); //Part design GuiCostText(); //Print cost ImGui.End(); } void GuiDesignUI()//Creates all UI elements need for designing the Component { ImGui.Text("Component Specifications"); ImGui.SameLine(ImGui.GetWindowWidth() - 70); if (ImGui.Button("Compact")) { compactmod = !compactmod; } ImGui.NewLine(); if (_componentDesigner != null) //Make sure comp is selected { foreach (ComponentDesignAttribute attribute in _componentDesigner.ComponentDesignAttributes.Values) //For each property of the comp type { ImGui.PushID(attribute.Name); if (attribute.IsEnabled) { switch (attribute.GuiHint) //Either { case GuiHint.None: break; case GuiHint.GuiTechSelectionList: //Let the user pick a type from a list GuiHintTechSelection(attribute); break; case GuiHint.GuiSelectionMaxMin: //Set a value GuiHintMaxMin(attribute); break; case GuiHint.GuiTextDisplay: //Display a stat GuiHintText(attribute); break; case GuiHint.GuiEnumSelectionList: //Let the user pick a type from a hard coded list GuiHintEnumSelection(attribute); break; case GuiHint.GuiOrdnanceSelectionList: GuiHintOrdnanceSelection(attribute); break; default: throw new ArgumentOutOfRangeException(); } } ImGui.PopID(); } ImGui.Text("Name"); ImGui.InputText("", _nameInputBuffer, 32); if (ImGui.Button("Create Design")) { _componentDesigner.Name = ImGuiSDL2CSHelper.StringFromBytes(_nameInputBuffer); _componentDesigner.CreateDesign(_state.Faction); //we reset the designer here, so we don't end up trying to edit the precious design. var factionTech = _state.Faction.GetDataBlob <FactionTechDB>(); _componentDesigner = new ComponentDesigner(_designables[_designType], factionTech); } ImGui.NewLine(); } else//Tell the user they don't have a comp type selected { ImGui.NewLine(); ImGui.Text("No component type selected"); ImGui.NewLine(); } } void GuiCostText()//Prints a 2 col table with the costs of the part { //ImGui.BeginChild("Cost"); if (_componentDesigner != null)//If a part time is selected { ImGui.Columns(2); ImGui.BeginTabItem("Cost"); ImGui.Text("Mass"); ImGui.Text("Volume_km3"); ImGui.Text("Crew Requred"); ImGui.Text("Cost"); ImGui.Text("Research Cost"); ImGui.Text("Build Cost"); ImGui.Text("Resource Costs"); ImGui.NextColumn();//Add all the cost names to col 1 ImGui.Text(Stringify.Mass(_componentDesigner.MassValue)); ImGui.Text(Stringify.Volume(_componentDesigner.VolumeM3Value)); ImGui.Text(_componentDesigner.CrewReqValue.ToString()); ImGui.Text(_componentDesigner.CreditCostValue.ToString()); ImGui.Text(_componentDesigner.ResearchCostValue.ToString() + " RP"); ImGui.Text(_componentDesigner.IndustryPointCostsValue.ToString() + " BP"); ImGui.NextColumn();//Add all the price values to col 2 foreach (var kvp in _componentDesigner.ResourceCostValues) { var resource = StaticRefLib.StaticData.CargoGoods.GetAny(kvp.Key); if (resource == null) { resource = (ICargoable)_state.Faction.GetDataBlob <FactionInfoDB>().IndustryDesigns[kvp.Key]; } var xpos = ImGui.GetCursorPosX(); ImGui.SetCursorPosX(xpos + 12); ImGui.Text(resource.Name); ImGui.NextColumn(); ImGui.Text(kvp.Value.ToString()); ImGui.NextColumn(); } } //ImGui.EndChild(); } void GuiHintText(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Value.ToString() + " " + attribute.Unit); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Value.ToString() + " " + attribute.Unit); ImGui.NewLine(); } } void GuiHintMaxMin(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } attribute.SetMax(); attribute.SetMin(); attribute.SetValue(); attribute.SetStep(); var max = attribute.MaxValue; var min = attribute.MinValue; double val = attribute.Value; double step = attribute.StepValue; double fstep = step * 10; IntPtr valPtr; IntPtr maxPtr; IntPtr minPtr; IntPtr stepPtr; IntPtr fstepPtr; unsafe { valPtr = new IntPtr(&val); maxPtr = new IntPtr(&max); minPtr = new IntPtr(&min); stepPtr = new IntPtr(&step); fstepPtr = new IntPtr(&fstep); } //ImGui.DragScalar("##slider" + attribute.Name, ImGuiDataType.Double, valPtr, 1f, minPtr, maxPtr); if (compactmod) { } else { ImGui.PushItemWidth(-1); if (ImGui.SliderScalar("##scaler" + attribute.Name, ImGuiDataType.Double, valPtr, minPtr, maxPtr)) { attribute.SetValueFromInput(val); } } ImGui.PushItemWidth(-1); if (ImGui.InputScalar("##input" + attribute.Name, ImGuiDataType.Double, valPtr, stepPtr, fstepPtr)) { attribute.SetValueFromInput(val); } ImGui.NewLine(); } void GuiHintTechSelection(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } int i = 0; _techSDs = new TechSD[attribute.GuidDictionary.Count]; _techNames = new string[attribute.GuidDictionary.Count]; foreach (var kvp in attribute.GuidDictionary) { TechSD sd = StaticRefLib.StaticData.Techs[Guid.Parse((string)kvp.Key)]; _techSDs[i] = sd; _techNames[i] = sd.Name; i++; } ImGui.TextWrapped(attribute.Value.ToString()); if (ImGui.Combo("Select Tech", ref _techSelectedIndex, _techNames, _techNames.Length)) { attribute.SetValueFromGuidList(_techSDs[_techSelectedIndex].ID); } ImGui.NewLine(); } void GuiHintEnumSelection(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } int i = 0; //_techSDs = new TechSD[attribute.GuidDictionary.Count]; _listNames = Enum.GetNames(attribute.EnumType); ImGui.TextWrapped(attribute.Value.ToString()); if (ImGui.Combo("Select", ref attribute.ListSelection, _listNames, (int)attribute.MaxValue + 1)) { int enumVal = (int)Enum.Parse(attribute.EnumType, _listNames[attribute.ListSelection]); attribute.SetValueFromInput(enumVal); } ImGui.NewLine(); } void GuiHintOrdnanceSelection(ComponentDesignAttribute attribute) { var dict = _state.Faction.GetDataBlob <FactionInfoDB>().MissileDesigns; _listNames = new string[dict.Count]; OrdnanceDesign[] ordnances = new OrdnanceDesign[dict.Count]; int i = 0; foreach (var kvp in dict) { _listNames[i] = kvp.Value.Name; ordnances[i] = kvp.Value; } if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } ImGui.TextWrapped(attribute.Value.ToString()); if (ImGui.Combo("Select", ref attribute.ListSelection, _listNames, _listNames.Length)) { attribute.SetValueFromComponentList(ordnances[attribute.ListSelection].ID); } ImGui.NewLine(); } }
public static Entity CreateShip(ShipDesign shipDesign, Entity ownerFaction, Vector3 position, Entity parent, StarSystem starsys, string shipName = null) { List <BaseDataBlob> dataBlobs = new List <BaseDataBlob>(); var shipinfo = new ShipInfoDB(); dataBlobs.Add(shipinfo); var mvdb = MassVolumeDB.NewFromMassAndVolume(shipDesign.Mass, shipDesign.Volume); dataBlobs.Add(mvdb); PositionDB posdb = new PositionDB(Distance.MToAU(position), starsys.Guid, parent); dataBlobs.Add(posdb); EntityDamageProfileDB damagedb = (EntityDamageProfileDB)shipDesign.DamageProfileDB.Clone(); dataBlobs.Add(damagedb); ComponentInstancesDB compInstances = new ComponentInstancesDB(); dataBlobs.Add(compInstances); OrderableDB ordable = new OrderableDB(); dataBlobs.Add(ordable); var ship = Entity.Create(starsys, ownerFaction.Guid, dataBlobs); StaticDataStore staticdata = StaticRefLib.StaticData; ComponentDesigner fireControlDesigner; ComponentDesign integratedfireControl; ComponentTemplateSD bfcSD = staticdata.ComponentTemplates[new Guid("33fcd1f5-80ab-4bac-97be-dbcae19ab1a0")]; fireControlDesigner = new ComponentDesigner(bfcSD, ownerFaction.GetDataBlob <FactionTechDB>()); fireControlDesigner.Name = "Bridge Computer Systems"; fireControlDesigner.ComponentDesignAttributes["Range"].SetValueFromInput(0); fireControlDesigner.ComponentDesignAttributes["Tracking Speed"].SetValueFromInput(0); fireControlDesigner.ComponentDesignAttributes["Size vs Range"].SetValueFromInput(0); //return fireControlDesigner.CreateDesign(faction); integratedfireControl = fireControlDesigner.CreateDesign(ownerFaction); ownerFaction.GetDataBlob <FactionTechDB>().IncrementLevel(integratedfireControl.TechID); //some DB's need tobe created after the entity. var namedb = new NameDB(ship.Guid.ToString()); namedb.SetName(ownerFaction.Guid, shipName); OrbitDB orbit = OrbitDB.FromPosition(parent, ship, starsys.ManagerSubpulses.StarSysDateTime); ship.SetDataBlob(namedb); ship.SetDataBlob(orbit); EntityManipulation.AddComponentToEntity(ship, integratedfireControl, 1); foreach (var item in shipDesign.Components) { EntityManipulation.AddComponentToEntity(ship, item.design, item.count); } if (ship.HasDataBlob <NewtonThrustAbilityDB>() && ship.HasDataBlob <CargoStorageDB>()) { NewtonionMovementProcessor.CalcDeltaV(ship); } return(ship); }
/// <summary> /// Initializes a new instance of the <see cref="NuGenCollectionEditorServiceContext"/> class. /// </summary> public NuGenCollectionEditorServiceContext(ComponentDesigner designer) { _designer = designer; }
public static IDictionary <string, List <Attribute> > GetRedirectedProperties(this ComponentDesigner d) { var ret = new Dictionary <string, List <Attribute> >(); foreach (var prop in d.GetType().GetProperties(allInstBind)) { foreach (RedirectedDesignerPropertyAttribute attr in prop.GetCustomAttributes(typeof(RedirectedDesignerPropertyAttribute), false)) { List <Attribute> attributes; if (attr.ApplyOtherAttributes) { attributes = prop.GetCustomAttributes <Attribute>().ToList(); attributes.RemoveAll(a => a is RedirectedDesignerPropertyAttribute); } else { attributes = new List <Attribute>(); } ret.Add(prop.Name, attributes); } } return(ret.Count > 0 ? ret : null); }
public ReoGridControlEditorActionList(ComponentDesigner designer) : base(designer.Component) { this.designer = designer; }
public ComponentDesignAttribute(ComponentDesigner parentComponent, ComponentTemplateAttributeSD templateAtb, FactionTechDB factionTech) { ParentComponent = parentComponent; _templateSD = templateAtb; var staticData = StaticRefLib.StaticData; if (_templateSD.AttributeFormula != null) { Formula = new ChainedExpression(_templateSD.AttributeFormula, this, factionTech, staticData); } if (!string.IsNullOrEmpty(_templateSD.DescriptionFormula)) { DescriptionFormula = new ChainedExpression(_templateSD.DescriptionFormula, this, factionTech, staticData); } if (_templateSD.GuidDictionary != null) { GuidDictionary = new Dictionary <object, ChainedExpression>(); if (GuiHint == GuiHint.GuiTechSelectionList) { foreach (var kvp in _templateSD.GuidDictionary) { if (factionTech.ResearchedTechs.ContainsKey(Guid.Parse(kvp.Key.ToString()))) { TechSD techSD = staticData.Techs[Guid.Parse(kvp.Key.ToString())]; GuidDictionary.Add(kvp.Key, new ChainedExpression(ResearchProcessor.DataFormula(factionTech, techSD).ToString(), this, factionTech, staticData)); } } } else { foreach (var kvp in _templateSD.GuidDictionary) { GuidDictionary.Add(kvp.Key, new ChainedExpression(kvp.Value, this, factionTech, staticData)); } } } if (GuiHint == GuiHint.GuiSelectionMaxMin) { MaxValueFormula = new ChainedExpression(_templateSD.MaxFormula, this, factionTech, staticData); MinValueFormula = new ChainedExpression(_templateSD.MinFormula, this, factionTech, staticData); StepValueFormula = new ChainedExpression(_templateSD.StepFormula, this, factionTech, staticData); } if (_templateSD.AttributeType != null) { AttributeType = Type.GetType(_templateSD.AttributeType); if (AttributeType == null) { throw new Exception("Attribute Type Error. Attribute type not found: " + _templateSD.AttributeType + ". Try checking the namespace."); } } if (GuiHint == GuiHint.GuiEnumSelectionList) { MaxValueFormula = new ChainedExpression(_templateSD.MaxFormula, this, factionTech, staticData); MinValueFormula = new ChainedExpression(_templateSD.MinFormula, this, factionTech, staticData); StepValueFormula = new ChainedExpression(_templateSD.StepFormula, this, factionTech, staticData); SetMax(); SetMin(); SetStep(); EnumType = Type.GetType(_templateSD.EnumTypeName); if (EnumType == null) { throw new Exception("EnumTypeName not found: " + _templateSD.EnumTypeName); } ListSelection = (int)Value; //string[] names = Enum.GetNames(EnumType); } if (_templateSD.GuiIsEnabledFormula != null) { IsEnabledFormula = new ChainedExpression(_templateSD.GuiIsEnabledFormula, this, factionTech, staticData); var ghint = GuiHint.GuiTextDisplay | GuiHint.GuiDisplayBool; } if (GuiHint == GuiHint.GuiOrdnanceSelectionList) { } }
public ComponentDesignAttribute(ComponentDesigner parentComponent) { ParentComponent = parentComponent; }
internal EditorServiceContext(ComponentDesigner designer, PropertyDescriptor prop, string newVerbText) : this(designer, prop) { Debug.Assert(!string.IsNullOrEmpty(newVerbText), "newVerbText cannot be null or empty"); _designer.Verbs.Add(new DesignerVerb(newVerbText, new EventHandler(OnEditItems))); }
internal EditorServiceContext(ComponentDesigner designer, PropertyDescriptor prop, string newVerbText) : this(designer, prop) { this._designer.Verbs.Add(new DesignerVerb(newVerbText, new EventHandler(this.OnEditItems))); }
private void EditValue(ComponentDesigner componentDesigner, IComponent iComponent, string propertyName) { // One more complication. The ListViewActionList classes uses an internal class, EditorServiceContext, to // edit the items/columns/groups collections. So, we use reflection to bypass the data hiding. Type tEditorServiceContext = Type.GetType("System.Windows.Forms.Design.EditorServiceContext, System.Design"); tEditorServiceContext.InvokeMember("EditValue", BindingFlags.InvokeMethod | BindingFlags.Static, null, null, new object[] { componentDesigner, iComponent, propertyName }); }
public static Entity DefaultHumans(Game game, string name) { //USE THIS TO TEST CODE //TESTING STUFFF //return completeTest(game, name); // while(true){ //} //TESTING STUFF var log = StaticRefLib.EventLog; StarSystemFactory starfac = new StarSystemFactory(game); StarSystem solSys = starfac.CreateSol(game); //sol.ManagerSubpulses.Init(sol); Entity solStar = solSys.Entities[0]; Entity earth = solSys.Entities[3]; //should be fourth entity created //Entity factionEntity = FactionFactory.CreatePlayerFaction(game, owner, name); Entity factionEntity = FactionFactory.CreateFaction(game, name); Entity speciesEntity = SpeciesFactory.CreateSpeciesHuman(factionEntity, game.GlobalManager); var namedEntites = solSys.GetAllEntitiesWithDataBlob <NameDB>(); foreach (var entity in namedEntites) { var nameDB = entity.GetDataBlob <NameDB>(); nameDB.SetName(factionEntity.Guid, nameDB.DefaultName); } Entity colonyEntity = ColonyFactory.CreateColony(factionEntity, speciesEntity, earth); Entity marsColony = ColonyFactory.CreateColony(factionEntity, speciesEntity, NameLookup.GetFirstEntityWithName(solSys, "Mars")); ComponentTemplateSD mineSD = game.StaticData.ComponentTemplates[new Guid("f7084155-04c3-49e8-bf43-c7ef4befa550")]; ComponentDesigner mineDesigner = new ComponentDesigner(mineSD, factionEntity.GetDataBlob <FactionTechDB>()); ComponentDesign mineDesign = mineDesigner.CreateDesign(factionEntity); ComponentTemplateSD RefinerySD = game.StaticData.ComponentTemplates[new Guid("90592586-0BD6-4885-8526-7181E08556B5")]; ComponentDesigner refineryDesigner = new ComponentDesigner(RefinerySD, factionEntity.GetDataBlob <FactionTechDB>()); ComponentDesign refinaryDesign = refineryDesigner.CreateDesign(factionEntity); ComponentTemplateSD labSD = game.StaticData.ComponentTemplates[new Guid("c203b7cf-8b41-4664-8291-d20dfe1119ec")]; ComponentDesigner labDesigner = new ComponentDesigner(labSD, factionEntity.GetDataBlob <FactionTechDB>()); ComponentDesign labEntity = labDesigner.CreateDesign(factionEntity); ComponentTemplateSD facSD = game.StaticData.ComponentTemplates[new Guid("{07817639-E0C6-43CD-B3DC-24ED15EFB4BA}")]; ComponentDesigner facDesigner = new ComponentDesigner(facSD, factionEntity.GetDataBlob <FactionTechDB>()); ComponentDesign facEntity = facDesigner.CreateDesign(factionEntity); Scientist scientistEntity = CommanderFactory.CreateScientist(factionEntity, colonyEntity); colonyEntity.GetDataBlob <TeamsHousedDB>().AddTeam(scientistEntity); FactionTechDB factionTech = factionEntity.GetDataBlob <FactionTechDB>(); //TechProcessor.ApplyTech(factionTech, game.StaticData.Techs[new ID("35608fe6-0d65-4a5f-b452-78a3e5e6ce2c")]); //add conventional engine for testing. ResearchProcessor.CheckRequrements(factionTech); DefaultThrusterDesign(game, factionEntity); DefaultWarpDesign(game, factionEntity); DefaultFuelTank(game, factionEntity); DefaultCargoInstalation(game, factionEntity); DefaultSimpleLaser(game, factionEntity); DefaultBFC(game, factionEntity); ShipDefaultCargoHold(game, factionEntity); ShipSmallCargo(game, factionEntity); ShipPassiveSensor(game, factionEntity); FacPassiveSensor(game, factionEntity); DefaultFisionReactor(game, factionEntity); DefaultBatteryBank(game, factionEntity); DefaultFragPayload(game, factionEntity); DefaultMissileSRB(game, factionEntity); DefaultMissileSensors(game, factionEntity); DefaultMissileTube(game, factionEntity); MissileDesign250(game, factionEntity); ShipSmallOrdnanceStore(game, factionEntity); EntityManipulation.AddComponentToEntity(colonyEntity, mineDesign); EntityManipulation.AddComponentToEntity(colonyEntity, refinaryDesign); EntityManipulation.AddComponentToEntity(colonyEntity, labEntity); EntityManipulation.AddComponentToEntity(colonyEntity, facEntity); EntityManipulation.AddComponentToEntity(colonyEntity, _fuelTank_500); EntityManipulation.AddComponentToEntity(colonyEntity, _cargoInstalation); EntityManipulation.AddComponentToEntity(marsColony, _cargoInstalation); EntityManipulation.AddComponentToEntity(colonyEntity, _sensorInstalation); EntityManipulation.AddComponentToEntity(colonyEntity, SpacePort(factionEntity)); ReCalcProcessor.ReCalcAbilities(colonyEntity); colonyEntity.GetDataBlob <ColonyInfoDB>().Population[speciesEntity] = 9000000000; var rawSorium = NameLookup.GetMineralSD(game, "Sorium"); StorageSpaceProcessor.AddCargo(colonyEntity.GetDataBlob <CargoStorageDB>(), rawSorium, 5000); var iron = NameLookup.GetMineralSD(game, "Iron"); StorageSpaceProcessor.AddCargo(colonyEntity.GetDataBlob <CargoStorageDB>(), iron, 5000); var hydrocarbon = NameLookup.GetMineralSD(game, "Hydrocarbons"); StorageSpaceProcessor.AddCargo(colonyEntity.GetDataBlob <CargoStorageDB>(), hydrocarbon, 5000); var stainless = NameLookup.GetMaterialSD(game, "Stainless Steel"); StorageSpaceProcessor.AddCargo(colonyEntity.GetDataBlob <CargoStorageDB>(), stainless, 1000); factionEntity.GetDataBlob <FactionInfoDB>().KnownSystems.Add(solSys.Guid); //test systems //factionEntity.GetDataBlob<FactionInfoDB>().KnownSystems.Add(starfac.CreateEccTest(game).ID); //factionEntity.GetDataBlob<FactionInfoDB>().KnownSystems.Add(starfac.CreateLongitudeTest(game).ID); factionEntity.GetDataBlob <NameDB>().SetName(factionEntity.Guid, "UEF"); // Todo: handle this in CreateShip ShipDesign shipDesign = DefaultShipDesign(game, factionEntity); ShipDesign gunShipDesign = GunShipDesign(game, factionEntity); Entity ship1 = ShipFactory.CreateShip(shipDesign, factionEntity, earth, solSys, "Serial Peacemaker"); Entity ship2 = ShipFactory.CreateShip(shipDesign, factionEntity, earth, solSys, "Ensuing Calm"); Entity ship3 = ShipFactory.CreateShip(shipDesign, factionEntity, earth, solSys, "Touch-and-Go"); Entity gunShip = ShipFactory.CreateShip(gunShipDesign, factionEntity, earth, solSys, "Prevailing Stillness"); Entity courier = ShipFactory.CreateShip(CargoShipDesign(game, factionEntity), factionEntity, earth, solSys, "Planet Express Ship"); var fuel = NameLookup.GetMaterialSD(game, "Sorium Fuel"); var rp1 = NameLookup.GetMaterialSD(game, "LOX/Hydrocarbon"); StorageSpaceProcessor.AddCargo(ship1.GetDataBlob <CargoStorageDB>(), rp1, 15000); StorageSpaceProcessor.AddCargo(ship2.GetDataBlob <CargoStorageDB>(), rp1, 15000); StorageSpaceProcessor.AddCargo(ship3.GetDataBlob <CargoStorageDB>(), rp1, 15000); StorageSpaceProcessor.AddCargo(gunShip.GetDataBlob <CargoStorageDB>(), rp1, 15000); StorageSpaceProcessor.AddCargo(gunShip.GetDataBlob <CargoStorageDB>(), MissileDesign250(game, factionEntity), 20); StorageSpaceProcessor.AddCargo(courier.GetDataBlob <CargoStorageDB>(), rp1, 15000); var elec = NameLookup.GetMaterialSD(game, "Electrical Energy"); ship1.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; ship2.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; ship3.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; gunShip.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; courier.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; NewtonionMovementProcessor.CalcDeltaV(ship1); NewtonionMovementProcessor.CalcDeltaV(ship2); NewtonionMovementProcessor.CalcDeltaV(ship3); NewtonionMovementProcessor.CalcDeltaV(gunShip); NewtonionMovementProcessor.CalcDeltaV(courier); //StorageSpaceProcessor.AddCargo(ship1.GetDataBlob<CargoStorageDB>(), fuel, 200000000000); //StorageSpaceProcessor.AddCargo(ship2.GetDataBlob<CargoStorageDB>(), fuel, 200000000000); //StorageSpaceProcessor.AddCargo(ship3.GetDataBlob<CargoStorageDB>(), fuel, 200000000000); double test_a = 0.5; //AU double test_e = 0; double test_i = 0; //° double test_loan = 0; //° double test_aop = 0; //° double test_M0 = 0; //° double test_bodyMass = ship2.GetDataBlob <MassVolumeDB>().Mass; OrbitDB testOrbtdb_ship2 = OrbitDB.FromAsteroidFormat(solStar, solStar.GetDataBlob <MassVolumeDB>().Mass, test_bodyMass, test_a, test_e, test_i, test_loan, test_aop, test_M0, StaticRefLib.CurrentDateTime); ship2.RemoveDataBlob <OrbitDB>(); ship2.SetDataBlob(testOrbtdb_ship2); ship2.GetDataBlob <PositionDB>().SetParent(solStar); StaticRefLib.ProcessorManager.RunProcessOnEntity <OrbitDB>(ship2, 0); test_a = 0.51; test_i = 180; test_aop = 0; OrbitDB testOrbtdb_ship3 = OrbitDB.FromAsteroidFormat(solStar, solStar.GetDataBlob <MassVolumeDB>().Mass, test_bodyMass, test_a, test_e, test_i, test_loan, test_aop, test_M0, StaticRefLib.CurrentDateTime); ship3.RemoveDataBlob <OrbitDB>(); ship3.SetDataBlob(testOrbtdb_ship3); ship3.GetDataBlob <PositionDB>().SetParent(solStar); StaticRefLib.ProcessorManager.RunProcessOnEntity <OrbitDB>(ship3, 0); gunShip.GetDataBlob <PositionDB>().RelativePosition_AU = new Vector3(8.52699302490434E-05, 0, 0); //give the gunship a hypobolic orbit to test: //var orbit = OrbitDB.FromVector(earth, gunShip, new Vector4(0, velInAU, 0, 0), game.CurrentDateTime); gunShip.RemoveDataBlob <OrbitDB>(); var nmdb = new NewtonMoveDB(earth, new Vector3(0, -10000.0, 0)); gunShip.SetDataBlob <NewtonMoveDB>(nmdb); solSys.SetDataBlob(ship1.ID, new TransitableDB()); solSys.SetDataBlob(ship2.ID, new TransitableDB()); solSys.SetDataBlob(gunShip.ID, new TransitableDB()); solSys.SetDataBlob(courier.ID, new TransitableDB()); //Entity ship = ShipFactory.CreateShip(shipDesign, sol.SystemManager, factionEntity, position, sol, "Serial Peacemaker"); //ship.SetDataBlob(earth.GetDataBlob<PositionDB>()); //first ship reference PositionDB //Entity ship3 = ShipFactory.CreateShip(shipDesign, sol.SystemManager, factionEntity, position, sol, "Contiual Pacifier"); //ship3.SetDataBlob((OrbitDB)earth.GetDataBlob<OrbitDB>().Clone());//second ship clone earth OrbitDB //sol.SystemManager.SetDataBlob(ship.ID, new TransitableDB()); //Entity rock = AsteroidFactory.CreateAsteroid2(sol, earth, game.CurrentDateTime + TimeSpan.FromDays(365)); Entity rock = AsteroidFactory.CreateAsteroid(solSys, earth, StaticRefLib.CurrentDateTime + TimeSpan.FromDays(365)); var pow = solSys.GetAllEntitiesWithDataBlob <EnergyGenAbilityDB>(); foreach (var entityItem in pow) { StaticRefLib.ProcessorManager.GetInstanceProcessor(nameof(EnergyGenProcessor)).ProcessEntity(entityItem, StaticRefLib.CurrentDateTime); } var entitiesWithSensors = solSys.GetAllEntitiesWithDataBlob <SensorAbilityDB>(); foreach (var entityItem in entitiesWithSensors) { StaticRefLib.ProcessorManager.GetInstanceProcessor(nameof(SensorScan)).ProcessEntity(entityItem, StaticRefLib.CurrentDateTime); } return(factionEntity); }
internal ShadowPropertyCollection(ComponentDesigner designer) { _designer = designer; }
internal EditorServiceContext(ComponentDesigner designer) { this._designer = designer; }
public _BaseDesignerActionList(ComponentDesigner designer, IComponent component) : base(component) { base.AutoShow = true; ParentDesigner = designer; }