Client LuaCsForBarotrauma
EditorScreen.cs
1 using Microsoft.Xna.Framework;
2 
3 namespace Barotrauma
4 {
6  {
7  public static Color BackgroundColor = GameSettings.CurrentConfig.SubEditorBackground;
8  public override bool IsEditor => true;
9 
10  public override sealed void Deselect()
11  {
13 #if !DEBUG
14  //reset cheats the player might have used in the editor
15  GameMain.LightManager.LightingEnabled = true;
16  GameMain.LightManager.LosEnabled = true;
17  Hull.EditFire = false;
18  Hull.EditWater = false;
20 #endif
21  }
22 
23  protected virtual void DeselectEditorSpecific() { }
24 
26  {
27  var msgBox = new GUIMessageBox(TextManager.Get("CharacterEditor.EditBackgroundColor"), "", new[] { TextManager.Get("Reset"), TextManager.Get("OK")}, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
28 
29  var rgbLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), msgBox.Content.RectTransform), isHorizontal: true);
30 
31  // Generate R,G,B labels and parent elements
32  var layoutParents = new GUILayoutGroup[3];
33  for (int i = 0; i < 3; i++)
34  {
35  var colorContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.33f, 1), rgbLayout.RectTransform), isHorizontal: true) { Stretch = true };
36  new GUITextBlock(new RectTransform(new Vector2(0.2f, 1), colorContainer.RectTransform, Anchor.CenterLeft) { MinSize = new Point(15, 0) }, GUI.ColorComponentLabels[i], font: GUIStyle.SmallFont, textAlignment: Alignment.Center);
37  layoutParents[i] = colorContainer;
38  }
39 
40  // attach number inputs to our generated parent elements
41  var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), NumberType.Int) { IntValue = BackgroundColor.R };
42  var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), NumberType.Int) { IntValue = BackgroundColor.G };
43  var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), NumberType.Int) { IntValue = BackgroundColor.B };
44 
45  rInput.MinValueInt = gInput.MinValueInt = bInput.MinValueInt = 0;
46  rInput.MaxValueInt = gInput.MaxValueInt = bInput.MaxValueInt = 255;
47 
48  rInput.OnValueChanged = gInput.OnValueChanged = bInput.OnValueChanged = delegate
49  {
50  var color = new Color(rInput.IntValue, gInput.IntValue, bInput.IntValue);
51  BackgroundColor = color;
52  var config = GameSettings.CurrentConfig;
53  config.SubEditorBackground = color;
54  GameSettings.SetCurrentConfig(config);
55  };
56 
57  // Reset button
58  msgBox.Buttons[0].OnClicked = (button, o) =>
59  {
60  rInput.IntValue = 13;
61  gInput.IntValue = 37;
62  bInput.IntValue = 69;
63  return true;
64  };
65 
66  // Ok button
67  msgBox.Buttons[1].OnClicked = (button, o) =>
68  {
69  msgBox.Close();
70  GameSettings.SaveCurrentConfig();
71  return true;
72  };
73  }
74  }
75 }
static Color BackgroundColor
Definition: EditorScreen.cs:7
virtual void DeselectEditorSpecific()
Definition: EditorScreen.cs:23
override sealed void Deselect()
Definition: EditorScreen.cs:10
void CreateBackgroundColorPicker()
Definition: EditorScreen.cs:25
override bool IsEditor
Definition: EditorScreen.cs:8
static Lights.LightManager LightManager
Definition: GameMain.cs:78
NumberType
Definition: Enums.cs:715