File size: 2,121 Bytes
402daee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
--[[

  ReaSpeechProductActivationUI.lua - ReaSpeech Product Activation UI

]]--

ReaSpeechProductActivationUI = Polo {
  LARGE_ITEM_WIDTH = 375,
}

function ReaSpeechProductActivationUI:init()
  assert(self.product_activation, 'missing product activation')
  self.license_input = ''
end

function ReaSpeechProductActivationUI:render()
  if self.product_activation.state ~= "activated" then
    self:render_activation_inputs()
    return
  end

  if not self.product_activation.config:get('eula_signed') then
    self:render_EULA_inputs()
    return
  end
end

function ReaSpeechProductActivationUI:render_activation_inputs()
  ImGui.Text(ctx, ('Welcome to ReaSpeech by Tech Audio'))
  ImGui.Dummy(ctx, self.LARGE_ITEM_WIDTH, 25)
  ImGui.Text(ctx, ('Please enter your license key to get started'))
  ImGui.Dummy(ctx, self.LARGE_ITEM_WIDTH, 5)
  ImGui.PushItemWidth(ctx, self.LARGE_ITEM_WIDTH)
  app:trap(function ()
    local rv, value = ImGui.InputText(ctx, '##', self.license_input)
    if rv then
      self.license_input = value
    end
    if self.product_activation.activation_message ~= "" then
      --Possibly make this ColorText with and change depending on message
      ImGui.SameLine(ctx)
      ImGui.Text(ctx, self.product_activation.activation_message)
    end
  end)
  ImGui.PopItemWidth(ctx)
  ImGui.Dummy(ctx, self.LARGE_ITEM_WIDTH, 30)
  if ImGui.Button(ctx, "Submit") then
    self:handle_product_activation(self.license_input)
  end
end

function ReaSpeechProductActivationUI:render_EULA_inputs()
  ImGui.PushItemWidth(ctx, self.LARGE_ITEM_WIDTH)
  app:trap(function ()
    ImGui.Text(ctx, 'EULA')
    ImGui.Dummy(ctx, self.LARGE_ITEM_WIDTH, 25)
    ImGui.TextWrapped(ctx, ReaSpeechEULAContent)
    ImGui.Dummy(ctx, self.LARGE_ITEM_WIDTH, 25)
     if ImGui.Button(ctx, "Agree") then
      self.product_activation.config:set('eula_signed', true)
    end
  end)
  ImGui.PopItemWidth(ctx)
end

function ReaSpeechProductActivationUI:handle_product_activation(input_license)
  --reaper.ShowConsoleMsg(tostring(input_license) .. '\n')
  self.product_activation:handle_product_activation(input_license)
end