public LoginView(LauncherWindow window) { Window = window; this.MinWidth = 250; ErrorLabel = new Label("Username or password incorrect") { TextColor = Color.FromBytes(255, 0, 0), TextAlignment = Alignment.Center, Visible = false }; UsernameText = new TextEntry(); PasswordText = new PasswordEntry(); LogInButton = new Button("Log In"); RegisterButton = new Button("Register"); RememberCheckBox = new CheckBox("Remember Me"); UsernameText.Text = UserSettings.Local.Username; if (UserSettings.Local.AutoLogin) { PasswordText.Password = UserSettings.Local.Password; RememberCheckBox.Active = true; } using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TrueCraft.Launcher.Content.truecraft-logo.png")) TrueCraftLogoImage = new ImageView(Image.FromStream(stream)); UsernameText.PlaceholderText = "Username"; PasswordText.PlaceholderText = "Password"; PasswordText.KeyReleased += (sender, e) => { if (e.Key == Key.Return || e.Key == Key.NumPadEnter) LogInButton_Clicked(sender, e); }; UsernameText.KeyReleased += (sender, e) => { if (e.Key == Key.Return || e.Key == Key.NumPadEnter) LogInButton_Clicked(sender, e); }; RegisterButton.Clicked += (sender, e) => { if (RegisterButton.Label == "Register") Window.WebView.Url = "http://truecraft.io/register"; else { Window.User.Username = UsernameText.Text; Window.User.SessionId = "-"; Window.MainContainer.Remove(this); Window.MainContainer.PackEnd(Window.MainMenuView = new MainMenuView(Window)); } }; LogInButton.Clicked += LogInButton_Clicked; this.PackStart(TrueCraftLogoImage); this.PackEnd(RegisterButton); this.PackEnd(LogInButton); this.PackEnd(RememberCheckBox); this.PackEnd(PasswordText); this.PackEnd(UsernameText); this.PackEnd(ErrorLabel); }
public ColoursScreen( LauncherWindow game ) : base(game, true) { enterIndex = 6; view = new ColoursView( game ); widgets = view.widgets; }
public ServersScreen( LauncherWindow game ) : base(game, true) { enterIndex = 3; view = new ServersView( game ); widgets = view.widgets; }
public LauncherTableWidget( LauncherWindow window ) : base(window) { OnClick = HandleOnClick; view = new LauncherTableView(); view.Init( window, this ); }
public LauncherBoolWidget( LauncherWindow window, Font font, int width, int height ) : base(window) { BoxWidth = width; BoxHeight = height; Width = width; Height = height; this.font = font; }
public MainScreen( LauncherWindow game ) : base(game, true) { enterIndex = 2; view = new MainView( game ); widgets = view.widgets; LoadResumeInfo(); }
public LauncherInputScreen( LauncherWindow game, bool makeFonts ) : base(game) { if( !makeFonts ) return; titleFont = new Font( game.FontName, 15, FontStyle.Bold ); inputFont = new Font( game.FontName, 14, FontStyle.Regular ); inputHintFont = new Font( game.FontName, 12, FontStyle.Italic ); }
public DirectConnectScreen( LauncherWindow game ) : base(game, true) { booleanFont = new Font( game.FontName, 22, FontStyle.Regular ); enterIndex = 3; view = new DirectConnectView( game ); widgets = view.widgets; }
public UpdatesScreen( LauncherWindow game ) : base(game) { game.Window.Mouse.Move += MouseMove; game.Window.Mouse.ButtonDown += MouseButtonDown; view = new UpdatesView( game ); widgets = view.widgets; }
public ChooseModeScreen( LauncherWindow game, bool firstTime ) : base(game) { game.Window.Mouse.Move += MouseMove; game.Window.Mouse.ButtonDown += MouseButtonDown; view = new ChooseModeView( game ); view.FirstTime = firstTime; widgets = view.widgets; }
public ResourcesScreen( LauncherWindow game ) : base(game) { game.Window.Mouse.Move += MouseMove; game.Window.Mouse.ButtonDown += MouseButtonDown; textFont = new Font( game.FontName, 16, FontStyle.Bold ); infoFont = new Font( game.FontName, 14, FontStyle.Regular ); view = new ResourcesView( game ); widgets = view.widgets; }
public static void MakeLabelAt( LauncherWindow game, LauncherWidget[] widgets, ref int widgetIndex, string text, Font font, Anchor horAnchor, Anchor verAnchor, int x, int y) { LauncherLabelWidget widget; if( widgets[widgetIndex] != null ) { widget = (LauncherLabelWidget)widgets[widgetIndex]; } else { widget = new LauncherLabelWidget( game, text ); widgets[widgetIndex] = widget; } widget.SetDrawData( game.Drawer, text, font, horAnchor, verAnchor, x, y ); widgetIndex++; }
public static void MakeBooleanAt( LauncherWindow game, LauncherWidget[] widgets, ref int widgetIndex, Anchor horAnchor, Anchor verAnchor, Font font, bool initValue, int width, int height, int x, int y, Action<int, int> onClick) { LauncherBoolWidget widget; if( widgets[widgetIndex] != null ) { widget = (LauncherBoolWidget)widgets[widgetIndex]; } else { widget = new LauncherBoolWidget( game, font, width, height ); widget.Value = initValue; widget.OnClick = onClick; widgets[widgetIndex] = widget; } widget.SetDrawData( game.Drawer, horAnchor, verAnchor, x, y ); widgetIndex++; }
public static void MakeButtonAt( LauncherWindow game, LauncherWidget[] widgets, ref int widgetIndex, string text, int width, int height, Font font, Anchor horAnchor, Anchor verAnchor, int x, int y, Action<int, int> onClick) { LauncherButtonWidget widget; if( widgets[widgetIndex] != null ) { widget = (LauncherButtonWidget)widgets[widgetIndex]; } else { widget = new LauncherButtonWidget( game ); widget.Text = text; widget.OnClick = onClick; widgets[widgetIndex] = widget; } widget.Active = false; widget.SetDrawData( game.Drawer, text, font, horAnchor, verAnchor, width, height, x, y ); widgetIndex++; }
public static void MakeInput( LauncherWindow game, LauncherWidget[] widgets, ref int widgetIndex, string text, int width, Anchor horAnchor, Anchor verAnchor, Font inputFont, Font inputHintFont, Action<int, int> onClick, bool password, int x, int y, int maxChars, string hint) { LauncherInputWidget widget; if( widgets[widgetIndex] != null ) { widget = (LauncherInputWidget)widgets[widgetIndex]; } else { widget = new LauncherInputWidget( game ); widget.OnClick = onClick; widget.Password = password; widget.MaxTextLength = maxChars; widget.HintText = hint; widgets[widgetIndex] = widget; } widget.SetDrawData( game.Drawer, text, inputFont, inputHintFont, horAnchor, verAnchor, width, 30, x, y ); widgetIndex++; }
public MainMenuView(LauncherWindow window) { Window = window; this.MinWidth = 250; WelcomeText = new Label("Welcome, " + Window.User.Username) { TextAlignment = Alignment.Center }; SingleplayerButton = new Button("Singleplayer"); MultiplayerButton = new Button("Multiplayer"); OptionsButton = new Button("Options"); QuitButton = new Button("Quit Game"); SingleplayerButton.Clicked += (sender, e) => { Window.InteractionBox.Remove(this); Window.InteractionBox.PackEnd(Window.SingleplayerView); }; MultiplayerButton.Clicked += (sender, e) => { Window.InteractionBox.Remove(this); Window.InteractionBox.PackEnd(Window.MultiplayerView); }; OptionsButton.Clicked += (sender, e) => { Window.InteractionBox.Remove(this); window.InteractionBox.PackEnd(Window.OptionView); }; QuitButton.Clicked += (sender, e) => Application.Exit(); this.PackStart(WelcomeText); this.PackStart(SingleplayerButton); this.PackStart(MultiplayerButton); this.PackStart(OptionsButton); this.PackEnd(QuitButton); }
public SingleplayerView(LauncherWindow window) { Worlds.Local = new Worlds(); Worlds.Local.Load(); Window = window; this.MinWidth = 250; SingleplayerLabel = new Label("Singleplayer") { Font = Font.WithSize(16), TextAlignment = Alignment.Center }; WorldListView = new ListView { MinHeight = 200, SelectionMode = SelectionMode.Single }; CreateWorldButton = new Button("New world"); DeleteWorldButton = new Button("Delete") { Sensitive = false }; PlayButton = new Button("Play") { Sensitive = false }; BackButton = new Button("Back"); CreateWorldBox = new VBox() { Visible = false }; NewWorldName = new TextEntry() { PlaceholderText = "Name" }; NewWorldSeed = new TextEntry() { PlaceholderText = "Seed (optional)" }; NewWorldCommit = new Button("Create") { Sensitive = false }; NewWorldCancel = new Button("Cancel"); NameField = new DataField<string>(); WorldListStore = new ListStore(NameField); WorldListView.DataSource = WorldListStore; WorldListView.HeadersVisible = false; WorldListView.Columns.Add(new ListViewColumn("Name", new TextCellView { TextField = NameField, Editable = false })); ProgressLabel = new Label("Loading world...") { Visible = false }; ProgressBar = new ProgressBar() { Visible = false, Indeterminate = true, Fraction = 0 }; BackButton.Clicked += (sender, e) => { Window.MainContainer.Remove(this); Window.MainContainer.PackEnd(Window.MainMenuView); }; CreateWorldButton.Clicked += (sender, e) => { CreateWorldBox.Visible = true; }; NewWorldCancel.Clicked += (sender, e) => { CreateWorldBox.Visible = false; }; NewWorldName.Changed += (sender, e) => { NewWorldCommit.Sensitive = !string.IsNullOrEmpty(NewWorldName.Text); }; NewWorldCommit.Clicked += NewWorldCommit_Clicked; WorldListView.SelectionChanged += (sender, e) => { PlayButton.Sensitive = DeleteWorldButton.Sensitive = WorldListView.SelectedRow != -1; }; PlayButton.Clicked += PlayButton_Clicked; DeleteWorldButton.Clicked += (sender, e) => { var world = Worlds.Local.Saves[WorldListView.SelectedRow]; WorldListStore.RemoveRow(WorldListView.SelectedRow); Worlds.Local.Saves = Worlds.Local.Saves.Where(s => s != world).ToArray(); Directory.Delete(world.BaseDirectory, true); }; foreach (var world in Worlds.Local.Saves) { var row = WorldListStore.AddRow(); WorldListStore.SetValue(row, NameField, world.Name); } var createDeleteHbox = new HBox(); CreateWorldButton.WidthRequest = DeleteWorldButton.WidthRequest = 0.5; createDeleteHbox.PackStart(CreateWorldButton, true); createDeleteHbox.PackStart(DeleteWorldButton, true); CreateWorldBox.PackStart(NewWorldName); CreateWorldBox.PackStart(NewWorldSeed); var newWorldHbox = new HBox(); NewWorldCommit.WidthRequest = NewWorldCancel.WidthRequest = 0.5; newWorldHbox.PackStart(NewWorldCommit, true); newWorldHbox.PackStart(NewWorldCancel, true); CreateWorldBox.PackStart(newWorldHbox); this.PackStart(SingleplayerLabel); this.PackStart(WorldListView); this.PackStart(createDeleteHbox); this.PackStart(PlayButton); this.PackStart(CreateWorldBox); this.PackStart(ProgressLabel); this.PackStart(ProgressBar); this.PackEnd(BackButton); }
public ResourcesView( LauncherWindow game ) : base(game) { widgets = new LauncherWidget[4]; }
public UpdatesView( LauncherWindow game ) : base(game) { widgets = new LauncherWidget[13]; }
public OptionView(LauncherWindow window) { _texturePacks = new List<TexturePack>(); _lastTexturePack = null; Window = window; this.MinWidth = 250; OptionLabel = new Label("Options") { Font = Font.WithSize(16), TextAlignment = Alignment.Center }; ResolutionLabel = new Label("Select a resolution..."); ResolutionComboBox = new ComboBox(); int resolutionIndex = -1; for (int i = 0; i < WindowResolution.Defaults.Length; i++) { ResolutionComboBox.Items.Add(WindowResolution.Defaults[i].ToString()); if (resolutionIndex == -1) { resolutionIndex = ((WindowResolution.Defaults[i].Width == UserSettings.Local.WindowResolution.Width) && (WindowResolution.Defaults[i].Height == UserSettings.Local.WindowResolution.Height)) ? i : -1; } } if (resolutionIndex == -1) { ResolutionComboBox.Items.Add(UserSettings.Local.WindowResolution.ToString()); resolutionIndex = ResolutionComboBox.Items.Count - 1; } ResolutionComboBox.SelectedIndex = resolutionIndex; FullscreenCheckBox = new CheckBox() { Label = "Fullscreen mode", State = (UserSettings.Local.IsFullscreen) ? CheckBoxState.On : CheckBoxState.Off }; TexturePackLabel = new Label("Select a texture pack..."); TexturePackImageField = new DataField<Image>(); TexturePackTextField = new DataField<string>(); TexturePackStore = new ListStore(TexturePackImageField, TexturePackTextField); TexturePackListView = new ListView { MinHeight = 200, SelectionMode = SelectionMode.Single, DataSource = TexturePackStore, HeadersVisible = false }; OpenFolderButton = new Button("Open texture pack folder"); BackButton = new Button("Back"); TexturePackListView.Columns.Add("Image", TexturePackImageField); TexturePackListView.Columns.Add("Text", TexturePackTextField); ResolutionComboBox.SelectionChanged += (sender, e) => { UserSettings.Local.WindowResolution = WindowResolution.FromString(ResolutionComboBox.SelectedText); UserSettings.Local.Save(); }; FullscreenCheckBox.Clicked += (sender, e) => { UserSettings.Local.IsFullscreen = !UserSettings.Local.IsFullscreen; UserSettings.Local.Save(); }; TexturePackListView.SelectionChanged += (sender, e) => { var texturePack = _texturePacks[TexturePackListView.SelectedRow]; if (_lastTexturePack != texturePack) { UserSettings.Local.SelectedTexturePack = texturePack.Name; UserSettings.Local.Save(); } }; OpenFolderButton.Clicked += (sender, e) => { var dir = new DirectoryInfo(TexturePack.TexturePackPath); Process.Start(dir.FullName); }; BackButton.Clicked += (sender, e) => { Window.MainContainer.Remove(this); Window.MainContainer.PackEnd(Window.MainMenuView); }; OfficialAssetsButton = new Button("Download Minecraft assets") { Visible = false }; OfficialAssetsButton.Clicked += OfficialAssetsButton_Clicked; OfficialAssetsProgress = new ProgressBar() { Visible = false, Indeterminate = true }; LoadTexturePacks(); this.PackStart(OptionLabel); this.PackStart(ResolutionLabel); this.PackStart(ResolutionComboBox); this.PackStart(FullscreenCheckBox); this.PackStart(TexturePackLabel); this.PackStart(TexturePackListView); this.PackStart(OfficialAssetsProgress); this.PackStart(OfficialAssetsButton); this.PackStart(OpenFolderButton); this.PackEnd(BackButton); }
public UpdatesScreen(LauncherWindow game) : base(game) { view = new UpdatesView(game); widgets = view.widgets; }
public ColoursView( LauncherWindow game ) : base(game) { widgets = new LauncherWidget[25]; }
public DirectConnectView( LauncherWindow game ) : base(game) { widgets = new LauncherWidget[8]; }
public ServersView( LauncherWindow game ) : base(game) { widgets = new LauncherWidget[7]; }
public LauncherButtonWidget( LauncherWindow window ) : base(window) { }
public LauncherInputWidget( LauncherWindow window ) : base(window) { }
public LauncherWidget( LauncherWindow window ) { Window = window; }
public MainView( LauncherWindow game ) : base(game) { widgets = new LauncherWidget[16]; }
public LauncherLabelWidget( LauncherWindow window, string text ) : base(window) { Text = text; }
public MultiplayerView(LauncherWindow window) { Window = window; this.MinWidth = 250; MultiplayerLabel = new Label("Multiplayer") { Font = Font.WithSize(16), TextAlignment = Alignment.Center }; ServerIPEntry = new TextEntry() { PlaceholderText = "Server IP", Text = UserSettings.Local.LastIP }; ConnectButton = new Button("Connect"); BackButton = new Button("Back"); ServerListView = new ListView() { MinHeight = 200, SelectionMode = SelectionMode.Single }; AddServerButton = new Button("Add server"); RemoveServerButton = new Button("Remove") { Sensitive = false }; ServerCreationBox = new VBox() { Visible = false }; NewServerLabel = new Label("Add new server:") { TextAlignment = Alignment.Center }; NewServerName = new TextEntry() { PlaceholderText = "Name" }; NewServerAddress = new TextEntry() { PlaceholderText = "Address" }; CommitAddNewServer = new Button("Add server"); CancelAddNewServer = new Button("Cancel"); var iconField = new DataField<Image>(); var nameField = new DataField<string>(); var playersField = new DataField<string>(); ServerListStore = new ListStore(iconField, nameField, playersField); ServerListView.DataSource = ServerListStore; ServerListView.HeadersVisible = false; ServerListView.Columns.Add(new ListViewColumn("Icon", new ImageCellView { ImageField = iconField })); ServerListView.Columns.Add(new ListViewColumn("Name", new TextCellView { TextField = nameField })); ServerListView.Columns.Add(new ListViewColumn("Players", new TextCellView { TextField = playersField })); ServerIPEntry.KeyReleased += (sender, e) => { if (e.Key == Key.Return || e.Key == Key.NumPadEnter) ConnectButton_Clicked(sender, e); }; BackButton.Clicked += (sender, e) => { Window.InteractionBox.Remove(this); Window.InteractionBox.PackEnd(Window.MainMenuView); }; ConnectButton.Clicked += ConnectButton_Clicked; ServerListView.SelectionChanged += (sender, e) => { RemoveServerButton.Sensitive = ServerListView.SelectedRow != -1; ServerIPEntry.Sensitive = ServerListView.SelectedRow == -1; }; AddServerButton.Clicked += (sender, e) => { AddServerButton.Sensitive = false; RemoveServerButton.Sensitive = false; ConnectButton.Sensitive = false; ServerListView.Sensitive = false; ServerIPEntry.Sensitive = false; ServerCreationBox.Visible = true; }; CancelAddNewServer.Clicked += (sender, e) => { AddServerButton.Sensitive = true; RemoveServerButton.Sensitive = true; ConnectButton.Sensitive = true; ServerListView.Sensitive = true; ServerIPEntry.Sensitive = true; ServerCreationBox.Visible = false; }; RemoveServerButton.Clicked += (sender, e) => { var server = UserSettings.Local.FavoriteServers[ServerListView.SelectedRow]; ServerListStore.RemoveRow(ServerListView.SelectedRow); UserSettings.Local.FavoriteServers = UserSettings.Local.FavoriteServers.Where( s => s.Name != server.Name && s.Address != server.Address).ToArray(); UserSettings.Local.Save(); }; CommitAddNewServer.Clicked += (sender, e) => { var server = new FavoriteServer { Name = NewServerName.Text, Address = NewServerAddress.Text }; var row = ServerListStore.AddRow(); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TrueCraft.Launcher.Content.default-server-icon.png")) ServerListStore.SetValue(row, iconField, Image.FromStream(stream)); ServerListStore.SetValue(row, nameField, server.Name); ServerListStore.SetValue(row, playersField, "TODO/50"); UserSettings.Local.FavoriteServers = UserSettings.Local.FavoriteServers.Concat(new[] { server }).ToArray(); UserSettings.Local.Save(); AddServerButton.Sensitive = true; RemoveServerButton.Sensitive = true; ConnectButton.Sensitive = true; ServerListView.Sensitive = true; ServerIPEntry.Sensitive = true; ServerCreationBox.Visible = false; }; foreach (var server in UserSettings.Local.FavoriteServers) { var row = ServerListStore.AddRow(); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TrueCraft.Launcher.Content.default-server-icon.png")) ServerListStore.SetValue(row, iconField, Image.FromStream(stream)); ServerListStore.SetValue(row, nameField, server.Name); ServerListStore.SetValue(row, playersField, "TODO/50"); } var addServerHBox = new HBox(); AddServerButton.WidthRequest = RemoveServerButton.WidthRequest = 0.5; addServerHBox.PackStart(AddServerButton, true); addServerHBox.PackStart(RemoveServerButton, true); var commitHBox = new HBox(); CancelAddNewServer.WidthRequest = CommitAddNewServer.WidthRequest = 0.5; commitHBox.PackStart(CommitAddNewServer, true); commitHBox.PackStart(CancelAddNewServer, true); ServerCreationBox.PackStart(NewServerLabel); ServerCreationBox.PackStart(NewServerName); ServerCreationBox.PackStart(NewServerAddress); ServerCreationBox.PackStart(commitHBox); this.PackEnd(BackButton); this.PackEnd(ConnectButton); this.PackStart(MultiplayerLabel); this.PackStart(ServerIPEntry); this.PackStart(ServerListView); this.PackStart(addServerHBox); this.PackStart(ServerCreationBox); }
public void Init(LauncherWindow game, TableWidget table) { this.game = game; this.table = table; }
public void Init( LauncherWindow window, LauncherTableWidget table ) { this.window = window; this.table = table; }