-- инициализация
class "dots" (CUIScriptWnd)

function dots:__init(owner,objid) super()
	self.targt = objid
	self.owner = owner
	self:InitControls()
	self:InitCallBacks()
end

function dots:__finalize() end

function dots:InitControls()
	self:SetWndRect(Frect():set(0,0,1024,768))
	self:Enable(true)
	
	-- файл-описатель наших элементов
	local xml = CScriptXmlInit()
	xml:ParseFile("ui_si_dlg.xml")

	self.dialog					= xml:InitStatic("dialog", self)
	xml:InitStatic				("capt", self.dialog)
	xml:InitStatic				("msg2", self.dialog)
	
	-- кнопки
	self:Register(xml:Init3tButton("btn_1", self.dialog),"btn_1")
--	self:Register(xml:Init3tButton("btn_quit", self.dialog),"btn_quit")
	self:Register(xml:InitEditBox("edit_box", 	self.dialog), "edit_box")
	self:Register(xml:InitEditBox("edit_box2", 	self.dialog), "edit_box2")
	self:Register(xml:InitEditBox("edit_box3", 	self.dialog), "edit_box3")
end

function dots:InitCallBacks()
	-- тут интерактивные элементы, при определенном действии выполняется заданная ф-ия
	self:AddCallback("btn_1", ui_events.BUTTON_CLICKED, self.dots1, self)
--	self:AddCallback("btn_quit", ui_events.BUTTON_CLICKED, self.on_quit, self)
end

function dots:OnKeyboard(dik, keyboard_action)
	CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
	if keyboard_action == ui_events.WINDOW_KEY_PRESSED then
-- на выход повесим Esc
		if dik == DIK_keys.DIK_ESCAPE then
			self:on_quit()
		end
		if dik == DIK_keys.DIK_RETURN then
			self:dots1()
		end
	end
	return true
end

function dots:dots1()
	edit_box		= self:GetEditBox("edit_box")
	edit_box2		= self:GetEditBox("edit_box2")
	edit_box3		= self:GetEditBox("edit_box3")

      pos_x = tonumber(edit_box:GetText())
      pos_y = tonumber(edit_box2:GetText())
      pos_z = tonumber(edit_box3:GetText())


get_console():execute(pos_x)
get_console():execute(pos_y)
get_console():execute(pos_z)


get_console():execute("Started")

if db.actor then
-- self:on_quit()
-- get_console():execute("main_menu off")
get_console():execute("P1")
if pos_x==nil then pos_x=db.actor:position().x end
if pos_y==nil then pos_y=db.actor:position().y end
if pos_z==nil then pos_z=db.actor:position().z end
get_console():execute("P2")
local pos = vector():set(pos_x,pos_y,pos_z)
db.actor:set_actor_position(pos)
get_console():execute("P3")
end
end

function dots:on_quit()
	self:GetHolder():start_stop_menu	(self,false)
	self.owner:Show						(true)
end


