Thread Tools Display Modes
02-08-15, 11:12 AM   #1
odjur84
A Fallenroot Satyr
 
odjur84's Avatar
Join Date: Jan 2015
Posts: 24
Problem: DressUpModel:Show()

Hi!

I want to present to you another problem, that I've encountered with my LootCouncil-Addon. Short version: I create a "DessUpModel" to allow users (who are allowed to vote for transmog-need in my guild) to inspect the available loot and to try it on directly in the addon frame. For this reason I load the player-textures and the itemlink, which works perfectly, but when I try to show the DressUpModel via :Show(), nothing happens, regardless of where I post that command, even one line after the creation of the frame it doesn't work. So, here comes the code:

creating the DressUpModel:

Code:
local frame = CreateFrame("Frame");
frame:RegisterEvent("LOOT_OPENED");
frame:RegisterEvent("ADDON_LOADED");
local newmodel = CreateFrame("DressUpModel", "ORC_DressupModel", UIparent);
newmodel:SetSize(232, 320);
newmodel:SetPoint("CENTER", 0, 0);
newmodel:SetScript("OnShow", ORC_DressupModel_OnShow);
newmodel:SetScript("OnHide", ORC_DressupModel_OnHide);
Even directly after "SetScript("OnShow"...)" :Show() doesn't work!

creating the loot buttons:

Code:
local newButton = CreateFrame("Button", nil, ORC_FrameUser, "ItemButtonTemplate");
    positionButton(newButton, buttonNumber, "loot");
    newButton:SetSize(32, 32);
    ORC_lootFrames[buttonNumber] = newButton;
    ORC_lootLinks[buttonNumber] = link;
    ORC_existingButtons = ORC_existingButtons + 1;
    ORC_existingVoteButtons = ORC_existingVoteButtons + 1;
    SetItemButtonTexture(newButton, icon);
    ORC_lootFrames[buttonNumber]:SetScript("OnEnter", showTooltip);
    ORC_lootFrames[buttonNumber]:SetScript("OnLeave", hideTooltip);
    ORC_lootFrames[buttonNumber]:SetScript("OnClick", dressup);
    ORC_lootFrames[buttonNumber]:Show();
getting the item link to try on:

Code:
local function dressup(self)
    for i = 1, #ORC_lootFrames do
        if (self == ORC_lootFrames[i]) then
            ORC_DressupItem = ORC_lootLinks[i];
            --ORC_DressupModel:SetCreature(8570);
            break;
        end
    end
end
and loading the playermodel + the item:

Code:
function ORC_DressupModel_OnShow()
    ORC_DressupModel:SetUnit("player");
    ORC_RotateLeftButton:SetNormalTexture("Interface\\Buttons\\UI-RotationLeft-Button-Up");
    ORC_RotateRightButton:SetNormalTexture("Interface\\Buttons\\UI-RotationRight-Button-Up");
    ORC_RotateLeftButton:SetPushedTexture("Interface\\Buttons\\UI-RotationLeft-Button-Down");
    ORC_RotateRightButton:SetPushedTexture("Interface\\Buttons\\UI-RotationRight-Button-Down"); 
    ORC_RotateLeftButton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Round", "ADD");
    ORC_RotateRightButton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Round", "ADD");
    if (ORC_DressupItem and IsDressableItem(ORC_DressupItem)) then
        ORC_DressupModel:TryOn(ORC_DressupItem);
    else
        return false;
    end 
end
As I said: I tried to call ORC_DressupModel:Show(); serveral times, but it never shows the model. I've also already checked if the Model is actually created - it is since (print(ORC_DressupModel)) prints something like "tablexxxxx".

What do I overlook?

Greetings!
  Reply With Quote
02-08-15, 12:57 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
Do you have Lua Errors enabled in your interface options? If there's a syntax error somewhere in your code, the game may be trying to tell you.

It also has been noted that compile time errors may not always appear during login, but I've gotten them to show after a /reload. Others suggest using an error handling addon like BugGrabber.



-== Edit ==-
Originally Posted by odjur84 View Post
Code:
local frame = CreateFrame("Frame");
frame:RegisterEvent("LOOT_OPENED");
frame:RegisterEvent("ADDON_LOADED");
local newmodel = CreateFrame("DressUpModel", "ORC_DressupModel", UIparent);
newmodel:SetSize(232, 320);
newmodel:SetPoint("CENTER", 0, 0);
newmodel:SetScript("OnShow", ORC_DressupModel_OnShow);
newmodel:SetScript("OnHide", ORC_DressupModel_OnHide);
This should be UIParent. Even with the incorrect case, it theoretically should work as it would resolve to nil and objects are not required to have parents.



Some other things I'd like to point out:
Originally Posted by odjur84 View Post
Code:
function ORC_DressupModel_OnShow()
    ORC_DressupModel:SetUnit("player");
    ORC_RotateLeftButton:SetNormalTexture("Interface\\Buttons\\UI-RotationLeft-Button-Up");
    ORC_RotateRightButton:SetNormalTexture("Interface\\Buttons\\UI-RotationRight-Button-Up");
    ORC_RotateLeftButton:SetPushedTexture("Interface\\Buttons\\UI-RotationLeft-Button-Down");
    ORC_RotateRightButton:SetPushedTexture("Interface\\Buttons\\UI-RotationRight-Button-Down"); 
    ORC_RotateLeftButton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Round", "ADD");
    ORC_RotateRightButton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Round", "ADD");
    if (ORC_DressupItem and IsDressableItem(ORC_DressupItem)) then
        ORC_DressupModel:TryOn(ORC_DressupItem);
    else
        return false;
    end 
end
These lines shouldn't be in a script handler. You only need to set these once and forget about them. Also returning a value from this function does nothing.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 02-08-15 at 01:17 PM.
  Reply With Quote
02-08-15, 01:31 PM   #3
odjur84
A Fallenroot Satyr
 
odjur84's Avatar
Join Date: Jan 2015
Posts: 24
Hi!

Thank you very much for your help, I really appreciate it. I've installed BugGrabber and got the following error message in the starting process of the addon (before any user action is done):

[string "ORC_FrameUser:OnLoad"]:1: attempt to call global 'ORC_FrameUser_OnLoad' (a nil value)
[string "*:OnLoad"]:1: in function <[string "*:OnLoad"]:1>
Does this make any sense? I didn't get this error message in the normal process (neither with nor without /reload). But if ORC_FrameUser can't be loaded, why is it possible to :Show() it?

I add the XML- and LUA-file, since it seem to be a deeper problem.

Greetings!

PS: Thank you for your corrections, I've implemented them.

Last edited by odjur84 : 02-24-15 at 08:36 AM.
  Reply With Quote
02-08-15, 02:18 PM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
That error is being caused by you attempting to call ORC_FrameUser_OnLoad() in your xml file, and there is no function with that name in either file.
  Reply With Quote
02-08-15, 02:38 PM   #5
odjur84
A Fallenroot Satyr
 
odjur84's Avatar
Join Date: Jan 2015
Posts: 24
Hi!

Thank you, semlar. I've handled that, but unfortunately that didn't solve the problem. I really don't know how :Show() can't work with a correctly created frame. Is there any property of a DressUpModel (or a model or an object) that prevents showing it?

Greetings!

Last edited by odjur84 : 02-24-15 at 08:36 AM.
  Reply With Quote
02-08-15, 02:53 PM   #6
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The model is not visible for 2 reasons.

1. Your OnShow function is not being set because ORC_DressupModel_OnShow is being defined after newmodel:SetScript("OnShow", ORC_DressupModel_OnShow) is called, so it isn't calling that function when it's shown.

2. You aren't hiding the model after it's being created, so trying to show an already visible frame won't trigger its OnShow function anyway.
  Reply With Quote
02-08-15, 02:59 PM   #7
odjur84
A Fallenroot Satyr
 
odjur84's Avatar
Join Date: Jan 2015
Posts: 24
Thank you, that did the trick! So simple...
  Reply With Quote
02-09-15, 09:48 AM   #8
odjur84
A Fallenroot Satyr
 
odjur84's Avatar
Join Date: Jan 2015
Posts: 24
Hi!

I have two other problems with my DressupModel, respectively the model itself and a button i want to place on it. I'm really sorry for my nooby questions, but I simply have a lot more to learn. I have the following code:

Code:
local frame = CreateFrame("Frame");
frame:RegisterEvent("LOOT_OPENED");
frame:RegisterEvent("ADDON_LOADED");
frame:RegisterEvent("CHAT_MSG_ADDON");
local newframe = CreateFrame("Frame", "ORC_DressupFrame", UIFrame);
newframe:SetMovable(true);
newframe:SetClampedToScreen(true);
newframe:SetBackdrop( { 
  bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", 
  edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", tile = true, tileSize = 32, edgeSize = 32, 
  insets = { left = 11, right = 12, top = 12, bottom = 11 }
});
newframe:SetSize(232, 320);
newframe:SetPoint("CENTER", 0, 0);
newframe:SetScript("OnDragStart", newframe:StartMoving());
newframe:Hide();
local newmodel = CreateFrame("DressUpModel", "ORC_DressupModel", ORC_DressupFrame);
newmodel:SetMovable(true);
newframe:SetClampedToScreen(true);
newmodel:SetSize(232, 320);
newmodel:SetPoint("CENTER", 0, 0);
newmodel:SetScript("OnShow", ORC_DressupModel_OnShow);
newmodel:SetScript("OnHide", ORC_DressupModel_OnHide);
newmodel:SetScript("OnDragStart", newmodel:StartMoving());
newmodel:SetFrameStrata("HIGH");
local newButton = CreateFrame("Button", "ORC_RotateRightButton", ORC_DressupModel);
newButton:SetScript("OnMouseDown", ORC_Model_RotateRight);
newButton:SetSize(35, 35);
newButton:SetPoint("TOPLEFT", 156, -3);
newButton:Show();
local newButton = CreateFrame("Button", "ORC_RotateLeftButton", ORC_DressupModel);
newButton:SetScript("OnMouseDown", ORC_Model_RotateLeft);
newButton:SetSize(35, 35);
newButton:SetPoint("TOPLEFT", 194, -3);
newButton:Show();
ORC_RotateLeftButton:SetNormalTexture("Interface\\Buttons\\UI-RotationLeft-Button-Up");
ORC_RotateRightButton:SetNormalTexture("Interface\\Buttons\\UI-RotationRight-Button-Up");
ORC_RotateLeftButton:SetPushedTexture("Interface\\Buttons\\UI-RotationLeft-Button-Down");
ORC_RotateRightButton:SetPushedTexture("Interface\\Buttons\\UI-RotationRight-Button-Down"); 
ORC_RotateLeftButton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Round", "ADD");
ORC_RotateRightButton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Round", "ADD");
local newButton = CreateFrame("Button", "ORC_DressupClose", ORC_DressupModel);
newButton:SetScript("OnClick", ORC_DressupClose_OnClick);
newButton:SetSize(75, 23);
newButton:SetPoint("TOPLEFT", 83, -279);
newButton:SetText("Schließen");
newButton:Show();
Two questions:

1.) Why is the last newButton not displayed? I've tried rename the variables and the button itself, I've changed the Anchors and deleted the Show-call, but nothing worked. I've even tried to create another button on the UIFrame and that also didn't work.

2.) Why does the DressupFrame constantly stick to the mouse cursor so I can't do anything else than close WoW? Adding the "OnDragStop", "StopMovingOrSizing" doesn't work.

Greetings!
  Reply With Quote
02-10-15, 04:13 AM   #9
odjur84
A Fallenroot Satyr
 
odjur84's Avatar
Join Date: Jan 2015
Posts: 24
Alright... I was able to solve it by myself. :-)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problem: DressUpModel:Show()

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off