187 int bg = (j == DEFAULT) ? defaultBg : j; |
187 int bg = (j == DEFAULT) ? defaultBg : j; |
188 |
188 |
189 if (fg != -1 || bg != -1) |
189 if (fg != -1 || bg != -1) |
190 { |
190 { |
191 if (::init_pair (pairnum, fg, bg) == ERR) |
191 if (::init_pair (pairnum, fg, bg) == ERR) |
192 print_warning ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg); |
192 printWarning ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg); |
193 } |
193 } |
194 } |
194 } |
195 } |
195 } |
196 |
196 |
197 render_full(); |
197 renderFull(); |
198 refresh(); |
198 refresh(); |
199 m_needRefresh = false; |
199 m_needRefresh = false; |
200 } |
200 } |
201 |
201 |
202 // ------------------------------------------------------------------------------------------------- |
202 // ------------------------------------------------------------------------------------------------- |
606 m_needInputRender = true; |
606 m_needInputRender = true; |
607 } |
607 } |
608 |
608 |
609 // ------------------------------------------------------------------------------------------------- |
609 // ------------------------------------------------------------------------------------------------- |
610 // |
610 // |
611 void Interface::handle_input() |
611 void Interface::handleInput() |
612 { |
612 { |
613 int ch = ::getch(); |
613 int ch = ::getch(); |
614 |
614 |
615 if (ch < 0) |
615 if (ch < 0) |
616 return; |
616 return; |
617 |
617 |
618 if (ch == KEY_RESIZE) |
618 if (ch == KEY_RESIZE) |
619 { |
619 { |
620 ::clear(); |
620 ::clear(); |
621 render_full(); |
621 renderFull(); |
622 return; |
622 return; |
623 } |
623 } |
624 |
624 |
625 if (m_inputState == INPUTSTATE_CONFIRM_DISCONNECTION) |
625 if (m_inputState == INPUTSTATE_CONFIRM_DISCONNECTION) |
626 { |
626 { |
908 print_to_console (message); |
908 print_to_console (message); |
909 } |
909 } |
910 |
910 |
911 // ------------------------------------------------------------------------------------------------- |
911 // ------------------------------------------------------------------------------------------------- |
912 // |
912 // |
913 void __cdecl Interface::print_text (const char* fmtstr, ...) |
913 void __cdecl Interface::printText (const char* fmtstr, ...) |
914 { |
914 { |
915 va_list args; |
915 va_list args; |
916 va_start (args, fmtstr); |
916 va_start (args, fmtstr); |
917 vprint (fmtstr, args); |
917 vprint (fmtstr, args); |
918 va_end (args); |
918 va_end (args); |
929 va_end (args); |
929 va_end (args); |
930 } |
930 } |
931 |
931 |
932 // ------------------------------------------------------------------------------------------------- |
932 // ------------------------------------------------------------------------------------------------- |
933 // |
933 // |
934 void __cdecl Interface::print_warning (const char* fmtstr, ...) |
934 void __cdecl Interface::printWarning (const char* fmtstr, ...) |
935 { |
935 { |
936 va_list args; |
936 va_list args; |
937 va_start (args, fmtstr); |
937 va_start (args, fmtstr); |
938 print_to_console (TEXTCOLOR_BrightYellow "-!- "); |
938 print_to_console (TEXTCOLOR_BrightYellow "-!- "); |
939 vprint (fmtstr, args); |
939 vprint (fmtstr, args); |
940 va_end (args); |
940 va_end (args); |
941 } |
941 } |
942 |
942 |
943 // ------------------------------------------------------------------------------------------------- |
943 // ------------------------------------------------------------------------------------------------- |
944 // |
944 // |
945 void __cdecl Interface::print_error (const char* fmtstr, ...) |
945 void __cdecl Interface::printError (const char* fmtstr, ...) |
946 { |
946 { |
947 va_list args; |
947 va_list args; |
948 va_start (args, fmtstr); |
948 va_start (args, fmtstr); |
949 print_to_console (TEXTCOLOR_BrightRed "!!! "); |
949 print_to_console (TEXTCOLOR_BrightRed "!!! "); |
950 vprint (fmtstr, args); |
950 vprint (fmtstr, args); |
1011 m_session.connect (m_remoteAddress); |
1011 m_session.connect (m_remoteAddress); |
1012 } |
1012 } |
1013 |
1013 |
1014 // ------------------------------------------------------------------------------------------------- |
1014 // ------------------------------------------------------------------------------------------------- |
1015 // |
1015 // |
1016 void Interface::set_player_names (const StringList& names) |
1016 void Interface::setPlayerNames (const StringList& names) |
1017 { |
1017 { |
1018 m_playerNames.clear(); |
1018 m_playerNames.clear(); |
1019 |
1019 |
1020 for (const String& name : names) |
1020 for (const String& name : names) |
1021 { |
1021 { |
1028 m_needNicklistRender = true; |
1028 m_needNicklistRender = true; |
1029 } |
1029 } |
1030 |
1030 |
1031 // ------------------------------------------------------------------------------------------------- |
1031 // ------------------------------------------------------------------------------------------------- |
1032 // |
1032 // |
1033 void Interface::tab_complete (const String& part, String complete) |
1033 void Interface::tabComplete (const String& part, String complete) |
1034 { |
1034 { |
1035 String& input = mutable_current_input(); |
1035 String& input = mutable_current_input(); |
1036 |
1036 |
1037 if (input.starts_with (part)) |
1037 if (input.starts_with (part)) |
1038 { |
1038 { |
1070 { |
1070 { |
1071 address = IPAddress::from_string(args[0]); |
1071 address = IPAddress::from_string(args[0]); |
1072 } |
1072 } |
1073 catch (std::exception& e) |
1073 catch (std::exception& e) |
1074 { |
1074 { |
1075 print_error("%s\n", e.what()); |
1075 printError("%s\n", e.what()); |
1076 return; |
1076 return; |
1077 } |
1077 } |
1078 |
1078 |
1079 if (address.port == 0) |
1079 if (address.port == 0) |
1080 address.port = 10666; |
1080 address.port = 10666; |
1093 m_session.disconnect(); |
1093 m_session.disconnect(); |
1094 endwin(); |
1094 endwin(); |
1095 throw Exitception(); |
1095 throw Exitception(); |
1096 } |
1096 } |
1097 else |
1097 else |
1098 print_error("Unknown command: %s\n", command.chars()); |
1098 printError("Unknown command: %s\n", command.chars()); |
1099 } |
1099 } |
1100 |
1100 |
1101 // ------------------------------------------------------------------------------------------------- |
1101 // ------------------------------------------------------------------------------------------------- |
1102 // |
1102 // |
1103 void Interface::disconnected() |
1103 void Interface::disconnected() |
1104 { |
1104 { |
1105 print("Disconnected from %s\n", m_session.address().to_string(IPAddress::WITH_PORT).chars()); |
1105 print("Disconnected from %s\n", m_session.address().to_string(IPAddress::WITH_PORT).chars()); |
1106 reset_title(); |
1106 reset_title(); |
1107 render_full(); |
1107 renderFull(); |
1108 } |
1108 } |
1109 |
1109 |
1110 // ------------------------------------------------------------------------------------------------- |
1110 // ------------------------------------------------------------------------------------------------- |
1111 // |
1111 // |
1112 void Interface::reset_title() |
1112 void Interface::reset_title() |