Reference
  Util\Color.txt
  Util\Input.txt
  Util\CommonDialog.txt
  Util\Party.txt
  Util\Status.txt
  Util\FileOperation.txt
  Util\PartyStatusWindow.txt
  Util\Audio.txt
End Reference

Import StdUtilLib
  Math = MathUtil
End Import

Constant CampOperationStatus
  Normal = 0
  Exit = 1
End Constant

Dim g_hPartyStatusWindow

Procedure UpdatePartyStatusWindow()
  Dim we = GetPartyMembers()
  For i = 1 To we.Count
    Dim who = we[i]
    GetInfoWindowCell(g_hPartyStatusWindow, 1, i + 1).Text = who.Name
    GetInfoWindowCell(g_hPartyStatusWindow, 6, i + 1).Text = HanToZen(who.HP)
    GetInfoWindowCell(g_hPartyStatusWindow, 8, i + 1).Text = HanToZen(who.MP)
    Dim text_color = Color.White
    If who.HP = 0 Then
      text_color = Color.Red
    ElseIf who.HP < who.MaxHP / 4 Then
      text_color = Color.Yellow
    End If
    For j = 1 To 8
      GetInfoWindowCell(g_hPartyStatusWindow, j, i + 1).Color = text_color
    Next
  Next
End Procedure

Dim g_ExitingFromCamp = False

Procedure UpdateTime(hWnd)
  Do While Not g_ExitingFromCamp
    Dim elapsed_minutes = GetGameInfo("ElapsedTime") / 600000000L
    Dim elapsed_hours = elapsed_minutes / 60L
    elapsed_minutes -= elapsed_hours * 60L
    Dim time_str = ""
    If elapsed_minutes >= 10 Then
      time_str = HanToZen(CStr(elapsed_hours)) + "：" + HanToZen(CStr(elapsed_minutes))
    Else
      time_str = HanToZen(CStr(elapsed_hours)) + "：０" + HanToZen(CStr(elapsed_minutes))
    End If
    If GetInfoWindowCell(hWnd, 2, 2).Text <> time_str Then
      GetInfoWindowCell(hWnd, 2, 2).Text = time_str
    End If
    Sleep(100)
  Loop
  g_ExitingFromCamp = False
End Procedure

Procedure DoCamp()

  Dim ss = GetScreenSize()

  g_hPartyStatusWindow = CreateEmptyInfoWindow((ss.X - 360) / 2, ss.Y - 132, 360, 120, 8, 5)
  GetInfoWindowCell(g_hPartyStatusWindow, 1, 1).Text = "なまえ"
  GetInfoWindowCell(g_hPartyStatusWindow, 6, 1).Text = "ＨＰ"
  GetInfoWindowCell(g_hPartyStatusWindow, 8, 1).Text = "ＭＰ"
  UpdatePartyStatusWindow()
  
  Dim money_info = CreateEmptyInfoWindow(ss.X - 320, 0, 320, 50, 2, 2)
  GetInfoWindowCell(money_info, 1, 1).Text = "所持金"
  GetInfoWindowCell(money_info, 2, 1).Text = MoneyStr(CheckOurMoney())
  GetInfoWindowCell(money_info, 1, 2).Text = "経過時間"
  GetInfoWindowCell(money_info, 2, 2).Text = ""
  RunThread(UpdateTime, money_info)
  
  Dim exitCode = CampOperationStatus.Normal

  Dim menu_list = {"まほう", "どうぐ", "そうび", "つよさ", "ならび", "セーブ", "そのた"}
  If [RVII].Debugging Then menu_list.Add("DEBUG")
  Dim hMenu = CreateMenu(0, 0, 120, 200, Nothing, Nothing, "キャンプ", menu_list, Nothing, 1)
  Dim index = ProcessMenu(hMenu)
  Do While index > 0
    Dim result = True
    If index = 1 Then
      result = InvokeMagic()
    ElseIf index = 2 Then
      result = UseTool()
    ElseIf index = 3 Then
      result = ChangeEquipment()
    ElseIf index = 4 Then
      result = CheckStatus()
    ElseIf index = 5 Then
      result = ChangeOrder()
    ElseIf index = 6 Then
      If GetPrimaryActor().Area = [Field] Then
        result = SaveData()
      Else
        DoMsg("ここではセーブできません")
      End If
    ElseIf index = 7 Then
      result = ChangeVolume()
    ElseIf index = 8 Then
      result = UseDebugger()
    End If
    If result = True Then
      index = ProcessMenu(hMenu)
    Else
      Exit Do
    End If
  Loop
  DestroyControl(hMenu)
  
  g_ExitingFromCamp = True
  Do While g_ExitingFromCamp
    Sleep(0)
  Loop
  DestroyControl(money_info)

  DestroyControl(g_hPartyStatusWindow)

  Return exitCode

End Procedure

Procedure UseDebugger()
  Dim can_continue = True
  Dim hMenu = CreateMenu(120, 0, 120, 200, Nothing, Nothing, "I AM GOD", _
    {"ADD MAGIC", "ADD TOOL", "INC/DEC HP", "INC/DEC MP", "BATTLE", "CLSCRCAS", "GOANYWHR", "RELDELEM", "NOBATTLE"}, Nothing, 1)
  Dim index = ProcessMenu(hMenu)
  Do While index > 0
    If index = 1 Then
      Dim magic_list = GetElements("Magic")
      Dim magic_menu = CreateNameListBox(magic_list, 240, 0, 240, 200, _
        Nothing, Nothing, "なにを？", 1)
      Dim magic_index = ProcessMenu(magic_menu)
      Do While magic_index > 0
        Dim we = GetPartyMembers()
        Dim target_menu = CreateNameListBox(we, 360, 0, 240, 200, _
          Nothing, Nothing, "だれに？", 1)
        Dim target_index = ProcessMenu(target_menu)
        If target_index > 0 Then
          we[target_index].MagicList.Add(magic_list[magic_index])
        End If
        DestroyControl(target_menu)
        magic_index = ProcessMenu(magic_menu)
      Loop
      DestroyControl(magic_menu)
    ElseIf index = 2 Then
      Dim tool_list = GetElements("Tool")
      Dim tool_menu = CreateNameListBox(tool_list, 240, 0, 240, 200, _
        Nothing, Nothing, "なにを？", 1)
      Dim tool_index = ProcessMenu(tool_menu)
      Do While tool_index > 0
        Dim we = GetPartyMembers()
        Dim target_menu = CreateNameListBox(we, 360, 0, 240, 200, _
          Nothing, Nothing, "だれに？", 1)
        Dim target_index = ProcessMenu(target_menu)
        If target_index > 0 Then
          we[target_index].ToolList.Add(tool_list[tool_index])
        End If
        DestroyControl(target_menu)
        tool_index = ProcessMenu(tool_menu)
      Loop
      DestroyControl(tool_menu)
    ElseIf index = 3 Then
      Dim we = GetPartyMembers()
      Dim target_menu = CreateNameListBox(we, 240, 0, 240, 200, _
        Nothing, Nothing, "だれの？", 1)
      Dim target_index = ProcessMenu(target_menu)
      If target_index > 0 Then
        Dim target = we[target_index]
        Do
          Dim curr = GetInputState()
          If TestInput(curr, Buttons.Up) Then
            target.HP += 1
          ElseIf TestInput(curr, Buttons.Down) Then
            target.HP = Math.Max(target.HP - 1, 0)
          ElseIf TestInput(curr, Buttons.B) Then
            Exit Do
          End If
          UpdatePartyStatusWindow()
          Sleep(20)
        Loop
      End If
      DestroyControl(target_menu)
    ElseIf index = 4 Then
      Dim we = GetPartyMembers()
      Dim target_menu = CreateNameListBox(we, 240, 0, 240, 200, _
        Nothing, Nothing, "だれの？", 1)
      Dim target_index = ProcessMenu(target_menu)
      If target_index > 0 Then
        Dim target = we[target_index]
        Do
          Dim curr = GetInputState()
          If TestInput(curr, Buttons.Up) Then
            target.MP += 1
          ElseIf TestInput(curr, Buttons.Down) Then
            target.MP = Math.Max(target.MP - 1, 0)
          ElseIf TestInput(curr, Buttons.B) Then
            Exit Do
          End If
          UpdatePartyStatusWindow()
          Sleep(20)
        Loop
      End If
      DestroyControl(target_menu)
    ElseIf index = 5 Then
      Dim enemy_list = GetElements("Enemy")
      Dim enemy_menu = CreateNameListBox(enemy_list, 240, 0, 240, 200, _
        Nothing, Nothing, "だれと？", 1)
      Dim enemy_index = ProcessMenu(enemy_menu)
      If enemy_index > 0 Then
        Dim battle_result = 0
        Dim bp = BeginProcess("Area\Battle.txt", True, {enemy_list[enemy_index]})
        Do While Not WaitForCompletion(bp, battle_result)
          Sleep(100)
        Loop
      End If
      DestroyControl(enemy_menu)
    ElseIf index = 6 Then
      ClearScriptCache()
      DoMsg("DONE")
    ElseIf index = 7 Then
      Dim area_list = GetElements("Area")
      Dim area_menu = CreateNameListBox(area_list, 240, 0, 240, 200, _
        Nothing, Nothing, "どこへ？", 1)
      Dim area_index = ProcessMenu(area_menu)
      If area_index > 0 Then
        RaiseEvent("HAVE_TO_GO", area_list[area_index], "Entrance")
        can_continue = False
      End If
      DestroyControl(area_menu)
    ElseIf index = 8 Then
      Dim elem_menu = CreateMenu(240, 0, 240, 200, Nothing, Nothing, "なにを？", _
        {"Magic", "Tool", "Enemy"}, Nothing, 1)
      Dim elem_index = ProcessMenu(elem_menu)
      If elem_index > 0 Then
        If elem_index = 1 Then
          LoadDataSync(0, {"Magic"})
        ElseIf elem_index = 2 Then
          LoadDataSync(0, {"Tool"})
        ElseIf elem_index = 3 Then
          LoadDataSync(0, {"Enemy"})
        End If
        DoMsg("OK")
      End If
      DestroyControl(elem_menu)
    ElseIf index = 9 Then
      If DoYesNoMsg("戦闘をＯＮにしますか") = True Then
        ClearFlag("Debug_NoBattle")
      Else
        SetFlag("Debug_NoBattle")
      End If
    End If
    If can_continue Then
      index = ProcessMenu(hMenu)
    Else
      Exit Do
    End If
  Loop
  DestroyControl(hMenu)
  Return can_continue
End Procedure

Procedure ChangeVolume()
  Dim hMenu = CreateMenu(120, 0, 120, 200, Nothing, Nothing, "音の大きさ", _
    {"ＢＧＭ", "効果音"}, Nothing, 1)
  Dim index = ProcessMenu(hMenu)
  Do While index > 0
    Dim category_name = Nothing
    Dim game_info_name = Nothing
    If index = 1 Then
      game_info_name = "System_MusicVolume"
      category_name = "Music"
    Else
      game_info_name = "System_DefaultVolume"
      category_name = "Default"
    End If
    Dim volume_index = GetGameInfo(game_info_name)
    Dim volume_menu = CreateMenu(240, 0, 120, 200, Nothing, Nothing, "設定", _
      {"大", "中", "小", "無"}, Nothing, volume_index)
    volume_index = ProcessMenu(volume_menu)
    If volume_index > 0 Then
      If volume_index = 1 Then
        SetVolume(category_name, 100)
      ElseIf volume_index = 2 Then
        SetVolume(category_name, 50)
      ElseIf volume_index = 3 Then
        SetVolume(category_name, 25)
      Else
        SetVolume(category_name, 0)
      End If
      SetGameInfo(game_info_name, volume_index)
    End If
    DestroyControl(volume_menu)
    index = ProcessMenu(hMenu)
  Loop
  DestroyControl(hMenu)
  Return True
End Procedure

Procedure ApplyHeroMagic(who, magic, targets)
  
  Dim level_dep = 0
  Dim level_dep_count = 0
  Dim level_list = {who.PPLevel, who.MPLevel}
  Dim level_dep_list = magic.LevelDep
  For i = 1 To level_list.Count
    If level_dep_list[i] > 0 Then
      If level_dep_list[i] <= level_list[i] Then
        level_dep += level_list[i]
      Else
        level_dep = Math.Max(level_list[i] * level_list[i] / level_dep_list[i], 1)
      End If
      level_dep_count += 1
    End If
  Next
  If level_dep_count > 0 Then
    level_dep /= level_dep_count
  Else
    level_dep = 10
  End If

  Dim ability_dep = 0
  Dim ability_dep_count = 0
  Dim ability_list = {who.Strength, who.Vitality, who.Intelligence, who.Agility, who.Luck}
  Dim ability_dep_list = magic.AbilityDep
  For j = 1 To ability_list.Count
    If ability_dep_list[j] > 0 Then
      ability_dep += ability_list[j] * ability_dep_list[j]
      ability_dep_count += ability_dep_list[j]
    End If
  Next
  If ability_dep_count > 0 Then
    ability_dep /= ability_dep_count
  Else
    ability_dep = 5
  End If

  Dim msg_list = CreateList()
  
  For i = 1 To targets.Count

    Dim target = targets[i]

    If Math.TestBit(magic.StatusFX, StatusEffect.Dead) Then
      If TestStatus(target, StatusEffect.Dead) Then
        If magic.Value[1] >= Math.GetRandom(0, 100) Then
          ResetStatus(target, StatusEffect.Dead)
          target.HP = target.MaxHP * magic.Value[2] / 100
          msg_list.Add(target.Name + "は生き返った！")
        Else
          msg_list.Add("しかし" + target.Name + "は生き返らなかった！")
        End If
      End If
    End If

    If magic.DamageType <> 0 AndAlso Not TestStatus(target, StatusEffect.Dead) Then
      If magic.Value[1] > 0 Then
        Dim value = ((magic.Value[1] * 3 + (ability_dep - 5) * 8) * level_dep + Math.GetRandom(1, level_dep + 1) * 21) / 34
        target.HP = Math.Min(target.MaxHP, target.HP + value)
        msg_list.Add(target.Name + "のＨＰが" + HanToZen(value) + "回復した！")
      End If
      If magic.Value[2] > 0 Then
        target.MP = Math.Min(target.MaxMP, target.MP + magic.Value[2])
        msg_list.Add(target.Name + "のＭＰが" + HanToZen(magic.Value[2]) + "回復した！")
      End If
    End If

  Next

  If msg_list.Count = 0 Then
    msg_list.Add("しかし　なにも起こらなかった")
  End If

  UpdatePartyStatusWindow()
  DoMsgV(msg_list)

End Procedure

Procedure SelectTarget(x, y, who, magic)

  If magic.HasEffect Then
    If magic.Always Then
      Dim range = magic.TargetRange
      If range = TargetRange.OneOfUs Then
        Dim items = GetPartyMembers()
        Dim hMenu = CreateNameListBox(items, x, y, 240, 120, _
          Nothing, Nothing, "だれに？", 1)
        Dim index = ProcessMenu(hMenu)
        DestroyControl(hMenu)
        If index > 0 Then
          Return {items[index]}
        Else
          Return Nothing
        End If
      ElseIf range = TargetRange.AllOfUs Then
        Return GetPartyMembers()
      ElseIf range = TargetRange.Own Then
        Return {who}
      End If
    End If
    DoMsg("それは戦闘中に使用するべきものです")
  Else
    DoMsg("意味がありません")
  End If

  Return Nothing

End Procedure

Procedure InvokeMagic()
  Dim we = GetPartyMembers()
  Dim hMenu = CreateNameListBox(we, 120, 0, 240, 200, _
    Nothing, Nothing, "だれの？", 1)
  Dim index = ProcessMenu(hMenu)
  Do While index > 0
    Dim who = we[index]
    Dim magic_index = 1
    Do
      Dim magic_menu = CreateNameListBox(who.MagicList, 240, 0, 240, 200, _
        Nothing, Nothing, "なにを？", magic_index)
      magic_index = ProcessMenu(magic_menu)
      If magic_index > 0 Then
        Dim magic = who.MagicList[magic_index]
        Dim handling_menu = CreateMenu(360, 0, 120, 200, Nothing, Nothing, _
          "どうする？", {"つかう", "ならび"}, Nothing, 1)
        Dim handling_index = ProcessMenu(handling_menu)
        If handling_index = 1 Then
          If Not TestStatus(who, StatusEffect.Dead) Then
            If magic.Cost <= who.MP Then
              Dim targets = SelectTarget(420, 0, who, magic)
              If targets <> Nothing Then
                who.MP -= magic.Cost
                PlayAudio(Sound.Tonaeta)
                Sleep(500)
                ApplyHeroMagic(who, magic, targets)
              End If
            Else
              DoMsg("大変お気の毒ですがＭＰが足りません")
            End If
          Else
            DoMsg("残念ながら手遅れです")
          End If
        ElseIf handling_index = 2 Then
          Dim move_menu = CreateNameListBox(who.MagicList, 420, 0, 240, 200, _
            Nothing, Nothing, "どこに？", magic_index)
          Dim move_menu_index = ProcessMenu(move_menu)
          If move_menu_index > 0 Then
            who.MagicList[magic_index] = who.MagicList[move_menu_index]
            who.MagicList[move_menu_index] = magic
          End If
          DestroyControl(move_menu)
        End If
        DestroyControl(handling_menu)
      End If
      DestroyControl(magic_menu)
    Loop While magic_index > 0
    index = ProcessMenu(hMenu)
  Loop
  DestroyControl(hMenu)
  Return True
End Procedure

Procedure UseTool()
  Dim we = GetPartyMembers()
  Dim hMenu = CreateNameListBox(we, 120, 0, 240, 200, _
    Nothing, Nothing, "だれの？", 1)
  Dim index = ProcessMenu(hMenu)
  Do While index > 0
    Dim who = we[index]
    Dim tool_index = 1
    Do
      Dim tool_menu = CreateNameListBox(who.ToolList, 240, 0, 240, 200, _
        Nothing, Nothing, "なにを？", tool_index)
      tool_index = ProcessMenu(tool_menu)
      If tool_index > 0 Then
        Dim tool = who.ToolList[tool_index]
        Dim handling_menu = CreateMenu(360, 0, 120, 200, Nothing, Nothing, _
          "どうする？", {"つかう", "わたす", "ならび", "すてる"}, Nothing, 1)
        Dim handling_index = ProcessMenu(handling_menu)
        If handling_index > 0 Then
          If handling_index = 1 Then
            Dim targets = SelectTarget(420, 0, who, tool)
            If targets <> Nothing Then
              If Not tool.Importance AndAlso tool.SingleUse Then
                who.ToolList.RemoveAt(tool_index)
              End If
              ApplyHeroMagic(who, tool, targets, 100)
            End If
          ElseIf handling_index = 2 Then
            Dim target_menu = CreateNameListBox(we, 420, 0, 240, 200, _
              Nothing, Nothing, "だれに？", 1)
            Dim target_index = ProcessMenu(target_menu)
            If target_index > 0 Then
              we[target_index].ToolList.Add(tool)
              who.ToolList.RemoveAt(tool_index)
            End If
            DestroyControl(target_menu)
          ElseIf handling_index = 3 Then
            Dim move_menu = CreateNameListBox(who.ToolList, 420, 0, 240, 200, _
              Nothing, Nothing, "どこに？", tool_index)
            Dim move_index = ProcessMenu(move_menu)
            If move_index > 0 Then
              who.ToolList[tool_index] = who.ToolList[move_index]
              who.ToolList[move_index] = tool
            End If
            DestroyControl(move_menu)
          Else
            If Not tool.Importance Then
              If DoYesNoMsg("本気で捨てるのですか？") = True Then
                who.ToolList.RemoveAt(tool_index)
              End If
            Else
              DoMsg("捨てられないことになっています")
            End If
          End If
          tool_index = Math.Max(Math.Min(tool_index, who.ToolList.Count), 1)
        End If
        DestroyControl(handling_menu)
      End If
      DestroyControl(tool_menu)
    Loop While tool_index > 0
    index = ProcessMenu(hMenu)
  Loop
  DestroyControl(hMenu)
  Return True
End Procedure

Procedure GetEquipmentValue(tool)
  If tool.Part = 1 Then
    Return tool.DamageAP[1]
  Else
    Return tool.DamageDP[1]
  End If
End Procedure

Procedure ChangeEquipment()
  Dim we = GetPartyMembers()
  Dim hMenu = CreateNameListBox(we, 120, 0, 240, 200, _
    Nothing, Nothing, "だれの？", 1)
  Dim index = ProcessMenu(hMenu)
  Do While index > 0
    Dim who = we[index]
    Dim prev_tool_index = 1
    Dim part_menu = CreateMenu(240, 0, 120, 200, Nothing, Nothing, _
      "なにを？", {"ぶ　き", "からだ", "う　で", "あたま", "ふ　く"}, Nothing, 1)
    Dim part_index = ProcessMenu(part_menu)
    Do While part_index > 0
      If part_index <= 4 Then
        Dim curr_eq = Nothing
        Dim caption = ""
        Dim indexes = CreateList()
        Dim names = CreateList()
        Dim values = CreateList()
        If part_index = 1 Then
          curr_eq = who.Weapon
        ElseIf part_index = 2 Then
          curr_eq = who.Armor
        ElseIf part_index = 3 Then
          curr_eq = who.Shield
        ElseIf part_index = 4 Then
          curr_eq = who.Helmet
        End If
        For i = 1 To who.ToolList.Count
          Dim tool = who.ToolList[i]
          If tool.Part = part_index Then
            indexes.Add(i)
            names.Add(tool.Name)
            values.Add(GetEquipmentValue(tool))
          End If
        Next
        If curr_eq <> Nothing Then
          indexes.Add(0)
          names.Add("はずす")
          values.Add(GetEquipmentValue(curr_eq))
          caption = curr_eq.Name
        End If
        Dim eq_menu = CreateMenu(300, 0, 240, 240, Nothing, Nothing, _
          caption, names, values, 1)
        Dim eq_index = ProcessMenu(eq_menu)
        If eq_index > 0 Then
          Dim tool_index = indexes[eq_index]
          Dim new_eq = Nothing
          If tool_index > 0 Then
            new_eq = who.ToolList[tool_index]
            who.ToolList.RemoveAt(tool_index)
          End If
          If part_index = 1 Then
            who.Weapon = new_eq
          ElseIf part_index = 2 Then
            who.Armor = new_eq
          ElseIf part_index = 3 Then
            who.Shield = new_eq
          ElseIf part_index = 4 Then
            who.Helmet = new_eq
          End If
          If curr_eq <> Nothing Then
            who.ToolList.Add(curr_eq)
          End If
          Equip(who)
        End If
        DestroyControl(eq_menu)
      Else
        Dim skin_menu = Nothing
        If who.Type > 0 Then
          skin_menu = CreateMenu(300, 0, 240, 240, Nothing, Nothing, _
            "きがえる", {"赤系", "緑系", "青系"}, Nothing, 1)
        Else
          skin_menu = CreateMenu(300, 0, 240, 240, Nothing, Nothing, _
            "きがえる", {"銀系", "黒系", "金系"}, Nothing, 1)
        End If
        Dim skin_index = ProcessMenu(skin_menu)
        If skin_index > 0 Then
          If who.Type = 0 Then
            who.Texture = {[T_H01], [T_H02], [T_H03]}[skin_index]
          ElseIf who.Type = 1 Then
            who.Texture = {[T_H04], [T_H05], [T_H06]}[skin_index]
          ElseIf who.Type = 2 Then
            who.Texture = {[T_H07], [T_H08], [T_H09]}[skin_index]
          ElseIf who.Type = 3 Then
            who.Texture = {[T_H10], [T_H11], [T_H12]}[skin_index]
          ElseIf who.Type = 4 Then
            who.Texture = {[T_H13], [T_H14], [T_H15]}[skin_index]
          End If
        End If
        DestroyControl(skin_menu)
      End If
      part_index = ProcessMenu(part_menu)
    Loop
    DestroyControl(part_menu)
    index = ProcessMenu(hMenu)
  Loop
  DestroyControl(hMenu)
  Return True
End Procedure

Procedure CheckStatus()
  
  Dim ss = GetScreenSize()
  
  Dim party_info = CreateEmptyInfoWindow(ss.X - 320, 50, 320, 80, 2, 3)
  GetInfoWindowCell(party_info, 1, 1).Text = "歩数"
  GetInfoWindowCell(party_info, 2, 1).Text = HanToZen(GetGameInfo("NumOfSteps"))
  GetInfoWindowCell(party_info, 1, 2).Text = "戦闘"
  GetInfoWindowCell(party_info, 2, 2).Text = HanToZen(GetGameInfo("Battles"))
  GetInfoWindowCell(party_info, 1, 3).Text = "勝利"
  GetInfoWindowCell(party_info, 2, 3).Text = HanToZen(GetGameInfo("Victories"))
  
  Dim we = GetPartyMembers()
  Dim hMenu = CreateNameListBox(we, 120, 0, 240, 200, _
    Nothing, Nothing, "だれの？", 1)
  Dim index = ProcessMenu(hMenu)
  Do While index > 0
    Dim who = we[index]

    Dim col1 = CreateArrayList(10)
    col1[1] = who.Name
    col1[3] = "装備"
    If who.Weapon <> Nothing Then col1[4] = who.Weapon.Name
    If who.Armor <> Nothing Then col1[5] = who.Armor.Name
    If who.Shield <> Nothing Then col1[6] = who.Shield.Name
    If who.Helmet <> Nothing Then col1[7] = who.Helmet.Name
    col1[9] = "攻撃力"
    col1[10] = "防御力"
    Dim col2 = CreateArrayList(10)
    Dim col3 = CreateArrayList(10)
    Dim col4 = CreateArrayList(10)
    col4[9] = HanToZen(who.DamageAP[1])
    col4[10] = HanToZen(who.DamageDP[1])
    Dim col5 = CreateArrayList(10)
    Dim col6 = CreateArrayList(10)
    Dim col7 = {"　腕力　", "　体力　", "　魔力　", "すばやさ", "運のよさ", Nothing, "武器ＬＶ", "魔法ＬＶ", "最大ＨＰ", "最大ＭＰ"}
    Dim col8 = CreateArrayList(10)
    Dim col9 = CreateArrayList(10)
    Dim col10 = CreateArrayList(10)
    Dim col11 = CreateArrayList(10)
    Dim col12 = { _
	  HanToZen(who.Strength), HanToZen(who.Vitality), HanToZen(who.Intelligence), HanToZen(who.Agility), HanToZen(who.Luck), _
	  Nothing, HanToZen(who.PPLevel), HanToZen(who.MPLevel), HanToZen(who.MaxHP), HanToZen(who.MaxMP)}

    Dim hInfoWnd = CreateInfoWindow( _
	  (ss.X - 400) / 2, ss.Y - 132 - 240, 400, 240, 12, 10, _
      {col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12})
    WaitForOKOrCancel()
    DestroyControl(hInfoWnd)
    
    index = ProcessMenu(hMenu)
  Loop
  DestroyControl(hMenu)
  
  DestroyControl(party_info)
  
  Return True
End Procedure

Procedure ChangeOrder()
  Dim we = GetPartyMembers()
  Dim hMenu = CreateNameListBox(we, 120, 0, 240, 200, _
    Nothing, Nothing, "だれを？", 1)
  Dim index = ProcessMenu(hMenu)
  If index > 0 Then
    Dim who = we[index]
    Dim hDest = CreateNameListBox(we, 240, 0, 240, 200, _
      Nothing, Nothing, "どこに？", 1)
    Dim dest_index = ProcessMenu(hDest)
    If dest_index > 0 AndAlso index <> dest_index Then
      ExchangePartyMember(who, we[dest_index])
      UpdatePartyStatusWindow()
    End If
    DestroyControl(hDest)
  End If
  DestroyControl(hMenu)
  Return True
End Procedure

Procedure SaveData()
  Dim hMenu = CreateDataSlotMenuForSave(80, 80, 480, 280, Nothing, Nothing, _
    "どこに？", 1)
  Dim index = ProcessMenu(hMenu)
  Do While index > 0
    If Not IsDataSlotUsed(index) OrElse DoYesNoMsg( _
      "前のデータは消えますが　よろしいですか？") Then
      SaveGameData(index)
      DoMsg("セーブしました")
      Exit Do
    End If
    index = ProcessMenu(hMenu)
  Loop
  DestroyControl(hMenu)
  Return True
End Procedure
