#==============================================================================
#  Window_RingMenu
#==============================================================================
#==============================================================================
# Edited by MakirouAru
# 3D Version by Deblu
#==============================================================================
class Window_RingMenu < Window_Base
#--------------------------------------------------------------------------
# : N0X'"
#--------------------------------------------------------------------------
# Grafiktyp: Grafiken oder Icons?
grafik_typ = "i" # p = Pictures, i = Icons
# Die Dateinamen (ohne Dateiendung)
grafik_gegenstaende = "034-Item03"
grafik_faehigkeiten = "044-Skill01"
grafik_ausruestung = "001-Weapon01"
grafik_status = "050-Skill07"
grafik_speichern = "038-Item07"
grafik_beenden = "046-Skill03"
STARTUP_FRAMES = 20 # 0`Aj[V!"̒tR["
MOVING_FRAMES = 5   # `"O 0}~̒tR["
RING_R = 256         # `"O"Ra
if grafik_typ == "i"
  PIC_ITEM   = RPG:

ache.icon(grafik_gegenstaende) # uACevj&[̒ACR"
  PIC_SKILL  = RPG:

ache.icon(grafik_faehigkeiten) # uXL9vj&[̒ACR"
  PIC_EQUIP  = RPG:

ache.icon(grafik_ausruestung) # u'""vj&[̒ACR"
  PIC_STATUS = RPG:

ache.icon(grafik_status) # uXe[^Xvj&[̒ACR"
  PIC_SAVE   = RPG:

ache.icon(grafik_speichern) # uZ[uvj&[̒ACR"
  PIC_EXIT   = RPG:

ache.icon(grafik_beenden) # uIvj&[̒ACR"
else
  PIC_ITEM   = RPG:

ache.picture(grafik_gegenstaende) # uACevj&[̒ACR"
  PIC_SKILL  = RPG:

ache.picture(grafik_faehigkeiten) # uXL9vj&[̒ACR"
  PIC_EQUIP  = RPG:

ache.picture(grafik_ausruestung) # u'""vj&[̒ACR"
  PIC_STATUS = RPG:

ache.picture(grafik_status) # uXe[^Xvj&[̒ACR"
  PIC_SAVE   = RPG:

ache.picture(grafik_speichern) # uZ[uvj&[̒ACR"
  PIC_EXIT   = RPG:

ache.picture(grafik_beenden) # uIvj&[̒ACR"
end
PIC_DISABLE= RPG:

ache.icon("") # }gp9}~"tACR"
SE_STARTUP = "056-Right02" # j&[ `JƫSE
MODE_START = 1 # X^[gAbvAj[V!"
MODE_WAIT  = 2 # '9@
MODE_MOVER = 3 # }~Rv00"]Aj[V!"
MODE_MOVEL = 4 # "}~Rv00"]Aj[V!"
#--------------------------------------------------------------------------
# : ANZT
#--------------------------------------------------------------------------
attr_accessor :index
#--------------------------------------------------------------------------
# S IuWFNg0`0
#--------------------------------------------------------------------------
def initialize( center_x, center_y )
  super(0, 0, 640, 480)
  self.contents = Bitmap.new(width-32, height-32)
  self.contents.font.name = "Arial"
  self.opacity = 0
  self.back_opacity = 0
  s1 = "Gegenstnde"
  s2 = "Fhigkeiten"
  s3 = "Ausrstung"
  s4 = "Status"
  s5 = "Speichern"
  s6 = "Beenden"
  @commands = [ s1, s2, s3, s4, s5, s6 ]
  @item_max = 6
  @index = 0
  @items = [ PIC_ITEM, PIC_SKILL, PIC_EQUIP, PIC_STATUS, PIC_SAVE, PIC_EXIT ]
  @disabled = [ false, false, false, false, false, false ]
  @cx = center_x - 16
  @cy = center_y - 16
  setup_move_start
  refresh
end
#--------------------------------------------------------------------------
# S tR[XV
#--------------------------------------------------------------------------
def update
  super
  refresh
end
#--------------------------------------------------------------------------
# S 0"`0
#--------------------------------------------------------------------------
def refresh
  self.contents.clear
  # ACR" "`0
  case @mode
  when MODE_START
    refresh_start
  when MODE_WAIT
    refresh_wait
  when MODE_MOVER
    refresh_move(1)
  when MODE_MOVEL
    refresh_move(0)
  end
  # ANeBuȒR}"h"\}
  rect = Rect.new(@cx - 272, @cy + 24, self.contents.width-32, 32)
  self.contents.draw_text(rect, @commands[@index],1)
end
#--------------------------------------------------------------------------
# : 0"`0(0`0}~)
#--------------------------------------------------------------------------
def refresh_start
  d1 = 2.0 * Math::PI / @item_max
  d2 = 1.0 * Math::PI / STARTUP_FRAMES
  r = RING_R - 1.0 * RING_R * @steps / STARTUP_FRAMES
  for i in 0...@item_max
    j = i - @index
    d = d1 * j + d2 * @steps
    x = @cx + ( r * Math.sin( d ) ).to_i
    y = @cy - ( r/3 * Math.cos( d ) ).to_i
    draw_item(x, y, i)
  end
  @steps -= 1
  if @steps < 1
    @mode = MODE_WAIT
  end
end
#--------------------------------------------------------------------------
# : 0"`0('9@}~)
#--------------------------------------------------------------------------
def refresh_wait
  d = 2.0 * Math::PI / @item_max
  for i in 0...@item_max
    j = i - @index
    x = @cx + ( RING_R * Math.sin( d * j ) ).to_i
    y = @cy - ( RING_R/3 * Math.cos( d * j ) ).to_i
    draw_item(x, y, i)
  end
end
#--------------------------------------------------------------------------
# : 0"`0(0"]}~)
#  mode : 0="}~Rv0 1=}~Rv0
#--------------------------------------------------------------------------
def refresh_move( mode )
  d1 = 2.0 * Math::PI / @item_max
  d2 = d1 / MOVING_FRAMES
  d2 *= -1 if mode != 0
  for i in 0...@item_max
    j = i - @index
    d = d1 * j + d2 * @steps
    x = @cx + ( RING_R * Math.sin( d ) ).to_i
    y = @cy - ( RING_R/3 * Math.cos( d ) ).to_i
    draw_item(x, y, i)
  end
  @steps -= 1
  if @steps < 1
    @mode = MODE_WAIT
  end
end
#--------------------------------------------------------------------------
# S "`0
#     x : 
#     y : 
#     i : " 
#--------------------------------------------------------------------------
def draw_item(x, y, i)
  #p "x=" + x.to_s + " y=" + y.to_s + " i=" + @items[i].to_s
  rect = Rect.new(0, 0, @items[i].width, @items[i].height)
  if @index == i
    self.contents.blt( x, y, @items[i], rect )
    if @disabled[@index]
      self.contents.blt( x, y, ICON_DISABLE, rect )
    end
  else
    self.contents.blt( x, y, @items[i], rect, 128 )
    if @disabled[@index]
      self.contents.blt( x, y, ICON_DISABLE, rect, 128 )
    end
  end
end
#--------------------------------------------------------------------------
# S  Rɷ
#     index : " 
#--------------------------------------------------------------------------
def disable_item(index)
  @disabled[index] = true
end
#--------------------------------------------------------------------------
# : 0`0Aj[V!""
#--------------------------------------------------------------------------
def setup_move_start
  @mode = MODE_START
  @steps = STARTUP_FRAMES
  if  SE_STARTUP != nil and SE_STARTUP != ""
    Audio.se_play("Audio/SE/" + SE_STARTUP, 80, 100)
  end
end
#--------------------------------------------------------------------------
# : 0"]Aj[V!""
#--------------------------------------------------------------------------
def setup_move_move(mode)
  if mode == MODE_MOVER
    @index -= 1
    @index = @items.size - 1 if @index < 0
  elsif mode == MODE_MOVEL
    @index += 1
    @index = 0 if @index >= @items.size
  else
    return
  end
  @mode = mode
  @steps = MOVING_FRAMES
end
#--------------------------------------------------------------------------
# : Aj[V!"' Ǥ
#--------------------------------------------------------------------------
def animation?
  return @mode != MODE_WAIT
end
end
#==============================================================================
#  Window_MenuStatus
#------------------------------------------------------------------------------
# @j&[0Œp[eB"o[̒Xe[^X "\}EB"hEŷB
#==============================================================================
class Window_RingMenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# S IuWFNg0`0
#--------------------------------------------------------------------------
def initialize
  super(204, 64, 232, 352)
  self.contents = Bitmap.new(width - 32, height - 32)
  refresh
  self.active = false
  self.index = -1
end
#--------------------------------------------------------------------------
# S `tRbV&
#--------------------------------------------------------------------------
def refresh
  self.contents.clear
  self.contents.font.name = "Arial"
  @item_max = $game_party.actors.size
  for i in 0...$game_party.actors.size
    x = 80
    y = 80 * i
    actor = $game_party.actors[i]
    draw_actor_graphic(actor, x - 40, y + 80)
    draw_actor_name(actor, x, y + 24)
  end
end
#--------------------------------------------------------------------------
# S J[\99R`XV
#--------------------------------------------------------------------------
def update_cursor_rect
  if @index < 0
    self.cursor_rect.empty
  else
    self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  end
end
end
#==============================================================================
# # Scene_RingMenu
#  Scene_Menu
#------------------------------------------------------------------------------
# @j&[0 sN0XŷB
#==============================================================================
#class Scene_RingMenu
class Scene_Menu
#--------------------------------------------------------------------------
# S IuWFNg0`0
#     menu_index : R}"h̒J[\90`'u
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
  @menu_index = menu_index
end
#--------------------------------------------------------------------------
# S C"
#--------------------------------------------------------------------------
def main
  # Xv0CgZbg 
  @spriteset = Spriteset_Map.new
  # R}"hEB"hE 
  px = $game_player.screen_x - 15
  py = $game_player.screen_y - 24
  @command_window = Window_RingMenu.new(px,py)
  @command_window.index = @menu_index
  # p[eBl" 0 l!
  if $game_party.actors.size == 0
    # ACeAXL9A'""AXe[^X R0
    @command_window.disable_item(0)
    @command_window.disable_item(1)
    @command_window.disable_item(2)
    @command_window.disable_item(3)
  end
  @command_window.z = 100
  # Z[u9}~!
  if $game_system.save_disabled
    # Z[u Rɷ
    @command_window.disable_item(4)
  end
  # Xe[^XEB"hE 
  @status_window = Window_RingMenuStatus.new
  @status_window.x = 160
  @status_window.y = 0
  @status_window.z = 200
  @status_window.visible = false
  # g0"WV!"}s
  Graphics.transition
  # C"9[v
  loop do
    # Q[0 XV
    Graphics.update
    # "" XV
    Input.update
    # tR[XV
    update
    # 0ʪ'9[v ' 'f
    if $scene != self
      break
    end
  end
  # g0"WV!""
  Graphics.freeze
  # Xv0CgZbg 0 "
  @spriteset.dispose
  # EB"hE 0 "
  @command_window.dispose
  @status_window.dispose
end
#--------------------------------------------------------------------------
# S tR[XV
#--------------------------------------------------------------------------
def update
  # EB"hE XV
  @command_window.update
  @status_window.update
  # R}"hEB"hEANeBu!: update_command  R
  if @command_window.active
    update_command
    return
  end
  # Xe[^XEB"hEANeBu!: update_status  R
  if @status_window.active
    update_status
    return
  end
end
#--------------------------------------------------------------------------
# S tR[XV (R}"hEB"hEANeBu!)
#--------------------------------------------------------------------------
def update_command
  # B {^"0x!
  if Input.trigger?(Input:

)
    # L"Z9 SE  00't
    $game_system.se_play($data_system.cancel_se)
    # }bv0'֦
    $scene = Scene_Map.new
    return
  end
  # C {^"0x!
  if Input.trigger?(Input:

)
    # p[eBl" 0 lAZ[uAQ[I`O̒R}"h!
    if $game_party.actors.size == 0 and @command_window.index < 4
      # uU[ SE  00't
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # R}"hEB"hE̒J[\9'u"`
    case @command_window.index
    when 0  # ACe
      # R'  SE  00't
      $game_system.se_play($data_system.decision_se)
      # ACe0'֦
      $scene = Scene_Item.new
    when 1  # XL9
      # R' SE  00't
      $game_system.se_play($data_system.decision_se)
      # Xe[^XEB"hE ANeBuɷ
      @command_window.active = false
      @status_window.active = true
      @status_window.visible = true
      @status_window.index = 0
    when 2  # '""
      # R' SE  00't
      $game_system.se_play($data_system.decision_se)
      # Xe[^XEB"hE ANeBuɷ
      @command_window.active = false
      @status_window.active = true
      @status_window.visible = true
      @status_window.index = 0
    when 3  # Xe[^X
      # R' SE  00't
      $game_system.se_play($data_system.decision_se)
      # Xe[^XEB"hE ANeBuɷ
      @command_window.active = false
      @status_window.active = true
      @status_window.visible = true
      @status_window.index = 0
    when 4  # Z[u
      # Z[u9}~!
      if $game_system.save_disabled
        # uU[ SE  00't
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # R' SE  00't
      $game_system.se_play($data_system.decision_se)
      # Z[u0'֦
      $scene = Scene_Save.new
    when 5  # Q[I
      # R' SE  00't
      $game_system.se_play($data_system.decision_se)
...