# HG changeset patch # User Teemu Piippo # Date 1469015592 -10800 # Node ID c909c38ca8866c97e314b1aeafaf653df32473d2 # Parent 485cb6d6b98cbf6178d4f791f5c98a702a2e7420 Restyled Interface's public method names diff -r 485cb6d6b98c -r c909c38ca886 sources/interface.cpp --- a/sources/interface.cpp Wed Jul 20 14:48:47 2016 +0300 +++ b/sources/interface.cpp Wed Jul 20 14:53:12 2016 +0300 @@ -189,12 +189,12 @@ if (fg != -1 || bg != -1) { if (::init_pair (pairnum, fg, bg) == ERR) - print_warning ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg); + printWarning ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg); } } } - render_full(); + renderFull(); refresh(); m_needRefresh = false; } @@ -220,7 +220,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::set_title (const String& title) +void Interface::setTitle (const String& title) { m_title = title; render_titlebar(); @@ -476,7 +476,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::update_statusbar() +void Interface::updateStatusBar() { String text; @@ -528,9 +528,9 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::render_full() +void Interface::renderFull() { - update_statusbar(); + updateStatusBar(); render_titlebar(); render_output(); render_statusbar(); @@ -608,7 +608,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::handle_input() +void Interface::handleInput() { int ch = ::getch(); @@ -618,7 +618,7 @@ if (ch == KEY_RESIZE) { ::clear(); - render_full(); + renderFull(); return; } @@ -818,7 +818,7 @@ case INPUTSTATE_NORMAL: if (current_input()[0] == '/') { - handle_command(current_input()); + handleCommand(current_input()); flush_input(); } else if (m_session.send_command (current_input())) @@ -910,7 +910,7 @@ // ------------------------------------------------------------------------------------------------- // -void __cdecl Interface::print_text (const char* fmtstr, ...) +void __cdecl Interface::printText (const char* fmtstr, ...) { va_list args; va_start (args, fmtstr); @@ -931,7 +931,7 @@ // ------------------------------------------------------------------------------------------------- // -void __cdecl Interface::print_warning (const char* fmtstr, ...) +void __cdecl Interface::printWarning (const char* fmtstr, ...) { va_list args; va_start (args, fmtstr); @@ -942,7 +942,7 @@ // ------------------------------------------------------------------------------------------------- // -void __cdecl Interface::print_error (const char* fmtstr, ...) +void __cdecl Interface::printError (const char* fmtstr, ...) { va_list args; va_start (args, fmtstr); @@ -1013,7 +1013,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::set_player_names (const StringList& names) +void Interface::setPlayerNames (const StringList& names) { m_playerNames.clear(); @@ -1030,7 +1030,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::tab_complete (const String& part, String complete) +void Interface::tabComplete (const String& part, String complete) { String& input = mutable_current_input(); @@ -1047,7 +1047,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::handle_command(const String& input) +void Interface::handleCommand(const String& input) { if (input[0] != '/') return; @@ -1060,7 +1060,7 @@ { if (args.size() != 2) { - print_error("Usage: /connect
\n"); + printError("Usage: /connect
\n"); } else { @@ -1072,7 +1072,7 @@ } catch (std::exception& e) { - print_error("%s\n", e.what()); + printError("%s\n", e.what()); return; } @@ -1095,7 +1095,7 @@ throw Exitception(); } else - print_error("Unknown command: %s\n", command.chars()); + printError("Unknown command: %s\n", command.chars()); } // ------------------------------------------------------------------------------------------------- @@ -1104,7 +1104,7 @@ { print("Disconnected from %s\n", m_session.address().to_string(IPAddress::WITH_PORT).chars()); reset_title(); - render_full(); + renderFull(); } // ------------------------------------------------------------------------------------------------- diff -r 485cb6d6b98c -r c909c38ca886 sources/interface.h --- a/sources/interface.h Wed Jul 20 14:48:47 2016 +0300 +++ b/sources/interface.h Wed Jul 20 14:53:12 2016 +0300 @@ -49,24 +49,23 @@ }; Interface(); - void handle_input(); + void connect(String address, String password); + void disconnected(); + RCONSession* getSession() { return &m_session; } + void handleCommand(const String& input); + void handleInput(); + void needRefresh(); + void __cdecl print(const char* fmtstr, ...); + void __cdecl printWarning(const char* fmtstr, ...); + void __cdecl printError(const char* fmtstr, ...); + void __cdecl printText(const char* fmtstr, ...); void render(); - void render_full(); - void set_title (const String& message); - void update_statusbar(); - void connect (String address, String password); - void set_player_names (const StringList& names); - void need_refresh(); - void tab_complete (const String& part, String complete); - RCONSession* get_session() { return &m_session; } - void handle_command(const String& input); - void disconnected(); - - void vprint (const char* fmtstr, va_list args); - void __cdecl print (const char* fmtstr, ...); - void __cdecl print_warning (const char* fmtstr, ...); - void __cdecl print_error (const char* fmtstr, ...); - void __cdecl print_text (const char* fmtstr, ...); + void renderFull(); + void setPlayerNames(const StringList& names); + void setTitle(const String& message); + void tabComplete(const String& part, String complete); + void updateStatusBar(); + void vprint(const char* fmtstr, va_list args); private: StringList m_inputHistory; diff -r 485cb6d6b98c -r c909c38ca886 sources/main.cpp --- a/sources/main.cpp Wed Jul 20 14:48:47 2016 +0300 +++ b/sources/main.cpp Wed Jul 20 14:53:12 2016 +0300 @@ -84,7 +84,7 @@ FD_ZERO (&fdset); FD_SET (0, &fdset); - int fd = iface.get_session()->socket()->file_descriptor(); + int fd = iface.getSession()->socket()->file_descriptor(); highest = zfc::max (highest, fd); FD_SET (fd, &fdset); @@ -93,15 +93,15 @@ if (FD_ISSET (0, &fdset)) { // stdin is ready, what's incoming? - iface.handle_input(); + iface.handleInput(); } - iface.get_session()->tick(); + iface.getSession()->tick(); iface.render(); } } catch (const zfc::Exitception&) {} - iface.get_session()->disconnect(); + iface.getSession()->disconnect(); return EXIT_SUCCESS; } diff -r 485cb6d6b98c -r c909c38ca886 sources/network/rconsession.cpp --- a/sources/network/rconsession.cpp Wed Jul 20 14:48:47 2016 +0300 +++ b/sources/network/rconsession.cpp Wed Jul 20 14:53:12 2016 +0300 @@ -59,7 +59,7 @@ { m_address = address; m_state = RCON_CONNECTING; - m_interface->update_statusbar(); + m_interface->updateStatusBar(); send_hello(); } @@ -135,12 +135,12 @@ switch (ServerResponse (header)) { case SVRC_OLDPROTOCOL: - m_interface->print_error ("Your RCON client is using outdated protocol.\n"); + m_interface->printError ("Your RCON client is using outdated protocol.\n"); m_state = RCON_DISCONNECTED; break; case SVRC_BANNED: - m_interface->print_error ("You have been banned from the server.\n"); + m_interface->printError ("You have been banned from the server.\n"); m_state = RCON_DISCONNECTED; break; @@ -151,7 +151,7 @@ break; case SVRC_INVALIDPASSWORD: - m_interface->print_error ("Login failed.\n"); + m_interface->printError ("Login failed.\n"); m_state = RCON_DISCONNECTED; break; @@ -159,7 +159,7 @@ { String message = packet.read_string(); message.normalize(); - m_interface->print_text ("%s\n", message.chars()); + m_interface->printText ("%s\n", message.chars()); } break; @@ -167,7 +167,7 @@ m_interface->print ("Login successful!\n"); m_serverProtocol = packet.read_byte(); m_hostname = packet.read_string(); - m_interface->set_title (m_hostname); + m_interface->setTitle (m_hostname); m_state = RCON_CONNECTED; for (int i = packet.read_byte(); i > 0; --i) @@ -179,7 +179,7 @@ { String message = packet.read_string(); message.normalize(); - m_interface->print_text ("--- %s\n", message.chars()); + m_interface->printText ("--- %s\n", message.chars()); } m_interface->print ("End of previous messages.\n"); @@ -207,7 +207,7 @@ if (completes.size() == 1) { - m_interface->tab_complete (m_lastTabComplete, completes[0]); + m_interface->tabComplete (m_lastTabComplete, completes[0]); } else if (not completes.is_empty()) { @@ -227,7 +227,7 @@ } catch (std::exception& e) { - m_interface->print_warning ("Couldn't process packet: %s\n", e.what()); + m_interface->printWarning ("Couldn't process packet: %s\n", e.what()); } } @@ -244,22 +244,22 @@ for (int i = packet.read_byte(); i > 0; --i) players.append (packet.read_string()); - m_interface->set_player_names (players); + m_interface->setPlayerNames (players); } break; case SVRCU_ADMINCOUNT: m_numAdmins = packet.read_byte(); - m_interface->update_statusbar(); + m_interface->updateStatusBar(); break; case SVRCU_MAP: m_level = packet.read_string(); - m_interface->update_statusbar(); + m_interface->updateStatusBar(); break; default: - m_interface->print_warning ("Unknown server update type: %d\n", header); + m_interface->printWarning ("Unknown server update type: %d\n", header); break; } }