-
Notifications
You must be signed in to change notification settings - Fork 200
/
MainView.cs
75 lines (62 loc) · 2.67 KB
/
MainView.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
using System;
using System.Drawing;
using ClassicalSharp;
using Launcher.Gui.Widgets;
namespace Launcher.Gui.Views {
public sealed class MainView : IView {
internal int loginIndex, resIndex, dcIndex, spIndex, statusIndex, usernameIndex;
internal int sslIndex, settingsIndex;
const int buttonWidth = 220, buttonHeight = 35, sideButtonWidth = 150;
public MainView(LauncherWindow game) : base(game) {
widgets = new Widget[11];
}
public override void Init() {
titleFont = new Font(game.FontName, 16, FontStyle.Bold);
textFont = new Font(game.FontName, 14, FontStyle.Regular);
inputHintFont = new Font(game.FontName, 12, FontStyle.Italic);
MakeWidgets();
}
string Get(int index) {
Widget widget = widgets[index];
return widget == null ? "" : widget.Text;
}
internal string updateText = "&eChecking..";
protected override void MakeWidgets() {
widgetIndex = 0;
usernameIndex = widgetIndex;
MakeInput(Get(0), 280, false, 16, "&gUsername..")
.SetLocation(Anchor.Centre, Anchor.Centre, 0, -120);
MakeInput(Get(1), 280, true, 64, "&gPassword..")
.SetLocation(Anchor.Centre, Anchor.Centre, 0, -75);
loginIndex = widgetIndex;
Makers.Button(this, "Sign in", 100, buttonHeight, titleFont)
.SetLocation(Anchor.Centre, Anchor.Centre, -90, -25);
statusIndex = widgetIndex;
Makers.Label(this, Get(statusIndex), textFont)
.SetLocation(Anchor.Centre, Anchor.Centre, 0, 20);
resIndex = widgetIndex;
Makers.Button(this, "Resume", 100, buttonHeight, titleFont)
.SetLocation(Anchor.Centre, Anchor.Centre, 90, -25);
dcIndex = widgetIndex;
Makers.Button(this, "Direct connect", 200, buttonHeight, titleFont)
.SetLocation(Anchor.Centre, Anchor.Centre, 0, 60);
spIndex = widgetIndex;
Makers.Button(this, "Singleplayer", 200, buttonHeight, titleFont)
.SetLocation(Anchor.Centre, Anchor.Centre, 0, 110);
sslIndex = widgetIndex;
bool sslVisible = widgets[sslIndex] != null && widgets[sslIndex].Visible;
Makers.Checkbox(this, true, 30)
.SetLocation(Anchor.Centre, Anchor.Centre, 160, -20);
Makers.Label(this, "Skip SSL check", textFont)
.SetLocation(Anchor.Centre, Anchor.Centre, 250, -20);
widgets[sslIndex].Visible = sslVisible;
widgets[sslIndex + 1].Visible = sslVisible;
Makers.Label(this, updateText, inputHintFont)
.SetLocation(Anchor.Max, Anchor.Max, -10, -45);
settingsIndex = widgetIndex;
Makers.Button(this, "Options", 100, buttonHeight, titleFont)
.SetLocation(Anchor.Max, Anchor.Max, -6, -6);
}
}
}