public InterfaceInputHandler(fbInterface ui) { this.ui = ui; game = ui.Game; engine = ui.Engine; new InputSubscriber(this) .Subscribe("move-nw") .Subscribe("move-n") .Subscribe("move-ne") .Subscribe("move-e") .Subscribe("move-se") .Subscribe("move-s") .Subscribe("move-sw") .Subscribe("move-w") .Subscribe("pass") .Subscribe("warp") .Subscribe("bombard") .Subscribe("dev-login") .Subscribe("dev-test") .Subscribe("dev-save") .Subscribe("dev-spawn-station") .Subscribe("dev-spawn-planet") .Subscribe("dev-spawn-playerstart") .Subscribe("select-next-idle") .Subscribe("quit") .Register(); }
protected override void Initialize() { base.Initialize(); SpriteBatch = new SpriteBatch(GraphicsDevice); Engine = new fbEngine(this); Engine.SetSize(1280, 720); LoadTexturesFromFile("cfg/textures.cfg"); Engine.DefaultFont = new Font(); Engine.DefaultFont.FontSheet = Engine.GetTexture("font"); Engine.DefaultFont.CharSize = new Vector2(8); NetMessage3.Setup(); Game = new fbGame(); Game.Ready = false; Game.SetupClientSideEventHandler(Engine); //eugh fbNetClient.Game = Game; UI = new fbInterface(Game, Engine); Engine.StartNetClient(); }
public SmartText( string text, fbInterface ui ) { Text = text; this.ui = ui; }
protected ContainerWidget( fbEngine engine, fbInterface ui ) : base(engine, ui) { Children = new List <Widget>(); }
public SideBySideWidgets( fbEngine engine, fbInterface ui, int internalPadding = 0 ) : base(engine, ui) { this.internalPadding = internalPadding; }
public ListBox( fbEngine engine, fbInterface ui, int internalPadding = 0 ) : base(engine, ui) { this.internalPadding = internalPadding; }
public CheckBox( fbEngine engine, fbInterface ui, int depth = -1 ) : base(engine, ui, depth) { subscriber = new InputSubscriber(this); subscriber.Register(); }
public Label( string text, fbEngine engine, fbInterface ui, int depth = -1 ) : base(engine, ui, depth) { content = new SmartText(text, ui); }
public Image( string texture, fbEngine engine, fbInterface ui, float scale = 1f ) : base(engine, ui) { this.texture = texture; this.scale = scale; }
protected Widget( fbEngine engine, fbInterface ui, int depth = -1 ) { this.engine = engine; this.ui = ui; this.depth = depth; Conditions = new List <fbCondition>(); }
public TextureButton( string texture, Action reaction, fbEngine engine, fbInterface ui, float scale = 1f ) : base("", reaction, engine, ui) { this.texture = texture; this.scale = scale; }
public Button( string label, Action reaction, fbEngine engine, fbInterface ui ) : base(engine, ui) { this.label = new SmartText(label, ui); this.reaction = reaction; subscriber = new InputSubscriber(this); subscriber.Register(); }
public static Widget WidgetFromXml( XmlNode xml, fbInterface ui, fbEngine engine ) { Dictionary <string, XmlNode> nodes = new Dictionary <string, XmlNode>(); foreach (XmlNode child in xml.ChildNodes) { if (child.Name == "#comment") { continue; } nodes.Add(child.Name, child); } Widget w; int internalPadding = 0; if (nodes.ContainsKey("internalpadding")) { internalPadding = Int32.Parse( nodes["internalpadding"].InnerText ); nodes.Remove("internalpadding"); } switch (xml.Name.ToLower()) { case "button": w = new Button( nodes["content"].InnerText, null, engine, ui ); if (nodes.ContainsKey("keybind")) { ((Button)w).Subscribe(nodes["keybind"].InnerText); nodes.Remove("keybind"); } nodes.Remove("content"); break; case "checkbox": w = new CheckBox( engine, ui ); if (nodes.ContainsKey("keybind")) { ((CheckBox)w).Subscribe(nodes["keybind"].InnerText); nodes.Remove("keybind"); } break; case "image": w = new Image( nodes["content"].InnerText, engine, ui ); nodes.Remove("content"); break; case "label": w = new Label( nodes["content"].InnerText, engine, ui ); nodes.Remove("content"); break; case "texturebutton": float scale = 1f; if (nodes.ContainsKey("scale")) { scale = float.Parse(nodes["scale"].InnerText); nodes.Remove("scale"); } w = new TextureButton( nodes["content"].InnerText, null, engine, ui, scale ); if (nodes.ContainsKey("keybind")) { ((Button)w).Subscribe(nodes["keybind"].InnerText); nodes.Remove("keybind"); } nodes.Remove("content"); break; // === === === === === === === === === === case "listbox": w = new ListBox( engine, ui, internalPadding ); break; case "sidebyside": w = new SideBySideWidgets( engine, ui, internalPadding ); break; default: throw new ArgumentException(); } if (nodes.ContainsKey("margins")) { int[] marginValues = nodes["margins"].InnerText .Split(',') .Select(Int32.Parse) .ToArray(); switch (marginValues.Length) { case 1: w.Margins( marginValues[0] ); break; case 2: w.Margins( marginValues[0], marginValues[1] ); break; case 4: w.Margins( marginValues[0], marginValues[1], marginValues[2], marginValues[3] ); break; } nodes.Remove("margins"); } if (nodes.ContainsKey("padding")) { int[] paddingValues = nodes["padding"].InnerText .Split(',') .Select(Int32.Parse) .ToArray(); switch (paddingValues.Length) { case 1: w.Padding( paddingValues[0] ); break; case 2: w.Padding( paddingValues[0], paddingValues[1] ); break; case 4: w.Padding( paddingValues[0], paddingValues[1], paddingValues[2], paddingValues[3] ); break; } nodes.Remove("padding"); } if (nodes.ContainsKey("alignment")) { string alignment = nodes["alignment"].InnerText.ToLower(); string halign = alignment.Split(',')[0]; string valign = alignment.Split(',')[1]; Dictionary <string, HAlignment> hAlignments = new Dictionary <string, HAlignment> { { "left", HAlignment.Left }, { "center", HAlignment.Center }, { "right", HAlignment.Right } }; Dictionary <string, VAlignment> vAlignments = new Dictionary <string, VAlignment> { { "top", VAlignment.Top }, { "center", VAlignment.Center }, { "bottom", VAlignment.Bottom } }; w.SetAlign(hAlignments[halign], vAlignments[valign]); nodes.Remove("alignment"); } if (nodes.ContainsKey("borderwidth")) { int width = Int32.Parse(nodes["borderwidth"].InnerText); w.SetBorder(width); nodes.Remove("borderwidth"); } if (nodes.ContainsKey("backgroundalpha")) { float alpha = float.Parse(nodes["backgroundalpha"].InnerText); w.SetBackgroundAlpha(alpha); nodes.Remove("backgroundalpha"); } if (nodes.ContainsKey("tooltip")) { w.SetTooltip(nodes["tooltip"].InnerText); nodes.Remove("tooltip"); } if (nodes.ContainsKey("children")) { foreach (XmlNode child in nodes["children"].ChildNodes) { ((ContainerWidget)w) .AddChild(WidgetFromXml(child, ui, engine)); } nodes.Remove("children"); } if (nodes.ContainsKey("id")) { ui.NamedWidgets.Add(nodes["id"].InnerText.ToLower(), w); nodes.Remove("id"); } //if we forgot to read some node //(because we want to read *EVERYTHING* if (nodes.Count > 0) { throw new FormatException(); } return(w); }
public InterfaceEventHandler(fbGame game, fbInterface ui) : base(game) { Game = game; this.ui = ui; }