Skip to content

Commit

Permalink
warehousesorter新規作成.
Browse files Browse the repository at this point in the history
  • Loading branch information
weizlogy committed Sep 11, 2018
1 parent 5ceb608 commit 0161b3a
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
13 changes: 13 additions & 0 deletions addons.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,19 @@
"worldmap"
]
},
{
"name" : "Warehouse Sorter",
"file" : "warehousesorter",
"extension" : "ipf",
"fileVersion" : "v1.0.0",
"releaseTag" : "warehousesorter",
"unicode" : "📖",
"description" : "個人倉庫にソートボタンを追加します。",
"tags" : [
"warehouse",
"sort"
]
},
{
"name" : "Remove New Collection Mark",
"file" : "rmnewcollectionmark",
Expand Down
19 changes: 19 additions & 0 deletions warehousesorter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Release Note.

## v1.0.0

### 何をするもの?

個人倉庫にソートボタンを追加します。

### どうすれば?

ipfファイルをインストールするだけです。

### いつ動くの?

- 個人倉庫を開いたとき

### 注意事項

ないよ!
72 changes: 72 additions & 0 deletions warehousesorter/warehousesorter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
-- 領域定義
local author = 'weizlogy'
local addonName = 'warehousesorter'
_G['ADDONS'] = _G['ADDONS'] or {}
_G['ADDONS'][author] = _G['ADDONS'][author] or {}
_G['ADDONS'][author][addonName] = _G['ADDONS'][author][addonName] or {}

-- 領域へのポインターを取得
local g = _G['ADDONS'][author][addonName]

-- コンストラクター
function g.new(self)
local members = {};

-- ソートボタン挿入
members.InjectSortButton = function(self, frame)
DESTROY_CHILD_BYNAME(frame, 'WAREHOUSESORTER_')
local sortButton = frame:CreateOrGetControl('button', 'WAREHOUSESORTER_SORT', 0, 0, 45, 45)
tolua.cast(sortButton, "ui::CButton")
sortButton:SetImage('inven_piece_btn')
sortButton:SetTextTooltip('{@st59}インベントリを整理する{/}')
sortButton:SetClickSound('button_click_big')
sortButton:SetAnimation("MouseOnAnim", "btn_mouseover")
sortButton:SetAnimation("MouseOffAnim", "btn_mouseoff")
sortButton:SetEventScript(ui.LBUTTONUP, "WAREHOUSESORTER_SELECT_SORT_TYPE")
sortButton:SetGravity(ui.RIGHT, ui.TOP)
sortButton:SetMargin(0, 110, 160, 0)
end

-- デストラクター
members.Destroy = function(self)
if (self.WAREHOUSE_OPEN ~= nil) then
WAREHOUSE_OPEN = self.WAREHOUSE_OPEN
end
end
-- おまじない
return setmetatable(members, {__index = self});
end
-- .newなしでコンストラクターを呼ぶエイリアス登録
setmetatable(g, {__call = g.new});

-- 自フレーム初期化処理
function WAREHOUSESORTER_ON_INIT(addon, frame)
-- 個人倉庫を開いたときにソートボタンを挿入する
if (g.instance.WAREHOUSE_OPEN == nil) then
g.instance.WAREHOUSE_OPEN = WAREHOUSE_OPEN
end
WAREHOUSE_OPEN = function(frame)
g.instance:InjectSortButton(frame)
g.instance.WAREHOUSE_OPEN(frame)
end
end

-- ソートメニュー生成
-- inventory.lua SORT_ITEM_INVENTORY() をベースに REQ_INV_SORT() に渡すパラメータを変更
function WAREHOUSESORTER_SELECT_SORT_TYPE()
local context = ui.CreateContextMenu("WAREHOUSESORTER_CONTEXT_INV_SORT", "", 0, 0, 170, 100);
local scpScp = "";
scpScp = string.format("REQ_INV_SORT(%d, %d)",IT_WAREHOUSE, BY_LEVEL);
ui.AddContextMenuItem(context, ScpArgMsg("SortByLevel"), scpScp);
scpScp = string.format("REQ_INV_SORT(%d, %d)",IT_WAREHOUSE, BY_WEIGHT);
ui.AddContextMenuItem(context, ScpArgMsg("SortByWeight"), scpScp);
scpScp = string.format("REQ_INV_SORT(%d, %d)",IT_WAREHOUSE, BY_NAME);
ui.AddContextMenuItem(context, ScpArgMsg("SortByName"), scpScp);
ui.OpenContextMenu(context);
end

-- インスタンス作成
if (g.instance ~= nil) then
g.instance:Destroy();
end
g.instance = g();
10 changes: 10 additions & 0 deletions warehousesorter/warehousesorter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<uiframe name="warehousesorter" x="10" y="10" width="100" height="100">
<frame title="WareHouse Sorter" snapclient="true" snapframe="true"/>
<option closebutton="false" hideable="false"/>
<input hittest="true"/>
<layer layerlevel="31" />
<draw blend="100" drawtitlebar="false" drawframe="false"/>
<controls>
</controls>
</uiframe>

0 comments on commit 0161b3a

Please sign in to comment.