public PopupList(Font font, String[] names, int minWidth) { RectView back = new RectView(0, 0, 100, 100, Color.Gray, Color.Black); AddView(back); View contentView = new View(100, 100); int w = minWidth; items = new ListItem[names.Length]; for (int i = 0; i < names.Length; ++i) { ListItem item = new ListItem(font, names[i], w, font.FontHeight()); item.id = i; item.buttonDelegate = OnItemSelected; contentView.AddView(item); items[i] = item; } contentView.LayoutVer(2); contentView.ResizeToFitViewsVer(); AddView(contentView); back.width = contentView.width; back.height = contentView.height; width = contentView.width; height = contentView.height; }
public BlockingScreen(View messageView, ButtonDelegate buttonDelegate = null) { AllowsDrawPrevious = true; AllowsUpdatePrevious = true; m_delegate = buttonDelegate; View contentView = new RectView(0, 0, 366, 182, Color.Black, Color.White); contentView.x = 0.5f * width; contentView.y = 0.5f * height; contentView.alignX = contentView.alignY = View.ALIGN_CENTER; messageView.x = 0.5f * contentView.width; messageView.y = 0.5f * contentView.height; messageView.alignX = messageView.alignY = View.ALIGN_CENTER; contentView.AddView(messageView); Button cancelButton = new TempButton("Cancel"); cancelButton.x = 0.5f * contentView.width; cancelButton.y = contentView.height - 12; cancelButton.alignX = View.ALIGN_CENTER; cancelButton.alignY = View.ALIGN_MAX; cancelButton.buttonDelegate = CancelButtonDelegate; SetCancelButton(cancelButton); contentView.AddView(cancelButton); AddView(contentView); }
public void AddDebugView(View view) { Application.RootController().AddDebugView(view); if (m_debugViews == null) { m_debugViews = new List<View>(); } m_debugViews.Add(view); }
public MultiplayerLobbyScreen(ServerInfo serverInfo, ButtonDelegate buttonDelegate, bool isServer) { this.serverInfo = serverInfo; viewsLookup = new Dictionary<NetConnection, ClientInfoView>(); View contentView = new View(512, 363); contentView.alignX = View.ALIGN_CENTER; contentView.x = 0.5f * width; contentView.y = 48; Font font = GetDefaultFont(); contentView.AddView(new View(215, 145)); TextView serverName = new TextView(font, serverInfo.name); serverName.alignX = View.ALIGN_CENTER; serverName.x = 113; serverName.y = 155; contentView.AddView(serverName); clientsView = new View(286, contentView.height); clientsView.alignX = View.ALIGN_MAX; clientsView.x = contentView.width; contentView.AddView(clientsView); AddView(contentView); View buttons = new View(); buttons.x = 0.5f * width; buttons.y = 432; buttons.alignX = View.ALIGN_CENTER; buttons.alignY = View.ALIGN_MAX; Button button = new TempButton("BACK"); button.buttonDelegate = buttonDelegate; button.id = (int)ButtonId.Back; buttons.AddView(button); SetCancelButton(button); String label = isServer ? "START" : "READY"; ButtonId buttonId = isServer ? ButtonId.Start : ButtonId.Ready; button = new TempButton(label); button.buttonDelegate = buttonDelegate; button.id = (int)buttonId; buttons.AddView(button); buttons.LayoutHor(10); buttons.ResizeToFitViews(); AddView(buttons); }
public Screen(float width, float height) { this.width = width; this.height = height; timerManager = TimerManager.Null; updatables = UpdatableList.Null; drawables = DrawableList.Null; eventHandlers = EventHandlerList.Null; mRootView = CreateRootView(); }
public MainMenuScreen(ButtonDelegate buttonDelegate) : base((int)MenuController.ScreenID.MainMenu) { Font font = Helper.fontButton; View rootView = new View(); TextButton button = new TempButton("Play"); button.id = (int)ButtonId.Play; button.buttonDelegate = buttonDelegate; rootView.AddView(button); button = new TempButton("Test"); button.id = (int)ButtonId.Test; button.buttonDelegate = buttonDelegate; rootView.AddView(button); button = new TempButton("Join server"); button.id = (int)ButtonId.DebugStartClient; button.buttonDelegate = buttonDelegate; rootView.AddView(button); button = new TempButton("Start server"); button.id = (int)ButtonId.DebugStartServer; button.buttonDelegate = buttonDelegate; rootView.AddView(button); //button = new TempButton("Multiplayer", font, 0, 0, w, h); //button.id = (int)ButtonId.Multiplayer; //button.SetDelegate(buttonDelegate); //rootView.AddView(button); button = new TempButton("Settings"); button.id = (int)ButtonId.Settings; button.buttonDelegate = buttonDelegate; rootView.AddView(button); button = new TempButton("Exit"); button.id = (int)ButtonId.Exit; button.buttonDelegate = buttonDelegate; rootView.AddView(button); rootView.LayoutVer(20); rootView.ResizeToFitViews(); AddView(rootView); rootView.x = 0.5f * (width - rootView.width); rootView.y = 0.5f * (height - rootView.height); }
public DialogPopup(DialogPopupDelegate popupDelegate, String title, String message, PopupButton cancelButton, params PopupButton[] buttons) { this.popupDelegate = popupDelegate; AddView(new RectView(0, 0, width, height, new Color(0.0f, 0.0f, 0.0f, 0.25f), Color.Black)); RectView frameView = new RectView(0, 0, 0.75f * width, 0, new Color(0.0f, 0.0f, 0.0f, 0.75f), Color.Black); View content = new View(); content.width = frameView.width - 2 * 50; content.alignX = content.alignY = View.ALIGN_CENTER; Font font = Helper.fontSystem; // title TextView titleView = new TextView(font, title); titleView.alignX = titleView.parentAlignX = View.ALIGN_CENTER; content.AddView(titleView); // message TextView messageView = new TextView(font, message, (int)content.width); messageView.alignX = messageView.parentAlignX = View.ALIGN_CENTER; content.AddView(messageView); // buttons Button button = new TempButton(cancelButton.title); button.id = (int)cancelButton.id; button.buttonDelegate = OnButtonPress; button.alignX = View.ALIGN_CENTER; button.parentAlignX = View.ALIGN_CENTER; SetCancelButton(button); content.AddView(button); content.LayoutVer(10); content.ResizeToFitViewsVer(); frameView.AddView(content); frameView.ResizeToFitViewsVer(20, 20); frameView.alignX = frameView.alignY = frameView.parentAlignX = frameView.parentAlignY = View.ALIGN_CENTER; AddView(frameView); content.x = 0.5f * frameView.width; content.y = 0.5f * frameView.height; }
public SettingsScreen(ButtonDelegate buttonDelegate) : base((int)MenuController.ScreenID.Settings) { Font font = Helper.fontButton; View rootView = new View(); rootView.alignX = rootView.alignY = View.ALIGN_CENTER; TextButton button = new TempButton("Back"); button.id = (int)ButtonId.Back; button.buttonDelegate = OnButtonPressed; rootView.AddView(button); rootView.LayoutVer(20); rootView.ResizeToFitViewsVer(); AddView(rootView); rootView.x = 0.5f * width; rootView.y = 0.5f * height; }
public View(float x, float y, float width, float height) { this.x = x; this.y = y; this.width = width; this.height = height; rotation = 0; rotationCenterX = 0; rotationCenterY = 0; scaleX = 1.0f; scaleY = 1.0f; color = Color.White; //solidOpaqueRGBA; translateX = 0; translateY = 0; parentAlignX = parentAlignY = alignX = alignY = ALIGN_MIN; parent = null; viewList = ViewList.Null; visible = enabled = true; }
public void RemoveView(View child) { if (viewList.Count() > 0) { viewList.Remove(child); child.parent = null; } }
private void AddPowerupsView() { View container = new View(); List<Player> players = Field.PlayersList; for (int i = 0; i < players.Count; ++i) { container.AddView(new PowerupsView(players[i].powerups)); } container.LayoutVer(0); container.ResizeToFitViews(); AddDebugView(container); }
public void AddView(View view) { RootView.AddView(view); }
public int IndexOf(View child) { return viewList.IndexOf(child); }
public RoundResultScreen(Game game, ButtonDelegate buttonDelegate) { View contentView = new View(64, 48, 512, 384); // table View tableView = new View(0, 25, contentView.width, 330); float nameColWidth = 320; float winsColWidth = 0.5f * (tableView.width - nameColWidth); float suicidesColWidth = winsColWidth; Font font = Helper.fontButton; TextView textView = new TextView(font, "PLAYER"); textView.alignX = View.ALIGN_CENTER; textView.x = 0.5f * nameColWidth; tableView.AddView(textView); textView = new TextView(font, "WINS"); textView.alignX = View.ALIGN_CENTER; textView.x = nameColWidth + 0.5f * winsColWidth; tableView.AddView(textView); textView = new TextView(font, "SUICIDES"); textView.alignX = View.ALIGN_CENTER; textView.x = nameColWidth + winsColWidth + 0.5f * suicidesColWidth; tableView.AddView(textView); List<Player> players = game.GetPlayersList(); float px = 0.5f * nameColWidth; float py = textView.y + textView.height + 10; for (int i = 0; i < players.Count; ++i) { PlayerResultView pv = new PlayerResultView(players[i]); pv.alignX = View.ALIGN_CENTER; pv.x = px; pv.y = py; tableView.AddView(pv); py += pv.height + 10; } contentView.AddView(tableView); // buttons View buttons = new View(0.5f * contentView.width, contentView.height, 0, 0); buttons.alignX = View.ALIGN_CENTER; buttons.alignY = View.ALIGN_MAX; Button button = new TempButton("EXIT"); button.id = (int)ButtonId.Exit; button.buttonDelegate = buttonDelegate; SetCancelButton(button); buttons.AddView(button); button = new TempButton("START!"); button.id = (int)ButtonId.Continue; ; button.buttonDelegate = buttonDelegate; FocusView(button); SetConfirmButton(button); buttons.AddView(button); buttons.LayoutHor(20); buttons.ResizeToFitViews(); contentView.AddView(buttons); AddView(contentView); }
public MultiplayerScreen(ButtonDelegate buttonDelegate) { this.buttonDelegate = buttonDelegate; Font font = Helper.fontButton; TextView headerText = new TextView(font, "LOCAL SERVERS"); headerText.alignX = View.ALIGN_CENTER; headerText.x = 0.5f * width; headerText.y = 31; AddView(headerText); contentView = new View(467, 333); contentView.alignX = View.ALIGN_CENTER; contentView.x = 0.5f * width; contentView.y = 73; contentView.visible = false; AddView(contentView); busyView = new View(467, 333); busyView.alignX = View.ALIGN_CENTER; busyView.x = 0.5f * width; busyView.y = 73; TextView busyText = new TextView(font, "Searching for local servers..."); busyText.alignX = busyText.alignY = View.ALIGN_CENTER; busyText.x = 0.5f * busyView.width; busyText.y = 0.5f * busyView.height; busyView.AddView(busyText); AddView(busyView); View buttonGroup = new View(); Button button = new TempButton("BACK"); button.buttonDelegate = buttonDelegate; button.id = (int)ButtonId.Back; buttonGroup.AddView(button); SetCancelButton(button); button = new TempButton("REFRESH"); button.buttonDelegate = buttonDelegate; button.id = (int)ButtonId.Refresh; buttonGroup.AddView(button); button = new TempButton("CREATE"); button.buttonDelegate = buttonDelegate; button.id = (int)ButtonId.Create; buttonGroup.AddView(button); buttonGroup.LayoutHor(10); buttonGroup.ResizeToFitViews(); buttonGroup.alignX = View.ALIGN_CENTER; buttonGroup.alignY = View.ALIGN_MAX; buttonGroup.x = 0.5f * width; buttonGroup.y = 432; AddView(buttonGroup); }
public void RemoveDebugView(View view) { m_debugView.RemoveView(view); m_debugView.LayoutVer(0); }
public void AddView(View view, float x, float y) { AddView(view); view.x = x; view.y = y; }
private void InitDebugView() { int appWidth = Application.GetWidth(); int appHeight = Application.GetHeight(); int realWidth = Application.GetRealWidth(); int realHeight = Application.GetRealHeight(); int width = realWidth - appWidth; int height = realHeight; m_debugView = new View(appWidth, 0, width, height); }
public void AddDebugView(View view) { m_debugView.AddView(view); m_debugView.LayoutVer(0); }
public void RemoveDebugView(View view) { Application.RootController().RemoveDebugView(view); m_debugViews.Remove(view); }
public void AddView(View child, float x, float y) { AddView(child); child.x = x; child.y = y; }
private View FindFocusView(View root, View current, FocusDirection direction) { int index = root.IndexOf(current); Debug.Assert(index != -1); if (direction == FocusDirection.Down || direction == FocusDirection.Right) { for (int i = index + 1; i < root.ChildCount(); ++i) { View child = root.ViewAt(i); View view = FindFocusView(child, direction); if (view != null) { return view; } } } else if (direction == FocusDirection.Up || direction == FocusDirection.Left) { for (int i = index - 1; i >= 0; --i) { View child = root.ViewAt(i); View view = FindFocusView(child, direction); if (view != null) { return view; } } } View parent = root.Parent(); if (parent != null) { return FindFocusView(parent, root, direction); } return null; }
private View FindFocusView(View root, FocusDirection direction) { if (direction == FocusDirection.Down || direction == FocusDirection.Right) { for (int i = 0; i < root.ChildCount(); ++i) { View child = root.ViewAt(i); View view = FindFocusView(child, direction); if (view != null) { return view; } if (child.CanFocus()) { return child; } } } else if (direction == FocusDirection.Up || direction == FocusDirection.Left) { for (int i = root.ChildCount() - 1; i >= 0; --i) { View child = root.ViewAt(i); View view = FindFocusView(child, direction); if (view != null) { return view; } if (child.CanFocus()) { return child; } } } return root.focusable ? root : null; }
protected bool FocusView(View view) { if (view != mFocusedView) { if (mFocusedView != null) { mFocusedView.blur(); } if (view != null) { view.focus(); } mFocusedView = view; return true; } return false; }
public void AddView(View child) { if (viewList.IsNull()) { viewList = new ViewList(); } if (child.parent != null) { parent.RemoveView(child); } viewList.Add(child); child.parent = this; }
public PlayersScreen(Scheme scheme, InputType[] inputTypes, InputTypeSelectDelegate selectDelegate, ButtonDelegate buttonDelegate) { View contentView = new View(64, 48, 521, 363); // scheme view contentView.AddView(new SchemeView(scheme, SchemeView.Style.Large)); // input type selector int maxPlayers = inputTypes.Length; View inputTypeContainer = new View(226, 0, 286, 0); Font font = Helper.fontButton; for (int i = 0; i < maxPlayers; ++i) { InputTypeView typeView = new InputTypeView(i, inputTypes[i], font, inputTypeContainer.width, font.FontHeight()); typeView.selectDelegate = selectDelegate; inputTypeContainer.AddView(typeView); } inputTypeContainer.LayoutVer(0); inputTypeContainer.ResizeToFitViewsHor(); contentView.AddView(inputTypeContainer); AddView(contentView); // buttons View buttons = new View(0.5f * width, contentView.y + contentView.height, 0, 0); buttons.alignX = View.ALIGN_CENTER; Button button = new TempButton("BACK"); button.id = (int)ButtonId.Back; button.buttonDelegate = buttonDelegate; SetCancelButton(button); buttons.AddView(button); button = new TempButton("START!"); button.id = (int)ButtonId.Start; button.buttonDelegate = buttonDelegate; FocusView(button); SetConfirmButton(button); buttons.AddView(button); buttons.LayoutHor(20); buttons.ResizeToFitViews(); AddView(buttons); }