Skip to content
Permalink
Browse files

Only use uppercase forms for system-defined colour codes. This allows…

… users to use their lowercase forms in /ccols.
  • Loading branch information...
UnknownShadow200 committed May 20, 2017
1 parent cc8003d commit e5bfd9482fa4825ff8c91f7dc0e24efbf3d6ab03
Showing with 31 additions and 35 deletions.
  1. +1 −1 ConfigGUI/ChatPreview.cs
  2. +6 −4 ConfigGUI/ColorPicker.cs
  3. +0 −4 fCraft/Commands/CpeCommands.cs
  4. +24 −26 fCraft/System/Utils/Color.cs
@@ -81,7 +81,7 @@ sealed class TextSegment {
if( plainTextSegments[j].Length == 0 ) continue;
if( plainTextSegments[j][0] == '&' ) {
colorCode = plainTextSegments[j][1];
// Conver system color codes into actual color codes
// Convert system color codes into actual color codes
string converted = Color.Parse( colorCode );
if( converted != null ) colorCode = converted[1];
} else {
@@ -54,10 +54,12 @@ internal struct ColorPair {
SuspendLayout();
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);

for( int i = 0; i < Color.ExtColors.Length; i++ ) {
if( Color.ExtColors[i].Undefined ) continue;
MakeButton(Color.ExtColors[i].Code);
}
MakeCancelButton();
MakeWindow( title );
@@ -98,7 +100,7 @@ internal struct ColorPair {
if ((rows & 1) == 0) {
x = (rows * btnWidth) / 2 - (100 / 2);
} else {
x = ((rows / 2) * btnWidth) + (btnWidth - 100) / 2;
x = ((rows / 2) * btnWidth) + (btnWidth - 100) / 2;
}

bCancel.Location = new System.Drawing.Point( 8 + x, 10 + btnHeight * btnsPerCol );
@@ -651,10 +651,6 @@ static class CpeCommands {
static void RemoveCustomColorsHandler(Player p, CommandReader cmd) {
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;
}
if (!p.Can(Permission.DefineCustomBlocks)) {
p.MessageNoAccess(Permission.DefineCustomBlocks);
return;
@@ -143,16 +143,16 @@ public static class Color
}

internal static char ConvertNonStandard(char code) {
switch (Char.ToLower(code)) {
case 's': return Sys[1];
case 'y': return Say[1];
case 'p': return PM[1];
case 'r': return Announcement[1];
case 'h': return Help[1];
case 'w': return Warning[1];
case 'm': return Me[1];
case 'i': return IRC[1];
case 't': return White[1];
switch (code) {
case 'S': return Sys[1];
case 'Y': return Say[1];
case 'P': return PM[1];
case 'R': return Announcement[1];
case 'H': return Help[1];
case 'W': return Warning[1];
case 'M': return Me[1];
case 'I': return IRC[1];
case 'T': return White[1];
default:
char fallback = GetFallback(code);
return fallback == '\0' ? '\0' : code;
@@ -199,12 +199,10 @@ public static class Color
[Pure]
public static bool IsColorCode(char code) {
return (code >= '0' && code <= '9') || (code >= 'a' && code <= 'f') ||
(code >= 'A' && code <= 'F') || code == 'H' || code == 'h' ||
code == 'I' || code == 'i' || code == 'M' || code == 'm' ||
code == 'N' || code == 'n' || code == 'P' || code == 'p' ||
code == 'R' || code == 'r' || code == 'S' || code == 's' ||
code == 'T' || code == 't' || code == 'W' || code == 'w' ||
code == 'Y' || code == 'y' || GetFallback(code) != '\0';
(code >= 'A' && code <= 'F') || code == 'H' || code == 'I' ||
code == 'M' || code == 'N' || code == 'P' || code == 'R' ||
code == 'S' || code == 'T' || code == 'W' || code == 'Y' ||
GetFallback(code) != '\0';
}


@@ -221,16 +219,16 @@ public static class Color
for (int i = sb.Length - 1; i > 0; i--) {
if (sb[i - 1] != '&') continue;

switch (Char.ToLower(sb[i])) {
case 's': sb[i] = Sys[1]; break;
case 'y': sb[i] = Say[1]; break;
case 'p': sb[i] = PM[1]; break;
case 'r': sb[i] = Announcement[1]; break;
case 'h': sb[i] = Help[1]; break;
case 'w': sb[i] = Warning[1]; break;
case 'm': sb[i] = Me[1]; break;
case 'i': sb[i] = IRC[1]; break;
case 't': sb[i] = White[1]; break;
switch (sb[i]) {
case 'S': sb[i] = Sys[1]; break;
case 'Y': sb[i] = Say[1]; break;
case 'P': sb[i] = PM[1]; break;
case 'R': sb[i] = Announcement[1]; break;
case 'H': sb[i] = Help[1]; break;
case 'W': sb[i] = Warning[1]; break;
case 'M': sb[i] = Me[1]; break;
case 'I': sb[i] = IRC[1]; break;
case 'T': sb[i] = White[1]; break;
}

char fallback = GetFallback(sb[i]);

0 comments on commit e5bfd94

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