ManaPlus
|
#include <serverdialog.h>
Public Member Functions | |
ServerDialog (ServerInfo *const serverInfo, const std::string &dir) | |
void | postInit () |
~ServerDialog () | |
void | action (const ActionEvent &event) |
void | keyPressed (KeyEvent &event) |
void | valueChanged (const SelectionEvent &event) |
void | mouseClicked (MouseEvent &event) |
void | logic () |
void | updateServer (const ServerInfo &server, const int index) |
void | connectToSelectedServer () |
void | close () |
Public Member Functions inherited from Window | |
Window (const std::string &caption, const Modal modal, Window *const parent, std::string skin) | |
~Window () | |
void | draw (Graphics *const graphics) |
void | safeDraw (Graphics *const graphics) |
void | setContentSize (int width, int height) |
void | setLocationRelativeTo (const Widget *const widget) |
void | setLocationHorisontallyRelativeTo (const Widget *const widget) |
void | setLocationRelativeTo (const ImagePosition::Type &position, int offsetX, int offsetY) |
void | setResizable (const bool resize) |
void | redraw () |
void | widgetResized (const Event &event) |
void | widgetMoved (const Event &event) |
void | widgetHidden (const Event &event) |
void | setCloseButton (const bool flag) |
bool | getCloseButton () const |
void | setAllowClose (const bool b) |
bool | getAlowClose () const |
bool | isResizable () const |
void | setMinWidth (const int width) |
int | getMinWidth () const |
void | setMinHeight (const int height) |
int | getMinHeight () const |
void | setMaxWidth (const int width) |
int | getMaxWidth () const |
void | setMaxHeight (const int height) |
int | getMaxHeight () const |
void | setShowTitle (bool flag) |
void | setStickyButton (const bool flag) |
void | setSticky (const bool sticky) |
bool | isSticky () const |
void | setStickyButtonLock (const bool sticky) |
bool | isStickyButtonLock () const |
virtual void | setVisible (Visible visible) |
void | setVisible (const Visible visible, const bool forceSticky) |
bool | isDefaultVisible () const |
void | setDefaultVisible (const bool save) |
bool | willSaveVisible () const |
void | setSaveVisible (const bool save) |
Window * | getParentWindow () const |
virtual void | scheduleDelete () |
void | mousePressed (MouseEvent &event) |
void | mouseDragged (MouseEvent &event) |
void | mouseMoved (MouseEvent &event) |
void | mouseReleased (MouseEvent &event) |
void | mouseExited (MouseEvent &event) |
void | mouseEntered (MouseEvent &event) |
void | updateResizeHandler (MouseEvent &event) |
void | setWindowName (const std::string &name) |
const std::string & | getWindowName () const |
void | loadWindowState () |
void | saveWindowState () |
void | setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight) |
void | setDefaultSize () |
void | setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx, const int offsetY) |
virtual void | resetToDefaultSize () |
void | adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight) |
Layout & | getLayout () |
void | clearLayout () |
void | reflowLayout (int w, int h) |
LayoutCell & | place (const int x, const int y, Widget *const wg, const int w, const int h) |
ContainerPlacer | getPlacer (const int x, const int y) |
void | center () |
void | centerHorisontally () |
void | setModal (const Modal modal) |
Rect | getWindowArea () const |
bool | isResizeAllowed (const MouseEvent &event) const |
void | setCaptionFont (Font *font) |
void | enableVisibleSound (bool b) |
bool | isWindowVisible () const |
void | setPadding (int padding) |
int | getPadding () const |
void | setTitleBarHeight (unsigned int height) |
unsigned int | getTitleBarHeight () const |
void | setCaption (const std::string &caption) |
const std::string & | getCaption () const |
void | setAlignment (Graphics::Alignment alignment) |
Graphics::Alignment | getAlignment () const |
void | setMovable (Move movable) |
bool | isMovable () const |
Rect | getChildrenArea () |
virtual void | resizeToContent () |
Public Member Functions inherited from BasicContainer2 | |
BasicContainer2 (const Widget2 *const widget) | |
~BasicContainer2 () | |
void | setOpaque (Opaque opaque) |
bool | isOpaque () const |
virtual void | add (Widget *const widget) |
void | addXY (Widget *const widget, const int x, const int y) |
Public Member Functions inherited from BasicContainer | |
BasicContainer (const Widget2 *const widget) | |
~BasicContainer () | |
void | showWidgetPart (Widget *const widget, const Rect &area) |
void | moveToTop (Widget *const widget) |
void | moveToBottom (Widget *const widget) |
void | focusNext () |
void | focusPrevious () |
void | setFocusHandler (FocusHandler *const focusHandler) |
void | setInternalFocusHandler (FocusHandler *const focusHandler) |
Widget * | getWidgetAt (int x, int y) |
void | death (const Event &event) |
Widget * | findFirstWidget (const std::set< Widget * > &list) |
void | add (Widget *const widget) |
virtual void | remove (Widget *const widget) |
virtual void | clear () |
Public Member Functions inherited from Widget | |
Widget (const Widget2 *const widget) | |
~Widget () | |
virtual void | drawFrame (Graphics *graphics) |
virtual void | safeDrawFrame (Graphics *graphics) |
void | setFrameSize (const unsigned int frameSize) |
unsigned int | getFrameSize () const |
Widget * | getParent () const |
void | setWidth (const int width) |
int | getWidth () const |
void | setHeight (const int height) |
int | getHeight () const |
void | setSize (const int width, const int height) |
void | setX (const int x) |
int | getX () const |
void | setY (const int y) |
int | getY () const |
void | setPosition (const int x, const int y) |
void | setDimension (const Rect &dimension) |
const Rect & | getDimension () const |
void | setFocusable (const bool focusable) |
bool | isFocusable () const |
virtual bool | isFocused () const |
void | setEnabled (const bool enabled) |
bool | isEnabled () const |
void | setVisible (Visible visible) |
bool | isVisible () const |
void | setBaseColor (const Color &color) |
const Color & | getBaseColor () const |
void | setForegroundColor (const Color &color) |
const Color & | getForegroundColor () const |
void | setBackgroundColor (const Color &color) |
const Color & | getBackgroundColor () const |
virtual void | requestFocus () |
virtual void | requestMoveToTop () |
virtual void | requestMoveToBottom () |
FocusHandler * | getFocusHandler () |
void | addActionListener (ActionListener *const actionListener) |
void | removeActionListener (ActionListener *const actionListener) |
void | addDeathListener (WidgetDeathListener *const deathListener) |
void | removeDeathListener (WidgetDeathListener *const deathListener) |
void | addMouseListener (MouseListener *const mouseListener) |
void | removeMouseListener (MouseListener *const mouseListener) |
void | addKeyListener (KeyListener *const keyListener) |
void | removeKeyListener (KeyListener *const keyListener) |
void | addFocusListener (FocusListener *const focusListener) |
void | removeFocusListener (FocusListener *const focusListener) |
void | addWidgetListener (WidgetListener *const widgetListener) |
void | removeWidgetListener (WidgetListener *const widgetListener) |
void | setActionEventId (const std::string &actionEventId) |
const std::string & | getActionEventId () const |
virtual void | getAbsolutePosition (int &x, int &y) const |
virtual void | setParent (Widget *parent) |
Font * | getFont () const |
void | setFont (Font *const font) |
virtual void | fontChanged () |
bool | isTabInEnabled () const |
void | setTabInEnabled (const bool enabled) |
bool | isTabOutEnabled () const |
void | setTabOutEnabled (const bool enabled) |
void | requestModalFocus () |
virtual void | requestModalMouseInputFocus () |
virtual void | releaseModalFocus () |
virtual void | releaseModalMouseInputFocus () |
virtual bool | isModalFocused () const |
virtual bool | isModalMouseInputFocused () const |
const std::list< MouseListener * > & | getMouseListeners () const A_CONST |
const std::list< KeyListener * > & | getKeyListeners () const A_CONST |
const std::list< FocusListener * > & | getFocusListeners () const A_CONST |
virtual FocusHandler * | getInternalFocusHandler () |
void | setInternalFocusHandler (FocusHandler *const internalFocusHandler) |
void | setId (const std::string &id) |
const std::string & | getId () const |
virtual void | showPart (const Rect &rectangle) |
bool | isAllowLogic () const |
void | setMouseConsume (const bool b) |
bool | isMouseConsume () const |
void | setRedraw (const bool b) |
virtual bool | isSelectable () const |
void | setSelectable (const bool selectable) |
void | windowResized () |
Public Member Functions inherited from Widget2 | |
virtual | ~Widget2 () |
const Color & | getThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE |
const Color & | getThemeCharColor (const signed char c, bool &valid) const A_INLINE |
virtual void | setWidget2 (const Widget2 *const widget) |
void | setPalette (int palette) |
void | checkPalette () |
void | setForegroundColor2 (const Color &color) |
Widget * | getWindow () const |
virtual void | setWindow (Widget *const window) |
Public Member Functions inherited from WidgetDeathListener | |
virtual | ~WidgetDeathListener () |
Public Member Functions inherited from MouseListener | |
virtual | ~MouseListener () |
virtual void | mouseWheelMovedUp (MouseEvent &event) |
virtual void | mouseWheelMovedDown (MouseEvent &event) |
Public Member Functions inherited from WidgetListener | |
virtual | ~WidgetListener () |
virtual void | widgetShown (const Event &event) |
Public Member Functions inherited from ActionListener | |
virtual | ~ActionListener () |
Public Member Functions inherited from KeyListener | |
virtual | ~KeyListener () |
virtual void | keyReleased (KeyEvent &event) |
Public Member Functions inherited from SelectionListener | |
virtual | ~SelectionListener () |
Protected Member Functions | |
MutexLocker | lock () |
Protected Member Functions inherited from Window | |
bool | canMove () const |
int | getOption (const std::string &name, const int def) const |
bool | getOptionBool (const std::string &name, const bool def) const |
void | setTitlePadding (const int p) |
int | getTitlePadding () const |
Protected Member Functions inherited from BasicContainer | |
virtual void | drawChildren (Graphics *const graphics) |
virtual void | safeDrawChildren (Graphics *const graphics) |
virtual void | logicChildren () |
Protected Member Functions inherited from Widget | |
void | distributeActionEvent () |
void | distributeResizedEvent () |
void | distributeMovedEvent () |
void | distributeHiddenEvent () |
void | distributeShownEvent () |
Protected Member Functions inherited from Widget2 | |
Widget2 (const Widget2 *const widget) | |
Protected Member Functions inherited from WidgetDeathListener | |
WidgetDeathListener () | |
Protected Member Functions inherited from MouseListener | |
MouseListener () | |
Protected Member Functions inherited from WidgetListener | |
WidgetListener () | |
Protected Member Functions inherited from ActionListener | |
ActionListener () | |
Protected Member Functions inherited from KeyListener | |
KeyListener () | |
Protected Member Functions inherited from SelectionListener | |
SelectionListener () | |
Private Member Functions | |
void | downloadServerList () |
void | loadServers (const bool addNew) |
void | loadCustomServers () |
void | saveCustomServers (const ServerInfo ¤tServer, const int index) |
bool | needUpdateServers () const |
Static Private Member Functions | |
static int | downloadUpdate (void *ptr, const DownloadStatusT status, size_t total, const size_t remaining) |
Private Attributes | |
Mutex | mMutex |
ServerInfos | mServers |
const std::string & | mDir |
Label * | mDescription |
Button * | mQuitButton |
Button * | mConnectButton |
Button * | mAddEntryButton |
Button * | mEditEntryButton |
Button * | mDeleteButton |
Button * | mLoadButton |
Button * | mInfoButton |
ServersListModel * | mServersListModel |
ListBox * | mServersList |
Net::Download * | mDownload |
ServerInfo * | mServerInfo |
CheckBox * | mPersistentIPCheckBox |
float | mDownloadProgress |
ServerDialogDownloadStatusT | mDownloadStatus |
Friends | |
class | ServersListModel |
class | EditServerDialog |
The server choice dialog.
Definition at line 57 of file serverdialog.h.
ServerDialog::ServerDialog | ( | ServerInfo *const | serverInfo, |
const std::string & | dir | ||
) |
Constructor
Definition at line 97 of file serverdialog.cpp.
References _, Widget::addKeyListener(), Widget::addMouseListener(), ListBox::addSelectionListener(), ImagePosition::CENTER, config, fromBool, Configuration::getBoolValue(), Widget::getHeight(), Configuration::getIntValue(), Window::getLayout(), Window::getOptionBool(), Widget::getWidth(), isSafeMode, loadCustomServers(), Window::loadWindowState(), mAddEntryButton, mConnectButton, mDeleteButton, mDescription, mEditEntryButton, mInfoButton, mLoadButton, mPersistentIPCheckBox, mQuitButton, mServersList, Window::place(), Layout::reflow(), RENDER_SOFTWARE, Window::setCaption(), Window::setCloseButton(), Window::setContentSize(), Window::setDefaultSize(), ScrollArea::setHorizontalScrollPolicy(), Window::setMinHeight(), Window::setMinWidth(), LayoutCell::setPadding(), Window::setResizable(), LayoutCell::setRowHeight(), ScrollArea::setVerticalScrollAmount(), Window::setWindowName(), and ScrollArea::SHOW_NEVER.
ServerDialog::~ServerDialog | ( | ) |
Destructor
Definition at line 216 of file serverdialog.cpp.
References Net::Download::cancel, delete2, mDownload, and mServersListModel.
|
virtual |
Called when receiving actions from the widgets.
Implements ActionListener.
Definition at line 289 of file serverdialog.cpp.
References close(), connectToSelectedServer(), CREATEWIDGET, CREATEWIDGETR, downloadServerList(), ListBox::getSelected(), mServers, mServersList, saveCustomServers(), Window::scheduleDelete(), serverInfoWindow, and ListBox::setSelected().
Referenced by keyPressed(), and mouseClicked().
|
virtual |
Overrideable functionality for when the window is to close. This allows for class implementations to clean up or do certain actions on window close they couldn't do otherwise.
Reimplemented from Window.
Definition at line 910 of file serverdialog.cpp.
References Net::Download::cancel, client, Window::close(), State::FORCE_QUIT, mDownload, and Client::setState().
Referenced by action().
void ServerDialog::connectToSelectedServer | ( | ) |
Definition at line 226 of file serverdialog.cpp.
References ServerInfo::althostname, Net::Download::cancel, chatLogger, client, config, State::CONNECT_SERVER, ServerInfo::defaultHostName, ServerInfo::description, desktop, ServerInfo::docs, empty, ServerInfo::freeSources, ServerInfo::freeType, ListBox::getSelected(), Client::getState(), ServerInfo::hostname, CheckBox::isSelected(), mConnectButton, mDownload, mLoadButton, mPersistentIPCheckBox, mQuitButton, mServerInfo, mServers, mServersList, ServerInfo::name, ServerInfo::nonFreeSources, ServerInfo::onlineListUrl, ServerInfo::packetVersion, ServerInfo::persistentIp, Settings::persistentIp, ServerInfo::port, ServerInfo::registerUrl, Desktop::reloadWallpaper(), ServerInfo::save, saveCustomServers(), LoginDialog::savedPassword, LoginDialog::savedPasswordKey, ServerInfo::serverUrl, Widget::setEnabled(), ChatLogger::setServerName(), Client::setState(), settings, Configuration::setValue(), ServerInfo::supportUrl, Settings::supportUrl, ServerInfo::type, ServerInfo::updateHosts, ServerInfo::updateMirrors, and Settings::updateMirrors.
Referenced by EditServerDialog::action(), and action().
|
private |
Called to load a list of available server from an online xml file.
Definition at line 462 of file serverdialog.cpp.
References Net::Download::addMirror(), branding, Net::Download::cancel, config, delete2, downloadUpdate(), getDateString(), Configuration::getStringValue(), mDir, mDownload, pathJoin(), Net::Download::setFile(), Configuration::setValue(), and Net::Download::start().
Referenced by action(), and postInit().
|
staticprivate |
Definition at line 845 of file serverdialog.cpp.
References DownloadStatus::Cancelled, CAST_S32, ServerDialogDownloadStatus::COMPLETE, DownloadStatus::Complete, ServerDialogDownloadStatus::ERROR, Net::Download::getError(), ServerDialogDownloadStatus::IN_PROGRESS, Logger::log(), logger, mDownload, mDownloadProgress, mDownloadStatus, and mMutex.
Referenced by downloadServerList().
|
virtual |
Called if a key is pressed when the widget has keyboard focus. If a key is held down the widget will generate multiple key presses.
event | Discribes the event. |
Reimplemented from KeyListener.
Definition at line 343 of file serverdialog.cpp.
References action(), client, CREATEWIDGET, State::EXIT, Widget::getActionEventId(), KeyEvent::getActionId(), ListBox::getSelected(), InputAction::GUI_BACKSPACE, InputAction::GUI_CANCEL, InputAction::GUI_DELETE, InputAction::GUI_INSERT, InputAction::GUI_SELECT, InputAction::GUI_SELECT2, InputGuiEvent::isConsumed(), ListBox::keyPressed(), mConnectButton, mServers, mServersList, PRAGMA45(), saveCustomServers(), ListBox::setSelected(), and Client::setState().
|
private |
Definition at line 743 of file serverdialog.cpp.
References CAST_U16, config, defaultPortForServerType(), ServerInfo::description, ConfigurationObject::getValue(), ServerInfo::hostname, ServerInfo::isValid(), MAX_SERVERLIST, mServers, ServerInfo::name, ServerInfo::onlineListUrl, ServerInfo::packetVersion, ServerInfo::parseType(), ServerInfo::persistentIp, ServerInfo::port, ServerInfo::save, Catch::toString(), and ServerInfo::type.
Referenced by ServerDialog().
|
private |
Definition at line 559 of file serverdialog.cpp.
References _, ServerInfo::althostname, branding, CAST_U16, CAST_U32, compareStrI(), ServerInfo::defaultHostName, defaultPortForServerType(), ServerInfo::description, ServerInfo::docs, for_each_xml_child_node, ServerInfo::freeSources, ServerInfo::freeType, Gui::getFont(), getLangShort(), XML::getProperty(), ListBox::getSelected(), Configuration::getStringValue(), Font::getWidth(), gui, ServerInfo::hostname, XML::langProperty(), loadHostsGroup(), loadServerSources(), loadServerSourcesList(), Logger::log(), Logger::log1(), logger, mDir, mMutex, mServers, mServersList, mServersListModel, ServerInfo::name, ServerInfo::nonFreeSources, ServerInfo::onlineListUrl, ServerInfo::packetVersion, ServerInfo::parseFreeType(), ServerInfo::parseType(), pathJoin(), ServerInfo::persistentIp, ServerInfo::port, ServerInfo::registerUrl, XML::Document::rootNode(), ServerInfo::serverUrl, ListBox::setSelected(), ServersListModel::setVersionString(), SkipError_true, SMALL_VERSION, strprintf(), ServerInfo::supportUrl, ServerInfo::type, ServerType::UNKNOWN, ServerInfo::updateHosts, ServerInfo::updateMirrors, UseVirtFs_false, and ServerInfo::version.
Referenced by logic(), and postInit().
|
inlineprotected |
Definition at line 104 of file serverdialog.h.
References mMutex.
Referenced by ServersListModel::getElementAt(), and ServersListModel::getNumberOfElements().
|
virtual |
Called for all widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.
Reimplemented from BasicContainer.
Definition at line 422 of file serverdialog.cpp.
References _, BLOCK_END, BLOCK_START, ServerDialogDownloadStatus::COMPLETE, ServerDialogDownloadStatus::ERROR, ServerDialogDownloadStatus::IDLE, ServerDialogDownloadStatus::IN_PROGRESS, loadServers(), Logger::log(), logger, BasicContainer::logic(), mDescription, mDownloadProgress, mDownloadStatus, mMutex, ServerDialogDownloadStatus::OVER, ServerDialogDownloadStatus::PREPARING, Label::setCaption(), and strprintf().
|
virtual |
Called when a mouse button is pressed and released (clicked) on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 408 of file serverdialog.cpp.
References action(), Widget::getActionEventId(), MouseEvent::getButton(), MouseEvent::getClickCount(), Event::getSource(), MouseButton::LEFT, mConnectButton, and mServersList.
|
private |
Definition at line 899 of file serverdialog.cpp.
References config, getDateString(), Configuration::getStringValue(), and mServers.
Referenced by postInit().
|
virtual |
Reimplemented from Window.
Definition at line 199 of file serverdialog.cpp.
References downloadServerList(), loadServers(), Logger::log(), logger, mConnectButton, mServersList, needUpdateServers(), Window::postInit(), Widget::requestFocus(), ListBox::setSelected(), Window::setVisible(), and Visible_true.
|
private |
Definition at line 782 of file serverdialog.cpp.
References CAST_SIZE, CAST_U32, config, ServerInfo::description, FOR_EACH, ServerInfo::hostname, ServerInfo::isValid(), MAX_SERVERLIST, mServers, ServerInfo::name, ServerInfo::onlineListUrl, ServerInfo::packetVersion, ServerInfo::persistentIp, ServerInfo::port, ServerInfo::save, serverTypeToString(), Configuration::setValue(), Catch::toString(), and ServerInfo::type.
Referenced by action(), connectToSelectedServer(), keyPressed(), and updateServer().
void ServerDialog::updateServer | ( | const ServerInfo & | server, |
const int | index | ||
) |
Definition at line 894 of file serverdialog.cpp.
References saveCustomServers().
Referenced by EditServerDialog::action().
|
virtual |
Called when the selected value changed in the servers list box.
Reimplemented from SelectionListener.
Definition at line 397 of file serverdialog.cpp.
References ListBox::getSelected(), mDeleteButton, mServersList, and Widget::setEnabled().
|
friend |
Definition at line 108 of file serverdialog.h.
|
friend |
Definition at line 102 of file serverdialog.h.
|
private |
Definition at line 135 of file serverdialog.h.
Referenced by ServerDialog().
|
private |
Definition at line 134 of file serverdialog.h.
Referenced by connectToSelectedServer(), keyPressed(), mouseClicked(), postInit(), and ServerDialog().
|
private |
Definition at line 137 of file serverdialog.h.
Referenced by ServerDialog(), and valueChanged().
|
private |
Definition at line 132 of file serverdialog.h.
Referenced by logic(), and ServerDialog().
|
private |
Definition at line 131 of file serverdialog.h.
Referenced by downloadServerList(), and loadServers().
|
private |
Status of the current download.
Definition at line 144 of file serverdialog.h.
Referenced by close(), connectToSelectedServer(), downloadServerList(), downloadUpdate(), and ~ServerDialog().
|
private |
Definition at line 147 of file serverdialog.h.
Referenced by downloadUpdate(), and logic().
|
private |
Definition at line 148 of file serverdialog.h.
Referenced by downloadUpdate(), and logic().
|
private |
Definition at line 136 of file serverdialog.h.
Referenced by ServerDialog().
|
private |
Definition at line 139 of file serverdialog.h.
Referenced by ServerDialog().
|
private |
Definition at line 138 of file serverdialog.h.
Referenced by connectToSelectedServer(), and ServerDialog().
|
private |
Definition at line 129 of file serverdialog.h.
Referenced by downloadUpdate(), loadServers(), lock(), and logic().
|
private |
Definition at line 146 of file serverdialog.h.
Referenced by connectToSelectedServer(), and ServerDialog().
|
private |
Definition at line 133 of file serverdialog.h.
Referenced by connectToSelectedServer(), and ServerDialog().
|
private |
Definition at line 145 of file serverdialog.h.
Referenced by connectToSelectedServer().
|
private |
Definition at line 130 of file serverdialog.h.
Referenced by action(), connectToSelectedServer(), keyPressed(), loadCustomServers(), loadServers(), needUpdateServers(), and saveCustomServers().
|
private |
Definition at line 141 of file serverdialog.h.
Referenced by action(), connectToSelectedServer(), keyPressed(), loadServers(), mouseClicked(), postInit(), ServerDialog(), and valueChanged().
|
private |
Definition at line 140 of file serverdialog.h.
Referenced by loadServers(), and ~ServerDialog().