Files

142 lines
3.3 KiB
C
Raw Permalink Normal View History

2026-03-03 13:56:44 +08:00
#ifndef _GLOBAL_JOSN_H_
#define _GLOBAL_JOSN_H_
#include <string>
#include <vector>
#include <mutex>
#include "Define.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#define DEFINE_REFRESH_TIME 10 // 默认刷新时间
#else
#define DEFINE_REFRESH_TIME 60 // 默认刷新时间
#endif
/*
* JOSN文件配置;
*/
struct tagGameConfig
{
int nGameKindId; // kind_id;
bool bGameActive; // 是否激活游戏;
bool bAddToList; // 是否加入列表;
std::string strGamename; // 游戏名;
std::string strGameRule; // 游戏规则;
std::string strComment; // 备注;
tagGameConfig()
{
strGamename = "";
nGameKindId = -1;
bGameActive = false;
strComment = "";
}
};
// 游戏中用的可变的文字信息
struct tagShareInfo
{
int nKindID; // ID
std::string strComment; // 备注;
tagShareInfo()
{
nKindID = 0;
strComment = "";
}
};
// 提示信息KIND
enum SHARE_KIND
{
SH_KIND_0 = 0, // 空
SH_KIND_BUY, // 房卡购买提示
SH_KIND_SHOP, // 商城提示
SH_KIND_WEIXIN_URL, // 微信分享URL
SH_KIND_WEIXIN_TITLE, // 微信分享标题
SH_KIND_WEIXIN_COMMET, // 微信分享内容
SH_KIND_FRIEND_RUL, // 朋友圈URL
SH_KIND_FRIEND_TITLE, // 朋友圈标题
SH_KIND_FRIEND_COMMET, // 朋友圈内容
SH_KIND_ROOMID_DDZ, // 斗地主房间号分享
};
class GlobalJosn
{
CREATE_SINGLETON_MUTEX_CLEAR(GlobalJosn, s_configInstance, nullptr);
private:
void init();
void clear();
public:
//加载游戏列表配置文件
void loadConfig();
void loadServerList();
void loadShareList();
//获取游戏列表游戏数目
int getGameCount();
//获取游戏配置信息
tagGameConfig getGameConfigByIdx(const int &nIdx, bool &bHave);
//获取游戏配置信息
tagGameConfig getGameConfigByKind(const int &nKind, bool &bHave);
//根据kindid判断游戏是否被激活
bool isGameActive(const int &nKind);
//根据kindid判断游戏是否在列表中
bool isGameInList(const int &nKind);
// 根据下标获取短语
std::string getChatShotByIndex(int index);
//获取分享公告
std::vector<tagShareInfo>& getShareList(){ return m_vecShareList; };
//获取共享信息
std::string getShareInfoByKind(const int nKindID);
//设置IP和PORT
void SetLoginIpAndPort(std::string strIpAndPortEncrypt);
// 获取刷新时间;
int GetRefreshTime(){ return (m_RefreshTime <= 0) ? DEFINE_REFRESH_TIME : m_RefreshTime; }
private:
static GlobalJosn *s_configInstance;
std::vector<tagGameConfig> m_vecGameConfig;
std::vector<tagShareInfo> m_vecShareList;
//登陆信息
public:
std::string m_strNickName; //昵称
std::string m_strAesKey; //解密KEY
std::string m_strLogonIp; //登陆IP
int m_iPort; //PORT
std::string m_strAgentTip; // 代理信息;
std::string m_strShareTip; // 分享信息;
// 公告信息;
bool m_IsNotice; // 是否显示;
std::string m_NoticeUrl; // 图片URL;
std::string m_strPayUrl; // 充值链接;
std::string m_strDuiHuanUrl; // 兑换链接;
std::string m_strGongHuiUrl; // 公会链接;
std::string m_strShareUrl; // 分享链接;
bool m_IsOpenNN;
bool m_IsOpenZJH;
bool m_IsOpenSSZ;
int m_RefreshTime; // 刷新工会列表时间;
};
#endif // _GLOBAL_JOSN_H_