File size: 1,881 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class ScriptConsoleAddLocation extends UIScriptedMenu
{
	void ScriptConsoleAddLocation()
	{

	}

	void ~ScriptConsoleAddLocation()
	{
	}
	
	void SetPosition(vector pos)
	{
		m_EditboxPos.SetText(pos.ToString());
	}

	override Widget Init()
	{
		m_ConfigDebugProfile = PluginConfigDebugProfile.Cast( GetPlugin(PluginConfigDebugProfile) );
		layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/script_console/script_console_add_location_dialogue.layout");
		m_EditboxName = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("LocationName") );
		m_EditboxPos = EditBoxWidget.Cast( layoutRoot.FindAnyWidget("Position") );
		m_Label = TextWidget.Cast( layoutRoot.FindAnyWidget("WindowLabel") );
		m_ClearButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget("ButtonClear") );
		m_Label.SetText("ADD NEW LOCATION");

		return layoutRoot;
	}

	override bool OnClick(Widget w, int x, int y, int button)
	{
		super.OnClick(w, x, y, button);

		if (w.GetUserID() == IDC_OK)
		{
			string name = m_EditboxName.GetText();
			ScriptConsole console = ScriptConsole.Cast(GetGame().GetUIManager().FindMenu(MENU_SCRIPTCONSOLE));
			ScriptConsoleGeneralTab tab = ScriptConsoleGeneralTab.Cast(console.GetTabHandler(ScriptConsoleGeneralTab));
			if (tab)
			{
				if (!tab.IsLocationNameAvailable(name) || name == "" || m_EditboxPos.GetText() == "")
					return false;
				m_ConfigDebugProfile.CustomLocationsAdd(name, m_EditboxPos.GetText().BeautifiedToVector());
				Close();
				tab.RefreshLocations();
				return true;
			}
		}
		else if (w.GetUserID() == IDC_CANCEL)
		{
			Close();
			return true;
		}
		else if (w == m_ClearButton)
		{
			m_EditboxPos.SetText("");
			return true;
		}

		return false;
	}
	PluginConfigDebugProfile m_ConfigDebugProfile;
	EditBoxWidget m_EditboxName;
	EditBoxWidget m_EditboxPos;
	TextWidget m_Label;
	TextWidget m_Message;
	ButtonWidget m_ClearButton;
}