WoWInterface SVN Xcalc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 8 to Rev 9
    Reverse comparison

Rev 8 → Rev 9

trunk/Localization.lua
1,35 → 1,37
BINDING_HEADER_XCALC = "xcalc (automatic)";
BINDING_NAME_XC_NUMLOCK = "Numlock";
BINDING_NAME_XC_CLEAR = "Clear";
BINDING_NAME_XC_CLOSE = "Close";
BINDING_NAME_XC_DIV = "Divide";
BINDING_NAME_XC_MUL = "Multiply";
BINDING_NAME_XC_SUB = "Subtract";
BINDING_NAME_XC_ADD = "Add";
BINDING_NAME_XC_EQ = "Equals";
BINDING_NAME_XC_0 = "Digit 0";
BINDING_NAME_XC_1 = "Digit 1";
BINDING_NAME_XC_2 = "Digit 2";
BINDING_NAME_XC_3 = "Digit 3";
BINDING_NAME_XC_4 = "Digit 4";
BINDING_NAME_XC_5 = "Digit 5";
BINDING_NAME_XC_6 = "Digit 6";
BINDING_NAME_XC_7 = "Digit 7";
BINDING_NAME_XC_8 = "Digit 8";
BINDING_NAME_XC_9 = "Digit 9";
BINDING_NAME_XC_DEC = "Decimal";
BINDING_NAME_XC_BACKSPACE = "Backspace";
BINDING_HEADER_XCALC = "xcalc"
BINDING_NAME_XC_TOGGLEWINDOW = "Toggle xcalc"
BINDING_HEADER_XCALC_AUTOMATIC = "xcalc (automatic)"
BINDING_NAME_XC_NUMLOCK = "Numlock"
BINDING_NAME_XC_CLEAR = "Clear"
BINDING_NAME_XC_CLOSE = "Close"
BINDING_NAME_XC_DIV = "Divide"
BINDING_NAME_XC_MUL = "Multiply"
BINDING_NAME_XC_SUB = "Subtract"
BINDING_NAME_XC_ADD = "Add"
BINDING_NAME_XC_EQ = "Equals"
BINDING_NAME_XC_0 = "Digit 0"
BINDING_NAME_XC_1 = "Digit 1"
BINDING_NAME_XC_2 = "Digit 2"
BINDING_NAME_XC_3 = "Digit 3"
BINDING_NAME_XC_4 = "Digit 4"
BINDING_NAME_XC_5 = "Digit 5"
BINDING_NAME_XC_6 = "Digit 6"
BINDING_NAME_XC_7 = "Digit 7"
BINDING_NAME_XC_8 = "Digit 8"
BINDING_NAME_XC_9 = "Digit 9"
BINDING_NAME_XC_DEC = "Decimal"
BINDING_NAME_XC_BACKSPACE = "Backspace"
 
 
 
XCALC_NUMBERDISPLAY = "0";
XCALC_RUNNINGTOTAL = "";
XCALC_PREVIOUSKEYTYPE = "none";
XCALC_PREVIOUSOP = "";
XCALC_NUMBERDISPLAY = "0"
XCALC_RUNNINGTOTAL = ""
XCALC_PREVIOUSKEYTYPE = "none"
XCALC_PREVIOUSOP = ""
 
XCALC_CONSOLE_LAST_ANS = "0";
XCALC_MEMORYINDICATOR = "";
XCALC_MEMORYINDICATORON = "M";
XCALC_MEMORYNUMBER = "0";
XCALC_MEMORYSET = "0";
XCALC_CONSOLE_LAST_ANS = "0"
XCALC_MEMORYINDICATOR = ""
XCALC_MEMORYINDICATORON = "M"
XCALC_MEMORYNUMBER = "0"
XCALC_MEMORYSET = "0"
Xcalc_Settings = { }
\ No newline at end of file
trunk/xcalc.lua
15,25 → 15,25
--Initialization stuff
function xcalc_initialize()
-- add our very first chat command!
SlashCmdList["XCALC"] = xcalc_command;
SLASH_XCALC1 = "/xcalc";
SLASH_XCALC2 = "/calc";
SLASH_XCALC3 = "/=";
xcalc_optionvariables();
xcalc_minimap_init();
XCALC_VERSION = GetAddOnMetadata("xcalc", "Version");
SlashCmdList["XCALC"] = xcalc_command
SLASH_XCALC1 = "/xcalc"
SLASH_XCALC2 = "/calc"
SLASH_XCALC3 = "/="
xcalc_optionvariables()
xcalc_minimap_init()
XCALC_VERSION = GetAddOnMetadata("xcalc", "Version")
end
 
--Fuction for setting up Saved Variables
function xcalc_optionvariables()
if (Xcalc_Settings.Binding == nil) then
Xcalc_Settings.Binding = 1;
Xcalc_Settings.Binding = 1
end
if (Xcalc_Settings.Minimapdisplay == nil) then
Xcalc_Settings.Minimapdisplay = 1;
Xcalc_Settings.Minimapdisplay = 1
end
if (Xcalc_Settings.Minimappos == nil) then
Xcalc_Settings.Minimappos = 295;
Xcalc_Settings.Minimappos = 295
end
end
 
46,105 → 46,105
---------------------------------------------------------------------]]
function xcalc_display(displaynumber, memoryset)
if ( displaynumber == nil or displaynumber == "" ) then
displaynumber = "0";
displaynumber = "0"
elseif ( memoryset == "1" ) then
xcalc_memorydisplay:SetText ( XCALC_MEMORYINDICATORON );
xcalc_memorydisplay:SetText ( XCALC_MEMORYINDICATORON )
elseif ( memoryset == "0" ) then
xcalc_memorydisplay:SetText( XCALC_MEMORYINDICATOR );
xcalc_memorydisplay:SetText( XCALC_MEMORYINDICATOR )
end
XCALC_NUMBERDISPLAY = displaynumber;
xcalc_numberdisplay:SetText( displaynumber );
XCALC_NUMBERDISPLAY = displaynumber
xcalc_numberdisplay:SetText( displaynumber )
end
 
--[[--------------------------------------------------------------------
Function for adding Debug messages via xcalc_debug("message"); call
Function for adding Debug messages via xcalc_debug("message") call
Haven't decided on adding a variable to add lots of debugging messages
if set, will look into that idea as the code evolves a bit.
--------------------------------------------------------------------]]
function xcalc_debug(debugmsg)
ChatFrame1:AddMessage("xcalc_debug:" .. debugmsg);
ChatFrame1:AddMessage("xcalc_debug: " .. debugmsg)
end
 
--Function for handling the chat slash commands
function xcalc_command(msg)
-- this function handles our chat command
if (msg == nil or msg == "") then
xcalc_windowdisplay();
return nil;
xcalc_windowdisplay()
return nil
end
 
local expression = msg;
local expression = msg
 
newexpression = xcalc_parse(expression);
newexpression = xcalc_parse(expression)
 
local result = xcalc_xcalculate(newexpression);
local result = xcalc_xcalculate(newexpression)
 
if ( result == nil ) then
result = 'nil';
result = 'nil'
end
 
XCALC_CONSOLE_LAST_ANS = result;
XCALC_CONSOLE_LAST_ANS = result
 
--message(result);
ChatFrame1:AddMessage("Xcalc Result: " .. expression .. " = " .. result, 1.0, 1.0, 0.5);
--message(result)
ChatFrame1:AddMessage("Xcalc Result: " .. expression .. " = " .. result, 1.0, 1.0, 0.5)
end
 
--Display Main calculator Window
function xcalc_windowdisplay()
if (xcalc_window == nil) then
xcalc_windowframe();
xcalc_windowframe()
elseif (xcalc_window:IsVisible()) then
xcalc_window:Hide();
xcalc_window:Hide()
else
xcalc_window:Show();
xcalc_clear();
xcalc_window:Show()
xcalc_clear()
end
end
 
--Display options window
function xcalc_optiondisplay()
if (xcalc_optionwindow == nil) then
xcalc_optionframe();
xcalc_optionframe()
elseif (xcalc_optionwindow:IsVisible()) then
xcalc_optionwindow:Hide();
xcalc_optionwindow:Hide()
else
xcalc_optionwindow:Show();
xcalc_optionwindow:Show()
end
end
 
--Function for handeling Binding checkbox
function xcalc_options_binding()
if (xcalc_options_bindcheckbox:GetChecked() == 1) then
Xcalc_Settings.Binding = 1;
Xcalc_Settings.Binding = 1
else
xcalc_unbind();
Xcalc_Settings.Binding = 0;
xcalc_unbind()
Xcalc_Settings.Binding = 0
end
end
 
-- Function for Handeling Minimap Display checkbox
function xcalc_options_minimapdisplay()
if (xcalc_options_minimapcheckbox:GetChecked() == 1) then
Xcalc_Settings.Minimapdisplay = 1;
Xcalc_Settings.Minimapdisplay = 1
if (xcalc_minimap_button == nil) then
xcalc_minimap_init();
xcalc_minimap_init()
else
xcalc_minimap_button:Show();
xcalc_minimap_button:Show()
end
else
Xcalc_Settings.Minimapdisplay = 0;
xcalc_minimap_button:Hide();
Xcalc_Settings.Minimapdisplay = 0
xcalc_minimap_button:Hide()
end
end
 
-- Function for managing options slider
function xcalc_options_minimapslidercontrol()
if (Xcalc_Settings.Minimapdisplay == 1) then
Xcalc_Settings.Minimappos = xcalc_options_minimapslider:GetValue();
xcalc_minimapbutton_updateposition();
Xcalc_Settings.Minimappos = xcalc_options_minimapslider:GetValue()
xcalc_minimapbutton_updateposition()
else
xcalc_options_minimapslider:SetValue(Xcalc_Settings.Minimappos);
return;
xcalc_options_minimapslider:SetValue(Xcalc_Settings.Minimappos)
return
end
end
 
153,42 → 153,42
if (Xcalc_Settings.Binding == 1) then
 
--steal numlock away from anything else
SetBinding("NUMLOCK", "XC_NUMLOCK");
SetBinding("HOME", "XC_CLEAR");
SetBinding("END", "XC_CLOSE");
SetBinding("BACKSPACE", "XC_BACKSPACE");
SetBinding("NUMLOCK", "XC_NUMLOCK")
SetBinding("HOME", "XC_CLEAR")
SetBinding("END", "XC_CLOSE")
SetBinding("BACKSPACE", "XC_BACKSPACE")
 
--set numlock on keys
SetBinding("NUMPADDIVIDE", "XC_DIV");
SetBinding("NUMPADMULTIPLY", "XC_MUL");
SetBinding("NUMPADMINUS", "XC_SUB");
SetBinding("NUMPADPLUS", "XC_ADD");
SetBinding("ENTER", "XC_EQ");
SetBinding("NUMPAD0", "XC_0");
SetBinding("NUMPAD1", "XC_1");
SetBinding("NUMPAD2", "XC_2");
SetBinding("NUMPAD3", "XC_3");
SetBinding("NUMPAD4", "XC_4");
SetBinding("NUMPAD5", "XC_5");
SetBinding("NUMPAD6", "XC_6");
SetBinding("NUMPAD7", "XC_7");
SetBinding("NUMPAD8", "XC_8");
SetBinding("NUMPAD9", "XC_9");
SetBinding("NUMPADDECIMAL", "XC_DEC");
SetBinding("NUMPADDIVIDE", "XC_DIV")
SetBinding("NUMPADMULTIPLY", "XC_MUL")
SetBinding("NUMPADMINUS", "XC_SUB")
SetBinding("NUMPADPLUS", "XC_ADD")
SetBinding("ENTER", "XC_EQ")
SetBinding("NUMPAD0", "XC_0")
SetBinding("NUMPAD1", "XC_1")
SetBinding("NUMPAD2", "XC_2")
SetBinding("NUMPAD3", "XC_3")
SetBinding("NUMPAD4", "XC_4")
SetBinding("NUMPAD5", "XC_5")
SetBinding("NUMPAD6", "XC_6")
SetBinding("NUMPAD7", "XC_7")
SetBinding("NUMPAD8", "XC_8")
SetBinding("NUMPAD9", "XC_9")
SetBinding("NUMPADDECIMAL", "XC_DEC")
 
end
end
 
function xcalc_unbind()
if (Xcalc_Settings.Binding == 1) then
LoadBindings(0);
LoadBindings(GetCurrentBindingSet())
end
end
 
--Bound Key management
function xcalc_onkeydown()
key = arg1;
--message(key);
key = arg1
--message(key)
 
if ( key == "END" ) then
 
217,151 → 217,151
 
--Button Clear
function xcalc_clear()
XCALC_RUNNINGTOTAL = "";
XCALC_PREVIOUSKEYTYPE = "none";
XCALC_PREVIOUSOP = "";
xcalc_display("0");
XCALC_RUNNINGTOTAL = ""
XCALC_PREVIOUSKEYTYPE = "none"
XCALC_PREVIOUSOP = ""
xcalc_display("0")
end
 
--Button CE
function xcalc_ce()
xcalc_display("0");
xcalc_display("0")
end
 
--Button Backspace
function xcalc_backspace()
local currText = XCALC_NUMBERDISPLAY;
local currText = XCALC_NUMBERDISPLAY
if (currText == "0") then
return;
return
else
length = string.len(currText)-1;
length = string.len(currText)-1
if (length < 0) then
length = 0;
length = 0
end
currText = string.sub(currText,0,length);
currText = string.sub(currText,0,length)
if (string.len(currText) < 1) then
xcalc_display("0");
xcalc_display("0")
else
xcalc_display(currText);
xcalc_display(currText)
end
end
end
 
--Button Plus Minus Key
function xcalc_plusminus()
local currText = XCALC_NUMBERDISPLAY;
local currText = XCALC_NUMBERDISPLAY
if (currText ~= "0") then
if (string.find(currText, "-")) then
currText = string.sub(currText, 2);
currText = string.sub(currText, 2)
else
currText = "-" .. currText;
currText = "-" .. currText
end
end
XCALC_PREVIOUSKEYTYPE = "state";
xcalc_display(currText);
XCALC_PREVIOUSKEYTYPE = "state"
xcalc_display(currText)
end
 
--Button Gold (state)
function xcalc_stategold()
local currText = XCALC_NUMBERDISPLAY;
local currText = XCALC_NUMBERDISPLAY
if (string.find(currText, "c") == nil) then
if (string.find(currText, "s") == nil) then
if (string.find(currText, "g") == nil) then
currText = currText .. "g";
currText = currText .. "g"
end
end
end
XCALC_PREVIOUSKEYTYPE = "state";
xcalc_display(currText);
XCALC_PREVIOUSKEYTYPE = "state"
xcalc_display(currText)
end
 
--Button Silver (state)
function xcalc_statesilver()
local currText = XCALC_NUMBERDISPLAY;
local currText = XCALC_NUMBERDISPLAY
if (string.find(currText, "c") == nil) then
if (string.find(currText, "s") == nil) then
currText = currText .. "s";
currText = currText .. "s"
end
end
XCALC_PREVIOUSKEYTYPE = "state";
xcalc_display(currText);
XCALC_PREVIOUSKEYTYPE = "state"
xcalc_display(currText)
end
 
--Button Copper (state)
function xcalc_statecopper()
local currText = XCALC_NUMBERDISPLAY;
local currText = XCALC_NUMBERDISPLAY
if (string.find(currText, "c") == nil) then
currText = currText .. "c";
currText = currText .. "c"
end
XCALC_PREVIOUSKEYTYPE = "state";
xcalc_display(currText);
XCALC_PREVIOUSKEYTYPE = "state"
xcalc_display(currText)
end
 
--Button Memory Clear
function xcalc_mc()
XCALC_MEMORYNUMBER = "0";
xcalc_display(XCALC_NUMBERDISPLAY, "0");
XCALC_MEMORYNUMBER = "0"
xcalc_display(XCALC_NUMBERDISPLAY, "0")
end
 
--Button Memory Add
function xcalc_ma()
temp = xcalc_parse(XCALC_MEMORYNUMBER .. "+" .. XCALC_NUMBERDISPLAY);
XCALC_MEMORYNUMBER = xcalc_xcalculate(temp);
xcalc_display("0","1");
xcalc_clear();
temp = xcalc_parse(XCALC_MEMORYNUMBER .. "+" .. XCALC_NUMBERDISPLAY)
XCALC_MEMORYNUMBER = xcalc_xcalculate(temp)
xcalc_display("0","1")
xcalc_clear()
end
 
--Button Memory Store
function xcalc_ms()
XCALC_MEMORYNUMBER = xcalc_parse(XCALC_NUMBERDISPLAY);
xcalc_display("0","1");
xcalc_clear();
XCALC_MEMORYNUMBER = xcalc_parse(XCALC_NUMBERDISPLAY)
xcalc_display("0","1")
xcalc_clear()
end
 
--Button Memory Recall
function xcalc_mr()
xcalc_display(XCALC_MEMORYNUMBER);
xcalc_display(XCALC_MEMORYNUMBER)
end
 
--Sets up the function keys ie, + - * / =
function xcalc_funckey(key)
local currText = XCALC_NUMBERDISPLAY;
local currText = XCALC_NUMBERDISPLAY
if ( IsShiftKeyDown() and key == "=" ) then
ChatFrame_OpenChat("");
return;
ChatFrame_OpenChat("")
return
end
if (XCALC_PREVIOUSKEYTYPE=="none" or XCALC_PREVIOUSKEYTYPE=="num" or XCALC_PREVIOUSKEYTYPE=="state") then
if (key == "/" or key == "*" or key == "-" or key == "-" or key == "+" or key == "^") then
 
if (XCALC_PREVIOUSOP~="" and XCALC_PREVIOUSOP ~= "=") then
temp = xcalc_parse(XCALC_RUNNINGTOTAL .. XCALC_PREVIOUSOP .. currText);
currText = xcalc_xcalculate(temp);
temp = xcalc_parse(XCALC_RUNNINGTOTAL .. XCALC_PREVIOUSOP .. currText)
currText = xcalc_xcalculate(temp)
end
XCALC_RUNNINGTOTAL = currText;
XCALC_PREVIOUSOP = key;
XCALC_RUNNINGTOTAL = currText
XCALC_PREVIOUSOP = key
elseif (key == "=") then
if XCALC_PREVIOUSOP ~= "=" and XCALC_PREVIOUSOP ~= "" then
temp = xcalc_parse(XCALC_RUNNINGTOTAL .. XCALC_PREVIOUSOP .. currText);
currText = xcalc_xcalculate(temp);
XCALC_RUNNINGTOTAL = currText;
XCALC_PREVIOUSOP="=";
temp = xcalc_parse(XCALC_RUNNINGTOTAL .. XCALC_PREVIOUSOP .. currText)
currText = xcalc_xcalculate(temp)
XCALC_RUNNINGTOTAL = currText
XCALC_PREVIOUSOP="="
end
end
 
else --must be a func key, a second+ time
if (key == "/" or key == "*" or key == "-" or key == "-" or key == "+" or key == "^") then
XCALC_PREVIOUSOP=key;
XCALC_PREVIOUSOP=key
else
XCALC_PREVIOUSOP="";
XCALC_PREVIOUSOP=""
end
end
XCALC_PREVIOUSKEYTYPE = "func";
xcalc_display(currText);
XCALC_PREVIOUSKEYTYPE = "func"
xcalc_display(currText)
end
 
--Manage Number Inputs
function xcalc_numkey(key)
local currText = XCALC_NUMBERDISPLAY;
local currText = XCALC_NUMBERDISPLAY
 
if (XCALC_PREVIOUSKEYTYPE=="none" or XCALC_PREVIOUSKEYTYPE=="num" or XCALC_PREVIOUSKEYTYPE=="state")then
if (key == ".") then
369,28 → 369,28
if (string.find(currText, "s") == nil) then
if (string.find(currText, "g") == nil) then
if (string.find(currText, "%.") == nil) then
currText = currText .. ".";
currText = currText .. "."
end
end
end
end
else
if (currText == "0") then
currText = "";
currText = ""
end
 
currText = currText .. key;
currText = currText .. key
end
else
if (key == ".") then
currText = "0.";
currText = "0."
else
currText = key;
currText = key
end
end
 
XCALC_PREVIOUSKEYTYPE = "num";
xcalc_display(currText);
XCALC_PREVIOUSKEYTYPE = "num"
xcalc_display(currText)
end
 
--Send the number display to an open chatbox
398,7 → 398,7
if ( button == "LeftButton" ) then
if ( IsShiftKeyDown() and not ignoreShift ) then
if ( ChatFrameEditBox:IsVisible() ) then
ChatFrameEditBox:Insert(XCALC_NUMBERDISPLAY);
ChatFrameEditBox:Insert(XCALC_NUMBERDISPLAY)
end
end
end
420,69 → 420,69
to perform math functions may introduce unexpected results... maybe.
-----------------------------------------------------------------------------------]]
function xcalc_xcalculate(expression)
local tempvar = "QCExpVal";
local tempvar = "QCExpVal"
 
setglobal(tempvar, nil);
RunScript(tempvar .. "=(" .. expression .. ")");
local result = getglobal(tempvar);
setglobal(tempvar, nil)
RunScript(tempvar .. "=(" .. expression .. ")")
local result = getglobal(tempvar)
 
return result;
return result
end
 
--This function parses the input for the money functions
function xcalc_parse(expression)
local ismoney = false;
local ismoney = false
 
newexpression = expression
 
local newexpression = string.gsub(newexpression, "ans", XCALC_CONSOLE_LAST_ANS);
local newexpression = string.gsub(newexpression, "ans", XCALC_CONSOLE_LAST_ANS)
 
-- g s c
local newexpression = string.gsub(newexpression, "%d+g%d+s%d+c", function (a)
ismoney = true;
return FromGSC(a);
end );
ismoney = true
return FromGSC(a)
end )
 
-- g s
local newexpression = string.gsub(newexpression, "%d+g%d+s", function (a)
ismoney = true;
return FromGSC(a);
end );
ismoney = true
return FromGSC(a)
end )
 
 
-- g c
local newexpression = string.gsub(newexpression, "%d+g%d+c", function (a)
ismoney = true;
return FromGSC(a);
end );
ismoney = true
return FromGSC(a)
end )
 
-- g allows #.#
local newexpression = string.gsub(newexpression, "%d+%.?%d*g", function (a)
ismoney = true;
return FromGSC(a);
end );
ismoney = true
return FromGSC(a)
end )
 
-- s c
local newexpression = string.gsub(newexpression, "%d+s%d+c", function (a)
ismoney = true;
return FromGSC(a);
end );
ismoney = true
return FromGSC(a)
end )
 
-- s allows #.#
local newexpression = string.gsub(newexpression, "%d+%.?%d*s", function (a)
ismoney = true;
return FromGSC(a);
end );
ismoney = true
return FromGSC(a)
end )
 
-- c
local newexpression = string.gsub(newexpression, "%d+c", function (a)
ismoney = true;
return FromGSC(a);
end );
ismoney = true
return FromGSC(a)
end )
 
 
if (ismoney) then
newexpression = "ToGSC(" .. newexpression .. ")";
newexpression = "ToGSC(" .. newexpression .. ")"
end
 
return newexpression
490,90 → 490,90
 
--The following two functions do the to and from gold calculations
function ToGSC(decimal, std)
local gold = 0;
local silver = 0;
local copper = 0;
local gold = 0
local silver = 0
local copper = 0
 
if (std == "gold") then
copper = math.fmod(decimal, .01);
decimal = decimal - copper;
copper = math.fmod(decimal, .01)
decimal = decimal - copper
copper = copper * 10000
 
silver = math.fmod(decimal, 1);
decimal = decimal - silver;
silver = silver * 100;
silver = math.fmod(decimal, 1)
decimal = decimal - silver
silver = silver * 100
 
gold = decimal;
gold = decimal
elseif (std == "silver") then
copper = math.fmod(decimal, 1);
decimal = decimal - copper;
copper = copper * 100;
copper = math.fmod(decimal, 1)
decimal = decimal - copper
copper = copper * 100
 
silver = math.fmod(decimal, 100);
decimal = decimal - silver;
silver = math.fmod(decimal, 100)
decimal = decimal - silver
 
gold = decimal / 100;
gold = decimal / 100
else
copper = math.fmod(decimal, 100);
decimal = decimal - copper;
copper = math.fmod(decimal, 100)
decimal = decimal - copper
 
silver = math.fmod(decimal, 10000);
decimal = decimal - silver;
silver = silver / 100;
silver = math.fmod(decimal, 10000)
decimal = decimal - silver
silver = silver / 100
 
gold = decimal / 10000;
gold = decimal / 10000
end
 
local temp = "";
local temp = ""
 
if (gold > 0) then
temp = temp .. gold .. "g";
temp = temp .. gold .. "g"
end
if (silver > 0 or (gold > 0 and copper > 0)) then
temp = temp .. silver .. "s";
temp = temp .. silver .. "s"
end
if (copper > 0) then
temp = temp .. copper .. "c";
temp = temp .. copper .. "c"
end
 
return temp;
return temp
end
 
function FromGSC(gold, silver, copper)
if (gold == nil) then
return "";
return ""
end
 
local total = 0;
local total = 0
 
if (type(gold) == "string" and (not silver or type(silver) == "nil") and (not copper or type(copper) == "nil")) then
local temp = gold;
local temp = gold
 
golds,golde = string.find(temp, "%d*%.?%d*g");
golds,golde = string.find(temp, "%d*%.?%d*g")
if (golds == nil) then
gold = 0;
gold = 0
else
gold = string.sub(temp, golds, golde - 1);
gold = string.sub(temp, golds, golde - 1)
end
 
silvers,silvere = string.find(temp, "%d*%.?%d*s");
silvers,silvere = string.find(temp, "%d*%.?%d*s")
if (silvers == nil) then
silver = 0;
silver = 0
else
silver = string.sub(temp, silvers, silvere - 1);
silver = string.sub(temp, silvers, silvere - 1)
end
 
coppers,coppere = string.find(temp, "%d*c");
coppers,coppere = string.find(temp, "%d*c")
if (coppers == nil) then
copper = 0;
copper = 0
else
copper = string.sub(temp, coppers, coppere - 1);
copper = string.sub(temp, coppers, coppere - 1)
end
end
 
total = total + copper;
total = total + (silver * 100);
total = total + (gold * 10000);
total = total + copper
total = total + (silver * 100)
total = total + (gold * 10000)
 
return "" .. total;
return "" .. total
end
\ No newline at end of file
trunk/Bindings.xml
1,5 → 1,9
<Bindings>
<Binding name="XC_NUMLOCK" description="Numlock" header="XCALC">
<Binding name="XC_TOGGLEWINDOW" description="Toggle Xcalc" header="XCALC">
xcalc_windowdisplay();
</Binding>
 
<Binding name="XC_NUMLOCK" description="Numlock" header="XCALC_AUTOMATIC">
 
</Binding>
<Binding name="XC_CLEAR" description="Clear">
trunk/xcalcgui.lua
7,356 → 7,356
 
function xcalc_windowframe()
--Main Window Frame (container) and title bar
local frame = CreateFrame("Frame","xcalc_window",UIParent);
frame:SetFrameStrata("HIGH");
frame:EnableMouse(true);
frame:EnableKeyboard(true);
frame:SetMovable(true);
frame:SetHeight(307);
frame:SetWidth(240);
frame:SetScript("OnMouseDown", function() frame:StartMoving() end);
frame:SetScript("OnMouseUp", function() frame:StopMovingOrSizing() end);
frame:SetScript("OnShow", function() xcalc_rebind() end);
frame:SetScript("OnHide", function() xcalc_unbind() end);
local frame = CreateFrame("Frame","xcalc_window",UIParent)
frame:SetFrameStrata("HIGH")
frame:EnableMouse(true)
frame:EnableKeyboard(true)
frame:SetMovable(true)
frame:SetHeight(307)
frame:SetWidth(240)
frame:SetScript("OnMouseDown", function() frame:StartMoving() end)
frame:SetScript("OnMouseUp", function() frame:StopMovingOrSizing() end)
frame:SetScript("OnShow", function() xcalc_rebind() end)
frame:SetScript("OnHide", function() xcalc_unbind() end)
frame: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 }});
frame:SetPoint("CENTER",0,0);
local titletexture = frame:CreateTexture("xcalc_window_titletexture");
titletexture:SetHeight(32);
titletexture:SetWidth(160);
titletexture:SetTexture("Interface/DialogFrame/UI-DialogBox-Header");
titletexture:SetTexCoord(0.2, 0.8, 0, 0.6);
titletexture:SetPoint("TOP",0,5);
local titlefont = frame:CreateFontString("xcalc_windowtest_titlefont");
titlefont:SetHeight(0);
titlefont:SetWidth(140);
titlefont:SetFont("Fonts/FRIZQT__.TTF",12);
titlefont:SetPoint("TOP",0,-4);
titlefont:SetTextColor(1,0.8196079,0);
titlefont:SetText("xcalc v" .. XCALC_VERSION);
insets = { left = 11, right = 12, top = 12, bottom = 11 }})
frame:SetPoint("CENTER",0,0)
local titletexture = frame:CreateTexture("xcalc_window_titletexture")
titletexture:SetHeight(32)
titletexture:SetWidth(160)
titletexture:SetTexture("Interface/DialogFrame/UI-DialogBox-Header")
titletexture:SetTexCoord(0.2, 0.8, 0, 0.6)
titletexture:SetPoint("TOP",0,5)
local titlefont = frame:CreateFontString("xcalc_windowtest_titlefont")
titlefont:SetHeight(0)
titlefont:SetWidth(140)
titlefont:SetFont("Fonts/FRIZQT__.TTF",12)
titlefont:SetPoint("TOP",0,-4)
titlefont:SetTextColor(1,0.8196079,0)
titlefont:SetText("xcalc v" .. XCALC_VERSION)
--Number Display box
local numberdisplaybackground = frame:CreateTexture("xcalc_numberdisplaybackground");
numberdisplaybackground:SetHeight(34);
numberdisplaybackground:SetWidth(215);
numberdisplaybackground:SetTexture("interface/chatframe/ui-chatinputborder");
numberdisplaybackground:SetPoint("TOPLEFT",10,-33);
local numberdisplay = frame:CreateFontString("xcalc_numberdisplay","GameFontWhite");
numberdisplay:SetHeight(34);
numberdisplay:SetWidth(205);
numberdisplay:SetFont("Fonts/FRIZQT__.TTF",12);
numberdisplay:SetJustifyH("RIGHT");
numberdisplay:SetPoint("TOPLEFT",10,-33);
numberdisplay:SetText(XCALC_NUMBERDISPLAY);
local numberdisplaybackground = frame:CreateTexture("xcalc_numberdisplaybackground")
numberdisplaybackground:SetHeight(34)
numberdisplaybackground:SetWidth(215)
numberdisplaybackground:SetTexture("interface/chatframe/ui-chatinputborder")
numberdisplaybackground:SetPoint("TOPLEFT",10,-33)
local numberdisplay = frame:CreateFontString("xcalc_numberdisplay","GameFontWhite")
numberdisplay:SetHeight(34)
numberdisplay:SetWidth(205)
numberdisplay:SetFont("Fonts/FRIZQT__.TTF",12)
numberdisplay:SetJustifyH("RIGHT")
numberdisplay:SetPoint("TOPLEFT",10,-33)
numberdisplay:SetText(XCALC_NUMBERDISPLAY)
--Memory Display
local memorydisplay = frame:CreateFontString("xcalc_memorydisplay","GameFontNormal");
memorydisplay:SetWidth(29);
memorydisplay:SetHeight(29);
memorydisplay:SetFont("Fonts/FRIZQT__.TTF",12);
memorydisplay:SetPoint("TOPLEFT",15,-73);
--memorydisplay:SetText("M");
local memorydisplay = frame:CreateFontString("xcalc_memorydisplay","GameFontNormal")
memorydisplay:SetWidth(29)
memorydisplay:SetHeight(29)
memorydisplay:SetFont("Fonts/FRIZQT__.TTF",12)
memorydisplay:SetPoint("TOPLEFT",15,-73)
--memorydisplay:SetText("M")
--ExitButton
local exitbutton = CreateFrame("Button", "xcalc_exitbutton",frame,"UIPanelCloseButton");
exitbutton:SetPoint("TOPRIGHT",-4,-4);
exitbutton:SetScript("OnClick", function() xcalc_windowdisplay() end);
local exitbutton = CreateFrame("Button", "xcalc_exitbutton",frame,"UIPanelCloseButton")
exitbutton:SetPoint("TOPRIGHT",-4,-4)
exitbutton:SetScript("OnClick", function() xcalc_windowdisplay() end)
--Backspace Button
local backspacebutton = CreateFrame("Button", "backspacebutton",frame,"UIPanelButtonTemplate");
backspacebutton:SetWidth(75);
backspacebutton:SetHeight(29);
backspacebutton:SetPoint("TOPLEFT",50,-73);
backspacebutton:SetText("Backspace");
backspacebutton:SetScript("OnClick", function() xcalc_backspace() end);
local backspacebutton = CreateFrame("Button", "backspacebutton",frame,"UIPanelButtonTemplate")
backspacebutton:SetWidth(75)
backspacebutton:SetHeight(29)
backspacebutton:SetPoint("TOPLEFT",50,-73)
backspacebutton:SetText("Backspace")
backspacebutton:SetScript("OnClick", function() xcalc_backspace() end)
--CE button
local cebutton = CreateFrame("Button", "cebutton",frame,"UIPanelButtonTemplate");
cebutton:SetWidth(41);
cebutton:SetHeight(29);
cebutton:SetPoint("TOPLEFT",131,-73);
cebutton:SetText("CE");
cebutton:SetScript("OnClick", function() xcalc_ce() end);
local cebutton = CreateFrame("Button", "cebutton",frame,"UIPanelButtonTemplate")
cebutton:SetWidth(41)
cebutton:SetHeight(29)
cebutton:SetPoint("TOPLEFT",131,-73)
cebutton:SetText("CE")
cebutton:SetScript("OnClick", function() xcalc_ce() end)
--Clear Button
local cbutton = CreateFrame("Button", "cbutton",frame,"UIPanelButtonTemplate");
cbutton:SetWidth(41);
cbutton:SetHeight(29);
cbutton:SetPoint("TOPLEFT",178,-73);
cbutton:SetText("C");
cbutton:SetScript("OnClick", function() xcalc_clear() end);
local cbutton = CreateFrame("Button", "cbutton",frame,"UIPanelButtonTemplate")
cbutton:SetWidth(41)
cbutton:SetHeight(29)
cbutton:SetPoint("TOPLEFT",178,-73)
cbutton:SetText("C")
cbutton:SetScript("OnClick", function() xcalc_clear() end)
--Equals Button
local equalbutton = CreateFrame("Button", "equalbutton",frame,"UIPanelButtonTemplate");
equalbutton:SetWidth(29);
equalbutton:SetHeight(70);
equalbutton:SetPoint("TOPLEFT",190,-183);
equalbutton:SetText("=");
equalbutton:SetScript("OnClick", function() xcalc_funckey("=") end);
local equalbutton = CreateFrame("Button", "equalbutton",frame,"UIPanelButtonTemplate")
equalbutton:SetWidth(29)
equalbutton:SetHeight(70)
equalbutton:SetPoint("TOPLEFT",190,-183)
equalbutton:SetText("=")
equalbutton:SetScript("OnClick", function() xcalc_funckey("=") end)
--Exp Button
local expbutton = CreateFrame("Button", "expbutton",frame,"UIPanelButtonTemplate");
expbutton:SetWidth(29);
expbutton:SetHeight(32);
expbutton:SetPoint("TOPLEFT",190,-146);
expbutton:SetText("^");
expbutton:SetScript("OnClick", function() xcalc_funckey("^") end);
local expbutton = CreateFrame("Button", "expbutton",frame,"UIPanelButtonTemplate")
expbutton:SetWidth(29)
expbutton:SetHeight(32)
expbutton:SetPoint("TOPLEFT",190,-146)
expbutton:SetText("^")
expbutton:SetScript("OnClick", function() xcalc_funckey("^") end)
--Plus Minus Button
local pmbutton = CreateFrame("Button", "pmbutton",frame,"UIPanelButtonTemplate");
pmbutton:SetWidth(29);
pmbutton:SetHeight(32);
pmbutton:SetPoint("TOPLEFT",190,-108);
pmbutton:SetText("+/-");
pmbutton:SetScript("OnClick", function() xcalc_plusminus() end);
local pmbutton = CreateFrame("Button", "pmbutton",frame,"UIPanelButtonTemplate")
pmbutton:SetWidth(29)
pmbutton:SetHeight(32)
pmbutton:SetPoint("TOPLEFT",190,-108)
pmbutton:SetText("+/-")
pmbutton:SetScript("OnClick", function() xcalc_plusminus() end)
--Plus Button
local plusbutton = CreateFrame("Button", "plusbutton",frame,"UIPanelButtonTemplate");
plusbutton:SetWidth(29);
plusbutton:SetHeight(32);
plusbutton:SetPoint("TOPLEFT",155,-221);
plusbutton:SetText("+");
plusbutton:SetScript("OnClick", function() xcalc_funckey("+") end);
local plusbutton = CreateFrame("Button", "plusbutton",frame,"UIPanelButtonTemplate")
plusbutton:SetWidth(29)
plusbutton:SetHeight(32)
plusbutton:SetPoint("TOPLEFT",155,-221)
plusbutton:SetText("+")
plusbutton:SetScript("OnClick", function() xcalc_funckey("+") end)
--Minus Button
local minuxbutton = CreateFrame("Button", "minusbutton",frame,"UIPanelButtonTemplate");
minusbutton:SetWidth(29);
minusbutton:SetHeight(32);
minusbutton:SetPoint("TOPLEFT",155,-183);
minusbutton:SetText("-");
minusbutton:SetScript("OnClick", function() xcalc_funckey("-") end);
local minuxbutton = CreateFrame("Button", "minusbutton",frame,"UIPanelButtonTemplate")
minusbutton:SetWidth(29)
minusbutton:SetHeight(32)
minusbutton:SetPoint("TOPLEFT",155,-183)
minusbutton:SetText("-")
minusbutton:SetScript("OnClick", function() xcalc_funckey("-") end)
--Multiply Button
local multiplybutton = CreateFrame("Button", "multiplybutton",frame,"UIPanelButtonTemplate");
multiplybutton:SetWidth(29);
multiplybutton:SetHeight(32);
multiplybutton:SetPoint("TOPLEFT",155,-146);
multiplybutton:SetText("*");
multiplybutton:SetScript("OnClick", function() xcalc_funckey("*") end);
local multiplybutton = CreateFrame("Button", "multiplybutton",frame,"UIPanelButtonTemplate")
multiplybutton:SetWidth(29)
multiplybutton:SetHeight(32)
multiplybutton:SetPoint("TOPLEFT",155,-146)
multiplybutton:SetText("*")
multiplybutton:SetScript("OnClick", function() xcalc_funckey("*") end)
--Divide Button
local dividebutton = CreateFrame("Button", "dividebutton",frame,"UIPanelButtonTemplate");
dividebutton:SetWidth(29);
dividebutton:SetHeight(32);
dividebutton:SetPoint("TOPLEFT",155,-108);
dividebutton:SetText("/");
dividebutton:SetScript("OnClick", function() xcalc_funckey("/") end);
local dividebutton = CreateFrame("Button", "dividebutton",frame,"UIPanelButtonTemplate")
dividebutton:SetWidth(29)
dividebutton:SetHeight(32)
dividebutton:SetPoint("TOPLEFT",155,-108)
dividebutton:SetText("/")
dividebutton:SetScript("OnClick", function() xcalc_funckey("/") end)
--Copper Button
local copperbutton = CreateFrame("Button", "copperbutton",frame,"UIPanelButtonTemplate");
copperbutton:SetWidth(29);
copperbutton:SetHeight(32);
copperbutton:SetPoint("TOPLEFT",120,-259);
copperbutton:SetText("c");
copperbutton:SetScript("OnClick", function() xcalc_statecopper() end);
local copperbutton = CreateFrame("Button", "copperbutton",frame,"UIPanelButtonTemplate")
copperbutton:SetWidth(29)
copperbutton:SetHeight(32)
copperbutton:SetPoint("TOPLEFT",120,-259)
copperbutton:SetText("c")
copperbutton:SetScript("OnClick", function() xcalc_statecopper() end)
--Silver Button
local silverbutton = CreateFrame("Button", "silverbutton",frame,"UIPanelButtonTemplate");
silverbutton:SetWidth(29);
silverbutton:SetHeight(32);
silverbutton:SetPoint("TOPLEFT",85,-259);
silverbutton:SetText("s");
silverbutton:SetScript("OnClick", function() xcalc_statesilver() end);
local silverbutton = CreateFrame("Button", "silverbutton",frame,"UIPanelButtonTemplate")
silverbutton:SetWidth(29)
silverbutton:SetHeight(32)
silverbutton:SetPoint("TOPLEFT",85,-259)
silverbutton:SetText("s")
silverbutton:SetScript("OnClick", function() xcalc_statesilver() end)
--Gold Button
local goldbutton = CreateFrame("Button", "goldbutton",frame,"UIPanelButtonTemplate");
goldbutton:SetWidth(29);
goldbutton:SetHeight(32);
goldbutton:SetPoint("TOPLEFT",50,-259);
goldbutton:SetText("g");
goldbutton:SetScript("OnClick", function() xcalc_stategold() end);
local goldbutton = CreateFrame("Button", "goldbutton",frame,"UIPanelButtonTemplate")
goldbutton:SetWidth(29)
goldbutton:SetHeight(32)
goldbutton:SetPoint("TOPLEFT",50,-259)
goldbutton:SetText("g")
goldbutton:SetScript("OnClick", function() xcalc_stategold() end)
--Decimal Button
local decimalbutton = CreateFrame("Button", "decimalbutton",frame,"UIPanelButtonTemplate");
decimalbutton:SetWidth(29);
decimalbutton:SetHeight(32);
decimalbutton:SetPoint("TOPLEFT",120,-221);
decimalbutton:SetText(".");
decimalbutton:SetScript("OnClick", function() xcalc_numkey(".") end);
local decimalbutton = CreateFrame("Button", "decimalbutton",frame,"UIPanelButtonTemplate")
decimalbutton:SetWidth(29)
decimalbutton:SetHeight(32)
decimalbutton:SetPoint("TOPLEFT",120,-221)
decimalbutton:SetText(".")
decimalbutton:SetScript("OnClick", function() xcalc_numkey(".") end)
--0 button
local zerobutton = CreateFrame("Button", "zerobutton",frame,"UIPanelButtonTemplate");
zerobutton:SetWidth(64);
zerobutton:SetHeight(32);
zerobutton:SetPoint("TOPLEFT",50,-222);
zerobutton:SetText("0");
zerobutton:SetScript("OnClick", function() xcalc_numkey("0") end);
local zerobutton = CreateFrame("Button", "zerobutton",frame,"UIPanelButtonTemplate")
zerobutton:SetWidth(64)
zerobutton:SetHeight(32)
zerobutton:SetPoint("TOPLEFT",50,-222)
zerobutton:SetText("0")
zerobutton:SetScript("OnClick", function() xcalc_numkey("0") end)
--3 button
local threebutton = CreateFrame("Button", "threebutton",frame,"UIPanelButtonTemplate");
threebutton:SetWidth(29);
threebutton:SetHeight(32);
threebutton:SetPoint("TOPLEFT",120,-183);
threebutton:SetText("3");
threebutton:SetScript("OnClick", function() xcalc_numkey("3") end);
local threebutton = CreateFrame("Button", "threebutton",frame,"UIPanelButtonTemplate")
threebutton:SetWidth(29)
threebutton:SetHeight(32)
threebutton:SetPoint("TOPLEFT",120,-183)
threebutton:SetText("3")
threebutton:SetScript("OnClick", function() xcalc_numkey("3") end)
--2 Button
local twobutton = CreateFrame("Button", "twobutton",frame,"UIPanelButtonTemplate");
twobutton:SetWidth(29);
twobutton:SetHeight(32);
twobutton:SetPoint("TOPLEFT",85,-183);
twobutton:SetText("2");
twobutton:SetScript("OnClick", function() xcalc_numkey("2") end);
local twobutton = CreateFrame("Button", "twobutton",frame,"UIPanelButtonTemplate")
twobutton:SetWidth(29)
twobutton:SetHeight(32)
twobutton:SetPoint("TOPLEFT",85,-183)
twobutton:SetText("2")
twobutton:SetScript("OnClick", function() xcalc_numkey("2") end)
--1 Button
local onebutton = CreateFrame("Button", "onebutton",frame,"UIPanelButtonTemplate");
onebutton:SetWidth(29);
onebutton:SetHeight(32);
onebutton:SetPoint("TOPLEFT",50,-184);
onebutton:SetText("1");
onebutton:SetScript("OnClick", function() xcalc_numkey("1") end);
local onebutton = CreateFrame("Button", "onebutton",frame,"UIPanelButtonTemplate")
onebutton:SetWidth(29)
onebutton:SetHeight(32)
onebutton:SetPoint("TOPLEFT",50,-184)
onebutton:SetText("1")
onebutton:SetScript("OnClick", function() xcalc_numkey("1") end)
--6 Button
local sixbutton = CreateFrame("Button", "sixbutton",frame,"UIPanelButtonTemplate");
sixbutton:SetWidth(29);
sixbutton:SetHeight(32);
sixbutton:SetPoint("TOPLEFT",120,-146);
sixbutton:SetText("6");
sixbutton:SetScript("OnClick", function() xcalc_numkey("6") end);
local sixbutton = CreateFrame("Button", "sixbutton",frame,"UIPanelButtonTemplate")
sixbutton:SetWidth(29)
sixbutton:SetHeight(32)
sixbutton:SetPoint("TOPLEFT",120,-146)
sixbutton:SetText("6")
sixbutton:SetScript("OnClick", function() xcalc_numkey("6") end)
--5 Button
local fivebutton = CreateFrame("Button", "fivebutton",frame,"UIPanelButtonTemplate");
fivebutton:SetWidth(29);
fivebutton:SetHeight(32);
fivebutton:SetPoint("TOPLEFT",85,-146);
fivebutton:SetText("5");
fivebutton:SetScript("OnClick", function() xcalc_numkey("5") end);
local fivebutton = CreateFrame("Button", "fivebutton",frame,"UIPanelButtonTemplate")
fivebutton:SetWidth(29)
fivebutton:SetHeight(32)
fivebutton:SetPoint("TOPLEFT",85,-146)
fivebutton:SetText("5")
fivebutton:SetScript("OnClick", function() xcalc_numkey("5") end)
--4 Button
local fourbutton = CreateFrame("Button", "fourbutton",frame,"UIPanelButtonTemplate");
fourbutton:SetWidth(29);
fourbutton:SetHeight(32);
fourbutton:SetPoint("TOPLEFT",50,-146);
fourbutton:SetText("4");
fourbutton:SetScript("OnClick", function() xcalc_numkey("4") end);
local fourbutton = CreateFrame("Button", "fourbutton",frame,"UIPanelButtonTemplate")
fourbutton:SetWidth(29)
fourbutton:SetHeight(32)
fourbutton:SetPoint("TOPLEFT",50,-146)
fourbutton:SetText("4")
fourbutton:SetScript("OnClick", function() xcalc_numkey("4") end)
--9 Button
local ninebutton = CreateFrame("Button", "ninebutton",frame,"UIPanelButtonTemplate");
ninebutton:SetWidth(29);
ninebutton:SetHeight(32);
ninebutton:SetPoint("TOPLEFT",120,-108);
ninebutton:SetText("9");
ninebutton:SetScript("OnClick", function() xcalc_numkey("9") end);
local ninebutton = CreateFrame("Button", "ninebutton",frame,"UIPanelButtonTemplate")
ninebutton:SetWidth(29)
ninebutton:SetHeight(32)
ninebutton:SetPoint("TOPLEFT",120,-108)
ninebutton:SetText("9")
ninebutton:SetScript("OnClick", function() xcalc_numkey("9") end)
--8 Button
local eightbutton = CreateFrame("Button", "eightbutton",frame,"UIPanelButtonTemplate");
eightbutton:SetWidth(29);
eightbutton:SetHeight(32);
eightbutton:SetPoint("TOPLEFT",85,-108);
eightbutton:SetText("8");
eightbutton:SetScript("OnClick", function() xcalc_numkey("8") end);
local eightbutton = CreateFrame("Button", "eightbutton",frame,"UIPanelButtonTemplate")
eightbutton:SetWidth(29)
eightbutton:SetHeight(32)
eightbutton:SetPoint("TOPLEFT",85,-108)
eightbutton:SetText("8")
eightbutton:SetScript("OnClick", function() xcalc_numkey("8") end)
--7 Button
local sevenbutton = CreateFrame("Button", "sevenbutton",frame,"UIPanelButtonTemplate");
sevenbutton:SetWidth(29);
sevenbutton:SetHeight(32);
sevenbutton:SetPoint("TOPLEFT",50,-108);
sevenbutton:SetText("7");
sevenbutton:SetScript("OnClick", function() xcalc_numkey("7") end);
local sevenbutton = CreateFrame("Button", "sevenbutton",frame,"UIPanelButtonTemplate")
sevenbutton:SetWidth(29)
sevenbutton:SetHeight(32)
sevenbutton:SetPoint("TOPLEFT",50,-108)
sevenbutton:SetText("7")
sevenbutton:SetScript("OnClick", function() xcalc_numkey("7") end)
--Memory Add Button
local mabutton = CreateFrame("Button", "mabutton",frame,"UIPanelButtonTemplate");
mabutton:SetWidth(29);
mabutton:SetHeight(32);
mabutton:SetPoint("TOPLEFT",15,-221);
mabutton:SetText("MA");
mabutton:SetScript("OnClick", function() xcalc_ma() end);
local mabutton = CreateFrame("Button", "mabutton",frame,"UIPanelButtonTemplate")
mabutton:SetWidth(29)
mabutton:SetHeight(32)
mabutton:SetPoint("TOPLEFT",15,-221)
mabutton:SetText("MA")
mabutton:SetScript("OnClick", function() xcalc_ma() end)
--Memory Store Button
local msbutton = CreateFrame("Button", "msbutton",frame,"UIPanelButtonTemplate");
msbutton:SetWidth(29);
msbutton:SetHeight(32);
msbutton:SetPoint("TOPLEFT",15,-183);
msbutton:SetText("MS");
msbutton:SetScript("OnClick", function() xcalc_ms() end);
local msbutton = CreateFrame("Button", "msbutton",frame,"UIPanelButtonTemplate")
msbutton:SetWidth(29)
msbutton:SetHeight(32)
msbutton:SetPoint("TOPLEFT",15,-183)
msbutton:SetText("MS")
msbutton:SetScript("OnClick", function() xcalc_ms() end)
--Memory Recall Button
local mrbutton = CreateFrame("Button", "mrbutton",frame,"UIPanelButtonTemplate");
mrbutton:SetWidth(29);
mrbutton:SetHeight(32);
mrbutton:SetPoint("TOPLEFT",15,-146);
mrbutton:SetText("MR");
mrbutton:SetScript("OnClick", function() xcalc_mr() end);
local mrbutton = CreateFrame("Button", "mrbutton",frame,"UIPanelButtonTemplate")
mrbutton:SetWidth(29)
mrbutton:SetHeight(32)
mrbutton:SetPoint("TOPLEFT",15,-146)
mrbutton:SetText("MR")
mrbutton:SetScript("OnClick", function() xcalc_mr() end)
--Memory Clear Button
local mcbutton = CreateFrame("Button", "mcbutton",frame,"UIPanelButtonTemplate");
mcbutton:SetWidth(29);
mcbutton:SetHeight(32);
mcbutton:SetPoint("TOPLEFT",15,-108);
mcbutton:SetText("MC");
mcbutton:SetScript("OnClick", function() xcalc_mc() end);
local mcbutton = CreateFrame("Button", "mcbutton",frame,"UIPanelButtonTemplate")
mcbutton:SetWidth(29)
mcbutton:SetHeight(32)
mcbutton:SetPoint("TOPLEFT",15,-108)
mcbutton:SetText("MC")
mcbutton:SetScript("OnClick", function() xcalc_mc() end)
--Option show button
local optionbutton = CreateFrame("Button", "xcalc_optionwindow_button",frame,"UIPanelButtonTemplate");
optionbutton:SetWidth(70);
optionbutton:SetHeight(25);
local optionbutton = CreateFrame("Button", "xcalc_optionwindow_button",frame,"UIPanelButtonTemplate")
optionbutton:SetWidth(70)
optionbutton:SetHeight(25)
optionbutton:SetPoint("BOTTOMRIGHT",-15,15)
optionbutton:SetText("Options");
optionbutton:SetScript("OnClick", function() xcalc_optiondisplay() end);
xcalc_rebind();
frame:Show();
tinsert(UISpecialFrames,"xcalc_window");
optionbutton:SetText("Options")
optionbutton:SetScript("OnClick", function() xcalc_optiondisplay() end)
xcalc_rebind()
frame:Show()
tinsert(UISpecialFrames,"xcalc_window")
end
 
function xcalc_optionframe()
--Options window Frame
local frame = CreateFrame("Frame","xcalc_optionwindow",xcalc_window);
frame:SetFrameStrata("HIGH");
frame:EnableMouse(true);
frame:SetWidth(220);
frame:SetHeight(200);
local frame = CreateFrame("Frame","xcalc_optionwindow",xcalc_window)
frame:SetFrameStrata("HIGH")
frame:EnableMouse(true)
frame:SetWidth(220)
frame:SetHeight(200)
frame: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 }});
frame:SetPoint("CENTER",230,0);
local titletexture = frame:CreateTexture("xcalc_optionwindow_titletexture");
titletexture:SetHeight(32);
titletexture:SetWidth(160);
titletexture:SetTexture("Interface/DialogFrame/UI-DialogBox-Header");
titletexture:SetTexCoord(0.2, 0.8, 0, 0.6);
titletexture:SetPoint("TOP",0,5);
local titlefont = frame:CreateFontString("xcalc_optionwindow_titlefont");
titlefont:SetHeight(0);
titlefont:SetWidth(140);
titlefont:SetFont("Fonts/FRIZQT__.TTF",12);
titlefont:SetPoint("TOP",0,-4);
titlefont:SetTextColor(1,0.8196079,0);
titlefont:SetText("Xcalc Options");
insets = { left = 11, right = 12, top = 12, bottom = 11 }})
frame:SetPoint("CENTER",230,0)
local titletexture = frame:CreateTexture("xcalc_optionwindow_titletexture")
titletexture:SetHeight(32)
titletexture:SetWidth(160)
titletexture:SetTexture("Interface/DialogFrame/UI-DialogBox-Header")
titletexture:SetTexCoord(0.2, 0.8, 0, 0.6)
titletexture:SetPoint("TOP",0,5)
local titlefont = frame:CreateFontString("xcalc_optionwindow_titlefont")
titlefont:SetHeight(0)
titlefont:SetWidth(140)
titlefont:SetFont("Fonts/FRIZQT__.TTF",12)
titlefont:SetPoint("TOP",0,-4)
titlefont:SetTextColor(1,0.8196079,0)
titlefont:SetText("Xcalc Options")
--Options Okay Button
local okaybutton = CreateFrame("Button", "xcalc_optionokaybutton",frame,"UIPanelButtonTemplate");
okaybutton:SetWidth(70);
okaybutton:SetHeight(29);
okaybutton:SetPoint("BOTTOM",0,20);
okaybutton:SetText("Okay");
okaybutton:SetScript("OnClick", function() xcalc_optiondisplay() end);
local okaybutton = CreateFrame("Button", "xcalc_optionokaybutton",frame,"UIPanelButtonTemplate")
okaybutton:SetWidth(70)
okaybutton:SetHeight(29)
okaybutton:SetPoint("BOTTOM",0,20)
okaybutton:SetText("Okay")
okaybutton:SetScript("OnClick", function() xcalc_optiondisplay() end)
--Binding Check box
local bindingcheckbox = CreateFrame("CheckButton","xcalc_options_bindcheckbox",frame,"OptionsCheckButtonTemplate");
bindingcheckbox:SetPoint("TOPLEFT",15,-40);
bindingcheckbox:SetChecked(Xcalc_Settings.Binding);
bindingcheckbox:SetScript("OnClick", function() xcalc_options_binding() end);
local bindingcheckboxtext = frame:CreateFontString("xcalc_options_bindcheckboxtext");
bindingcheckboxtext:SetWidth(200);
bindingcheckboxtext:SetHeight(0);
bindingcheckboxtext:SetFont("Fonts/FRIZQT__.TTF",10);
bindingcheckboxtext:SetTextColor(1,0.8196079,0);
bindingcheckboxtext:SetJustifyH("LEFT");
bindingcheckboxtext:SetText("Use Automatic Key Bindings");
bindingcheckboxtext:SetPoint("LEFT","xcalc_options_bindcheckbox",30,0);
local bindingcheckbox = CreateFrame("CheckButton","xcalc_options_bindcheckbox",frame,"OptionsCheckButtonTemplate")
bindingcheckbox:SetPoint("TOPLEFT",15,-40)
bindingcheckbox:SetChecked(Xcalc_Settings.Binding)
bindingcheckbox:SetScript("OnClick", function() xcalc_options_binding() end)
local bindingcheckboxtext = frame:CreateFontString("xcalc_options_bindcheckboxtext")
bindingcheckboxtext:SetWidth(200)
bindingcheckboxtext:SetHeight(0)
bindingcheckboxtext:SetFont("Fonts/FRIZQT__.TTF",10)
bindingcheckboxtext:SetTextColor(1,0.8196079,0)
bindingcheckboxtext:SetJustifyH("LEFT")
bindingcheckboxtext:SetText("Use Automatic Key Bindings")
bindingcheckboxtext:SetPoint("LEFT","xcalc_options_bindcheckbox",30,0)
--Display Minimap Check Box
local minimapcheckbox = CreateFrame("CheckButton","xcalc_options_minimapcheckbox",frame,"OptionsCheckButtonTemplate");
minimapcheckbox:SetPoint("TOPLEFT",15,-70);
minimapcheckbox:SetChecked(Xcalc_Settings.Minimapdisplay);
minimapcheckbox:SetScript("OnClick", function() xcalc_options_minimapdisplay() end);
local minimapcheckboxtext = minimapcheckbox:CreateFontString("xcalc_options_minimapcheckboxtext");
minimapcheckboxtext:SetWidth(200);
minimapcheckboxtext:SetHeight(0);
minimapcheckboxtext:SetFont("Fonts/FRIZQT__.TTF",10);
minimapcheckboxtext:SetTextColor(1,0.8196079,0);
minimapcheckboxtext:SetJustifyH("LEFT");
minimapcheckboxtext:SetText("Display Minimap Icon");
minimapcheckboxtext:SetPoint("LEFT","xcalc_options_minimapcheckbox",30,0);
local minimapcheckbox = CreateFrame("CheckButton","xcalc_options_minimapcheckbox",frame,"OptionsCheckButtonTemplate")
minimapcheckbox:SetPoint("TOPLEFT",15,-70)
minimapcheckbox:SetChecked(Xcalc_Settings.Minimapdisplay)
minimapcheckbox:SetScript("OnClick", function() xcalc_options_minimapdisplay() end)
local minimapcheckboxtext = minimapcheckbox:CreateFontString("xcalc_options_minimapcheckboxtext")
minimapcheckboxtext:SetWidth(200)
minimapcheckboxtext:SetHeight(0)
minimapcheckboxtext:SetFont("Fonts/FRIZQT__.TTF",10)
minimapcheckboxtext:SetTextColor(1,0.8196079,0)
minimapcheckboxtext:SetJustifyH("LEFT")
minimapcheckboxtext:SetText("Display Minimap Icon")
minimapcheckboxtext:SetPoint("LEFT","xcalc_options_minimapcheckbox",30,0)
--Minimap Position Slider
local minimapslider = CreateFrame("Slider","xcalc_options_minimapslider",frame,"OptionsSliderTemplate");
minimapslider:SetWidth(180);
minimapslider:SetHeight(16);
minimapslider:SetMinMaxValues(0, 360);
minimapslider:SetValueStep(1);
minimapslider:SetScript("OnValueChanged", function() xcalc_options_minimapslidercontrol() end);
xcalc_options_minimapsliderHigh:SetText();
xcalc_options_minimapsliderLow:SetText();
xcalc_options_minimapsliderText:SetText("Minimap Button Position");
minimapslider:SetPoint("TOPLEFT",15,-120);
minimapslider:SetValue(Xcalc_Settings.Minimappos);
local minimapslider = CreateFrame("Slider","xcalc_options_minimapslider",frame,"OptionsSliderTemplate")
minimapslider:SetWidth(180)
minimapslider:SetHeight(16)
minimapslider:SetMinMaxValues(0, 360)
minimapslider:SetValueStep(1)
minimapslider:SetScript("OnValueChanged", function() xcalc_options_minimapslidercontrol() end)
xcalc_options_minimapsliderHigh:SetText()
xcalc_options_minimapsliderLow:SetText()
xcalc_options_minimapsliderText:SetText("Minimap Button Position")
minimapslider:SetPoint("TOPLEFT",15,-120)
minimapslider:SetValue(Xcalc_Settings.Minimappos)
 
frame:Show();
frame:Show()
end
 
function xcalc_minimap_init()
if (Xcalc_Settings.Minimapdisplay == 1) then
local frame = CreateFrame("Button","xcalc_minimap_button",Minimap);
frame:SetWidth(34);
frame:SetHeight(34);
frame:SetFrameStrata("LOW");
frame:SetToplevel(1);
frame:SetNormalTexture("Interface\\AddOns\\xcalc\\xcalc_ButtonRoundNormal.tga");
frame:SetPushedTexture("Interface\\AddOns\\xcalc\\xcalc_ButtonRoundPushed.tga");
frame:SetHighlightTexture("Interface/Minimap/UI-Minimap-ZoomButton-Highlight");
frame:SetScript("OnClick", function() xcalc_windowdisplay() end);
frame:SetScript("OnEnter", function() xcalc_tooltip("minimap") end);
frame:SetScript("OnLeave", function() xcalc_tooltip("hide") end);
xcalc_minimapbutton_updateposition();
frame:Show();
local frame = CreateFrame("Button","xcalc_minimap_button",Minimap)
frame:SetWidth(34)
frame:SetHeight(34)
frame:SetFrameStrata("LOW")
frame:SetToplevel(1)
frame:SetNormalTexture("Interface\\AddOns\\xcalc\\xcalc_ButtonRoundNormal.tga")
frame:SetPushedTexture("Interface\\AddOns\\xcalc\\xcalc_ButtonRoundPushed.tga")
frame:SetHighlightTexture("Interface/Minimap/UI-Minimap-ZoomButton-Highlight")
frame:SetScript("OnClick", function() xcalc_windowdisplay() end)
frame:SetScript("OnEnter", function() xcalc_tooltip("minimap") end)
frame:SetScript("OnLeave", function() xcalc_tooltip("hide") end)
xcalc_minimapbutton_updateposition()
frame:Show()
end
end