XKSYU2021 1 месяц назад
Родитель
Сommit
f2bbd8e8d8
3 измененных файлов с 33 добавлено и 49 удалено
  1. 2 0
      Ui for BDS/Config.h
  2. 18 43
      Ui for BDS/config.cpp
  3. 13 6
      Ui for BDS/configEditProc.cpp

+ 2 - 0
Ui for BDS/Config.h

@@ -1,8 +1,10 @@
 #pragma once
 
 void Submit(HWND hWnd1);
+void Update(HWND hWnd1, int id, int id1);
 
 extern HWND hGamemode, hDifficulty, hPermission;
+extern WORD wmId, wmEvent;
 
 #define CONF_ServerName 51010
 #define CONF_GameMode 51020

+ 18 - 43
Ui for BDS/config.cpp

@@ -5,6 +5,11 @@
 
 #include <vector>
 
+void Update(HWND hWnd1, int id, int id1 )
+{
+	if (wmEvent == BN_CLICKED && wmId == id)
+		SendMessage(GetDlgItem(hWnd1,id1), BM_SETCHECK, BST_UNCHECKED, 0);
+}
 
 //basic
 static std::vector<std::string> ConfigRead()
@@ -136,25 +141,15 @@ static void ConfigSet_CheckDIY_AntiCheat(std::vector<std::string>& configText, H
 static void ConfigSet_ComboDIY_Gamemode(std::vector<std::string>& configText, HWND hWnd1)
 {
 	int selected = SendMessage(hGamemode, CB_GETCURSEL, 0, 0);
-	std::string target;
+	std::string target = "gamemode";
 	switch (selected)
 	{
-	case 0:
-		for (auto& l : configText)
-		{
-			if (l.find(target) != std::string::npos)
-			{
-					l = target + "=";
-				return;
-			}
-		}
-		break;
 	case 1:
 		for (auto& l : configText)
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=adventure";
 				return;
 			}
 		}
@@ -164,7 +159,7 @@ static void ConfigSet_ComboDIY_Gamemode(std::vector<std::string>& configText, HW
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=survival";
 				return;
 			}
 		}
@@ -174,7 +169,7 @@ static void ConfigSet_ComboDIY_Gamemode(std::vector<std::string>& configText, HW
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=creative";
 				return;
 			}
 		}
@@ -184,25 +179,15 @@ static void ConfigSet_ComboDIY_Gamemode(std::vector<std::string>& configText, HW
 static void ConfigSet_ComboDIY_Difficuty(std::vector<std::string>& configText, HWND hWnd1)
 {
 	int selected = SendMessage(hDifficulty, CB_GETCURSEL, 0, 0);
-	std::string target;
+	std::string target = "difficulty";
 	switch (selected)
 	{
-	case 0:
-		for (auto& l : configText)
-		{
-			if (l.find(target) != std::string::npos)
-			{
-				l = target + "=";
-				return;
-			}
-		}
-		break;
 	case 1:
 		for (auto& l : configText)
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=peaceful";
 				return;
 			}
 		}
@@ -212,7 +197,7 @@ static void ConfigSet_ComboDIY_Difficuty(std::vector<std::string>& configText, H
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=easy";
 				return;
 			}
 		}
@@ -222,7 +207,7 @@ static void ConfigSet_ComboDIY_Difficuty(std::vector<std::string>& configText, H
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=normal";
 				return;
 			}
 		}
@@ -232,7 +217,7 @@ static void ConfigSet_ComboDIY_Difficuty(std::vector<std::string>& configText, H
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=hard";
 				return;
 			}
 		}
@@ -242,25 +227,15 @@ static void ConfigSet_ComboDIY_Difficuty(std::vector<std::string>& configText, H
 static void ConfigSet_ComboDIY_Level(std::vector<std::string>& configText, HWND hWnd1)
 {
 	int selected = SendMessage(hPermission, CB_GETCURSEL, 0, 0);
-	std::string target;
+	std::string target = "default-player-permission-level";
 	switch (selected)
 	{
-	case 0:
-		for (auto& l : configText)
-		{
-			if (l.find(target) != std::string::npos)
-			{
-				l = target + "=";
-				return;
-			}
-		}
-		break;
 	case 1:
 		for (auto& l : configText)
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=visitor";
 				return;
 			}
 		}
@@ -270,7 +245,7 @@ static void ConfigSet_ComboDIY_Level(std::vector<std::string>& configText, HWND
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=member";
 				return;
 			}
 		}
@@ -280,7 +255,7 @@ static void ConfigSet_ComboDIY_Level(std::vector<std::string>& configText, HWND
 		{
 			if (l.find(target) != std::string::npos)
 			{
-				l = target + "=";
+				l = target + "=operator";
 				return;
 			}
 		}

+ 13 - 6
Ui for BDS/configEditProc.cpp

@@ -6,6 +6,8 @@
 #include <vector>
 
 HFONT Font();
+HWND hGamemode, hDifficulty, hPermission;
+WORD wmId, wmEvent;
 
 LRESULT CALLBACK ConfProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam)
 {
@@ -15,7 +17,7 @@ LRESULT CALLBACK ConfProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam)
     {
         HFONT hFont = Font();
 
-         HWND hLabel_1 = CreateWindow(
+        HWND hLabel_1 = CreateWindow(
             L"STATIC", L"·þÎñÆ÷Ãû³Æ",
             WS_VISIBLE | WS_CHILD,
             20, 20, 100, 30,
@@ -44,7 +46,7 @@ LRESULT CALLBACK ConfProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam)
             hWnd1, NULL,
             (HINSTANCE)GetWindowLongPtr(hWnd1, GWLP_HINSTANCE), NULL
         );
-        HWND hGamemode = CreateWindow(
+        hGamemode = CreateWindow(
             L"COMBOBOX", NULL,
             WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST,
             150, 150, 150, 100,
@@ -70,7 +72,7 @@ LRESULT CALLBACK ConfProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam)
             hWnd1, NULL,
             (HINSTANCE)GetWindowLongPtr(hWnd1, GWLP_HINSTANCE), NULL
         );
-        HWND hDifficulty = CreateWindow(
+        hDifficulty = CreateWindow(
             L"COMBOBOX", NULL,
             WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST,
             150, 195, 150, 100,
@@ -107,7 +109,7 @@ LRESULT CALLBACK ConfProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam)
             hWnd1, NULL,
             (HINSTANCE)GetWindowLongPtr(hWnd1, GWLP_HINSTANCE), NULL
         );
-        HWND hPermission = CreateWindow(
+        hPermission = CreateWindow(
             L"COMBOBOX", NULL,
             WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST,
             210, 320, 150, 100,
@@ -307,8 +309,8 @@ LRESULT CALLBACK ConfProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam)
 
     case WM_COMMAND:
     {
-        WORD wmId = LOWORD(wParam);
-        WORD wmEvent = HIWORD(wParam);
+        wmId = LOWORD(wParam);
+        wmEvent = HIWORD(wParam);
 
         if (wmEvent == CBN_SELCHANGE && wmId == CONF_GameMode)
         {
@@ -328,9 +330,14 @@ LRESULT CALLBACK ConfProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam)
             }
         }
 
+        //Update(hWnd1,);
+        Update(hWnd1, CONF_Cheat, CONF_Cheat_NOEDIT);
 
         switch (wmId)
         {
+        case CONF_OPENCONFIG:
+            ShellExecute(NULL, L"open", L"server.properties", NULL, NULL, SW_SHOW);
+            break;
         case CONF_OK:
             Submit(hWnd1);
             DestroyWindow(hWnd1);