156 ::timeout (0); |
156 ::timeout (0); |
157 InputHistory.clear(); |
157 InputHistory.clear(); |
158 InputHistory << ""; |
158 InputHistory << ""; |
159 OutputLines.clear(); |
159 OutputLines.clear(); |
160 OutputLines << ColoredLine(); |
160 OutputLines << ColoredLine(); |
161 Title = format (APPNAME " %1 (%2)", full_version_string(), changeset_date_string()); |
161 Title.sprintf (APPNAME " %s (%d)", full_version_string(), changeset_date_string()); |
162 |
162 |
163 if (::has_colors()) |
163 if (::has_colors()) |
164 { |
164 { |
165 ::start_color(); |
165 ::start_color(); |
166 ::use_default_colors(); |
166 ::use_default_colors(); |
175 int pairnum = 1 + (i * NUM_COLORS + j); |
175 int pairnum = 1 + (i * NUM_COLORS + j); |
176 int fg = (i == DEFAULT) ? defaultFg : i; |
176 int fg = (i == DEFAULT) ? defaultFg : i; |
177 int bg = (j == DEFAULT) ? defaultBg : j; |
177 int bg = (j == DEFAULT) ? defaultBg : j; |
178 |
178 |
179 if (::init_pair (pairnum, fg, bg) == ERR) |
179 if (::init_pair (pairnum, fg, bg) == ERR) |
180 print ("Unable to initialize color pair %1 (%2, %3)\n", pairnum, fg, bg); |
180 print ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg); |
181 } |
181 } |
182 } |
182 } |
183 else |
183 else |
184 { |
184 { |
185 print ("This terminal does not appear to support colors.\n"); |
185 print ("This terminal does not appear to support colors.\n"); |
512 case RCON_CONNECTED: |
512 case RCON_CONNECTED: |
513 { |
513 { |
514 String adminText; |
514 String adminText; |
515 |
515 |
516 if (Session.num_admins() == 0) |
516 if (Session.num_admins() == 0) |
|
517 { |
517 adminText = "No other admins"; |
518 adminText = "No other admins"; |
|
519 } |
518 else |
520 else |
519 adminText = format ("%1 other admin%s1", Session.num_admins()); |
521 { |
520 |
522 adminText.sprintf ("%d other admin%s", Session.num_admins(), |
521 text = format ("%1 | %2 | %3", Session.address().to_string (IP_WITH_PORT), |
523 Session.num_admins() != 1 ? "s" : ""); |
522 Session.level(), adminText); |
524 } |
|
525 |
|
526 text.sprintf ("%s | %s | %s", Session.address().to_string (IP_WITH_PORT).chars(), |
|
527 Session.level().chars(), adminText.chars()); |
523 } |
528 } |
524 break; |
529 break; |
525 } |
530 } |
526 |
531 |
527 if (not text.is_empty()) |
532 if (not text.is_empty()) |
803 { |
808 { |
804 CurrentAddress = IPAddress::from_string (current_input()); |
809 CurrentAddress = IPAddress::from_string (current_input()); |
805 } |
810 } |
806 catch (std::exception& e) |
811 catch (std::exception& e) |
807 { |
812 { |
808 print ("%1\n", e.what()); |
813 print ("%s\n", e.what()); |
809 return; |
814 return; |
810 } |
815 } |
811 |
816 |
812 if (CurrentAddress.port == 0) |
817 if (CurrentAddress.port == 0) |
813 CurrentAddress.port = 10666; |
818 CurrentAddress.port = 10666; |
900 } |
905 } |
901 } |
906 } |
902 |
907 |
903 // ------------------------------------------------------------------------------------------------- |
908 // ------------------------------------------------------------------------------------------------- |
904 // |
909 // |
|
910 void Interface::vprint (const char* fmtstr, va_list args) |
|
911 { |
|
912 String message; |
|
913 message.vsprintf (fmtstr, args); |
|
914 print_to_console (message); |
|
915 } |
|
916 |
|
917 // ------------------------------------------------------------------------------------------------- |
|
918 // |
|
919 void __cdecl Interface::print (const char* fmtstr, ...) |
|
920 { |
|
921 va_list args; |
|
922 va_start (args, fmtstr); |
|
923 vprint (fmtstr, args); |
|
924 va_end (args); |
|
925 } |
|
926 |
|
927 // ------------------------------------------------------------------------------------------------- |
|
928 // |
|
929 void __cdecl Interface::print_warning (const char* fmtstr, ...) |
|
930 { |
|
931 va_list args; |
|
932 va_start (args, fmtstr); |
|
933 print_to_console (TEXTCOLOR_BrightYellow "-!- "); |
|
934 vprint (fmtstr, args); |
|
935 print_to_console (TEXTCOLOR_Reset); |
|
936 va_end (args); |
|
937 } |
|
938 |
|
939 // ------------------------------------------------------------------------------------------------- |
|
940 // |
|
941 void __cdecl Interface::print_error (const char* fmtstr, ...) |
|
942 { |
|
943 va_list args; |
|
944 va_start (args, fmtstr); |
|
945 print_to_console (TEXTCOLOR_BrightRed "!!! "); |
|
946 vprint (fmtstr, args); |
|
947 print_to_console (TEXTCOLOR_Reset); |
|
948 va_end (args); |
|
949 } |
|
950 |
|
951 // ------------------------------------------------------------------------------------------------- |
|
952 // |
905 void Interface::print_to_console (String a) |
953 void Interface::print_to_console (String a) |
906 { |
954 { |
907 // Zandronum sometimes sends color codes as "\\c" and sometimes as "\x1C". |
955 // Zandronum sometimes sends color codes as "\\c" and sometimes as "\x1C". |
908 // Let's correct that on our end and hope this won't cause conflicts. |
956 // Let's correct that on our end and hope this won't cause conflicts. |
909 a.replace ("\\c", "\x1C"); |
957 a.replace ("\\c", "\x1C"); |
942 { |
990 { |
943 CurrentAddress = IPAddress::from_string (address); |
991 CurrentAddress = IPAddress::from_string (address); |
944 } |
992 } |
945 catch (std::exception& e) |
993 catch (std::exception& e) |
946 { |
994 { |
947 print ("%1\n", e.what()); |
995 print ("%s\n", e.what()); |
948 return; |
996 return; |
949 } |
997 } |
950 |
998 |
951 if (CurrentAddress.port == 0) |
999 if (CurrentAddress.port == 0) |
952 CurrentAddress.port = 10666; |
1000 CurrentAddress.port = 10666; |