/** \file client.cpp * Client prototype * * $Id: client.cpp,v 1.9 2000/11/28 13:21:23 coutelas Exp $ */ /* Copyright, 2000 Nevrax Ltd. * * This file is part of NEVRAX NEL. * NEVRAX NEL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * NEVRAX NEL is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * You should have received a copy of the GNU General Public License * along with NEVRAX NEL; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ #include "nel/misc/types_nl.h" #include "nel/misc/debug.h" #include "nel/misc/i18n.h" #include "nel/net/msg_socket.h" #include "nel/net/naming_client.h" #include "nel/net/unitime.h" #include "nel/3d/driver.h" #include "language_interface.h" #include "login_interface.h" #include "shards_list_interface.h" #include using namespace std; using namespace NLNET; using namespace NLMISC; using namespace NL3D; #ifdef NL_OS_WINDOWS CFontGenerator fontGen("\\\\server\\code\\fonts\\arialuni.ttf"); #else CFontGenerator fontGen("arialuni.ttf"); #endif /** * login */ sint8 login(NL3D::CScene * scene, NL3D::CFontGenerator * fontGenerator, uint w, uint h, vector& shards) { CLoginInterface logscreen(scene, fontGenerator, w, h); return logscreen.log(shards); } /** * chooseLanguage */ sint chooseLanguage(NL3D::CScene * scene, NL3D::CFontGenerator * fontGenerator, uint w, uint h) { CLanguageInterface languageScreen(scene, fontGenerator, w, h); return languageScreen.choose(); } /** * chooseShard */ sint chooseShard(NL3D::CScene * scene, NL3D::CFontGenerator * fontGenerator, uint w, uint h, const std::vector& shards) { CShardsListInterface shardListScreen(scene, fontGenerator, w, h, shards); return shardListScreen.choose(); } enum TState { LANGUAGE, LOGIN, SHARD }; /****************************************************************\ MAIN \****************************************************************/ void main() { try { // init scene uint w = 800; uint h = 600; uint bpp = 32; bool windowed = false;//true; NL3D::CScene scene; NL3D::CSceneUt::init3d(scene, w, h, bpp, windowed); // synchronize time with server CUniTime::syncUniTimeFromService(); // user id (login & password) CLogUserId id; //shard's name list vector shards; // index of chard in the list sint shardIndex; TState clientState = LANGUAGE; bool quit = false; while(!quit) { switch(clientState) { // language choice case LANGUAGE: { sint languageIndex = chooseLanguage(&scene, &fontGen, w, h); if(languageIndex==-1) quit = true; else { CI18N::load(languageIndex); clientState = LOGIN; } } break; // get user's login and password case LOGIN: { if(login(&scene, &fontGen, w, h, shards)) clientState = SHARD; else clientState = LANGUAGE; } break; // shard choice case SHARD: { shardIndex = chooseShard(&scene, &fontGen, w, h, shards); if(shardIndex==-1) clientState = LOGIN; else quit = true; } break; } if(quit) break; } // release scene NL3D::CSceneUt::release3d(scene); } catch(Exception &e) { nlerror ("main(): Exception trapped: %s", e.what ()); } }