/*
*	OXWARE developed by oxiKKK
*	Copyright (c) 2023
*
*	This program is licensed under the MIT license. By downloading, copying,
*	installing or using this software you agree to this license.
*
*	License Agreement
*
*	Permission is hereby granted, free of charge, to any person obtaining a
*	copy of this software and associated documentation files (the "Software"),
*	to deal in the Software without restriction, including without limitation
*	the rights to use, copy, modify, merge, publish, distribute, sublicense,
*	and/or sell copies of the Software, and to permit persons to whom the
*	Software is furnished to do so, subject to the following conditions:
*
*	The above copyright notice and this permission notice shall be included
*	in all copies or substantial portions of the Software.
*
*	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
*	OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
*	THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
*	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
*	IN THE SOFTWARE.
*/

#include "precompiled.h"

void MenuChilden::Exploits::BypassGameConstrains::contents()
{
	CUIMenuWidgets::the().add_checkbox("Re-enable noclip", &bypass_constrain_noclip, "Makes it possible to re-enable noclip in singleplayer. sv_cheats must be enabled.");

	CUIMenuWidgets::the().add_checkbox("Enable", &bypass_constrain_renderdist_enable);
	CUIMenuWidgets::the().add_slider("Render distance", "%0.0f units", &bypass_constrain_renderdist_value);

	CUIMenuWidgets::the().add_checkbox("Clear background", &bypass_constrain_renderer_glclear);

	CUIMenuWidgets::the().section_unavailable_for_builds(
		[](int current_bn) { return current_bn <= 3266; }, "> 3266",
		[]()
		{
			CUIMenuWidgets::the().add_checkbox("Re-enable renderer cvars", &bypass_constrain_renderer_cvars);

			CUIMenuWidgets::the().add_description_text(
				"Disables R_ForceCVars, which is responsible for preventing some renderer cvars to be set.",

				"These cvars are:\n\nr_lightmap, gl_clear, r_novis, r_fullbright, snd_show, chase_active, gl_monolights, gl_wireframe, r_dynamic, gl_alphamin, gl_max_size, gl_polyoffset, r_drawentities.");
		});

	CUIMenuWidgets::the().add_checkbox("Disable SP-Only cvars", &bypass_constrain_sponly_cvars,
									   "Some cvars can be only set in singleplayer. Set this to be able to control these cvars also in MP. "
									   "See the console output for which cvars this affects.");
}

void MenuChilden::Exploits::ServerCommandFilter::contents()
{
	CStuffCmdFilter::the().render_ui();
}

void MenuChilden::Exploits::FrameSkipper::contents()
{
	CUIMenuWidgets::the().feature_enabled_section_incommands(
	&CFrameSkipper::the().frame_skipper,
	[]()
	{
		CUIMenuWidgets::the().add_slider("Amount", "%0.0f frames", &frame_skip_amount);

		CUIMenuWidgets::the().add_listbox("Type", &frame_skip_type, { "Skip every N frames", "Skip every Nth frame" });
		CUIMenuWidgets::the().add_listbox("Method", &frame_skip_method, { "UpdateScreen", "ViewportPaintBackground" });

		switch (frame_skip_method.get_value())
		{
			case 0:
			{
				CUIMenuWidgets::the().add_description_text(
					"UpdateScreen frame skip method or \"Frame simulation\" enables \"fake\" fps, that are mostly not physical, but visual only.");
				break;
			}
			case 1:
			{
				CUIMenuWidgets::the().add_description_text(
					"ViewportPaintBackground frame skip method enables to skip world rendering and game GUI, resulting in massive physical fps boosts.");
				break;
			}
		}
	});
}

void MenuChilden::Exploits::ConsistencyBypass::contents()
{
	CUIMenuWidgets::the().feature_enabled_section(
	&consistencybypass_enable,
	[]()
	{
		CUIMenuWidgets::the().add_checkbox("Logging", &consistencybypass_log);

		CUIMenuWidgets::the().add_description_text(
			"This enables to send false consistency information to the server, when it gets requested.",

			"Consistency in GoldSrc games is a technique that enables servers to check whenever clients have same files"
			" as the server does. The server can also check for malicious DLL files anywhere inside your Half-Life folder (cheat dlls)."
			" Plugins use this to detect cheats when you're connecting to a server and can ban you if they find some.\n\n"
			"This allows you to bypass not only the checks for invalid dlls, but also for other things such as models, sprites, sounds, etc.");
	});
}

void MenuChilden::Exploits::FakeLatency::contents()
{
	CUIMenuWidgets::the().feature_enabled_section(
	&fake_latency,
	[]()
	{
		CUIMenuWidgets::the().add_slider("Amount", "%0.0f ms", &fake_latency_amount);
	});
}

void MenuChilden::Exploits::SIDSpoofer::contents()
{
	CUIMenuWidgets::the().add_checkbox("Enable", &sid_spoofer_enable);

	CUIMenuWidgets::the().add_listbox("Type", &sid_spoofer_type, g_sid_emulators);
	
	CUIMenuWidgets::the().add_description_text(
		"All of these generators will produce different steam ID's for you when you connect to a server, "
		"choose which one you like. (NOTE: it doesn't really matter.)");
}

void MenuChilden::Exploits::CvarSandbox::contents()
{
	if (g_gui_widgets_i->begin_columns("cvar_sandbox_columns", 2))
	{
		g_gui_widgets_i->setup_column_fixed_width(200);
		g_gui_widgets_i->goto_next_column();

		CUIMenuWidgets::the().add_checkbox("Enable", &cvar_sandbox_enable);

		g_gui_widgets_i->add_spacing();

		CUIMenuWidgets::the().add_checkbox("Monitor server", &cvar_sandbox_monitor_server,
										   "Enables to see what cvars is the server requesting."
										   " See the console after you join a server, to see what cvars it requests from you.");

		g_gui_widgets_i->goto_next_column();

		g_gui_widgets_i->add_text("Description");

		CUIMenuWidgets::the().add_description_text(
			"\"Cvar sandbox\" is used to \"fake\" the server with cvar values.",

			"Occasionally, some servers request cvar values from the client such as \"fps_max\" etc. and"
			" they basically want to know the value - in order to kick you when the value is \"against their rules\"."
			"\n\nUsing this technique, you can basically send whatever cvar values you want to the server, when it requests it."
			"\n\nFor example, the server wants you to have \"fps_max\" set to \"100\", but you don't want to. Change the value here, "
			"and when the server will request this cvar value, it will send him whatever value you've specified here, instead of the real one."
		);

		g_gui_widgets_i->end_columns();
	}

	// too much code to have inside of the menu...
	CCvarSandbox::the().render_ui();
}
