changed colours and added validation to more inputs
This commit is contained in:
parent
45a094a25f
commit
bd0a281a0b
1 changed files with 48 additions and 29 deletions
|
@ -20,7 +20,7 @@ namespace Pithos
|
|||
}
|
||||
public void display(string text, Color colour) {
|
||||
/* Message Color Codes:
|
||||
* Green: User Messages (Mainly Echo)
|
||||
* Light Green: User Messages (Mainly Echo)
|
||||
* Orange: Admin Commands
|
||||
* Black: General text / Date
|
||||
* Red: Error Messages
|
||||
|
@ -35,44 +35,63 @@ namespace Pithos
|
|||
output.SelectionLength = text.Length;
|
||||
output.SelectionColor = colour;
|
||||
output.SelectionStart = length + text.Length;
|
||||
output.SelectionColor = Color.Black;
|
||||
output.SelectionColor = Color.White;
|
||||
}
|
||||
private void mainWindow_Load(object sender, EventArgs e)
|
||||
{
|
||||
display("Currently Logged in as: " + Environment.UserDomainName + "\\" + Environment.UserName, Color.Blue);
|
||||
display("Currently Logged in as: " + Environment.UserDomainName + "\\" + Environment.UserName, Color.White);
|
||||
}
|
||||
|
||||
private void executeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool valid = true;
|
||||
private void executeButton_Click(object sender, EventArgs e) {
|
||||
bool valid = false;
|
||||
string input = inputBox.Text;
|
||||
if (input == "") { display("Error: No command given.", Color.Red); return; } //if its empty, dont bother decoding
|
||||
string initChar = input.Substring(0, 1); //gets the first character in the input
|
||||
string[] args = input.Substring(1).Split(' '); //splits the input by spaces, and removes init character
|
||||
switch (initChar)
|
||||
{
|
||||
case "/":
|
||||
if (args[0] == "exec") //runs a pithos program
|
||||
{
|
||||
pithosPrograms.decodeInput(input);
|
||||
return;
|
||||
}
|
||||
else if (args[0] == "start") //runs a program (using cmd)
|
||||
{
|
||||
|
||||
}
|
||||
else { valid = decoder.command(input); } //decode other commands
|
||||
break;
|
||||
case "¦": //admin commands
|
||||
privateFunctions.adminCommands(input);
|
||||
break;
|
||||
}
|
||||
|
||||
if (input.Substring(0, 4).ToLower() == "echo")
|
||||
{
|
||||
display(input.Substring(5), Color.Green);
|
||||
}
|
||||
inputBox.Text = ""; //clear the contents after execution
|
||||
try
|
||||
{
|
||||
switch (initChar)
|
||||
{
|
||||
case "/":
|
||||
if (args[0] == "exec") //runs a pithos program
|
||||
{
|
||||
valid = pithosPrograms.decodeInput(input);
|
||||
return;
|
||||
}
|
||||
else if (args[0] == "start") //runs a program (using cmd)
|
||||
{
|
||||
|
||||
}
|
||||
else { valid = decoder.command(input); } //decode other commands
|
||||
break;
|
||||
|
||||
case "¦": //admin commands
|
||||
if (!adminMode) {
|
||||
display("Access Denied: Admin commands are currently disabled.", Color.Orange);
|
||||
return;
|
||||
}
|
||||
valid = privateFunctions.adminCommands(input);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch {
|
||||
displayError(input);
|
||||
return;
|
||||
}
|
||||
if (!valid) { displayError(input); }
|
||||
}
|
||||
|
||||
private void displayError(string input)
|
||||
{
|
||||
display("Error: Command '" + input + "' is not recognised.", Color.Red);
|
||||
}
|
||||
|
||||
private void mainWindow_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue