Skip to content

Commit e5bfd94

Browse files
Only use uppercase forms for system-defined colour codes. This allows users to use their lowercase forms in /ccols.
1 parent cc8003d commit e5bfd94

4 files changed

Lines changed: 31 additions & 35 deletions

File tree

ConfigGUI/ChatPreview.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void SetText( string[] lines ) {
8181
if( plainTextSegments[j].Length == 0 ) continue;
8282
if( plainTextSegments[j][0] == '&' ) {
8383
colorCode = plainTextSegments[j][1];
84-
// Conver system color codes into actual color codes
84+
// Convert system color codes into actual color codes
8585
string converted = Color.Parse( colorCode );
8686
if( converted != null ) colorCode = converted[1];
8787
} else {

ConfigGUI/ColorPicker.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ public ColorPicker( string title, char oldColorCode ) {
5454
SuspendLayout();
5555
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);
59+
60+
for( int i = 0; i < Color.ExtColors.Length; i++ ) {
61+
if( Color.ExtColors[i].Undefined ) continue;
62+
MakeButton(Color.ExtColors[i].Code);
6163
}
6264
MakeCancelButton();
6365
MakeWindow( title );
@@ -98,7 +100,7 @@ void MakeCancelButton() {
98100
if ((rows & 1) == 0) {
99101
x = (rows * btnWidth) / 2 - (100 / 2);
100102
} else {
101-
x = ((rows / 2) * btnWidth) + (btnWidth - 100) / 2;
103+
x = ((rows / 2) * btnWidth) + (btnWidth - 100) / 2;
102104
}
103105

104106
bCancel.Location = new System.Drawing.Point( 8 + x, 10 + btnHeight * btnsPerCol );

fCraft/Commands/CpeCommands.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,6 @@ static void AddCustomColorsHandler(Player p, CommandReader cmd) {
651651
static void RemoveCustomColorsHandler(Player p, CommandReader cmd) {
652652
string fullCode = cmd.Next();
653653
if (fullCode == null) { p.Message("Usage: &H/ccols remove [code]"); return; }
654-
if (fullCode.Contains("\"")) {
655-
p.Message("Color code cannot be \"");
656-
return;
657-
}
658654
if (!p.Can(Permission.DefineCustomBlocks)) {
659655
p.MessageNoAccess(Permission.DefineCustomBlocks);
660656
return;

fCraft/System/Utils/Color.cs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ public static string Parse(char code) {
143143
}
144144

145145
internal static char ConvertNonStandard(char code) {
146-
switch (Char.ToLower(code)) {
147-
case 's': return Sys[1];
148-
case 'y': return Say[1];
149-
case 'p': return PM[1];
150-
case 'r': return Announcement[1];
151-
case 'h': return Help[1];
152-
case 'w': return Warning[1];
153-
case 'm': return Me[1];
154-
case 'i': return IRC[1];
155-
case 't': return White[1];
146+
switch (code) {
147+
case 'S': return Sys[1];
148+
case 'Y': return Say[1];
149+
case 'P': return PM[1];
150+
case 'R': return Announcement[1];
151+
case 'H': return Help[1];
152+
case 'W': return Warning[1];
153+
case 'M': return Me[1];
154+
case 'I': return IRC[1];
155+
case 'T': return White[1];
156156
default:
157157
char fallback = GetFallback(code);
158158
return fallback == '\0' ? '\0' : code;
@@ -199,12 +199,10 @@ public static bool IsStandardColorCode(char code) {
199199
[Pure]
200200
public static bool IsColorCode(char code) {
201201
return (code >= '0' && code <= '9') || (code >= 'a' && code <= 'f') ||
202-
(code >= 'A' && code <= 'F') || code == 'H' || code == 'h' ||
203-
code == 'I' || code == 'i' || code == 'M' || code == 'm' ||
204-
code == 'N' || code == 'n' || code == 'P' || code == 'p' ||
205-
code == 'R' || code == 'r' || code == 'S' || code == 's' ||
206-
code == 'T' || code == 't' || code == 'W' || code == 'w' ||
207-
code == 'Y' || code == 'y' || GetFallback(code) != '\0';
202+
(code >= 'A' && code <= 'F') || code == 'H' || code == 'I' ||
203+
code == 'M' || code == 'N' || code == 'P' || code == 'R' ||
204+
code == 'S' || code == 'T' || code == 'W' || code == 'Y' ||
205+
GetFallback(code) != '\0';
208206
}
209207

210208

@@ -221,16 +219,16 @@ public static void SubstituteSpecialColors([NotNull] StringBuilder sb, bool useF
221219
for (int i = sb.Length - 1; i > 0; i--) {
222220
if (sb[i - 1] != '&') continue;
223221

224-
switch (Char.ToLower(sb[i])) {
225-
case 's': sb[i] = Sys[1]; break;
226-
case 'y': sb[i] = Say[1]; break;
227-
case 'p': sb[i] = PM[1]; break;
228-
case 'r': sb[i] = Announcement[1]; break;
229-
case 'h': sb[i] = Help[1]; break;
230-
case 'w': sb[i] = Warning[1]; break;
231-
case 'm': sb[i] = Me[1]; break;
232-
case 'i': sb[i] = IRC[1]; break;
233-
case 't': sb[i] = White[1]; break;
222+
switch (sb[i]) {
223+
case 'S': sb[i] = Sys[1]; break;
224+
case 'Y': sb[i] = Say[1]; break;
225+
case 'P': sb[i] = PM[1]; break;
226+
case 'R': sb[i] = Announcement[1]; break;
227+
case 'H': sb[i] = Help[1]; break;
228+
case 'W': sb[i] = Warning[1]; break;
229+
case 'M': sb[i] = Me[1]; break;
230+
case 'I': sb[i] = IRC[1]; break;
231+
case 'T': sb[i] = White[1]; break;
234232
}
235233

236234
char fallback = GetFallback(sb[i]);

0 commit comments

Comments
 (0)