Skip to content

Commit

Permalink
quickmenu v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
writ312 committed Jun 21, 2017
1 parent 28e1de9 commit 4e72365
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 0 deletions.
11 changes: 11 additions & 0 deletions addons.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,16 @@
"tags" : [
"ui","status"
]
},{
"name" : "Quick Menu",
"file" : "quickmenu",
"extension" : "ipf",
"fileVersion" : "v1.0.0",
"releaseTag" : "quickmenu",
"unicode" : "",
"description" : "チャットやチャットコマンドを登録し、選択できるメニューを表示する。詳細はREADMEに",
"tags" : [
"ui","Chat"
]
}
]
Binary file added quickmenu/quickmenu.ipf
Binary file not shown.
195 changes: 195 additions & 0 deletions quickmenu/quickmenu/quickmenu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
_G['ADDONS'] = _G['ADDONS'] or {};
_G['ADDONS']['QUICKMENU'] = _G['ADDONS']['QUICKMENU'] or {};
local g = _G['ADDONS']['QUICKMENU']
local acutil = require('acutil')
g.user = 'fill'
g.index = 1
g.counter = 0
g.setting = {}
g.settingPath = '../addons/quickmenu/'

function QUICKMENU_ON_INIT(addon,frame)
local user = GetMyName()
if(g.user ~= user) then
g.setting = {}
g.user = user
g.index = 1
end
local setting ,e = acutil.loadJSON(g.settingPath..user..'.json',nil) or {}
if(e or #setting == 0) then
table.insert(setting,{title = 'indun',type = 'chat',msg = '$indun'})
table.insert(setting,{title = 'よろ',type = 'chat',msg = 'よろー'})
table.insert(setting,{title = 'おつ',type = 'chat',msg = 'おつー'})
table.insert(setting,{title = 'おはよ',type = 'chat',msg = 'おはよー'})
table.insert(setting,{title = 'ばんわ',type = 'chat',msg = 'ばんわー'})
table.insert(setting,{title = 'うう~い',type = 'chat',msg = 'うう~い'})
g.setting.menu = setting
g.setting.interval = 5
else
g.setting = setting
end
for i = 1 ,12 do
if g.setting.menu[i] then
frame:GetChild('menu'..i):SetText('{#000000}'..g.setting.menu[i].title)
else
g.setting.menu[i] = {}
end
end

acutil.saveJSON(g.settingPath..g.user..'.json',g.setting)
acutil.setupHook(OPEN_QUICKMENU_FRAME,'UI_TOGGLE_HELPLIST')
acutil.slashCommand('/qm',QUICKMENU_COMMAND)
acutil.slashCommand('/quickmenu',QUICKMENU_COMMAND)

local edit = frame:CreateOrGetControl('edit','edit',0,0,0,0)
local timer = frame:CreateOrGetControl('timer','timer',0,0,0,0)
tolua.cast(timer,'ui::CAddOnTimer')
timer:SetUpdateScript('QUICKMENU_UPDATE')
end

function QUICKMENU_UPDATE(frame,msg,argStr,argNum)
g.counter = g.counter - 1
if g.counter > 0 then return end
local frame = ui.GetFrame('quickmenu')
if keyboard.GetDownKey() == 'ESC' or keyboard.GetDownKey() == 'F10' or joystick.IsKeyPressed('JOY_BTN_2') == 1 or GET_CHILD(frame,'edit','ui::CEditControl'):IsHaveFocus() == 0 then
GET_CHILD(frame,'timer','ui::CAddOnTimer'):Stop()
frame:ShowWindow(0)
return
end
if keyboard.GetDownKey() == 'SPACE' or keyboard.GetDownKey() == 'ENTER' or joystick.IsKeyPressed('JOY_BTN_3') == 1 then
EXCUTE_QUICKMENU_ITEM(frame,g.index)
return
end
if keyboard.GetDownKey() == 'DOWN' or joystick.IsKeyPressed('JOY_DOWN') == 1 then
g.index = g.index + 1
if g.index == 7 then
g.index = 1
elseif g.index == 13 then
g.index = 7
end
SELECT_QUICKMENU_ITEM(frame,g.index)
return
end
if keyboard.GetDownKey() == 'UP' or joystick.IsKeyPressed('JOY_UP') == 1 then
g.index = g.index - 1
if g.index == 0 then
g.index = 6
elseif g.index == 6 then
g.index = 12
end
SELECT_QUICKMENU_ITEM(frame,g.index)
return
end
if keyboard.GetDownKey() == 'RIGHT' or joystick.IsKeyPressed('JOY_RIGHT') == 1 then
g.index = g.index + 6
if g.index > 12 then
g.index = g.index - 12
end
SELECT_QUICKMENU_ITEM(frame,g.index)
return
end
if keyboard.GetDownKey() == 'LEFT' or joystick.IsKeyPressed('JOY_LEFT') == 1 then
g.index = g.index - 6
if g.index < 1 then
g.index = g.index + 12
end
SELECT_QUICKMENU_ITEM(frame,g.index)
return
end
end

function escapeCommand(string)
if string.sub(string, 1, 1) == "/" then
string = "$"..string.sub(string, 2, #string);
end
return string;
end

local function unescapeCommand(string)
if string.sub(string, 1, 1) == "$" then
string = "/"..string.sub(string, 2, #string);
end
return string;
end

function QUICKMENU_COMMAND(command)
local cmd = table.remove(command, 1);
if not cmd then
CHAT_SYSTEM("/qm [num] [title] [message]")
CHAT_SYSTEM("/qm msg [num] [message]");
CHAT_SYSTEM("/qm title [num] [title]");
CHAT_SYSTEM("/qm interval [num]");
elseif cmd == 'msg' then
-- /qm msg [num] [message]
local msg = "";
num = tonumber(table.remove(command, 1));
for index, item in ipairs(command) do
msg = msg..item.." ";
end
msg = string.sub(msg, 1, #msg - 1);
if 1 <= num and num <= 12 then
g.setting.menu[num].msg = escapeCommand(msg)
end
elseif cmd == 'title' then
-- /qm title [num] [title]
local title = "";
num = table.remove(command, 1);
title = table.remove(command, 1);
if 1 <= num and num <= 12 then
g.setting.menu[num].title = title
end
elseif cmd == 'interval' then
g.setting.interval = tonumber(table.remove(command,1))
else
-- /qm [num] [title] [message]
num = tonumber(cmd)
if 1 <= num and num <= 12 then
-- タイトルの取得
title = table.remove(command, 1);

-- メッセージの取得
local msg = "";
for index, item in ipairs(command) do
msg = msg..item.." ";
end
msg = string.sub(msg, 1, #msg - 1);
g.setting.menu[num].msg = escapeCommand(msg)
g.setting.menu[num].title = title
end
end
acutil.saveJSON(g.settingPath..g.user..'.json',g.setting)
local frame = ui.GetFrame('quickmenu')
for i = 1 ,12 do
if g.setting.menu[i] then
frame:GetChild('menu'..i):SetText('{#000000}'..g.setting.menu[i].title)
end
end
end

function OPEN_QUICKMENU_FRAME()
local frame = ui.GetFrame('quickmenu')
if frame:IsVisible() == 1 then frame:ShowWindow(0);return end
local edit = GET_CHILD(frame,'edit','ui::CEditControl')
edit:Focus()
local timer = GET_CHILD(frame,'timer','ui::CAddOnTimer')
timer:Stop()
timer:Start(0.01)
frame:Resize(frame:GetWidth(), 10 * 40 + 30);
frame:ShowWindow(1);
SELECT_QUICKMENU_ITEM(frame,g.index)
end

function SELECT_QUICKMENU_ITEM(frame,index)
local childName = 'menu' .. index
local ItemBtn = frame:GetChild(childName);
local x, y = GET_SCREEN_XY(ItemBtn);
mouse.SetPos(x + ItemBtn:GetWidth()*0.25,y);
mouse.SetHidable(0);
g.counter = g.setting.interval
end

function EXCUTE_QUICKMENU_ITEM(frame,index)
local item = g.setting.menu[index]
ui.Chat(unescapeCommand(item.msg))
frame:ShowWindow(0)
end
30 changes: 30 additions & 0 deletions quickmenu/quickmenu/quickmenu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by imc (imc) -->
<!-- edited with XMLSpy v2008 sp1 (http://www.altova.com) by MinstFaith (EMBRACE) -->
<uiframe name="quickmenu" x="0" y="0" width="500" height="400">
<frame title="{@st44}돌아가기{/}" layout_gravity="center top" margin="0 150 0 0"/>
<skin frameskin="test_win_system"/>
<draw drawnotitlebar="false" drawtitlebar="false"/>
<input moveable="false"/>
<layer topmostlayer="true" layerlevel="100"/>
<option closebutton="true" hideable="true"/>
<sound opensound="sys_popup_open_1" closesound="character_item_window_close"/>
<animation frameOpenAnim="chat_balloon_start" frameCloseAnim="chat_balloon_end"/>
<controls>
<!--<richtext name="tip" rect="0 60 380 30" layout_gravity="center top" caption="어떤 퀘스트로 돌아가시겠습니까?" fixwidth="true" fontname="brown_18_b" textalign="center center"/>-->
<button name="menu1" rect="0 0 200 40" margin="30 100 0 0" layout_gravity="left top" LBtnDownArgNum="0" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu2" rect="0 0 200 40" margin="30 140 0 0" layout_gravity="left top" LBtnDownArgNum="1" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu3" rect="0 0 200 40" margin="30 180 0 0" layout_gravity="left top" LBtnDownArgNum="2" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu4" rect="0 0 200 40" margin="30 220 0 0" layout_gravity="left top" LBtnDownArgNum="3" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu5" rect="0 0 200 40" margin="30 260 0 0" layout_gravity="left top" LBtnDownArgNum="4" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu6" rect="0 0 200 40" margin="30 300 0 0" layout_gravity="left top" LBtnDownArgNum="5" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>

<button name="menu7" rect="0 0 200 40" margin="260 100 0 0" layout_gravity="left top" LBtnDownArgNum="0" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu8" rect="0 0 200 40" margin="260 140 0 0" layout_gravity="left top" LBtnDownArgNum="1" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu9" rect="0 0 200 40" margin="260 180 0 0" layout_gravity="left top" LBtnDownArgNum="2" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu10" rect="0 0 200 40" margin="260 220 0 0" layout_gravity="left top" LBtnDownArgNum="3" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu11" rect="0 0 200 40" margin="260 260 0 0" layout_gravity="left top" LBtnDownArgNum="4" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>
<button name="menu12" rect="0 0 200 40" margin="260 300 0 0" layout_gravity="left top" LBtnDownArgNum="5" LBtnDownScp="QUESTWARP_QUESTID" MouseOffAnim="btn_mouseoff" MouseOnAnim="btn_mouseover" caption="{@st66b}퀘스트 클래스 네임{/}" clicksound="button_click_big" oversound="button_over" skin="test_pvp_btn" textalign="center center"/>

</controls>
</uiframe>

0 comments on commit 4e72365

Please sign in to comment.