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:{カラー_白}@[戻る]@/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

repo_name: napo/erafl

license: unknown


code:
;-------------------------------------------------
; ショップメニュー画面
; SHOP_NAME 在庫情報を定義した関数名
; SHOP_MESSAGE 画面に表示する商店の名称
; SHOP_STOCK_ARRAY 購入後の在庫情報を保持するための配列
;                  在庫をセーブデータとして保持したい場合指定
;                  指定する変数はERHファイルに定義したセーブデータ型広域変数である必要がある
;                  (ex.QUEST_14_DIC_SHOP_STOCK_0,フォルメンの露店)
;-------------------------------------------------
@HO_SHOP_MENU(SHOP_NAME, SHOP_MESSAGE = "アイテムの購入", SHOP_STOCK_ARRAY = "")
#DIMS SHOP_NAME
#DIMS SHOP_MESSAGE
#DIMS SHOP_STOCK_ARRAY
#DIM CONST WINDOW_ID = 0
#DIM DYNAMIC LINE_NUM

;初期処理
HO_SHOP_MENU_PAGE_LEFT = 0
HO_SHOP_MENU_SELECT_ITEM_STOCK_IDX = -1
HO_SHOP_MENU_CATEGORY = 0
HO_SHOP_MENU_BUY_AMOUNT = 1
HO_SHOP_MENU_STOCK_ARRAY = %SHOP_STOCK_ARRAY%

HO_SHOP_NAME = %SHOP_NAME%

LINE_NUM = LINECOUNT

WHILE 1
    LINE_NUM = LINECOUNT
    REDRAW 0
    CALL WndMgr_DestroyWindow(-1)
    CALL HO_DRAW_SHOP_MENU_WINDOW_PARENT(SHOP_MESSAGE)
    CALL WndMgr_DisplayAll()
    REDRAW 1
    CALL HO_SHOP_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_SHOP_MENU_WINDOW_PARENT(SHOP_MESSAGE)
#DIMS SHOP_MESSAGE
#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_SHOP_MENU_CATEGORY = カラー_選択中

CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@S:1@@C:{カラー_注釈}@◇　%SHOP_MESSAGE%　◇@/C@@/S@")
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_白}@所持金:%TOSTR(MONEY, "###,###,##0")%　名誉点:%TOSTR(QST_PRESTIGE_POINT, "###,##0")%　淫堕点:%TOSTR(QST_LEWD_POINT, "###,##0")%@/C@")

CALL HO_DRAW_SHOP_MENU_WINDOW_LEFT()
SELECTCASE HO_SHOP_MENU_CATEGORY
    CASE 0
        CALL HO_DRAW_SHOP_MENU_WINDOW_RIGHT()
    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_SHOP_MENU_WINDOW_LEFT(MODULE_ID)
#DIM MODULE_ID
#DIM CONST WINDOW_ID = 1
#DIM CONST WND_WIDTH  = 64
#DIM CONST WND_HEIGHT = 37
#DIM DYNAMIC L_CNT
#DIM DYNAMIC F_COL, 10

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

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

;ヘッダー
;-------------------------------------------------
;SHOP_ID = 1はギルドの名誉点引き換え用
IF HO_SHOP_NAME == "ギルドショップ"
    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:{カラー_選択不可}@　[クエスト]@/C@"
ENDIF
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, LOCALS)
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
;-------------------------------------------------

SELECTCASE HO_SHOP_MENU_CATEGORY
        ;アイテム
    CASE 0 TO 2,5
        CALL HO_DRAW_SHOP_MENU_WINDOW_PRINT_DETAIL_ITEM(WINDOW_ID)
        ;武器
    CASEELSE
ENDSELECT

@HO_DRAW_SHOP_MENU_WINDOW_RIGHT(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 F_COL
#DIM DYNAMIC ERR_FLG

;アイテム関連
#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC ITEM_ID
#DIM  DYNAMIC ASSET
#DIM  DYNAMIC PRICE
#DIMS DYNAMIC STR_ITEM_PRICE
#DIM  DYNAMIC SELL_TYPE
#DIMS DYNAMIC DICS_SHOP_STOCK, MAX_SHOP_STOCKNUM
#DIM  DYNAMIC STOCK_IDX
#DIM  DYNAMIC ITEM_NUM
#DIM  DYNAMIC ITEM_CAN_BUY = 0
#DIM  DYNAMIC SHOP_STOCK
#DIM  DYNAMIC STOCK_LIMITED_FLAG
;武器関連
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC MATERIAL
#DIM  DYNAMIC EQUIP_TYPE
#DIM  DYNAMIC CLOTH_PART
;スキル関連
#DIMS DYNAMIC LIST_SKILL
#DIMS DYNAMIC SKILL_DEF_NAME
#DIM  DYNAMIC SKILL_LV
#DIMS DYNAMIC TOOLTIP
#DIMS DYNAMIC STR_SKILL
#DIM  DYNAMIC SKILL_GENRE

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

STOCK_IDX = HO_SHOP_MENU_SELECT_ITEM_STOCK_IDX
IF STOCK_IDX >= 1000000
    STOCK_IDX -= 1000000
ENDIF

CALL HO_SHOP_MANAGE_GET_STOCK(HO_SHOP_NAME, DICS_SHOP_STOCK)
ITEM_ID = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_ID"))
;価格,ショップ側で定義していればそちらを優先する
IF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_PRICE")
    PRICE = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_PRICE"))
ELSE
    CALL GET_ITEM_INFO(ITEM_ID, ITEM_PRICE)
    PRICE = RESULT
ENDIF

IF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_ID")
    CALL GET_ITEM_NAME(ITEM_ID)
    ITEM_NAME = %RESULTS%
ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "CLOTH_ID")
    ITEM_ID = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "CLOTH_ID"))
    CLOTH_PART = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "CLOTH_PART"))
    CALL GET_CLOTH_NAME(CLOTH_PART, ITEM_ID)
    ITEM_NAME = %RESULTS%
ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_ID")
    ITEM_ID = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_ID"))
    WEAPON_RANK = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_RANK"))
    EQUIP_TYPE = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "EQUIP_TYPE"))
    MATERIAL = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "MATERIAL"))
    ITEM_NAME = %DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_NAME")%%WEAPON_RANK > 0 ? @" +{WEAPON_RANK}" # ""%
    CALL GET_WEAPON_STATUS(ITEM_ID, MATERIAL, EQUIP_TYPE, WEAPON_RANK)
ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "RUNE_ID")
    SKILL_DEF_NAME = %DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "RUNE_ID")%
    SKILL_LV = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "RUNE_LV"))
    SKILL_GENRE = WPN_SKILL_GET_GENRE(SKILL_DEF_NAME)
    CALL SKILL_GET_NAME(SKILL_GENRE, SKILL_DEF_NAME, 1)
    ITEM_NAME = %RESULTS%
    ITEM_NAME '= @"付呪のルーン:<%ITEM_NAME%Lv{SKILL_LV}>"
ENDIF

;ヘッダー
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))

IF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_ID")
    ;概要欄
    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
    ;販売タイプ取得
    CALL GET_ITEM_INFO(ITEM_ID,ITEM_SELL_TYPE)
    SELL_TYPE = RESULT
    ;販売物が衣装の場合
ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "CLOTH_ID")
    ;概要欄
    VARSET RESULTS
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・【衣装】@/C@")
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_白}@　衣装装着部位:%CLOTH_PART_NAME:CLOTH_PART%@/C@")
    ;販売物が武器、レリックの場合
ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_ID")
    ;ステータス欄
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・%EQUIP_TYPE == 0 ? "【武器】" # "【レリック】"%@/C@")
    L_CNT ++
    LOCALS '= ""
    FOR LOCAL, 0, WPN_MAX_STATUSNUM
        IF LOCAL != WPN_脅威選定
            LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME:LOCAL%:{WPN_STATUS:LOCAL}@/C@", 16, 1)
        ELSE
            SIF !EQUIP_TYPE
                LOCALS += TAG_PRINT_SHAPE(@"@C:{カラー_白}@%WPN_STATUS_NAME:LOCAL%:%WPN_脅威選定文字列:(WPN_STATUS:LOCAL)%@/C@", 16, 1)
        ENDIF
    NEXT
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%LOCALS%")
    L_CNT ++
    ;付与されているスキル
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・【装備スキル】@/C@")
    ;パッシブスキル
    LIST_SKILL = %DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "PASSIVE_WEAPON_SKILL")%
    IF LIST_SKILL != ""
        LOCALS '= ""
        FOR LOCAL, 0, LIST_COUNT(LIST_SKILL)
            IF LOCAL == 0 || LOCAL % 2 == 0
                SKILL_DEF_NAME = %LIST_GET(LIST_SKILL, LOCAL)%
            ELSE
                SKILL_LV = TOINT(LIST_GET(LIST_SKILL, LOCAL))
                CALL GET_SKILL_DESC(SKILL_DEF_NAME, 武器スキル_パッシブ, SKILL_LV, 1)
                TOOLTIP = %RESULTS%
                LOCALS += @"@B:DUMMY$%TOOLTIP%@<%GET_WPN_SKILL_NAME(SKILL_DEF_NAME, 武器スキル_パッシブ)%Lv{SKILL_LV}> @/B@"
            ENDIF
        NEXT
        STR_SKILL '= @"@C:{カラー_黄緑}@%LOCALS%@/C@"
    ENDIF
    ;アクティブスキル
    LIST_SKILL = %DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "ACTIVE_WEAPON_SKILL")%
    IF LIST_SKILL != ""
        LOCALS '= ""
        FOR LOCAL, 0, LIST_COUNT(LIST_SKILL)
            IF LOCAL == 0 || LOCAL % 2 == 0
                SKILL_DEF_NAME = %LIST_GET(LIST_SKILL, LOCAL)%
            ELSE
                SKILL_LV = TOINT(LIST_GET(LIST_SKILL, LOCAL))
                CALL GET_SKILL_DESC(SKILL_DEF_NAME, 武器スキル_アクティブ, SKILL_LV, 1)
                TOOLTIP = %RESULTS%
                LOCALS += @"@B:DUMMY$%TOOLTIP%@<%GET_WPN_SKILL_NAME(SKILL_DEF_NAME, 武器スキル_アクティブ)%Lv{SKILL_LV}> @/B@"
            ENDIF
        NEXT
        STR_SKILL += @"@C:{カラー_オレンジ}@%LOCALS%@/C@"
    ENDIF
    ;販売タイプ取得
    SELL_TYPE = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_SELL_TYPE"))
ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "RUNE_ID")
    ;概要欄
    VARSET RESULTS
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・【付呪のルーン】@/C@")
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_白}@　クラフト時に付呪枠がある武器に対して用いることでスキルを付与することが出来る@/C@")
    L_CNT++
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@・【スキル効果】@/C@")
    CALL GET_SKILL_DESC(SKILL_DEF_NAME, SKILL_GENRE, SKILL_LV, 1)
    LOCALS = %HTML_TOPLAINTEXT(RESULTS)%
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"%LOCALS%")
    ;アクティブスキルならクールタイムも表示
    IF SKILL_GENRE == 武器スキル_アクティブ
        CALL WPN_SKILL_GET_COOLTIME(SKILL_DEF_NAME, SKILL_LV)
        LOCALS = %TOSTR(RESULT)%
        CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_白}@・クールタイム:%LOCALS%@/C@")
    ENDIF
ENDIF
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　%STR_SKILL%")

;フッター
;-------------------------------------------------
;アイテムデータ取得
IF SELL_TYPE == 0
    ASSET = MONEY
ELSEIF SELL_TYPE == 1
    ASSET = QST_PRESTIGE_POINT
ELSEIF SELL_TYPE == 2
    ASSET = QST_LEWD_POINT
ENDIF
HO_SHOP_MENU_SUM_PRICE = PRICE * HO_SHOP_MENU_BUY_AMOUNT
IF HO_SHOP_MENU_STOCK_ARRAY != ""
    IF DIC_CONTAINSKEY(GETVARS(HO_SHOP_MENU_STOCK_ARRAY + @":{STOCK_IDX}"), "SHOP_STOCK")
        SHOP_STOCK = TOINT(DIC_GET(GETVARS(HO_SHOP_MENU_STOCK_ARRAY + @":{STOCK_IDX}"), "SHOP_STOCK"))
        STOCK_LIMITED_FLAG = 1
    ENDIF
ENDIF

;購入情報出力
L_CNT = WND_HEIGHT - 9
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_選択不可}@―@/C@" * ((WND_WIDTH / 2) - 2))
LOCALS '= ""
IF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_ID")
    LOCALS '= "所持数: "
    LOCALS += @" %TOSTR(HO_ITEM_STOCK:ITEM_ID, "#0")%　　　"
ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "CLOTH_ID")
    LOCALS '= "所持数: "
    LOCALS += @" %TOSTR(HAVE_CLOTH:CLOTH_PART:ITEM_ID, "#0")%　　　"
ENDIF
LOCALS += "商店在庫: "
IF SHOP_STOCK >= 0 && STOCK_LIMITED_FLAG
    LOCALS += @" %TOSTR(SHOP_STOCK, "#0")%"
ELSEIF !STOCK_LIMITED_FLAG
    LOCALS += @" 無制限"
ENDIF
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@C:{カラー_注釈}@%LOCALS%@/C@")
LOCALS '= "購入数: "
LOCALS += @" %TOSTR(HO_SHOP_MENU_BUY_AMOUNT, "##")% "
LOCALS = %TAG_PRINT_SHAPE(LOCALS, 15, 1, 0)%
IF HO_SHOP_MENU_BUY_AMOUNT > 1
    LOCALS += @"@B:20@[-5]@/B@"
ELSE
    LOCALS += @"@C:{カラー_選択不可}@[-5]@/C@"
ENDIF
IF HO_SHOP_MENU_BUY_AMOUNT > 1
    LOCALS += @"@B:21@[-1]@/B@"
ELSE
    LOCALS += @"@C:{カラー_選択不可}@[-1]@/C@"
ENDIF
IF ASSET >= (HO_SHOP_MENU_BUY_AMOUNT + 1) * PRICE && ((STOCK_LIMITED_FLAG && SHOP_STOCK > 0) || !STOCK_LIMITED_FLAG)
    LOCALS += @"@B:22@[+1]@/B@"
ELSE
    LOCALS += @"@C:{カラー_選択不可}@[+1]@/C@"
ENDIF
IF ASSET >= (HO_SHOP_MENU_BUY_AMOUNT + 5) * PRICE && ((STOCK_LIMITED_FLAG && SHOP_STOCK > 0) || !STOCK_LIMITED_FLAG)
    LOCALS += @"@B:23@[+5]@/B@"
ELSE
    LOCALS += @"@C:{カラー_選択不可}@[+5]@/C@"
ENDIF
CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"%LOCALS%")

IF STOCK_LIMITED_FLAG && SHOP_STOCK <= 0
    L_CNT ++
    CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"在庫がありません")
ELSE
    IF SELL_TYPE == 0
        IF ASSET >= HO_SHOP_MENU_SUM_PRICE
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　所持金:%TOSTR(MONEY,"###,###,##0")%　→　@C:{カラー_オレンジ}@%TOSTR(MONEY - HO_SHOP_MENU_SUM_PRICE,"###,###,##0")% (-%TOSTR(HO_SHOP_MENU_SUM_PRICE, "#,##0")%)@/C@")
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@B:{BTN_ID + ITEM_ID}@@C:{カラー_白}@[購入する]@/C@@/B@")
        ELSE
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"所持金が足りません")
        ENDIF
    ELSEIF SELL_TYPE == 1
        IF ASSET >= HO_SHOP_MENU_SUM_PRICE
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　名誉点:%TOSTR(QST_PRESTIGE_POINT,"###,###,##0")%　→　@C:{カラー_オレンジ}@%TOSTR(QST_PRESTIGE_POINT - HO_SHOP_MENU_SUM_PRICE,"###,###,##0")% (-%TOSTR(HO_SHOP_MENU_SUM_PRICE, "#,##0")%)@/C@")
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@B:{BTN_ID + ITEM_ID}@@C:{カラー_白}@[購入する]@/C@@/B@")
        ELSE
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"名誉点が足りません")
        ENDIF
    ELSEIF SELL_TYPE == 2
        IF ASSET >= HO_SHOP_MENU_SUM_PRICE
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"　淫堕点:%TOSTR(QST_LEWD_POINT,"###,###,##0")%　→　@C:{カラー_オレンジ}@%TOSTR(QST_LEWD_POINT - HO_SHOP_MENU_SUM_PRICE,"###,###,##0")% (-%TOSTR(HO_SHOP_MENU_SUM_PRICE, "#,##0")%)@/C@")
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"@B:{BTN_ID + ITEM_ID}@@C:{カラー_白}@[購入する]@/C@@/B@")
        ELSE
            L_CNT ++
            CALL WndMgr_TextSet(WINDOW_ID, L_CNT++, @"淫堕点が足りません")
        ENDIF
    ENDIF
ENDIF

;-------------------------------------------------
;アイテム明細リスト
;-------------------------------------------------
@HO_DRAW_SHOP_MENU_WINDOW_PRINT_DETAIL_ITEM(WINDOW_ID)
#DIM WINDOW_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
#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 ITEM_ID
#DIM  DYNAMIC STOCK_IDX
#DIM  DYNAMIC PRICE
#DIMS DYNAMIC STR_ITEM_PRICE
#DIM  DYNAMIC SELL_TYPE
#DIMS DYNAMIC DICS_SHOP_STOCK, MAX_SHOP_STOCKNUM
;武器関連
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC MATERIAL
#DIM  DYNAMIC EQUIP_TYPE
;衣装
#DIM  DYNAMIC CLOTH_PART

;明細リスト作成
;-------------------------------------------------
DETAIL_LINECOUNT = 0
L_CNT = 0
FOR STOCK_IDX, 0, MAX_SHOP_STOCKNUM
    ;商店在庫取得
    VARSET DICS_SHOP_STOCK
    CALL HO_SHOP_MANAGE_GET_STOCK(HO_SHOP_NAME, DICS_SHOP_STOCK)
    SIF DICS_SHOP_STOCK:STOCK_IDX == ""
        CONTINUE

    IF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "SHOP_STOCK")
        SIF !TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "SHOP_STOCK"))
            CONTINUE
    ENDIF
    ;アイテムデータ取得
    IF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_ID")
        ITEM_ID = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_ID"))
        CALL GET_ITEM_INFO(ITEM_ID, ITEM_SELL_TYPE)
        SELL_TYPE = RESULT
        CALL GET_ITEM_NAME(ITEM_ID)
        ITEM_NAME = %RESULTS%
    ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "CLOTH_ID")
        ITEM_ID =  TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "CLOTH_ID"))
        CLOTH_PART = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "CLOTH_PART"))
        CALL GET_CLOTH_NAME(CLOTH_PART, ITEM_ID)
        ITEM_NAME = %RESULTS%
    ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_ID")
        ITEM_ID   = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_ID"))
        SELL_TYPE = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "SELL_TYPE"))
        WEAPON_RANK = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_RANK"))
        ITEM_NAME = %DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "WEAPON_NAME")%%WEAPON_RANK > 0 ? @" +{WEAPON_RANK}" # ""%
    ELSEIF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "RUNE_ID")
        VARS SKILL_DEF_NAME
        VARS SKILL_NAME
        VARI SKILL_LV
        VARI GENRE

        SKILL_DEF_NAME = %DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "RUNE_ID")%
        SKILL_LV = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "RUNE_LV"))
        GENRE = WPN_SKILL_GET_GENRE(SKILL_DEF_NAME)
        CALL SKILL_GET_NAME(GENRE, SKILL_DEF_NAME, 1)
        SKILL_NAME = %RESULTS%
        ITEM_NAME '= @"ﾙｰﾝ:<%SKILL_NAME%Lv{SKILL_LV}>"

    ENDIF
    ITEM_NAME = %TAG_PRINT_SHAPE(ITEM_NAME, 15, 1, 0)%
    ;価格,ショップ側で定義していればそちらを優先する
    IF DIC_CONTAINSKEY(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_PRICE")
        PRICE = TOINT(DIC_GET(DICS_SHOP_STOCK:STOCK_IDX, "ITEM_PRICE"))
    ELSE
        CALL GET_ITEM_INFO(ITEM_ID, ITEM_PRICE)
        PRICE = RESULT
    ENDIF

    STR_ITEM_PRICE = %TAG_PRINT_SHAPE(TOSTR(PRICE, "###,##0"), 8, 1, 0)%
    ;明細出力
    DETAIL_LIST:DETAIL_LINECOUNT '= @"@B:{BTN_ID + STOCK_IDX}@@C:{カラー_白}@[%ITEM_NAME%] … %STR_ITEM_PRICE%@/C@@/B@"
    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_SHOP_MENU_PAGE_LEFT, MAX_ROW * (HO_SHOP_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_SHOP_MENU_PAGE_LEFT > 0 ? @"@B:9000@<<@/B@ " # "   "
    STR_FOOTER += @"%TOSTR(HO_SHOP_MENU_PAGE_LEFT + 1, "..")% "
    STR_FOOTER += HO_SHOP_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

@HO_SHOP_MENU_WINDOW_INPUT(MODULE_ID)
#DIM MODULE_ID
#DIM DYNAMIC ITEM_ID
#DIMS DYNAMIC ITEM_NAME
#DIM  DYNAMIC SELL_TYPE
#DIM  DYNAMIC STOCK_IDX
#DIM  DYNAMIC SHOP_STOCK
#DIM  DYNAMIC MATERIAL_NEEDS, ITEM_LENGTH
#DIM  DYNAMIC WEAPON_ID
#DIM  DYNAMIC WEAPON_RANK
#DIM  DYNAMIC WPN_MATERIAL_NEEDS, WPN_材質種類数, ITEM_LENGTH
#DIMS DYNAMIC STOCK_ARRAY
#DIMS DYNAMIC DIC_STOCK_DATA
#DIM  DYNAMIC CLOTH_PART
#DIMS DYNAMIC DICS_SHOP_STOCK, MAX_SHOP_STOCKNUM

STOCK_IDX = HO_SHOP_MENU_SELECT_ITEM_STOCK_IDX
SHOP_STOCK = -1
;商店在庫取得
IF HO_SHOP_MENU_STOCK_ARRAY != "" && STOCK_IDX != -1
    STOCK_ARRAY '= @"%HO_SHOP_MENU_STOCK_ARRAY%:{STOCK_IDX}"
    DIC_STOCK_DATA = %GETVARS(STOCK_ARRAY)%
    IF DIC_CONTAINSKEY(DIC_STOCK_DATA, "SHOP_STOCK")
        SHOP_STOCK = TOINT(DIC_GET(DIC_STOCK_DATA, "SHOP_STOCK"))
    ENDIF
ELSEIF STOCK_IDX != -1
    ;セーブされる有限の在庫がない場合は通常の在庫情報を読み出し
    CALL HO_SHOP_MANAGE_GET_STOCK(HO_SHOP_NAME, DICS_SHOP_STOCK)
    DIC_STOCK_DATA = %DICS_SHOP_STOCK:STOCK_IDX%
ENDIF

;入力受付
ONEINPUT
CLEARLINE 1
PRINTL

;キャンセルボタン
IF RESULT == 9999999
    RETURN -1
ELSEIF INRANGE(RESULT, 0, 6)
    STOCK_IDX = -1
    HO_SHOP_MENU_CATEGORY = RESULT
    ;購入数増減
ELSEIF INRANGE(RESULT, 20,23)
    SELECTCASE RESULT
        CASE 20
            HO_SHOP_MENU_BUY_AMOUNT = MAX(1, HO_SHOP_MENU_BUY_AMOUNT - 5)
        CASE 21
            HO_SHOP_MENU_BUY_AMOUNT = MAX(1, HO_SHOP_MENU_BUY_AMOUNT - 1)
        CASE 22
            HO_SHOP_MENU_BUY_AMOUNT = MIN(99, HO_SHOP_MENU_BUY_AMOUNT + 1)
        CASE 23
            HO_SHOP_MENU_BUY_AMOUNT = MIN(99, HO_SHOP_MENU_BUY_AMOUNT + 5)
    ENDSELECT
    IF HO_SHOP_MENU_BUY_AMOUNT > SHOP_STOCK && SHOP_STOCK != -1
        HO_SHOP_MENU_BUY_AMOUNT = SHOP_STOCK
    ENDIF
    ;購入アイテム選択
ELSEIF INRANGE(RESULT, 2000, 2999)
    ITEM_ID = RESULT - 2000
    IF DIC_CONTAINSKEY(DIC_STOCK_DATA, "ITEM_ID")
        CALL GET_ITEM_INFO(ITEM_ID,ITEM_SELL_TYPE)
        SELL_TYPE = RESULT
        CALL GET_ITEM_NAME(ITEM_ID)
        ITEM_NAME = %RESULTS%
        CALL CHANGE_ITEM_STOCK(ITEM_ID, HO_SHOP_MENU_BUY_AMOUNT)
    ELSEIF DIC_CONTAINSKEY(DIC_STOCK_DATA, "CLOTH_ID")
        CLOTH_PART = TOINT(DIC_GET(DIC_STOCK_DATA, "CLOTH_PART"))
        CALL GET_CLOTH_NAME(CLOTH_PART, ITEM_ID)
        ITEM_NAME = %RESULTS%
        SELL_TYPE = TOINT(DIC_GET(DIC_STOCK_DATA, "ITEM_SELL_TYPE"))
        CALL CHANGE_CLOTH_STOCK(CLOTH_PART, ITEM_ID, HO_SHOP_MENU_BUY_AMOUNT)
    ELSEIF DIC_CONTAINSKEY(DIC_STOCK_DATA, "WEAPON_ID")
        WEAPON_RANK = TOINT(DIC_GET(DIC_STOCK_DATA, "WEAPON_RANK"))
        ITEM_NAME = %DIC_GET(DIC_STOCK_DATA, "WEAPON_NAME")%%WEAPON_RANK > 0 ? @" +{WEAPON_RANK}" # ""%
        FOR LOCAL, 0, HO_SHOP_MENU_BUY_AMOUNT
            CALL QST_GET_EQUIP(DIC_STOCK_DATA, 0)
        NEXT
        SELL_TYPE = TOINT(DIC_GET(DIC_STOCK_DATA, "ITEM_SELL_TYPE"))
    ELSEIF DIC_CONTAINSKEY(DIC_STOCK_DATA, "RUNE_ID")
        VARS SKILL_DEF_NAME
        VARS SKILL_NAME
        VARI SKILL_GENRE
        VARI SKILL_LV
        SKILL_DEF_NAME = %DIC_GET(DIC_STOCK_DATA, "RUNE_ID")%
        SKILL_LV = TOINT(DIC_GET(DIC_STOCK_DATA, "RUNE_LV"))
        SKILL_GENRE = WPN_SKILL_GET_GENRE(SKILL_DEF_NAME)
        CALL SKILL_GET_NAME(SKILL_GENRE, SKILL_DEF_NAME, 1)
        ITEM_NAME '= @"ルーン:<%RESULTS%Lv{SKILL_LV}>"
        CALL RUNE_STOCK_CHANGE(SKILL_DEF_NAME, SKILL_LV, HO_SHOP_MENU_BUY_AMOUNT)
        SELL_TYPE = TOINT(DIC_GET(DIC_STOCK_DATA, "ITEM_SELL_TYPE"))
    ENDIF
    IF SELL_TYPE == 0
        MONEY -= HO_SHOP_MENU_SUM_PRICE
    ELSEIF SELL_TYPE == 1
        QST_PRESTIGE_POINT -= HO_SHOP_MENU_SUM_PRICE
    ELSEIF SELL_TYPE == 2
        QST_LEWD_POINT -= HO_SHOP_MENU_SUM_PRICE
    ENDIF
    ;参照元変数に変更した商店在庫を格納
    IF SHOP_STOCK != -1
        DIC_STOCK_DATA = %DIC_SET(DIC_STOCK_DATA, "SHOP_STOCK", TOSTR(SHOP_STOCK - HO_SHOP_MENU_BUY_AMOUNT))%
        SETVAR STOCK_ARRAY, DIC_STOCK_DATA
    ENDIF
    CALL FL_PLAYSE("Money_0.mp3")
    CALLF TAG_PRINT(@"%ITEM_NAME%を@C:{カラー_緑}@{HO_SHOP_MENU_BUY_AMOUNT}@/C@入手しました", 1)
    WAIT
    CLEARLINE 1
    ;商店在庫が有限で、購入した結果現在の購入数が在庫を上回る場合は購入数を調整
    IF SHOP_STOCK != -1
        SIF SHOP_STOCK - HO_SHOP_MENU_BUY_AMOUNT < HO_SHOP_MENU_BUY_AMOUNT
            HO_SHOP_MENU_BUY_AMOUNT = SHOP_STOCK - HO_SHOP_MENU_BUY_AMOUNT
    ENDIF
    ;衣装部位タブ切り替え
ELSEIF  HO_SHOP_MENU_CATEGORY == 2 && INRANGE(RESULT, 1000, 1999)
    HO_ITEM_CRAFT_SELECT_CLOTH_PARTS = RESULT - 1000
    HO_SHOP_MENU_PAGE_LEFT = 0
    RETURN
    ;ページ処理
ELSEIF INRANGE(RESULT, 9000, 9001)
    IF RESULT == 9000
        HO_SHOP_MENU_PAGE_LEFT --
    ELSE
        HO_SHOP_MENU_PAGE_LEFT ++
    ENDIF
ELSEIF INRANGE(RESULT, 1000000, 2999999)
    ;クラフト可能なアイテム ITEM_ID + 1000000, クラフト不可能なアイテム ITEM_ID + 2000000
    HO_SHOP_MENU_BUY_AMOUNT = 1
    HO_SHOP_MENU_SELECT_ITEM_STOCK_IDX = (RESULT - 1000000)
    RETURN
ENDIF

@HO_DRAW_SHOP_MENU_WINDOW_PRINT_DETAIL(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_SHOP_MENU_PAGE_LEFT, MAX_ROW * (HO_SHOP_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_SHOP_MENU_PAGE_LEFT > 0 ? @"@B:9000@<<@/B@ " # "   "
    STR_FOOTER += @"%TOSTR(HO_SHOP_MENU_PAGE_LEFT + 1, "..")% "
    STR_FOOTER += HO_SHOP_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


code:
;-------------------------------------------------
; ショップ在庫管理
;-------------------------------------------------
@HO_SHOP_MANAGE_GET_STOCK(SHOP_NAME, DICS_SHOP_STOCK)
#DIMS SHOP_NAME
#DIMS REF DICS_SHOP_STOCK
VARSET DICS_SHOP_STOCK
TRYCCALLFORM HO_SHOP_MANAGE_SHOP_%SHOP_NAME%(DICS_SHOP_STOCK)
CATCH
    DEBUGPRINTFORML (警告@HO_SHOP_MANAGE):SHOP_ID%SHOP_NAME%に対応する在庫定義関数が存在しません
ENDCATCH

;-------------------------------------------------
;各ショップの在庫定義
;-------------------------------------------------
;ギルドの名誉点引換ショップ
@HO_SHOP_MANAGE_SHOP_ギルドショップ(DICS_SHOP_STOCK)
#DIMS REF DICS_SHOP_STOCK
QUEST_MENU_DIC_SHOP_STOCK_0:0 '= @"[ITEM_ID:{ITEM_技巧の宝玉}]"
QUEST_MENU_DIC_SHOP_STOCK_0:1 '= @"[ITEM_ID:{ITEM_求人書類}]"
QUEST_MENU_DIC_SHOP_STOCK_0:2 '= @"[ITEM_ID:{ITEM_調合技能書}]"
QUEST_MENU_DIC_SHOP_STOCK_0:3 '= @"[ITEM_ID:{ITEM_工作技能書}]"
QUEST_MENU_DIC_SHOP_STOCK_0:4 '= @"[ITEM_ID:{ITEM_淫堕の宝玉}]"
QUEST_MENU_DIC_SHOP_STOCK_0:6 '= @"[ITEM_ID:{ITEM_栄誉勲章}]"
QUEST_MENU_DIC_SHOP_STOCK_0:7 '= @"[ITEM_ID:{ITEM_淫魔の刻印}]"
;在庫をセーブデータに持つので初回のみ読み込み
IF QUEST_MENU_DIC_SHOP_STOCK_0:10 == ""
    {
        QUEST_MENU_DIC_SHOP_STOCK_0:10 '= @"
            [WEAPON_ID:1][EQUIP_TYPE:1][WEAPON_NAME:淫魔の導印]
            [WEAPON_RANK:0][MATERIAL:{WPN_材質_鉄}]
            [PASSIVE_WEAPON_SKILL:WPN_SEXUAL_INITIATIVE,1,]
            [ITEM_PRICE:300][ITEM_SELL_TYPE:2][SHOP_STOCK:1]
            "
    }
    {
        QUEST_MENU_DIC_SHOP_STOCK_0:11 '= @"
            [WEAPON_ID:3][EQUIP_TYPE:1][WEAPON_NAME:淫魔の首枷]
            [WEAPON_RANK:0][MATERIAL:{WPN_材質_鋼}]
            [PASSIVE_WEAPON_SKILL:WPN_SEXUAL_FOLLOWER,1,]
            [ITEM_PRICE:300][ITEM_SELL_TYPE:2][SHOP_STOCK:1]
            "
    }
ENDIF

QUEST_MENU_DIC_SHOP_STOCK_0:15 = %ITEM_STAGED_SHOP_STOCK_MANAGEMENT(QUEST_MENU_DIC_SHOP_STOCK_0:15, ITEM_拳技秘伝書, "300,1000,3000,", "1,1,-1,")%

ARRAYCOPY "QUEST_MENU_DIC_SHOP_STOCK_0", "DICS_SHOP_STOCK"

;;;- 段階的に価格を上げられる在庫管理
;;;    - DICS_SHOP_STOCK: 在庫管理配列の要素
;;;    - ITEM_ID: アイテムID
;;;    - LIST_PRICE: ロットごとの価格を指定したLIST
;;;    - LIST_STOCK: ロットごとの在庫数を指定したLIST
;;;       - LIST_STOCKに-1を指定したロットは在庫無制限ロットとして扱う
@ITEM_STAGED_SHOP_STOCK_MANAGEMENT(DICS_SHOP_STOCK, ITEM_ID, LIST_PRICE, LIST_STOCK)
#FUNCTIONS
#DIMS DICS_SHOP_STOCK
#DIM ITEM_ID
#DIMS LIST_PRICE
#DIMS LIST_STOCK
#DIM CONST INFINITE_STOCK = -1
#DIM SHOP_STOCK
#DIM LOT_ID

LOT_ID = DIC_GETINT(DICS_SHOP_STOCK, "LOT_ID")
LOT_ID = MIN(LOT_ID, LIST_COUNT(LIST_PRICE))

IF DICS_SHOP_STOCK == ""
    SHOP_STOCK = LIST_GETINT(LIST_STOCK, 0)
ELSE
    SHOP_STOCK = DIC_GETINT(DICS_SHOP_STOCK, "SHOP_STOCK")
ENDIF

IF LIST_GETINT(LIST_STOCK, LOT_ID) == INFINITE_STOCK
    DICS_SHOP_STOCK '= @"[ITEM_ID:{ITEM_ID}][ITEM_PRICE:{LIST_GETINT(LIST_PRICE, LOT_ID)}][LOT_ID:{LOT_ID}]"
ELSEIF SHOP_STOCK == 0 && LOT_ID < LIST_COUNT(LIST_STOCK) ;在庫切れの場合はロットIDを上げて補充
    LOT_ID ++
    DICS_SHOP_STOCK '= @"[ITEM_ID:{ITEM_ID}][ITEM_PRICE:{LIST_GETINT(LIST_PRICE, LOT_ID)}][SHOP_STOCK:{LIST_GETINT(LIST_STOCK, LOT_ID)}][LOT_ID:{LOT_ID}]"
ELSE ;テスト中に価格をいじりやすいように、在庫がある場合でも文字列を上書きする
    DICS_SHOP_STOCK '= @"[ITEM_ID:{ITEM_ID}][ITEM_PRICE:{LIST_GETINT(LIST_PRICE, LOT_ID)}][SHOP_STOCK:{SHOP_STOCK}][LOT_ID:{LOT_ID}]"
ENDIF

RETURNF DICS_SHOP_STOCK


code:
;-------------------------------------------------
;アイテム使用時の汎用処理関数
;-------------------------------------------------
@ITEM_USING_COMMON(DICS_ITEM_EFFECT)
#DIMS DICS_ITEM_EFFECT
#DIM  DYNAMIC ITEM_ID
#DIMS DYNAMIC EFFECT_CATEGORY

ITEM_ID = TOINT(DIC_GET(DICS_ITEM_EFFECT, "ITEM_ID"))
CALL GET_ITEM_NAME(ITEM_ID)
EFFECT_CATEGORY = %DIC_GET(DICS_ITEM_EFFECT, "EFFECT_CATEGORY")%

TRYCCALLFORM ITEM_USING_COMMON_%EFFECT_CATEGORY%(DICS_ITEM_EFFECT)
    RETURN 1
CATCH
    DEBUGPRINTFORML ITEM_ID:{ITEM_ID}のEFFECT_CATEGORY:%EFFECT_CATEGORY%は無効なカテゴリ指定です
    THROW
ENDCATCH

;-------------------------------------------------------------------------------
;アイテム使用時の処理関数@ITEM_USING_COMMONから呼ばれるアイテム使用時処理
;[EFFECT_CATEGORY:QUEST_MEDICAL_CARE] クエスト中の体力回復
;-------------------------------------------------------------------------------
@ITEM_USING_COMMON_QUEST_MEDICAL_CARE(DICS_ITEM_EFFECT)
#DIMS DICS_ITEM_EFFECT

;DICS_ITEM_EFFECT関連変数
#DIM  DYNAMIC ITEM_ID
#DIM  DYNAMIC TARGET_NUM
#DIMS DYNAMIC TARGET_CLASS
;#DIMS DYNAMIC EFFECT_CATEGORY
;#DIMS DYNAMIC LIST_EFFECT_CLASS
#DIMS DYNAMIC LIST_EFFECT_RATE
#DIMS DYNAMIC DESCRIPTION_BEFORE_USING

;DICS_ITEM_EFFECT派生変数
#DIMS DYNAMIC ITEM_NAME

#DIM  DYNAMIC SELECTED_CHARA_ID
#DIM  DYNAMIC HEAL_AMOUNT
#DIM  FIRST_LINE

;DICS_ITEM_EFFECTから各種情報を取得
ITEM_ID           = TOINT(DIC_GET(DICS_ITEM_EFFECT, "ITEM_ID"))
TARGET_NUM        = TOINT(DIC_GET(DICS_ITEM_EFFECT, "TARGET_NUM"))
TARGET_CLASS      = %DIC_GET(DICS_ITEM_EFFECT, "TARGET_CLASS")%
;EFFECT_CATEGORY   = %DIC_GET(DICS_ITEM_EFFECT, "EFFECT_CATEGORY")%
;LIST_EFFECT_CLASS = %DIC_GET(DICS_ITEM_EFFECT, "LIST_EFFECT_CLASS")%
LIST_EFFECT_RATE  = %DIC_GET(DICS_ITEM_EFFECT, "LIST_EFFECT_RATE")%
DESCRIPTION_BEFORE_USING = %DIC_GET(DICS_ITEM_EFFECT, "DESCRIPTION_BEFORE_USING")%

;DICS_ITEM_EFFECTの情報から派生情報を取得
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME     = %RESULTS%

;アイテム使用前のメッセージ表示
;-------------------------------------------------
FIRST_LINE = LINECOUNT
WHILE 1
    IF HO_ITEM_STOCK:ITEM_ID == 0 || QST_応急治療点 == 0
        RETURN
    ENDIF
    REDRAW 0
    CLEARLINE LINECOUNT - FIRST_LINE
    CALLF TAG_PRINT(@"%STRFORM(DESCRIPTION_BEFORE_USING)%", 1)
    CALLF TAG_PRINT(@"　%ITEM_NAME%({HO_ITEM_STOCK:ITEM_ID} → @C:{カラー_オレンジ}@{HO_ITEM_STOCK:ITEM_ID -1}@/C@) 応急治療点({QST_応急治療点} → @C:{カラー_オレンジ}@{QST_応急治療点 - 1}@/C@)", 1)
    PRINTL

    CALL CHARA_SELECT_LIST_HEALTH(TARGET_CLASS, TARGET_NUM)
    SELECTED_CHARA_ID = RESULT
    IF SELECTED_CHARA_ID == -1
        RETURN
    ELSE
        HEAL_AMOUNT = (MAXBASE:SELECTED_CHARA_ID:体力 * TOINT(LIST_GET(LIST_EFFECT_RATE, 0))) / 100
        CALL QST_CHANGE_HP(SELECTED_CHARA_ID, HEAL_AMOUNT)
        HO_ITEM_STOCK:ITEM_ID --
        QST_応急治療点 --
        WAIT
    ENDIF
WEND

;アイテム使用処理 / 回復アイテム使用対象選択
@CHARA_SELECT_LIST_HEALTH(TARGET_CLASS, TARGET_NUM)
#DIM  TARGET_NUM
#DIMS TARGET_CLASS
#DIM CONST BTN_ID = 100
#DIM DYNAMIC F_COL
#DIM DYNAMIC CHARA_ID
#DIM HEAL_AMOUNT

FOR LOCAL, 0, QST_PARTYNUM
    CHARA_ID = TOINT((LIST_GET(_LIST_QST_PARTY, LOCAL)))
    LOCALS:0 '= @"@B:{CHARA_ID + BTN_ID}@%ANAME(CHARA_ID)%@/B@"
    LOCALS:0 = %TAG_PRINT_SHAPE(@"%LOCALS:0%", 15, 1, 0)%
    LOCALS:1 = 体力:%FuncTagSetText_CreateColorBarText(BASE:CHARA_ID:体力, MAXBASE:CHARA_ID:体力, 16, カラー_オレンジ, カラー_緑, 0x000000, 1, "▰")%
    LOCALS:2 = %TAG_PRINT_SHAPE("", 15, 1, 0)%
    LOCALS:3 = 気力:%FuncTagSetText_CreateColorBarText(BASE:CHARA_ID:気力, MAXBASE:CHARA_ID:気力, 16, カラー_シアン, カラー_白, 0x000000, 1, "▰")%
    CALLF TAG_PRINT(@"%LOCALS:0%%LOCALS:1%", 5)
    CALLF TAG_PRINT(@"%LOCALS:2%%LOCALS:3%", 5)
    PRINTL
NEXT
PRINTL
CALLF TAG_PRINT(@"@B:9999@[キャンセル]@/C@", 5)

;入力ループ
;-------------------------------------------------
WHILE 1
    REDRAW 1
    ONEINPUT
    CLEARLINE 1
    SELECTCASE RESULT
        CASE 9999
            RETURN -1
        CASEELSE
            CHARA_ID = RESULT - BTN_ID
            IF LIST_INDEXOF(_LIST_QST_PARTY, TOSTR(CHARA_ID)) == -1
                CONTINUE
            ENDIF
            IF MAXBASE:CHARA_ID:体力 == BASE:CHARA_ID:体力
                PRINTFORMW %ANAME(CHARA_ID)%は治療の必要がなさそうだ
                CLEARLINE 1
                CONTINUE
            ENDIF
            RETURN CHARA_ID
    ENDSELECT
WEND

;-------------------------------------------------------------------------------
;アイテム使用時の処理関数@ITEM_USING_COMMONから呼ばれるアイテム使用時処理
;[EFFECT_CATEGORY:QUEST_INSTANT_BUFF] クエスト中の各種食事バフ
;応急治療点から空腹度による判定に変更
;-------------------------------------------------------------------------------
@ITEM_USING_COMMON_QUEST_INSTANT_BUFF(DICS_ITEM_EFFECT)
#DIMS DICS_ITEM_EFFECT

;DICS_ITEM_EFFECT関連変数
#DIM  DYNAMIC ITEM_ID
#DIM  DYNAMIC TARGET_NUM
#DIMS DYNAMIC TARGET_CLASS
#DIMS DYNAMIC EFFECT_CATEGORY
;#DIMS DYNAMIC LIST_EFFECT_CLASS
;#DIMS DYNAMIC LIST_EFFECT_RATE
#DIMS DYNAMIC DESCRIPTION_BEFORE_USING

;DICS_ITEM_EFFECT派生変数
#DIMS DYNAMIC ITEM_NAME

#DIM  DYNAMIC SELECTED_CHARA_ID
#DIM  DYNAMIC HEAL_AMOUNT
#DIM  FIRST_LINE

#DIM DYNAMIC L_CNT
#DIM DYNAMIC C_ID

;DICS_ITEM_EFFECTから各種情報を取得
ITEM_ID           = TOINT(DIC_GET(DICS_ITEM_EFFECT, "ITEM_ID"))
TARGET_NUM        = TOINT(DIC_GET(DICS_ITEM_EFFECT, "TARGET_NUM"))
TARGET_CLASS      = %DIC_GET(DICS_ITEM_EFFECT, "TARGET_CLASS")%
EFFECT_CATEGORY   = %DIC_GET(DICS_ITEM_EFFECT, "EFFECT_CATEGORY")%
DESCRIPTION_BEFORE_USING = %DIC_GET(DICS_ITEM_EFFECT, "DESCRIPTION_BEFORE_USING")%

;DICS_ITEM_EFFECTの情報から派生情報を取得
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME     = %RESULTS%

;アイテム使用前のメッセージ表示
;-------------------------------------------------
FIRST_LINE = LINECOUNT
WHILE 1
    IF HO_ITEM_STOCK:ITEM_ID == 0
        RETURN
    ENDIF
    REDRAW 0
    CLEARLINE LINECOUNT - FIRST_LINE
    CALLF TAG_PRINT(@"%STRFORM(DESCRIPTION_BEFORE_USING)%", 1)
    CALLF TAG_PRINT(@"　%ITEM_NAME%({HO_ITEM_STOCK:ITEM_ID} → @C:{カラー_オレンジ}@{HO_ITEM_STOCK:ITEM_ID -1}@/C@)    ※食事後、２戦ほどで再度の食事が可能です", 1)
    PRINTL

    CALL CHARA_SELECT_LIST_INSTANT_BUFF(TARGET_CLASS, TARGET_NUM)
    SELECTED_CHARA_ID = RESULT
    IF SELECTED_CHARA_ID == -1
        RETURN
        ;パーティ全体対象の場合の処理
    ELSEIF SELECTED_CHARA_ID == 99999
        FOR L_CNT, 0, QST_PARTYNUM
            C_ID = TOINT(LIST_GET(_LIST_QST_PARTY, L_CNT))
            SIF TCVAR:C_ID:空腹度 < 300 ||  CFLAG:C_ID:QST食事
                CONTINUE
            CFLAG:C_ID:QST食事 = ITEM_ID
            IF HAS_SKILL(C_ID, "VORACITY", スキル_大分類_冒険)
                TCVAR:C_ID:空腹度 = 200
            ELSE
                TCVAR:C_ID:空腹度 = 0
            ENDIF
        NEXT
        HO_ITEM_STOCK:ITEM_ID --
        CALL FL_PLAYSE("Charge_0.mp3")
        PRINTL
        PRINTFORM みんなでおいしく
        SETCOLOR COLOR("イエロー")
        PRINTFORM %ITEM_NAME%
        RESETCOLOR
        PRINTFORMW をいただいた！
        RETURN
    ELSE
        ;食事バフフラグを立てる
        CFLAG:SELECTED_CHARA_ID:QST食事 = ITEM_ID
        ;スキル「健啖」を持っている場合は１戦での空腹状態を維持する
        IF HAS_SKILL(SELECTED_CHARA_ID, "VORACITY", スキル_大分類_冒険)
            TCVAR:SELECTED_CHARA_ID:空腹度 = 200
        ELSE
            ;満腹にする
            TCVAR:SELECTED_CHARA_ID:空腹度 = 0
        ENDIF
        HO_ITEM_STOCK:ITEM_ID --
        CALL FL_PLAYSE("Charge_0.mp3")
    ENDIF
WEND

;アイテム使用処理 / アイテム使用対象選択
@CHARA_SELECT_LIST_INSTANT_BUFF(TARGET_CLASS, TARGET_NUM)
#DIM  TARGET_NUM
#DIMS TARGET_CLASS
#DIM CONST BTN_ID = 100
#DIM DYNAMIC F_COL
#DIM DYNAMIC CHARA_ID
#DIM DYNAMIC HUNGRY_AMOUNT

FOR LOCAL, 0, QST_PARTYNUM
    CHARA_ID = TOINT((LIST_GET(_LIST_QST_PARTY, LOCAL)))
    LOCALS:0 '= @"@B:{CHARA_ID + BTN_ID}@%ANAME(CHARA_ID)%@/B@"
    LOCALS:0 = %TAG_PRINT_SHAPE(@"%LOCALS:0%", 15, 1, 0)%
    LOCALS:1 = 体力:%FuncTagSetText_CreateColorBarText(BASE:CHARA_ID:体力, MAXBASE:CHARA_ID:体力, 16, カラー_オレンジ, カラー_緑, 0x000000, 1, "▰")%
    LOCALS:2 = %TAG_PRINT_SHAPE("", 15, 1, 0)%
    LOCALS:3 = 気力:%FuncTagSetText_CreateColorBarText(BASE:CHARA_ID:気力, MAXBASE:CHARA_ID:気力, 16, カラー_シアン, カラー_白, 0x000000, 1, "▰")%
    IF CFLAG:CHARA_ID:QST食事
        TRYCALLFORM GET_ITEM_NAME_{CFLAG:CHARA_ID:QST食事}()
        LOCALS:4 = [★食事済: %RESULTS%]
    ELSEIF TCVAR:CHARA_ID:空腹度 <= 100
        LOCALS:4 = [×さっき食べたばかりだ]
    ELSEIF TCVAR:CHARA_ID:空腹度 <= 200
        LOCALS:4 = [△少し食事を取るには早い]
    ELSE
        LOCALS:4 =
    ENDIF
    CALLF TAG_PRINT(@"%LOCALS:0%%LOCALS:1%", 5)
    CALLF TAG_PRINT(@"%LOCALS:2%%LOCALS:3%  %LOCALS:4%", 5)
    PRINTL
NEXT
PRINTL
;パーティ全体対象の場合
;-------------------------------------------------
IF TARGET_NUM == 99
    ;全員が空腹でない、あるいは食事直後の場合
    FOR LOCAL, 0, QST_PARTYNUM
        CHARA_ID = TOINT((LIST_GET(_LIST_QST_PARTY, LOCAL)))
        SIF CFLAG:CHARA_ID:QST食事 || TCVAR:CHARA_ID:空腹度 < 300
            HUNGRY_AMOUNT ++
    NEXT
    IF HUNGRY_AMOUNT == QST_PARTYNUM
        PRINTFORMW 既にみんな食事を取っている
        CLEARLINE 1
        RETURN -1
    ENDIF
    PRINTFORML この食事をパーティ全体で取りますか？（既に食事をしている・満腹であるキャラは除外されます）
    CALL ASK_YN("パーティ全体で食事にする", "やめる")
    IF RESULT
        CLEARLINE 1
        RETURN -1
    ENDIF
    CLEARLINE 2
    RETURN 99999
ENDIF

CALLF TAG_PRINT(@"@B:9999@[キャンセル]@/C@", 5)

;単数対象の場合の入力ループ
;-------------------------------------------------
WHILE 1
    REDRAW 1
    ONEINPUT
    CLEARLINE 1
    SELECTCASE RESULT
        CASE 9999
            RETURN -1
        CASEELSE
            CHARA_ID = RESULT - BTN_ID
            IF LIST_INDEXOF(_LIST_QST_PARTY, TOSTR(CHARA_ID)) == -1
                CONTINUE
            ENDIF
            IF CFLAG:CHARA_ID:QST食事
                PRINTFORMW %ANAME(CHARA_ID)%は既に食事を摂っている
                CLEARLINE 1
                CONTINUE
            ENDIF
            ;空腹度300以上でないと食事不可
            IF TCVAR:CHARA_ID:空腹度 < 300
                PRINTFORMW %ANAME(CHARA_ID)%はまだ空腹になっていない　腹ごなしをしよう
                CLEARLINE 1
                CONTINUE
            ENDIF
            RETURN CHARA_ID
    ENDSELECT
WEND
;-------------------------------------------------------------------------------
;アイテム使用時の処理関数@ITEM_USING_COMMONから呼ばれるアイテム使用時処理
;[EFFECT_CATEGORY:QUEST_CHANGE_CHARA_EFFECT] クエスト中の各種キャラクター効果の変更
;-------------------------------------------------------------------------------
@ITEM_USING_COMMON_QUEST_CHANGE_CHARA_EFFECT(DICS_ITEM_EFFECT)
#DIMS DICS_ITEM_EFFECT

;DICS_ITEM_EFFECT関連変数
#DIM  DYNAMIC ITEM_ID
#DIM  DYNAMIC TARGET_NUM
#DIMS DYNAMIC TARGET_CLASS
#DIMS DYNAMIC EFFECT_CATEGORY
#DIMS DYNAMIC LIST_EFFECT_CLASS
#DIMS DYNAMIC LIST_EFFECT_RATE
#DIMS DYNAMIC DESCRIPTION_BEFORE_USING

;DICS_ITEM_EFFECT派生変数
#DIMS DYNAMIC ITEM_NAME

#DIM  DYNAMIC SELECTED_CHARA_ID
#DIM  DYNAMIC HEAL_AMOUNT
#DIM  FIRST_LINE

;DICS_ITEM_EFFECTから各種情報を取得
ITEM_ID           = TOINT(DIC_GET(DICS_ITEM_EFFECT, "ITEM_ID"))
TARGET_NUM        = TOINT(DIC_GET(DICS_ITEM_EFFECT, "TARGET_NUM"))
TARGET_CLASS      = %DIC_GET(DICS_ITEM_EFFECT, "TARGET_CLASS")%
EFFECT_CATEGORY   = %DIC_GET(DICS_ITEM_EFFECT, "EFFECT_CATEGORY")%
LIST_EFFECT_CLASS = %DIC_GET(DICS_ITEM_EFFECT, "LIST_EFFECT_CLASS")%
LIST_EFFECT_RATE  = %DIC_GET(DICS_ITEM_EFFECT, "LIST_EFFECT_RATE")%
DESCRIPTION_BEFORE_USING = %DIC_GET(DICS_ITEM_EFFECT, "DESCRIPTION_BEFORE_USING")%

;DICS_ITEM_EFFECTの情報から派生情報を取得
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME     = %RESULTS%

;アイテム使用前のメッセージ表示
;-------------------------------------------------
FIRST_LINE = LINECOUNT
WHILE 1
    IF HO_ITEM_STOCK:ITEM_ID == 0
        RETURN
    ENDIF
    REDRAW 0
    CLEARLINE LINECOUNT - FIRST_LINE
    CALLF TAG_PRINT(@"%STRFORM(DESCRIPTION_BEFORE_USING)%", 1)
    CALLF TAG_PRINT(@"　%ITEM_NAME%({HO_ITEM_STOCK:ITEM_ID} → @C:{カラー_オレンジ}@{HO_ITEM_STOCK:ITEM_ID -1}@/C@)", 1)
    PRINTL
    CALL ITEM_USING_COMMON_QUEST_CHANGE_CHARA_EFFECT_SELECT_LIST(TARGET_CLASS, TARGET_NUM, LIST_EFFECT_CLASS)
    SELECTED_CHARA_ID = RESULT
    IF SELECTED_CHARA_ID == -1
        RETURN
    ENDIF
    IF LIST_INDEXOF(LIST_EFFECT_CLASS, "REDUCE_ESTRUS") != -1
        IF TCVAR:SELECTED_CHARA_ID:媚薬 > 0
            TCVAR:SELECTED_CHARA_ID:媚薬 --
            HO_ITEM_STOCK:ITEM_ID --
            PRINTFORMW %ANAME(SELECTED_CHARA_ID)%は冷静さを取り戻したようだ
        ENDIF
    ENDIF
WEND

;アイテム使用処理 / 回復アイテム使用対象選択
@ITEM_USING_COMMON_QUEST_CHANGE_CHARA_EFFECT_SELECT_LIST(TARGET_CLASS, TARGET_NUM, LIST_EFFECT_CLASS)
#DIM  TARGET_NUM
#DIMS TARGET_CLASS
#DIMS LIST_EFFECT_CLASS
#DIM CONST BTN_ID = 100
#DIM DYNAMIC F_COL
#DIM DYNAMIC CHARA_ID
#DIM HEAL_AMOUNT

FOR LOCAL, 0, QST_PARTYNUM
    CHARA_ID = TOINT((LIST_GET(_LIST_QST_PARTY, LOCAL)))
    LOCALS:0 '= @"@B:{CHARA_ID + BTN_ID}@%ANAME(CHARA_ID)%@/B@"
    LOCALS:0 = %TAG_PRINT_SHAPE(@"%LOCALS:0%", 15, 1, 0)%
    LOCALS:1 = 体力:%FuncTagSetText_CreateColorBarText(BASE:CHARA_ID:体力, MAXBASE:CHARA_ID:体力, 16, カラー_オレンジ, カラー_緑, 0x000000, 1, "▰")%
    LOCALS:2 = %TAG_PRINT_SHAPE("", 15, 1, 0)%
    LOCALS:3 = 気力:%FuncTagSetText_CreateColorBarText(BASE:CHARA_ID:気力, MAXBASE:CHARA_ID:気力, 16, カラー_シアン, カラー_白, 0x000000, 1, "▰")%
    CALLF TAG_PRINT(@"%LOCALS:0%%LOCALS:1%", 5)
    CALLF TAG_PRINT(@"%LOCALS:2%%LOCALS:3%", 5)
    LOCALS:4 '= ""
    IF TCVAR:CHARA_ID:媚薬 > 0
        LOCALS:4 '= @"%TAG_PRINT_SHAPE(@"", 15, 1, 0)%"
        LOCALS:4 += @"@C:{カラー_ピンク}@発情Lv:{TCVAR:CHARA_ID:媚薬}@/C@"
    ENDIF
    IF LOCALS:4 != ""
        CALLF TAG_PRINT(@"%LOCALS:4%", 5)
    ENDIF
    PRINTL
NEXT
PRINTL
CALLF TAG_PRINT(@"@B:9999@[キャンセル]@/C@", 5)

;入力ループ
;-------------------------------------------------
WHILE 1
    REDRAW 1
    ONEINPUT
    CLEARLINE 1
    SELECTCASE RESULT
        CASE 9999
            RETURN -1
        CASEELSE
            CHARA_ID = RESULT - BTN_ID
            IF LIST_INDEXOF(_LIST_QST_PARTY, TOSTR(CHARA_ID)) == -1
                CONTINUE
            ENDIF
            IF LIST_INDEXOF(LIST_EFFECT_CLASS, "REDUCE_ESTRUS") != -1
                IF TCVAR:CHARA_ID:媚薬 < 1
                    PRINTFORMW %ANAME(CHARA_ID)%は治療の必要がなさそうだ
                    CLEARLINE 1
                    CONTINUE
                ENDIF
            ENDIF
            RETURN CHARA_ID
    ENDSELECT
WEND


code:
;-------------------------------------------------------------------------------
;アイテム使用時の処理関数@ITEM_USING_COMMONから呼ばれるアイテム使用時処理
;[EFFECT_CATEGORY:ADD_BASE_POINT] ステータス基礎値操作
;-------------------------------------------------------------------------------
@ITEM_USING_COMMON_ADD_BASE_POINT(DICS_ITEM_EFFECT)
#DIMS DICS_ITEM_EFFECT
CALL _ITEM_USING_COMMON_BASE_POINT(DICS_ITEM_EFFECT)

;-------------------------------------------------------------------------------
;アイテム使用時の処理関数@ITEM_USING_COMMONから呼ばれるアイテム使用時処理
;[EFFECT_CATEGORY:EXTEND_BASE_POINT] ステータス基礎値操作
;-------------------------------------------------------------------------------
@ITEM_USING_COMMON_EXTEND_BASE_POINT(DICS_ITEM_EFFECT)
#DIMS DICS_ITEM_EFFECT
CALL _ITEM_USING_COMMON_BASE_POINT(DICS_ITEM_EFFECT)

;-------------------------------------------------------------------------------
;内部処理：スキルポイント関連処理
;-------------------------------------------------------------------------------
@_ITEM_USING_COMMON_BASE_POINT(DICS_ITEM_EFFECT)
#DIMS DICS_ITEM_EFFECT

;DICS_ITEM_EFFECT関連変数
#DIM  DYNAMIC ITEM_ID
;#DIM  DYNAMIC TARGET_NUM
;#DIMS DYNAMIC TARGET_CLASS
;#DIMS DYNAMIC EFFECT_CATEGORY
;#DIMS DYNAMIC LIST_EFFECT_CLASS
;#DIMS DYNAMIC LIST_EFFECT_RATE
#DIMS DYNAMIC DESCRIPTION_BEFORE_USING

;DICS_ITEM_EFFECT派生変数
#DIMS DYNAMIC ITEM_NAME

;その他
#DIM  DYNAMIC SELECTED_CHARA_ID
#DIM  DYNAMIC TARGET_TEMP
#DIM  DYNAMIC FIRST_LINE

;-------------------------------------------------
;DICS_ITEM_EFFECTから各種情報を取得
;-------------------------------------------------
ITEM_ID           = TOINT(DIC_GET(DICS_ITEM_EFFECT, "ITEM_ID"))
;TARGET_NUM        = TOINT(DIC_GET(DICS_ITEM_EFFECT, "TARGET_NUM"))
;TARGET_CLASS      = %DIC_GET(DICS_ITEM_EFFECT, "TARGET_CLASS")%
;EFFECT_CATEGORY   = %DIC_GET(DICS_ITEM_EFFECT, "EFFECT_CATEGORY")%
;LIST_EFFECT_CLASS = %DIC_GET(DICS_ITEM_EFFECT, "LIST_EFFECT_CLASS")%
;LIST_EFFECT_RATE  = %DIC_GET(DICS_ITEM_EFFECT, "LIST_EFFECT_RATE")%
DESCRIPTION_BEFORE_USING = %DIC_GET(DICS_ITEM_EFFECT, "DESCRIPTION_BEFORE_USING")%

;DICS_ITEM_EFFECTの情報から派生情報を取得
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME     = %RESULTS%

;-------------------------------------------------
;キャラ選択ループ
;-------------------------------------------------
FIRST_LINE = LINECOUNT
WHILE 1
	REDRAW 0
	CLEARLINE LINECOUNT - FIRST_LINE
	;アイテムが0個になったら終了
	SIF HO_ITEM_STOCK:ITEM_ID == 0
		RETURN

	;アイテム効果/個数表示
	CALLF TAG_PRINT(@"%STRFORM(DESCRIPTION_BEFORE_USING)%", 1)
	CALLF TAG_PRINT(@"　%ITEM_NAME%({HO_ITEM_STOCK:ITEM_ID})", 1)
	PRINTL

	;リストを表示してキャラ選択
	CALL SELECT_CHARA_LIST_ONLY_LOGIC_SLG("SAME_FACTION", ITEM_NAME)
	CLEARLINE 1
	SELECTED_CHARA_ID = RESULT
	;キャラが選択されなかった場合は終了
	SIF SELECTED_CHARA_ID == -1
		RETURN
	PRINTL

	;TARGET情報の退避＆設定
	TARGET_TEMP = TARGET
	TARGET = SELECTED_CHARA_ID
	;スキルポイント操作画面を表示
	CALL _ITEM_USING_COMMON_BASE_POINT_CHANGE_OPERATION(DICS_ITEM_EFFECT)
	;TARGET情報の復元
	TARGET = TARGET_TEMP
WEND

;-------------------------------------------------------------------------------
;内部処理：ポイント操作画面呼び出し処理
;-------------------------------------------------------------------------------
@_ITEM_USING_COMMON_BASE_POINT_CHANGE_OPERATION(DICS_ITEM_EFFECT)
#DIMS DICS_ITEM_EFFECT

;DICS_ITEM_EFFECT関連変数
#DIM  DYNAMIC ITEM_ID
;#DIM  DYNAMIC TARGET_NUM
;#DIMS DYNAMIC TARGET_CLASS
#DIMS DYNAMIC EFFECT_CATEGORY
#DIMS DYNAMIC LIST_EFFECT_CLASS
#DIMS DYNAMIC LIST_EFFECT_RATE
;#DIMS DYNAMIC DESCRIPTION_BEFORE_USING

;DICS_ITEM_EFFECT派生変数
#DIMS DYNAMIC ITEM_NAME
#DIMS DYNAMIC ADDABLE_GENRES

;POINT_OPERATE用変数
;#DIMS DYNAMIC ITEM_NAME
#DIMS DYNAMIC LIST_SUBJECT_NAME
#DIMS DYNAMIC LIST_BASE_POINT
#DIMS DYNAMIC LIST_LIMIT_POINT
#DIM  DYNAMIC CHANGE_RATE
#DIM  DYNAMIC ITEM_STOCK
#DIM  DYNAMIC LARGE_CHANGE_VALUE
#DIMS DYNAMIC LIST_CHANGE_VALUE
#DIMS DYNAMIC LIST_ITEM_USE_NUM

;その他
#DIMS CONST ARRAY_POINT_NAME = "HP"
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC BASE_POINT
#DIM  DYNAMIC LIMIT_POINT

;-------------------------------------------------
;DICS_ITEM_EFFECTから各種情報を取得
;-------------------------------------------------
ITEM_ID           = TOINT(DIC_GET(DICS_ITEM_EFFECT, "ITEM_ID"))
;TARGET_NUM        = TOINT(DIC_GET(DICS_ITEM_EFFECT, "TARGET_NUM"))
;TARGET_CLASS      = %DIC_GET(DICS_ITEM_EFFECT, "TARGET_CLASS")%
EFFECT_CATEGORY   = %DIC_GET(DICS_ITEM_EFFECT, "EFFECT_CATEGORY")%
LIST_EFFECT_CLASS = %DIC_GET(DICS_ITEM_EFFECT, "LIST_EFFECT_CLASS")%
LIST_EFFECT_RATE  = %DIC_GET(DICS_ITEM_EFFECT, "LIST_EFFECT_RATE")%
;DESCRIPTION_BEFORE_USING = %DIC_GET(DICS_ITEM_EFFECT, "DESCRIPTION_BEFORE_USING")%

;DICS_ITEM_EFFECTの情報から派生情報を取得
CALL GET_ITEM_NAME(ITEM_ID)
ITEM_NAME     = %RESULTS%
ADDABLE_GENRES = %_ITEM_USING_COMMON_BASE_POINT_GET_ADDABLE_GENRE(LIST_EFFECT_CLASS)%

;ポイント操作関数に渡す情報の作成
VARSET LIST_SUBJECT_NAME
VARSET LIST_BASE_POINT
VARSET LIST_LIMIT_POINT

;1個当たり変更量
CHANGE_RATE = TOINT(LIST_GET(LIST_EFFECT_RATE, 0))
;最大変更回数＝アイテムの所持数
ITEM_STOCK = HO_ITEM_STOCK:ITEM_ID
;変更ボタン(大)の操作量
LARGE_CHANGE_VALUE = 5
;大分類ごとの情報設定
FOR L_CNT, 0, 1
	IF GROUPMATCH(ADDABLE_GENRES, ARRAY_POINT_NAME:L_CNT)
		;項目名
		LIST_SUBJECT_NAME '= LIST_ADD(LIST_SUBJECT_NAME, ARRAY_POINT_NAME:L_CNT)
		;ポイントの初期状態と上限値(効果カテゴリから判定して設定)
		CALL _ITEM_USING_COMMON_BASE_POINT_GET_TARGET_POINT(L_CNT, LIST_GET(LIST_EFFECT_CLASS, 0))
		BASE_POINT  = RESULT:0
		LIMIT_POINT = RESULT:1
		LIST_BASE_POINT   '= LIST_ADD(LIST_BASE_POINT  , TOSTR(BASE_POINT))
		LIST_LIMIT_POINT  '= LIST_ADD(LIST_LIMIT_POINT , TOSTR(LIMIT_POINT))
	ENDIF
NEXT

;ポイント操作関数呼び出し
CALL _ITEM_USING_COMMON_BASE_POINT_OPERATE(ITEM_NAME, LIST_SUBJECT_NAME, LIST_BASE_POINT, LIST_LIMIT_POINT, CHANGE_RATE, ITEM_STOCK, LARGE_CHANGE_VALUE)
LIST_CHANGE_VALUE '= RESULTS:0
LIST_ITEM_USE_NUM '= RESULTS:1

;変更した内容を反映する
IF RESULT
	CALL _ITEM_USING_COMMON_BASE_POINT_CHANGE_CONFIRM(ITEM_ID, EFFECT_CATEGORY, LIST_EFFECT_CLASS, LIST_CHANGE_VALUE, LIST_ITEM_USE_NUM)
ENDIF

;-------------------------------------------------------------------------------
;内部処理：操作するステータスの種類を取得
;現在はHPのみ
;-------------------------------------------------------------------------------
@_ITEM_USING_COMMON_BASE_POINT_GET_ADDABLE_GENRE(LIST_EFFECT_CLASS)
#FUNCTIONS
#DIMS LIST_EFFECT_CLASS
#DIMS DYNAMIC ADDABLE_GENRES

;ADD_BASE_HP：基礎HP増加
IF LIST_INDEXOF(LIST_EFFECT_CLASS, "ADD_BASE_HP") != -1
	ADDABLE_GENRES '= "HP"
ENDIF

RETURNF ADDABLE_GENRES

;-------------------------------------------------------------------------------
;内部処理：基礎値変更確定変更確定
;-------------------------------------------------------------------------------
@_ITEM_USING_COMMON_BASE_POINT_CHANGE_CONFIRM(ITEM_ID, EFFECT_CATEGORY, LIST_EFFECT_CLASS, LIST_CHANGE_POINT, LIST_ITEM_USE_NUM)
#DIM  ITEM_ID
#DIMS EFFECT_CATEGORY
#DIMS LIST_EFFECT_CLASS
#DIMS LIST_CHANGE_POINT
#DIMS LIST_ITEM_USE_NUM

#DIM  DYNAMIC CHANGE_POINT
#DIM  DYNAMIC ITEM_USE_NUM
#DIM  DYNAMIC GENRE_NO
#DIM  DYNAMIC L_CNT

#DIMS DYNAMIC CONFIRM_MESSAGE

;　対象：体力
IF LIST_INDEXOF(LIST_EFFECT_CLASS, "ADD_BASE_HP") != -1
	CONFIRM_MESSAGE '= @"@C:{カラー_注意}@%ANAME(TARGET)%の体力が上昇しました@/@"
	GENRE_NO = 0
ENDIF

;変更情報の取得
CHANGE_POINT = TOINT(LIST_GET(LIST_CHANGE_POINT, 0))
ITEM_USE_NUM = TOINT(LIST_GET(LIST_ITEM_USE_NUM, 0))
;メッセージ表示
CALLF TAG_PRINT(CONFIRM_MESSAGE, 1)
;ポイント更新処理
CALL _ITEM_USING_COMMON_BASE_POINT_CHANGE_CONFIRM_POINT(ITEM_ID, GENRE_NO, LIST_GET(LIST_EFFECT_CLASS, 0), CHANGE_POINT, ITEM_USE_NUM)
WAIT

;-------------------------------------------------------------------------------
;内部処理：ポイント更新
;-------------------------------------------------------------------------------
@_ITEM_USING_COMMON_BASE_POINT_CHANGE_CONFIRM_POINT(ITEM_ID, GENRE_NO, EFFECT_CATEGORY, CHANGE_POINT, ITEM_USE_NUM)
#DIM  ITEM_ID
#DIM  GENRE_NO
#DIMS EFFECT_CATEGORY
#DIM  CHANGE_POINT
#DIM  ITEM_USE_NUM

#DIMS CONST ARRAY_POINT_NAME = "体力"
#DIMS CONFIRM_MESSAGE
#DIM  BASE_POINT_BEFORE
#DIM  BASE_POINT_AFTER
#DIM  LIMIT_POINT

;変更前のポイント情報を取得
CALL _ITEM_USING_COMMON_BASE_POINT_GET_TARGET_POINT(GENRE_NO, EFFECT_CATEGORY)
BASE_POINT_BEFORE = RESULT:0
LIMIT_POINT       = RESULT:1

;ポイントを加算
CALL _ITEM_USING_COMMON_BASE_POINT_ADD_TARGET_POINT(GENRE_NO, EFFECT_CATEGORY, CHANGE_POINT)

;変更後のポイント情報を取得
CALL _ITEM_USING_COMMON_BASE_POINT_GET_TARGET_POINT(GENRE_NO, EFFECT_CATEGORY)
BASE_POINT_AFTER = RESULT:0
LIMIT_POINT      = RESULT:1

;アイテム数を減らす
HO_ITEM_STOCK:ITEM_ID -= ITEM_USE_NUM

;メッセージ表示
CONFIRM_MESSAGE '= @"　@C:{カラー_注意}@%ARRAY_POINT_NAME:GENRE_NO% :{BASE_POINT_BEFORE, 2} → {BASE_POINT_AFTER, 2}@/@"
CALLF TAG_PRINT(CONFIRM_MESSAGE, 1)

;-------------------------------------------------------------------------------
;内部処理：指定した効果カテゴリのポイント情報を取得
;-------------------------------------------------------------------------------
@_ITEM_USING_COMMON_BASE_POINT_GET_TARGET_POINT(GENRE_NO, EFFECT_CATEGORY)
#DIM GENRE_NO
#DIMS EFFECT_CATEGORY
#DIM DYNAMIC BASE_POINT
#DIM DYNAMIC LIMIT_POINT

SELECTCASE EFFECT_CATEGORY
	CASE "ADD_BASE_HP"
		;カテゴリ：スキルポイント増加
		;取得内容：スキルポイント/スキルポイント上限
		BASE_POINT  = MAXBASE:TARGET:体力
		LIMIT_POINT = 3000
ENDSELECT

RETURN BASE_POINT, LIMIT_POINT

;-------------------------------------------------------------------------------
;内部処理：指定した効果カテゴリのポイントを加算
;-------------------------------------------------------------------------------
;・広域変数を直接変更する。
;　[EFFECT_CATEGORY:ADD_BASE_POINT]    BASE_SKILL_POINT, HO_ITEM_STOCK
;　[EFFECT_CATEGORY:EXTEND_SKILL_POINT] CFLAG:＊＊スキル拡張上限, HO_ITEM_STOCK
@_ITEM_USING_COMMON_BASE_POINT_ADD_TARGET_POINT(GENRE_NO, EFFECT_CATEGORY, CHANGE_POINT)
#DIM  GENRE_NO
#DIMS EFFECT_CATEGORY
#DIM  CHANGE_POINT

SELECTCASE EFFECT_CATEGORY
	CASE "ADD_BASE_HP"
		;体力を加算
		MAXBASE:TARGET:体力 += CHANGE_POINT
		BASE:TARGET:体力 += CHANGE_POINT
ENDSELECT


code:
;===============================================================================
;スキルポイント操作関数
;===============================================================================
@_ITEM_USING_COMMON_BASE_POINT_OPERATE(ITEM_NAME, LIST_SUBJECT_NAME, LIST_INIT_POINT, LIST_LIMIT_POINT, CHANGE_RATE, ITEM_STOCK, LARGE_CHANGE_VALUE)
#DIMS ITEM_NAME
#DIMS LIST_SUBJECT_NAME
#DIMS LIST_INIT_POINT
#DIMS LIST_LIMIT_POINT
#DIM  CHANGE_RATE
#DIM  ITEM_STOCK
#DIM  LARGE_CHANGE_VALUE

#DIM CONST BTN_OFFSET = 100

#DIMS DYNAMIC ARGUMENT_DATA
#DIMS DYNAMIC BUTTON_TEXT
#DIM  DYNAMIC LIST_SIZE
#DIMS DYNAMIC LIST_CHANGE_VALUE
#DIMS DYNAMIC LIST_CURT_CHG_POINT		;List Current Change Point
#DIMS DYNAMIC LIST_CURT_ITEM_USE_NUM	;List Current Item Used Number
#DIM  DYNAMIC TOTAL_CURT_CHG_POINT		;Total Current Change Point
#DIM  DYNAMIC TOTAL_CURT_ITEM_USE_NUM	;Total Current Item Used Number
#DIM  DYNAMIC BUTTON_NO_BASE
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC INPUT_VALUE
#DIM  DYNAMIC SUBJECT_NO
#DIM  DYNAMIC CHANGE_NO
#DIM  DYNAMIC REST_ITEM_STOCK
#DIM  DYNAMIC CONFIRM_ANSWER
#DIM  DYNAMIC EXIT_FLAG
#DIM  DYNAMIC FIRST_LINE

;--------------
;-- 事前処理
;--------------
;表示開始行を記憶
FIRST_LINE = LINECOUNT
;リストの要素数の取得
LIST_SIZE =LIST_COUNT(LIST_SUBJECT_NAME)
;各ボタンを押した際の変更量を設定
LIST_CHANGE_VALUE '= ""
LIST_CHANGE_VALUE '= LIST_ADD(LIST_CHANGE_VALUE, TOSTR(-1 * LARGE_CHANGE_VALUE))
LIST_CHANGE_VALUE '= LIST_ADD(LIST_CHANGE_VALUE, TOSTR(-1))
LIST_CHANGE_VALUE '= LIST_ADD(LIST_CHANGE_VALUE, TOSTR( 1))
LIST_CHANGE_VALUE '= LIST_ADD(LIST_CHANGE_VALUE, TOSTR( 1 * LARGE_CHANGE_VALUE))
;終了判定フラグ
EXIT_FLAG = -1

;--------------
;-- 表示処理
;--------------
REDRAW 0
;1.残数表示
TOTAL_CURT_CHG_POINT = 0
TOTAL_CURT_ITEM_USE_NUM = 0
FOR L_CNT, 0, LIST_SIZE
	TOTAL_CURT_CHG_POINT    += TOINT(LIST_GET(LIST_CURT_CHG_POINT   , L_CNT))
	TOTAL_CURT_ITEM_USE_NUM += TOINT(LIST_GET(LIST_CURT_ITEM_USE_NUM, L_CNT))
NEXT
REST_ITEM_STOCK = ITEM_STOCK - TOTAL_CURT_ITEM_USE_NUM
CALLF TAG_PRINT(@"　%ITEM_NAME% ({ITEM_STOCK} → @C:{カラー_オレンジ}@{REST_ITEM_STOCK}@/C@)", 1)
PRINTL
;2.項目ごとのボタンを作成
FOR L_CNT, 0, LIST_SIZE
	BUTTON_NO_BASE = BTN_OFFSET * (L_CNT + 1)
	{
		CALL _ITEM_USING_COMMON_BASE_POINT_OPERATE_CREATE_BUTTON(
			BUTTON_NO_BASE,
			LIST_GET(LIST_SUBJECT_NAME  , L_CNT),
			TOINT(LIST_GET(LIST_INIT_POINT    , L_CNT)),
			TOINT(LIST_GET(LIST_LIMIT_POINT   , L_CNT)),
			LIST_CHANGE_VALUE,
			TOINT(LIST_GET(LIST_CURT_CHG_POINT, L_CNT)),
			REST_ITEM_STOCK
			)
	}
NEXT
;3.決定/キャンセルボタン作成
PRINTL
IF TOTAL_CURT_CHG_POINT
	BUTTON_TEXT '= @"@B:9998@[決定]@/B@ @B:9999@[キャンセル]@/B@"
	;変更なしの場合は決定ボタンを押せない
ELSE
	BUTTON_TEXT '= @"@C:{カラー_選択不可}@[決定]@/C@ @B:9999@[キャンセル]@/B@"
ENDIF
CALLF TAG_PRINT(BUTTON_TEXT, 5)
REDRAW 1

;--------------
;-- 入力処理
;--------------
BINPUT
INPUT_VALUE = RESULT
CLEARLINE 1
;PRINTFORMW INPUT_VALUE:{INPUT_VALUE}

;--------------------------
;-- 入力ごとの処理実行部
;--------------------------
SELECTCASE INPUT_VALUE
		;増減ボタン
	CASE BTN_OFFSET * 1 TO ((BTN_OFFSET * (LIST_SIZE + 1)) - 1)
		SUBJECT_NO = INPUT_VALUE / BTN_OFFSET - 1
		CHANGE_NO  = INPUT_VALUE % BTN_OFFSET
		;ポイント変更処理(スキルポイント処理と共通)
		{
			CALL _ITEM_USING_COMMON_SKILL_POINT_OPERATE_CALCULATION(
				CHANGE_NO,
				TOINT(LIST_GET(LIST_INIT_POINT    , SUBJECT_NO)),
				TOINT(LIST_GET(LIST_LIMIT_POINT   , SUBJECT_NO)),
				LIST_CHANGE_VALUE,
				CHANGE_RATE,
				ITEM_STOCK,
				TOINT(LIST_GET(LIST_CURT_ITEM_USE_NUM, SUBJECT_NO)),
				TOTAL_CURT_CHG_POINT
				)
		}
		LIST_CURT_CHG_POINT    '= LIST_SET(LIST_CURT_CHG_POINT   , SUBJECT_NO, TOSTR(RESULT:0))
		LIST_CURT_ITEM_USE_NUM '= LIST_SET(LIST_CURT_ITEM_USE_NUM, SUBJECT_NO, TOSTR(RESULT:1))
		;決定ボタン
	CASE 9998
		;ポイント変更確定処理
		;確認メッセージを表示
		;・個別の確認メッセージが設定されている場合は表示
		TRYCCALLFORM ITEM_USING_COMMON_CONFIRM_MESSAGE_%ITEM_NAME%(ITEM_NAME, TOTAL_CURT_ITEM_USE_NUM)
			;・個別の確認メッセージが設定されていない場合は汎用メッセージを表示
		CATCH
			CALL ITEM_USING_COMMON_CONFIRM_MESSAGE(ITEM_NAME, TOTAL_CURT_ITEM_USE_NUM)
		ENDCATCH
		PRINTL
		CALL ASK_YN()
		CONFIRM_ANSWER = RESULT

		;変更確定時
		IF !CONFIRM_ANSWER
			;結果を格納
			RESULTS:0 '= LIST_CURT_CHG_POINT
			RESULTS:1 '= LIST_CURT_ITEM_USE_NUM
			;終了判定ON(1:変更)
			EXIT_FLAG = 1
		ENDIF
		;変更キャンセルした場合は何もしない(ループする)
		;キャンセルボタン
	CASE 9999
		;キャンセルメッセージを表示
		;変更内容は使用しないで終了する
		VARSET RESULTS
		PRINTW キャンセルしました
		;終了判定ON(0:キャンセル)
		EXIT_FLAG = 0
		;その他
	CASEELSE
		;処理なし
ENDSELECT

;--------------
;-- 終了処理
;--------------
IF EXIT_FLAG != -1
	;次回実行時用に変更内容を初期化
	VARSET LIST_CURT_CHG_POINT
	VARSET LIST_CURT_ITEM_USE_NUM
	;変更/キャンセル結果を返す
	RETURN EXIT_FLAG
ENDIF

;------------------
;-- ループ前処理
;------------------
REDRAW 0
;表示開始行までを消去する
CLEARLINE LINECOUNT - FIRST_LINE
;関数の最初に戻ってループする
RESTART

;-------------------------------------------------------------------------------
;内部処理：ポイント変更ボタン表示
;-------------------------------------------------------------------------------
@_ITEM_USING_COMMON_BASE_POINT_OPERATE_CREATE_BUTTON(BUTTON_NO_BASE, SUBJECT_NAME, INIT_POINT, LIMIT_POINT, LIST_CHANGE_VALUE, CURT_CHG_POINT, REST_ITEM_STOCK)
#DIM  BUTTON_NO_BASE
#DIMS SUBJECT_NAME
#DIM  INIT_POINT
#DIM  LIMIT_POINT
#DIMS LIST_CHANGE_VALUE
#DIM  CURT_CHG_POINT
#DIM  REST_ITEM_STOCK

#DIM  DYNAMIC BUTTON_NO
#DIM  DYNAMIC NOW_POINT
#DIM  DYNAMIC L_CNT
#DIM  DYNAMIC CHANGE_VALUE
#DIMS DYNAMIC NUM_SYMBOL
#DIMS DYNAMIC BUTTON_TEXT
#DIMS DYNAMIC PRINT_TEXT
#DIMS DYNAMIC LIMIT_TEXT

;------------------------
;-- 表示テキストの作成
;------------------------
PRINT_TEXT '= ""

;項目名
PRINT_TEXT += @"　%SUBJECT_NAME% "

;ポイント現在値
;・変更中の場合は色を変更
NOW_POINT = INIT_POINT + CURT_CHG_POINT
IF CURT_CHG_POINT
	PRINT_TEXT += @"@C:{カラー_緑}@{NOW_POINT, 2}@/C@"
ELSE
	PRINT_TEXT += @"{NOW_POINT, 2}"
ENDIF

;ポイント変更量
;・プラス/ゼロの場合は＋記号を追加(マイナスは最初から付いてるので不要)
IF CURT_CHG_POINT >= 0
	NUM_SYMBOL '= "+"
ELSE
	NUM_SYMBOL '= ""
ENDIF

;・変更中の場合は色を変更
IF CURT_CHG_POINT > 0
	PRINT_TEXT += @" (@C:{カラー_緑}@%NUM_SYMBOL%{CURT_CHG_POINT, 2}@/C@)"
ELSE
	PRINT_TEXT += @" (%NUM_SYMBOL%{CURT_CHG_POINT, 2})"
ENDIF

;ポイント上限値
PRINT_TEXT += @" @C:{カラー_注釈}@上限:{LIMIT_POINT, 2}@/C@"

;ポイント増減ボタン
FOR L_CNT, 0, 4
	CHANGE_VALUE = TOINT(LIST_GET(LIST_CHANGE_VALUE, L_CNT))
	BUTTON_NO    = BUTTON_NO_BASE + L_CNT
	PRINT_TEXT += " "

	;ボタンのテキストを設定
	;・プラス/ゼロの場合は＋記号を追加(マイナスは最初から付いてるので不要)
	IF CHANGE_VALUE >= 0
		NUM_SYMBOL '= "+"
	ELSE
		NUM_SYMBOL '= ""
	ENDIF

	BUTTON_TEXT '= @"[%NUM_SYMBOL%{CHANGE_VALUE}]"

	;変更ボタン表示
	;・押せない(押す必要がない)ボタンは選択不可で表示
	;マイナスボタン：これ以上減らせない場合は×
	IF (CHANGE_VALUE < 0) && (CURT_CHG_POINT <= 0)
		PRINT_TEXT += @"@C:{カラー_選択不可}@%BUTTON_TEXT%@/C@"
		;プラスボタン：これ以上増やせない場合は×
	ELSEIF (CHANGE_VALUE > 0) && ((NOW_POINT >= LIMIT_POINT) || (REST_ITEM_STOCK <= 0))
		PRINT_TEXT += @"@C:{カラー_選択不可}@%BUTTON_TEXT%@/C@"
	ELSE
		PRINT_TEXT += @"@B:{BUTTON_NO}@%BUTTON_TEXT%@/B@"
	ENDIF
NEXT

;----------------------------
;-- 作成したテキストを表示
;----------------------------
;PRINTFORML %PRINT_TEXT%
CALLF TAG_PRINT(PRINT_TEXT, 5)