Files
2026-06-01 12:46:52 +02:00

216 lines
7.1 KiB
C++

#pragma once
//#include <string>
//#include <vector>
#include <map>
#include <mmo/ArType.h>
#include <toolkit/c_hidint.h>
#include "STitleDB.h"
#include "SGameUIMgr.h"
#include "SStringDB.h"
const int c_Max_SubTitle_Num = 5;
const int c_Available_SUbTitle_Max_Rank = 6; //6 랭크 이상은 부호칭으로 사용 못한다.
namespace TITLEMGR
{
enum {
TITLE_STATUS_OPEN = ( 1 << 0 ), // 공개 된거
TITLE_STATUS_ACHIEVE = ( 1 << 1 ), // 획득 한거
TITLE_STATUS_BOOKMARK = ( 1 << 2 ) // 즐겨찾기
};
enum{
EMPTY_TITLE = -1,
MAIN_TITLE = 0,
SUB_TITLE =1
};
struct stCondition{
int nTypeID; // 타입 id
__int64 nCount; // 횟수
__int64 nCurCount; // 현재 횟수
bool bState; // 달성조건, 공개조건
int nCategoryID; // 카테고리 ID
int nCategoryValue[3]; // 카테고리 상세값
bool IsAchieveCondition( ){ return bState; } // 획득조건
};
struct stTitleRes{
TitleResource m_title;
std::vector<stCondition> vCondition;
};
struct stTitleUI{
stTitleUI(int _id, int _stringID, bool _bookmark, bool _bUsing, bool _bArchive, bool _bOpen, bool _bIsNew ):
nID(_id),iStringID(_stringID), bBookMark(_bookmark), bUsing(_bUsing), bAchieve(_bArchive), bOpen(bOpen),bIsNew(_bIsNew)
{}
int nID; // 호칭 ID
int iStringID; // 호칭 타이틀
bool bBookMark; // 즐겨찾기
bool bUsing; // 장착중인가
bool bAchieve; // 획득
bool bOpen; // 공개
bool bIsNew; // 새로 획득,공개 된 호칭
};
struct stTitleUsingID{
stTitleUsingID(){
nMain = EMPTY_TITLE;
nBeforeMain =EMPTY_TITLE;
for(int i=0 ; i<c_Max_SubTitle_Num ; ++i)
{
nSub[i] = EMPTY_TITLE;
nBeforeSub[i] = EMPTY_TITLE;
}
}
int nMain;
int nSub[c_Max_SubTitle_Num];
int nBeforeMain;
int nBeforeSub[c_Max_SubTitle_Num];
};
enum SORTKIND{
GAIN = 0,
BOOKMARK,
NAME,
USING,
BASE,
TOTAL_KIND
};
enum SORTSTATE{
NONE = 0,
DES, // 내림차순
ASE, // 오름차순
TOTAL_STATE
};
struct stTitleSort{
stTitleSort():m_kind(0),m_index(0){}
int m_kind;
int m_index;
int Set(int nKind){
if(m_kind == nKind) // 이전과 같은 종류의 정렬일 경우
{
++m_index;
if(m_index == SORTSTATE::TOTAL_STATE)
m_index = NONE;
}
else // 다른 종유류의 정렬일 경우
{
m_kind = nKind;
m_index = DES; // 첫번째는 내림차순
}
if(m_kind == BASE) // 기본정렬의 경우 무조건 아무것도 아닌 상태이다.
m_index = NONE;
return m_index;
}
void ReSet(){ m_index = 0; m_kind = 0; }
};
}
using namespace TITLEMGR;
/* 2012. 4. 17 - marine
1. 타이틀은 현재 3개(TitleResource,TitleConditionResource,TitleTypeConditionResource) 의 RDB를 사용한다.
2. 각 호칭 마다 3개의 RDB를 모두 사용해야하는데 매번 검색을 하면 성능저하와 구현상의 어려움으로인해
stTitleRes 타입으로 재정의해서 map데이터로 갖는다. - m_TitleRes (3개의 RDB를 취합한 map데이터)
3. 호칭의 상태변경(수량변경등)이 일어났을때 typeID가 를 사용하는 모든 호칭을 검색해야 하므로 typeID를 갖는 모든
호칭ID를 호칭ID를 벡터로 만들어 갖고 있는다. - m_CheckRes
4. 2,3번의 데이터는 참조용이고 실제로 UI에서 사용될 유저의 데이터는 따로 갖는다.
*/
class STitleMgr : public SGameUIMgr
{
private:
const std::map<int, TitleResource> &c_TitleRes;
const std::multimap<int, TitleConditionResource> &c_TitleConRes;
const std::map<int, TitleConditionTypeResource> &c_TitleConTypeRes;
std::map<int, stTitleRes> m_TitleRes; // 통합 타이틀 리소스
std::map<int, std::vector<int>> m_CheckRes; // ConditionType을 키로 갖는 호칭ID의 벡터 들의 맵..
std::vector<stTitleUI> m_TitleUiRes; // ui 출력을 위한 데이터
std::vector<stTitleUI> m_TitleUiResSort; // UI 출력을 위한 정렬된 데이터 ->실제로 사용되는것은 이놈..
stTitleUsingID m_UsingID; // 사용중인 주,부 ID
std::vector<int> m_SortingList; // 정렬된 아이디 벡터
stTitleSort m_SortState; // 정렬상태 관리
std::map<int,std::string> m_QuestInfo; // 퀘스트 상세정보창에 호칭보상 스트링을 얻기 위한 맵
void Init();
void InitMakeCondition( int id , stTitleRes& titleRes);
void InitCheckRes( int TitleID, int TypeID );
bool m_IsNewTitleExist; // 새로 획득한 호칭이 있는지 여부(이 플래그에 따라 정렬방식이 다르다.)
void SetNewTitleExist(bool flag); // m_IsNewTitleExist 설정 및 알람 호출
void SendNewTitleNotify(); // ui에 새로운 호칭 상태 변경 알림
void SetInfoForQeust(stTitleRes &titleRes); // 퀘스트 상세정보창에 호칭 보상 스트링 저장 맵 구성 함수
public:
STitleMgr();
virtual ~STitleMgr();
static STitleMgr &GetInstance()
{
static STitleMgr _inst;
return _inst;
}
void SetMsgTitleData( struct SGameMessage*pMsg );
void SetMsgTitleList( SGameMessage *pMsg ); // 호칭 리스트
void SetMsgConditionList( SGameMessage *pMsg ); // 조건 리스트
void SetMsgMainTitleUsing( SGameMessage *pMsg ); // 주호칭 장착
void SetMsgSubTitleUsing( SGameMessage *pMsg ); // 부호칭 장착
void SetMsgRemainTimeTitle( SGameMessage *pMsg ); // 주호칭 남은 쿨타임
void SetMsgCondition( SGameMessage *pMsg ,bool update = false); // 호칭 조건의 상태 변경
void SetMsgBookmark( SGameMessage *pMsg); // 북마크
void SetMsgOpenTitle( SGameMessage *pMsg); // 호칭 공개
void SetMsgAchieveTitle( SGameMessage *pMsg); // 호칭 획득
void SetCondition( int id , __int64 count); // 호칭 조건 값 변경
int GetTitleStringID( int nID ); // 호칭 아이디로 호칭 스트링 아이디 얻기
TITLEMGR::stTitleUI* GetTitleUiByID( int nID );
const std::vector<stTitleUI>& GetTitleUI() {return m_TitleUiResSort;}
int GetAchieveTitleCount(); // 획득한 호칭 갯수
stTitleUsingID& GetEquipList() {return m_UsingID;}
bool IsAllEquip();
void SetMainTitleUsingState( int id ,AR_HANDLE handle); // 호칭사용상태 변경
void SetSubTitleUsingState(int id, int index);
void SetTitleUsingStateBoth(int id, int _id); // 원본벡터와 소팅벡터의 장착상태를 변경시켜준다.
// 정렬용
int ReQuestSorting(int Kind); // 정렬을 하고 상태값을 넘긴다.
void TitleSorting(int kind, int state);
void Refresh() { m_TitleUiResSort = m_TitleUiRes; }
void RequestSetUpMainTitle( int nID );
void RequestSetUpSubtitle( int nID, int nIndex );
void RequestSetDownMainTitle();
void RequestSetDownSubtitle( int nID, int nIndex );
void RequestSetBookmark( int nID );
int GetTitleCount() { return m_TitleUiRes.size(); }
const bool getTitleRes( int nID , stTitleRes& res);
int GetTitleValue( int id ); // (조건타입의 첫번째 상세값을 얻는다)
bool IsNewTitleExist() {return m_IsNewTitleExist;} // 새 호칭이 있는지
void SetNewTitleClose() ;
bool IsEquipID( int nID );
void ResetTitle();
std::string GetTitleNameForQuest( int questID ); // 퀘스트 ID로 해당 호칭 이름 얻기
};