mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Rewrote phone UI code, added "CommonEvent" trainer comment for that phone contact to run instead of default phone messages, added phone signal icon to phone
This commit is contained in:
@@ -182,7 +182,11 @@ MenuHandlers.add(:pokegear_menu, :phone, {
|
||||
"order" => 20,
|
||||
# "condition" => proc { next $PokemonGlobal.phone && $PokemonGlobal.phone.contacts.length > 0 },
|
||||
"effect" => proc { |menu|
|
||||
pbFadeOutIn { PokemonPhoneScene.new.start }
|
||||
pbFadeOutIn {
|
||||
scene = PokemonPhone_Scene.new
|
||||
screen = PokemonPhoneScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
}
|
||||
next false
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# TODO: Choosable icons/marks for each contact?
|
||||
# TODO: Allow rearranging contacts.
|
||||
#===============================================================================
|
||||
# Phone screen
|
||||
# Phone list of contacts
|
||||
#===============================================================================
|
||||
class Window_PhoneList < Window_CommandPokemon
|
||||
def drawCursor(index, rect)
|
||||
@@ -20,17 +22,57 @@ end
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPhoneScene
|
||||
def start
|
||||
# Get list of contacts
|
||||
class PokemonPhone_Scene
|
||||
def pbStartScene
|
||||
@sprites = {}
|
||||
# Create viewport
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
# Background
|
||||
addBackgroundPlane(@sprites, "bg", "Phone/bg", @viewport)
|
||||
# List of contacts
|
||||
@sprites["list"] = Window_PhoneList.newEmpty(152, 32, Graphics.width - 142, Graphics.height - 80, @viewport)
|
||||
@sprites["list"].windowskin = nil
|
||||
# Rematch readiness icons
|
||||
if Phone.rematches_enabled
|
||||
@sprites["list"].page_item_max.times do |i|
|
||||
@sprites["rematch_#{i}"] = IconSprite.new(468, 62 + (i * 32), @viewport)
|
||||
end
|
||||
end
|
||||
# Phone signal icon
|
||||
@sprites["signal"] = IconSprite.new(Graphics.width - 32, 0, @viewport)
|
||||
if Phone::Call.can_make?
|
||||
@sprites["signal"].setBitmap("Graphics/UI/Phone/icon_signal")
|
||||
else
|
||||
@sprites["signal"].setBitmap("Graphics/UI/Phone/icon_nosignal")
|
||||
end
|
||||
# Title text
|
||||
@sprites["header"] = Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Phone"), 2, -18, 128, 64, @viewport
|
||||
)
|
||||
@sprites["header"].baseColor = Color.new(248, 248, 248)
|
||||
@sprites["header"].shadowColor = Color.black
|
||||
@sprites["header"].windowskin = nil
|
||||
# Info text about all contacts
|
||||
@sprites["info"] = Window_AdvancedTextPokemon.newWithSize("", -8, 224, 180, 160, @viewport)
|
||||
@sprites["info"].windowskin = nil
|
||||
# Portrait of contact
|
||||
@sprites["icon"] = IconSprite.new(70, 102, @viewport)
|
||||
# Contact's location text
|
||||
@sprites["bottom"] = Window_AdvancedTextPokemon.newWithSize(
|
||||
"", 162, Graphics.height - 64, Graphics.width - 158, 64, @viewport
|
||||
)
|
||||
@sprites["bottom"].windowskin = nil
|
||||
# Start scene
|
||||
pbRefreshList
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbRefreshList
|
||||
@contacts = []
|
||||
$PokemonGlobal.phone.contacts.each do |contact|
|
||||
@contacts.push(contact) if contact.visible?
|
||||
end
|
||||
if @contacts.length == 0
|
||||
pbMessage(_INTL("There are no phone numbers stored."))
|
||||
return
|
||||
end
|
||||
# Create list of commands (display names of contacts) and count rematches
|
||||
commands = []
|
||||
rematch_count = 0
|
||||
@@ -38,95 +80,126 @@ class PokemonPhoneScene
|
||||
commands.push(contact.display_name)
|
||||
rematch_count += 1 if contact.can_rematch?
|
||||
end
|
||||
# Create viewport and sprites
|
||||
@sprites = {}
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
addBackgroundPlane(@sprites, "bg", "Phone/bg", @viewport)
|
||||
@sprites["list"] = Window_PhoneList.newEmpty(152, 32, Graphics.width - 142, Graphics.height - 80, @viewport)
|
||||
@sprites["list"].windowskin = nil
|
||||
# Set list's commands
|
||||
@sprites["list"].commands = commands
|
||||
@sprites["list"].page_item_max.times do |i|
|
||||
@sprites["rematch[#{i}]"] = IconSprite.new(468, 62 + (i * 32), @viewport)
|
||||
j = i + @sprites["list"].top_item
|
||||
if j < @contacts.length && @contacts[j].can_rematch?
|
||||
@sprites["rematch[#{i}]"].setBitmap("Graphics/UI/Phone/icon_rematch")
|
||||
end
|
||||
@sprites["list"].index = commands.length - 1 if @sprites["list"].index >= commands.length
|
||||
if @sprites["list"].top_row > @sprites["list"].itemCount - @sprites["list"].page_item_max - 1
|
||||
@sprites["list"].top_row = @sprites["list"].itemCount - @sprites["list"].page_item_max - 1
|
||||
end
|
||||
@sprites["header"] = Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Phone"), 2, -18, 128, 64, @viewport
|
||||
)
|
||||
@sprites["header"].baseColor = Color.new(248, 248, 248)
|
||||
@sprites["header"].shadowColor = Color.black
|
||||
@sprites["header"].windowskin = nil
|
||||
@sprites["bottom"] = Window_AdvancedTextPokemon.newWithSize(
|
||||
"", 162, Graphics.height - 64, Graphics.width - 158, 64, @viewport
|
||||
)
|
||||
@sprites["bottom"].windowskin = nil
|
||||
map_name = (@contacts[0].map_id > 0) ? pbGetMapNameFromId(@contacts[0].map_id) : ""
|
||||
@sprites["bottom"].text = "<ac>" + map_name
|
||||
@sprites["info"] = Window_AdvancedTextPokemon.newWithSize("", -8, 224, 180, 160, @viewport)
|
||||
@sprites["info"].windowskin = nil
|
||||
# Set info text
|
||||
infotext = _INTL("Registered<br>")
|
||||
infotext += _INTL(" <r>{1}<br>", @sprites["list"].commands.length)
|
||||
infotext += _INTL("Waiting for a rematch<r>{1}", rematch_count)
|
||||
@sprites["info"].text = infotext
|
||||
@sprites["icon"] = IconSprite.new(70, 102, @viewport)
|
||||
if @contacts[0].trainer?
|
||||
filename = GameData::TrainerType.charset_filename(@contacts[0].trainer_type)
|
||||
else
|
||||
filename = sprintf("Graphics/Characters/phone%03d", @contacts[0].common_event_id)
|
||||
pbRefreshScreen
|
||||
end
|
||||
|
||||
def pbRefreshScreen
|
||||
# Redraw rematch readiness icons
|
||||
if @sprites["rematch_0"]
|
||||
@sprites["list"].page_item_max.times do |i|
|
||||
@sprites["rematch_#{i}"].clearBitmaps
|
||||
j = i + @sprites["list"].top_item
|
||||
if j < @contacts.length && @contacts[j].can_rematch?
|
||||
@sprites["rematch_#{i}"].setBitmap("Graphics/UI/Phone/icon_rematch")
|
||||
end
|
||||
end
|
||||
end
|
||||
@sprites["icon"].setBitmap(filename)
|
||||
charwidth = @sprites["icon"].bitmap.width
|
||||
charheight = @sprites["icon"].bitmap.height
|
||||
@sprites["icon"].x = 86 - (charwidth / 8)
|
||||
@sprites["icon"].y = 134 - (charheight / 8)
|
||||
@sprites["icon"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4)
|
||||
# Start scene
|
||||
pbFadeInAndShow(@sprites)
|
||||
# Get the selected contact
|
||||
contact = @contacts[@sprites["list"].index]
|
||||
if contact
|
||||
# Redraw contact's portrait
|
||||
if contact.trainer?
|
||||
filename = GameData::TrainerType.charset_filename(contact.trainer_type)
|
||||
else
|
||||
filename = sprintf("Graphics/Characters/phone%03d", contact.common_event_id)
|
||||
end
|
||||
@sprites["icon"].setBitmap(filename)
|
||||
charwidth = @sprites["icon"].bitmap.width
|
||||
charheight = @sprites["icon"].bitmap.height
|
||||
@sprites["icon"].x = 86 - (charwidth / 8)
|
||||
@sprites["icon"].y = 134 - (charheight / 8)
|
||||
@sprites["icon"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4)
|
||||
# Redraw contact's location text
|
||||
map_name = (contact.map_id > 0) ? pbGetMapNameFromId(contact.map_id) : ""
|
||||
@sprites["bottom"].text = "<ac>" + map_name
|
||||
else
|
||||
@sprites["icon"].setBitmap(nil)
|
||||
@sprites["bottom"].text = ""
|
||||
end
|
||||
end
|
||||
|
||||
def pbChooseContact
|
||||
pbActivateWindow(@sprites, "list") {
|
||||
oldindex = -1
|
||||
index = -1
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
# Cursor moved, update display
|
||||
if @sprites["list"].index != oldindex
|
||||
contact = @contacts[@sprites["list"].index]
|
||||
if contact.trainer?
|
||||
filename = GameData::TrainerType.charset_filename(contact.trainer_type)
|
||||
else
|
||||
filename = sprintf("Graphics/Characters/phone%03d", contact.common_event_id)
|
||||
end
|
||||
@sprites["icon"].setBitmap(filename)
|
||||
charwidth = @sprites["icon"].bitmap.width
|
||||
charheight = @sprites["icon"].bitmap.height
|
||||
@sprites["icon"].x = 86 - (charwidth / 8)
|
||||
@sprites["icon"].y = 134 - (charheight / 8)
|
||||
@sprites["icon"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4)
|
||||
map_name = (contact.map_id > 0) ? pbGetMapNameFromId(contact.map_id) : ""
|
||||
@sprites["bottom"].text = "<ac>" + map_name
|
||||
@sprites["list"].page_item_max.times do |i|
|
||||
@sprites["rematch[#{i}]"].clearBitmaps
|
||||
j = i + @sprites["list"].top_item
|
||||
if j < @contacts.length && @contacts[j].can_rematch?
|
||||
@sprites["rematch[#{i}]"].setBitmap("Graphics/UI/Phone/icon_rematch")
|
||||
end
|
||||
end
|
||||
end
|
||||
pbRefreshScreen if @sprites["list"].index != index
|
||||
index = @sprites["list"].index
|
||||
# Get inputs
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
return nil
|
||||
elsif Input.trigger?(Input::USE)
|
||||
index = @sprites["list"].index
|
||||
Phone::Call.make_outgoing(@contacts[index]) if index >= 0
|
||||
return @contacts[index] if index >= 0
|
||||
end
|
||||
end
|
||||
}
|
||||
pbFadeOutAndHide(@sprites)
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPhoneScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreen
|
||||
if $PokemonGlobal.phone.contacts.none? { |con| con.visible? }
|
||||
pbMessage(_INTL("There are no phone numbers stored."))
|
||||
return
|
||||
end
|
||||
@scene.pbStartScene
|
||||
loop do
|
||||
contact = @scene.pbChooseContact
|
||||
break if !contact
|
||||
commands = []
|
||||
commands.push(_INTL("Call"))
|
||||
commands.push(_INTL("Delete")) if contact.can_hide?
|
||||
commands.push(_INTL("Cancel"))
|
||||
cmd = pbShowCommands(nil, commands, -1)
|
||||
cmd -= 1 if cmd >=1 && !contact.can_hide?
|
||||
case cmd
|
||||
when 0 # Call
|
||||
Phone::Call.make_outgoing(contact)
|
||||
when 1 # Delete
|
||||
name = contact.display_name
|
||||
if pbConfirmMessage(_INTL("Are you sure you want to delete {1} from your phone?", name))
|
||||
contact.visible = false
|
||||
@scene.pbRefreshList
|
||||
pbMessage(_INTL("{1} was deleted from your phone contacts.", name))
|
||||
if $PokemonGlobal.phone.contacts.none? { |con| con.visible? }
|
||||
pbMessage(_INTL("There are no phone numbers stored."))
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user