Skip to content

Commit

Permalink
Continuing to establish UI parity with WinForms verison
Browse files Browse the repository at this point in the history
  • Loading branch information
TauAkiou committed Oct 4, 2020
1 parent 525835c commit dd90625
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 33 deletions.
44 changes: 27 additions & 17 deletions AmongUsCapture/UserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ private Color Rainbow(float progress)
public UserForm(Builder builder, ClientSocket sock) : base("Among Us Capture - GTK")
{
//builder.Autoconnect(this);
var pixbuf = new Pixbuf(Assembly.GetExecutingAssembly().GetManifestResourceStream("amonguscapture_gtk.icon.ico"));
Icon = pixbuf;
Icon = new Pixbuf(Assembly.GetExecutingAssembly().GetManifestResourceStream("amonguscapture_gtk.icon.ico"));
clientSocket = sock;
InitializeWindow();
GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler;
Expand All @@ -62,11 +61,14 @@ public UserForm(Builder builder, ClientSocket sock) : base("Among Us Capture - G
GameMemReader.getInstance().JoinedLobby += OnJoinedLobby;

// Load URL
URLTextBox.Text = Settings.PersistentSettings.host;
_urlHostEntryField.Text = Settings.PersistentSettings.host;

// Connect on Enter
this.AcceptButton = ConnectButton;
//this.AcceptButton = ConnectButton;
this.Default = _connectCodeSubmitButton;



// Get the user's default GTK TextView foreground color.
var userwidgetpath = new WidgetPath();
var userstylecontext = new StyleContext();
Expand All @@ -80,7 +82,10 @@ public UserForm(Builder builder, ClientSocket sock) : base("Among Us Capture - G
private void _consoleTextView_OnPopulateContextMenu(object o, PopulatePopupArgs e)
{
Menu textViewContextMenu = (Menu)e.Args[0];
SeparatorMenuItem _contextMenuSeperator = new SeparatorMenuItem();
CheckMenuItem _autoscrollMenuItem = new CheckMenuItem();


_autoscrollMenuItem.Name = "_autoscrollMenuItem";
_autoscrollMenuItem.Label = "Auto Scroll";
_autoscrollMenuItem.TooltipText = "Enable or disable console autoscrolling";
Expand All @@ -89,13 +94,14 @@ private void _consoleTextView_OnPopulateContextMenu(object o, PopulatePopupArgs
_autoscrollMenuItem.Toggled += delegate(object sender, EventArgs args)
{
// it has to be written this way to get around a crash.
// don't know why, but i do what must be done, apparently.
// don't know why, but i do what must be done.
var button = sender as CheckMenuItem;
_autoscroll = button.Active;
};


textViewContextMenu.Append(_contextMenuSeperator);
textViewContextMenu.Append(_autoscrollMenuItem);
_autoscrollMenuItem.Show();
textViewContextMenu.ShowAll();

}

Expand Down Expand Up @@ -131,6 +137,7 @@ private void OnChatMessageAdded(object sender, ChatMessageEventArgs e)
//WriteLineToConsole($"[CHAT] {e.Sender}: {e.Message}");
}

/*
private void ConnectCodeBox_Enter(object sender, EventArgs e)
{
this.BeginInvoke((MethodInvoker)delegate ()
Expand All @@ -149,6 +156,7 @@ private void ConnectCodeBox_Click(object sender, EventArgs e)
}
}
*/

private void UserForm_PlayerChanged(object sender, PlayerChangedEventArgs e)
{
Expand Down Expand Up @@ -177,14 +185,14 @@ private void GameStateChangedHandler(object sender, GameStateChangedEventArgs e)
private void _connectCodeSubmitButton_Click(object sender, EventArgs e)
{

ConnectCodeBox.Enabled = false;
ConnectButton.Enabled = false;
URLTextBox.Enabled = false;
_connectCodeEntryField.Sensitive = false;
_connectCodeSubmitButton.Sensitive = false;
_urlHostEntryField.Sensitive = false;

var url = "http://localhost:8123";
if (URLTextBox.Text != "")
if (_urlHostEntryField.Text != "")
{
url = URLTextBox.Text;
url = _urlHostEntryField.Text;
}

doConnect(url);
Expand All @@ -196,7 +204,7 @@ private void doConnect(string url)
{
Settings.PersistentSettings.host = url;

clientSocket.SendConnectCode(ConnectCodeBox.Text, (sender, e) =>
clientSocket.SendConnectCode(_connectCodeEntryField.Text, (sender, e) =>
{
if (lastJoinedLobby != null) // Send the game code _after_ the connect code
{
Expand All @@ -211,18 +219,20 @@ private void doConnect(string url)
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK);
ConnectCodeBox.Enabled = true;
ConnectButton.Enabled = true;
URLTextBox.Enabled = true;
//MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK);
_connectCodeEntryField.Sensitive = true;
_connectCodeSubmitButton.Sensitive = true;
_urlHostEntryField.Sensitive = true;
return;
}
}

/*
private void ConnectCodeBox_TextChanged(object sender, EventArgs e)
{
ConnectButton.Enabled = (ConnectCodeBox.Enabled && ConnectCodeBox.Text.Length == 6 && !ConnectCodeBox.Text.Contains(" "));
}
*/

private void _consoleTextView_BufferChanged(object sender, EventArgs e)
{
Expand Down
63 changes: 47 additions & 16 deletions AmongUsCapture/Userform.Gtk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,36 @@ public partial class UserForm
private Box _gameCodeLayoutContainer;
private Entry _gameCodeEntryField;
private Button _gameCodeCopyButton;

// Websocket/Host Control
private Frame _hostControlFrame;
private VBox _hostControlLayoutContainer;


private Frame _urlHostEntryFrame;
private HBox _urlHostEntryLayoutContainer;
private Entry _urlHostEntryField;

// Connect Code
private Frame _connectCodeParentFrame;
private HBox _connectCodeLayoutContainer;
private Button _connectCodeSubmitButton;
private Entry _connectCodeEntryField;


// Right Side Text Console

private Frame _consoleParentFrame;
private VBox _consoleLayoutContainer;
private ScrolledWindow _consoleScrolledWindow;
private TextView _consoleTextView;
private Menu _consoleContextMenu;


private Box _currentStateContainer;
private Frame _currentStateFrame;
private Label _currentStateLabel;


private CheckMenuItem _autoScrollCheckMenuItem;
private MenuItem _autoScrollMenuItem;





Expand All @@ -68,31 +73,33 @@ public void InitializeWindow()
_gameCodeCopyButton = new Button();
_gameCodeEntryField = new Entry();

// Left Side Connect Code Fields
// Left Side Websocket/Host Control
_hostControlFrame = new Frame();
_hostControlLayoutContainer = new VBox();

_urlHostEntryFrame = new Frame();
_urlHostEntryLayoutContainer = new HBox();
_urlHostEntryField = new Entry();

_connectCodeParentFrame = new Frame();
_connectCodeLayoutContainer = new HBox();
_connectCodeSubmitButton = new Button();
_connectCodeEntryField = new Entry();




// Right Side Console
_consoleScrolledWindow = new ScrolledWindow();
_consoleLayoutContainer = new VBox();
_consoleParentFrame = new Frame();
_consoleTextView = new TextView();

_consoleTextView = new TextView();

_autoScrollCheckMenuItem = new CheckMenuItem();
_consoleContextMenu = new Menu();
_autoScrollMenuItem = new MenuItem();



// _primaryWindowPane definition (splitContainer1)
_primaryWindowPane.Name = "_primaryWindowPane";
_primaryWindowPane.SetSizeRequest(824, 476);
_primaryWindowPane.Position = 180;
_primaryWindowPane.TooltipText = "paneContainer1";

_primaryWindowPane.Pack1(_primaryWindowLeftContainer, true, false);
_primaryWindowPane.Pack2(_consoleParentFrame, true, false);
Expand All @@ -111,8 +118,8 @@ public void InitializeWindow()

_userSettingsParentContainer.Margin = 5;
_userSettingsParentContainer.PackStart(_currentStateFrame, true, false, 10);
_userSettingsParentContainer.PackStart(_hostControlFrame, true, false, 10);
_userSettingsParentContainer.PackStart(_gameCodeParentFrame, true, false, 5);
_userSettingsParentContainer.PackStart(_connectCodeParentFrame, true, false, 5);
_userSettingsParentContainer.Name = "_userSettingsParentContainer";

// CurrentStateFrame
Expand Down Expand Up @@ -159,6 +166,27 @@ public void InitializeWindow()

// CONNECT CODE UI BLOCK

// HOST CONTROL UI BLOCK

_hostControlFrame.Name = "_hostControlFrame";
_hostControlFrame.Label = "Server Connection";
_hostControlFrame.Add(_hostControlLayoutContainer);

_hostControlLayoutContainer.Name = "_hostControlLayoutContainer";
_hostControlLayoutContainer.Margin = 5;
_hostControlLayoutContainer.SetSizeRequest(25, 20);
_hostControlLayoutContainer.PackStart(_urlHostEntryFrame, true, false, 5);
_hostControlLayoutContainer.PackStart(_connectCodeParentFrame, true, false, 5);

_urlHostEntryFrame.Name = "_urlHostEntryFrame";
_urlHostEntryFrame.Label = "Server URL";
_urlHostEntryFrame.Add(_urlHostEntryLayoutContainer);

_urlHostEntryLayoutContainer.Name = "_urlHostEntryLayoutContainer";
_urlHostEntryLayoutContainer.SetSizeRequest(25, 20);
_urlHostEntryLayoutContainer.PackStart(_urlHostEntryField, true, false, 5);
_urlHostEntryLayoutContainer.MarginBottom = 5;

_connectCodeParentFrame.Name = "_connectCodeParentFrame";
_connectCodeParentFrame.Label = "Connect Code";
_connectCodeParentFrame.Add(_connectCodeLayoutContainer);
Expand All @@ -167,7 +195,7 @@ public void InitializeWindow()
_connectCodeLayoutContainer.SetSizeRequest(25, 20);
_connectCodeLayoutContainer.PackStart(_connectCodeEntryField, true, false, 5);
_connectCodeLayoutContainer.PackStart(_connectCodeSubmitButton, true, false, 5);
_connectCodeLayoutContainer.MarginBottom = 7;
_connectCodeLayoutContainer.MarginBottom = 5;

_connectCodeEntryField.Name = "_connectCodeEntryField";
_connectCodeEntryField.Xalign = (float)0.5;
Expand All @@ -178,6 +206,9 @@ public void InitializeWindow()
_connectCodeSubmitButton.Label = "Submit";
_connectCodeSubmitButton.SetSizeRequest(30, 20);
_connectCodeSubmitButton.Clicked += _connectCodeSubmitButton_Click;
_connectCodeSubmitButton.CanDefault = true;



// Right Side
_consoleParentFrame.Name = "_consoleParentFrame";
Expand Down

0 comments on commit dd90625

Please sign in to comment.