Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Application/OasisBot/OasisBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@
<Copy SourceFiles="@(DependencyFiles)" DestinationFolder="..\..\Build\Data\%(RecursiveDir)" />
</Target>
</Project>

34 changes: 22 additions & 12 deletions Application/OasisBot/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using CommandLine;
using CommandLine.Text;
using RSBot.Core;
using RSBot.Core.Components;
using RSBot.Core.Event;
using RSBot.Core.Objects;
using RSBot.Views;
using System;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using CommandLine;
using CommandLine.Text;
using RSBot.Core;
using RSBot.Core.Components;
using RSBot.Core.Components.Command;
using System.Runtime.InteropServices;
using RSBot.Core.Event;
using RSBot.Core.Objects;
using RSBot.Views;

namespace RSBot;

Expand Down Expand Up @@ -47,6 +47,7 @@ public class CommandLineOptions

[Option("launch-clientless", Required = false, HelpText = "Start clientless")]
public bool LaunchClientless { get; set; }

[Option("headless", Required = false, HelpText = "Start the bot without graphical user interface")]
public bool Headless { get; set; }
}
Expand Down Expand Up @@ -82,7 +83,9 @@ private static void Main(string[] args)
.WithNotParsed(errs =>
{
DisplayHelp(parserResult);
var isHelp = errs.Any(e => e.Tag == ErrorType.HelpRequestedError || e.Tag == ErrorType.VersionRequestedError);
var isHelp = errs.Any(e =>
e.Tag == ErrorType.HelpRequestedError || e.Tag == ErrorType.VersionRequestedError
);
Environment.Exit(isHelp ? 0 : 1);
});

Expand Down Expand Up @@ -113,9 +116,13 @@ private static void Main(string[] args)
Application.Run(mainForm);
}
}

private static void RunHeadless()
{
EventManager.SubscribeEvent("OnAddLog", (string message, LogLevel level) => Terminal.WriteLog($"[{level}] {message}"));
EventManager.SubscribeEvent(
"OnAddLog",
(string message, LogLevel level) => Terminal.WriteLog($"[{level}] {message}")
);
EventManager.SubscribeEvent("OnChangeStatusText", (string status) => Terminal.WriteLog($"[Status] {status}"));

BotCL.Initialize(ProfileManager.SelectedProfile);
Expand All @@ -124,10 +131,12 @@ private static void RunHeadless()
while (running)
{
var inputLine = Terminal.ReadLine();
if (string.IsNullOrWhiteSpace(inputLine)) continue;
if (string.IsNullOrWhiteSpace(inputLine))
continue;

var input = inputLine.Split(',');
if (input == null || input.Length == 0) continue;
if (input == null || input.Length == 0)
continue;

var command = input[0].ToLowerInvariant();
var args = input.Skip(1).ToArray();
Expand All @@ -141,6 +150,7 @@ private static void RunHeadless()
CLIManager.Execute(command, args);
}
}

private static void RunOptions(CommandLineOptions options)
{
if (options.LaunchClient)
Expand Down
48 changes: 16 additions & 32 deletions Application/OasisBot/Views/Controls/Cos/CosControlBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,53 +46,41 @@ private void InitializeComponent()
labelLevel = new Label();
panel1.SuspendLayout();
SuspendLayout();
//
//
// label1
//
//
label1.ApplyGradient = false;
label1.AutoSize = true;
label1.ForeColor = Color.FromArgb(0, 0, 0);
label1.Gradient = new Color[]
{
Color.Gray,
Color.Black
};
label1.Gradient = new Color[] { Color.Gray, Color.Black };
label1.GradientAnimation = false;
label1.Location = new Point(14, 44);
label1.Name = "label1";
label1.Size = new Size(31, 20);
label1.TabIndex = 20;
label1.Text = "HP:";
//
//
// lblPetName
//
//
lblPetName.ApplyGradient = false;
lblPetName.AutoSize = true;
lblPetName.Dock = System.Windows.Forms.DockStyle.Left;
lblPetName.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblPetName.ForeColor = Color.FromArgb(0, 0, 0);
lblPetName.Gradient = new Color[]
{
Color.Gray,
Color.Black
};
lblPetName.Gradient = new Color[] { Color.Gray, Color.Black };
lblPetName.GradientAnimation = false;
lblPetName.Location = new Point(0, 0);
lblPetName.Name = "lblPetName";
lblPetName.Size = new Size(103, 20);
lblPetName.TabIndex = 19;
lblPetName.Text = "No pet found";
//
//
// progressHP
//
//
progressHP.BackColor = Color.Transparent;
progressHP.DrawHatch = false;
progressHP.ForeColor = Color.Firebrick;
progressHP.Gradient = new Color[]
{
Color.Empty,
Color.Empty
};
progressHP.Gradient = new Color[] { Color.Empty, Color.Empty };
progressHP.HatchType = HatchStyle.Percent10;
progressHP.Location = new Point(48, 45);
progressHP.Maximum = 100L;
Expand All @@ -106,9 +94,9 @@ private void InitializeComponent()
progressHP.TabIndex = 18;
progressHP.Text = "0 / 100";
progressHP.Value = 0L;
//
//
// panel1
//
//
panel1.BackColor = Color.Transparent;
panel1.Border = new System.Windows.Forms.Padding(0, 0, 0, 0);
panel1.BorderColor = Color.Transparent;
Expand All @@ -120,27 +108,23 @@ private void InitializeComponent()
panel1.ShadowDepth = 4F;
panel1.Size = new Size(180, 21);
panel1.TabIndex = 21;
//
//
// labelLevel
//
//
labelLevel.ApplyGradient = false;
labelLevel.AutoSize = true;
labelLevel.Dock = System.Windows.Forms.DockStyle.Left;
labelLevel.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
labelLevel.ForeColor = Color.FromArgb(0, 0, 0);
labelLevel.Gradient = new Color[]
{
Color.Gray,
Color.Black
};
labelLevel.Gradient = new Color[] { Color.Gray, Color.Black };
labelLevel.GradientAnimation = false;
labelLevel.Location = new Point(103, 0);
labelLevel.Name = "labelLevel";
labelLevel.Size = new Size(0, 20);
labelLevel.TabIndex = 20;
//
//
// CosControlBase
//
//
Controls.Add(panel1);
Controls.Add(label1);
Controls.Add(progressHP);
Expand Down
30 changes: 19 additions & 11 deletions Application/OasisBot/Views/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ public Main()
// TODO
private void donateButton_Click(object sender, EventArgs e)
{
Process.Start(new ProcessStartInfo { FileName = "https://github.com/Silkroad-Developer-Community/OasisBot", UseShellExecute = true });
Process.Start(
new ProcessStartInfo
{
FileName = "https://github.com/Silkroad-Developer-Community/OasisBot",
UseShellExecute = true,
}
);
}

/// <summary>
Expand Down Expand Up @@ -188,7 +194,11 @@ private async Task SelectBotbase(string name)

var control = newBotbaseView.Value.View;
control.Name = newBotbaseView.Value.Name;
control.Text = LanguageManager.GetLangBySpecificKey(newBotbaseView.Value.Name, "TabText", newBotbaseView.Value.TabText);
control.Text = LanguageManager.GetLangBySpecificKey(
newBotbaseView.Value.Name,
"TabText",
newBotbaseView.Value.TabText
);
control.Enabled = Game.Ready;
windowPageControl.Controls.Add(control);

Expand Down Expand Up @@ -246,15 +256,15 @@ private void LoadExtensions()

var control = extension.Value.View;
control.Name = extension.Value.InternalName;

control.Text = LanguageManager.GetLangBySpecificKey(
extension.Value.InternalName,
"DisplayName",
extension.Value.DisplayName
);
control.Enabled = !extension.Value.RequireIngame;
control.Dock = DockStyle.Fill;

windowPageControl.Controls.Add(control);
if (control.Name == "RSBot.Python" && !GlobalConfig.Get("RSBot.ShowPythonPlugins", true))
windowPageControl.Controls.Remove(control);
Expand Down Expand Up @@ -540,11 +550,12 @@ private void InitializeCustomButtons()
TabStop = false,
Tag = "private",
Text = "START + SET AREA",
UseVisualStyleBackColor = false
UseVisualStyleBackColor = false,
};

var gap = btnStartStop.Left - (btnSave.Left + btnSave.Width);
if (gap <= 0) gap = 6;
if (gap <= 0)
gap = 6;

btnStartSetArea.Location = new Point(btnSave.Left - btnStartSetArea.Width - gap, btnSave.Top);

Expand Down Expand Up @@ -851,11 +862,12 @@ private void buttonConfig_Click(object sender, EventArgs e)

GlobalConfig.Set("RSBot.Network.BindIp", ipAddress.ToString());
}

private void pyPluginsToolStripMenuItem_Click(object sender, EventArgs e)
{
pyPluginsToolStripMenuItem.Checked = !pyPluginsToolStripMenuItem.Checked;
GlobalConfig.Set("RSBot.ShowPythonPlugins", pyPluginsToolStripMenuItem.Checked.ToString());
foreach( var plugin in Kernel.PluginManager.ExtensionsViews.Values)
foreach (var plugin in Kernel.PluginManager.ExtensionsViews.Values)
{
if (plugin.InternalName == "RSBot.Python")
{
Expand All @@ -871,7 +883,6 @@ private void pyPluginsToolStripMenuItem_Click(object sender, EventArgs e)
if (pluginIndex == currentIndex)
windowPageControl.SelectedIndex = 0;
}

}
}
}
Expand Down Expand Up @@ -1039,7 +1050,4 @@ private static void ApplyPlayerConfig()
}

#endregion Core events


}

4 changes: 4 additions & 0 deletions Botbases/RSBot.Alchemy/AlchemyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@ public void Start()

Log.AppendFormat(LogLevel.Debug, "[Alchemy] Starting automated alchemy...");
}

public void Stop()
{
if (Globals.Botbase != null)
Globals.Botbase.Stop();

Log.AppendFormat(LogLevel.Debug, "[Alchemy] Stopped automated alchemy");
}

public void Register()
{
Initialize();

Log.Debug("[Alchemy] Botbase registered to the kernel!");
}

public void Tick()
{
if (!Globals.View.IsRefreshing && !AlchemyManager.IsFusing)
Globals.Botbase.Tick();
}

public void Initialize()
{
AlchemyEventsSubscriber.Subscribe();
Expand Down
5 changes: 3 additions & 2 deletions Botbases/RSBot.Alchemy/AlchemyView.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using RSBot.Core;
using System.Windows.Forms;
using RSBot.Core;
using RSBot.Core.Components;
using RSBot.Core.Plugins;
using System.Windows.Forms;

namespace RSBot.Alchemy
{
Expand All @@ -11,6 +11,7 @@ public class AlchemyView : IBotbaseView
public string DisplayName => "Alchemy";
public string TabText => DisplayName;
public Control View => Globals.View;

public void Translate()
{
LanguageManager.Translate(View, Kernel.Language);
Expand Down
1 change: 0 additions & 1 deletion Botbases/RSBot.Alchemy/RSBot.Alchemy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
</ProjectReference>
</ItemGroup>
</Project>

6 changes: 4 additions & 2 deletions Botbases/RSBot.Alchemy/Views/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ private void ReloadItemList()
var newComboItem = new InventoryItemComboboxItem(item);

int firstSlot = 13;
if (Game.ClientType == GameClientType.Global
if (
Game.ClientType == GameClientType.Global
|| Game.ClientType == GameClientType.Korean
|| Game.ClientType == GameClientType.VTC_Game
|| Game.ClientType == GameClientType.RuSro
|| Game.ClientType == GameClientType.Turkey
|| Game.ClientType == GameClientType.Taiwan
|| Game.ClientType == GameClientType.Japanese)
|| Game.ClientType == GameClientType.Japanese
)
firstSlot = 17; //4 slots for relics

if (item.Slot >= firstSlot)
Expand Down
2 changes: 1 addition & 1 deletion Botbases/RSBot.Lure/LureBotbase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ public void Stop()
public void Register()
{
Log.Debug("[Lure] Botbase registered to the kernel!");
}
}
}
5 changes: 3 additions & 2 deletions Botbases/RSBot.Lure/LureView.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using RSBot.Core;
using System.Windows.Forms;
using RSBot.Core;
using RSBot.Core.Components;
using RSBot.Core.Plugins;
using System.Windows.Forms;

namespace RSBot.Lure
{
Expand All @@ -13,6 +13,7 @@ public class LureView : IBotbaseView

public string TabText => DisplayName;
public Control View => Views.View.Main;

public void Translate()
{
LanguageManager.Translate(View, Kernel.Language);
Expand Down
1 change: 0 additions & 1 deletion Botbases/RSBot.Lure/RSBot.Lure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
</ProjectReference>
</ItemGroup>
</Project>

1 change: 0 additions & 1 deletion Botbases/RSBot.Trade/RSBot.Trade.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
</ProjectReference>
</ItemGroup>
</Project>

Loading
Loading