Commit 714e157e authored by The Old Nut Man's avatar The Old Nut Man

Revert back to build 380+.

parent 479e9b43
using System;
using Tangine.GitHub;
namespace Tangine
{
[AttributeUsage(AttributeTargets.Class)]
public sealed class GitHubAttribute : Attribute
{
public GitRepository Repository { get; }
public GitHubAttribute(string ownerName, string repoName)
{
Repository = new GitRepository(ownerName, repoName);
}
}
}
\ No newline at end of file
using System.Threading.Tasks;
using Sulakore.Protocol;
using Sulakore.Communication;
namespace Tangine
{
internal class ContractorProxy : IHConnection
{
private readonly HNode _remoteContractor;
public string Host { get; set; }
public ushort Port { get; set; }
public string Address { get; set; }
public int TotalOutgoing { get; set; }
public int TotalIncoming { get; set; }
public ContractorProxy(HNode remoteContractor)
{
_remoteContractor = remoteContractor;
}
public Task<int> SendToClientAsync(byte[] data)
{
return _remoteContractor.SendAsync(4, data.Length, data);
}
public Task<int> SendToClientAsync(ushort header, params object[] values)
{
return SendToClientAsync(HMessage.Construct(header, values));
}
public Task<int> SendToServerAsync(byte[] data)
{
return _remoteContractor.SendAsync(5, data.Length, data);
}
public Task<int> SendToServerAsync(ushort header, params object[] values)
{
return SendToServerAsync(HMessage.Construct(header, values));
}
}
}
\ No newline at end of file
using System.ComponentModel;
using Tangine.Network.Protocol;
namespace Tangine.Controls
{
public class ScheduleTickEventArgs : CancelEventArgs
{
private readonly TanjiSchedulerView.HSchedule _schedule;
public int CurrentCycle { get; }
public int Cycles => _schedule.Cycles;
public double Interval
{
get { return _schedule.Interval; }
set { _schedule.Interval = value; }
}
public HPacket Packet
{
get { return _schedule.Packet; }
set { _schedule.Packet = value; }
}
public ScheduleTickEventArgs(TanjiSchedulerView.HSchedule schedule, int currentCycle)
{
_schedule = schedule;
CurrentCycle = currentCycle;
}
}
}
\ No newline at end of file
using System.Windows.Forms;
using Tangine.Habbo;
namespace Tangine.Controls
{
public class TileEventArgs : MouseEventArgs
{
public HPoint Tile { get; }
public TileEventArgs(HPoint tile, MouseButtons button, int clicks, int x, int y, int delta)
: base(button, clicks, x, y, delta)
{
Tile = tile;
}
}
}
\ No newline at end of file
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
namespace Tangine.Controls
{
[DesignerCategory("Code")]
public class TanjiButton : Control, IButtonControl
{
private bool _isPressed;
private const int GRAD_HEIGHT = 10;
/// <summary>
/// Gets or sets a value that is returned to the parent form when the button is clicked.
/// </summary>
[DefaultValue(DialogResult.None)]
public DialogResult DialogResult { get; set; }
[Browsable(false)]
public override Color BackColor
{
get { return base.BackColor; }
set { base.BackColor = value; }
}
[Browsable(false)]
public override Color ForeColor
{
get { return base.ForeColor; }
set { base.ForeColor = value; }
}
[Browsable(false)]
public override Image BackgroundImage
{
get { return base.BackgroundImage; }
set { base.BackgroundImage = value; }
}
[Browsable(false)]
public override ImageLayout BackgroundImageLayout
{
get { return base.BackgroundImageLayout; }
set { base.BackgroundImageLayout = value; }
}
[SettingsBindable(true)]
[Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
public override string Text
{
get { return base.Text; }
set { base.Text = value; Invalidate(); }
}
[Localizable(true)]
[DefaultValue(typeof(Size), "100, 20")]
new public Size Size
{
get { return base.Size; }
set { base.Size = value; }
}
private Color _skin = Color.SteelBlue;
[DefaultValue(typeof(Color), "SteelBlue")]
public Color Skin
{
get { return _skin; }
set { _skin = value; Invalidate(); }
}
public TanjiButton()
{
SetStyle((ControlStyles)2050, true);
DoubleBuffered = true;
Size = new Size(100, 20);
BackColor = Color.Transparent;
}
public void PerformClick()
{
if (Enabled)
{
Focus();
base.OnClick(EventArgs.Empty);
}
}
public void NotifyDefault(bool value)
{
Invalidate();
}
protected override void OnClick(EventArgs e)
{ }
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.Clear(Enabled ?
Skin : SystemColors.Control);
using (var pen = new Pen(Color.FromArgb(50, Color.Black)))
{
e.Graphics.DrawRectangle(pen, ClientRectangle.X, ClientRectangle.Y,
ClientRectangle.Width - 1, ClientRectangle.Height - 1);
}
using (var format = new StringFormat())
{
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
if (Enabled)
{
int textOffset = 0;
var clickShadow = Color.FromArgb(25, Color.Black);
var textShadow = Color.FromArgb(_isPressed ? 150 : 100, Color.Black);
if (_isPressed)
{
textOffset++;
var r1 = new Rectangle(0, 0, Width, GRAD_HEIGHT);
using (var clickShadowGradient = new LinearGradientBrush(r1, clickShadow, Color.Transparent, 90))
e.Graphics.FillRectangle(clickShadowGradient, r1);
var r2 = new Rectangle(0, Height - GRAD_HEIGHT, Width, GRAD_HEIGHT);
using (var clickShadowGradient = new LinearGradientBrush(r2, clickShadow, Color.Transparent, 270))
e.Graphics.FillRectangle(clickShadowGradient, r2);
}
using (var textShadowBrush = new SolidBrush(textShadow))
{
e.Graphics.DrawString(Text, Font, textShadowBrush,
new Rectangle(textOffset + 1, textOffset + 1, Width, Height), format);
}
e.Graphics.DrawString(Text, Font, Brushes.White,
new Rectangle(textOffset, textOffset, Width, Height), format);
}
else
{
using (var solidBrush = new SolidBrush(Color.FromArgb(150, Color.Black)))
{
e.Graphics.DrawString(Text, Font, solidBrush,
new Rectangle(0, 0, Width, Height), format);
}
}
}
base.OnPaint(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
bool isLeft = (e.Button == MouseButtons.Left);
if (isLeft)
{
_isPressed = false;
Focus();
Invalidate();
}
base.OnMouseUp(e);
if (isLeft &&
ClientRectangle.Contains(e.Location))
{
base.OnClick(e);
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
_isPressed = true;
Focus();
Invalidate();
}
base.OnMouseDown(e);
}
}
}
\ No newline at end of file
using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using Tangine.Network.Protocol;
namespace Tangine.Controls
{
[DesignerCategory("Code")]
public class TanjiConstructView : TanjiListView
{
private HPacket _cachedPacket;
private readonly List<object> _valuesWritten;
public IReadOnlyList<object> ValuesWritten { get; }
public TanjiConstructView()
{
_valuesWritten = new List<object>();
ValuesWritten = _valuesWritten.AsReadOnly();
}
public void WriteInteger(int value)
{
WriteInteger(value, 1);
}
public void WriteInteger(int value, int amount)
{
WriteValue("Integer", value,
HEncoding.BigEndian.GetBytes(value), amount);
}
public void WriteBoolean(bool value)
{
WriteBoolean(value, 1);
}
public void WriteBoolean(bool value, int amount)
{
WriteValue("Boolean", value,
HEncoding.BigEndian.GetBytes(value), amount);
}
public void WriteString(string value)
{
WriteString(value, 1);
}
public void WriteString(string value, int amount)
{
WriteValue("String", value,
HEncoding.BigEndian.GetBytes(value), amount);
}
protected virtual void MoveValue(int oldIndex, int newIndex)
{
lock (_valuesWritten)
{
object value = _valuesWritten[oldIndex];
_valuesWritten.RemoveAt(oldIndex);
_valuesWritten.Insert(newIndex, value);
_cachedPacket = null;
}
}
protected virtual void WriteValue(string type, object value, byte[] data, int amount)
{
lock (_valuesWritten)
{
BeginUpdate();
string encoded = null;// HPacket.ToString(data); // TODO
for (int i = 0; i < amount; i++)
{
_valuesWritten.Add(value);
ListViewItem item = null;
if (i != (amount - 1))
{
item = AddItem(type, value, encoded);
}
else item = AddFocusedItem(type, value, encoded);
}
EndUpdate();
_cachedPacket = null;
}
}
protected override void MoveItemUp(ListViewItem item)
{
int oldIndex = item.Index;
base.MoveItemUp(item);
MoveValue(oldIndex, item.Index);
}
protected override void MoveItemDown(ListViewItem item)
{
int oldIndex = item.Index;
base.MoveItemDown(item);
MoveValue(oldIndex, item.Index);
}
protected override void RemoveItem(ListViewItem item, bool selectNext)
{
lock (_valuesWritten)
{
_valuesWritten.RemoveAt(item.Index);
base.RemoveItem(item, selectNext);
_cachedPacket = null;
}
}
public void UpdateSelectedValue(object value)
{
if (HasSelectedItem)
UpdateValue(SelectedItem, value);
}
protected virtual void UpdateValue(ListViewItem item, object value)
{
lock (_valuesWritten)
{
byte[] data = null;
switch (item.SubItems[0].Text)
{
case "String": data = HEncoding.BigEndian.GetBytes((string)value); break;
case "Integer": data = HEncoding.BigEndian.GetBytes((int)value); break;
case "Boolean": data = HEncoding.BigEndian.GetBytes((bool)value); break;
}
string encoded = null; //HPacket.ToString(data); // TODO
item.SubItems[1].Text = value.ToString();
item.SubItems[2].Text = encoded;
_valuesWritten[item.Index] = value;
_cachedPacket = null;
}
}
public HPacket GetPacket(ushort header)
{
// TODO
return null;
//lock (_valuesWritten)
//{
// if (_cachedPacket == null)
// {
// _cachedPacket =
// new HMessage(header, _valuesWritten.ToArray());
// }
// _cachedPacket.Header = header;
// return _cachedPacket;
//}
}
public string GetStructure(ushort header)
{
lock (_valuesWritten)
{
string structure = $"{{l}}{{u:{header}}}";
foreach (object value in _valuesWritten)
{
char type = Type.GetTypeCode(
value.GetType()).ToString().ToLower()[0];
structure += $"{{{type}:{value}}}";
}
return structure;
}
}
}
}
\ No newline at end of file
using System;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using Tangine.Network.Protocol;
namespace Tangine.Controls
{
[DesignerCategory("Code")]
public class TanjiInjectionMenu : ContextMenuStrip
{
private TextBox _inputBox;
[Browsable(false)]
public TextBox InputBox
{
get { return _inputBox; }
set
{
if (value != null)
{
_inputBox = value;
_inputBox.ContextMenuStrip = this;
}
}
}
#region Menu Items
protected ToolStripMenuItem RealignBtn { get; }
protected ToolStripMenuItem InsertParametersBtn { get; }
protected ToolStripMenuItem StringBtn { get; }
protected ToolStripMenuItem IntegerBtn { get; }
protected ToolStripMenuItem ByteBooleanBtn { get; }
protected ToolStripSeparator TopSeparator { get; }
protected ToolStripMenuItem CutBtn { get; }
protected ToolStripMenuItem CopyBtn { get; }
protected ToolStripMenuItem PasteBtn { get; }
protected ToolStripSeparator BottomSeparator { get; }
protected ToolStripMenuItem UndoBtn { get; }
protected ToolStripMenuItem SelectAllBtn { get; }
#endregion
public TanjiInjectionMenu(IContainer container)
: base(container)
{
RealignBtn = CreateItem("Realign", Keys.R);
RealignBtn.Click += RealignBtn_Click;
InsertParametersBtn = CreateItem("Insert Parameter(s)");
TopSeparator = new ToolStripSeparator();
StringBtn = CreateItem("String", Keys.S);
StringBtn.Click += StringBtn_Click;
IntegerBtn = CreateItem("Integer", Keys.I);
IntegerBtn.Click += IntegerBtn_Click;
ByteBooleanBtn = CreateItem("Byte/Boolean", Keys.B);
ByteBooleanBtn.Click += ByteBooleanBtn_Click;
InsertParametersBtn.DropDownItems.Add(StringBtn);
InsertParametersBtn.DropDownItems.Add(IntegerBtn);
InsertParametersBtn.DropDownItems.Add(ByteBooleanBtn);
CutBtn = CreateItem("Cut", Keys.X);
CutBtn.Click += CutBtn_Click;
CopyBtn = CreateItem("Copy", Keys.C);
CopyBtn.Click += CopyBtn_Click;
PasteBtn = CreateItem("Paste", Keys.V);
PasteBtn.Click += PasteBtn_Click;
BottomSeparator = new ToolStripSeparator();
UndoBtn = CreateItem("Undo", Keys.Z);
UndoBtn.Click += UndoBtn_Click;
SelectAllBtn = CreateItem("Select All", Keys.A);
SelectAllBtn.Click += SelectAllBtn_Click;
Items.AddRange(new ToolStripItem[]
{
RealignBtn,
InsertParametersBtn,
TopSeparator,
CutBtn,
CopyBtn,
PasteBtn,
BottomSeparator,
UndoBtn,
SelectAllBtn
});
}
public void InsertString()
{
InsertParameter("s");
}
public void InsertInteger()
{
InsertParameter("i");
}
public void InsertByteBoolean()
{
InsertParameter("b");
}
protected void InsertParameter(string parameterName)
{
if (InputBox == null) return;
string selectedValue = InputBox.SelectedText;
object parameterValue = null;
byte[] parameterData = HPacket.ToBytes(HEncoding.BigEndian, selectedValue);
switch (parameterName)
{
case "i":
{
if (parameterData.Length == 4)
{
parameterValue = HEncoding.BigEndian.ReadInt32(parameterData, 0);
}
break;
}
case "s":
{
if (parameterData.Length >= 2 &&
(HEncoding.BigEndian.ReadUInt16(parameterData, 0) == (parameterData.Length - 2)))
{
parameterValue = Encoding.UTF8.GetString(
parameterData, 2, parameterData.Length - 2);
}
break;
}
case "b":
{
if (parameterData.Length == 1)
{
parameterValue = HEncoding.BigEndian.ReadBoolean(parameterData, 0);
}
break;