code:
;-------------------------------------------------
; アイテム加工画面
;-------------------------------------------------
@HO_ITEM_CRAFT_MENU(MODULE_ID)
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 0
#DIM DYNAMIC LINE_NUM

;初期処理
HO_ITEM_CRAFT_PAGE_LEFT = 0
HO_ITEM_CRAFT_SELECT_ITEM_ID = -1
HO_ITEM_CRAFT_SELECT_RUNE_ID = -1
HO_ITEM_CRAFT_SELECT_RUNE_GENRE = 武器スキル_パッシブ
HO_CRAFT_CATEGORY = 0
HO_CRAFT_IS_ACTIVE_SUBWND = 0
HO_ITEM_CRAFT_BASE_PRODUCTION_RATE = 1
HO_ITEM_CRAFT_NUM_PRODUCTION       = 1
HO_ITEM_CRAFT_PRODUCTION_TIME      = 0

LINE_NUM = LINECOUNT

WHILE 1
    LINE_NUM = LINECOUNT
    REDRAW 0
    CALL WndMgr_DestroyWindow(-1)
    CALL HO_DRAW_CRAFT_ITEM_WINDOW_PARENT(MODULE_ID)
    IF HO_CRAFT_IS_ACTIVE_SUBWND && HO_CRAFT_CATEGORY == 0
        CALL WndMgr_Attribute(-1, "Disabled", 1)
        CALL HO_DRAW_CRAFT_ORDER_WINDOW()
    ENDIF
    CALL WndMgr_DisplayAll()
    REDRAW 1
    CALL HO_CRAFT_WINDOW_INPUT(MODULE_ID)
    IF RESULT == -1
        CLEARLINE LINECOUNT - LINE_NUM
        RETURN -1
    ELSEIF RESULT == 1
        CLEARLINE LINECOUNT - LINE_NUM
        RETURN 1
    ENDIF
    CLEARLINE LINECOUNT - LINE_NUM
WEND

@HO_DRAW_CRAFT_ITEM_WINDOW_PARENT(MODULE_ID)
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 0
#DIM CONST WND_WIDTH  = 170
#DIM CONST WND_HEIGHT = 54
#DIM DYNAMIC L_CNT
#DIM DYNAMIC BTN_ID

#DIMS DYNAMIC _LIST_MEMBER
#DIM DYNAMIC MEMBER_NUM
#DIM DYNAMIC CHARA_ID
#DIM DYNAMIC F_COL, 10

#DIMS DYNAMIC ITEM_NAME
#DIM DYNAMIC ITEM_NUM
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC WPN_MATERIAL_NEEDS, WPN_材質種類数, ITEM_LENGTH
#DIMS DYNAMIC WEAPON_NAME
#DIM DYNAMIC 材質種類
#DIM DYNAMIC アイテム種類
#DIM DYNAMIC IS_CRAFTABLE

BTN_ID = HO_アイテムクラフトボタンID

CALL WndMgr_CheckExistWindow()
FINDELEMENT RESULT, WINDOW_ID, 1
IF RESULT == -1
    CALL WndMgr_CreateWindow(WINDOW_ID, 0, 1, WND_WIDTH, WND_HEIGHT, 2)
ELSE
    CALL WndMgr_ResetWindow(WINDOW_ID)
ENDIF

;CATEGORYタブの文字色
VARSET F_COL, カラー_白
F_COL:HO_CRAFT_CATEGORY = カラー_選択中

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇クラフト◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;ヘッダー
LOCALS '= @"@C:{F_COL:0}@@B:0@[素材]@/B@@/C@"
SELECTCASE MODULE_ID
    CASE 301
        LOCALS += @"@C:{F_COL:1}@@B:1@　[武器]@/B@@/C@"
        LOCALS += @"@C:{F_COL:3}@@B:3@　[武器の強化]@/B@@/C@"
        LOCALS += @"@C:{F_COL:4}@@B:4@　[武器の付呪]@/B@@/C@"
    CASE 305
        LOCALS += @"@C:{F_COL:2}@@B:2@　[衣類]@/B@@/C@"
ENDSELECT
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)

SELECTCASE HO_CRAFT_CATEGORY
        ;アイテム
    CASE 0
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_LEFT(MODULE_ID)
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT(MODULE_ID)
        ;武器
    CASE 1
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_LEFT(MODULE_ID)
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_WEAPON(MODULE_ID)
        ;衣類
    CASE 2
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_LEFT(MODULE_ID)
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_CLOTH(MODULE_ID)
        ;武器の改良
    CASE 3
        CALL HO_DRAW_ITEM_MENU_WINDOW_LEFT(MODULE_ID, "WEAPON_MODIFY")
        IF HO_CRAFT_IS_ACTIVE_SUBWND
            CALL WndMgr_Attribute(-1, "Disabled", 1)
            CALL HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_WEAPON_MODIFY(MODULE_ID)
        ENDIF
    CASE 4
        CALL HO_DRAW_ITEM_MENU_WINDOW_LEFT(MODULE_ID, "WEAPON_ENCHANT")
        IF HO_CRAFT_IS_ACTIVE_SUBWND
            CALL WndMgr_Attribute(-1, "Disabled", 1)
            IF HO_CRAFT_IS_ACTIVE_SUBWND == 1
                CALL HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_WEAPON_ENCHANT(MODULE_ID)
            ELSEIF HO_CRAFT_IS_ACTIVE_SUBWND == 2
                CALL HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_WEAPON_SELECT_RUNE(MODULE_ID)
            ENDIF
        ENDIF
    CASEELSE

ENDSELECT

;フッター出力
;-------------------------------------------------
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@B:9999999@@C:{カラー_白}@[キャンセル]@/C@@/B@")

RETURN

@HO_DRAW_CRAFT_ITEM_WINDOW_LEFT(MODULE_ID)
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 1
#DIM CONST WND_WIDTH  = 64
#DIM CONST WND_HEIGHT = 48
#DIM DYNAMIC L_CNT
#DIM DYNAMIC F_COL, 10

;CATEGORYタブの文字色
VARSET F_COL, カラー_白
F_COL:HO_CRAFT_CATEGORY = カラー_選択中

;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 2, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@作成するアイテムを選択してください@/C@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;衣類用の衣装部位タブ
IF HO_CRAFT_CATEGORY == 2
    FOR LOCAL, 0, VARSIZE("CLOTH_PART_NAME")
        SIF LOCAL == 衣装部位_武器
            CONTINUE
        LOCALS '= TAG_PRINT_SHAPE(@"@B:{LOCAL + 1000}@%TOHALF(CLOTH_PART_NAME:LOCAL)%@/B@", 8, 1, 2)
        CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"@C:{HO_ITEM_CRAFT_SELECT_CLOTH_PARTS == LOCAL ? カラー_選択中 # カラー_白}@[%LOCALS%]@/C@　")
        SIF (LOCAL + 1) % 5 == 0
            L_CNT ++
    NEXT
    L_CNT ++
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
ENDIF

SELECTCASE HO_CRAFT_CATEGORY
        ;アイテム
    CASE 0
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_PRINT_DETAIL_ITEM(WINDOW_ID, MODULE_ID)
        ;武器
    CASE 1
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_PRINT_DETAIL_WEAPON(WINDOW_ID, MODULE_ID)
        ;衣類
    CASE 2
        CALL HO_DRAW_CRAFT_ITEM_WINDOW_PRINT_DETAIL_CLOTH(WINDOW_ID, MODULE_ID)
        ;武器の改良
    CASE 3
        ; CALL HO_DRAW_CRAFT_ITEM_WINDOW_PRINT_DETAIL_WEAPON_MODIFY(WINDOW_ID, MODULE_ID)
    CASEELSE

ENDSELECT

@HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT(MODULE_ID)
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 2
#DIM CONST WND_WIDTH  = 102
#DIM CONST WND_HEIGHT = 48
#DIM CONST ヘッダー行数 = 2
#DIM CONST BTN_ID = 2000
#DIM DYNAMIC L_CNT

#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC MATERIAL_NAME
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM  DYNAMIC STOCKNUM
#DIM DYNAMIC F_COL
#DIM DYNAMIC IS_CRAFTABLE = 1
#DIM DYNAMIC ERR_FLG

#DIM DYNAMIC 基準生産量
#DIM DYNAMIC 基準生産時間 = 15
#DIMS DYNAMIC 生産物名
#DIM DYNAMIC 生産時間
#DIM DYNAMIC 生産回数
#DIMS DYNAMIC 現在時刻
#DIMS DYNAMIC 完了予定時刻
#DIM  DYNAMIC 能力累算

;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 66, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)
SIF HO_ITEM_CRAFT_SELECT_ITEM_ID == -1
    RETURN

ITEM_ID = HO_ITEM_CRAFT_SELECT_ITEM_ID
IF ITEM_ID >= 1000000
    ITEM_ID -= 1000000
    IS_CRAFTABLE = 0
ENDIF

基準生産量   = HO_ITEM_CRAFT_BASE_PRODUCTION_RATE
生産回数     = HO_ITEM_CRAFT_NUM_PRODUCTION

;ヘッダー
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME = %RESULTS%
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　%ITEM_NAME%　◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;概要欄
VARSET RESULTS
FOR LOCAL, 0, 10
    TRYCALLFORM GET_ITEM_DESCRIPTION_{ITEM_ID}
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%RESULTS:LOCAL%")
NEXT

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
VARSET RESULTS
FOR LOCAL, 0, 10
    TRYCALLFORM GET_ITEM_SUBDESCRIPTION_{ITEM_ID}
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%RESULTS:LOCAL%")
NEXT

;備考欄
L_CNT++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　生産情報　◇@/S@@/C@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@C:{カラー_注釈}@・要求素材@/C@")

FOR LOCAL, 0, 5
    IF LOCAL > 0
        CALL GET_ITEM_MATERIAL_NEEDS(ITEM_ID, MATERIAL_NEEDS, LOCAL)
    ENDIF
    IF LOCAL == 0 || (LOCAL > 0 && RESULT > 0) ;通常レシピは確定で表示。代替レシピ(RECIPE_ID > 0)はレシピが有効(RESULT > 0)なら表示
        CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"@B:{BTN_ID + 10 + LOCAL}@@C:{LOCAL == HO_CRAFT_RECIPE_ID ? カラー_選択中 # カラー_白}@　　[レシピ{LOCAL + 1}]@/C@@/B@")
    ENDIF
NEXT
L_CNT ++
L_CNT ++
CALL GET_ITEM_MATERIAL_NEEDS(ITEM_ID, MATERIAL_NEEDS, HO_CRAFT_RECIPE_ID)
FOR LOCAL:0, 0, ITEM_LENGTH
    IF MATERIAL_NEEDS:(LOCAL:0) > 0
        IF LOCAL == ITEM_ディナリ
            STOCKNUM = MONEY
        ELSEIF LOCAL == ITEM_淫堕点
            STOCKNUM = QST_LEWD_POINT
        ELSE
            STOCKNUM = HO_ITEM_STOCK:(LOCAL:0)
        ENDIF
        CALL GET_ITEM_NAME(LOCAL:0)
        MATERIAL_NAME = %RESULTS%
        LOCALS = %TAG_PRINT_SHAPE(@"　　@C:{カラー_白}@%MATERIAL_NAME%@/C@", 24, 1, 0)%
        LOCALS += @"× {(MATERIAL_NEEDS:(LOCAL:0)* 生産回数)}"
        LOCALS += @"@C:{カラー_選択不可}@　(所持:{STOCKNUM})@/C@"
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
        L_CNT ++
        IF STOCKNUM < MATERIAL_NEEDS:(LOCAL:0)
            IS_CRAFTABLE = 0
        ENDIF
    ENDIF
NEXT

;生産対象の情報を取得
CALL GET_ITEM_INFO(ITEM_ID, ITEM_基準生産量 + HO_CRAFT_RECIPE_ID)
基準生産量 = RESULT
;15分以上に時間をかけたいものに生産時間を加算
CALL GET_ITEM_INFO(ITEM_ID, ITEM_追加生産時間)
基準生産時間 += RESULT
;クラフトに参加している他のキャラの能力に応じ生産時間を減算 （100-3*√該当能力累算)％ 能力50が3人いると所要時間36％減
CALL HO_GET_USE_MODULE_INFO(MASTER)
MODULE_ID = RESULT
FOR LOCAL, 0, MTAR_NUM
    SELECTCASE MODULE_ID
        CASE 300 ;作業台
            能力累算 += ABL:(MTAR:LOCAL):器用
        CASE 302 ;キッチン
            能力累算 += ABL:(MTAR:LOCAL):料理
        CASE 303 ;錬金台
            能力累算 += ABL:(MTAR:LOCAL):知識
        CASEELSE
            能力累算 += ABL:(MTAR:LOCAL):器用
    ENDSELECT
NEXT
SIF 能力累算
    基準生産時間 = MAX(10, FTIMES(基準生産時間, 100 - (3 * SQRT(能力累算))))
;まとめ作りボーナスで時間減算 100-(生産回数の２乗÷4)％　10個作ると25％の時短に
SIF 生産回数 > 1
    基準生産時間 = MAX(10, FTIMES(基準生産時間, 100 - (生産回数 * 生産回数 / 4)))
;基準生産時間に端数がある場合は単位時間の倍数になるように
SIF 基準生産時間 % HO_単位時間 > 0
    基準生産時間 = MAX(HO_単位時間, 基準生産時間 / HO_単位時間 * HO_単位時間)

現在時刻 '= @"{HO_TIME / 60}:%TOSTR(HO_TIME % 60, "00")%"
生産時間 = 基準生産時間 * 生産回数
完了予定時刻 '= @"{(HO_TIME + 生産時間) / 60}:%TOSTR((HO_TIME + 生産時間) % 60, "00")%"

;;生産回数と時間
;生産回数設定ボタン
;生産量増減時のエラーチェック
FOR LOCAL:0, 0, ITEM_LENGTH
    IF LOCAL == ITEM_ディナリ
        STOCKNUM = MONEY
    ELSEIF LOCAL == ITEM_淫堕点
        STOCKNUM = QST_LEWD_POINT
    ELSE
        STOCKNUM = HO_ITEM_STOCK:(LOCAL:0)
    ENDIF
    IF (MATERIAL_NEEDS:(LOCAL:0) * (生産回数 + 1)) > STOCKNUM
        ERR_FLG ++
    ENDIF
    IF HO_TIME + 基準生産時間 * (生産回数 + 1) > HO_CLOCK(2700)
        ERR_FLG ++
    ENDIF
NEXT

L_CNT ++
IF 生産回数 > 1
    LOCALS '= @"@B:{BTN_ID + 3}@[-]@/B@ "
ELSE
    LOCALS '= @"@C:{カラー_選択不可}@[-]@/C@ "
ENDIF
IF !ERR_FLG && 生産回数 < 10
    LOCALS += @"@B:{BTN_ID + 2}@[+]@/B@ "
ELSE
    LOCALS += @"@C:{カラー_選択不可}@[+]@/C@ "
ENDIF

;L_CNT = 25
L_CNT = WND_HEIGHT - 7 - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・生産回数@/C@")
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"　　@C:{カラー_白}@生産回数:{生産回数}回　@/C@%LOCALS%")
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"　　　　@C:{カラー_白}@⇒　所要時間:{生産時間}分 (%現在時刻% → %完了予定時刻%)@/C@")
L_CNT ++
;生産対象の情報を印字
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・生産物@/C@")
L_CNT ++
LOCALS = %TAG_PRINT_SHAPE(@"　　　　@C:{カラー_注意}@⇒　%ITEM_NAME%@/C@", 36, 1, 0)%
LOCALS += @"× {基準生産量 * 生産回数}"
LOCALS += @"@C:{カラー_選択不可}@　(所持:{HO_ITEM_STOCK:ITEM_ID})@/C@"
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注意}@%LOCALS%@/C@")

;フッター
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
IF IS_CRAFTABLE
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@B:{BTN_ID + 1}@@C:{カラー_白}@[クラフトする]@/C@@/B@")
ELSE
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@C:{カラー_選択不可}@[クラフトする]@/C@")
ENDIF
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT++, @"@B:[CRAFT_ORDER:{ITEM_ID}][RECIPE_NO:{HO_CRAFT_RECIPE_ID}]@　[レシピを指示書に登録]@/B@")

HO_ITEM_CRAFT_BASE_PRODUCTION_RATE = 基準生産量
HO_ITEM_CRAFT_NUM_PRODUCTION       = 生産回数
HO_ITEM_CRAFT_PRODUCTION_TIME      = 生産時間

@HO_DRAW_CRAFT_ITEM_WINDOW_PRINT_DETAIL_ITEM(WINDOW_ID, MODULE_ID)
#DIM WINDOW_ID
#DIM MODULE_ID
#DIM CONST HEADER_NUM = 2
#DIM CONST MAX_ROW = 40
#DIM CONST BTN_ID = 1000000

#DIM  DYNAMIC WND_WIDTH
#DIMS DYNAMIC DETAIL_LIST, ITEM_LENGTH
#DIM  DYNAMIC ITEM_NUM
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC PAGE_NUM
#DIMS DYNAMIC STR_FOOTER
#DIM  DYNAMIC DETAIL_LINECOUNT
;アイテム関連
#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM  DYNAMIC ITEM_ID
#DIM  DYNAMIC IS_CRAFTABLE
#DIM  DYNAMIC RECIPE_ID

;明細リスト作成
DETAIL_LINECOUNT = 0
L_CNT = 0
FOR ITEM_ID, 0, ITEM_LENGTH
    CALL CHECK_ITEM_CRAFTABLE((ITEM_ID), MODULE_ID)
    SIF RESULT == -1
        CONTINUE
    IS_CRAFTABLE = -1
    FOR RECIPE_ID, 0, 5
        CALL GET_ITEM_MATERIAL_NEEDS((ITEM_ID), MATERIAL_NEEDS, RECIPE_ID)
        SIF RESULT == -1
            CONTINUE
        FOR LOCAL:1, 0, ITEM_LENGTH
            ;アイテム在庫が要求を満たさない場合、表示はするが作成は不可に
            IF MATERIAL_NEEDS:(LOCAL:1) > 0 && (HO_ITEM_STOCK:(LOCAL:1) < MATERIAL_NEEDS:(LOCAL:1))
                IS_CRAFTABLE = 0
            ELSEIF HO_ITEM_STOCK:(LOCAL:1) >= MATERIAL_NEEDS:(LOCAL:1)
                IS_CRAFTABLE = 1
            ENDIF
        NEXT
    NEXT
    CALL GET_ITEM_NAME(ITEM_ID)
    ITEM_NAME = %RESULTS%
    IF IS_CRAFTABLE == 1
        DETAIL_LIST:DETAIL_LINECOUNT '= @"@B:{BTN_ID + ITEM_ID}@@C:{カラー_白}@[%ITEM_NAME%]@/C@@/B@"
    ELSE
        DETAIL_LIST:DETAIL_LINECOUNT '= @"@B:{BTN_ID + ITEM_ID + 1000000}@@C:{カラー_選択不可}@[%ITEM_NAME%]@/C@@/B@"
    ENDIF
    DETAIL_LIST:DETAIL_LINECOUNT = %TAG_PRINT_SHAPE(DETAIL_LIST:DETAIL_LINECOUNT, 28, 1, 0)%
    DETAIL_LINECOUNT ++
NEXT

PAGE_NUM = DETAIL_LINECOUNT / MAX_ROW

;明細リスト出力
L_CNT = 0
FOR LOCAL, MAX_ROW * HO_ITEM_CRAFT_PAGE_LEFT, MAX_ROW * (HO_ITEM_CRAFT_PAGE_LEFT + 1)
    IF  L_CNT / MAX_ROW <= 0
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT + HEADER_NUM, DETAIL_LIST:LOCAL)
        L_CNT++
    ELSE
        CALL WndMgr_TextAdd(WINDOW_ID, (L_CNT % MAX_ROW) + HEADER_NUM, DETAIL_LIST:LOCAL)
        L_CNT ++
    ENDIF
    L_CNT ++
NEXT

;フッター
CALL WndMgr_GetRectangle(WINDOW_ID)
WND_WIDTH = RESULT:2

IF PAGE_NUM > 0
    STR_FOOTER += HO_ITEM_CRAFT_PAGE_LEFT > 0 ? @"@B:9000@<<@/B@ " # "   "
    STR_FOOTER += @"%TOSTR(HO_ITEM_CRAFT_PAGE_LEFT + 1, "..")% "
    STR_FOOTER += HO_ITEM_CRAFT_PAGE_LEFT != PAGE_NUM ? @"@B:9001@>>@/B@" # "  "
    CALLF TAG_PRINT_SHAPE(STR_FOOTER, WND_WIDTH - 8, 1, 2)
    CALL WndMgr_TextSet(WINDOW_ID, MAX_ROW + 2, @"@C:{カラー_注釈}@%RESULTS%@/C@")
ENDIF

@HO_DRAW_CRAFT_ITEM_WINDOW_PRINT_DETAIL_WEAPON(WINDOW_ID, MODULE_ID)
#DIM WINDOW_ID
#DIM MODULE_ID
#DIM CONST HEADER_NUM = 2
#DIM CONST MAX_ROW = 20
#DIM CONST BTN_ID = 1000000

#DIM  DYNAMIC WND_WIDTH
#DIMS DYNAMIC DETAIL_LIST, ITEM_LENGTH
#DIM  DYNAMIC ITEM_NUM
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC PAGE_NUM
#DIMS DYNAMIC STR_FOOTER
#DIM  DYNAMIC DETAIL_LINECOUNT
;アイテム関連
#DIMS DYNAMIC ITEM_NAME
#DIM DYNAMIC WPN_MATERIAL_NEEDS, WPN_材質種類数, ITEM_LENGTH
#DIM  DYNAMIC ITEM_ID
#DIM  DYNAMIC IS_CRAFTABLE
#DIM  DYNAMIC 材質種類
#DIM  DYNAMIC 素材アイテム

;明細リスト作成
DETAIL_LINECOUNT = 0
L_CNT = 0
FOR ITEM_ID, 0, WPN_MAX_WEAPONNUM
    CALL CHECK_WEAPON_CRAFTABLE(ITEM_ID, MODULE_ID)
    SIF RESULT == -1
        CONTINUE
    FOR 材質種類, 0, WPN_材質種類数
        CALL GET_WEAPON_MATERIAL_NEEDS(ITEM_ID, 材質種類, WPN_MATERIAL_NEEDS)
        IF RESULT != -1
            IS_CRAFTABLE = -1
            FOR 素材アイテム, 0, ITEM_LENGTH
                ;アイテム在庫が要求を満たさない場合、表示はするが作成は不可に
                IF WPN_MATERIAL_NEEDS:材質種類:素材アイテム > 0 && (HO_ITEM_STOCK:素材アイテム < WPN_MATERIAL_NEEDS:材質種類:素材アイテム)
                    IS_CRAFTABLE = 0
                ENDIF
            NEXT
            CALL GET_WEAPON_NAME(ITEM_ID)
            ITEM_NAME = %RESULTS%
            IF IS_CRAFTABLE
                DETAIL_LIST:DETAIL_LINECOUNT '= @"@B:{BTN_ID + ITEM_ID + (材質種類 * 1000)}@@C:{カラー_白}@[%WPN_材質別接頭文字:材質種類%の%ITEM_NAME%]@/C@@/B@"
            ELSE
                DETAIL_LIST:DETAIL_LINECOUNT '= @"@B:{BTN_ID + ITEM_ID + (材質種類 * 1000) + 1000000}@@C:{カラー_選択不可}@[%WPN_材質別接頭文字:材質種類%の%ITEM_NAME%]@/C@@/B@"
            ENDIF
            DETAIL_LIST:DETAIL_LINECOUNT = %TAG_PRINT_SHAPE(DETAIL_LIST:DETAIL_LINECOUNT, 28, 1, 0)%
            DETAIL_LINECOUNT ++
        ELSE
            CONTINUE
        ENDIF
    NEXT
NEXT

PAGE_NUM = DETAIL_LINECOUNT / MAX_ROW

;明細リスト出力
L_CNT = 0
FOR LOCAL, MAX_ROW * HO_ITEM_CRAFT_PAGE_LEFT, MAX_ROW * (HO_ITEM_CRAFT_PAGE_LEFT + 1)
    IF  L_CNT / MAX_ROW <= 0
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT + HEADER_NUM, DETAIL_LIST:LOCAL)
        L_CNT++
    ELSE
        CALL WndMgr_TextAdd(WINDOW_ID, (L_CNT % MAX_ROW) + HEADER_NUM, DETAIL_LIST:LOCAL)
        L_CNT ++
    ENDIF
    L_CNT ++
NEXT

;フッター
CALL WndMgr_GetRectangle(WINDOW_ID)
WND_WIDTH = RESULT:2

IF PAGE_NUM > 0
    STR_FOOTER += HO_ITEM_CRAFT_PAGE_LEFT > 0 ? @"@B:9000@<<@/B@ " # "   "
    STR_FOOTER += @"%TOSTR(HO_ITEM_CRAFT_PAGE_LEFT + 1, "..")% "
    STR_FOOTER += HO_ITEM_CRAFT_PAGE_LEFT != PAGE_NUM ? @"@B:9001@>>@/B@" # "  "
    CALLF TAG_PRINT_SHAPE(STR_FOOTER, WND_WIDTH - 8, 1, 2)
    CALL WndMgr_TextSet(WINDOW_ID, MAX_ROW + 2, @"@C:{カラー_注釈}@%RESULTS%@/C@")
ENDIF

@HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_WEAPON(MODULE_ID)
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 2
#DIM CONST WND_WIDTH  = 102
#DIM CONST WND_HEIGHT = 37
#DIM CONST ヘッダー行数 = 2
#DIM CONST BTN_ID = 2000
#DIM DYNAMIC L_CNT

#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC ITEM_NAME
#DIMS DYNAMIC MATERIAL_NAME
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC F_COL
#DIM DYNAMIC IS_CRAFTABLE = 1
#DIM DYNAMIC ERR_FLG
;生産関連変数
#DIM DYNAMIC 基準生産量
#DIM DYNAMIC 基準生産時間 = 30
#DIMS DYNAMIC 生産物名
#DIM DYNAMIC 生産時間
#DIM DYNAMIC 生産回数 = 1
#DIMS DYNAMIC 現在時刻
#DIMS DYNAMIC 完了予定時刻
;武器関連変数
#DIMS DYNAMIC WEAPON_NAME
#DIM DYNAMIC WEAPON_ID
#DIM DYNAMIC 材質種類
#DIM DYNAMIC WPN_MATERIAL_NEEDS, WPN_材質種類数, ITEM_LENGTH
#DIM DYNAMIC PASSIVE_SKILL_SLOT
#DIM DYNAMIC ACTIVE_SKILL_SLOT

#DIMS CONST  WPN_STATUS_NAME_SHORT = "攻撃", "防御", "軽減", "魔力", "行動", "敵視", "選敵"
#DIM  DYNAMIC COLUMN_LENGTH = 14, 14, 14, 14, 14, 14, 16
#DIM  DYNAMIC STATUS_IDX
;ステータスの表示順序
{
    #DIMS CONST COLUMN_ORDER =
        "ATTACK"
        , "DEFENCE"
        , "ARMOR"
        , "MAG"
        , "AGILITY"
        , "HATE_RATE"
        , "TARGETING"
}

;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 66, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)
SIF HO_ITEM_CRAFT_SELECT_ITEM_ID == -1
    RETURN

ITEM_ID = HO_ITEM_CRAFT_SELECT_ITEM_ID
IF ITEM_ID >= 1000000
    ITEM_ID -= 1000000
    IS_CRAFTABLE = 0
ENDIF

;1-3桁目 WEAPON_ID
;4-5桁目 材質種類
WEAPON_ID = ITEM_ID % 1000
材質種類   = ITEM_ID / 1000
;武器名
CALL GET_WEAPON_NAME(WEAPON_ID)
WEAPON_NAME '= @"%WPN_材質別接頭文字:材質種類%の%RESULTS%"
;ステータス取得
CALL GET_WEAPON_STATUS(WEAPON_ID, 材質種類)

;ヘッダー
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME = %RESULTS%
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　%WEAPON_NAME%　◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・ステータス@/C@")
LOCALS '= ""
FOR LOCAL, 0, WPN_MAX_STATUSNUM
    STATUS_IDX = FINDELEMENT(WPN_STATUS_NAME_ENG, COLUMN_ORDER:LOCAL)
    IF STATUS_IDX != WPN_脅威選定
        LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:{WPN_STATUS:STATUS_IDX}@/C@", COLUMN_LENGTH:LOCAL, 1)
    ELSE
        LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:%WPN_脅威選定文字列:(WPN_STATUS:STATUS_IDX)%@/C@", COLUMN_LENGTH:LOCAL, 1)
    ENDIF
NEXT
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%LOCALS%")

TRYCCALLFORM GET_WEAPON_SKILL_SLOT_{WEAPON_ID}(材質種類)
    PASSIVE_SKILL_SLOT = RESULT:0
    ACTIVE_SKILL_SLOT = RESULT:1
    L_CNT ++
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・スキルスロット数@/C@")
    LOCALS '= @"@C:{カラー_オレンジ}@　ACTIVE :@/C@%"□"* (ACTIVE_SKILL_SLOT)%"
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
    LOCALS '=  @"@C:{カラー_黄緑}@　PASSIVE:@/C@%"□"* (PASSIVE_SKILL_SLOT)%"
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
CATCH
ENDCATCH

;生産情報
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　生産情報　◇@/S@@/C@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・要求素材@/C@")
L_CNT ++
CALL GET_WEAPON_MATERIAL_NEEDS(WEAPON_ID, 材質種類, WPN_MATERIAL_NEEDS)
FOR LOCAL:0, 0, ITEM_LENGTH
    IF WPN_MATERIAL_NEEDS:材質種類:(LOCAL:0) > 0
        CALL GET_ITEM_NAME(LOCAL:0)
        MATERIAL_NAME = %RESULTS%
        LOCALS = %TAG_PRINT_SHAPE(@"　　@C:{カラー_白}@%MATERIAL_NAME%@/C@", 24, 1, 0)%
        LOCALS += @"× {WPN_MATERIAL_NEEDS:材質種類:(LOCAL:0)}"
        LOCALS += @"@C:{カラー_選択不可}@　(所持:{HO_ITEM_STOCK:(LOCAL:0)})@/C@"
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
        L_CNT ++
    ENDIF
NEXT

SIF !IS_CRAFTABLE
    RETURN

;生産時間
現在時刻 '= @"{HO_TIME / 60}:%TOSTR(HO_TIME % 60, "00")%"
生産時間 = 基準生産時間 * 生産回数
完了予定時刻 '= @"{(HO_TIME + 生産時間) / 60}:%TOSTR((HO_TIME + 生産時間) % 60, "00")%"
L_CNT = 25
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・生産回数@/C@")
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"　　@C:{カラー_白}@生産回数:{生産回数}回　@/C@")
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"　　　　@C:{カラー_白}@⇒　所要時間:{生産時間}分 (%現在時刻% → %完了予定時刻%)@/C@")
L_CNT ++

;フッター
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@B:{BTN_ID + 1}@@C:{カラー_白}@[クラフトする]@/C@@/B@")

HO_ITEM_CRAFT_WEAPON_NAME          = %WEAPON_NAME%
HO_ITEM_CRAFT_WEAPON_MATERIAL      = 材質種類
HO_ITEM_CRAFT_NUM_PRODUCTION       = 生産回数
HO_ITEM_CRAFT_PRODUCTION_TIME      = 生産時間

;-------------------------------------------------
;衣装
;-------------------------------------------------
@HO_DRAW_CRAFT_ITEM_WINDOW_PRINT_DETAIL_CLOTH(WINDOW_ID, MODULE_ID)
#DIM WINDOW_ID
#DIM MODULE_ID
#DIM CONST HEADER_NUM = 6
#DIM CONST MAX_ROW = 26
#DIM CONST BTN_ID = 1000000

#DIM  DYNAMIC WND_WIDTH
#DIM  DYNAMIC WND_HEIGHT
#DIMS DYNAMIC DETAIL_LIST, ITEM_LENGTH
#DIM  DYNAMIC ITEM_NUM
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC PAGE_NUM
#DIMS DYNAMIC STR_FOOTER
#DIM  DYNAMIC DETAIL_LINECOUNT
;アイテム関連
#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM  DYNAMIC ITEM_ID
#DIM  DYNAMIC IS_CRAFTABLE
;衣装関連
#DIM 部位

部位 = HO_ITEM_CRAFT_SELECT_CLOTH_PARTS
;明細リスト作成
DETAIL_LINECOUNT = 0
L_CNT = 0
;衣装の0番は"なし"なので1からスタート
FOR ITEM_ID, 1, ITEM_LENGTH
    CALL GET_CLOTH_MATERIAL_NEEDS(部位, ITEM_ID, MATERIAL_NEEDS)
    IS_CRAFTABLE = 1
    FOR LOCAL:1, 0, ITEM_LENGTH
        ;アイテム在庫が要求を満たさない場合、表示はするが作成は不可に
        IF MATERIAL_NEEDS:(LOCAL:1) > 0 && (HO_ITEM_STOCK:(LOCAL:1) < MATERIAL_NEEDS:(LOCAL:1))
            IS_CRAFTABLE = 0
        ENDIF
    NEXT
    CALL GET_CLOTH_NAME(部位, ITEM_ID)
    IF RESULT
        ITEM_NAME = %RESULTS%
        IF IS_CRAFTABLE
            DETAIL_LIST:DETAIL_LINECOUNT '= @"@B:{BTN_ID + ITEM_ID}@@C:{カラー_白}@[%ITEM_NAME%]@/C@@/B@"
        ELSE
            DETAIL_LIST:DETAIL_LINECOUNT '= @"@B:{BTN_ID + ITEM_ID + 1000000}@@C:{カラー_選択不可}@[%ITEM_NAME%]@/C@@/B@"
        ENDIF
        DETAIL_LIST:DETAIL_LINECOUNT = %TAG_PRINT_SHAPE(DETAIL_LIST:DETAIL_LINECOUNT, 28, 1, 0)%
        DETAIL_LINECOUNT ++
    ENDIF
    ; ELSE
    ;     CONTINUE
    ; ENDIF
NEXT

PAGE_NUM = DETAIL_LINECOUNT / MAX_ROW

;明細リスト出力
L_CNT = 0
FOR LOCAL, MAX_ROW * HO_ITEM_CRAFT_PAGE_LEFT, MAX_ROW * (HO_ITEM_CRAFT_PAGE_LEFT + 1)
    IF  L_CNT / MAX_ROW <= 0
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT + HEADER_NUM, DETAIL_LIST:LOCAL)
        L_CNT++
    ELSE
        CALL WndMgr_TextAdd(WINDOW_ID, (L_CNT % MAX_ROW) + HEADER_NUM, DETAIL_LIST:LOCAL)
        L_CNT ++
    ENDIF
    L_CNT ++
NEXT

;フッター
CALL WndMgr_GetRectangle(WINDOW_ID)
WND_WIDTH  = RESULT:2
WND_HEIGHT = RESULT :3
L_CNT = WND_HEIGHT - 4
IF PAGE_NUM > 0
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
    STR_FOOTER += HO_ITEM_CRAFT_PAGE_LEFT > 0 ? @"@B:9000@<<@/B@ " # "   "
    STR_FOOTER += @"%TOSTR(HO_ITEM_CRAFT_PAGE_LEFT + 1, "..")% "
    STR_FOOTER += HO_ITEM_CRAFT_PAGE_LEFT != PAGE_NUM ? @"@B:9001@>>@/B@" # "  "
    CALLF TAG_PRINT_SHAPE(STR_FOOTER, WND_WIDTH - 8, 1, 2)
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@%RESULTS%@/C@")
ENDIF

@HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_CLOTH(MODULE_ID)
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 2
#DIM CONST WND_WIDTH  = 102
#DIM CONST WND_HEIGHT = 37
#DIM CONST ヘッダー行数 = 2
#DIM CONST BTN_ID = 2000
#DIM DYNAMIC L_CNT

#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC ITEM_NAME
#DIMS DYNAMIC MATERIAL_NAME
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC F_COL
#DIM DYNAMIC IS_CRAFTABLE = 1
#DIM DYNAMIC ERR_FLG
;生産関連変数
#DIM DYNAMIC  基準生産量   = 1
#DIM DYNAMIC  基準生産時間 = 30
#DIMS DYNAMIC 生産物名
#DIM DYNAMIC  生産時間
#DIM DYNAMIC  生産回数
#DIMS DYNAMIC 現在時刻
#DIMS DYNAMIC 完了予定時刻
;武器関連変数
#DIMS DYNAMIC WEAPON_NAME
#DIM DYNAMIC WEAPON_ID
#DIM DYNAMIC 材質種類
#DIM DYNAMIC WPN_MATERIAL_NEEDS, WPN_材質種類数, ITEM_LENGTH
;衣装関連
#DIM 部位

部位            = HO_ITEM_CRAFT_SELECT_CLOTH_PARTS
生産回数        = HO_ITEM_CRAFT_NUM_PRODUCTION

;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 66, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)
SIF HO_ITEM_CRAFT_SELECT_ITEM_ID == -1
    RETURN

ITEM_ID = HO_ITEM_CRAFT_SELECT_ITEM_ID
IF ITEM_ID >= 1000000
    ITEM_ID -= 1000000
    IS_CRAFTABLE = 0
ENDIF

WEAPON_ID = ITEM_ID % 1000
材質種類   = ITEM_ID / 1000

;アイテム名
CALL GET_CLOTH_NAME(部位, ITEM_ID)
ITEM_NAME = %RESULTS%
生産回数   = HO_ITEM_CRAFT_NUM_PRODUCTION

;ヘッダー
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　%ITEM_NAME%　◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;概要欄
; VARSET RESULTS
; FOR LOCAL, 0, 10
;     TRYCALLFORM GET_ITEM_DESCRIPTION_{ITEM_ID}
;     CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%RESULTS:LOCAL%")
; NEXT
L_CNT += 4

;備考欄
L_CNT++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　生産情報　◇@/S@@/C@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・要求素材@/C@")
L_CNT ++
;材料は暫定で固定
CALL GET_CLOTH_MATERIAL_NEEDS(部位, ITEM_ID, MATERIAL_NEEDS)
FOR LOCAL:0, 0, ITEM_LENGTH
    IF MATERIAL_NEEDS:(LOCAL:0) > 0
        CALL GET_ITEM_NAME(LOCAL:0)
        MATERIAL_NAME = %RESULTS%
        LOCALS = %TAG_PRINT_SHAPE(@"　　@C:{カラー_白}@%MATERIAL_NAME%@/C@", 24, 1, 0)%
        LOCALS += @"× {(MATERIAL_NEEDS:(LOCAL:0)* 生産回数)}"
        LOCALS += @"@C:{カラー_選択不可}@　(所持:{HO_ITEM_STOCK:(LOCAL:0)})@/C@"
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
        L_CNT ++
    ENDIF
NEXT

SIF !IS_CRAFTABLE
    RETURN

;生産対象の情報を取得
; CALL GET_ITEM_INFO(ITEM_ID, ITEM_基準生産量)
; 基準生産量 = RESULT
現在時刻 '= @"{HO_TIME / 60}:%TOSTR(HO_TIME % 60, "00")%"
生産時間 = 基準生産時間 * 生産回数
完了予定時刻 '= @"{(HO_TIME + 生産時間) / 60}:%TOSTR((HO_TIME + 生産時間) % 60, "00")%"

;;生産回数と時間
;生産回数設定ボタン
;生産量増減時のエラーチェック
FOR LOCAL:0, 0, ITEM_LENGTH
    IF (MATERIAL_NEEDS:(LOCAL:0) * (生産回数 + 1)) > HO_ITEM_STOCK:(LOCAL:0)
        ERR_FLG ++
    ENDIF
    IF HO_TIME + 基準生産時間 * (生産回数 + 1) > HO_CLOCK(2700)
        ERR_FLG ++
    ENDIF
NEXT

L_CNT ++
IF 生産回数 > 1
    LOCALS '= @"@B:{BTN_ID + 3}@[-]@/B@ "
ELSE
    LOCALS '= @"@C:{カラー_選択不可}@[-]@/C@ "
ENDIF
IF !ERR_FLG && 生産回数 < 10
    LOCALS += @"@B:{BTN_ID + 2}@[+]@/B@ "
ELSE
    LOCALS += @"@C:{カラー_選択不可}@[+]@/C@ "
ENDIF

L_CNT = 25
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・生産回数@/C@")
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"　　@C:{カラー_白}@生産回数:{生産回数}回　@/C@%LOCALS%")
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"　　　　@C:{カラー_白}@⇒　所要時間:{生産時間}分 (%現在時刻% → %完了予定時刻%)@/C@")
L_CNT ++
;生産対象の情報を印字
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・生産物@/C@")
L_CNT ++
LOCALS = %TAG_PRINT_SHAPE(@"　　　　@C:{カラー_注意}@⇒　%ITEM_NAME%@/C@", 36, 1, 0)%
LOCALS += @"× {基準生産量 * 生産回数}"
LOCALS += @"@C:{カラー_選択不可}@　(所持:{HAVE_CLOTH:部位:ITEM_ID})@/C@"
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注意}@%LOCALS%@/C@")

;フッター
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@B:{BTN_ID + 1}@@C:{カラー_白}@[クラフトする]@/C@@/B@")

HO_ITEM_CRAFT_BASE_PRODUCTION_RATE = 基準生産量
HO_ITEM_CRAFT_NUM_PRODUCTION       = 生産回数
HO_ITEM_CRAFT_PRODUCTION_TIME      = 生産時間

@HO_DRAW_CRAFT_ORDER_WINDOW()
#DIM CONST WND_WIDTH  = 140
#DIM CONST WND_HEIGHT = 40
#DIM CONST WND_POS_X = 10
#DIM CONST WND_POS_Y = 4
#DIM  DYNAMIC WINDOW_ID
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC F_COL

#DIM  DYNAMIC MODULE_LIST_IDX
#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIMS DYNAMIC TOOLTIP

#DIM  DYNAMIC RECIPE_NO
#DIM  DYNAMIC TARGET_NUM
#DIM  DYNAMIC IS_ACTIVE
#DIM  DYNAMIC IDX

#DIMS DYNAMIC MODULE_NAME
#DIM  DYNAMIC MODULE_ID

#DIM  DYNAMIC REGISTED_CRAFT_ORDER, MAX_CRAFT_ORDER

CALL WndMgr_VacantId()
WINDOW_ID = RESULT

CALL WndMgr_CreateWindow(WINDOW_ID, WND_POS_X, WND_POS_Y, WND_WIDTH, WND_HEIGHT, 2)

MODULE_LIST_IDX = HO_MASTER_USE_MODULE_LIST_IDX
ITEM_ID = TOINT(DIC_GET(HO_ITEM_CRAFT_DIC_CRAFT_ORDER, "CRAFT_ORDER"))
RECIPE_NO = TOINT(DIC_GET(HO_ITEM_CRAFT_DIC_CRAFT_ORDER, "RECIPE_NO"))
CALL HO_GET_MODULE_LIST(MODULE_LIST_IDX, "MODULE_ID")
MODULE_ID = RESULT
CALL HO_GET_MODULE_DATA(MODULE_ID, "MODULE_NAME")
MODULE_NAME = %RESULTS%
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME = %RESULTS%

;ヘッダー
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"◆以下の作業指示を登録します。登録先を選択してください")
L_CNT ++
LOCALS '= @"%MODULE_NAME%で%ITEM_NAME%を生産(レシピ{RECIPE_NO + 1})"
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT++, LOCALS)
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;明細行
DT_SELECT "CRAFT_ORDER",,, REGISTED_CRAFT_ORDER
FOR LOCAL, 0, RESULT
    ;情報取得
    MODULE_LIST_IDX = DT_CELL_GET("CRAFT_ORDER", REGISTED_CRAFT_ORDER:LOCAL, "MODULE_LIST_IDX", 1)
    ITEM_ID = DT_CELL_GET("CRAFT_ORDER", REGISTED_CRAFT_ORDER:LOCAL, "ITEM_ID", 1)
    RECIPE_NO = DT_CELL_GET("CRAFT_ORDER", REGISTED_CRAFT_ORDER:LOCAL, "RECIPE_NO", 1)
    TARGET_NUM = DT_CELL_GET("CRAFT_ORDER", REGISTED_CRAFT_ORDER:LOCAL, "TARGET_NUM", 1)
    IS_ACTIVE = DT_CELL_GET("CRAFT_ORDER", REGISTED_CRAFT_ORDER:LOCAL, "IS_ACTIVE", 1)
    CALL HO_GET_MODULE_LIST(MODULE_LIST_IDX, "MODULE_ID")
    MODULE_ID = RESULT
    CALL HO_GET_MODULE_DATA(MODULE_ID, "MODULE_NAME")
    MODULE_NAME = %RESULTS%
    CALL GET_ITEM_NAME(ITEM_ID)
    ITEM_NAME = %RESULTS%

    ;ツールチップ生成
    CALL GET_ITEM_MATERIAL_NEEDS(ITEM_ID, MATERIAL_NEEDS, RECIPE_NO)
    CALL HO_GET_MATERIAL_NEEDS_STR(MATERIAL_NEEDS)
    TOOLTIP '= "◆必要コスト<br>"
    TOOLTIP += RESULTS
    ;文字列出力
    LOCALS '= @"[%TOSTR(IDX + 1, "00")%] %MODULE_NAME%で%ITEM_NAME%を生産"
    LOCALS += @"@B:DUMMY$%TOOLTIP%@(レシピ{RECIPE_NO + 1})@/B@"
    LOCALS '= TAG_PRINT_SHAPE(LOCALS, 50, 1, 0)
    IF TARGET_NUM == 0
        LOCALS += @"　可能な限り"
    ELSE
        LOCALS += @"　在庫が{TARGET_NUM}個になるまで"
    ENDIF
    LOCALS += @"@C:{カラー_選択不可}@(現在:{HO_ITEM_STOCK:ITEM_ID}個)@/C@"
    LOCALS '= TAG_PRINT_SHAPE(LOCALS, 100, 1, 0)
    LOCALS += @"　@B:[REPLACE_ORDER:{REGISTED_CRAFT_ORDER:LOCAL}]@[上書]@/B@"
    LOCALS += @"　@B:[DELETE_ORDER:{REGISTED_CRAFT_ORDER:LOCAL}]@[削除]@/B@"
    LOCALS += @"　@B:[SET_TARGET_NUM:{REGISTED_CRAFT_ORDER:LOCAL}]@[生産量設定]@/B@"

    CALL WndMgr_TextAdd(WINDOW_ID, L_CNT++, LOCALS)
    L_CNT++
    IDX ++
NEXT
L_CNT++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"[%TOSTR(IDX + 1, "00")%]@C:{カラー_白}@@B:[ADD_ORDER:1]@ [追加]@/B@@/C@")

;フッター
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@B:[EXIT:1]@　[決定]@/B@")

@HO_ADD_CRAFT_ORDER()
#DIM DYNAMIC ITEM_ID
#DIM DYNAMIC RECIPE_NO
#DIM DYNAMIC MODULE_LIST_IDX

DT_SELECT "CRAFT_ORDER"
IF RESULT == MAX_CRAFT_ORDER
    CALL COLOR_PRINTW("登録可能な指示が上限に達しています", カラー_注意)
    RETURN 0
ENDIF

MODULE_LIST_IDX = HO_MASTER_USE_MODULE_LIST_IDX
ITEM_ID = TOINT(DIC_GET(HO_ITEM_CRAFT_DIC_CRAFT_ORDER, "CRAFT_ORDER"))
RECIPE_NO = TOINT(DIC_GET(HO_ITEM_CRAFT_DIC_CRAFT_ORDER, "RECIPE_NO"))
{
    DT_ROW_ADD "CRAFT_ORDER"
        ,"ITEM_ID", ITEM_ID
        ,"MODULE_LIST_IDX", MODULE_LIST_IDX
        ,"RECIPE_NO", RECIPE_NO
        ,"TARGET_NUM", 0
        ,"IS_ACTIVE", 1
}
RETURN RESULT

@HO_REPLACE_CRAFT_ORDER(DATAIDX)
#DIM DATAIDX
#DIM DYNAMIC ITEM_ID
#DIM DYNAMIC RECIPE_NO
#DIM DYNAMIC MODULE_LIST_IDX

CALL COLOR_PRINTL("Overwrites instructions that have already been registered. Confirm?", カラー_注意)
CALL ASK_YN()
IF RESULT
    RETURN 0
ENDIF

MODULE_LIST_IDX = HO_MASTER_USE_MODULE_LIST_IDX
ITEM_ID = TOINT(DIC_GET(HO_ITEM_CRAFT_DIC_CRAFT_ORDER, "CRAFT_ORDER"))
RECIPE_NO = TOINT(DIC_GET(HO_ITEM_CRAFT_DIC_CRAFT_ORDER, "RECIPE_NO"))
{
    DT_ROW_SET "CRAFT_ORDER", DATAIDX
        ,"ITEM_ID", ITEM_ID
        ,"MODULE_LIST_IDX", MODULE_LIST_IDX
        ,"RECIPE_NO", RECIPE_NO
        ,"TARGET_NUM", 0
        ,"IS_ACTIVE", 1
}
RETURN RESULT

@HO_DELETE_CRAFT_ORDER(DATAIDX)
#DIM DATAIDX
#DIM DYNAMIC ITEM_ID
#DIM DYNAMIC RECIPE_NO
#DIM DYNAMIC MODULE_LIST_IDX

CALL COLOR_PRINTL("Delete the instructions that have already been registered. Confirm?", カラー_注意)
CALL ASK_YN()
IF RESULT
    RETURN 0
ENDIF

DT_ROW_REMOVE "CRAFT_ORDER", DATAIDX
RETURN RESULT

@HO_CRAFT_ORDER_SET_TARGET_NUM(DATAIDX)
#DIM DATAIDX
#DIM DYNAMIC ITEM_ID
#DIM DYNAMIC RECIPE_NO
#DIM DYNAMIC MODULE_LIST_IDX

CALL COLOR_PRINTL("目標生産数を設定してください(0～999,0で可能な限り生産)", カラー_注意)

WHILE 1
    INPUT
    IF !INRANGE(RESULT, 0, 999)
        PRINTFORMW 入力値が不正です
        CLEARLINE 2
    ELSE
        DT_CELL_SET "CRAFT_ORDER", DATAIDX, "TARGET_NUM", RESULT, 1
        RETURN RESULT
    ENDIF
WEND

@HO_REMOVE_CRAFT_ORDER(MODULE_LIST_IDX)
#DIM MODULE_LIST_IDX
#DIM DYNAMIC DID, MAX_CRAFT_ORDER
#DIM DYNAMIC CHARA_ID
#DIM DYNAMIC ITER_I
#DIM DYNAMIC ITER_J

;削除された設備に対応する作業指示を削除
DT_SELECT "CRAFT_ORDER", @"MODULE_LIST_IDX = {MODULE_LIST_IDX}",, DID
FOR ITER_I, 0, RESULT
    ;キャラクター側の作業指示を削除
    FOR CHARA_ID, 0, CHARANUM
        DT_ROW_REMOVE "CRAFT_ORDER", DID:ITER_I
        FOR ITER_J, 0, HO_TIMETABLENUM
            _LIST_HO_CRAFT_ORDER_DID:CHARA_ID:ITER_J = %LIST_REMOVEALL(_LIST_HO_CRAFT_ORDER_DID:CHARA_ID:ITER_J, TOSTR(DID:ITER_I))%
        NEXT
    NEXT
NEXT

RETURN


code:
@HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_WEAPON_ENCHANT(MODULE_ID)
; #region
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 2
#DIM CONST WND_WIDTH  = 102
#DIM CONST WND_HEIGHT = 37
#DIM CONST ヘッダー行数 = 2
#DIM CONST BTN_ID = 2000
#DIM DYNAMIC L_CNT

#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC ITEM_NAME
#DIMS DYNAMIC MATERIAL_NAME
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC F_COL
#DIM DYNAMIC IS_CRAFTABLE = 1
#DIM DYNAMIC ERR_FLG

;武器関連変数
#DIMS DYNAMIC WEAPON_PRINT_NAME
#DIMS DYNAMIC WEAPON_NAME
#DIM  DYNAMIC WEAPON_DID
#DIM  DYNAMIC WEAPON_ID
#DIM  DYNAMIC RUNE_DID
#DIMS DYNAMIC DIC_REMOVE_ENCHANT
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC MODIFIED_STATUS, WPN_MAX_STATUSNUM
#DIM  DYNAMIC STATUS_IDX
#DIM  DYNAMIC EQUIP_CHARA_ID
;スキル関連
#DIM DYNAMIC  PASSIVE_SKILL_SLOT
#DIM DYNAMIC  ACTIVE_SKILL_SLOT
#DIM  DYNAMIC PASSIVE_SKILL_SLOT_USED
#DIM  DYNAMIC ACTIVE_SKILL_SLOT_USED
#DIMS DYNAMIC SKILL_DEF_NAME
#DIMS DYNAMIC SKILL_NAME
#DIM  DYNAMIC SKILL_LV
#DIM  DYNAMIC WPN_SKILL_GENRE
#DIMS DYNAMIC TOOLTIP
#DIM  DYNAMIC AMOUNT
#DIM  DYNAMIC COST

#DIM  DYNAMIC PARAM_DIFF
#DIMS CONST  WPN_STATUS_NAME_SHORT = "攻撃", "防御", "軽減", "魔力", "行動", "敵視", "選敵"
#DIM  DYNAMIC COLUMN_LENGTH = 14, 14, 14, 14, 14, 14, 16
;ステータスの表示順序
{
    #DIMS CONST COLUMN_ORDER =
        "ATTACK"
        , "DEFENCE"
        , "ARMOR"
        , "MAG"
        , "AGILITY"
        , "HATE_RATE"
        , "TARGETING"
}

;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 66, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)
SIF HO_ITEM_CRAFT_SELECT_ITEM_ID == -1
    RETURN

WEAPON_DID = HO_ITEM_CRAFT_SELECT_ITEM_ID
RUNE_DID = HO_ITEM_CRAFT_SELECT_RUNE_ID
DIC_REMOVE_ENCHANT = %HO_ITEM_CRAFT_DIC_REMOVE_ENCHANT%

;武器名
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_NAME")
WEAPON_NAME = %RESULTS%
CALL GET_WEAPON_PRINT_NAME(WEAPON_DID)
WEAPON_PRINT_NAME = %RESULTS%
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "EQUIP_CHARA_ID")
EQUIP_CHARA_ID = RESULT
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_RANK")
WEAPON_RANK = RESULT
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "PASSIVE_SKILL_SLOT")
PASSIVE_SKILL_SLOT = RESULT
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "ACTIVE_SKILL_SLOT")
ACTIVE_SKILL_SLOT = RESULT
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "PASSIVE_SKILL_SLOT_USED")
PASSIVE_SKILL_SLOT_USED = RESULT
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "ACTIVE_SKILL_SLOT_USED")
ACTIVE_SKILL_SLOT_USED = RESULT

;改造前の武器ステータス取得
VARSET WPN_STATUS
FOR STATUS_IDX, 0, VARSIZE("WPN_STATUS_NAME_ENG")
    DT_CELL_GET "WEAPON_STOCK", WEAPON_DID, WPN_STATUS_NAME_ENG:STATUS_IDX, 1
    WPN_STATUS:STATUS_IDX = RESULT
NEXT
;改良後ステータス取得
CALL GET_WEAPON_MODIFIED_STATUS(WPN_STATUS, MODIFIED_STATUS)
CALL GET_WEAPON_MODIFY_COST(MATERIAL_NEEDS, WEAPON_RANK)
SIF !RESULT
    IS_CRAFTABLE = 0

;スキルルーンの情報取得
IF RUNE_DID != -1
    CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "SKILL_DEF_NAME")
    SKILL_DEF_NAME = %RESULTS%
    CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "SKILL_LV")
    SKILL_LV = RESULT
    CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "AMOUNT")
    AMOUNT = RESULT
    CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "WPN_SKILL_GENRE")
    WPN_SKILL_GENRE = RESULT
    CALL SKILL_GET_NAME(WPN_SKILL_GENRE, SKILL_DEF_NAME, 1)
    SKILL_NAME = %RESULTS%
    CALL GET_SKILL_DESC(SKILL_DEF_NAME, WPN_SKILL_GENRE, SKILL_LV, 1)
    TOOLTIP = %RESULTS%
ENDIF

;印字部
;ヘッダー
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　%WEAPON_PRINT_NAME%　◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;ステータス欄
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・現在のステータス@/C@")
LOCALS '= ""
FOR LOCAL, 0, WPN_MAX_STATUSNUM
    STATUS_IDX = FINDELEMENT(WPN_STATUS_NAME_ENG, COLUMN_ORDER:LOCAL)
    IF STATUS_IDX != WPN_脅威選定
        LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:{WPN_STATUS:STATUS_IDX}@/C@", COLUMN_LENGTH:LOCAL, 1)
    ELSE
        LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:%WPN_脅威選定文字列:(WPN_STATUS:STATUS_IDX)%@/C@", COLUMN_LENGTH:LOCAL, 1)
    ENDIF
NEXT

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%LOCALS%")
IF EQUIP_CHARA_ID >= 0
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　装備者:%ANAME(EQUIP_CHARA_ID)%")
ELSE
    L_CNT ++
ENDIF

;付与されているスキル
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・現在の装備スキル@/C@")
;アクティブスキル
CALL GET_EQUIP_SKILL_LIST_STR(WEAPON_DID, 武器スキル_アクティブ)
IF RESULTS != ""
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_オレンジ}@　ACTIVE :@/C@%RESULTS%")
ENDIF
;パッシブスキル
CALL GET_EQUIP_SKILL_LIST_STR(WEAPON_DID, 武器スキル_パッシブ)
IF RESULTS != ""
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_黄緑}@　PASSIVE:@/C@%RESULTS%")
ENDIF

;スキルスロット
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・空スキルスロット数@/C@")
LOCALS '= @"@C:{カラー_オレンジ}@　ACTIVE :@/C@%"■"* ACTIVE_SKILL_SLOT_USED%%"□"* (ACTIVE_SKILL_SLOT - ACTIVE_SKILL_SLOT_USED)%"
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
LOCALS '=  @"@C:{カラー_黄緑}@　PASSIVE:@/C@%"■"* PASSIVE_SKILL_SLOT_USED%%"□"* (PASSIVE_SKILL_SLOT - PASSIVE_SKILL_SLOT_USED)%"
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)

;付呪情報欄
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　付呪情報　◇@/S@@/C@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%WEAPON_NAME%@")
L_CNT ++

;アクティブスキル
CALL ENCHANT_GET_EQUIP_SKILL_LIST_STR(WEAPON_DID, 武器スキル_アクティブ)
IF RESULTS != ""
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@C:{カラー_オレンジ}@　ACTIVE :@/C@%RESULTS%")
    IF ACTIVE_SKILL_SLOT > 0
        IF RUNE_DID != -1 && HO_ITEM_CRAFT_SELECT_RUNE_GENRE == 武器スキル_アクティブ
            CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"@B:[SELECT_RUNE:{武器スキル_アクティブ}]$%TOOLTIP%@@C:{カラー_注意}@⇒<%SKILL_NAME%Lv{SKILL_LV}>@/B@@/C@")
        ELSEIF RUNE_DID == -1
            IF ACTIVE_SKILL_SLOT - ACTIVE_SKILL_SLOT_USED > 0
                CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @" @B:[SELECT_RUNE:{武器スキル_アクティブ}]@[+]@/B@")
            ENDIF
        ENDIF
    ENDIF
    L_CNT ++
ENDIF
;パッシブスキル
CALL ENCHANT_GET_EQUIP_SKILL_LIST_STR(WEAPON_DID, 武器スキル_パッシブ)
IF RESULTS != ""
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@C:{カラー_黄緑}@　PASSIVE:@/C@%RESULTS%")
    IF PASSIVE_SKILL_SLOT > 0
        IF RUNE_DID != -1 && HO_ITEM_CRAFT_SELECT_RUNE_GENRE == 武器スキル_パッシブ
            CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"@B:[SELECT_RUNE:{武器スキル_パッシブ}]$%TOOLTIP%@@C:{カラー_注意}@⇒<%SKILL_NAME%Lv{SKILL_LV}>@/B@@/C@")
        ELSEIF RUNE_DID == -1
            IF PASSIVE_SKILL_SLOT - PASSIVE_SKILL_SLOT_USED > 0
                CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @" @B:[SELECT_RUNE:{武器スキル_パッシブ}]@[+]@/B@")
            ENDIF
        ENDIF
    ENDIF
    L_CNT ++
ENDIF

VARI REMOVE_ENCHANT_MODE
IF RUNE_DID != -1
    ;付呪
    CALL EQUIP_GET_COST_FOR_ENCHANT(WEAPON_DID, SKILL_DEF_NAME, WPN_SKILL_GENRE, SKILL_LV)
    COST = RESULT
    L_CNT ++
    L_CNT ++
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・消費ルーン@/C@")
    LOCALS = %TAG_PRINT_SHAPE(@"　　@C:{カラー_注意}@<%SKILL_NAME%Lv{SKILL_LV}>@", 24, 1, 0)%
    IF COST > AMOUNT
        LOCALS += @"× @C:{カラー_オレンジ}@{COST}@/C@"
    ELSE
        LOCALS += @"× @C:{カラー_白}@{COST}@/C@"
    ENDIF
    LOCALS += @"@C:{カラー_選択不可}@　(所持:{AMOUNT})@/C@"
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
ELSEIF DIC_CONTAINSKEY(DIC_REMOVE_ENCHANT, "REMOVE_ENCHANT")
    ;解呪対象の情報取得
    VARS STR_GENRE
    VARS SKILL_SLOT_USED_SKILL
    SKILL_DEF_NAME = %DIC_GET(DIC_REMOVE_ENCHANT, "REMOVE_ENCHANT")%
    WPN_SKILL_GENRE = WPN_SKILL_GET_GENRE(SKILL_DEF_NAME)
    STR_GENRE '= WPN_SKILL_GENRE == 武器スキル_アクティブ ? "ACTIVE" # "PASSIVE"
    SKILL_SLOT_USED_SKILL = %DT_CELL_GETS("WEAPON_STOCK", WEAPON_DID, @"%STR_GENRE%_SKILL_SLOT_USED_SKILL_NAME", 1)%
    SKILL_LV = DIC_GETINT(SKILL_SLOT_USED_SKILL, SKILL_DEF_NAME)
    SKILL_NAME = %TOHALF(GET_WPN_SKILL_NAME(SKILL_DEF_NAME, WPN_SKILL_GENRE))%
    AMOUNT = RUNE_STOCK_GET_AMOUNT(SKILL_DEF_NAME, SKILL_LV)
    COST = 1
    REMOVE_ENCHANT_MODE = 1
    ;メッセージ表示部
    L_CNT ++
    L_CNT ++
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・解呪対象スキル・返却ルーン@/C@")
    LOCALS = %TAG_PRINT_SHAPE(@"　　@C:{カラー_注意}@<%SKILL_NAME%Lv{SKILL_LV}>@", 24, 1, 0)%
    LOCALS += @"× @C:{カラー_緑}@{COST}@/C@"
    LOCALS += @"@C:{カラー_選択不可}@　(所持:{AMOUNT})@/C@"
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
ENDIF

;フッター
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
IF RUNE_DID != -1 && COST <= AMOUNT
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@B:[EXEC_ENCHANT_WEAPON:{WEAPON_DID}]@@C:{カラー_白}@[付呪する]@/C@@/B@")
ELSEIF REMOVE_ENCHANT_MODE == 1
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@B:[EXEC_REMOVE_ENCHANT:{WEAPON_DID}]@@C:{カラー_白}@[解呪する]@/C@@/B@")
ELSE
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@C:{カラー_選択不可}@[付呪する]@/C@")
ENDIF
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"　@B:[RENAME:1]@@C:{カラー_白}@[リネーム]@/C@@/B@")
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"　@B:[EXIT:1]@@C:{カラー_白}@[キャンセル]@/C@@/B@")
; #endregion

@HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_WEAPON_SELECT_RUNE(MODULE_ID)
; #region

#DIM MODULE_ID
#DIM CONST WINDOW_ID = 2
#DIM CONST WND_WIDTH  = 102
#DIM CONST WND_HEIGHT = 37
#DIM CONST ヘッダー行数 = 2
#DIM CONST BTN_ID = 2000
#DIM DYNAMIC L_CNT

#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC ITEM_NAME
#DIMS DYNAMIC MATERIAL_NAME
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC F_COL
#DIM DYNAMIC IS_CRAFTABLE = 1
#DIM DYNAMIC ERR_FLG

;武器関連変数
#DIMS DYNAMIC WEAPON_PRINT_NAME
#DIMS DYNAMIC WEAPON_NAME
#DIM  DYNAMIC WEAPON_DID
#DIM  DYNAMIC WEAPON_ID
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC MODIFIED_STATUS, WPN_MAX_STATUSNUM
#DIM  DYNAMIC STATUS_IDX
#DIM  DYNAMIC EQUIP_CHARA_ID
#DIM DYNAMIC PASSIVE_SKILL_SLOT
#DIM DYNAMIC ACTIVE_SKILL_SLOT
#DIM  DYNAMIC PARAM_DIFF

;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 66, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)
SIF HO_ITEM_CRAFT_SELECT_ITEM_ID == -1
    RETURN
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@付呪するルーンを選択してください@/C@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL HO_DRAW_ITEM_MENU_WINDOW_PRINT_DETAIL_RUNE(WINDOW_ID, "WEAPON_ENCHANT")
;フッター
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"　@B:[SELECT_RUNE_EXIT:1]@@C:{カラー_白}@[BACK]@/C@@/B@")
; #endregion

;-------------------------------------------------
;;; 対象ルーンが選択可能か判定
;-------------------------------------------------
@HO_ITEM_CRAFT_CHECK_CAN_SELECT_RUNE()
#DIM  DYNAMIC WEAPON_DID
#DIM  DYNAMIC RUNE_DID
#DIMS DYNAMIC SKILL_DEF_NAME
#DIM  DYNAMIC WPN_SKILL_GENRE

WEAPON_DID = HO_ITEM_CRAFT_SELECT_ITEM_ID
RUNE_DID = HO_ITEM_CRAFT_SELECT_RUNE_ID

;スキルルーンの情報取得
CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "SKILL_DEF_NAME")
SKILL_DEF_NAME = %RESULTS%
CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "WPN_SKILL_GENRE")
WPN_SKILL_GENRE = RESULT

CALL EQUIP_CAN_ADD_SKILL(WEAPON_DID, SKILL_DEF_NAME, WPN_SKILL_GENRE)
RETURN RESULT

;-------------------------------------------------
;;; 付呪処理実行
;-------------------------------------------------
@HO_ITEM_CRAFT_EXEC_ENCHANT_WEAPON(WEAPON_DID)
; #region
#DIM WEAPON_DID
;素材関連
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
;武器関連変数
#DIMS DYNAMIC WEAPON_NAME
#DIM  DYNAMIC WEAPON_ID
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC MODIFIED_STATUS, WPN_MAX_STATUSNUM
#DIM  DYNAMIC STATUS_IDX
;スキル関連
#DIM  DYNAMIC RUNE_DID
#DIM DYNAMIC  PASSIVE_SKILL_SLOT
#DIM DYNAMIC  ACTIVE_SKILL_SLOT
#DIMS DYNAMIC SKILL_DEF_NAME
#DIMS DYNAMIC SKILL_NAME
#DIM  DYNAMIC SKILL_LV
#DIM  DYNAMIC WPN_SKILL_GENRE
#DIMS DYNAMIC TOOLTIP
#DIM  DYNAMIC AMOUNT
#DIM  DYNAMIC COST

;改造前の武器ステータス取得
VARSET WPN_STATUS
FOR STATUS_IDX, 0, VARSIZE("WPN_STATUS_NAME_ENG")
    DT_CELL_GET "WEAPON_STOCK", WEAPON_DID, WPN_STATUS_NAME_ENG:STATUS_IDX, 1
    WPN_STATUS:STATUS_IDX = RESULT
NEXT

;武器名
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_NAME")
WEAPON_NAME = %RESULTS%
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_RANK")
WEAPON_RANK = RESULT

;付呪対象ルーンの取得
RUNE_DID = HO_ITEM_CRAFT_SELECT_RUNE_ID

;スキルルーンの情報取得
CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "SKILL_DEF_NAME")
SKILL_DEF_NAME = %RESULTS%
CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "SKILL_LV")
SKILL_LV = RESULT
CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "AMOUNT")
AMOUNT = RESULT
CALL RUNE_STOCK_GET_TABLE_DATA(RUNE_DID, "WPN_SKILL_GENRE")
WPN_SKILL_GENRE = RESULT
CALL SKILL_GET_NAME(WPN_SKILL_GENRE, SKILL_DEF_NAME, 1)
SKILL_NAME = %RESULTS%
CALL GET_SKILL_DESC(SKILL_DEF_NAME, WPN_SKILL_GENRE, SKILL_LV, 1)
TOOLTIP = %RESULTS%

;強化コスト取得
CALL EQUIP_GET_COST_FOR_ENCHANT(WEAPON_DID, SKILL_DEF_NAME, SKILL_LV)
COST = RESULT

;付呪実行
CALL EQUIP_ADD_SKILL(WEAPON_DID, SKILL_DEF_NAME, WPN_SKILL_GENRE, SKILL_LV)

;コスト消費
CALL RUNE_STOCK_UPDATE(SKILL_DEF_NAME, WPN_SKILL_GENRE, SKILL_LV, COST * -1)

CALL FL_PLAYSE("CRAFT_3.mp3")
PRINTFORMW %WEAPON_NAME%にスキル:<%SKILL_NAME%Lv{SKILL_LV}>を付呪した！

HO_ITEM_CRAFT_SELECT_RUNE_ID = -1
; #endregion

;-------------------------------------------------
;;; 解呪処理実行
;-------------------------------------------------
@HO_ITEM_CRAFT_EXEC_REMOVE_ENCHANT(WEAPON_DID)
; #region
#DIM WEAPON_DID
;素材関連
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
;武器関連変数
#DIMS DYNAMIC WEAPON_NAME
#DIM  DYNAMIC WEAPON_ID
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC MODIFIED_STATUS, WPN_MAX_STATUSNUM
#DIM  DYNAMIC STATUS_IDX
;スキル関連
#DIM  DYNAMIC RUNE_DID
#DIM DYNAMIC  PASSIVE_SKILL_SLOT
#DIM DYNAMIC  ACTIVE_SKILL_SLOT
#DIMS DYNAMIC SKILL_DEF_NAME
#DIMS DYNAMIC SKILL_NAME
#DIM  DYNAMIC SKILL_LV
#DIM  DYNAMIC WPN_SKILL_GENRE
#DIMS DYNAMIC TOOLTIP
#DIM  DYNAMIC AMOUNT
#DIM  DYNAMIC COST
#DIMS DYNAMIC DIC_REMOVE_ENCHANT
#DIMS DYNAMIC STR_GENRE
#DIMS DYNAMIC SKILL_SLOT_USED_SKILL

;解呪対象スキル情報
DIC_REMOVE_ENCHANT = %HO_ITEM_CRAFT_DIC_REMOVE_ENCHANT%

;武器名
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_NAME")
WEAPON_NAME = %RESULTS%
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_RANK")
WEAPON_RANK = RESULT

;スキル情報取得
SKILL_DEF_NAME = %DIC_GET(DIC_REMOVE_ENCHANT, "REMOVE_ENCHANT")%
WPN_SKILL_GENRE = WPN_SKILL_GET_GENRE(SKILL_DEF_NAME)
STR_GENRE '= WPN_SKILL_GENRE == 武器スキル_アクティブ ? "ACTIVE" # "PASSIVE"
SKILL_SLOT_USED_SKILL = %DT_CELL_GETS("WEAPON_STOCK", WEAPON_DID, @"%STR_GENRE%_SKILL_SLOT_USED_SKILL_NAME", 1)%
SKILL_LV = DIC_GETINT(SKILL_SLOT_USED_SKILL, SKILL_DEF_NAME)
SKILL_NAME = %TOHALF(GET_WPN_SKILL_NAME(SKILL_DEF_NAME, WPN_SKILL_GENRE))%
CALL GET_SKILL_DESC(SKILL_DEF_NAME, WPN_SKILL_GENRE, SKILL_LV, 1)
TOOLTIP = %RESULTS%

;強化コスト取得
CALL EQUIP_GET_COST_FOR_ENCHANT(WEAPON_DID, SKILL_DEF_NAME, SKILL_LV)
COST = RESULT

;解呪実行
CALL EQUIP_REMOVE_SKILL(WEAPON_DID, SKILL_DEF_NAME, WPN_SKILL_GENRE)

;コスト返却
CALL RUNE_STOCK_UPDATE(SKILL_DEF_NAME, WPN_SKILL_GENRE, SKILL_LV, COST)

CALL FL_PLAYSE("CRAFT_3.mp3")
PRINTFORMW %WEAPON_NAME%からスキル:<%SKILL_NAME%Lv{SKILL_LV}>を解呪した！

HO_ITEM_CRAFT_DIC_REMOVE_ENCHANT '= ""
; #endregion

@ENCHANT_GET_EQUIP_SKILL_LIST_STR(EQUIP_DID, GENRE)
#DIM  EQUIP_DID
#DIM  GENRE
#DIM  DYNAMIC EQUIP_IDX, WPN_MAX_WEAPON_STOCK
#DIM  DYNAMIC WEAPON_ID
#DIMS DYNAMIC DIC_WPN_SKILL
#DIMS DYNAMIC SKILL_DEF_NAME
#DIMS DYNAMIC WPN_SKILL_DEF_LIST, VARSIZE("SKILL_DEF_LIST")
#DIMS DYNAMIC SKILL_NAME
#DIM  DYNAMIC SKILL_LV
#DIMS DYNAMIC TOOLTIP
#DIM  DYNAMIC F_COL
#DIM  DYNAMIC IDX
#DIM  DYNAMIC ITER_I

SKILL_NAME '= ""
VARS STR_GENRE
VARI SKILL_SLOT
VARI SKILL_SLOT_USED
VARS SKILL_SLOT_USED_SKILL_NAME

IF GENRE == 武器スキル_アクティブ
    STR_GENRE '= "ACTIVE"
ELSE
    STR_GENRE '= "PASSIVE"
ENDIF

;DIC_WPN_SKILL = %DT_CELL_GETS("WEAPON_STOCK", EQUIP_DID, @"%STR_GENRE%_WEAPON_SKILL", 1)%
SKILL_SLOT = DT_CELL_GET("WEAPON_STOCK", EQUIP_DID, @"%STR_GENRE%_SKILL_SLOT", 1)
SKILL_SLOT_USED = DT_CELL_GET("WEAPON_STOCK", EQUIP_DID, @"%STR_GENRE%_SKILL_SLOT_USED", 1)
SKILL_SLOT_USED_SKILL_NAME = %DT_CELL_GETS("WEAPON_STOCK", EQUIP_DID, @"%STR_GENRE%_SKILL_SLOT_USED_SKILL_NAME", 1)%

CALL DIC_KEYS(SKILL_SLOT_USED_SKILL_NAME)
ARRAYCOPY "RESULTS", "WPN_SKILL_DEF_LIST"
FOR ITER_I, 0, RESULT
    SKILL_DEF_NAME = %WPN_SKILL_DEF_LIST:ITER_I%
    SKILL_LV = TOINT(DIC_GET(SKILL_SLOT_USED_SKILL_NAME, SKILL_DEF_NAME))
    CALL GET_SKILL_DESC(SKILL_DEF_NAME, GENRE, SKILL_LV, 1)
    TOOLTIP = %RESULTS%
    ;ルーンによって付呪されたスキルである場合
    IF DIC_CONTAINSKEY(SKILL_SLOT_USED_SKILL_NAME, SKILL_DEF_NAME)
        TOOLTIP += "

※このスキルはルーンによって付呪された
"
        SKILL_NAME += @"@B:DUMMY$%TOOLTIP%@<R:%TOHALF(GET_WPN_SKILL_NAME(SKILL_DEF_NAME, GENRE))%Lv{SKILL_LV}>@/B@@B:[REMOVE_ENCHANT:%SKILL_DEF_NAME%][GENRE:{GENRE}]@[-] @/B@"
    ELSE
        SKILL_NAME += @"@B:DUMMY$%TOOLTIP%@<%TOHALF(GET_WPN_SKILL_NAME(SKILL_DEF_NAME, GENRE))%Lv{SKILL_LV}>@/B@@B:[REMOVE_ENCHANT:%SKILL_DEF_NAME%][GENRE:{GENRE}]@[-] @/B@"
    ENDIF
NEXT
IF SKILL_SLOT - SKILL_SLOT_USED > 0
    TOOLTIP '= "ルーン付呪枠"
    SKILL_NAME += @"@B:DUMMY$%TOOLTIP%@<---> @/B@" * (SKILL_SLOT - SKILL_SLOT_USED)
ENDIF
IF GENRE == 武器スキル_アクティブ
    F_COL = カラー_オレンジ
ELSE
    F_COL = カラー_黄緑
ENDIF
RESULTS '= @"@C:{F_COL}@%SKILL_NAME%@/C@"

RETURN

repo_name: pervysquirrelz/erafl

license: unknown


code:
@HO_CRAFT_WINDOW_INPUT(MODULE_ID)
#DIM MODULE_ID
#DIM  DYNAMIC INPUT_VALUE
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM  DYNAMIC WEAPON_ID
#DIM  DYNAMIC WPN_MATERIAL_NEEDS, WPN_材質種類数, ITEM_LENGTH
#DIMS DYNAMIC SORT_COLUMN

;入力受付
REDRAW 1
ONEINPUTS
REDRAW 0
CLEARLINE 1
PRINTL

IF ISNUMERIC(RESULTS)
    RESULT = TOINT(RESULTS)
    ;キャンセルボタン
    IF RESULT == 9999999
        RETURN -1
    ELSEIF INRANGE(RESULT, 0, 4)
        HO_ITEM_CRAFT_SELECT_ITEM_ID = -1
        HO_CRAFT_CATEGORY = RESULT
        HO_ITEM_MENU_PAGE_LEFT = 0
        HO_ITEM_CRAFT_PAGE_LEFT = 0
        ;アイテム作成
    ELSEIF HO_CRAFT_CATEGORY == 0 && INRANGE(RESULT, 2000, 2999)
        SELECTCASE RESULT - 2000
            CASE 1
                CALL GET_ITEM_MATERIAL_NEEDS(HO_ITEM_CRAFT_SELECT_ITEM_ID, MATERIAL_NEEDS, HO_CRAFT_RECIPE_ID)
                CALL USE_MATERIAL(MATERIAL_NEEDS, HO_ITEM_CRAFT_NUM_PRODUCTION)
                CALL CHANGE_ITEM_STOCK(HO_ITEM_CRAFT_SELECT_ITEM_ID, HO_ITEM_CRAFT_BASE_PRODUCTION_RATE * HO_ITEM_CRAFT_NUM_PRODUCTION)
                ;地の文・口上表示用
                TFLAG:クラフト_アイテムID = HO_ITEM_CRAFT_SELECT_ITEM_ID
                TFLAG:クラフト_作成量 = HO_ITEM_CRAFT_BASE_PRODUCTION_RATE * HO_ITEM_CRAFT_NUM_PRODUCTION
                RETURN 1
            CASE 2
                HO_ITEM_CRAFT_NUM_PRODUCTION ++
            CASE 3
                HO_ITEM_CRAFT_NUM_PRODUCTION --
                ;使用レシピ切替
            CASE 10 TO 14
                HO_CRAFT_RECIPE_ID = RESULT - 2010
        ENDSELECT
        ;衣装作成
    ELSEIF HO_CRAFT_CATEGORY == 2 && INRANGE(RESULT, 2000, 2999)
        SELECTCASE RESULT - 2000
            CASE 1
                CALL GET_CLOTH_MATERIAL_NEEDS(HO_ITEM_CRAFT_SELECT_CLOTH_PARTS, HO_ITEM_CRAFT_SELECT_ITEM_ID, MATERIAL_NEEDS)
                CALL USE_MATERIAL(MATERIAL_NEEDS, HO_ITEM_CRAFT_NUM_PRODUCTION)
                CALL CHANGE_CLOTH_STOCK(HO_ITEM_CRAFT_SELECT_CLOTH_PARTS, HO_ITEM_CRAFT_SELECT_ITEM_ID, HO_ITEM_CRAFT_NUM_PRODUCTION)
                ;地の文・口上表示用
                TFLAG:クラフト_アイテムID   = HO_ITEM_CRAFT_SELECT_ITEM_ID
                TFLAG:クラフト_衣装部位     = HO_ITEM_CRAFT_SELECT_CLOTH_PARTS
                TFLAG:クラフト_作成量       = HO_ITEM_CRAFT_NUM_PRODUCTION
                RETURN 1
            CASE 2
                HO_ITEM_CRAFT_NUM_PRODUCTION ++
            CASE 3
                HO_ITEM_CRAFT_NUM_PRODUCTION --
        ENDSELECT
        ;武器作成
    ELSEIF  HO_CRAFT_CATEGORY == 1 && INRANGE(RESULT, 2000, 2999)
        WEAPON_ID = HO_ITEM_CRAFT_SELECT_ITEM_ID % 1000
        CALL GET_WEAPON_MATERIAL_NEEDS(WEAPON_ID, HO_ITEM_CRAFT_WEAPON_MATERIAL, WPN_MATERIAL_NEEDS)
        FOR LOCAL, 0, ITEM_LENGTH
            MATERIAL_NEEDS:LOCAL = WPN_MATERIAL_NEEDS:HO_ITEM_CRAFT_WEAPON_MATERIAL:LOCAL
        NEXT
        ;生産に必要なアイテムを消費
        CALL USE_MATERIAL(MATERIAL_NEEDS)
        ;スキルスロット数を取得
        TRYCCALLFORM GET_WEAPON_SKILL_SLOT_{WEAPON_ID}(HO_ITEM_CRAFT_WEAPON_MATERIAL)
            CALL ADD_WEAPON_STOCK_LIST(WEAPON_ID, HO_ITEM_CRAFT_WEAPON_NAME, HO_ITEM_CRAFT_WEAPON_MATERIAL, 0,,,, RESULT:0, RESULT:1)
        CATCH
            CALL ADD_WEAPON_STOCK_LIST(WEAPON_ID, HO_ITEM_CRAFT_WEAPON_NAME, HO_ITEM_CRAFT_WEAPON_MATERIAL, 0)
        ENDCATCH
        ;クラフトコマンド実行時　地の文表示用
        TFLAG:クラフト_作成量  = HO_ITEM_CRAFT_NUM_PRODUCTION
        TFLAG:クラフト_武器IDX = RESULT
        RETURN 1
        ;衣装部位タブ切り替え
    ELSEIF  HO_CRAFT_CATEGORY == 2 && INRANGE(RESULT, 1000, 1999)
        HO_ITEM_CRAFT_SELECT_CLOTH_PARTS = RESULT - 1000
        HO_ITEM_CRAFT_PAGE_LEFT = 0
        RETURN
        ;ページ処理
    ELSEIF INRANGE(RESULT, 9000, 9001)
        IF RESULT == 9000
            IF HO_CRAFT_CATEGORY == 3
                HO_ITEM_MENU_PAGE_LEFT --
            ELSE
                HO_ITEM_CRAFT_PAGE_LEFT --
            ENDIF
        ELSE
            IF HO_CRAFT_CATEGORY == 3
                HO_ITEM_MENU_PAGE_LEFT ++
            ELSE
                HO_ITEM_CRAFT_PAGE_LEFT ++
            ENDIF
        ENDIF
        ;アイテム選択
    ELSEIF INRANGE(RESULT, 1000000, 2999999)
        ;クラフト可能なアイテム ITEM_ID + 1000000, クラフト不可能なアイテム ITEM_ID + 2000000
        HO_ITEM_CRAFT_NUM_PRODUCTION = 1
        HO_CRAFT_RECIPE_ID = 0
        HO_ITEM_CRAFT_SELECT_ITEM_ID = (RESULT - 1000000)
        RETURN
    ENDIF
ELSE
    ;アイテム作成
    IF HO_CRAFT_CATEGORY == 0
        IF !HO_CRAFT_IS_ACTIVE_SUBWND
            IF DIC_CONTAINSKEY(RESULTS, "CRAFT_ORDER")
                HO_CRAFT_IS_ACTIVE_SUBWND = 1
                HO_ITEM_CRAFT_DIC_CRAFT_ORDER = %RESULTS%
            ENDIF
        ELSE
            IF DIC_CONTAINSKEY(RESULTS, "EXIT")
                HO_CRAFT_IS_ACTIVE_SUBWND = 0
            ELSEIF DIC_CONTAINSKEY(RESULTS, "ADD_ORDER")
                CALL HO_ADD_CRAFT_ORDER()
            ELSEIF DIC_CONTAINSKEY(RESULTS, "REPLACE_ORDER")
                CALL HO_REPLACE_CRAFT_ORDER(TOINT(DIC_GET(RESULTS, "REPLACE_ORDER")))
            ELSEIF DIC_CONTAINSKEY(RESULTS, "DELETE_ORDER")
                CALL HO_DELETE_CRAFT_ORDER(TOINT(DIC_GET(RESULTS, "DELETE_ORDER")))
            ELSEIF DIC_CONTAINSKEY(RESULTS, "SET_TARGET_NUM")
                CALL HO_CRAFT_ORDER_SET_TARGET_NUM(TOINT(DIC_GET(RESULTS, "SET_TARGET_NUM")))
            ENDIF
        ENDIF
        ;武器の強化、付呪
    ELSEIF HO_CRAFT_CATEGORY == 3 || HO_CRAFT_CATEGORY == 4
        IF !HO_CRAFT_IS_ACTIVE_SUBWND
            IF DIC_CONTAINSKEY(RESULTS, "WEAPON_DID")
                HO_ITEM_CRAFT_SELECT_ITEM_ID = TOINT(DIC_GET(RESULTS, "WEAPON_DID"))
                HO_CRAFT_IS_ACTIVE_SUBWND = 1
            ELSEIF DIC_CONTAINSKEY(RESULTS, "SORT")
                SORT_COLUMN = %DIC_GET(RESULTS, "SORT")%
                IF SORT_COLUMN == HO_ITEM_MENU_CURRENT_SORT_COLUMN
                    HO_ITEM_MENU_CURRENT_SORT_ORDER ++
                    IF HO_ITEM_MENU_CURRENT_SORT_ORDER > 2
                        HO_ITEM_MENU_CURRENT_SORT_COLUMN '= ""
                        HO_ITEM_MENU_CURRENT_SORT_ORDER = 0
                    ENDIF
                ELSE
                    HO_ITEM_MENU_CURRENT_SORT_COLUMN = %SORT_COLUMN%
                    HO_ITEM_MENU_CURRENT_SORT_ORDER = 1
                ENDIF
            ENDIF
        ELSE
            IF DIC_CONTAINSKEY(RESULTS, "MODIFY_WEAPON")
                CALL HO_ITEM_CRAFT_MODIFY_WEAPON(HO_ITEM_CRAFT_SELECT_ITEM_ID)
            ELSEIF DIC_CONTAINSKEY(RESULTS, "EXEC_ENCHANT_WEAPON")
                CALL HO_ITEM_CRAFT_EXEC_ENCHANT_WEAPON(HO_ITEM_CRAFT_SELECT_ITEM_ID)
            ELSEIF DIC_CONTAINSKEY(RESULTS, "EXEC_REMOVE_ENCHANT")
                CALL HO_ITEM_CRAFT_EXEC_REMOVE_ENCHANT(HO_ITEM_CRAFT_SELECT_ITEM_ID)
            ELSEIF DIC_CONTAINSKEY(RESULTS, "RENAME")
                CALL HO_ITEM_CRAFT_MODIFT_WEAPON_RENAME(HO_ITEM_CRAFT_SELECT_ITEM_ID)
            ELSEIF DIC_CONTAINSKEY(RESULTS, "EXIT")
                HO_CRAFT_IS_ACTIVE_SUBWND = 0
                HO_ITEM_CRAFT_SELECT_RUNE_ID  = -1
                HO_ITEM_CRAFT_DIC_REMOVE_ENCHANT '= ""
            ELSEIF DIC_CONTAINSKEY(RESULTS, "SELECT_RUNE")
                IF HO_ITEM_CRAFT_SELECT_RUNE_ID == -1
                    HO_ITEM_CRAFT_SELECT_RUNE_GENRE = DIC_GETINT(RESULTS, "SELECT_RUNE")
                    HO_CRAFT_IS_ACTIVE_SUBWND = 2
                ELSE
                    HO_ITEM_CRAFT_SELECT_RUNE_ID  = -1
                ENDIF
            ELSEIF DIC_CONTAINSKEY(RESULTS, "SELECT_RUNE_EXIT")
                HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT = 0
                HO_CRAFT_IS_ACTIVE_SUBWND = 1
            ELSEIF DIC_CONTAINSKEY(RESULTS, "RUNE_ID")
                HO_ITEM_CRAFT_SELECT_RUNE_ID = DIC_GETINT(RESULTS, "RUNE_ID")
                CALL HO_ITEM_CRAFT_CHECK_CAN_SELECT_RUNE()
                IF RESULT == -1
                    CALL COLOR_PRINTW("既に同種のスキルが付呪されているため選択できません", カラー_注意)
                    HO_ITEM_CRAFT_SELECT_RUNE_ID = -1
                ELSE
                    HO_CRAFT_IS_ACTIVE_SUBWND = 1
                ENDIF
            ELSEIF DIC_CONTAINSKEY(RESULTS, "REMOVE_ENCHANT")
                HO_ITEM_CRAFT_DIC_REMOVE_ENCHANT = %RESULTS%
            ELSEIF DIC_CONTAINSKEY(RESULTS, "RUNE_PAGE_PREV")
                HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT --
            ELSEIF DIC_CONTAINSKEY(RESULTS, "RUNE_PAGE_NEXT")
                HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT ++
            ENDIF
        ENDIF
    ENDIF
ENDIF


code:
@HO_DRAW_CRAFT_ITEM_WINDOW_RIGHT_WEAPON_MODIFY(MODULE_ID)
; #region
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 2
#DIM CONST WND_WIDTH  = 102
#DIM CONST WND_HEIGHT = 37
#DIM CONST ヘッダー行数 = 2
#DIM CONST BTN_ID = 2000
#DIM DYNAMIC L_CNT

#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC ITEM_NAME
#DIMS DYNAMIC MATERIAL_NAME
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC F_COL
#DIM DYNAMIC IS_CRAFTABLE = 1
#DIM DYNAMIC ERR_FLG

;武器関連変数
#DIMS DYNAMIC WEAPON_PRINT_NAME
#DIMS DYNAMIC WEAPON_NAME
#DIM  DYNAMIC WEAPON_DID
#DIM  DYNAMIC WEAPON_ID
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC MODIFIED_STATUS, WPN_MAX_STATUSNUM
#DIM  DYNAMIC STATUS_IDX
#DIM  DYNAMIC EQUIP_CHARA_ID
#DIM  DYNAMIC PARAM_DIFF
#DIMS CONST  WPN_STATUS_NAME_SHORT = "攻撃", "防御", "軽減", "魔力", "行動", "敵視", "選敵"
#DIM  DYNAMIC COLUMN_LENGTH = 14, 14, 14, 14, 14, 14, 16
;ステータスの表示順序
{
    #DIMS CONST COLUMN_ORDER =
        "ATTACK"
        , "DEFENCE"
        , "ARMOR"
        , "MAG"
        , "AGILITY"
        , "HATE_RATE"
        , "TARGETING"
}

;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 66, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)
SIF HO_ITEM_CRAFT_SELECT_ITEM_ID == -1
    RETURN

WEAPON_DID = HO_ITEM_CRAFT_SELECT_ITEM_ID
;武器名
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_NAME")
WEAPON_NAME = %RESULTS%
CALL GET_WEAPON_PRINT_NAME(WEAPON_DID)
WEAPON_PRINT_NAME = %RESULTS%
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "EQUIP_CHARA_ID")
EQUIP_CHARA_ID = RESULT
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_RANK")
WEAPON_RANK = RESULT

;改造前の武器ステータス取得
VARSET WPN_STATUS
FOR STATUS_IDX, 0, VARSIZE("WPN_STATUS_NAME_ENG")
    DT_CELL_GET "WEAPON_STOCK", WEAPON_DID, WPN_STATUS_NAME_ENG:STATUS_IDX, 1
    WPN_STATUS:STATUS_IDX = RESULT
NEXT
;改良後ステータス取得
CALL GET_WEAPON_MODIFIED_STATUS(WPN_STATUS, MODIFIED_STATUS)
CALL GET_WEAPON_MODIFY_COST(MATERIAL_NEEDS, WEAPON_RANK)
SIF !RESULT
    IS_CRAFTABLE = 0

;印字部
;ヘッダー
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　%WEAPON_PRINT_NAME%　◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;ステータス欄
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・現在のステータス@/C@")
L_CNT ++
LOCALS '= ""
FOR LOCAL, 0, WPN_MAX_STATUSNUM
    STATUS_IDX = FINDELEMENT(WPN_STATUS_NAME_ENG, COLUMN_ORDER:LOCAL)
    IF STATUS_IDX != WPN_脅威選定
        LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:{WPN_STATUS:STATUS_IDX}@/C@", COLUMN_LENGTH:LOCAL, 1)
    ELSE
        LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:%WPN_脅威選定文字列:(WPN_STATUS:STATUS_IDX)%@/C@", COLUMN_LENGTH:LOCAL, 1)
    ENDIF
NEXT

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%LOCALS%")
IF EQUIP_CHARA_ID >= 0
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　装備者:%ANAME(EQUIP_CHARA_ID)%")
ELSE
    L_CNT ++
ENDIF

;付与されているスキル
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・装備スキル@/C@")
;アクティブスキル
CALL GET_EQUIP_SKILL_LIST_STR(WEAPON_DID, 武器スキル_アクティブ)
IF RESULTS != ""
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_オレンジ}@　ACTIVE :@/C@%RESULTS%")
ENDIF
;パッシブスキル
CALL GET_EQUIP_SKILL_LIST_STR(WEAPON_DID, 武器スキル_パッシブ)
IF RESULTS != ""
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_黄緑}@　PASSIVE:@/C@%RESULTS%")
ENDIF

;強化情報欄
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　強化情報　◇@/S@@/C@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・強化後のステータス@/C@")
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%WEAPON_NAME%@C:{カラー_黄}@ +%(TOSTR(WEAPON_RANK + 1))%@/C@")
L_CNT ++
;強化予測値
LOCALS '= ""
FOR LOCAL, 0, WPN_MAX_STATUSNUM
    STATUS_IDX = FINDELEMENT(WPN_STATUS_NAME_ENG, COLUMN_ORDER:LOCAL)
    IF STATUS_IDX != WPN_脅威選定
        PARAM_DIFF = MODIFIED_STATUS:STATUS_IDX - WPN_STATUS:STATUS_IDX
        IF PARAM_DIFF > 0
            LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:{MODIFIED_STATUS:STATUS_IDX}@/C@@C:{カラー_緑}@(+{PARAM_DIFF})@/C@", COLUMN_LENGTH:LOCAL, 1)
        ELSE
            LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:{MODIFIED_STATUS:STATUS_IDX}@/C@", COLUMN_LENGTH:LOCAL, 1)
        ENDIF
    ELSE
        LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME_SHORT:LOCAL%:%WPN_脅威選定文字列:(MODIFIED_STATUS:STATUS_IDX)%@/C@", COLUMN_LENGTH:LOCAL, 1)
    ENDIF
NEXT
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%LOCALS%")

L_CNT ++
L_CNT ++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・要求素材@/C@")
L_CNT ++
FOR LOCAL:0, 0, ITEM_LENGTH
    IF MATERIAL_NEEDS:(LOCAL:0) > 0
        CALL GET_ITEM_NAME(LOCAL:0)
        MATERIAL_NAME = %RESULTS%
        IF HO_ITEM_STOCK:LOCAL < MATERIAL_NEEDS:LOCAL
            LOCALS = %TAG_PRINT_SHAPE(@"　　@C:{カラー_オレンジ}@%MATERIAL_NAME%@/C@", 24, 1, 0)%
            IS_CRAFTABLE = 0
        ELSE
            LOCALS = %TAG_PRINT_SHAPE(@"　　@C:{カラー_白}@%MATERIAL_NAME%@/C@", 24, 1, 0)%
        ENDIF
        LOCALS += @"× {MATERIAL_NEEDS:(LOCAL:0)}"
        LOCALS += @"@C:{カラー_選択不可}@　(所持:{HO_ITEM_STOCK:(LOCAL:0)})@/C@"
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
        L_CNT ++
    ENDIF
NEXT

;フッター
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
IF IS_CRAFTABLE
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@B:[MODIFY_WEAPON:{WEAPON_DID}]@@C:{カラー_白}@[強化する]@/C@@/B@")
ELSE
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@C:{カラー_選択不可}@[これ以上強化できない]@/C@")
ENDIF
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"　@B:[RENAME:1]@@C:{カラー_白}@[リネーム]@/C@@/B@")
CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"　@B:[EXIT:1]@@C:{カラー_白}@[キャンセル]@/C@@/B@")
; #endregion

;-------------------------------------------------
;改造処理実行
;-------------------------------------------------
@HO_ITEM_CRAFT_MODIFY_WEAPON(WEAPON_DID)
; #region
#DIM WEAPON_DID
;素材関連
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
;武器関連変数
#DIMS DYNAMIC WEAPON_NAME
#DIM  DYNAMIC WEAPON_ID
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC MODIFIED_STATUS, WPN_MAX_STATUSNUM
#DIM  DYNAMIC STATUS_IDX

;改造前の武器ステータス取得
VARSET WPN_STATUS
FOR STATUS_IDX, 0, VARSIZE("WPN_STATUS_NAME_ENG")
    DT_CELL_GET "WEAPON_STOCK", WEAPON_DID, WPN_STATUS_NAME_ENG:STATUS_IDX, 1
    WPN_STATUS:STATUS_IDX = RESULT
NEXT
;武器名
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_NAME")
WEAPON_NAME = %RESULTS%
CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_RANK")
WEAPON_RANK = RESULT

;改良後ステータス取得
CALL GET_WEAPON_MODIFIED_STATUS(WPN_STATUS, MODIFIED_STATUS)
;強化コスト取得
CALL GET_WEAPON_MODIFY_COST(MATERIAL_NEEDS, WEAPON_RANK)

;改造後の武器ステータスをテーブルにセット
DT_CELL_SET "WEAPON_STOCK", WEAPON_DID, "WEAPON_RANK", WEAPON_RANK + 1, 1
FOR STATUS_IDX, 0, VARSIZE("WPN_STATUS_NAME_ENG")
    DT_CELL_SET "WEAPON_STOCK", WEAPON_DID, WPN_STATUS_NAME_ENG:STATUS_IDX, MODIFIED_STATUS:STATUS_IDX, 1
NEXT
;コスト消費
CALL USE_MATERIAL(MATERIAL_NEEDS)
CALL FL_PLAYSE("CRAFT_3.mp3")
PRINTFORMW %WEAPON_NAME%の強化に成功した！
; #endregion

;-------------------------------------------------
;リネーム処理
;-------------------------------------------------
@HO_ITEM_CRAFT_MODIFT_WEAPON_RENAME(WEAPON_DID)
#DIM  WEAPON_DID
#DIMS DYNAMIC WEAPON_NAME
#DIM  DYNAMIC FIRST_LINE

CALL GET_WEAPON_STOCK_TABLE(WEAPON_DID, "WEAPON_NAME")
WEAPON_NAME = %RESULTS%

CALL PRINTLINE_RESERVE()
$INPUT_LOOP
CALL PRINTLINE_CLEAR()

CALLF TAG_PRINT(@"@C:{カラー_注意}@%WEAPON_NAME%@/C@の新しい名前を入力してください(12字まで、未入力でキャンセル)", 1)

INPUTS
CLEARLINE 1
IF RESULTS == ""
    RETURN
ENDIF

RESULTS = %HTML_TOPLAINTEXT(RESULTS)%
IF STRLENSU(RESULTS) > 12
    PRINTFORMW 名前が長すぎます(12字まで)
    GOTO INPUT_LOOP
ENDIF

CALLF TAG_PRINT(@"@C:{カラー_注意}@%RESULTS%@/C@でいいですか？", 1)

CALL ASK_YN
IF RESULT == 1
    GOTO INPUT_LOOP
ENDIF

DT_CELL_SET "WEAPON_STOCK", WEAPON_DID, "WEAPON_NAME", RESULTS, 1
RETURN


code:
;-------------------------------------------------
; アイテムメニュー画面
;-------------------------------------------------
@HO_ITEM_MENU(CATEGORY = 0, DIC_OPTIONS = "")
#DIM CATEGORY
#DIMS DIC_OPTIONS
#DIM CONST WINDOW_ID = 0
#DIM DYNAMIC LINE_NUM

;初期処理
HO_ITEM_MENU_PAGE_LEFT = 0
HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT = 0
HO_ITEM_MENU_SELECT_ITEM_ID = -1
HO_ITEM_MENU_CATEGORY = CATEGORY
;一括破棄モード管理用変数の初期化
CALL BULK_DISPOSE_MODE_INIT()

LINE_NUM = LINECOUNT

IF DIC_CONTAINSKEY(DIC_OPTIONS, "BULK_DISPOSE_MODE")
    SELECTCASE DIC_GETINT(DIC_OPTIONS, "BULK_DISPOSE_MODE")
        CASE 0
            HO_ITEM_MENU_CATEGORY = HO_ITEM_MENU_CATEGORY_武器
            HO_ITEM_MENU_BULK_DISPOSE_MODE = HO_ITEM_MENU_CATEGORY
        CASE 1
            HO_ITEM_MENU_CATEGORY = HO_ITEM_MENU_CATEGORY_レリック
            HO_ITEM_MENU_BULK_DISPOSE_MODE = HO_ITEM_MENU_CATEGORY
    ENDSELECT
ENDIF

WHILE 1
    LINE_NUM = LINECOUNT
    REDRAW 0
    CALL WndMgr_DestroyWindow(-1)
    CALL HO_DRAW_ITEM_MENU_WINDOW_PARENT()
    CALL WndMgr_DisplayAll()
    REDRAW 1
    CALL HO_ITEM_MENU_WINDOW_INPUT()
    IF RESULT == -1
        CLEARLINE LINECOUNT - LINE_NUM
        RETURN -1
    ELSEIF RESULT == 1
        CLEARLINE LINECOUNT - LINE_NUM
        RETURN 1
    ENDIF
    CLEARLINE LINECOUNT - LINE_NUM
WEND

@HO_DRAW_ITEM_MENU_WINDOW_PARENT()
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 0
#DIM CONST WND_WIDTH  = 170
#DIM CONST WND_HEIGHT = 44
#DIM DYNAMIC L_CNT
#DIM DYNAMIC BTN_ID

#DIMS DYNAMIC _LIST_MEMBER
#DIM DYNAMIC MEMBER_NUM
#DIM DYNAMIC CHARA_ID
#DIM DYNAMIC F_COL, 10

#DIMS DYNAMIC ITEM_NAME
#DIM DYNAMIC ITEM_NUM
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC WPN_MATERIAL_NEEDS, WPN_材質種類数, ITEM_LENGTH
#DIMS DYNAMIC WEAPON_NAME
#DIM DYNAMIC 材質種類
#DIM DYNAMIC アイテム種類
#DIM DYNAMIC IS_CRAFTABLE

BTN_ID = HO_アイテムクラフトボタンID

CALL WndMgr_CheckExistWindow()
FINDELEMENT RESULT, WINDOW_ID, 1
IF RESULT == -1
    CALL WndMgr_CreateWindow(WINDOW_ID, 0, 1, WND_WIDTH, WND_HEIGHT, 2)
ELSE
    CALL WndMgr_ResetWindow(WINDOW_ID)
ENDIF

;CATEGORYタブの文字色
VARSET F_COL, カラー_白
F_COL:HO_ITEM_MENU_CATEGORY = カラー_選択中
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　アイテム　◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

CALL HO_DRAW_ITEM_MENU_WINDOW_LEFT(MODULE_ID)
SELECTCASE HO_ITEM_MENU_CATEGORY
        ;アイテム
    CASE 0 TO 2,5
        CALL HO_DRAW_ITEM_MENU_WINDOW_RIGHT(MODULE_ID)
        ;     ;武器
        ; CASE 1
        ;     CALL HO_DRAW_ITEM_MENU_WINDOW_RIGHT_WEAPON(MODULE_ID)
        ;     ;衣類
        ; CASE 2
        ;     CALL HO_DRAW_ITEM_MENU_WINDOW_RIGHT_CLOTH(MODULE_ID)
    CASEELSE

ENDSELECT

;フッター出力
;-------------------------------------------------
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL WndMgr_TextSet(WINDOW_ID, L_CNT, @"@B:9999999@@C:{カラー_白}@[BACK]@/C@@/B@")
IF GROUPMATCH(HO_ITEM_MENU_CATEGORY, HO_ITEM_MENU_CATEGORY_武器, HO_ITEM_MENU_CATEGORY_レリック)
    CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"@B:[BULK_DISPOSE_MODE:1]@@C:{HO_ITEM_MENU_BULK_DISPOSE_MODE == HO_ITEM_MENU_CATEGORY ? カラー_選択中 # カラー_白}@　[一括廃棄]@/C@@/B@")
    IF HO_ITEM_MENU_BULK_DISPOSE_MODE == HO_ITEM_MENU_CATEGORY
        IF FINDELEMENT(HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID, 0) > 0
            CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"@B:[BULK_DISPOSE_EXEC:1]@@C:{カラー_白}@　[一括廃棄の実行]@/C@@/B@")
        ELSE
            CALL WndMgr_TextAdd(WINDOW_ID, L_CNT, @"@C:{カラー_選択不可}@　[一括廃棄の実行]@/C@")
        ENDIF
    ENDIF
ENDIF

RETURN

@HO_DRAW_ITEM_MENU_WINDOW_LEFT(MODULE_ID, CALL_FROM = "ITEM_MENU")
#DIM  MODULE_ID
#DIMS CALL_FROM
#DIM  CONST WINDOW_ID = 1
#DIM  WND_WIDTH  = 64
#DIM  WND_HEIGHT = 37
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC F_COL, 10

;CATEGORYタブの文字色
VARSET F_COL, カラー_白
F_COL:HO_ITEM_MENU_CATEGORY = カラー_選択中

IF CALL_FROM == "WEAPON_MODIFY" || CALL_FROM == "WEAPON_ENCHANT"
    HO_ITEM_MENU_CATEGORY = 3
ENDIF

;カテゴリー毎の設定
SELECTCASE HO_ITEM_MENU_CATEGORY
        ;アイテム
    CASE 0 TO 2,5
        WND_WIDTH = 64
        ;武器、レリック
    CASEELSE
        WND_WIDTH = 166
ENDSELECT

;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 2, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)

IF CALL_FROM == "ITEM_MENU"
    ;カテゴリー選択
    ;-------------------------------------------------
    LOCALS '= @"@C:{F_COL:0}@@B:0@[消費]@/B@@/C@"
    LOCALS += @"@C:{F_COL:1}@@B:1@　[調教]@/B@@/C@"
    LOCALS += @"@C:{F_COL:2}@@B:2@　[素材]@/B@@/C@"
    LOCALS += @"@C:{F_COL:3}@@B:3@　[武器]@/B@@/C@"
    LOCALS += @"@C:{F_COL:4}@@B:4@　[ﾚﾘｯｸ]@/B@@/C@"
    LOCALS += @"@C:{F_COL:6}@@B:6@　[ﾙｰﾝ ]@/B@@/C@"
    LOCALS += @"@C:{F_COL:5}@@B:5@　[貴重]@/B@@/C@"
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
    ;-------------------------------------------------
ELSEIF CALL_FROM == "WEAPON_MODIFY"
    LOCALS '= @"@C:{カラー_注釈}@強化する対象を選択してください@/C@"
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
ELSEIF CALL_FROM == "WEAPON_ENCHANT"
    LOCALS '= @"@C:{カラー_注釈}@付呪を行う対象を選択してください@/C@"
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
ENDIF

;カテゴリー用ヘッダ
SELECTCASE HO_ITEM_MENU_CATEGORY
        ;アイテム
    CASE 0 TO 2,5
        ;武器、レリック
    CASE 3, 4
        ;-------------------------------------------------
        ;武器用ステータス欄の見出
        ;-------------------------------------------------
        LOCALS '= ""
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:FAVORITE_FLAG]@[★]@/B@", 5, 1)
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:WEAPON_NAME]@[名称]@/B@", 26, 1)
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:EQUIP_CHARA_ID]@ [装備者]@/B@", 16, 1)
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:ATTACK]@ [攻撃]@/B@", 8, 1)
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:DEFENCE]@ [防御]@/B@", 8, 1)
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:ARMOR]@ [軽減]@/B@", 8, 1)
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:MAG]@ [魔力]@/B@", 8, 1)
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:AGILITY]@ [行動]@/B@", 8, 1)
        LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:HATE_RATE]@ [敵視]@/B@", 8, 1)
        IF HO_ITEM_MENU_CATEGORY == 3
            LOCALS += TAG_PRINT_SHAPE(@"@B:[SORT:TARGETING]@ [選敵]@/B@", 8, 1)
        ENDIF
        LOCALS += TAG_PRINT_SHAPE(@"  [装備スキル]", 22, 1)
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
        ;ﾙｰﾝ
    CASE 6
ENDSELECT

;カテゴリー用明細
SELECTCASE HO_ITEM_MENU_CATEGORY
        ;アイテム
    CASE 0 TO 2,5
        CALL HO_DRAW_ITEM_MENU_WINDOW_PRINT_DETAIL_ITEM(WINDOW_ID)
        ;武器、レリック
    CASE 6
        CALL HO_DRAW_ITEM_MENU_WINDOW_PRINT_DETAIL_RUNE(WINDOW_ID)
    CASEELSE
        CALL HO_DRAW_ITEM_MENU_WINDOW_PRINT_DETAIL_WEAPON(WINDOW_ID, CALL_FROM  )
ENDSELECT

@HO_DRAW_ITEM_MENU_WINDOW_RIGHT(MODULE_ID)
; #region
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 4
#DIM CONST WND_WIDTH  = 102
#DIM CONST WND_HEIGHT = 37
#DIM CONST ヘッダー行数 = 2
#DIM CONST BTN_ID = 2000
#DIM DYNAMIC L_CNT

#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC MATERIAL_NAME
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC F_COL
#DIM DYNAMIC ITEM_CAN_USE = 0
#DIM DYNAMIC ERR_FLG
;ウィンドウ作成
CALL WndMgr_CreateWindow(WINDOW_ID, 66, 5, WND_WIDTH, WND_HEIGHT, 2)
CALL WndMgr_Attribute(WINDOW_ID, "BorderColor", カラー_選択不可)
SIF HO_ITEM_MENU_SELECT_ITEM_ID == -1
    RETURN

ITEM_ID = HO_ITEM_MENU_SELECT_ITEM_ID
IF ITEM_ID >= 1000000
    ITEM_ID -= 1000000
ENDIF

;ヘッダー
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME = %RESULTS%
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　%ITEM_NAME%　◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;概要欄
VARSET RESULTS
FOR LOCAL, 0, 10
    TRYCALLFORM GET_ITEM_DESCRIPTION_{ITEM_ID}
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%RESULTS:LOCAL%")
NEXT

;備考欄
L_CNT++
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　備考　◇@/S@@/C@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

VARSET RESULTS
FOR LOCAL, 0, 10
    TRYCALLFORM GET_ITEM_SUBDESCRIPTION_{ITEM_ID}
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%RESULTS:LOCAL%")
NEXT

;フッター
L_CNT = WND_HEIGHT - 4
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))

;条件をみたす場合のみ「使用する」ボタンをアクティブに
CALL HO_ITEM_MENU_CHECK_ITEM_CAN_USE(ITEM_ID)
ITEM_CAN_USE = RESULT
IF ITEM_CAN_USE
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@B:{BTN_ID + ITEM_ID}@@C:{カラー_白}@[使用する]@/C@@/B@")
ELSE
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@[使用する]@/C@")
ENDIF
; #endregion

;-------------------------------------------------
;アイテム使用可能判定
;-------------------------------------------------
@HO_ITEM_MENU_CHECK_ITEM_CAN_USE(ITEM_ID)
#DIM ITEM_ID
#DIMS DICS_ITEM_EFFECT

TRYCCALLFORM GET_ITEM_INFO_AT_USING_{ITEM_ID}
    DICS_ITEM_EFFECT = %RESULTS%
CATCH
    RETURN 0
ENDCATCH

IF FLAG:クエストモード
    CALL GET_ITEM_INFO(ITEM_ID, ITEM_CAN_USE_AT_QUEST)
    IF RESULT
        ;クエスト中の応急治療アイテム使用は応急治療点を保有している場合のみ可
        IF DIC_GET(DICS_ITEM_EFFECT, "EFFECT_CATEGORY") == "QUEST_MEDICAL_CARE"
            IF QST_応急治療点 > 0
                RETURN 1
            ELSE
                RETURN 0
            ENDIF
        ELSE
            RETURN 1
        ENDIF
    ENDIF
    ;ホーム画面
ELSEIF !FLAG:ハウジングモード
    CALL GET_ITEM_INFO(ITEM_ID, ITEM_CAN_USE_AT_HOME)
    IF RESULT
        RETURN 1
    ENDIF
ENDIF

;-------------------------------------------------
;アイテム明細リスト
;-------------------------------------------------
@HO_DRAW_ITEM_MENU_WINDOW_PRINT_DETAIL_ITEM(WINDOW_ID)
; #region
#DIM WINDOW_ID
#DIM CONST HEADER_NUM = 2 ;ヘッダー行数
#DIM CONST MAX_ROW = 30
#DIM CONST BTN_ID = 1000000

#DIM  DYNAMIC WND_WIDTH
#DIMS DYNAMIC DETAIL_LIST, ITEM_LENGTH
#DIM  DYNAMIC ITEM_NUM
#DIMS DYNAMIC STR_ITEM_NUM
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC PAGE_NUM
#DIMS DYNAMIC STR_FOOTER
#DIM  DYNAMIC DETAIL_LINECOUNT
;アイテム関連
#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM  DYNAMIC ITEM_ID
;武器関連
#DIM  DYNAMIC IDX, WPN_MAX_WEAPON_STOCK
#DIM  DYNAMIC EQUIP_CHARA_ID
#DIM  DYNAMIC EQUIP_CHARA_NAME

;明細リスト作成
;-------------------------------------------------
DETAIL_LINECOUNT = 0
L_CNT = 0
FOR ITEM_ID, 0, ITEM_LENGTH
    CALL GET_ITEM_CATEGORY(ITEM_ID)
    SIF LIST_INDEXOF(RESULTS, HO_ITEM_MENU_CATEGORY_NAME:HO_ITEM_MENU_CATEGORY) == -1
        CONTINUE
    ITEM_NUM = HO_ITEM_STOCK:ITEM_ID
    IF ITEM_NUM > 0
        CALL GET_ITEM_NAME(ITEM_ID)
        ITEM_NAME = %RESULTS%
        ITEM_NAME = %TAG_PRINT_SHAPE(ITEM_NAME, 15, 1, 0)%
        STR_ITEM_NUM = %TAG_PRINT_SHAPE(TOSTR(ITEM_NUM), 8, 1, 0)%
        DETAIL_LIST:DETAIL_LINECOUNT '= @"@B:{BTN_ID + ITEM_ID}@@C:{カラー_白}@[%ITEM_NAME%] × %STR_ITEM_NUM%@/C@@/B@"
        DETAIL_LIST:DETAIL_LINECOUNT = %TAG_PRINT_SHAPE(DETAIL_LIST:DETAIL_LINECOUNT, 28, 1, 0)%
        DETAIL_LINECOUNT ++
    ELSE
        CONTINUE
    ENDIF
NEXT
PAGE_NUM = DETAIL_LINECOUNT / MAX_ROW

;明細リスト出力
;-------------------------------------------------
L_CNT = 0
FOR LOCAL, MAX_ROW * HO_ITEM_MENU_PAGE_LEFT, MAX_ROW * (HO_ITEM_MENU_PAGE_LEFT + 1)
    IF  L_CNT / MAX_ROW <= 0
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT + HEADER_NUM, DETAIL_LIST:LOCAL)
        L_CNT++
    ELSE
        CALL WndMgr_TextAdd(WINDOW_ID, (L_CNT % MAX_ROW) + HEADER_NUM, DETAIL_LIST:LOCAL)
        L_CNT ++
    ENDIF
    L_CNT ++
NEXT

;フッター
;-------------------------------------------------
CALL WndMgr_GetRectangle(WINDOW_ID)
WND_WIDTH = RESULT:2

IF PAGE_NUM > 0
    STR_FOOTER += HO_ITEM_MENU_PAGE_LEFT > 0 ? @"@B:9000@<<@/B@ " # "   "
    STR_FOOTER += @"%TOSTR(HO_ITEM_MENU_PAGE_LEFT + 1, "..")% "
    STR_FOOTER += HO_ITEM_MENU_PAGE_LEFT != PAGE_NUM ? @"@B:9001@>>@/B@" # "  "
    CALLF TAG_PRINT_SHAPE(STR_FOOTER, WND_WIDTH - 8, 1, 2)
    CALL WndMgr_TextSet(WINDOW_ID, MAX_ROW + 2, @"@C:{カラー_注釈}@%RESULTS%@/C@")
ENDIF
; #endregion

;-------------------------------------------------
;武器明細リスト
;-------------------------------------------------
@HO_DRAW_ITEM_MENU_WINDOW_PRINT_DETAIL_WEAPON(WINDOW_ID, CALL_FROM)
; #region
#DIM  WINDOW_ID
#DIMS CALL_FROM
#DIM CONST HEADER_NUM = 4 ;ヘッダー行数
#DIM CONST MAX_ROW = 14
#DIM CONST BTN_ID = 1000000

#DIM  DYNAMIC WND_WIDTH
#DIM  DYNAMIC WND_HEIGHT
#DIMS DYNAMIC DETAIL_LIST, WPN_MAX_WEAPON_STOCK
#DIM  DYNAMIC ITEM_NUM
#DIMS DYNAMIC STR_ITEM_NUM
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC PAGE_NUM
#DIMS DYNAMIC STR_FOOTER
#DIM  DYNAMIC DETAIL_LINECOUNT
#DIMS DYNAMIC SORT_ORDER = "WEAPON_ID ASC, MATERIAL ASC"
#DIM  DYNAMIC EQUIP_TYPE
#DIMS  DYNAMIC FILTER
;アイテム関連
#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM  DYNAMIC ITEM_ID
;武器関連
#DIM  DYNAMIC IDX, WPN_MAX_WEAPON_STOCK
#DIM  DYNAMIC STATUS_IDX
#DIM  DYNAMIC WEAPON_ID
#DIMS DYNAMIC WEAPON_NAME
#DIM  DYNAMIC FAVORITE_FLAG
#DIM  DYNAMIC MATERIAL
#DIM  DYNAMIC EQUIP_CHARA_ID
#DIM  DYNAMIC EQUIP_CHARA_NAME
#DIMS DYNAMIC DIC_WPN_SKILL
#DIMS DYNAMIC SKILL_DEF_NAME
#DIMS DYNAMIC WPN_SKILL_DEF_LIST, VARSIZE("SKILL_DEF_LIST")
#DIMS DYNAMIC SKILL_NAME
#DIM  DYNAMIC SKILL_LV
#DIMS DYNAMIC TOOLTIP
;印字カラム
#DIMS DYNAMIC COLUMN, 10
#DIM  DYNAMIC COLUMN_IDX
#DIM  DYNAMIC COLUMN_LENGTH = 5, 28, 13, 8, 8, 8, 8, 8, 8, 8,
#DIM  DYNAMIC COLUMN_PADDING = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;ステータスの表示順序
{
    #DIMS CONST   COLUMN_ORDER =
        "ATTACK"
        , "DEFENCE"
        , "ARMOR"
        , "MAG"
        , "AGILITY"
        , "HATE_RATE"
        , "TARGETING"
}

#DIM  ITER_J

;レリック
SIF HO_ITEM_MENU_CATEGORY == 4
    EQUIP_TYPE = 1
IF CALL_FROM == "WEAPON_ENCHANT"
    FILTER '= @"EQUIP_TYPE = {EQUIP_TYPE} AND (ON_SALE_FLAG = 0 OR ON_SALE_FLAG IS NULL) AND (PASSIVE_SKILL_SLOT > 0 OR ACTIVE_SKILL_SLOT > 0)"
ELSE
    FILTER '= @"EQUIP_TYPE = {EQUIP_TYPE} AND (ON_SALE_FLAG = 0 OR ON_SALE_FLAG IS NULL)"
ENDIF

;明細リスト作成
;-------------------------------------------------
DETAIL_LINECOUNT = 0
L_CNT = 0
IF HO_ITEM_MENU_CURRENT_SORT_COLUMN != ""
    SELECTCASE HO_ITEM_MENU_CURRENT_SORT_ORDER
        CASE 1 ;降順
            SORT_ORDER '= @"%HO_ITEM_MENU_CURRENT_SORT_COLUMN% DESC"
        CASE 2 ;昇順
            SORT_ORDER '= @"%HO_ITEM_MENU_CURRENT_SORT_COLUMN% ASC"
    ENDSELECT
ELSE
    SORT_ORDER '= "WEAPON_ID ASC, MATERIAL ASC"
ENDIF
ITEM_NUM = DT_SELECT("WEAPON_STOCK", FILTER, SORT_ORDER, IDX)
; DT_TOXML "WEAPON_STOCK"
; DEBUGPRINTFORML results = %RESULTS%
FOR LOCAL, 0, ITEM_NUM
    COLUMN_IDX = 0
    CALL GET_WEAPON_STOCK_TABLE(IDX:LOCAL, "WEAPON_ID")
    WEAPON_ID = RESULT
    CALL GET_WEAPON_STOCK_TABLE(IDX:LOCAL, "MATERIAL")
    MATERIAL = RESULT
    CALL GET_WEAPON_PRINT_NAME(IDX:LOCAL)
    WEAPON_NAME = %RESULTS%
    EQUIP_CHARA_ID = -1
    CALL GET_WEAPON_STOCK_TABLE(IDX:LOCAL, "EQUIP_CHARA_ID")
    EQUIP_CHARA_ID = RESULT
    CALL GET_WEAPON_STOCK_TABLE(IDX:LOCAL, "FAVORITE_FLAG")
    FAVORITE_FLAG = RESULT
    ;気に入り状態
    TOOLTIP '= "・お気に入り設定の切り替え
お気に入り設定を切り替えます
お気に入り指定された装備は売却対象に表示されず、廃棄出来なくなります"
    IF !FAVORITE_FLAG
        COLUMN:COLUMN_IDX = %TAG_PRINT_SHAPE(@"@B:[FAVORITE_FLAG:{IDX:LOCAL}]$%TOOLTIP%@@C:{カラー_注釈}@ □@/C@@/B@", COLUMN_LENGTH:COLUMN_IDX, 1)%
    ELSE
        COLUMN:COLUMN_IDX = %TAG_PRINT_SHAPE(@"@B:[FAVORITE_FLAG:{IDX:LOCAL}]$%TOOLTIP%@@C:{カラー_白}@ ★@/C@@/B@", COLUMN_LENGTH:COLUMN_IDX, 1)%
    ENDIF
    COLUMN_IDX ++
    ;各カラムの値セット
    ;装備名
    VARI F_COL
    IF HO_ITEM_MENU_BULK_DISPOSE_MODE == HO_ITEM_MENU_CATEGORY
        IF FINDELEMENT(HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID, IDX:LOCAL) != -1
            F_COL = カラー_選択中
        ELSE
            F_COL = カラー_白
        ENDIF
    ELSE
        F_COL = カラー_白
    ENDIF
    COLUMN:COLUMN_IDX = %TAG_PRINT_SHAPE(@"@C:{F_COL}@@B:[WEAPON_DID:{IDX:LOCAL}]@[%WEAPON_NAME%]@/B@@/C@", COLUMN_LENGTH:COLUMN_IDX, 1)%
    COLUMN_IDX ++
    ;装備者
    IF EQUIP_CHARA_ID >= 0
        COLUMN:COLUMN_IDX = %TAG_PRINT_SHAPE(@"@C:{カラー_白}@%ANAME(EQUIP_CHARA_ID)%@/C@", COLUMN_LENGTH:COLUMN_IDX, 1)%
    ELSE
        COLUMN:COLUMN_IDX = %TAG_PRINT_SHAPE(@"", COLUMN_LENGTH:COLUMN_IDX, 1)%
    ENDIF
    COLUMN_IDX ++
    ;各パラメータ
    FOR STATUS_IDX, 0, WPN_MAX_STATUSNUM
        IF COLUMN_ORDER:STATUS_IDX != "TARGETING"
            COLUMN:(STATUS_IDX + COLUMN_IDX) = %TAG_PRINT_SHAPE(@"@C:{カラー_注釈}@{DT_CELL_GET("WEAPON_STOCK", IDX:LOCAL, COLUMN_ORDER:STATUS_IDX, 1)}@/C@", COLUMN_LENGTH:(STATUS_IDX + COLUMN_IDX), 1, 1)%
        ELSEIF EQUIP_TYPE == 0
            COLUMN:(STATUS_IDX + COLUMN_IDX) = %TAG_PRINT_SHAPE(@"@C:{カラー_注釈}@%WPN_脅威選定文字列:DT_CELL_GET("WEAPON_STOCK", IDX:LOCAL, COLUMN_ORDER:STATUS_IDX, 1)%@/C@", COLUMN_LENGTH:(STATUS_IDX + COLUMN_IDX), 1, 1)%
        ENDIF
        ;        COLUMN:(STATUS_IDX + 2) = %COLUMN:(STATUS_IDX + 2) + TOSTR_SPACE(COLUMN_PADDING:STATUS_IDX + 2)%
    NEXT
    DETAIL_LIST:DETAIL_LINECOUNT '= ""
    FOR COLUMN_IDX, 0, VARSIZE("COLUMN")
        DETAIL_LIST:DETAIL_LINECOUNT += COLUMN:COLUMN_IDX
    NEXT
    DETAIL_LIST:DETAIL_LINECOUNT += "    "
    ;武器スキル_アクティブ
    CALL GET_EQUIP_SKILL_LIST_STR(IDX:LOCAL, 武器スキル_アクティブ)
    DETAIL_LIST:DETAIL_LINECOUNT += RESULTS
    ;武器スキル_パッシブ
    CALL GET_EQUIP_SKILL_LIST_STR(IDX:LOCAL, 武器スキル_パッシブ)
    DETAIL_LIST:DETAIL_LINECOUNT += RESULTS
    DETAIL_LINECOUNT ++
NEXT
PAGE_NUM = DETAIL_LINECOUNT / MAX_ROW

;明細リスト出力
;-------------------------------------------------
L_CNT = 0
FOR LOCAL, MAX_ROW * HO_ITEM_MENU_PAGE_LEFT, MAX_ROW * (HO_ITEM_MENU_PAGE_LEFT + 1)
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT + HEADER_NUM, DETAIL_LIST:LOCAL)
    L_CNT++
    L_CNT ++
NEXT

;フッター
;-------------------------------------------------
CALL WndMgr_GetRectangle(WINDOW_ID)
WND_WIDTH = RESULT:2
WND_HEIGHT = RESULT:3

IF PAGE_NUM > 0
    STR_FOOTER += HO_ITEM_MENU_PAGE_LEFT > 0 ? @"@B:9000@<<@/B@ " # "   "
    STR_FOOTER += @"%TOSTR(HO_ITEM_MENU_PAGE_LEFT + 1, "..")% "
    STR_FOOTER += HO_ITEM_MENU_PAGE_LEFT != PAGE_NUM ? @"@B:9001@>>@/B@" # "  "
    CALLF TAG_PRINT_SHAPE(STR_FOOTER, WND_WIDTH - 8, 1, 2)
    CALL WndMgr_TextSet(WINDOW_ID, WND_HEIGHT - 4, @"@C:{カラー_注釈}@%RESULTS%@/C@")
ENDIF
; #endregion

;-------------------------------------------------
;エンチャントルーン明細リスト
;-------------------------------------------------
@HO_DRAW_ITEM_MENU_WINDOW_PRINT_DETAIL_RUNE(WINDOW_ID, CALL_FROM = "")
; #region
#DIM  WINDOW_ID
#DIMS CALL_FROM
#DIM  CONST HEADER_NUM = 2 ;ヘッダー行数
#DIM  CONST MAX_ROW = 14
#DIM  CONST BTN_ID = 1000000

#DIM  DYNAMIC WND_WIDTH
#DIM  DYNAMIC WND_HEIGHT
#DIMS DYNAMIC DETAIL_LIST, ITEM_LENGTH
#DIM  DYNAMIC ITEM_NUM
#DIMS DYNAMIC STR_ITEM_NUM
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC PAGE_NUM
#DIMS DYNAMIC STR_FOOTER
#DIM  DYNAMIC DETAIL_LINECOUNT
#DIMS DYNAMIC SORT_ORDER = "WEAPON_ID ASC, MATERIAL ASC"
#DIM  DYNAMIC EQUIP_TYPE
#DIMS DYNAMIC FILTER
#DIM  DYNAMIC F_COL
;アイテム関連
#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM  DYNAMIC ITEM_ID
;武器関連
#DIM  DYNAMIC IDX, WPN_MAX_WEAPON_STOCK
#DIMS DYNAMIC SKILL_DEF_NAME
#DIMS DYNAMIC SKILL_NAME
#DIM  DYNAMIC SKILL_LV
#DIM  DYNAMIC WPN_SKILL_GENRE
#DIMS DYNAMIC TOOLTIP
#DIM  DYNAMIC AMOUNT
;印字カラム
#DIMS DYNAMIC COLUMN, 9
#DIM  DYNAMIC COLUMN_IDX

#DIM  ITER_J

;明細リスト作成
;-------------------------------------------------
DETAIL_LINECOUNT = 0
L_CNT = 0
SORT_ORDER '= "WPN_SKILL_GENRE DESC, SKILL_DEF_NAME ASC, SKILL_LV ASC"

IF CALL_FROM == "WEAPON_ENCHANT"
    IF HO_ITEM_CRAFT_SELECT_RUNE_GENRE == 武器スキル_アクティブ
        FILTER += @"WPN_SKILL_GENRE = {武器スキル_アクティブ}"
    ELSE
        FILTER += @"WPN_SKILL_GENRE = {武器スキル_パッシブ}"
    ENDIF
ENDIF

ITEM_NUM = DT_SELECT("RUNE_STOCK", FILTER, SORT_ORDER, IDX)
; DT_TOXML "WEAPON_STOCK"
; DEBUGPRINTFORML results = %RESULTS%
FOR LOCAL, 0, ITEM_NUM
    CALL RUNE_STOCK_GET_TABLE_DATA(IDX:LOCAL, "SKILL_DEF_NAME")
    SKILL_DEF_NAME = %RESULTS%
    CALL RUNE_STOCK_GET_TABLE_DATA(IDX:LOCAL, "SKILL_LV")
    SKILL_LV = RESULT
    CALL RUNE_STOCK_GET_TABLE_DATA(IDX:LOCAL, "AMOUNT")
    AMOUNT = RESULT
    CALL RUNE_STOCK_GET_TABLE_DATA(IDX:LOCAL, "WPN_SKILL_GENRE")
    WPN_SKILL_GENRE = RESULT
    CALL SKILL_GET_NAME(WPN_SKILL_GENRE, SKILL_DEF_NAME, 1)
    SKILL_NAME = %RESULTS%
    CALL GET_SKILL_DESC(SKILL_DEF_NAME, WPN_SKILL_GENRE, SKILL_LV, 1)
    TOOLTIP = %RESULTS%
    SKILL_NAME '= @"@B:[RUNE_ID:{IDX:LOCAL}]$%TOOLTIP%@<%GET_WPN_SKILL_NAME(SKILL_DEF_NAME, WPN_SKILL_GENRE)%Lv{SKILL_LV}> @/B@"
    IF WPN_SKILL_GENRE == 武器スキル_アクティブ
        F_COL = カラー_オレンジ
    ELSE
        F_COL = カラー_黄緑
    ENDIF
    COLUMN:0 '= @"@C:{F_COL}@%SKILL_NAME%@/C@"
    COLUMN:1 '= @"× {AMOUNT}"
    ;明細文字列連結
    DETAIL_LIST:DETAIL_LINECOUNT '= ""
    FOR COLUMN_IDX, 0, VARSIZE("COLUMN")
        DETAIL_LIST:DETAIL_LINECOUNT += COLUMN:COLUMN_IDX
    NEXT
    DETAIL_LINECOUNT ++
NEXT
PAGE_NUM = DETAIL_LINECOUNT / MAX_ROW

;明細リスト出力
;-------------------------------------------------
L_CNT = 0
FOR LOCAL, MAX_ROW * HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT, MAX_ROW * (HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT + 1)
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT + HEADER_NUM, DETAIL_LIST:LOCAL)
    L_CNT++
    L_CNT ++
NEXT

;フッター
;-------------------------------------------------
CALL WndMgr_GetRectangle(WINDOW_ID)
WND_WIDTH = RESULT:2
WND_HEIGHT = RESULT:3

IF PAGE_NUM > 0
    STR_FOOTER += HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT > 0 ? @"@B:[RUNE_PAGE_PREV:1]@<<@/B@ " # "   "
    STR_FOOTER += @"%TOSTR(HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT + 1, "..")% "
    STR_FOOTER += HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT != PAGE_NUM ? @"@B:[RUNE_PAGE_NEXT:1]@>>@/B@" # "  "
    CALLF TAG_PRINT_SHAPE(STR_FOOTER, WND_WIDTH - 8, 1, 2)
    CALL WndMgr_TextSet(WINDOW_ID, WND_HEIGHT - 5, @"@C:{カラー_注釈}@%RESULTS%@/C@")
ENDIF
; #endregion

@HO_ITEM_MENU_WINDOW_INPUT(MODULE_ID)
#DIM MODULE_ID
#DIM DYNAMIC ITEM_ID
#DIM DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM DYNAMIC WEAPON_ID
#DIM DYNAMIC WPN_MATERIAL_NEEDS, WPN_材質種類数, ITEM_LENGTH
#DIMS SORT_COLUMN

;入力受付
REDRAW 1
ONEINPUTS
REDRAW 0
CLEARLINE 1
PRINTL
IF ISNUMERIC(RESULTS)
    RESULT = TOINT(RESULTS)
    ;キャンセルボタン
    IF RESULT == 9999999
        RETURN -1
        ;カテゴリタブ切り替え
    ELSEIF INRANGE(RESULT, 0, 6)
        HO_ITEM_MENU_PAGE_LEFT = 0
        HO_ITEM_MENU_SELECT_ITEM_ID = -1
        HO_ITEM_MENU_CATEGORY = RESULT
        CALL BULK_DISPOSE_MODE_INIT()
        ;アイテム使用
    ELSEIF INRANGE(RESULT, 2000, 2999)
        ITEM_ID = RESULT - 2000
        VARSET RESULTS
        TRYCCALLFORM GET_ITEM_INFO_AT_USING_{ITEM_ID}
            CALL ITEM_USING_COMMON(RESULTS)
            IF HO_ITEM_STOCK:ITEM_ID == 0
                HO_ITEM_MENU_SELECT_ITEM_ID = -1
            ENDIF
        CATCH
            DEBUGPRINTFORML (警告@ITEM_MENU)ITEM_ID:{ITEM_ID}のアイテム使用時情報が未定義です
        ENDCATCH
        ;衣装部位タブ切り替え
    ELSEIF  HO_ITEM_MENU_CATEGORY == 2 && INRANGE(RESULT, 1000, 1999)
        HO_ITEM_CRAFT_SELECT_CLOTH_PARTS = RESULT - 1000
        HO_ITEM_MENU_PAGE_LEFT = 0
        RETURN
        ;ページ処理
    ELSEIF INRANGE(RESULT, 9000, 9001)
        IF RESULT == 9000
            HO_ITEM_MENU_PAGE_LEFT --
        ELSE
            HO_ITEM_MENU_PAGE_LEFT ++
        ENDIF
    ELSEIF INRANGE(RESULT, 1000000, 2999999)
        ;クラフト可能なアイテム ITEM_ID + 1000000, クラフト不可能なアイテム ITEM_ID + 2000000
        HO_ITEM_CRAFT_NUM_PRODUCTION = 1
        HO_CRAFT_RECIPE_ID = 0
        HO_ITEM_MENU_SELECT_ITEM_ID = (RESULT - 1000000)
        RETURN
    ENDIF
ELSE
    IF DIC_CONTAINSKEY(RESULTS, "SORT")
        SORT_COLUMN = %DIC_GET(RESULTS, "SORT")%
        IF SORT_COLUMN == HO_ITEM_MENU_CURRENT_SORT_COLUMN
            HO_ITEM_MENU_CURRENT_SORT_ORDER ++
            IF HO_ITEM_MENU_CURRENT_SORT_ORDER > 2
                HO_ITEM_MENU_CURRENT_SORT_COLUMN '= ""
                HO_ITEM_MENU_CURRENT_SORT_ORDER = 0
            ENDIF
        ELSE
            HO_ITEM_MENU_CURRENT_SORT_COLUMN = %SORT_COLUMN%
            HO_ITEM_MENU_CURRENT_SORT_ORDER = 1
        ENDIF
    ELSEIF DIC_CONTAINSKEY(RESULTS, "WEAPON_DID")
        IF HO_ITEM_MENU_BULK_DISPOSE_MODE == -1
            CALL EQUIP_OVERVIEW_MAIN(TOINT(DIC_GET(RESULTS, "WEAPON_DID")))
            ;CALL CHANGE_EQUIPMENT_MENU_WEAPON(TOINT(DIC_GET(RESULTS, "WEAPON_DID")))
        ELSE
            CALL BULK_DISPOSE_MODE_SWITCH_TARGET(DIC_GETINT(RESULTS, "WEAPON_DID"))
        ENDIF
    ELSEIF DIC_CONTAINSKEY(RESULTS, "FAVORITE_FLAG")
        CALL EQUIP_SWITCH_FAVORITE_FLAG(TOINT(DIC_GET(RESULTS, "FAVORITE_FLAG")))
    ELSEIF DIC_CONTAINSKEY(RESULTS, "BULK_DISPOSE_MODE")
        IF HO_ITEM_MENU_BULK_DISPOSE_MODE == -1
            HO_ITEM_MENU_BULK_DISPOSE_MODE = HO_ITEM_MENU_CATEGORY
        ELSE
            CALL BULK_DISPOSE_MODE_INIT()
        ENDIF
    ELSEIF DIC_CONTAINSKEY(RESULTS, "BULK_DISPOSE_EXEC")
        CALL BULK_DISPOSE_MODE_EXEC_DISPOSE()
    ELSEIF DIC_CONTAINSKEY(RESULTS, "RUNE_PAGE_PREV")
        HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT --
    ELSEIF DIC_CONTAINSKEY(RESULTS, "RUNE_PAGE_NEXT")
        HO_ITEM_CRAFT_SELECT_RUNE_PAGE_LEFT ++
    ENDIF
ENDIF

@BULK_DISPOSE_MODE_INIT
HO_ITEM_MENU_BULK_DISPOSE_MODE = -1
VARSET HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID

@BULK_DISPOSE_MODE_SWITCH_TARGET(TARGET_DID)
#DIM TARGET_DID

VARI IDX
;既に対象が選択されている場合は選択解除
IDX = FINDELEMENT(HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID, TARGET_DID)
IF IDX != -1
    HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID:IDX = 0
    RETURN 0
ENDIF

;お気に入り指定されている場合は削除不可
IF DT_CELL_GET("WEAPON_STOCK", TARGET_DID, "FAVORITE_FLAG", 1) == 1
    CALL COLOR_PRINTW(@"この装備はお気に入り指定されているため破棄できません", カラー_注意)
    RETURN 0
ENDIF

;誰かが装備している場合は削除不可
IF DT_CELL_GET("WEAPON_STOCK", TARGET_DID, "EQUIP_CHARA_ID", 1) >= 0
    CALL COLOR_PRINTW(@"この装備は装備者がいるため破棄できません", カラー_注意)
    RETURN 0
ENDIF

;対象が最大数の場合はエラー
IDX = FINDELEMENT(HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID, 0)
IF IDX == -1
    CALL COLOR_PRINTW(@"一括廃棄対象が最大です({HO_ITEM_MENU_MAX_BULK_DISPOSE_NUM}個まで)", カラー_注意)
    RETURN 0
ENDIF

;対象が未選択の場合は対象を追加
HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID:IDX = TARGET_DID
RETURN 1

@BULK_DISPOSE_MODE_EXEC_DISPOSE()
#DIM TARGET_NUM

TARGET_NUM = FINDELEMENT(HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID, 0)
IF !TARGET_NUM
    CALL COLOR_PRINTW(@"一括廃棄対象が未選択です", カラー_注意)
    RETURN 0
ENDIF
CALL COLOR_PRINTL(@"合計{TARGET_NUM}個の装備を一括廃棄します。破棄された武器は完全に失われます。よろしいですか？", カラー_注意)
CALL ASK_YN()
IF RESULT
    RETURN 0
ENDIF
VARI I
FOR I, 0, TARGET_NUM
    CALL DELETE_WEAPON(HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID:I)
NEXT
VARSET HO_ITEM_MENU_BULK_DISPOSE_TARGET_DID
RETURN 1