aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIControl_TextInput.cpp
blob: dc7bc532672875cd2edfda770b1a654d5023a7f5 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "stdafx.h"
#include "UI.h"
#include "UIControl_TextInput.h"

UIControl_TextInput::UIControl_TextInput()
{
	m_bHasFocus = false;
}

bool UIControl_TextInput::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
	UIControl::setControlType(UIControl::eTextInput);
	bool success = UIControl_Base::setupControl(scene,parent,controlName);

	//TextInput specific initialisers
	m_textName = registerFastName(L"text");
	m_funcChangeState = registerFastName(L"ChangeState");
	m_funcSetCharLimit = registerFastName(L"SetCharLimit");

	return success;
}

void UIControl_TextInput::init(UIString label, int id)
{
	m_label = label;
	m_id = id;

	IggyDataValue result;
	IggyDataValue value[2];
	value[0].type = IGGY_DATATYPE_string_UTF16;
	IggyStringUTF16 stringVal;

	stringVal.string = (IggyUTF16*)label.c_str();
	stringVal.length = label.length();
	value[0].string16 = stringVal;

	value[1].type = IGGY_DATATYPE_number;
	value[1].number = id;
	IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 2 , value );

 #ifdef __PSVITA__
 	// 4J-TomK - add this buttonlist to the vita touch box list
 
 	switch(m_parentScene->GetParentLayer()->m_iLayer)
 	{
 	case eUILayer_Fullscreen:
 	case eUILayer_Scene:
 	case eUILayer_HUD:
 		ui.TouchBoxAdd(this,m_parentScene);
 		break;
 	}
 #endif
}

void UIControl_TextInput::ReInit()
{
	UIControl_Base::ReInit();

	init(m_label, m_id);
}

void UIControl_TextInput::setFocus(bool focus)
{
	if(m_bHasFocus != focus)
	{
		m_bHasFocus = focus;

		IggyDataValue result;
		IggyDataValue value[1];
		value[0].type = IGGY_DATATYPE_number;
		value[0].number = focus?0:1;
		IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcChangeState , 1 , value );
	}
}

void UIControl_TextInput::SetCharLimit(int iLimit)
{
	IggyDataValue result;
	IggyDataValue value[1];
	value[0].type = IGGY_DATATYPE_number;
	value[0].number = iLimit;
	IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcSetCharLimit , 1 , value );
}