Code/ServerApp/Source/ServerInfoTab.cpp
//=================================================================================================
// Edit an existing or new Client Config entry
Edit an existing or new Client Config entry
Edit an existing or new Client Config entry
void ServerInfoTab_DrawClient_SectionConfig_PopupEdit(ClientConfig*& pEditClientCfg)
{	
	bool bOpenEdit(pEditClientCfg);
	if (bOpenEdit)
	{		
		ImGui::OpenPopup("Edit Client Info");
		if (ImGui::BeginPopupModal("Edit Client Info", &bOpenEdit, ImGuiWindowFlags_AlwaysAutoResize))
		{
			ImGui::NewLine();
			ImGui::InputText("Display Name", pEditClientCfg->ClientName, sizeof(pEditClientCfg->ClientName));
			ImGui::InputText("Host Name", pEditClientCfg->HostName, sizeof(pEditClientCfg->HostName));
			if( ImGui::IsItemHovered() ){
				ImGui::SetTooltip("IP address or name of the host to reach");
			}
			int port = static_cast<int>(pEditClientCfg->HostPort);
			if( ImGui::InputInt("Host Port", &port, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue) ){
				pEditClientCfg->HostPort = std::min<int>(0xFFFF, std::max<int>(1, port));
			}
			ImGui::SameLine();
			if (ImGui::Button("Default")){
				pEditClientCfg->HostPort = NetImgui::kDefaultClientPort;
			}
			ImGui::Checkbox("Auto Connect", &pEditClientCfg->ConnectAuto);
			ImGui::NewLine();
			ImGui::Separator();
			bOpenEdit &= !ImGui::Button("Cancel", ImVec2(ImGui::GetContentRegionAvailWidth()/2.f, 0));
			ImGui::SetItemDefaultFocus();
			ImGui::SameLine();
			if (ImGui::Button("Save", ImVec2(ImGui::GetContentRegionAvailWidth(), 0))){
				ClientConfig::SetConfig(*pEditClientCfg);
				ClientConfig::SaveAll();
				bOpenEdit = false;
			}
			ImGui::EndPopup();
		}
	}	
	if( !bOpenEdit ){
		SafeDelete(pEditClientCfg);
	}
}
void ServerInfoTab_DrawClient_SectionConfig_PopupEdit ( ClientConfig * & pEditClientCfg ) { bool bOpenEdit ( pEditClientCfg ) ; if ( bOpenEdit ) { ImGui :: OpenPopup ( " " ) ; if ( ImGui :: BeginPopupModal ( " " , & bOpenEdit , ImGuiWindowFlags_AlwaysAutoResize ) ) { ImGui :: NewLine ( ) ; ImGui :: InputText ( " " , pEditClientCfg -> ClientName , sizeof ( pEditClientCfg -> ClientName ) ) ; ImGui :: InputText ( " " , pEditClientCfg -> HostName , sizeof ( pEditClientCfg -> HostName ) ) ; if ( ImGui :: IsItemHovered ( ) ) { ImGui :: SetTooltip ( " " ) ; } int port = static_cast < int > ( pEditClientCfg -> HostPort ) ; if ( ImGui :: InputInt ( " " , & port , 1 , 100 , ImGuiInputTextFlags_EnterReturnsTrue ) ) { pEditClientCfg -> HostPort = std :: min < int > ( 0xFFFF , std :: max < int > ( 1 , port ) ) ; } ImGui :: SameLine ( ) ; if ( ImGui :: Button ( " " ) ) { pEditClientCfg -> HostPort = NetImgui :: kDefaultClientPort ; } ImGui :: Checkbox ( " " , & pEditClientCfg -> ConnectAuto ) ; ImGui :: NewLine ( ) ; ImGui :: Separator ( ) ; bOpenEdit &= ! ImGui :: Button ( " " , ImVec2 ( ImGui :: GetContentRegionAvailWidth ( ) / 2.f , 0 ) ) ; ImGui :: SetItemDefaultFocus ( ) ; ImGui :: SameLine ( ) ; if ( ImGui :: Button ( " " , ImVec2 ( ImGui :: GetContentRegionAvailWidth ( ) , 0 ) ) ) { ClientConfig :: SetConfig ( * pEditClientCfg ) ; ClientConfig :: SaveAll ( ) ; bOpenEdit = false ; } ImGui :: EndPopup ( ) ; } } if ( ! bOpenEdit ) { SafeDelete ( pEditClientCfg ) ; } }
Edit an existing or new Client Config entry
Edit an existing or new Client Config entry
//================================================================================================= // --- Name --- // --- IP Address --- // --- Port --- // --- Auto --- // --- Save/Cancel ---