Skip to content

Commit c5ec83a

Browse files
Allow setting colors in configgui to custom colors, fix /ccols remove
1 parent ae4bc56 commit c5ec83a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

ConfigGUI/ColorPicker.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,33 @@ public ColorPicker( string title, char oldColorCode ) {
5252
StartPosition = FormStartPosition.CenterParent;
5353

5454
SuspendLayout();
55-
for (char code = '0'; code <= '9'; code++)
55+
for( char code = '0'; code <= '9'; code++ )
5656
MakeButton(code);
57-
for (char code = 'a'; code <= 'f'; code++)
57+
for ( char code = 'a'; code <= 'f'; code++ )
5858
MakeButton(code);
59+
for (int i = 0; i < Color.ExtColors.Length; i++) {
60+
if (!Color.ExtColors[i].Undefined) MakeButton(Color.ExtColors[i].Code);
61+
}
5962
MakeCancelButton();
6063
MakeWindow( title );
6164
ResumeLayout( false );
6265
}
6366

6467

6568
const int btnWidth = 130, btnHeight = 40;
69+
int index = 0;
6670
void MakeButton( char colCode ) {
67-
int hex = Color.Hex( colCode );
68-
int row = hex / 8, col = hex % 8;
71+
int row = index / 8, col = index % 8;
72+
index++;
6973

7074
Button btn = new Button();
7175
SysCol textCol;
7276
btn.BackColor = LookupColor( colCode, out textCol );
7377
btn.ForeColor = textCol;
7478
btn.Location = new System.Drawing.Point( 9 + row * btnWidth, 7 + col * btnHeight );
7579
btn.Size = new System.Drawing.Size( btnWidth, btnHeight );
76-
btn.Name = "b" + hex;
77-
btn.TabIndex = hex;
80+
btn.Name = "b" + index;
81+
btn.TabIndex = index;
7882
btn.Text = ColorName(colCode) + " - " + colCode;
7983
btn.Click += delegate { ColorCode = colCode; DialogResult = DialogResult.OK; Close(); };
8084
btn.Margin = new Padding( 0 );
@@ -90,7 +94,7 @@ void MakeCancelButton() {
9094
bCancel.Location = new System.Drawing.Point( 88, 330 );
9195
bCancel.Name = "bCancel";
9296
bCancel.Size = new System.Drawing.Size( 100, 25 );
93-
bCancel.TabIndex = 16;
97+
bCancel.TabIndex = 260;
9498
bCancel.Text = "Cancel";
9599
bCancel.UseVisualStyleBackColor = true;
96100
Controls.Add( bCancel );

fCraft/Commands/CpeCommands.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,9 @@ static void AddCustomColorsHandler(Player p, CommandReader cmd) {
649649
}
650650

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

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

0 commit comments

Comments
 (0)