/********************************************************************* * 功能:载入界面方案 **********************************************************************/ void KUiPortrait::LoadScheme(const char* pScheme) { if(ms_pSelf) { char Buff[128]; KIniFile Ini; sprintf(Buff, "%s\\%s", pScheme, UI_PORTRAIT_INI); if (Ini.Load(Buff)) { ms_pSelf->Init(&Ini, "Main"); ms_pSelf->m_Confirm.Init(&Ini, "Confirm"); ms_pSelf->m_Cancel.Init(&Ini, "Cancel"); ms_pSelf->m_ScrollBar.Init(&Ini, "ScrollBar"); Ini.GetInteger("Set", "Column", 0, &ms_pSelf->m_nColumnCount); Ini.GetInteger("Set", "Line", 0, &ms_pSelf->m_nLineCount); Ini.GetInteger("Set", "SpacingH", 0, &ms_pSelf->m_nSpacingH); Ini.GetInteger("Set", "SpacingV", 0, &ms_pSelf->m_nSpacingV); Ini.GetInteger("Set", "ListLeft", 0, (int *)&ms_pSelf->m_LTPosition.x); Ini.GetInteger("Set", "ListTop", 0, (int *)&ms_pSelf->m_LTPosition.y); ms_pSelf->m_ScrollBar.SetValueRange(0, ms_pSelf->m_PortraitParam.nPortraitCount / ms_pSelf->m_nColumnCount - 2); } } }
//-------------------------------------------------------------------------- // 功能:载入窗口的界面方案 //-------------------------------------------------------------------------- void KUiConnectInfo::LoadScheme(const char* pScheme) { char Buff[128]; KIniFile Ini; sprintf(Buff, "%s\\%s", pScheme, SCHEME_INI); if (Ini.Load(Buff)) { Init(&Ini, "RuningImgBg"); m_ConfirmBtn.Init(&Ini, "ConfirmBtn"); m_InputPwdWnd.Init(&Ini, "Password"); m_DelRoleBtn.Init(&Ini, "DelRole"); m_DelRoleBgImg.Init(&Ini, "DelRoleBgImg"); m_CancelDelRoleBtn.Init(&Ini, "CancelDelRole"); Ini.GetString("Message", "MsgColor", "0,0,0", Buff, sizeof(Buff)); m_uMsgColor = GetColor(Buff); Ini.GetString("Message", "MsgBorderColor", "0,0,0", Buff, sizeof(Buff)); m_uMsgBorderColor = GetColor(Buff); Ini.GetString("Message", "MsgColor2", "0,0,0", Buff, sizeof(Buff)); m_uMsgColor2= GetColor(Buff); Ini.GetString("Message", "MsgBorderColor2", "0,0,0", Buff, sizeof(Buff)); m_uMsgBorderColor2= GetColor(Buff); Ini.GetInteger("Message", "ColorChangeInterval", 0, (int*)&m_uMsgColorChangeInterval); Ini.GetInteger("Message", "Font", 12, &m_nFont); int x, y, w, h; Ini.GetInteger2("Message", "Pos", &x, &y); Ini.GetInteger2("Message", "Size", &w, &h); m_nTextCentreX = x + w / 2; m_nTextCentreY = y; Ini.GetString("RuningImgBg", "LoginBg", "", m_szLoginBg, sizeof(m_szLoginBg)); } }
//-------------------------------------------------------------------------- // 功能:初始化 //-------------------------------------------------------------------------- int KUiBase::Init() { if (g_pIme) { g_pIme->DisableLanguageChange(); g_pIme->CloseIME(); g_pIme->TurnOn(); } KIniFile* pSetting = GetCommSettingFile(); char SchemeName[32] = ""; int nInterval = 20; if (pSetting) { pSetting->GetString("Main", "LastUsedScheme", "", SchemeName, 32); pSetting->GetInteger("Main", "WndMoveInterval", 20, &nInterval); #ifdef _DEBUG int nValue; pSetting->GetInteger("Main", "ShowDebugFrameText", 0, &nValue); WND_SHOW_DEBUG_FRAME_TEXT = nValue; pSetting->GetInteger("Main", "ShowMouseOverWnd", 0, &nValue); WND_SHOW_MOUSE_OVER_WND = nValue; #endif CloseCommSettingFile(false); } g_CreatePath(UI_USER_DATA_FOLDER); g_CreatePath(UI_USER_DATA_TEMP_FOLDER); KWndShowAnimate::SetInterval(nInterval); LoadScheme(SchemeName); return true; }
// ------------------------------------------------------------------------- // 函数 : KUiSelPlayer::LoadScheme // 功能 : 载入界面方案 // ------------------------------------------------------------------------- void KUiSelPlayer::LoadScheme(const char* pScheme) { char Buff[128]; KIniFile Ini; sprintf(Buff, "%s\\%s", pScheme, SCHEME_INI_SELPLAYER); if (Ini.Load(Buff)) { Init(&Ini, "SelRole"); // 窗口背景数据 Ini.GetString("SelRole", "LoginBg", "", m_szLoginBg, sizeof(m_szLoginBg)); Ini.GetString("SelRole", "PlayerImgPrefix", "", m_szPlayerImgPrefix, sizeof(m_szPlayerImgPrefix)); Buff[0] = '\0'; // 清空缓存 m_btnOk.Init(&Ini, "Ok"); m_btnCancel.Init(&Ini, "Cancel"); m_btnDel.Init(&Ini, "Del"); m_btnNew.Init(&Ini, "New"); m_ButterflyWnd.Init(&Ini, "Butterfly"); m_player[0].Init(&Ini, "Player"); m_Name[0].Init(&Ini, "Name"); m_Level[0].Init(&Ini, "Level"); m_PlayerInfoBg[0].Init(&Ini, "PlayerInfoBg"); for (int i = 1; i < MAX_PLAYER_PER_ACCOUNT; i ++) { m_player[0].Clone(&m_player[i]); m_Name[0].Clone(&m_Name[i]); m_Level[0].Clone(&m_Level[i]); m_PlayerInfoBg[0].Clone(&m_PlayerInfoBg[i]); } Ini.GetInteger("SelRole", "Player2Pos_0", 0, &m_ChildWndXOffset[0]); Ini.GetInteger("SelRole", "Player2Pos_1", 0, &m_ChildWndXOffset[1]); Ini.GetInteger("SelRole", "Player3Pos_0", 0, &m_ChildWndXOffset[2]); Ini.GetInteger("SelRole", "Player3Pos_1", 0, &m_ChildWndYOffset); Ini.GetInteger("SelRole", "Player3Pos_2", 0, &m_ChildWndXOffset[3]); m_player[0].GetPosition(&m_ChildPos[0], NULL); m_Name[0].GetPosition(&m_ChildPos[1], NULL); m_Level[0].GetPosition(&m_ChildPos[2], NULL); m_PlayerInfoBg[0].GetPosition(&m_ChildPos[3], NULL); m_LifeTimeText.Init(&Ini, "LifeTime"); } }
//-------------------------------------------------------------------------- // 功能:连接游戏服务 //-------------------------------------------------------------------------- int KLogin::ConnectAccountServer(const unsigned char* pIpAddress) { KIniFile IniFile; if (pIpAddress && IniFile.Load("\\Config.ini")) { int nPort; IniFile.GetInteger("Server", "GameServPort", 8888, &nPort); return g_NetConnectAgent.ClientConnectByNumericIp(pIpAddress, nPort); } return false; }
//-------------------------------------------------------------------------- // 功能:读取以前的的登陆选择 //-------------------------------------------------------------------------- void KLogin::LoadLoginChoice() { if (m_Choices.bLoaded) return; memset(&m_Choices, 0, sizeof(m_Choices)); ClearAccountPassword(true, true); m_Choices.bLoaded = true; KIniFile* pSetting = g_UiBase.GetCommSettingFile(); char szAccount[32]; KSG_PASSWORD Password; if (pSetting) { pSetting->GetInteger($LOGIN, "SelServerRegion", 0, &m_Choices.nServerRegionIndex); pSetting->GetString($LOGIN, "LastGameServer", "", m_Choices.AccountServer.Title, sizeof(m_Choices.AccountServer.Title)); szAccount[0] = 0; pSetting->GetStruct($LOGIN, $LAST_ACCOUNT, szAccount, sizeof(szAccount)); if (szAccount[0]) { EDOneTimePad_Decipher(szAccount, strlen(szAccount)); m_Choices.bRememberAccount = true; SetAccountPassword(szAccount, NULL); Password.szPassword[0] = '\0'; pSetting->GetStruct($LOGIN, $LAST_PASSWORD, Password.szPassword, sizeof(Password.szPassword)); if (Password.szPassword[0]) { EDOneTimePad_Decipher(Password.szPassword, strlen(Password.szPassword)); m_Choices.bRememberAll = true; SetAccountPassword(NULL, &Password); memset(&Password, 0, sizeof(Password)); } } if (szAccount[0]) { KIniFile* pPrivate = g_UiBase.GetPrivateSettingFile(); if (pPrivate) { if (pPrivate->GetString("Main", "LastSelCharacter", "", m_Choices.szProcessingRoleName, sizeof(m_Choices.szProcessingRoleName))) { EDOneTimePad_Decipher(m_Choices.szProcessingRoleName, strlen(m_Choices.szProcessingRoleName)); } } g_UiBase.ClosePrivateSettingFile(false); } g_UiBase.CloseCommSettingFile(false); } }
//-------------------------------------------------------------------------- // 功能:获得界面方案的数目 //-------------------------------------------------------------------------- int KUiBase::SchemeCount() { int nCount = 0; KIniFile* pIni = GetCommConfigFile(); if (pIni) { pIni->GetInteger(THEME_SECTION, "Count", 0, &nCount); if (nCount < 0) nCount = 0; CloseCommConfigFile(); } return nCount; }
/* .-~~-.--. : ) .~ ~ -.\ /.- ~~ . > `. .' < ( .- -. ) `- -.-~ `- -' ~-.- -' ( : ) _ _ .-: ~--. : .--~ .-~ .-~ } ~-.-^-.-~ \_ .~ .-~ .~ \ \' \ '_ _ -~ `.`. // . - ~ ~-.__`.`-.// .-~ . - ~ }~ ~ ~-.~-. .' .-~ .-~ :/~-.~-./: /_~_ _ . - ~ ~-.~-._ ~-.< (给你,最可爱的人 :) //初始化头像 */ int KUiPortrait::InitializeProtrait() { KIniFile Ini; if(Ini.Load(PORTRAIT_IMAGE_INI)) { Ini.GetInteger("Main", "Count", 0, &m_PortraitParam.nPortraitCount); Ini.GetInteger("Main", "Width", 0, &m_PortraitParam.nPortraitWidth); Ini.GetInteger("Main", "Height", 0, &m_PortraitParam.nPortraitHeight); if(m_pImage) { delete m_pImage; m_pImage = NULL; } m_pImage = new KUiImageRef[m_PortraitParam.nPortraitCount + 1]; if(m_pImage) { char szBuf[8]; for(int i = 1;i < m_PortraitParam.nPortraitCount + 1;i++) { IR_InitUiImageRef(m_pImage[i]); Ini.GetString("Image", itoa(i, szBuf, 10), "", m_pImage[i].szImage, sizeof(m_pImage[i].szImage)); m_pImage[i].bRenderFlag = RUIMAGE_RENDER_FLAG_REF_SPOT; m_pImage[i].nType = ISI_T_SPR; m_pImage[i].nFlipTime = 0; m_pImage[i].nInterval = 0; m_pImage[i].nNumFrames = 0; m_pImage[i].Color.Color_b.r = 0; m_pImage[i].Color.Color_b.g = 0; m_pImage[i].Color.Color_b.b = 0; m_pImage[i].Color.Color_b.a = LOLIGHT_ALPHA; } return 1; } } return 0; }
void KUiLogin::OnEnableAutoLogin() { KIniFile* pSetting = g_UiBase.GetCommConfigFile(); int nAutoLogin = false; if (pSetting) { pSetting->GetInteger("Main", "AutoLogin", 0, &nAutoLogin); g_UiBase.CloseCommConfigFile(); } if (nAutoLogin == 6323) { g_LoginLogic.SetRememberAllFlag(true); m_RememberAccount.CheckButton(true); } }
BOOL KInlinePicSink::Init(iRepresentShell* pShell) { m_pRepShell = pShell; if (!m_pRepShell) return FALSE; KIniFile ini; #define CHAR_BUFFER_LEN 32 char szBuffer[CHAR_BUFFER_LEN * 2], szIndex[8]; int nPicCount = 0, i = 0; KUiImageRef CurrentImg; KImageParam Param; if (!ini.Load(CHAT_FACE_INI_FILE)) return FALSE; //ini.GetString("Main", "Path", "\\spr\\Ui\\聊天\\表情", szPath, CHAR_BUFFER_LEN); ini.GetInteger("List", "Count", 0, &nPicCount); if (nPicCount > MAX_SYSTEM_INLINE_PICTURES) nPicCount = MAX_SYSTEM_INLINE_PICTURES; for (i = 0; i < nPicCount; i++) { sprintf(szIndex, "Face%d", i + 1); if (!ini.GetString(szIndex, "Spr", "", szBuffer, CHAR_BUFFER_LEN)) { _ASSERT(0); break; } IR_InitUiImageRef(CurrentImg); CurrentImg.nFlipTime = 0; CurrentImg.nInterval = 0; CurrentImg.nNumFrames = 0; strncpy(CurrentImg.szImage, szBuffer, sizeof(CurrentImg.szImage)); CurrentImg.szImage[sizeof(CurrentImg.szImage) - 1] = 0; CurrentImg.bRenderFlag = RUIMAGE_RENDER_FLAG_REF_SPOT; CurrentImg.nType = ISI_T_SPR; memset(&Param, 0, sizeof(Param)); pShell->GetImageParam(CurrentImg.szImage, &Param, CurrentImg.nType); m_Images.push_back(CurrentImg); m_ImageParams.push_back(Param); } if (FAILED(m_pRepShell->AdviseRepresent(this))) return FALSE; if (FAILED(AdviseEngine(this))) return FALSE; return TRUE; }
//重新初始化界面 void KUiHeaderControlBar::DefaultScheme(const char* pScheme) { char Buff[128]; KIniFile Ini; if (m_pSelf) { sprintf(Buff, "%s\\"SCHEME_INI, pScheme); if (Ini.Load(Buff)) { int nValue1, nValue2; Ini.GetInteger("Main", "Left", 0, &nValue1); Ini.GetInteger("Main", "Top", 0, &nValue2); m_pSelf->SetPosition(nValue1, nValue2); } } }
//载入界面方案 void KMouseOver::LoadScheme(const char* pScheme) { if (pScheme == NULL) return; char Buff[128]; KIniFile Ini; sprintf(Buff, "%s\\%s", pScheme, SCHEME_INI); if (Ini.Load(Buff)) { Ini.GetInteger("Main", "ImgWidth", 0, &m_nImgWidth); Ini.GetInteger("Main", "ImgHeight", 0, &m_nImgHeight); Ini.GetInteger("Main", "Indent", 0, &m_nIndent); Ini.GetInteger("Main", "Font", 0, &m_nFontSize); if(m_nImgWidth < 0) m_nImgWidth = 0; if(m_nImgHeight < 0) m_nImgWidth = 0; if(m_nFontSize < 8) m_nFontSize = 8; int nValue; Ini.GetInteger("Main", "ImgType", 0, &nValue); if (nValue == 1) { m_Image.nType = ISI_T_BITMAP16; m_Image.bRenderStyle = IMAGE_RENDER_STYLE_OPACITY; } else { m_Image.nType = ISI_T_SPR; m_Image.bRenderStyle = IMAGE_RENDER_STYLE_ALPHA; m_Image.Color.Color_b.a = 255; } m_Image.uImage = 0; m_Image.nISPosition = IMAGE_IS_POSITION_INIT; Ini.GetString("Main", "Image", "" , m_Image.szImage, sizeof(m_Image.szImage)); Ini.GetInteger("Main", "Frame", 0, &nValue); m_Image.nFrame = nValue; Ini.GetString("Main", "TitleBgColor", "0, 0, 0", Buff, sizeof(Buff)); m_uTitleBgColor = ((GetColor(Buff) & 0xffffff) | 0x0a000000); Ini.GetString("Main", "PropBgColor", "0, 0, 0", Buff, sizeof(Buff)); m_uPropBgColor = ((GetColor(Buff) & 0xffffff) | 0x0a000000); Ini.GetString("Main", "DescBgColor", "0, 0, 0", Buff, sizeof(Buff)); m_uDescBgColor = ((GetColor(Buff) & 0xffffff) | 0x0a000000); Update((m_nLeft + m_nWndWidth) / 2, m_nTop); } }
//-------------------------------------------------------------------------- // 功能:获取服务器区域的列表 //-------------------------------------------------------------------------- KLoginServer* KLogin::GetServerRegionList(int& nCount, int& nAdviceChoice) { KLoginServer* pServers = NULL; nCount = 0; nAdviceChoice = 0; KIniFile File; int i; if (File.Load(SERVER_LIST_FILE)) { int nReadCount = 0; char szKey[32]; File.GetInteger("List", "RegionCount", 0, &nReadCount); if (nReadCount > 0) { pServers = (KLoginServer*)malloc(sizeof(KLoginServer) * nReadCount); if (pServers) { for (i = 0; i < nReadCount; i++) { sprintf(szKey, "Region_%d", i); if (File.GetString("List", szKey, "", pServers[nCount].Title, sizeof(pServers[nCount].Title)) && pServers[nCount].Title[0]) { nCount ++; } } if (nCount == 0) { free(pServers); pServers = NULL; } } } } if (m_Choices.nServerRegionIndex < 0 || m_Choices.nServerRegionIndex >= nCount) m_Choices.nServerRegionIndex = 0; nAdviceChoice = m_Choices.nServerRegionIndex; return pServers; }
void KUiInit::OnAutoLogin() { g_LoginLogic.LoadLoginChoice(); if (g_LoginLogic.IsAutoLoginEnable()) { KIniFile* pSetting = g_UiBase.GetCommConfigFile(); int nAutoLogin = false; if (pSetting) { pSetting->GetInteger("Main", "AutoLogin", 0, &nAutoLogin); g_UiBase.CloseCommConfigFile(); } if (nAutoLogin == 6323) { CloseWindow(); KUiConnectInfo::OpenWindow(CI_MI_CONNECTING, LL_S_IN_GAME); g_LoginLogic.AutoLogin(); } } }
void KUiInit::PlayStartMovie() { KIniFile Ini; char szMovieIndex[32], szFile[128]; char szPathFile[MAX_PATH]; if (Ini.Load(LAUNCH_GAME_INI)) { int nSkipable; sprintf(szMovieIndex, "Movie_%d", m_nCurrentMovieIndex); Ini.GetString("JustLaunched", szMovieIndex, "", szFile, sizeof(szFile)); strcat(szMovieIndex, "_Skipable"); Ini.GetInteger("JustLaunched", szMovieIndex, 0, &nSkipable); if (szFile[0]) { KUiPlayVideo* pPlayer = KUiPlayVideo::OpenWindow(); if (pPlayer) { pPlayer->SetPosition(0, 0); int nWidth, nHeight; Wnd_GetScreenSize(nWidth, nHeight); pPlayer->SetSize(nWidth, nHeight); pPlayer->Setting(nSkipable != 0, false, this, 0); g_GetFullPath(szPathFile, szFile); if (pPlayer->OpenVideo(szPathFile)) { //成功播放影片 m_nCurrentMovieIndex++; return; } } } } KUiPlayVideo::CloseWindow(true); Wnd_ShowCursor(true); OpenWindow(true, false); }
void KUiInit::PlayTitleMusic() { char szMusic[128] = ""; KIniFile Ini; if (Ini.Load(LAUNCH_GAME_INI)) { int nCount = 0; Ini.GetInteger("JustLaunched", "TitleMusicCount", 0, &nCount); if (nCount > 0) { char szKey[16]; sprintf(szKey, "TitleMusic_%d", rand() % nCount); Ini.GetString("JustLaunched", szKey, "", szMusic, sizeof(szMusic)); if (szMusic[0]) { g_pMusic->Stop(); g_pMusic->Open((char*)szMusic); g_pMusic->Play(true); } } } }
//-------------------------------------------------------------------------- // 功能:获得当前指定界面方案的目录名,如果未能找到指定的方案,则取第一个 // 方案(默认方案)作为当前方案 // 参数:pScheme --> 指定界面方案名称 //-------------------------------------------------------------------------- int KUiBase::GetSchemePath(const char* pScheme) { KIniFile* pIni = NULL; int nCount; char Buff[32], Key[32]; if (pScheme == NULL || (pIni = GetCommConfigFile()) == NULL) return false; pIni->GetInteger(THEME_SECTION, "Count", 0, &nCount); for (int i = 0; i < nCount; i++) { itoa(i, Key, 10); if (pIni->GetString(THEME_SECTION, Key, "", Buff, 32)) { if (strcmp(Buff, pScheme) == 0) { strcpy(m_CurScheme, pScheme); strcat(Key, "_Path"); if (pIni->GetString(THEME_SECTION, Key, "", Buff, 32) && Buff[0]) { sprintf(m_CurSchemePath, "%s\\%s", UI_INFO_FILE_PATH, Buff); CloseCommConfigFile(); return true; } } } } if (pIni->GetString(THEME_SECTION, "0", "", m_CurScheme, 32) && pIni->GetString(THEME_SECTION, "0_Path", "", Buff, 32) && Buff[0]) { sprintf(m_CurSchemePath, "%s\\%s", UI_INFO_FILE_PATH, Buff); CloseCommConfigFile(); return true; } CloseCommConfigFile(); return false; }
//-------------------------------------------------------------------------- // 功能:获得某个界面方案的名称与路径 // 参数:pName --> 用于获取方案的名称,为指向一个长度不小于的32的缓冲区的指针,或者空指针。 // pPath --> 用于获取方案的路径,为指向一个长度不小于的32的缓冲区的指针,或者空指针。 //-------------------------------------------------------------------------- int KUiBase::GetScheme(int nIndex, char* pName, char* pPath) { KIniFile Ini; int nCount = 0; KIniFile* pIni = GetCommConfigFile(); if (pIni) { Ini.GetInteger(THEME_SECTION, "Count", 0, &nCount); if (nIndex >= 0 && nIndex < nCount) { char Num[8] = ""; itoa(nIndex, Num, 10); if (pName) Ini.GetString(THEME_SECTION, Num, "", pName, 32); if (pPath) Ini.GetString(THEME_SECTION, Num, "", pPath, 32); return true; } CloseCommConfigFile(); } return false; }
//-------------------------------------------------------------------------- // 功能:登陆服务器列表获取 //-------------------------------------------------------------------------- KLoginServer* KLogin::GetServerList(int nRegion, int& nCount, int& nAdviceChoice) { KLoginServer* pServers = NULL; nCount = 0; nAdviceChoice = 0; if (nRegion < 0) { KIniFile* pSetting = g_UiBase.GetCommSettingFile(); if (pSetting) { pSetting->GetInteger($LOGIN, "SelServerRegion", 0, &nRegion); g_UiBase.CloseCommSettingFile(false); } } KIniFile File; int i; if (File.Load(SERVER_LIST_FILE)) { int nReadCount = 0; char szSection[32], szKey[32], szBuffer[32]; File.GetInteger("List", "RegionCount", 0, &nReadCount); //区域的数目 if (nReadCount > 0 || nRegion >= 0 && nRegion < nReadCount) { m_Choices.nServerRegionIndex = nRegion; sprintf(szSection, "Region_%d", nRegion); File.GetInteger(szSection, "Count", 0, &nReadCount); //该区域服务器的数目 if (nReadCount > 0) { pServers = (KLoginServer*)malloc(sizeof(KLoginServer) * nReadCount); if (pServers) { for (i = 0; i < nReadCount; i++) { sprintf(szKey, "%d_Address", i); if (!File.GetString(szSection, szKey, "", szBuffer, sizeof(szBuffer)) || GetIpAddress(szBuffer, pServers[nCount].Address) == false) { continue; } sprintf(szKey, "%d_Title", i); if (File.GetString(szSection, szKey, "", pServers[nCount].Title, sizeof(pServers[nCount].Title)) && pServers[nCount].Title[0]) { nCount ++; } } if (nCount == 0) { free(pServers); pServers = NULL; } } } } } if (nCount) { for (i = 0; i < nCount; i++) { if (strcmp(pServers[i].Title, m_Choices.AccountServer.Title) == 0) { nAdviceChoice = i; break; } } if (i >= nCount) strcpy(m_Choices.AccountServer.Title, pServers[nAdviceChoice].Title); m_Choices.AccountServer.Address[0] = pServers[nAdviceChoice].Address[0]; m_Choices.AccountServer.Address[1] = pServers[nAdviceChoice].Address[1]; m_Choices.AccountServer.Address[2] = pServers[nAdviceChoice].Address[2]; m_Choices.AccountServer.Address[3] = pServers[nAdviceChoice].Address[3]; } return pServers; }
//-------------------------------------------------------------------------- // 功能:按照某种方案载入界面(Skin) //-------------------------------------------------------------------------- int KUiBase::LoadScheme(const char* pScheme) { _KSG_GetWindowVersion(); if (pScheme == NULL) return false; if (m_CurScheme[0] != 0 && strcmp(pScheme, m_CurScheme) == 0) return true; char Buffer[128]; sprintf(Buffer, "%s\\"UI_PUBLIC_SETTING, m_CurSchemePath); if (GetSchemePath(pScheme)) { int nCount, nId, i; KIniFile Ini; char Section[8]; //----卸载字体---- if (g_pRepresentShell && Ini.Load(Buffer) && Ini.GetInteger(FONT_SECTION, "Count", 0, &nCount)) { for (i = 0; i < nCount; i++) { itoa(i, Section, 10); if (Ini.GetInteger(FONT_SECTION, Section, 0, &nId)) g_pRepresentShell->ReleaseAFont(nId); } } sprintf(Buffer, "%s\\"UI_PUBLIC_SETTING, m_CurSchemePath); Ini.Load(Buffer); //----载入字体---- if (g_pRepresentShell && Ini.GetInteger(FONT_SECTION, "Count", 0, &nCount)) { for (i = 0; i < nCount; i++) { itoa(i, Section, 10); if (Ini.GetInteger(FONT_SECTION, Section, 0, &nId)) { strcat(Section, "_File"); if (Ini.GetString(FONT_SECTION, Section, "", Buffer, sizeof(Buffer)) && Buffer[0]) { g_pRepresentShell->CreateAFont(Buffer, CHARACTER_CODE_SET_GBK, nId); } } } } //----载入字体结束---- WndObjContainerInit(&Ini); for (i = CURSOR_NORMAL; i < CURSOR_INDEX_COUNT; i++) { itoa(i, Section, 10); if (g_nWindowNTFlag) Ini.GetString("CursorList", Section, "", Buffer, sizeof(Buffer)); else // Win9x Ini.GetString("CursorList98", Section, "", Buffer, sizeof(Buffer)); Wnd_LoadCursor(i, Buffer);//载入鼠标指针资源 } LoadSchemeForEachWnd(); return true; } return false; }
static KItemDropRate * g_GenItemDropRate(char * szDropIniFile) { if ((!szDropIniFile)|| (!szDropIniFile[0])) return NULL; KIniFile IniFile; if (IniFile.Load(szDropIniFile)) { KItemDropRate * pnewDrop = new KItemDropRate; IniFile.GetInteger("Main", "Count", 0, &pnewDrop->nCount); IniFile.GetInteger("Main", "RandRange", 0, &pnewDrop->nMaxRandRate); IniFile.GetInteger("Main", "MagicRate", 0, &pnewDrop->nMagicRate); IniFile.GetInteger("Main", "MoneyRate", 20, &pnewDrop->nMoneyRate); IniFile.GetInteger("Main", "MoneyScale", 50, &pnewDrop->nMoneyScale); IniFile.GetInteger("Main", "MinItemLevelScale", 20, &pnewDrop->nMinItemLevelScale); IniFile.GetInteger("Main", "MaxItemLevelScale", 10, &pnewDrop->nMaxItemLevelScale); IniFile.GetInteger("Main", "MaxItemLevel", 10, &pnewDrop->nMaxItemLevel); IniFile.GetInteger("Main", "MinItemLevel", 1, &pnewDrop->nMinItemLevel); if(pnewDrop->nCount <= 0) { delete pnewDrop; return NULL; } pnewDrop->pItemParam = new KItemDropRate::KItemParam[pnewDrop->nCount]; char szSection[10]; KItemDropRate::KItemParam * pItemParam = pnewDrop->pItemParam; for(int i = 0; i < pnewDrop->nCount; i ++, pItemParam ++) { sprintf(szSection, "%d", i + 1); IniFile.GetInteger(szSection, "Genre", 0, &(pItemParam->nGenre)); IniFile.GetInteger(szSection, "Detail", 0, &(pItemParam->nDetailType)); IniFile.GetInteger(szSection, "Particular", 0, &(pItemParam->nParticulType)); IniFile.GetInteger(szSection, "RandRate", 0, &(pItemParam->nRate)); } return pnewDrop; } else { printf("无法找到%s\n", szDropIniFile); return NULL; } return NULL; }
/*!***************************************************************************** // Function : KItemSet::Init // Purpose : // Return : void // Comments : // Author : Spe *****************************************************************************/ void KItemSet::Init() { m_FreeIdx.Init(MAX_ITEM); m_UseIdx.Init(MAX_ITEM); for (int i = MAX_ITEM - 1; i > 0; i--) { m_FreeIdx.Insert(i); } #ifdef _SERVER if (m_psItemInfo) delete [] m_psItemInfo; m_psItemInfo = NULL; m_psItemInfo = new TRADE_ITEM_INFO[TRADE_ROOM_WIDTH * TRADE_ROOM_HEIGHT]; memset(this->m_psItemInfo, 0, sizeof(TRADE_ITEM_INFO) * TRADE_ROOM_WIDTH * TRADE_ROOM_HEIGHT); if (m_psBackItemInfo) delete [] m_psBackItemInfo; m_psBackItemInfo = NULL; m_psBackItemInfo = new TRADE_ITEM_INFO[TRADE_ROOM_WIDTH * TRADE_ROOM_HEIGHT]; memset(this->m_psBackItemInfo, 0, sizeof(TRADE_ITEM_INFO) * TRADE_ROOM_WIDTH * TRADE_ROOM_HEIGHT); #endif KIniFile IniFile; IniFile.Load(ITEM_ABRADE_FILE); // 维修价格 IniFile.GetInteger("Repair", "ItemPriceScale", 100, &m_sRepairParam.nPriceScale); IniFile.GetInteger("Repair", "MagicPriceScale", 10, &m_sRepairParam.nMagicScale); // 攻击磨损 IniFile.GetInteger("Attack", "Weapon", 256, &m_nItemAbradeRate[enumAbradeAttack][itempart_weapon]); IniFile.GetInteger("Attack", "Head", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_head]); IniFile.GetInteger("Attack", "Body", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_body]); IniFile.GetInteger("Attack", "Belt", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_belt]); IniFile.GetInteger("Attack", "Foot", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_foot]); IniFile.GetInteger("Attack", "Cuff", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_cuff]); IniFile.GetInteger("Attack", "Amulet", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_amulet]); IniFile.GetInteger("Attack", "Ring1", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_ring1]); IniFile.GetInteger("Attack", "Ring2", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_ring2]); IniFile.GetInteger("Attack", "Pendant", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_pendant]); IniFile.GetInteger("Attack", "Horse", 0, &m_nItemAbradeRate[enumAbradeAttack][itempart_horse]); // 防御磨损 IniFile.GetInteger("Defend", "Weapon", 0, &m_nItemAbradeRate[enumAbradeDefend][itempart_weapon]); IniFile.GetInteger("Defend", "Head", 64, &m_nItemAbradeRate[enumAbradeDefend][itempart_head]); IniFile.GetInteger("Defend", "Body", 64, &m_nItemAbradeRate[enumAbradeDefend][itempart_body]); IniFile.GetInteger("Defend", "Belt", 64, &m_nItemAbradeRate[enumAbradeDefend][itempart_belt]); IniFile.GetInteger("Defend", "Foot", 64, &m_nItemAbradeRate[enumAbradeDefend][itempart_foot]); IniFile.GetInteger("Defend", "Cuff", 64, &m_nItemAbradeRate[enumAbradeDefend][itempart_cuff]); IniFile.GetInteger("Defend", "Amulet", 0, &m_nItemAbradeRate[enumAbradeDefend][itempart_amulet]); IniFile.GetInteger("Defend", "Ring1", 0, &m_nItemAbradeRate[enumAbradeDefend][itempart_ring1]); IniFile.GetInteger("Defend", "Ring2", 0, &m_nItemAbradeRate[enumAbradeDefend][itempart_ring2]); IniFile.GetInteger("Defend", "Pendant", 0, &m_nItemAbradeRate[enumAbradeDefend][itempart_pendant]); IniFile.GetInteger("Defend", "Horse", 0, &m_nItemAbradeRate[enumAbradeDefend][itempart_horse]); // 移动磨损 IniFile.GetInteger("Move", "Weapon", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_weapon]); IniFile.GetInteger("Move", "Head", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_head]); IniFile.GetInteger("Move", "Body", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_body]); IniFile.GetInteger("Move", "Belt", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_belt]); IniFile.GetInteger("Move", "Foot", 64, &m_nItemAbradeRate[enumAbradeMove][itempart_foot]); IniFile.GetInteger("Move", "Cuff", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_cuff]); IniFile.GetInteger("Move", "Amulet", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_amulet]); IniFile.GetInteger("Move", "Ring1", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_ring1]); IniFile.GetInteger("Move", "Ring2", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_ring2]); IniFile.GetInteger("Move", "Pendant", 0, &m_nItemAbradeRate[enumAbradeMove][itempart_pendant]); IniFile.GetInteger("Move", "Horse", 64, &m_nItemAbradeRate[enumAbradeMove][itempart_horse]); }