/// <summary> /// Initialize the base controls /// </summary> public void init() { _Form = new GForm(); _Form.owner = _Owner; _Form.caller = _Caller; _Form.ecs_instance = _ECSInstance; _Form.bounds = new Rectangle(_Position.X, _Position.Y, _Dimensions.X, _Dimensions.Y); _Canvas = new GCanvas(); _Canvas.owner = _Owner; _Canvas.caller = _Caller; _Canvas.ecs_instance = _ECSInstance; _Canvas.bounds = new Rectangle(_Position.X, _Position.Y, _Dimensions.X, _Dimensions.Y); _Frame = new GFrame(); _Frame.owner = _Owner; _Frame.caller = _Caller; _Frame.ecs_instance = _ECSInstance; _Frame.bounds = new Rectangle(_Position.X, _Position.Y, _Dimensions.X, _Dimensions.Y); _Button = new GButton(); _Button.owner = _Owner; _Button.caller = _Caller; _Button.ecs_instance = _ECSInstance; _Button.bounds = new Rectangle(_Position.X, _Position.Y, _Dimensions.X, _ButtonHeight); }
static string GetScriptString(GPrefabInstance firstTarget) { string script = ""; GFrame frame = firstTarget.GetComponentInParent <GFrame>(); if (frame) { //script += "findPath = \"" + GUtility.GetPath(frame.transform, firstTarget.transform) + "\";\n"; script += "trans = frame.Find(\"" + GUtility.GetPath(frame.transform, firstTarget.transform) + "\");\n"; } GWidget prefab = firstTarget.prefab; for (int i = 0; i < prefab.exportToScriptInfos.Count; i++) { GExportToScriptInfo property = prefab.exportToScriptInfos[i]; string path = GUtility.GetPath(firstTarget.transform, property.target.transform); if (path.StartsWith("/")) { path = path.Substring(1); } script += "trans.Find(\"" + path + "\")."; script += "GetComponent <" + property.type + "> ();"; script += "//" + property.rename + "\n"; } return(script); }
public Icon() : base() { this.slope = 0; this.image = null; this.frame = null; this.dimen = null; this.calib = null; this.point = null; }
public override void OnInspectorGUI() { GFrame frame = target as GFrame; //if (GUILayout.Button("生成代码")) { // string script = CreateClassScript(frame); // File.WriteAllText(GFrame.SavePath + "/" + GetName(frame.name) + ".cs", script); // AssetDatabase.Refresh(); //} EditorGUILayout.TextArea(CreateDeclearScript(frame) + CreateBindScript(frame)); }
//static string CreateClassScript(GFrame frame) //{ // string result = ""; // result += "using UnityEngine;\n"; // result += "using UnityEngine.UI;\n\n"; // result += "//该文件由GFrameInspector.cs自动生成,请不要手动修改\n"; // result += "namespace UIFrame{\n"; // result += " public class " + GetName(frame.name) + "\n"; // result += " {\n"; // // //属性列表 // ForEachProperty(frame, (GPrefabInstance loader, GExportToScriptInfo property) => { // result += " public " + property.type.Replace('+','.') + " " + GetName(loader,property) + ";"; // result += " \n"; // }); // // //绑定函数 // result += " public void BindProperty(Transform frame)\n"; // result += " {\n"; // ForEachProperty(frame, (GPrefabInstance loader, GExportToScriptInfo property) => { // result += " " + GetName(loader, property) + " = frame.Find(\"" + GUtility.GetPath(frame.transform,property.target.transform) + "\").GetComponent<" + property.type + ">();"; // result += "\n"; // }); // result += " }\n"; // // result += " }\n}\n"; // return result; //} static string CreateDeclearScript(GFrame frame) { string result = ""; ForEachProperty(frame, (GPrefabInstance loader, GRuntimeLib lib) => { if (lib) { result += "public " + lib.GetType().Name.Replace('+', '.') + " " + GetName(loader.name) + ";"; result += "\n"; } }); return(result + "\n"); }
public CommandResult SetLocalEcho(bool enabled) { //Set Value _connection.Param.LocalEcho = enabled; GFrame f = GApp.Frame; //ToolBar if (GApp.Options.ShowToolBar) { f.ToolBar.LocalEchoButton.Checked = enabled; f.ToolBar.Invalidate(true); } //Menu f.MenuLocalEcho.Checked = enabled; return(CommandResult.Success); }
public CommandResult SetLogSuspended(bool suspended) { //Set Value _connection.LogSuspended = suspended; GFrame f = GApp.Frame; //ToolBar if (GApp.Options.ShowToolBar) { f.ToolBar.SuspendLogButton.Checked = suspended; f.ToolBar.Invalidate(true); } //Menu f.MenuSuspendLog.Checked = suspended; return(CommandResult.Success); }
static string GetScriptString2(GPrefabInstance firstTarget) { string script = ""; GFrame frame = firstTarget.GetComponentInParent <GFrame>(); if (frame) { script += "相对于Frame的路径:\n"; script += " \"" + GUtility.GetPath(frame.transform, firstTarget.transform) + "\"\t//" + GetTypes(firstTarget.prefab.transform) + "\n"; } script += "\n"; GWidget prefab = firstTarget.prefab; script += "内部结构:\n"; script += GetTreeString(prefab.transform, " "); return(script); }
static void ForEachProperty(GFrame frame, System.Action <GPrefabInstance, GRuntimeLib> fun) { //GWidget[] widgets = frame.transform.GetComponentsInChildren<GWidget>(); //for (int i = 0; i < widgets.Length; i++) { // for(int p = 0; p < widgets[i].exportToScriptInfos.Count; p++) { // fun(widgets[i], widgets[i].exportToScriptInfos[p]); // } //} GPrefabInstance[] loaders = frame.transform.GetComponentsInChildren <GPrefabInstance>(); for (int i = 0; i < loaders.Length; i++) { //for(int p = 0; p < loaders[i].prefab.exportToScriptInfos.Count; p++) { fun(loaders[i], loaders[i].prefab.GetComponent <GRuntimeLib>()); //} } }
static string CreateBindScript(GFrame frame) { string result = ""; //绑定函数 result += "public void BindProperty(Transform frame)\n"; result += "{\n"; ForEachProperty(frame, (GPrefabInstance loader, GRuntimeLib lib) => { if (lib) { result += " " + GetName(loader.name) + " = frame.Find(\"" + GUtility.GetPath(frame.transform, loader.transform) + "\").GetComponent<" + lib.GetType().Name + ">();"; result += "\n"; } }); result += "}\n"; return(result); }
public CommandResult SetTransmitNewLine(NewLine nl) { //Set Value _connection.Param.TransmitNL = nl; GFrame f = GApp.Frame; //ToolBar if (GApp.Options.ShowToolBar) { f.ToolBar.NewLineBox.SelectedIndex = (int)nl; f.ToolBar.Invalidate(true); } //Menu f.MenuNewLineCR.Checked = nl == NewLine.CR; f.MenuNewLineLF.Checked = nl == NewLine.LF; f.MenuNewLineCRLF.Checked = nl == NewLine.CRLF; return(CommandResult.Success); }
/// <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 static void Init(InitialAction act, string[] args, bool already_exists) //GFrameの作成はコンストラクタの後にしないと、GuevaraAppのメソッドをデリゲートの引数にできない。 { if (args.Length > 0) { act.ShortcutFile = args[0]; } _frame = new GFrame(act); _globalCommandTarget.Init(_frame); if (already_exists && _options.FrameState == FormWindowState.Normal) { Rectangle rect = _options.FramePosition; rect.Location += new Size(24, 24); _options.FramePosition = rect; } _frame.DesktopBounds = _options.FramePosition; _frame.WindowState = _options.FrameState; _frame.AdjustMRUMenu(); //キャッチできなかったエラーの補足 Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException); }
public static Entity createInventoryWindow(Entity caller, Point position, Point dimensions, int buttonHeight, int rows, int cols) { Entity e = ecs_instance.create(); BasicWindow window = new BasicWindow(e, caller, ecs_instance, position, dimensions, buttonHeight); //initialize the window window.init(); //setup background frame window.Frame.background_color = Color.White; window.Frame.background_name = "whitebg"; window.Frame.transparency = 0.5f; //setup close button window.Button.background_name = "test_dialog"; window.Button.background_color = Color.Gray; window.Button.transparency = 1f; window.Button.border = 0; window.Button.font_name = "General"; window.Button.center_text = true; window.Button.text = "Inventory"; window.Button.text_color = Color.White; //setup button mouse events window.Button.mouse_enter += change_button_on_hover; window.Button.mouse_press += change_button_on_press; window.Button.mouse_leave += change_button_on_leave; window.Button.mouse_click += destroyUI; //pre-assemble window window.preAssemble(); //add what i need here int x = window.Frame.bounds.X; int y = window.Frame.bounds.Y + buttonHeight; int xSize = window.Frame.bounds.Width / cols; int ySize = (window.Frame.bounds.Height - buttonHeight) / rows; for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { GFrame slot = new GFrame(); slot.owner = e; slot.caller = caller; slot.ecs_instance = ecs_instance; slot.bounds = new Rectangle(x + i * xSize, y + j * ySize, xSize - 1, ySize - 1); slot.background_color = Color.White; slot.background_name = "frame"; slot.transparency = 0.5f; slot.mouse_click += getItem; window.Canvas.controls.Add(slot); } } //final assemble window.assemble(); //create the UI component and assign it to the entity UserInterface ui = new UserInterface(window.Form); ecs_instance.component_manager.add_component(e, ui); ecs_instance.resolve(e); return(e); }
public FrameChangedEventArgs(int number, GFrame frame) { Frame = frame; Number = number; }
public override void LoadContent() { //create backdrop UIFactory.createFrame(null, new Point(0, 0), s_Container.GraphicsDevice.Viewport.Height, s_Container.GraphicsDevice.Viewport.Width, "Title"); //create menu Entity e = ecs_instance.create(); int border = 10; int spacing = 5; int height = 38; int width = 100; Point screen = new Point(s_Container.GraphicsDevice.Viewport.Width, s_Container.GraphicsDevice.Viewport.Height); Point location = new Point(screen.X / 2 - (width + 2 * border) / 2, screen.Y / 2); s_ButtonMenu = new ButtonMenu(e, null, ecs_instance, 3, location, height, width, border, spacing); s_ButtonMenu.init(); s_ButtonMenu.Frame.background_name = "frame"; s_ButtonMenu.Frame.background_color = Color.Black; s_ButtonMenu.Frame.transparency = 0.75f; s_ButtonMenu.Buttons[0].background_name = "test_dialog"; s_ButtonMenu.Buttons[0].background_color = Color.Gray; s_ButtonMenu.Buttons[0].transparency = 1f; //0.75f; s_ButtonMenu.Buttons[0].border = 10; s_ButtonMenu.Buttons[0].font_name = "General"; s_ButtonMenu.Buttons[0].autosize = false; s_ButtonMenu.Buttons[0].center_text = true; s_ButtonMenu.Buttons[0].text = "New Game"; s_ButtonMenu.Buttons[0].text_color = Color.White; s_ButtonMenu.Buttons[0].mouse_enter += change_button_on_hover; s_ButtonMenu.Buttons[0].mouse_press += change_button_on_press; s_ButtonMenu.Buttons[0].mouse_leave += change_button_on_leave; s_ButtonMenu.Buttons[0].mouse_click += OnMouseClickNewGame; s_ButtonMenu.Buttons[1].background_name = "test_dialog"; s_ButtonMenu.Buttons[1].background_color = Color.Gray; s_ButtonMenu.Buttons[1].transparency = 1f; s_ButtonMenu.Buttons[1].border = 10; s_ButtonMenu.Buttons[1].font_name = "General"; s_ButtonMenu.Buttons[1].autosize = false; s_ButtonMenu.Buttons[1].center_text = true; s_ButtonMenu.Buttons[1].text = "World Gen"; s_ButtonMenu.Buttons[1].text_color = Color.White; s_ButtonMenu.Buttons[1].mouse_enter += change_button_on_hover; s_ButtonMenu.Buttons[1].mouse_press += change_button_on_press; s_ButtonMenu.Buttons[1].mouse_leave += change_button_on_leave; s_ButtonMenu.Buttons[1].mouse_click += OnMouseClickWorldGen; s_ButtonMenu.Buttons[2].background_name = "test_dialog"; s_ButtonMenu.Buttons[2].background_color = Color.Gray; s_ButtonMenu.Buttons[2].transparency = 1f; s_ButtonMenu.Buttons[2].border = 10; s_ButtonMenu.Buttons[2].font_name = "General"; s_ButtonMenu.Buttons[2].autosize = false; s_ButtonMenu.Buttons[2].center_text = true; s_ButtonMenu.Buttons[2].text = "Exit Game"; s_ButtonMenu.Buttons[2].text_color = Color.White; s_ButtonMenu.Buttons[2].mouse_enter += change_button_on_hover; s_ButtonMenu.Buttons[2].mouse_press += change_button_on_press; s_ButtonMenu.Buttons[2].mouse_leave += change_button_on_leave; s_ButtonMenu.Buttons[2].mouse_click += OnMouseClickExit; s_ButtonMenu.assemble(); UserInterface ui = new UserInterface(s_ButtonMenu.Form); ecs_instance.add_component(e, ui); ecs_instance.resolve(e); //load the json start screen file s_json = s_JsonManager.loadJSON(GameConfig.root_dir + "/Content/json/start_screen.v"); //create mouse pointer s_Frame = UIFactory.createMousePointer(InputManager.getMousePosition(), 10, 10, "pointer", OnMousePointerUpdate); //early entity reslove ecs_instance.resolve_entities(); //load system content ecs_instance.system_manager.systems_load_content(); base.LoadContent(); }
public void Init(GFrame f) { _frame = f; }
public Context() { OutputData = new GFrame(); }