Skip to content
Permalink
Browse files

Allow setting colors in configgui to custom colors, fix /ccols remove

  • Loading branch information...
UnknownShadow200 committed May 20, 2017
1 parent ae4bc56 commit c5ec83a841b0b3c311373dbb9b0a2245323d56f6
Showing with 15 additions and 10 deletions.
  1. +11 −7 ConfigGUI/ColorPicker.cs
  2. +4 −3 fCraft/Commands/CpeCommands.cs
@@ -52,29 +52,33 @@ internal struct ColorPair {
StartPosition = FormStartPosition.CenterParent;

SuspendLayout();
for (char code = '0'; code <= '9'; code++)
for( char code = '0'; code <= '9'; code++ )
MakeButton(code);
for (char code = 'a'; code <= 'f'; code++)
for ( char code = 'a'; code <= 'f'; code++ )
MakeButton(code);
for (int i = 0; i < Color.ExtColors.Length; i++) {
if (!Color.ExtColors[i].Undefined) MakeButton(Color.ExtColors[i].Code);
}
MakeCancelButton();
MakeWindow( title );
ResumeLayout( false );
}


const int btnWidth = 130, btnHeight = 40;
int index = 0;
void MakeButton( char colCode ) {
int hex = Color.Hex( colCode );
int row = hex / 8, col = hex % 8;
int row = index / 8, col = index % 8;
index++;

Button btn = new Button();
SysCol textCol;
btn.BackColor = LookupColor( colCode, out textCol );
btn.ForeColor = textCol;
btn.Location = new System.Drawing.Point( 9 + row * btnWidth, 7 + col * btnHeight );
btn.Size = new System.Drawing.Size( btnWidth, btnHeight );
btn.Name = "b" + hex;
btn.TabIndex = hex;
btn.Name = "b" + index;
btn.TabIndex = index;
btn.Text = ColorName(colCode) + " - " + colCode;
btn.Click += delegate { ColorCode = colCode; DialogResult = DialogResult.OK; Close(); };
btn.Margin = new Padding( 0 );
@@ -90,7 +94,7 @@ internal struct ColorPair {
bCancel.Location = new System.Drawing.Point( 88, 330 );
bCancel.Name = "bCancel";
bCancel.Size = new System.Drawing.Size( 100, 25 );
bCancel.TabIndex = 16;
bCancel.TabIndex = 260;
bCancel.Text = "Cancel";
bCancel.UseVisualStyleBackColor = true;
Controls.Add( bCancel );
@@ -649,8 +649,9 @@ static class CpeCommands {
}

static void RemoveCustomColorsHandler(Player p, CommandReader cmd) {
if (cmd.CountRemaining < 2) { p.Message("Usage: &H/ccols remove [code]"); return; }
if (cmd.RawMessage.Split()[2].Contains("\"")) {
string fullCode = cmd.Next();
if (fullCode == null) { p.Message("Usage: &H/ccols remove [code]"); return; }
if (fullCode.Contains("\"")) {
p.Message("Color code cannot be \"");
return;
}
@@ -659,7 +660,7 @@ static class CpeCommands {
return;
}

char code = cmd.Next()[0];
char code = fullCode[0];
if (Color.IsStandardColorCode(code)) {
p.Message(code + " is a standard color, and thus cannot be removed."); return;
}

0 comments on commit c5ec83a

Please sign in to comment.
You can’t perform that action at this time.