public static void createHitPointLabel(Entity entity, int width, int height, Point position) { Entity e = ecs_instance.create(); HpLabelUpdater updater = new HpLabelUpdater(ecs_instance); GForm form = new GForm(); form.owner = e; form.ecs_instance = ecs_instance; form.bounds = new Rectangle(position.X, position.Y, width, height); GCanvas canvas = new GCanvas(); canvas.owner = e; canvas.ecs_instance = ecs_instance; canvas.bounds = new Rectangle(position.X, position.Y, width, height); GLabel label = new GLabel(); label.owner = e; label.caller = entity; label.ecs_instance = ecs_instance; label.bounds = new Rectangle(position.X, position.Y, width, height); label.font_name = "General"; label.border = 5; label.background_name = "frame"; label.background_color = Color.Gray; label.transparency = 1f; label.autosize = true; label.center_text = true; label.text = "XXX / XXX"; label.text_color = Color.Red; label.updating += updater.updateHandler; canvas.controls.Add(label); form.canvas_controls.Add(canvas); UserInterface ui = new UserInterface(form); ecs_instance.component_manager.add_component(e, ui); ecs_instance.resolve(e); }
/// <summary> /// initialize menu /// </summary> public void init() { //setup form _Form = new GForm(); _Form.owner = _Owner; _Form.caller = _Caller; _Form.ecs_instance = _ECSInstance; _Form.bounds = new Rectangle(_Position.X, _Position.Y, _Width + 2 * _border, (_Height + _Spacing) * _ButtonCount + 2 * _border); //setup canvas _Canvas = new GCanvas(); _Canvas.owner = _Owner; _Canvas.caller = _Caller; _Canvas.ecs_instance = _ECSInstance; _Canvas.bounds = new Rectangle(_Position.X, _Position.Y, _Width + 2 * _border, (_Height + _Spacing) * _ButtonCount + 2 * _border); //setup frame _Frame = new GFrame(); _Frame.owner = _Owner; _Frame.caller = _Caller; _Frame.ecs_instance = _ECSInstance; _Frame.bounds = new Rectangle(_Position.X, _Position.Y, _Width + 2 * _border, (_Height + _Spacing) * _ButtonCount + 2 * _border); //_Canvas.Controls.Add(_Frame); for (int i = 0; i < _ButtonCount; i++) { GButton button = new GButton(); button.owner = _Owner; button.caller = _Caller; button.ecs_instance = _ECSInstance; button.bounds = new Rectangle(_Position.X + _border, _Position.Y + _border + i * (_Height + _Spacing), _Width, _Height); //_Canvas.Controls.Add(button); _Buttons.Add(button); } //_Form.CanvasControls.Add(_Canvas); }
public static GFrame createMousePointer(Point position, int width, int height, string textureName, InterfaceHandler handler) { Entity e = ecs_instance.create(); GForm form = new GForm(); form.owner = e; form.ecs_instance = ecs_instance; form.bounds = new Rectangle(position.X, position.Y, width, height); GCanvas canvas = new GCanvas(); canvas.owner = e; canvas.ecs_instance = ecs_instance; canvas.bounds = new Rectangle(position.X, position.Y, width, height); GFrame frame = new GFrame(); frame.owner = e; frame.ecs_instance = ecs_instance; frame.bounds = new Rectangle(position.X, position.Y, width, height); frame.background_name = textureName; frame.updating += handler; canvas.controls.Add(frame); form.canvas_controls.Add(canvas); UserInterface ui = new UserInterface(form); ecs_instance.component_manager.add_component(e, ui); ecs_instance.resolve(e); return(frame); }
public static void createFrame(Entity caller, Point Position, int height, int width, string textureName) { Entity e = ecs_instance.create(); GForm form = new GForm(); form.caller = caller; form.owner = e; form.ecs_instance = ecs_instance; form.bounds = new Rectangle(Position.X, Position.Y, width, height); GCanvas canvas = new GCanvas(); canvas.caller = caller; canvas.owner = e; canvas.ecs_instance = ecs_instance; canvas.bounds = new Rectangle(Position.X, Position.Y, width, height); GFrame frame = new GFrame(); frame.caller = caller; frame.owner = e; frame.ecs_instance = ecs_instance; frame.bounds = new Rectangle(Position.X, Position.Y, width, height); frame.background_name = textureName; canvas.controls.Add(frame); form.canvas_controls.Add(canvas); UserInterface ui = new UserInterface(form); ecs_instance.component_manager.add_component(e, ui); ecs_instance.resolve(e); }
public UserInterface(GForm form) { this.form = form; }