Skip to content

Commit

Permalink
Removed server browser for FLTK-based main window
Browse files Browse the repository at this point in the history
  • Loading branch information
yvt committed Feb 24, 2014
1 parent 7cbba74 commit 4cf2fd3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 430 deletions.
6 changes: 0 additions & 6 deletions OpenSpades.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
E842889618A667930060743D /* Fonts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E842889418A667930060743D /* Fonts.cpp */; };
E844886217CFB32C005105D0 /* GLLongSpriteRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E844886017CFB32B005105D0 /* GLLongSpriteRenderer.cpp */; };
E844886617D0C43B005105D0 /* Tracer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E844886417D0C43B005105D0 /* Tracer.cpp */; };
E844886A17D262E4005105D0 /* Serverbrowser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E844886817D262E3005105D0 /* Serverbrowser.cpp */; };
E844888217D2633C005105D0 /* json_reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E844887B17D2633C005105D0 /* json_reader.cpp */; };
E844888317D2633C005105D0 /* json_value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E844887C17D2633C005105D0 /* json_value.cpp */; };
E844888417D2633C005105D0 /* json_writer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E844887E17D2633C005105D0 /* json_writer.cpp */; };
Expand Down Expand Up @@ -395,8 +394,6 @@
E844886417D0C43B005105D0 /* Tracer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Tracer.cpp; sourceTree = "<group>"; };
E844886517D0C43B005105D0 /* Tracer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tracer.h; sourceTree = "<group>"; };
E844886717D262C1005105D0 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
E844886817D262E3005105D0 /* Serverbrowser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Serverbrowser.cpp; sourceTree = "<group>"; };
E844886917D262E4005105D0 /* Serverbrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Serverbrowser.h; sourceTree = "<group>"; };
E844886D17D2633C005105D0 /* AUTHORS */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AUTHORS; sourceTree = "<group>"; };
E844887017D2633C005105D0 /* autolink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autolink.h; sourceTree = "<group>"; };
E844887117D2633C005105D0 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1375,8 +1372,6 @@
children = (
E8F74CEC183F931F0085AA54 /* SDLMain.h */,
E8F74CEA183F92DA0085AA54 /* SDLmain.m */,
E844886817D262E3005105D0 /* Serverbrowser.cpp */,
E844886917D262E4005105D0 /* Serverbrowser.h */,
E8CF03BE178EE50E000683D4 /* Main.cpp */,
E8F74CE6183F8A110085AA54 /* Main.h */,
E8CF03BB178EE502000683D4 /* SDLGLDevice.cpp */,
Expand Down Expand Up @@ -1967,7 +1962,6 @@
E81A7C6718610BE400BF3FCE /* SWPort.cpp in Sources */,
E844886217CFB32C005105D0 /* GLLongSpriteRenderer.cpp in Sources */,
E844886617D0C43B005105D0 /* Tracer.cpp in Sources */,
E844886A17D262E4005105D0 /* Serverbrowser.cpp in Sources */,
E844888217D2633C005105D0 /* json_reader.cpp in Sources */,
E844888317D2633C005105D0 /* json_value.cpp in Sources */,
E844888417D2633C005105D0 /* json_writer.cpp in Sources */,
Expand Down
59 changes: 57 additions & 2 deletions Sources/Gui/MainScreenHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright (c) 2013 yvt
Portion of the code is based on Serverbrowser.cpp.
Portion of the code is based on Serverbrowser.cpp (Copyright (c) 2013 learn_more).
This file is part of OpenSpades.
Expand All @@ -20,7 +21,6 @@
*/
#include <OpenSpades.h>
#include "MainScreenHelper.h"
#include "Serverbrowser.h"
#include <Core/AutoLocker.h>
#include <Core/Thread.h>
#include <curl/curl.h>
Expand All @@ -33,8 +33,63 @@
SPADES_SETTING(cl_serverListUrl, "http://services.buildandshoot.com/serverlist.json");

namespace spades {

class Serveritem
{
//NetClient::Connect
std::string mName, mIp, mMap, mGameMode;
std::string mCountry, mVersion;
int mPing, mPlayers, mMaxPlayers;

Serveritem( const std::string& name, const std::string& ip, const std::string& map, const std::string& gameMode, const std::string& country, const std::string& version,
int ping, int players, int maxPlayers );
public:
static Serveritem* create( Json::Value& val );

inline const std::string& Name() const { return mName; }
inline const std::string& Ip() const { return mIp; }
inline const std::string& Map() const { return mMap; }
inline const std::string& GameMode() const { return mGameMode; }
inline const std::string& Country() const { return mCountry; }
inline const std::string& Version() const { return mVersion; }
inline int Ping() const { return mPing; }
inline int Players() const { return mPlayers; }
inline int MaxPlayers() const { return mMaxPlayers; }
};


Serveritem::Serveritem( const std::string& name, const std::string& ip, const std::string& map, const std::string& gameMode, const std::string& country, const std::string& version, int ping, int players, int maxPlayers )
: mName(name), mIp(ip), mMap(map), mGameMode(gameMode), mCountry(country), mVersion(version), mPing(ping), mPlayers(players), mMaxPlayers(maxPlayers)
{
}

Serveritem* Serveritem::create( Json::Value& val )
{
Serveritem* item = NULL;
if( val.type() == Json::objectValue ) {
std::string name, ip, map, gameMode, country, version;
int ping = 0, players = 0, maxPlayers = 0;

name = val["name"].asString();
ip = val["identifier"].asString();
map = val["map"].asString();
gameMode = val["game_mode"].asString();
country = val["country"].asString();
version = val["game_version"].asString();

ping = val["latency"].asInt();
players = val["players_current"].asInt();
maxPlayers = val["players_max"].asInt();
item = new Serveritem( name, ip, map, gameMode, country, version, ping, players, maxPlayers );
}
return item;
}



namespace gui {


// FIXME: mostly duplicated code with Serverbrowser.cpp
class MainScreenHelper::ServerListQuery: public Thread {
Mutex infoLock;
Expand Down
Loading

0 comments on commit 4cf2fd3

Please sign in to comment.