诸暨麻将添加redis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

233 lines
6.7 KiB

  1. #include "StdAfx.h"
  2. #include "ModuleListControl.h"
  3. //////////////////////////////////////////////////////////////////////////////////
  4. //构造函数
  5. CModuleListControl::CModuleListControl()
  6. {
  7. }
  8. //析构函数
  9. CModuleListControl::~CModuleListControl()
  10. {
  11. }
  12. //配置列表
  13. VOID CModuleListControl::InitListControl()
  14. {
  15. //变量定义
  16. INT nColIndex = 0;
  17. //配置列表
  18. InsertColumn(nColIndex++, TEXT("游戏名字"), LVCFMT_CENTER, 80);
  19. InsertColumn(nColIndex++, TEXT("组件状态"), LVCFMT_CENTER, 80);
  20. InsertColumn(nColIndex++, TEXT("数据库名"), LVCFMT_LEFT, 100);
  21. InsertColumn(nColIndex++, TEXT("连接地址"), LVCFMT_LEFT, 100);
  22. InsertColumn(nColIndex++, TEXT("服务器名"), LVCFMT_LEFT, 140);
  23. InsertColumn(nColIndex++, TEXT("客户端名"), LVCFMT_LEFT, 120);
  24. return;
  25. }
  26. //子项排序
  27. INT CModuleListControl::SortListItemData(LPARAM lParam1, LPARAM lParam2, WORD wColumnIndex)
  28. {
  29. //变量定义
  30. tagGameModuleInfo * pGameModuleInfo1 = (tagGameModuleInfo *)lParam1;
  31. tagGameModuleInfo * pGameModuleInfo2 = (tagGameModuleInfo *)lParam2;
  32. //安装排序
  33. bool bInstall1 = (pGameModuleInfo1->dwNativeVersion != 0L);
  34. bool bInstall2 = (pGameModuleInfo2->dwNativeVersion != 0L);
  35. if (bInstall1 != bInstall2) return (bInstall1 == true) ? 1 : -1;
  36. //子项排序
  37. switch (wColumnIndex)
  38. {
  39. case 0: //游戏名字
  40. {
  41. return lstrcmp(pGameModuleInfo1->szGameName, pGameModuleInfo2->szGameName);
  42. }
  43. case 1: //组件状态
  44. {
  45. //组件状态
  46. BYTE cbStatus1 = 0;
  47. if (pGameModuleInfo1->dwNativeVersion != 0)
  48. {
  49. cbStatus1 = (pGameModuleInfo1->dwNativeVersion == pGameModuleInfo1->dwServerVersion) ? 2 : 1;
  50. }
  51. //组件状态
  52. BYTE cbStatus2 = 0;
  53. if (pGameModuleInfo2->dwNativeVersion != 0)
  54. {
  55. cbStatus2 = (pGameModuleInfo2->dwNativeVersion == pGameModuleInfo2->dwServerVersion) ? 2 : 1;
  56. }
  57. return (cbStatus1 > cbStatus2) ? SORT_POSITION_AFTER : SORT_POSITION_FRONT;
  58. }
  59. case 2: //数据库名
  60. {
  61. return lstrcmp(pGameModuleInfo1->szDataBaseName, pGameModuleInfo2->szDataBaseName);
  62. }
  63. case 3: //连接地址
  64. {
  65. return lstrcmp(pGameModuleInfo1->szDataBaseAddr, pGameModuleInfo2->szDataBaseAddr);
  66. }
  67. case 4: //服务器名
  68. {
  69. return lstrcmp(pGameModuleInfo1->szServerDLLName, pGameModuleInfo2->szServerDLLName);
  70. }
  71. case 5: //客户端名
  72. {
  73. return lstrcmp(pGameModuleInfo1->szClientEXEName, pGameModuleInfo2->szClientEXEName);
  74. }
  75. }
  76. return 0;
  77. }
  78. //获取颜色
  79. VOID CModuleListControl::GetListItemColor(LPARAM lItemParam, UINT uItemStatus, tagListItemColor & ListItemColor)
  80. {
  81. //变量定义
  82. ASSERT(lItemParam != NULL);
  83. tagGameModuleInfo * pGameModuleInfo = (tagGameModuleInfo *)lItemParam;
  84. //没有安装
  85. if (pGameModuleInfo->dwNativeVersion == 0L)
  86. {
  87. //设置颜色
  88. ListItemColor.rcTextColor = RGB(125, 125, 125);
  89. ListItemColor.rcBackColor = (uItemStatus&ODS_SELECTED) ? RGB(50, 50, 50) : CR_NORMAL_BK;
  90. return;
  91. }
  92. //存在更新
  93. if (pGameModuleInfo->dwNativeVersion != pGameModuleInfo->dwServerVersion)
  94. {
  95. //设置颜色
  96. ListItemColor.rcTextColor = RGB(128, 0, 0);
  97. ListItemColor.rcBackColor = (uItemStatus&ODS_SELECTED) ? RGB(230, 230, 0) : CR_NORMAL_BK;
  98. return;
  99. }
  100. //版本一致
  101. if (pGameModuleInfo->dwNativeVersion == pGameModuleInfo->dwServerVersion)
  102. {
  103. //设置颜色
  104. ListItemColor.rcBackColor = (uItemStatus&ODS_SELECTED) ? RGB(0, 0, 128) : CR_NORMAL_BK;
  105. ListItemColor.rcTextColor = (uItemStatus&ODS_SELECTED) ? RGB(255, 255, 255) : RGB(0, 0, 0);
  106. return;
  107. }
  108. return;
  109. }
  110. //插入列表
  111. bool CModuleListControl::InsertModuleInfo(tagGameModuleInfo * pGameModuleInfo)
  112. {
  113. //变量定义
  114. LVFINDINFO FindInfo;
  115. ZeroMemory(&FindInfo, sizeof(FindInfo));
  116. //设置变量
  117. FindInfo.flags = LVFI_PARAM;
  118. FindInfo.lParam = (LPARAM)pGameModuleInfo;
  119. //存在判断
  120. INT nInsertItem = FindItem(&FindInfo);
  121. if (nInsertItem != LB_ERR) return true;
  122. //插入列表
  123. for (WORD i = 0; i < m_ListHeaderCtrl.GetItemCount(); i++)
  124. {
  125. if (i == 0)
  126. {
  127. //插入首项
  128. INT nIndex = GetInsertIndex(pGameModuleInfo);
  129. LPCTSTR pszDescribe = GetDescribeString(pGameModuleInfo, i);
  130. nInsertItem = InsertItem(LVIF_TEXT | LVIF_PARAM, nIndex, pszDescribe, 0, 0, 0, (LPARAM)pGameModuleInfo);
  131. }
  132. else
  133. {
  134. //字符子项
  135. SetItem(nInsertItem, i, LVIF_TEXT, GetDescribeString(pGameModuleInfo, i), 0, 0, 0, 0);
  136. }
  137. }
  138. return true;
  139. }
  140. //插入索引
  141. WORD CModuleListControl::GetInsertIndex(tagGameModuleInfo * pGameModuleInfo)
  142. {
  143. //变量定义
  144. INT nItemCount = GetItemCount();
  145. tagGameModuleInfo * pGameModuleTemp = NULL;
  146. //获取位置
  147. for (INT i = 0; i < nItemCount; i++)
  148. {
  149. //获取数据
  150. pGameModuleTemp = (tagGameModuleInfo *)GetItemData(i);
  151. //安装判断
  152. if ((pGameModuleInfo->dwNativeVersion == 0) && (pGameModuleTemp->dwNativeVersion != 0))
  153. {
  154. continue;
  155. }
  156. //名字判断
  157. if (lstrcmp(pGameModuleInfo->szGameName, pGameModuleTemp->szGameName) < 0)
  158. {
  159. return i;
  160. }
  161. }
  162. return nItemCount;
  163. }
  164. //描述字符
  165. LPCTSTR CModuleListControl::GetDescribeString(tagGameModuleInfo * pGameModuleInfo, WORD wColumnIndex)
  166. {
  167. //构造字符
  168. switch (wColumnIndex)
  169. {
  170. case 0: //游戏名字
  171. {
  172. return pGameModuleInfo->szGameName;
  173. }
  174. case 1: //组件状态
  175. {
  176. if (pGameModuleInfo->dwNativeVersion == 0L) return TEXT("没有安装");
  177. if (pGameModuleInfo->dwServerVersion != pGameModuleInfo->dwNativeVersion) return TEXT("存在更新");
  178. return TEXT("已经安装");
  179. }
  180. case 2: //数据库名
  181. {
  182. return pGameModuleInfo->szDataBaseName;
  183. }
  184. case 3: //连接地址
  185. {
  186. return pGameModuleInfo->szDataBaseAddr;
  187. }
  188. case 4: //服务器名
  189. {
  190. return pGameModuleInfo->szServerDLLName;
  191. }
  192. case 5: //客户端名
  193. {
  194. return pGameModuleInfo->szClientEXEName;
  195. }
  196. }
  197. return NULL;
  198. }
  199. //////////////////////////////////////////////////////////////////////////////////