/// <summary> /// Cell group up button changed /// </summary> /// <param name="sender"></param> public void btnGroupUpChanged(Widget sender, Object value) { if ((bool)value == true) groupSelector.MoveUp(); }
/// <summary> /// Rotation wheel has moved - rotate the selected cell /// </summary> /// <param name="sender"></param> public void knobRotateChanged(Widget sender, Object value) { if (Lab.SelectedCell != null) { // Get a delta angle from the wheel & add it to the plug's yaw Lab.SelectedCell.PlugOrientation *= Matrix.RotationYawPitchRoll((float)value, 0, 0); } }
/// <summary> /// Constant wheel has moved - adjust the current channel's constant value /// </summary> /// <param name="sender"></param> private void wheelConstChanged(Widget sender, Object value) { if ((Lab.SelectedCell != null)&&(Lab.SelectedCell.NumChannels>Lab.SelectedChannel)) { // Get a delta angle from the wheel & add it to the constant float c = Lab.SelectedCell.GetChannelConstant(Lab.SelectedChannel); c += (float)value / (float)Math.PI; if (c<0f) c=0f; else if (c>1f) c=1f; Lab.SelectedCell.SetChannelConstant(Lab.SelectedChannel, c); // Set meter to reflect change UpdateConstantMeter(); } }
/// <summary> /// A socket navigation button has been pressed - select next socket (if any - may be null) /// </summary> /// <param name="sender"></param> public void btnSktNextChanged(Widget sender, Object value) { if (((bool)value == true) && (Lab.SelectedCell != null)) Lab.SelectedCell.SelectNext(); }
public void btnVariantUpChanged(Widget sender, Object value) { ((LabPanel2)owner.Panel[1]).btnVariantUpChanged(sender, value); }
/// <summary> /// Button: Start a new creature /// </summary> /// <param name="sender"></param> public void btnNewChanged(Widget sender, Object value) { if (((bool)value == true) // Only do it if the button has been pressed && (Lab.SelectedOrg == null)) // and no creature is on the clamp { owner.New(); // lab creates the creature DrawCellData(); // update the LCD } }
/// <summary> /// Button: detach the creature from the clamp /// </summary> /// <param name="sender"></param> public void btnReleaseChanged(Widget sender, Object value) { if (((bool)value == true) // Only do it if the button has been pressed && (Lab.SelectedOrg != null)) // and there is a creature on the clamp { owner.Detach(); // detach the creature from the clamp DrawCellData(); // update the LCD } }
/// <summary> /// ADD button pressed - add a new cell /// </summary> /// <param name="sender"></param> /// <param name="value"></param> public void btnAddChanged(Widget sender, Object value) { if (((bool)value == true) && (Lab.SelectedCell != null)) { owner.Add(); DrawCellData(); } }
public void btnCamDnChanged(Widget sender, Object value) { owner.Command("down", value); }
/// <summary> /// Cell variant selector has changed /// </summary> /// <param name="sender"></param> public void variantSelectorChanged(Widget sender, Object value) { // Tell the Lab that the selected cell variant has changed. // The Lab will then tell the main panel to update its own cell type selection text ((Lab)owner).NewCelltypeSelection(groupSelector.Selection, typeSelector.Selection, variantSelector.Selection); }
private float zoomRate = 0; // current rate of zoom #endregion Fields #region Constructors public LabPanel(Lab owner) : base() { // Record my owner for callbacks etc. this.owner = owner; // Create fonts // KLUDGE: When lcdFont is different from msgFont, there's an odd bug: // if I create a creature, anything using lcdFont fails to draw (the EditBox and the LCD text) // but if I type into the EditBox before creating a creature, everything is ok. // Equally, if I make the cell selector use lcdFont instead of msgFont then all objects using lcdFont work ok. // So there's something in the EditBox and cell selector code that "fixes" lcdFont. Can't figure this out, // so for now I'll just use the one font for everthing and wait until inspiration strikes!!!! msgFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold, GraphicsUnit.Pixel); //lcdFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 14, FontStyle.Regular, GraphicsUnit.Pixel); lcdFont = msgFont; // Temp: let lcdFont share msgFont // writeable onscreen display (behind screen so that raster lines show) widgetList.Add(osd = new Widget("LabOSD", true, 256, 64, 210, 64)); // Edit box for typing species name editSpecies = new EditBox("LCDEditBox", 128, 16, 210, 48, 54, 0, lcdFont, Brushes.Green, "Species:"); widgetList.Add(editSpecies); editSpecies.OnChange += new ChangeEventHandler(editSpeciesChanged); // Backdrop widgetList.Add(new Widget("LabBkgnd", false, 1024, 768, 0, 0)); // Display panels for showing the currently selected cell group & type dispCellGroup = new Widget("LCDLine", true, 100, 20, 416, 675); widgetList.Add(dispCellGroup); dispCellType = new Widget("LCDLine", true, 100, 20, 416, 695); widgetList.Add(dispCellType); dispCellVariant = new Widget("LCDLine", true, 100, 20, 416, 715); widgetList.Add(dispCellVariant); // Button: Start building a new creature SafetyButton btnNew = new SafetyButton("SafetySwitch", 80, 92, 18, 16, Keys.None, 0.3f); widgetList.Add(btnNew); btnNew.OnChange += new ChangeEventHandler(btnNewChanged); // Button: Release creature from clamp SafetyButton btnRelease = new SafetyButton("SafetySwitch", 80, 92, 18, 154, Keys.None, 0.3f); widgetList.Add(btnRelease); btnRelease.OnChange += new ChangeEventHandler(btnReleaseChanged); // Button: Activate the tractor beam Button btnTractor = new Button("PushButtonSmall", 40, 40, 37, 320, Keys.T, false); widgetList.Add(btnTractor); btnTractor.OnChange += new ChangeEventHandler(btnTractorChanged); // LED to show when tractor beam is active lampTractor = new Lamp("LED", 24, 24, 45, 292); widgetList.Add(lampTractor); // Button: Delete selected cells Button btnDelete = new Button("PushButtonSmall", 40, 40, 300, 686, Keys.Back, false); widgetList.Add(btnDelete); btnDelete.OnChange += new ChangeEventHandler(btnDeleteChanged); // Button: Add a new cell (INSERT) Button btnAdd = new Button("PushButtonSmall", 40, 40, 593, 698, Keys.Insert, false); widgetList.Add(btnAdd); btnAdd.OnChange += new ChangeEventHandler(btnAddChanged); // Button: Preview a potential new cell (SPACE) Button btnPreview = new Button("BtnRect", 64, 24, 580,670, Keys.Space, false); widgetList.Add(btnPreview); btnPreview.OnChange += new ChangeEventHandler(btnPreviewChanged); // These buttons change the selected celltype by mimicking those in the secondary panel // Button: cell group selection up Button btnGroupUp = new Button("BtnRectSmallLeft", 32, 24, 363, 670, Keys.Insert, true); widgetList.Add(btnGroupUp); btnGroupUp.OnChange += new ChangeEventHandler(btnGroupUpChanged); // Button: cell group selection down Button btnGroupDn = new Button("BtnRectSmallRight", 32, 24, 536, 670, Keys.Delete, true); widgetList.Add(btnGroupDn); btnGroupDn.OnChange += new ChangeEventHandler(btnGroupDnChanged); // Button: cell type selection up Button btnTypeUp = new Button("BtnRectSmallLeft", 32, 24, 363, 694, Keys.Home, true); widgetList.Add(btnTypeUp); btnTypeUp.OnChange += new ChangeEventHandler(btnTypeUpChanged); // Button: cell type selection down Button btnTypeDn = new Button("BtnRectSmallRight", 32, 24, 536, 694, Keys.End, true); widgetList.Add(btnTypeDn); btnTypeDn.OnChange += new ChangeEventHandler(btnTypeDnChanged); // Button: cell variant selection up Button btnVariantUp = new Button("BtnRectSmallLeft", 32, 24, 363, 718, Keys.PageUp, true); widgetList.Add(btnVariantUp); btnVariantUp.OnChange += new ChangeEventHandler(btnVariantUpChanged); // Button: cell variant selection down Button btnVariantDn = new Button("BtnRectSmallRight", 32, 24, 536, 718, Keys.PageDown, true); widgetList.Add(btnVariantDn); btnVariantDn.OnChange += new ChangeEventHandler(btnVariantDnChanged); // Buttons for navigating/selecting cells and sockets // Button: up in cell tree Button btnCellUp = new Button("BtnRectUp", 64, 24, 16, 664, Keys.Up, false); widgetList.Add(btnCellUp); btnCellUp.OnChange += new ChangeEventHandler(btnCellUpChanged); // Button: down in cell tree Button btnCellDn = new Button("BtnRectDn", 64, 24, 16, 712, Keys.Down, false); widgetList.Add(btnCellDn); btnCellDn.OnChange += new ChangeEventHandler(btnCellDnChanged); // Button: next sibling in cell tree Button btnCellNext = new Button("BtnRectSmallRight", 32, 24, 48, 688, Keys.Right, false); widgetList.Add(btnCellNext); btnCellNext.OnChange += new ChangeEventHandler(btnCellNextChanged); // Button: prev sibling in cell tree Button btnCellPrev = new Button("BtnRectSmallLeft", 32, 24, 16, 688, Keys.Left, false); widgetList.Add(btnCellPrev); btnCellPrev.OnChange += new ChangeEventHandler(btnCellPrevChanged); // Button: next socket Button btnSktNext = new Button("PushbuttonSmall", 40, 40, 123, 686, Keys.Enter, false); widgetList.Add(btnSktNext); btnSktNext.OnChange += new ChangeEventHandler(btnSktNextChanged); // Knob: rotates selected cell wheelRotate = new Wheel("Knob", 48, 56, 34, 578, 24f, 24f, Keys.None, Keys.None); widgetList.Add(wheelRotate); wheelRotate.OnChange += new ChangeEventHandler(knobRotateChanged); // Button: rotates selected cell in 45-degree increments Button btnRotate = new Button("PushbuttonSmall", 40, 40, 37, 511, Keys.R, true); widgetList.Add(btnRotate); btnRotate.OnChange += new ChangeEventHandler(btnRotateChanged); // Multiswitch selects mode: cell-edit, channel-edit or chemoscan modeSwitch = new MultiSwitch("knobMedium", 64, 75, 930, 317, 32f, 32f, Keys.None, Keys.None, 4, (float)(Math.PI * 0.5)); widgetList.Add(modeSwitch); modeSwitch.OnChange += new ChangeEventHandler(ModeSwitchChanged); modeSwitch.Value = (int)Camera.ScannerModes.Cell; // default mode is cell-edit mode // Buttons for navigating/modifying chemical channels // Button: previous channel Button btnChannelUp = new Button("BtnRectUp", 64, 24, 205, 684, Keys.None, false); widgetList.Add(btnChannelUp); btnChannelUp.OnChange += new ChangeEventHandler(btnChannelUpChanged); // Button: next channel Button btnChannelDn = new Button("BtnRectDn", 64, 24, 205, 708, Keys.None, false); widgetList.Add(btnChannelDn); btnChannelDn.OnChange += new ChangeEventHandler(btnChannelDnChanged); // Button: change channel to use previous chemical Button btnChemUp = new Button("BtnRectUp", 64, 24, 677, 684, Keys.None, false); widgetList.Add(btnChemUp); btnChemUp.OnChange += new ChangeEventHandler(btnChemUpChanged); // Button: change channel to use next chemical Button btnChemDn = new Button("BtnRectDn", 64, 24, 677, 708, Keys.None, false); widgetList.Add(btnChemDn); btnChemDn.OnChange += new ChangeEventHandler(btnChemDnChanged); // Buttons for steering & zooming camera Button btnCamUp = new Button("BtnRectUp", 64, 24, 930, 440, Keys.NumPad8, false); widgetList.Add(btnCamUp); btnCamUp.OnChange += new ChangeEventHandler(btnCamUpChanged); Button btnCamDn = new Button("BtnRectDn", 64, 24, 930, 488, Keys.NumPad2, false); widgetList.Add(btnCamDn); btnCamDn.OnChange += new ChangeEventHandler(btnCamDnChanged); Button btnCamLeft = new Button("BtnRectSmallRight", 32, 24, 962, 464, Keys.NumPad6, false); widgetList.Add(btnCamLeft); btnCamLeft.OnChange += new ChangeEventHandler(btnCamLeftChanged); Button btnCamRight = new Button("BtnRectSmallLeft", 32, 24, 930, 464, Keys.NumPad4, false); widgetList.Add(btnCamRight); btnCamRight.OnChange += new ChangeEventHandler(btnCamRightChanged); Button btnCamZoomIn = new Button("BtnRectUp", 64, 24, 930, 548, Keys.NumPad9, true); widgetList.Add(btnCamZoomIn); btnCamZoomIn.OnChange += new ChangeEventHandler(btnCamZoomInChanged); Button btnCamZoomOut = new Button("BtnRectDn", 64, 24, 930, 572, Keys.NumPad3, true); widgetList.Add(btnCamZoomOut); btnCamZoomOut.OnChange += new ChangeEventHandler(btnCamZoomOutChanged); // Knob: adjusts channel constants wheelConst = new Wheel("Knob", 48, 56, 785, 689, 24f, 24f, Keys.None, Keys.None); widgetList.Add(wheelConst); wheelConst.OnChange += new ChangeEventHandler(wheelConstChanged); // Meter: shows channel constant meterConst = new Meter("LabNeedle", 8, 48, 898, 710, 0.87f, 4, 40, -3, 3, true); widgetList.Add(meterConst); // LED to show when a constant is applicable (i.e. chemical selectivity is set to none) lampConst = new Lamp("LED", 24, 24, 796, 662); widgetList.Add(lampConst); // transparent reflection on LCD glass (printed on top of LCD contents) widgetList.Add(labReflection = new Widget("LabReflection", false, 620, 112, 416, 675)); }
/// <summary> /// Cell type selector has changed /// </summary> /// <param name="sender"></param> public void typeSelectorChanged(Widget sender, Object value) { // Rebuild the type selection list variantSelector.SetList(GroupTypeVariant.GetVariants(groupSelector.Index,typeSelector.Index)); }
/// <summary> /// Cell variant up button changed /// </summary> /// <param name="sender"></param> public void btnVariantUpChanged(Widget sender, Object value) { if ((bool)value == true) variantSelector.MoveUp(); }
/// <summary> /// Cell type up button changed /// </summary> /// <param name="sender"></param> public void btnTypeUpChanged(Widget sender, Object value) { if ((bool)value == true) typeSelector.MoveUp(); }
/// <summary> /// Button: delete the selected cell(s) /// </summary> /// <param name="sender"></param> public void btnDeleteChanged(Widget sender, Object value) { if (((bool)value == true) // Only do it if the button has been pressed && (Lab.SelectedCell != null)) // and there is a selected cell { Organism.DeleteCell(); // delete the selected cell DrawCellData(); // update the LCD } }
public void btnCamLeftChanged(Widget sender, Object value) { owner.Command("left", value); }
public void btnGroupDnChanged(Widget sender, Object value) { ((LabPanel2)owner.Panel[1]).btnGroupDnChanged(sender, value); }
public void btnCamRightChanged(Widget sender, Object value) { owner.Command("right", value); }
/// <summary> /// PREVIEW button pressed - temporarily add a new cell or delete it again when btn released /// </summary> /// <param name="sender"></param> /// <param name="value"></param> public void btnPreviewChanged(Widget sender, Object value) { if (((bool)value == true) && (Lab.SelectedCell != null) && (Lab.SelectedSocket != null)) { owner.Add(); DrawCellData(); previewed = Lab.SelectedCell; } else if (((bool)value == false) && (Lab.SelectedCell != null) && (Lab.SelectedCell == previewed)) { Organism.DeleteCell(); // delete the selected cell DrawCellData(); // update the LCD previewed = null; } }
/// <summary> /// A camera steering button has changed. Pass this to the cell (via the organism) to animate the camera joints /// </summary> /// <param name="sender"></param> /// <param name="value"></param> public void btnCamUpChanged(Widget sender, Object value) { owner.Command("up", value); }
/// <summary> /// Rotation button has changed - rotate the selected cell in neat 90-degree increments /// </summary> /// <param name="sender"></param> public void btnRotateChanged(Widget sender, Object value) { if (((bool)value == true) && (Lab.SelectedCell != null)) { // get the current angle from the matrix (varies from 0 at top to +/- PI at bottom) float angle = -(float)Math.Atan2(Lab.SelectedCell.PlugOrientation.M13, Lab.SelectedCell.PlugOrientation.M33); // Convert range from +/-PI to +/-1 const float PI = (float)Math.PI; float octant = angle / PI; // From there into range +/-4 (current octant). Round to nearest integer so that we go to // our nearest octant, then increment to the next octant octant = (float)Math.Round(octant * 4) + 1; // Return into the range +/-PI octant = octant / 4 * PI; // This is the new rotation Lab.SelectedCell.PlugOrientation = Matrix.RotationYawPitchRoll(octant, 0, 0); } }
public void btnCamZoomOutChanged(Widget sender, Object value) { zoomRate = ((bool)value) ? 0.3f : 0f; }
/// <summary> /// Button: Activate the tractor beam /// </summary> /// <param name="sender"></param> public void btnTractorChanged(Widget sender, Object value) { if (((bool)value == true) // Only do it if the button has been pressed && (Lab.TrackedOrg != null)) // and there has been a creature on the clamp or selected for tracking { if (Lab.SelectedOrg != null) // detach any existing creature from the clamp { // in case another creature was clicked on from the sub, whilst editing owner.Detach(); } Lab.TractorBeam = Lab.TrackedOrg; // attach this org to the tractor beam DrawCellData(); // update the LCD } }
/// <summary> /// A cell navigation button was pressed. Move up/down/left/right in the tree and select a new cell /// </summary> /// <param name="sender"></param> public void btnCellUpChanged(Widget sender, Object value) { if (((bool)value == true) && (Lab.SelectedOrg != null)) { Lab.SelectedOrg.SelectUp(); DrawCellData(); } }
/// <summary> /// The organism's species name has been changed /// </summary> /// <param name="sender"></param> /// <param name="value"></param> public void editSpeciesChanged(Widget sender, Object value) { Organism org = Lab.SelectedOrg; if (org != null) { org.Name = (string)value; } }
public void btnChannelDnChanged(Widget sender, Object value) { if (((bool)value == true) && (Lab.SelectedCell != null)) { Lab.SelectedCell.PrevChannel(); DrawCellData(); } }
/// <summary> /// User has selected a new disply mode (normal, cell-editing, channel-editing, chemoscan) /// </summary> public void ModeSwitchChanged(Widget sender, Object value) { Camera.ScannerMode = (Camera.ScannerModes)((int)value); }
public void btnChemUpChanged(Widget sender, Object value) { if (((bool)value == true) && (Lab.SelectedCell != null)) { Lab.SelectedCell.NextChemical(); DrawCellData(); } }
private Pen vduPen = null; // foreground pen for lines etc. (same colour as .brush) #endregion Fields #region Constructors public LabPanel2(Lab owner) : base() { // Store the camera ship for callbacks etc. this.owner = owner; // Create the fonts, brushes and pens vduFont = new System.Drawing.Font(FontFamily.GenericMonospace, 12, FontStyle.Bold); vduBrush = new SolidBrush(Color.FromArgb(150, Color.LightGreen)); vduFill = new SolidBrush(Color.FromArgb(64, Color.LightGreen)); vduPen = new Pen(vduBrush, 2); // Depth of one line of text vduLine = vduFont.Height; // Create the backdrop and widgets... // For now, use a single-piece backdrop and superimpose smaller bitmaps for the writeable widgets // such as selectors. Later it might be sensible to cut up the backdrop so as not to duplicate // these regions widgetList.Add(new Widget("LabPanel2", false, 1024, 768, 0, 0)); // cell group list on VDU groupSelector = new Selector("LabVduGroup", 160, 128, 192, 98, vduFont, vduBrush, vduFill); widgetList.Add(groupSelector); groupSelector.OnChange += new ChangeEventHandler(groupSelectorChanged); // cell type list on VDU typeSelector = new Selector("LabVduType", 160, 128, 192, 256, vduFont, vduBrush, vduFill); widgetList.Add(typeSelector); typeSelector.OnChange += new ChangeEventHandler(typeSelectorChanged); // cell variant list on VDU variantSelector = new Selector("LabVduVariant", 160, 96, 192, 415, vduFont, vduBrush, vduFill); widgetList.Add(variantSelector); variantSelector.OnChange += new ChangeEventHandler(variantSelectorChanged); // Button: cell group selection up Button btnGroupUp = new Button("BtnRectUp", 64, 24, 8, 64, Keys.None, true); widgetList.Add(btnGroupUp); btnGroupUp.OnChange += new ChangeEventHandler(btnGroupUpChanged); // Button: cell group selection down Button btnGroupDn = new Button("BtnRectDn", 64, 24, 8, 128, Keys.None, true); widgetList.Add(btnGroupDn); btnGroupDn.OnChange += new ChangeEventHandler(btnGroupDnChanged); // Button: cell type selection up Button btnTypeUp = new Button("BtnRectUp", 64, 24, 8, 192, Keys.None, true); widgetList.Add(btnTypeUp); btnTypeUp.OnChange += new ChangeEventHandler(btnTypeUpChanged); // Button: cell type selection down Button btnTypeDn = new Button("BtnRectDn", 64, 24, 8, 256, Keys.None, true); widgetList.Add(btnTypeDn); btnTypeDn.OnChange += new ChangeEventHandler(btnTypeDnChanged); // Button: cell variant selection up Button btnVariantUp = new Button("BtnRectUp", 64, 24, 8, 320, Keys.None, true); widgetList.Add(btnVariantUp); btnVariantUp.OnChange += new ChangeEventHandler(btnVariantUpChanged); // Button: cell variant selection down Button btnVariantDn = new Button("BtnRectDn", 64, 24, 8, 384, Keys.None, true); widgetList.Add(btnVariantDn); btnVariantDn.OnChange += new ChangeEventHandler(btnVariantDnChanged); // Carousel for displaying information about the selected cell type infoPanel = new Carousel("LabVduInfoPanel", 512, 400, 400, 105); // Space for writing information about the creature being built (total mass, etc.) totalsPanel = new Widget("LabVduTotalsPanel", true, 740, 64, 192, 530); widgetList.Add(totalsPanel); // fill the selectors with the cell groups, types and variants available on this system groupSelector.SetList(GroupTypeVariant.GetGroups()); typeSelector.SetList(GroupTypeVariant.GetTypes(0)); variantSelector.SetList(GroupTypeVariant.GetVariants(0,0)); }
/// <summary> /// Hatch button has been pressed - jump to survey ship / lab /// </summary> /// <param name="sender"></param> /// <param name="value"></param> void hatch_OnChange(Widget sender, object value) { hatch.Frame = 0; // reset switch CameraShip.SwitchCameraShip(); // change to next (specific???) camera ship }