Mercurial > wow > askmrrobot
comparison Import.lua @ 69:69db1c3025ac v27
fixed some bugs with 6.2 item link format changes, added bib overwolf support
author | yellowfive |
---|---|
date | Mon, 06 Jul 2015 17:39:57 -0700 |
parents | 01b63b8ed811 |
children | 0515882856f1 |
comparison
equal
deleted
inserted
replaced
68:6c523f147709 | 69:69db1c3025ac |
---|---|
2 local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true) | 2 local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true) |
3 local AceGUI = LibStub("AceGUI-3.0") | 3 local AceGUI = LibStub("AceGUI-3.0") |
4 | 4 |
5 local _txtImport | 5 local _txtImport |
6 local _lblError | 6 local _lblError |
7 local _panelCover | |
7 | 8 |
8 local function onImportOkClick(widget) | 9 local function onImportOkClick(widget) |
9 local txt = _txtImport:GetText() | 10 local txt = _txtImport:GetText() |
10 local msg = Amr:ImportCharacter(txt) | 11 local msg = Amr:ImportCharacter(txt) |
11 if msg then | 12 if msg then |
19 | 20 |
20 local function onImportCancelClick(widget) | 21 local function onImportCancelClick(widget) |
21 Amr:HideCover() | 22 Amr:HideCover() |
22 end | 23 end |
23 | 24 |
24 local function renderImportWindow(container) | 25 local function onTextEnterPressed(widget) |
26 -- hide the overwolf cover when import data is received | |
27 if _panelCover then | |
28 _panelCover:SetVisible(false) | |
29 end | |
30 | |
31 -- do an import if the data starts and ends with a dollar sign | |
32 local txt = _txtImport:GetText() | |
33 local txtLen = string.len(txt) | |
34 if txtLen > 2 and string.sub(txt, 1, 1) == '$' then | |
35 onImportOkClick() | |
36 end | |
37 | |
38 end | |
39 | |
40 local function renderImportWindow(container, fromOverwolf) | |
25 | 41 |
26 local panelImport = Amr:RenderCoverChrome(container, 700, 450) | 42 local panelImport = Amr:RenderCoverChrome(container, 700, 450) |
27 | 43 |
28 local lbl = AceGUI:Create("AmrUiLabel") | 44 local lbl = AceGUI:Create("AmrUiLabel") |
29 lbl:SetWidth(600) | 45 lbl:SetWidth(600) |
34 _txtImport = AceGUI:Create("AmrUiTextarea") | 50 _txtImport = AceGUI:Create("AmrUiTextarea") |
35 _txtImport:SetWidth(600) | 51 _txtImport:SetWidth(600) |
36 _txtImport:SetHeight(300) | 52 _txtImport:SetHeight(300) |
37 _txtImport:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -10) | 53 _txtImport:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -10) |
38 _txtImport:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text)) | 54 _txtImport:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text)) |
55 _txtImport:SetCallback("OnEnterPressed", onTextEnterPressed) | |
39 panelImport:AddChild(_txtImport) | 56 panelImport:AddChild(_txtImport) |
40 | 57 |
41 local btnImportOk = AceGUI:Create("AmrUiButton") | 58 local btnImportOk = AceGUI:Create("AmrUiButton") |
42 btnImportOk:SetText(L.ImportButtonOk) | 59 btnImportOk:SetText(L.ImportButtonOk) |
43 btnImportOk:SetBackgroundColor(Amr.Colors.Green) | 60 btnImportOk:SetBackgroundColor(Amr.Colors.Green) |
63 _lblError:SetFont(Amr.CreateFont("Bold", 14, Amr.Colors.Red)) | 80 _lblError:SetFont(Amr.CreateFont("Bold", 14, Amr.Colors.Red)) |
64 _lblError:SetText("") | 81 _lblError:SetText("") |
65 _lblError:SetPoint("TOPLEFT", btnImportOk.frame, "BOTTOMLEFT", 0, -20) | 82 _lblError:SetPoint("TOPLEFT", btnImportOk.frame, "BOTTOMLEFT", 0, -20) |
66 panelImport:AddChild(_lblError) | 83 panelImport:AddChild(_lblError) |
67 | 84 |
68 end | 85 if fromOverwolf then |
69 | 86 -- show a cover preventing interaction until we receive data from overwolf |
70 function Amr:ShowImportWindow() | 87 _panelCover = AceGUI:Create("AmrUiPanel") |
88 _panelCover:SetLayout("None") | |
89 _panelCover:EnableMouse(true) | |
90 _panelCover:SetBackgroundColor(Amr.Colors.Black, 0.75) | |
91 _panelCover:SetPoint("TOPLEFT", panelImport.frame, "TOPLEFT") | |
92 _panelCover:SetPoint("BOTTOMRIGHT", panelImport.frame, "BOTTOMRIGHT") | |
93 panelImport:AddChild(_panelCover) | |
94 | |
95 local coverMsg = AceGUI:Create("AmrUiLabel") | |
96 coverMsg:SetWidth(500) | |
97 coverMsg:SetFont(Amr.CreateFont("Regular", 16, Amr.Colors.TextTan)) | |
98 coverMsg:SetJustifyH("MIDDLE") | |
99 coverMsg:SetJustifyV("MIDDLE") | |
100 coverMsg:SetText(L.ImportOverwolfWait) | |
101 coverMsg:SetPoint("CENTER", _panelCover.frame, "CENTER", 0, 20) | |
102 _panelCover:AddChild(coverMsg) | |
103 | |
104 -- after adding, set cover to sit on top of everything | |
105 _panelCover:SetStrata("FULLSCREEN_DIALOG") | |
106 _panelCover:SetLevel(Amr.FrameLevels.Highest) | |
107 end | |
108 end | |
109 | |
110 function Amr:ShowImportWindow(fromOverwolf) | |
71 -- this is shown as a modal dialog | 111 -- this is shown as a modal dialog |
72 Amr:ShowCover(renderImportWindow) | 112 Amr:ShowCover(function(container) |
113 renderImportWindow(container, fromOverwolf) | |
114 end) | |
73 | 115 |
74 _txtImport:SetText("") | 116 _txtImport:SetText("") |
75 _txtImport:SetFocus(true) | 117 _txtImport:SetFocus(true) |
76 end | 118 end |
77 | 119 |