ManaPlus
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
Client Class Reference

#include <client.h>

Inheritance diagram for Client:
ActionListener ConfigListener ActionListener

Public Member Functions

 Client ()
 
 ~Client ()
 
void gameInit ()
 
void testsInit ()
 
int gameExec ()
 
void setState (const StateT state)
 
StateT getState () const
 
void action (const ActionEvent &event)
 
void moveButtons (const int width)
 
void windowRemoved (const Window *const window)
 
void updatePinState ()
 
void focusWindow ()
 
void slowLogic ()
 
 Client ()
 
 ~Client ()
 
void gameInit ()
 
void testsInit ()
 
int gameExec ()
 
void setState (const StateT state)
 
StateT getState () const
 
void optionChanged (const std::string &name)
 
void action (const ActionEvent &event)
 
void moveButtons (const int width)
 
void windowRemoved (const Window *const window)
 
void focusWindow ()
 
void updatePinState ()
 
void slowLogic ()
 
ServerInfogetCurrentServer ()
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- Public Member Functions inherited from ConfigListener
 ConfigListener ()
 
virtual ~ConfigListener ()
 

Static Public Member Functions

static int testsExec ()
 
static bool isTmw ()
 
static int testsExec ()
 
static bool isTmw ()
 
static void initTradeFilter ()
 

Private Member Functions

void stateGame ()
 
void initSoundManager ()
 
void gameClear ()
 
void testsClear ()
 
void initSoundManager ()
 
void initConfigListeners ()
 
void gameClear ()
 
void testsClear ()
 
void stateConnectServer1 ()
 
void stateWorldSelect1 ()
 
void stateGame1 ()
 
void stateSwitchLogin1 ()
 
void loadData ()
 
void unloadData ()
 
void runValidate () __attribute__((noreturn))
 

Static Private Member Functions

static void initGraphics ()
 
static void initPaths ()
 
static void logVars ()
 
static void initGraphics ()
 
static void initFeatures ()
 
static void initPaths ()
 
static void logVars ()
 
static void stateConnectGame1 ()
 

Private Attributes

WindowmCurrentDialog
 
ButtonmSetupButton
 
ButtonmVideoButton
 
ButtonmHelpButton
 
ButtonmAboutButton
 
ButtonmThemesButton
 
ButtonmPerfomanceButton
 
StateT mState
 
StateT mOldState
 
SkinmSkin
 
int mButtonPadding
 
int mButtonSpacing
 
ServerInfo mCurrentServer
 
GamemGame
 
QuitDialogmQuitDialog
 
int mPing
 
bool mConfigAutoSaved
 

Additional Inherited Members

- Protected Member Functions inherited from ActionListener
 ActionListener ()
 

Detailed Description

The core part of the client. This class initializes all subsystems, runs the event loop, and shuts everything down again.

Definition at line 49 of file client.h.

Constructor & Destructor Documentation

◆ Client() [1/2]

Client::Client ( )

Definition at line 140 of file client.cpp.

140  :
141  ActionListener(),
142  mCurrentDialog(nullptr),
143  mSetupButton(nullptr),
144  mVideoButton(nullptr),
145  mHelpButton(nullptr),
146  mAboutButton(nullptr),
147  mThemesButton(nullptr),
148  mPerfomanceButton(nullptr),
149 #ifdef ANDROID
150  mCloseButton(nullptr),
151 #endif // ANDROID
154  mSkin(nullptr),
155  mButtonPadding(1),
156  mButtonSpacing(3)
157 {
159 }
StateT mState
Definition: client.h:112
int mButtonPadding
Definition: client.h:116
int mButtonSpacing
Definition: client.h:117
Button * mAboutButton
Definition: client.h:105
StateT mOldState
Definition: client.h:113
Button * mPerfomanceButton
Definition: client.h:107
Button * mVideoButton
Definition: client.h:103
Button * mHelpButton
Definition: client.h:104
Button * mSetupButton
Definition: client.h:102
Button * mThemesButton
Definition: client.h:106
Skin * mSkin
Definition: client.h:115
Window * mCurrentDialog
Definition: client.h:101
@ START
Definition: state.h:36
@ GAME
Definition: state.h:49

References WindowManager::init().

◆ ~Client() [1/2]

Client::~Client ( )

Definition at line 382 of file client.cpp.

383 {
385  gameClear();
386  else
387  testsClear();
388 }
void gameClear()
Definition: client.cpp:435
void testsClear()
Definition: client.cpp:165
Options options
Definition: settings.h:130
Settings settings
Definition: settings.cpp:32
bool testMode
Definition: options.h:99

References gameClear(), Settings::options, settings, Options::testMode, and testsClear().

◆ Client() [2/2]

Client::Client ( )

◆ ~Client() [2/2]

Client::~Client ( )

Member Function Documentation

◆ action() [1/2]

void Client::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 732 of file client.cpp.

733 {
734  std::string tab;
735  const std::string &eventId = event.getId();
736 
737  if (eventId == "close")
738  {
740  return;
741  }
742  if (eventId == "Setup")
743  {
744  tab.clear();
745  }
746  else if (eventId == "help")
747  {
749  return;
750  }
751  else if (eventId == "about")
752  {
754  return;
755  }
756  else if (eventId == "Video")
757  {
758  tab = "Video";
759  }
760  else if (eventId == "Themes")
761  {
762  tab = "Theme";
763  }
764  else if (eventId == "Perfomance")
765  {
766  tab = "Perfomance";
767  }
768  else
769  {
770  return;
771  }
772 }
void setState(const StateT state)
Definition: client.h:66
void executeAction(const InputActionT keyNum)
InputManager inputManager
@ FORCE_QUIT
Definition: state.h:68

References InputManager::executeAction(), State::FORCE_QUIT, inputManager, setState(), InputAction::WINDOW_ABOUT, and InputAction::WINDOW_HELP.

◆ action() [2/2]

void Client::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

◆ focusWindow() [1/2]

void Client::focusWindow ( )

Definition at line 809 of file client.cpp.

810 {
811  if (mCurrentDialog != nullptr)
812  {
814  }
815 }
virtual void requestFocus()
Definition: widget.cpp:204

References mCurrentDialog, and Widget::requestFocus().

Referenced by PincodeManager::pinOk().

◆ focusWindow() [2/2]

void Client::focusWindow ( )

◆ gameClear() [1/2]

void Client::gameClear ( )
private

Definition at line 435 of file client.cpp.

436 {
437  if (logger != nullptr)
438  logger->log1("Quitting1");
439 
442  if (windowContainer != nullptr)
444 
445  stopTimers();
446 
447  delete2(ipc)
448 
449  if (logger != nullptr)
450  logger->log1("Quitting2");
451 
455  delete2(gui)
456 
457  if (logger != nullptr)
458  logger->log1("Quitting3");
459 
461 
462  if (logger != nullptr)
463  logger->log1("Quitting4");
464 
465  XML::cleanupXML();
466 
467  if (logger != nullptr)
468  logger->log1("Quitting5");
469 
471 
472  if (logger != nullptr)
473  logger->log1("Quitting6");
474 
477 
479 
480  if (logger != nullptr)
481  logger->log1("Quitting8");
482 
484 
485  if (logger != nullptr)
486  logger->log1("Quitting9");
487 
489 
490  keyboard.deinit();
491 
492  if (logger != nullptr)
493  logger->log1("Quitting10");
494 
496 
497 #ifdef DEBUG_CONFIG
498  config.enableKeyLogging();
499 #endif // DEBUG_CONFIG
500 
502  config.write();
504 
505  config.clear();
507 
508  if (logger != nullptr)
509  logger->log1("Quitting11");
510 
511 #ifdef USE_PROFILER
513 #endif // USE_PROFILER
514 
515 #ifdef DEBUG_OPENGL_LEAKS
516  if (logger)
517  logger->log("textures left: %d", textures_count);
518 #endif // DEBUG_OPENGL_LEAKS
519 
521 
522  if (logger != nullptr)
523  logger->log1("Quitting12");
524 
525 // delete2(chatLogger)
527  VirtFs::deinit();
528 }
static void deleteRenderers()
static void cleanUp()
Definition: graphics.cpp:159
void log(const char *const log_text,...)
Definition: logger.cpp:269
void log1(const char *const log_text)
Definition: logger.cpp:238
Configuration config
Configuration serverConfig
#define delete2(var)
Definition: delete2.h:25
DialogsManager * dialogsManager
int textures_count
Definition: client.cpp:138
EventsManager eventsManager
Gui * gui
Definition: gui.cpp:111
IPC * ipc
Definition: ipc.cpp:37
Joystick * joystick
Definition: joystick.cpp:43
KeyboardConfig keyboard
Logger * logger
Definition: logger.cpp:89
void clear()
Definition: playerinfo.cpp:452
bool deinit()
Definition: fs.cpp:785
void cleanupXML()
Definition: libxml.cpp:315
PopupManager * popupManager
SoundManager soundManager
void stopTimers()
Definition: timer.cpp:121
TouchManager touchManager
WindowContainer * windowContainer

References Graphics::cleanUp(), XML::cleanupXML(), PlayerInfo::clear(), ConfigurationObject::clear(), TouchManager::clear(), SoundManager::close(), TranslationManager::close(), config, VirtFs::deinit(), KeyboardConfig::deinit(), delete2, WindowManager::deleteIcon(), ResourceManager::deleteInstance(), GraphicsManager::deleteRenderers(), WindowManager::deleteWindows(), dialogsManager, eventsManager, gui, ipc, joystick, keyboard, Logger::log(), Logger::log1(), logger, mCurrentDialog, popupManager, Configuration::removeOldKeys(), serverConfig, EventsManager::shutdown(), TouchManager::shutdown(), SoundManager::shutdown(), WindowContainer::slowLogic(), soundManager, stopTimers(), textures_count, touchManager, windowContainer, and Configuration::write().

Referenced by ~Client().

◆ gameClear() [2/2]

void Client::gameClear ( )
private

◆ gameExec() [1/2]

int Client::gameExec ( )

Definition at line 577 of file client.cpp.

578 {
579  int lastTickTime = tick_time;
580 
581  while (mState != State::EXIT)
582  {
583  PROFILER_START();
585  continue;
586 
587  BLOCK_START("Client::gameExec 4")
588  if (gui != nullptr)
589  gui->logic();
590  cur_time = time(nullptr);
591  int k = 0;
592  while (lastTickTime != tick_time && k < 40)
593  {
594 // if (mGame)
595 // mGame->logic();
596 // else
597  if (gui != nullptr)
598  gui->handleInput();
599 
600  ++lastTickTime;
601  k ++;
602  }
604 
605  logic_count = logic_count + k;
606  if (gui != nullptr)
607  gui->slowLogic();
608 // if (mGame)
609 // mGame->slowLogic();
610  slowLogic();
611  BLOCK_END("Client::gameExec 4")
612 
613  // This is done because at some point tick_time will wrap.
614  lastTickTime = tick_time;
615 
616  // Update the screen when application is visible, delay otherwise.
618  {
619  frame_count = frame_count + 1;
620  if (gui != nullptr)
621  gui->draw();
623  }
624  else
625  {
626  SDL_Delay(100);
627  }
628 
629  BLOCK_START("~Client::SDL_framerateDelay")
630  if (settings.limitFps)
633 
635 /*
636  if (mState == State::CONNECT_GAME)
637  {
638  stateConnectGame1();
639  }
640 */
642 
643  if (mState != mOldState)
644  {
645  BLOCK_START("Client::gameExec 7")
646 
647  mOldState = mState;
648 
649  // Get rid of the dialog of the previous state
651 
652  // State has changed, while the quitDialog was active, it might
653  // not be correct anymore
654 /*
655  if (mQuitDialog)
656  {
657  mQuitDialog->scheduleDelete();
658  mQuitDialog = nullptr;
659  }
660 */
662 
664  PRAGMA45(GCC diagnostic push)
665  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
666  switch (mState)
667  {
668  case State::GAME:
669  stateGame();
670  break;
671 
672  case State::LOAD_DATA:
673  {
674  BLOCK_START("Client::gameExec State::LOAD_DATA")
675  logger->log1("State: LOAD DATA");
676 
677  // If another data path has been set,
678  // we don't load any other files...
679  if (settings.options.dataPath.empty())
680  {
681  // Add customdata directory
683  "customdata/",
684  "zip",
685  Append_false);
686  }
687 
689  {
691  settings.updatesDir, "local/"),
692  "zip",
693  Append_false);
694 
698  "local/"),
699  Append_false);
700  }
701 
702  logger->log("Init paths");
703  paths.init("paths.xml",
707  initPaths();
710 
711  if (desktop != nullptr)
713 
715  BLOCK_END("Client::gameExec State::LOAD_DATA")
716  break;
717  }
718  case State::START:
719  default:
721  break;
722  }
723  PRAGMA45(GCC diagnostic pop)
725  }
726  PROFILER_END();
727  }
728 
729  return 0;
730 }
Uint32 SDL_framerateDelay(FPSmanager *manager)
Delay execution to maintain a constant framerate and calculate fps.
const bool Append_false
Definition: append.h:30
volatile time_t cur_time
Definition: timer.cpp:58
Definition: client.h:50
static void initPaths()
Definition: client.cpp:850
void slowLogic()
Definition: client.cpp:829
void stateGame()
Definition: client.cpp:535
int gameExec()
Definition: client.cpp:577
void init(const std::string &filename, const UseVirtFs useResManager, const SkipError skipError)
void reloadWallpaper()
Definition: desktop.cpp:122
bool handleEvents() const
virtual void updateScreen()=0
void draw()
Definition: gui.cpp:470
void slowLogic()
Definition: gui.cpp:323
bool handleInput()
Definition: gui.cpp:388
std::string localDataDir
Definition: settings.h:112
std::string updatesDir
Definition: settings.h:110
static void loadCurrentLang()
static void loadDictionaryLang()
Configuration paths
void setPathsDefaults(Configuration &cfg)
Definition: defaults.cpp:550
Desktop * desktop
Definition: desktop.cpp:49
FPSmanager fpsManager
Graphics * mainGraphics
Definition: graphics.cpp:109
if(!vert) return
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
volatile int tick_time
Definition: timer.cpp:53
Definition: state.h:33
@ GET_CHARACTERS
Definition: state.h:46
@ LOAD_DATA
Definition: state.h:45
@ EXIT
Definition: state.h:67
void searchAndAddArchives(const std::string &path, const std::string &ext, const Append append)
Definition: tools.cpp:41
bool mountDir(std::string newDir, const Append append)
Definition: fs.cpp:393
#define PROFILER_END()
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
#define PROFILER_START()
Definition: perfomance.h:77
std::string empty
Definition: podict.cpp:26
const bool SkipError_false
Definition: skiperror.h:30
std::string pathJoin(std::string str1, const std::string &str2)
bool skipUpdate
Definition: options.h:95
volatile int logic_count
Definition: timer.cpp:57
volatile int frame_count
Definition: timer.cpp:56
const bool UseVirtFs_true
Definition: usevirtfs.h:30

References Append_false, BLOCK_END, BLOCK_START, cur_time, Options::dataPath, delete2, desktop, Gui::draw(), eventsManager, State::EXIT, State::FORCE_QUIT, fpsManager, frame_count, State::GAME, State::GET_CHARACTERS, WindowManager::getIsMinimized(), gui, EventsManager::handleEvents(), Gui::handleInput(), Configuration::init(), initPaths(), Settings::limitFps, State::LOAD_DATA, TranslationManager::loadCurrentLang(), TranslationManager::loadDictionaryLang(), Settings::localDataDir, Logger::log(), Logger::log1(), logger, Gui::logic(), SoundManager::logic(), logic_count, mainGraphics, mCurrentDialog, mOldState, VirtFs::mountDir(), mState, Settings::options, pathJoin(), paths, PRAGMA45(), PROFILER_END, PROFILER_START, Desktop::reloadWallpaper(), SDL_framerateDelay(), VirtFs::searchAndAddArchives(), setPathsDefaults(), settings, SkipError_false, Options::skipUpdate, Gui::slowLogic(), slowLogic(), soundManager, State::START, stateGame(), tick_time, Graphics::updateScreen(), Settings::updatesDir, and UseVirtFs_true.

Referenced by mainGui().

◆ gameExec() [2/2]

int Client::gameExec ( )

◆ gameInit() [1/2]

void Client::gameInit ( )

Definition at line 170 of file client.cpp.

171 {
172  logger = new Logger;
173  SDL::initLogger();
174 
175  initRand();
176 
177  // Load branding information
178  if (!settings.options.brandingPath.empty())
179  {
183  }
185 
188 
189  // Configure logger
190  if (!settings.options.logFileName.empty())
191  {
193  }
194  else
195  {
197  "manaplus.log");
198  }
200 
201 #ifdef USE_FUZZER
202  Fuzzer::init();
203 #endif // USE_FUZZER
204 
205  if (settings.options.test.empty())
206  ConfigManager::backupConfig("config.xml");
208  SDL::setLogLevel(config.getIntValue("sdlLogLevel"));
210  initPaths();
211  logger->log("init 4");
212  logger->setDebugLog(config.getBoolValue("debugLog"));
213  logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog"));
214 
215  config.incValue("runcount");
216 
217 #ifndef ANDROID
218  if (settings.options.test.empty())
220 #endif // ANDROID
221 
223  {
224  logger->error(strprintf("%s couldn't be set as home directory! "
225  "Exiting.", settings.localDataDir.c_str()));
226  }
227 
229 
230 /*
231  chatLogger = new ChatLogger;
232  if (settings.options.chatLogDir.empty())
233  {
234  chatLogger->setBaseLogDir(settings.localDataDir
235  + std::string("/logs/"));
236  }
237  else
238  {
239  chatLogger->setBaseLogDir(settings.options.chatLogDir);
240  }
241 */
242  // Log the client version
244  logger->log("Start configPath: " + config.getConfigPath());
245 
247 
248  // Initialize SDL
249  logger->log1("Initializing SDL...");
250  if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
251  {
252  logger->safeError(strprintf("Could not initialize SDL: %s",
253  SDL_GetError()));
254  }
255  atexit(SDL_Quit);
256 
257 #ifndef USE_SDL2
258  SDL_EnableUNICODE(1);
259 #endif // USE_SDL2
260 
264 
265 #ifdef WIN32
267 #endif // WIN32
268 #ifndef USE_SDL2
270 #endif // USE_SDL2
271 
273  logVars();
274  Cpu::detect();
276 #if defined(USE_OPENGL)
277 #if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__)
278  if (!settings.options.safeMode && settings.options.test.empty()
279  && !config.getBoolValue("videodetected"))
280  {
282  }
283 #endif // !defined(ANDROID) && !defined(__APPLE__) &&
284  // !defined(__native_client__)
285 #endif // defined(USE_OPENGL)
286 
287  updateEnv();
288  SDL::allowScreenSaver(config.getBoolValue("allowscreensaver"));
289  initGraphics();
290 
291 #ifndef WIN32
294 #endif // WIN32
295 
297 
298  // Add the main data directories to our VirtFs search path
299  if (!settings.options.dataPath.empty())
300  {
302  Append_false);
303  }
304 
305  // Add the local data directory to VirtFs search path
307  Append_false);
310 #ifdef ENABLE_CUSTOMNLS
311  TranslationManager::loadGettextLang();
312 #endif // ENABLE_CUSTOMNLS
313 
314 #ifdef USE_SDL2
316 #endif // USE_SDL2
318 
320 
321  theme = new Theme;
323  touchManager.init();
324 
325  // Initialize the item and emote shortcuts.
326 // for (size_t f = 0; f < SHORTCUT_TABS; f ++)
327 // itemShortcut[f] = new ItemShortcut(f);
328 // emoteShortcut = new EmoteShortcut;
329 // dropShortcut = new DropShortcut;
330 
331  gui = new Gui;
335 
337 
338  // Initialize keyboard
339  keyboard.init();
340  inputManager.init();
341 
342  // Initialise player relations
343  Joystick::init();
345 
346  keyboard.update();
347  if (joystick != nullptr)
348  joystick->update();
349 
350 // if (mState != State::ERROR)
351 // mState = State::CHOOSE_SERVER;
352 
353  startTimers();
354 
355  const int fpsLimit = config.getIntValue("fpslimit");
356  settings.limitFps = fpsLimit > 0;
357 
359  WindowManager::setFramerate(fpsLimit);
360 
361  start_time = time(nullptr);
362 
363 // PlayerInfo::init();
364 
365 #ifdef ANDROID
366 #ifndef USE_SDL2
367  WindowManager::updateScreenKeyboard(SDL_GetScreenKeyboardHeight(nullptr));
368 #endif // USE_SDL2
369 #endif // ANDROID
370 
371  mSkin = theme->load("windowmenu.xml",
372  "",
373  true,
375  if (mSkin != nullptr)
376  {
378  mButtonSpacing = mSkin->getOption("spacing", 3);
379  }
380 }
void SDL_initFramerate(FPSmanager *manager)
Initialize the framerate manager.
static void initGraphics()
Definition: client.cpp:413
static void logVars()
Definition: client.cpp:821
void initSoundManager()
Definition: client.cpp:390
static void backupConfig(const std::string &name)
static void storeSafeParameters()
static void checkConfigVersion()
static void initConfiguration()
bool getBoolValue(const std::string &key) const
const std::string & getConfigPath() const
void incValue(const std::string &key)
int getIntValue(const std::string &key) const
static void initRootDir()
Definition: dirs.cpp:266
static void initHomeDir()
Definition: dirs.cpp:330
static void initScreenshotDir()
Definition: dirs.cpp:544
static void extractDataDir()
Definition: dirs.cpp:179
static void mountDataDir()
Definition: dirs.cpp:198
static void updateDataPath()
Definition: dirs.cpp:161
static void initFunctions()
Definition: dyepalette.cpp:253
static void initLang()
virtual void postInit()
Definition: graphics.h:462
Definition: gui.h:117
void postInit(Graphics *const graphics)
Definition: gui.cpp:151
static void init()
Definition: joystick.cpp:73
void update()
Definition: joystick.cpp:359
Definition: logger.h:69
void safeError(const std::string &error_text) __attribute__((noreturn))
Definition: logger.cpp:435
void setReportUnimplemented(const bool n)
Definition: logger.h:184
void error(const std::string &error_text) __attribute__((noreturn))
Definition: logger.cpp:472
void setDebugLog(const bool n)
Definition: logger.h:181
void setLogFile(const std::string &logFilename)
Definition: logger.cpp:120
bool limitFps
Definition: settings.h:154
std::string logFileName
Definition: settings.h:122
int getOption(const std::string &name) const
Definition: skin.h:106
int getPadding() const
Definition: skin.h:100
Definition: theme.h:55
static std::string getThemePath()
Definition: theme.h:67
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:179
static void selectSkin()
Definition: theme.cpp:598
Configuration branding
void setBrandingDefaults(Configuration &cfg)
Definition: defaults.cpp:490
time_t start_time
Definition: client.cpp:135
void updateEnv()
Definition: env.cpp:30
GraphicsManager graphicsManager
#define FULL_VERSION
Definition: main.h:164
void initRand()
Definition: mrand.cpp:35
void detect()
Definition: cpu.cpp:46
void init()
Definition: playerinfo.cpp:434
void initLogger()
Definition: sdlhelper.cpp:187
void setLogLevel(const int level)
Definition: sdlhelper.cpp:191
void allowScreenSaver(const bool allow)
Definition: sdlhelper.cpp:210
bool setWriteDir(const std::string &newDir)
Definition: fs.cpp:331
void setFramerate(const unsigned int fpsLimit)
void updateScreenKeyboard(const int height)
std::string strprintf(const char *const format,...)
std::string brandingPath
Definition: options.h:79
bool safeMode
Definition: options.h:98
std::string test
Definition: options.h:88
std::string dataPath
Definition: options.h:81
std::string logFileName
Definition: options.h:83
Theme * theme
Definition: theme.cpp:62
void startTimers()
Definition: timer.cpp:113
const bool UseVirtFs_false
Definition: usevirtfs.h:30

References SDL::allowScreenSaver(), Append_false, WindowManager::applyKeyRepeat(), ConfigManager::backupConfig(), branding, Options::brandingPath, ConfigManager::checkConfigVersion(), config, WindowManager::createWindows(), Options::dataPath, Cpu::detect(), GraphicsManager::detectVideoSettings(), dialogsManager, EventsManager::enableEvents(), Logger::error(), eventsManager, Dirs::extractDataDir(), fpsManager, FULL_VERSION, Configuration::getBoolValue(), Configuration::getConfigPath(), Configuration::getIntValue(), Skin::getOption(), Skin::getPadding(), Theme::getThemePath(), graphicsManager, gui, Configuration::incValue(), PlayerInfo::init(), EventsManager::init(), InputManager::init(), Joystick::init(), KeyboardConfig::init(), TouchManager::init(), Configuration::init(), ConfigManager::initConfiguration(), DyePalette::initFunctions(), initGraphics(), Dirs::initHomeDir(), GettextHelper::initLang(), SDL::initLogger(), initPaths(), initRand(), Dirs::initRootDir(), Dirs::initScreenshotDir(), initSoundManager(), WindowManager::initTitle(), inputManager, joystick, keyboard, Settings::limitFps, Theme::load(), TranslationManager::loadCurrentLang(), TranslationManager::loadDictionaryLang(), Settings::localDataDir, Logger::log(), Logger::log1(), Options::logFileName, Settings::logFileName, logger, logVars(), mainGraphics, mButtonPadding, mButtonSpacing, Dirs::mountDataDir(), VirtFs::mountDir(), mSkin, Settings::options, pathJoin(), paths, popupManager, Graphics::postInit(), Gui::postInit(), Logger::safeError(), Options::safeMode, SDL_initFramerate(), Theme::selectSkin(), setBrandingDefaults(), Logger::setDebugLog(), WindowManager::setFramerate(), WindowManager::setIcon(), Logger::setLogFile(), SDL::setLogLevel(), setPathsDefaults(), Logger::setReportUnimplemented(), settings, VirtFs::setWriteDir(), SkipError_false, start_time, startTimers(), ConfigManager::storeSafeParameters(), strprintf(), Options::test, theme, touchManager, Joystick::update(), KeyboardConfig::update(), Dirs::updateDataPath(), updateEnv(), WindowManager::updateScreenKeyboard(), and UseVirtFs_false.

Referenced by mainGui().

◆ gameInit() [2/2]

void Client::gameInit ( )

◆ getCurrentServer()

ServerInfo& Client::getCurrentServer ( )
inline

Definition at line 98 of file client.h.

99  { return mCurrentServer; }
ServerInfo mCurrentServer
Definition: client.h:143

References mCurrentServer.

◆ getState() [1/2]

StateT Client::getState ( ) const
inline

◆ getState() [2/2]

StateT Client::getState ( ) const
inline

Definition at line 77 of file client.h.

78  { return mState; }

References mState.

◆ initConfigListeners()

void Client::initConfigListeners ( )
private

Definition at line 585 of file client.cpp.

586 {
587  config.addListener("fpslimit", this);
588  config.addListener("guialpha", this);
589  config.addListener("gamma", this);
590  config.addListener("enableGamma", this);
591  config.addListener("particleEmitterSkip", this);
592  config.addListener("vsync", this);
593  config.addListener("repeateDelay", this);
594  config.addListener("repeateInterval", this);
595  config.addListener("logInput", this);
596 }
void addListener(const std::string &key, ConfigListener *const listener)

References Configuration::addListener(), and config.

◆ initFeatures()

void Client::initFeatures ( )
staticprivate

Definition at line 1806 of file client.cpp.

1807 {
1808  features.init(paths.getStringValue("featuresFile"),
1810  SkipError_true);
1812  settings.fixDeadAnimation = features.getBoolValue("fixDeadAnimation");
1813 }
std::string getStringValue(const std::string &key) const
bool fixDeadAnimation
Definition: settings.h:160
Configuration features
void setFeaturesDefaults(Configuration &cfg)
Definition: defaults.cpp:752
const bool SkipError_true
Definition: skiperror.h:30

References features, Settings::fixDeadAnimation, Configuration::getBoolValue(), Configuration::getStringValue(), Configuration::init(), paths, setFeaturesDefaults(), settings, SkipError_true, and UseVirtFs_true.

Referenced by loadData(), and stateConnectServer1().

◆ initGraphics() [1/2]

void Client::initGraphics ( )
staticprivate

Definition at line 413 of file client.cpp.

414 {
415 #ifndef USE_SDL2
417 #endif // USE_SDL2
418 
419  runCounters = config.getBoolValue("packetcounters");
420 
422 
423 #ifdef USE_SDL2
425 #endif // USE_SDL2
426 
431 
433 }
virtual void beginDraw()
Definition: graphics.h:441
virtual void postInit()
Definition: imagehelper.h:110
void setConfigDefaults2(Configuration &cfg)
Definition: defaults.cpp:443
volatile bool runCounters
Definition: client.cpp:122
ImageHelper * imageHelper
Definition: imagehelper.cpp:44

References WindowManager::applyGamma(), WindowManager::applyGrabMode(), WindowManager::applyVSync(), Graphics::beginDraw(), config, Configuration::getBoolValue(), graphicsManager, imageHelper, GraphicsManager::initGraphics(), mainGraphics, ImageHelper::postInit(), runCounters, and setConfigDefaults2().

Referenced by gameInit().

◆ initGraphics() [2/2]

static void Client::initGraphics ( )
staticprivate

◆ initPaths() [1/2]

void Client::initPaths ( )
staticprivate

Definition at line 850 of file client.cpp.

851 {
852 }

Referenced by gameExec(), gameInit(), and loadData().

◆ initPaths() [2/2]

static void Client::initPaths ( )
staticprivate

◆ initSoundManager() [1/2]

void Client::initSoundManager ( )
private

Definition at line 390 of file client.cpp.

391 {
392  // Initialize sound engine
393  try
394  {
395  if (config.getBoolValue("sound"))
396  soundManager.init();
397 
400  }
401  catch (const char *const err)
402  {
404  errorMessage = err;
405  logger->log("Warning: %s", err);
406  }
408  "loginMusic",
409  "Magick - Real.ogg"),
411 }
std::string getValue(const std::string &key, const std::string &deflt) const
void playMusic(const std::string &fileName, const SkipError skipError)
void setSfxVolume(const int volume)
void setMusicVolume(const int volume)
std::string errorMessage
Definition: client.cpp:116
@ ERROR
Definition: state.h:35

References branding, config, State::ERROR, errorMessage, Configuration::getBoolValue(), Configuration::getIntValue(), ConfigurationObject::getValue(), SoundManager::init(), Logger::log(), logger, mState, SoundManager::playMusic(), SoundManager::setMusicVolume(), SoundManager::setSfxVolume(), SkipError_true, and soundManager.

Referenced by gameInit().

◆ initSoundManager() [2/2]

void Client::initSoundManager ( )
private

◆ initTradeFilter()

void Client::initTradeFilter ( )
static

Definition at line 1832 of file client.cpp.

1833 {
1834  const std::string tradeListName =
1835  settings.serverConfigDir + "/tradefilter.txt";
1836 
1837  std::ofstream tradeFile;
1838  struct stat statbuf;
1839 
1840  if ((stat(tradeListName.c_str(), &statbuf) != 0) ||
1841  !S_ISREG(statbuf.st_mode))
1842  {
1843  tradeFile.open(tradeListName.c_str(),
1844  std::ios::out);
1845  if (tradeFile.is_open())
1846  {
1847  tradeFile << ": sell" << std::endl;
1848  tradeFile << ": buy" << std::endl;
1849  tradeFile << ": trade" << std::endl;
1850  tradeFile << "i sell" << std::endl;
1851  tradeFile << "i buy" << std::endl;
1852  tradeFile << "i trade" << std::endl;
1853  tradeFile << "i trading" << std::endl;
1854  tradeFile << "i am buy" << std::endl;
1855  tradeFile << "i am sell" << std::endl;
1856  tradeFile << "i am trade" << std::endl;
1857  tradeFile << "i am trading" << std::endl;
1858  tradeFile << "i'm buy" << std::endl;
1859  tradeFile << "i'm sell" << std::endl;
1860  tradeFile << "i'm trade" << std::endl;
1861  tradeFile << "i'm trading" << std::endl;
1862  }
1863  else
1864  {
1865  reportAlways("Error opening file for writing: %s",
1866  tradeListName.c_str())
1867  }
1868  tradeFile.close();
1869  }
1870 }
#define reportAlways(...)
Definition: checkutils.h:253
std::string serverConfigDir
Definition: settings.h:117

References reportAlways, Settings::serverConfigDir, and settings.

Referenced by stateConnectServer1().

◆ isTmw() [1/2]

bool Client::isTmw ( )
static

Definition at line 838 of file client.cpp.

839 {
840  const std::string &name = settings.serverName;
841  if (name == "server.themanaworld.org"
842  || name == "themanaworld.org"
843  || name == "167.114.185.71")
844  {
845  return true;
846  }
847  return false;
848 }
std::string serverName
Definition: settings.h:114

References Settings::serverName, and settings.

Referenced by GuildManager::init(), ConfigManager::initServerConfig(), and EmoteDB::loadXmlFile().

◆ isTmw() [2/2]

static bool Client::isTmw ( )
static

◆ loadData()

void Client::loadData ( )
private

Definition at line 1980 of file client.cpp.

1981 {
1982  // If another data path has been set,
1983  // we don't load any other files...
1984  if (settings.options.dataPath.empty())
1985  {
1986  // Add customdata directory
1988  "customdata/",
1989  "zip",
1990  Append_false);
1991  }
1992 
1994  {
1996  settings.updatesDir + "/local/",
1997  "zip",
1998  Append_false);
1999 
2003  "local/"),
2004  Append_false);
2005  }
2006 
2007  logger->log("Init paths");
2008  paths.init("paths.xml",
2010  SkipError_false);
2012  initPaths();
2013  if (SpriteReference::Empty == nullptr)
2014  {
2016  paths.getStringValue("spriteErrorFile"),
2017  0);
2018  }
2019 
2020  if (BeingInfo::unknown == nullptr)
2022 
2023  initFeatures();
2027 
2030 
2031  delete spellManager;
2032  spellManager = new SpellManager;
2033  delete spellShortcut;
2035 
2037 
2039 
2040  if (desktop != nullptr)
2042 }
static void load()
static BeingInfo * unknown
Definition: beinginfo.h:56
static void initFeatures()
Definition: client.cpp:1806
static void prepareSlotNames()
void loadDb()
Definition: dbmanager.cpp:63
void stateChange(const StateT state)
Definition: playerinfo.cpp:470
SpellManager * spellManager
SpellShortcut * spellShortcut
static SpriteReference * Empty

References Append_false, Options::dataPath, desktop, SpriteReference::Empty, Configuration::getStringValue(), AttributesEnum::init(), Configuration::init(), initFeatures(), initPaths(), ActorSprite::load(), TranslationManager::loadCurrentLang(), DbManager::loadDb(), TranslationManager::loadDictionaryLang(), Settings::localDataDir, Logger::log(), logger, VirtFs::mountDir(), mState, Settings::options, pathJoin(), paths, EquipmentWindow::prepareSlotNames(), Desktop::reloadWallpaper(), VirtFs::searchAndAddArchives(), setPathsDefaults(), settings, SkipError_false, Options::skipUpdate, spellManager, spellShortcut, PlayerInfo::stateChange(), BeingInfo::unknown, Settings::updatesDir, and UseVirtFs_true.

Referenced by runValidate().

◆ logVars() [1/2]

void Client::logVars ( )
staticprivate

Definition at line 821 of file client.cpp.

822 {
823 #ifdef ANDROID
824  logger->log("APPDIR: %s", getenv("APPDIR"));
825  logger->log("DATADIR2: %s", getSdStoragePath().c_str());
826 #endif // ANDROID
827 }

References Logger::log(), and logger.

Referenced by gameInit().

◆ logVars() [2/2]

static void Client::logVars ( )
staticprivate

◆ moveButtons() [1/2]

void Client::moveButtons ( const int  width)

Definition at line 774 of file client.cpp.

775 {
776  if (mSetupButton != nullptr)
777  {
778  int x = width - mSetupButton->getWidth() - mButtonPadding;
780 #ifndef WIN32
783 
786 
789 
792 
795 #ifdef ANDROID
796  x -= mCloseButton->getWidth() + mButtonSpacing;
797  mCloseButton->setPosition(x, mButtonPadding);
798 #endif // ANDROID
799 #endif // WIN32
800  }
801 }
void setPosition(const int x, const int y)
Definition: widget.cpp:161
int getWidth() const
Definition: widget.h:221

References Widget::getWidth(), mAboutButton, mButtonPadding, mButtonSpacing, mHelpButton, mPerfomanceButton, mSetupButton, mThemesButton, mVideoButton, Widget::setPosition(), and x.

Referenced by WindowManager::resizeVideo().

◆ moveButtons() [2/2]

void Client::moveButtons ( const int  width)

◆ optionChanged()

void Client::optionChanged ( const std::string &  name)
virtual

Called when an option changed. The config listener will have to be registered to the option name first.

Implements ConfigListener.

Definition at line 1715 of file client.cpp.

1716 {
1717  if (name == "fpslimit")
1718  {
1719  const int fpsLimit = config.getIntValue("fpslimit");
1720  settings.limitFps = fpsLimit > 0;
1721  WindowManager::setFramerate(fpsLimit);
1722  }
1723  else if (name == "guialpha" ||
1724  name == "enableGuiOpacity")
1725  {
1726  const float alpha = config.getFloatValue("guialpha");
1727  settings.guiAlpha = alpha;
1728  ImageHelper::setEnableAlpha(alpha != 1.0F &&
1729  config.getBoolValue("enableGuiOpacity"));
1730  }
1731  else if (name == "gamma" ||
1732  name == "enableGamma")
1733  {
1735  }
1736  else if (name == "particleEmitterSkip")
1737  {
1739  config.getIntValue("particleEmitterSkip") + 1;
1740  }
1741  else if (name == "vsync")
1742  {
1744  }
1745  else if (name == "repeateInterval" ||
1746  name == "repeateDelay")
1747  {
1749  }
1750 }
float getFloatValue(const std::string &key) const
static void setEnableAlpha(const bool n)
Definition: imagehelper.h:98
static int emitterSkip
float guiAlpha
Definition: settings.h:131

References WindowManager::applyGamma(), WindowManager::applyKeyRepeat(), WindowManager::applyVSync(), config, ParticleEngine::emitterSkip, Configuration::getBoolValue(), Configuration::getFloatValue(), Configuration::getIntValue(), Settings::guiAlpha, Settings::limitFps, ImageHelper::setEnableAlpha(), WindowManager::setFramerate(), and settings.

◆ runValidate()

void Client::runValidate ( )
private

Definition at line 2088 of file client.cpp.

2089 {
2090  loadData();
2092 
2094  unloadData();
2095  delete2(client)
2096  VirtFs::deinit();
2097  exit(0);
2098 }
void loadData()
Definition: client.cpp:1980
void unloadData()
Definition: client.cpp:2044
Client * client
Definition: client.cpp:118
void deleteValidateWindows()
void createValidateWindows()

References client, WindowManager::createValidateWindows(), VirtFs::deinit(), delete2, WindowManager::deleteValidateWindows(), loadData(), and unloadData().

◆ setState() [1/2]

void Client::setState ( const StateT  state)
inline

Definition at line 66 of file client.h.

67  { mState = state; }

References mState.

Referenced by ChangeEmailDialog::action(), ChangePasswordDialog::action(), CharSelectDialog::action(), ConnectionDialog::action(), LoginDialog::action(), QuitDialog::action(), RegisterDialog::action(), UpdaterWindow::action(), WorldSelectDialog::action(), ChangePincodeListener::action(), ErrorListener::action(), NewPincodeListener::action(), PincodeListener::action(), action(), anonymous_namespace{client.cpp}::AccountListener::action(), anonymous_namespace{client.cpp}::LoginListener::action(), Ea::LoginHandler::chooseServer(), CharSelectDialog::close(), LoginDialog::close(), RegisterDialog::close(), ServerDialog::close(), EAthena::LoginHandler::connect(), ServerDialog::connectToSelectedServer(), UpdaterWindow::enable(), EAthena::GeneralHandler::flushNetwork(), TmwAthena::GeneralHandler::flushNetwork(), Ea::LoginHandler::getRegistrationDetails(), EventsManager::handleActive(), EventsManager::handleCommonEvents(), EventsManager::handleEvents(), Dirs::initUpdatesDir(), ServerDialog::keyPressed(), UpdaterWindow::keyPressed(), EAthena::CharServerRecv::processChangeMapServer(), TmwAthena::CharServerRecv::processChangeMapServer(), EAthena::CharServerRecv::processCharCharacters(), EAthena::CharServerRecv::processCharLogin(), TmwAthena::CharServerRecv::processCharLogin(), Ea::CharServerRecv::processCharLoginError(), EAthena::CharServerRecv::processCharMapInfo(), TmwAthena::CharServerRecv::processCharMapInfo(), EAthena::LoginRecv::processCharPasswordResponse(), TmwAthena::LoginRecv::processCharPasswordResponse(), Ea::GameRecv::processCharSwitchResponse(), EAthena::GeneralRecv::processConnectionProblem(), TmwAthena::GeneralRecv::processConnectionProblem(), EAthena::LoginRecv::processLoginData(), TmwAthena::LoginRecv::processLoginData(), Ea::LoginRecv::processLoginError(), EAthena::LoginRecv::processLoginError2(), EAthena::GameRecv::processMapLogin(), TmwAthena::GameRecv::processMapLogin(), EAthena::GeneralRecv::processMapNotFound(), EAthena::LoginRecv::processServerVersion(), TmwAthena::LoginRecv::processServerVersion(), and EAthena::LoginRecv::processUpdateHost2().

◆ setState() [2/2]

void Client::setState ( const StateT  state)
inline

Definition at line 74 of file client.h.

75  { mState = state; }

References mState.

◆ slowLogic() [1/2]

void Client::slowLogic ( )

Definition at line 829 of file client.cpp.

830 {
831 }

Referenced by gameExec().

◆ slowLogic() [2/2]

void Client::slowLogic ( )

◆ stateConnectGame1()

void Client::stateConnectGame1 ( )
staticprivate

Definition at line 806 of file client.cpp.

807 {
808  if ((gameHandler != nullptr) &&
809  (loginHandler != nullptr) &&
811  {
813  }
814 }
virtual bool isConnected() const =0
virtual void disconnect() const =0
Net::GameHandler * gameHandler
Definition: net.cpp:91
Net::LoginHandler * loginHandler
Definition: net.cpp:90

References Net::LoginHandler::disconnect(), gameHandler, Net::GameHandler::isConnected(), and loginHandler.

◆ stateConnectServer1()

void Client::stateConnectServer1 ( )
private

Definition at line 816 of file client.cpp.

817 {
819  {
823  initTradeFilter();
826 
827  // Initialize the item and emote shortcuts.
828  for (unsigned f = 0; f < SHORTCUT_TABS; f ++)
829  {
830  delete itemShortcut[f];
831  itemShortcut[f] = new ItemShortcut(f);
832  }
833  delete emoteShortcut;
835 
836  // Initialize the drop shortcuts.
837  delete dropShortcut;
839 
840  initFeatures();
844  if (!mCurrentServer.onlineListUrl.empty())
846  else
852  "enableRemoteCommands", 1) != 0);
853 
854  if (settings.options.username.empty())
855  {
856  if (loginData.remember)
857  loginData.username = serverConfig.getValue("username", "");
858  else
859  loginData.username.clear();
860  }
861  else
862  {
864  }
865 #ifdef SAVE_PASSWORD
867  serverConfig.getValue("password", "") : "";
870 #endif
873 
874  loginData.remember = (serverConfig.getValue("remember", 1) != 0);
876 
877 #ifdef USE_MUMBLE
878  if (mumbleManager)
879  mumbleManager->setServer(mCurrentServer.hostname);
880 #endif // USE_MUMBLE
881 
882 #ifdef TMWA_SUPPORT
884 #endif // TMWA_SUPPORT
885 
886  if (!mConfigAutoSaved)
887  {
888  mConfigAutoSaved = true;
889  config.write();
890  }
891  }
892  else if (loginHandler != nullptr &&
894  {
896  }
897 }
static void initTradeFilter()
Definition: client.cpp:1832
bool mConfigAutoSaved
Definition: client.h:165
static void initServerConfig(const std::string &serverName)
static void initUsersDir()
Definition: dirs.cpp:599
static void init()
std::string registerUrl
Definition: logindata.h:69
int packetVersion
Definition: logindata.h:73
std::string username
Definition: logindata.h:59
std::string password
Definition: logindata.h:60
bool remember
Definition: logindata.h:74
static std::string savedPassword
Definition: logindialog.h:80
virtual bool isConnected() const =0
std::string hostname
Definition: serverinfo.h:45
std::vector< std::string > updateMirrors
Definition: serverinfo.h:53
std::string supportUrl
Definition: serverinfo.h:50
std::string onlineListUrl
Definition: serverinfo.h:49
int packetVersion
Definition: serverinfo.h:60
bool persistentIp
Definition: serverinfo.h:62
std::string registerUrl
Definition: serverinfo.h:48
std::string onlineListUrl
Definition: settings.h:116
bool persistentIp
Definition: settings.h:153
bool enableRemoteCommands
Definition: settings.h:162
std::vector< std::string > updateMirrors
Definition: settings.h:129
std::string supportUrl
Definition: settings.h:121
std::string login
Definition: settings.h:108
const unsigned int SHORTCUT_TABS
Definition: itemshortcut.h:28
DropShortcut * dropShortcut
EmoteShortcut * emoteShortcut
ItemShortcut * itemShortcut[SHORTCUT_TABS]
LoginData loginData
Definition: client.cpp:185
void connectToServer(const ServerInfo &server)
Definition: net.cpp:130
void initPacketLimiter()
void loadData()
Definition: playerinfo.cpp:445
@ CHOOSE_SERVER
Definition: state.h:37
@ PRE_LOGIN
Definition: state.h:39
PlayerRelationsManager playerRelations
std::string password
Definition: options.h:77
std::string username
Definition: options.h:76

References State::CHOOSE_SERVER, config, Net::connectToServer(), dropShortcut, emoteShortcut, Settings::enableRemoteCommands, ConfigurationObject::getValue(), ServerInfo::hostname, PlayerRelationsManager::init(), GuildManager::init(), initFeatures(), PacketLimiter::initPacketLimiter(), ConfigManager::initServerConfig(), initTradeFilter(), Dirs::initUsersDir(), Net::LoginHandler::isConnected(), itemShortcut, PlayerInfo::loadData(), Settings::login, loginData, loginHandler, mConfigAutoSaved, mCurrentServer, mOldState, mState, ServerInfo::onlineListUrl, Settings::onlineListUrl, Settings::options, LoginData::packetVersion, ServerInfo::packetVersion, LoginData::password, Options::password, ServerInfo::persistentIp, Settings::persistentIp, playerRelations, State::PRE_LOGIN, LoginData::registerUrl, ServerInfo::registerUrl, LoginData::remember, LoginDialog::savedPassword, serverConfig, Settings::serverName, settings, SHORTCUT_TABS, ServerInfo::supportUrl, Settings::supportUrl, ServerInfo::updateMirrors, Settings::updateMirrors, WindowManager::updateTitle(), LoginData::username, Options::username, and Configuration::write().

◆ stateGame()

void Client::stateGame ( )
private

Definition at line 535 of file client.cpp.

536 {
537  if (gui == nullptr)
538  return;
539 
540  BasicContainer2 *const top = static_cast<BasicContainer2*>(
541  gui->getTop());
542 
543  if (top == nullptr)
544  return;
545 
546  CREATEWIDGETV(desktop, Desktop, nullptr);
547  top->add(desktop);
548  int x = top->getWidth() - mButtonPadding;
550  // TRANSLATORS: setup tab quick button
551  _("Setup"), "Setup", BUTTON_SKIN, this))
553  // TRANSLATORS: perfoamance tab quick button
554  _("Performance"), "Perfomance", BUTTON_SKIN, this))
556  // TRANSLATORS: video tab quick button
557  _("Video"), "Video", BUTTON_SKIN, this))
559  // TRANSLATORS: theme tab quick button
560  _("Theme"), "Themes", BUTTON_SKIN, this))
562  // TRANSLATORS: theme tab quick button
563  _("About"), "about", BUTTON_SKIN, this))
565  // TRANSLATORS: theme tab quick button
566  _("Help"), "help", BUTTON_SKIN, this))
567 #ifdef ANDROID
568  ADDBUTTON(mCloseButton, new Button(desktop,
569  // TRANSLATORS: close quick button
570  _("Close"), "close", BUTTON_SKIN, this))
571 #endif // ANDROID
572 
575 }
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
int getHeight() const
Definition: graphics.cpp:648
int getWidth() const
Definition: graphics.cpp:643
Widget * getTop() const
Definition: gui.h:248
void setSize(const int width, const int height)
Definition: widget.cpp:367
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:25
#define new
Definition: debug_new.h:147
#define ADDBUTTON(var, object)
Definition: client.cpp:530
#define _(s)
Definition: gettext.h:35
const Image *restrict const top

References _, ADDBUTTON, BUTTON_SKIN, CREATEWIDGETV, desktop, Graphics::getHeight(), Gui::getTop(), Graphics::getWidth(), gui, mAboutButton, mainGraphics, mButtonPadding, mHelpButton, mPerfomanceButton, mSetupButton, mThemesButton, mVideoButton, Widget::setSize(), top, and x.

Referenced by gameExec().

◆ stateGame1()

void Client::stateGame1 ( )
private

Definition at line 909 of file client.cpp.

910 {
911  if (gui == nullptr)
912  return;
913 
914  BasicContainer2 *const top = static_cast<BasicContainer2*>(
915  gui->getTop());
916 
917  if (top == nullptr)
918  return;
919 
920  CREATEWIDGETV(desktop, Desktop, nullptr);
921  top->add(desktop);
922  int x = top->getWidth() - mButtonPadding;
924  // TRANSLATORS: setup tab quick button
925  _("Setup"), "Setup", BUTTON_SKIN, this))
927  // TRANSLATORS: perfoamance tab quick button
928  _("Performance"), "Perfomance", BUTTON_SKIN, this))
930  // TRANSLATORS: video tab quick button
931  _("Video"), "Video", BUTTON_SKIN, this))
933  // TRANSLATORS: theme tab quick button
934  _("Theme"), "Themes", BUTTON_SKIN, this))
936  // TRANSLATORS: theme tab quick button
937  _("About"), "about", BUTTON_SKIN, this))
939  // TRANSLATORS: theme tab quick button
940  _("Help"), "help", BUTTON_SKIN, this))
941 #ifdef ANDROID
942  ADDBUTTON(mCloseButton, new Button(desktop,
943  // TRANSLATORS: close quick button
944  _("Close"), "close", BUTTON_SKIN, this))
945 #endif // ANDROID
946 
949 }
#define ADDBUTTON(var, object)
Definition: client.cpp:801

References _, ADDBUTTON, BUTTON_SKIN, CREATEWIDGETV, desktop, Graphics::getHeight(), Gui::getTop(), Graphics::getWidth(), gui, mAboutButton, mainGraphics, mButtonPadding, mHelpButton, mPerfomanceButton, mSetupButton, mThemesButton, mVideoButton, Widget::setSize(), top, and x.

◆ stateSwitchLogin1()

void Client::stateSwitchLogin1 ( )
private

Definition at line 951 of file client.cpp.

952 {
953  if (mOldState == State::GAME &&
954  (gameHandler != nullptr))
955  {
957  }
958 }
virtual void disconnect() const =0

References Net::GameHandler::disconnect(), State::GAME, gameHandler, and mOldState.

◆ stateWorldSelect1()

void Client::stateWorldSelect1 ( )
private

Definition at line 899 of file client.cpp.

900 {
901  if (mOldState == State::UPDATE &&
902  (loginHandler != nullptr))
903  {
904  if (loginHandler->getWorlds().size() < 2)
906  }
907 }
virtual const Worlds & getWorlds() const =0
@ UPDATE
Definition: state.h:44

References Net::LoginHandler::getWorlds(), loginHandler, mOldState, mState, State::PRE_LOGIN, and State::UPDATE.

◆ testsClear() [1/2]

void Client::testsClear ( )
private

Definition at line 165 of file client.cpp.

166 {
167 }

Referenced by ~Client().

◆ testsClear() [2/2]

void Client::testsClear ( )
private

◆ testsExec() [1/2]

int Client::testsExec ( )
static

Definition at line 833 of file client.cpp.

834 {
835  return 0;
836 }

Referenced by mainGui().

◆ testsExec() [2/2]

static int Client::testsExec ( )
static

◆ testsInit() [1/2]

void Client::testsInit ( )

Definition at line 161 of file client.cpp.

162 {
163 }

Referenced by mainGui().

◆ testsInit() [2/2]

void Client::testsInit ( )

◆ unloadData()

void Client::unloadData ( )
private

Definition at line 2044 of file client.cpp.

2045 {
2047  mCurrentServer.supportUrl.clear();
2048  settings.supportUrl.clear();
2049  if (settings.options.dataPath.empty())
2050  {
2051  // Add customdata directory
2053  "customdata/",
2054  "zip");
2055  }
2056 
2057  if (!settings.oldUpdates.empty())
2058  {
2060  settings.oldUpdates.clear();
2061  }
2062 
2064  {
2066  pathJoin(settings.updatesDir, "local/"),
2067  "zip");
2068 
2072  "local/"));
2073  }
2074 
2076 
2078  localClan.clear();
2079  serverVersion = 0;
2080  packetVersion = 0;
2081  packetVersionMain = 0;
2082  packetVersionRe = 0;
2083  packetVersionZero = 0;
2084  tmwServerVersion = 0;
2085  evolPacketOffset = 0;
2086 }
void clearUpdateHost()
Definition: logindata.h:96
std::string oldUpdates
Definition: settings.h:109
static void unloadUpdates(const std::string &dir)
unsigned int tmwServerVersion
Definition: client.cpp:134
int serverVersion
Definition: client.cpp:124
int packetVersionRe
Definition: client.cpp:127
int packetVersionMain
Definition: client.cpp:126
int packetVersionZero
Definition: client.cpp:128
int packetVersion
Definition: client.cpp:125
LocalClan localClan
Definition: localclan.cpp:26
int evolPacketOffset
Definition: net.cpp:40
void unloadDb()
Definition: dbmanager.cpp:106
bool unmountDirSilent(std::string oldDir)
Definition: fs.cpp:554
void searchAndRemoveArchives(const std::string &path, const std::string &ext)
Definition: tools.cpp:62
void clear()
Definition: localclan.h:48

References LocalClan::clear(), ResourceManager::clearCache(), LoginData::clearUpdateHost(), Options::dataPath, evolPacketOffset, localClan, Settings::localDataDir, loginData, mCurrentServer, Settings::oldUpdates, Settings::options, packetVersion, packetVersionMain, packetVersionRe, packetVersionZero, pathJoin(), VirtFs::searchAndRemoveArchives(), serverVersion, settings, Options::skipUpdate, ServerInfo::supportUrl, Settings::supportUrl, tmwServerVersion, DbManager::unloadDb(), UpdaterWindow::unloadUpdates(), VirtFs::unmountDirSilent(), and Settings::updatesDir.

Referenced by runValidate().

◆ updatePinState() [1/2]

void Client::updatePinState ( )

Definition at line 817 of file client.cpp.

818 {
819 }

Referenced by PincodeManager::processPincodeStatus().

◆ updatePinState() [2/2]

void Client::updatePinState ( )

◆ windowRemoved() [1/2]

void Client::windowRemoved ( const Window *const  window)

Definition at line 803 of file client.cpp.

804 {
805  if (mCurrentDialog == window)
806  mCurrentDialog = nullptr;
807 }

References mCurrentDialog.

Referenced by Window::~Window().

◆ windowRemoved() [2/2]

void Client::windowRemoved ( const Window *const  window)

Field Documentation

◆ mAboutButton

Button * Client::mAboutButton
private

Definition at line 105 of file client.h.

Referenced by moveButtons(), stateGame(), and stateGame1().

◆ mButtonPadding

int Client::mButtonPadding
private

Definition at line 116 of file client.h.

Referenced by gameInit(), moveButtons(), stateGame(), and stateGame1().

◆ mButtonSpacing

int Client::mButtonSpacing
private

Definition at line 117 of file client.h.

Referenced by gameInit(), and moveButtons().

◆ mConfigAutoSaved

bool Client::mConfigAutoSaved
private

Definition at line 165 of file client.h.

Referenced by stateConnectServer1().

◆ mCurrentDialog

Window * Client::mCurrentDialog
private

Definition at line 101 of file client.h.

Referenced by focusWindow(), gameClear(), gameExec(), and windowRemoved().

◆ mCurrentServer

ServerInfo Client::mCurrentServer
private

Definition at line 143 of file client.h.

Referenced by getCurrentServer(), stateConnectServer1(), and unloadData().

◆ mGame

Game* Client::mGame
private

Definition at line 145 of file client.h.

◆ mHelpButton

Button * Client::mHelpButton
private

Definition at line 104 of file client.h.

Referenced by moveButtons(), stateGame(), and stateGame1().

◆ mOldState

StateT Client::mOldState
private

Definition at line 113 of file client.h.

Referenced by gameExec(), stateConnectServer1(), stateSwitchLogin1(), and stateWorldSelect1().

◆ mPerfomanceButton

Button * Client::mPerfomanceButton
private

Definition at line 107 of file client.h.

Referenced by moveButtons(), stateGame(), and stateGame1().

◆ mPing

int Client::mPing
private

Definition at line 164 of file client.h.

◆ mQuitDialog

QuitDialog* Client::mQuitDialog
private

Definition at line 147 of file client.h.

◆ mSetupButton

Button * Client::mSetupButton
private

Definition at line 102 of file client.h.

Referenced by moveButtons(), stateGame(), and stateGame1().

◆ mSkin

Skin * Client::mSkin
private

Definition at line 115 of file client.h.

Referenced by gameInit().

◆ mState

StateT Client::mState
private

◆ mThemesButton

Button * Client::mThemesButton
private

Definition at line 106 of file client.h.

Referenced by moveButtons(), stateGame(), and stateGame1().

◆ mVideoButton

Button * Client::mVideoButton
private

Definition at line 103 of file client.h.

Referenced by moveButtons(), stateGame(), and stateGame1().


The documentation for this class was generated from the following files: