File size: 1,864 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
class ScriptConsoleUniversalInfoDialog extends UIScriptedMenu
{
	private const int EDITBOX_TEXT_SIZE = 16;
	
	private TextWidget m_Label;
	private ScrollWidget m_ContentScroll;
	private MultilineEditBoxWidget m_Content;
	private ButtonWidget m_OKButton;
	
	void ScriptConsoleUniversalInfoDialog();
	void ~ScriptConsoleUniversalInfoDialog();

	override Widget Init()
	{
		layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/script_console/script_console_universal_info_dialog.layout");
		m_Label = TextWidget.Cast(layoutRoot.FindAnyWidget("Label"));
		m_ContentScroll = ScrollWidget.Cast(layoutRoot.FindAnyWidget("ContentScroll"));
		m_ContentScroll.VScrollToPos(0);
		m_Content = MultilineEditBoxWidget.Cast(layoutRoot.FindAnyWidget("Content"));
		m_OKButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("MessageText"));

		return layoutRoot;
	}

	override bool OnClick(Widget w, int x, int y, int button)
	{
		super.OnClick(w, x, y, button);
		
		if (w.GetUserID() == IDC_OK)
		{
			UIScriptedMenu consoleMenu = GetGame().GetUIManager().FindMenu(MENU_SCRIPTCONSOLE);
			if (consoleMenu != null)
			{
				ScriptConsole scriptedConsole = ScriptConsole.Cast(consoleMenu);
				ScriptConsoleItemsTab tab = ScriptConsoleItemsTab.Cast(scriptedConsole.GetTabHandler(ScriptConsoleItemsTab));
				if (tab)
				{
					Close();
					return true;
				}
			}
		}

		return false;
	}
	
	void SetLabel(string label)
	{
		m_Label.SetText(label);
	}
	
	void SetContent(string content)
	{
		m_Content.SetText(content);
		m_Content.Update();
		float contentSizeX, contentSizeY = 0;
		m_Content.GetSize(contentSizeX, contentSizeY);
		m_Content.SetSize(contentSizeX, EDITBOX_TEXT_SIZE * m_Content.GetLinesCount());
		float y_c = m_ContentScroll.GetContentHeight();
		float x, y;
		m_Content.GetScreenSize(x, y);
		if (y > y_c)
		{
			m_ContentScroll.SetAlpha(1);
		}
	}
}