Merge branch 'ui-redesign' into dev

This commit is contained in:
Maruno17
2025-01-16 22:54:12 +00:00
111 changed files with 36440 additions and 24208 deletions

View File

@@ -9,6 +9,7 @@ module GameData
class Stat
attr_reader :id
attr_reader :real_name
attr_reader :real_name_semi_brief
attr_reader :real_name_brief
attr_reader :type
attr_reader :pbs_order
@@ -39,11 +40,12 @@ module GameData
#---------------------------------------------------------------------------
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@real_name_brief = hash[:name_brief] || "None"
@type = hash[:type] || :none
@pbs_order = hash[:pbs_order] || -1
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@real_name_semi_brief = hash[:name_semi_brief]
@real_name_brief = hash[:name_brief] || "None"
@type = hash[:type] || :none
@pbs_order = hash[:pbs_order] || -1
end
# @return [String] the translated name of this stat
@@ -51,6 +53,10 @@ module GameData
return _INTL(@real_name)
end
def name_semi_brief
return _INTL(@real_name_semi_brief || @real_name)
end
# @return [String] the translated brief name of this stat
def name_brief
return _INTL(@real_name_brief)
@@ -87,19 +93,21 @@ GameData::Stat.register({
})
GameData::Stat.register({
:id => :SPECIAL_ATTACK,
:name => _INTL("Special Attack"),
:name_brief => _INTL("SpAtk"),
:type => :main_battle,
:pbs_order => 4
:id => :SPECIAL_ATTACK,
:name => _INTL("Special Attack"),
:name_semi_brief => _INTL("Sp. Attack"),
:name_brief => _INTL("SpAtk"),
:type => :main_battle,
:pbs_order => 4
})
GameData::Stat.register({
:id => :SPECIAL_DEFENSE,
:name => _INTL("Special Defense"),
:name_brief => _INTL("SpDef"),
:type => :main_battle,
:pbs_order => 5
:id => :SPECIAL_DEFENSE,
:name => _INTL("Special Defense"),
:name_semi_brief => _INTL("Sp. Defense"),
:name_brief => _INTL("SpDef"),
:type => :main_battle,
:pbs_order => 5
})
GameData::Stat.register({

View File

@@ -0,0 +1,160 @@
#===============================================================================
#
#===============================================================================
module GameData
class BagPocket
attr_reader :id
attr_reader :real_name
attr_reader :icon_position # Where this pocket's icon is within icon_pocket.png
attr_reader :order
attr_reader :max_slots
attr_reader :auto_sort
DATA = {}
extend ClassMethodsSymbols
include InstanceMethods
def self.load; end
def self.save; end
def self.all_pockets
ret = []
DATA.each_value { |pocket| ret.push([pocket.bag_pocket]) }
ret.uniq!
ret.each { |data| data.push(self.get(data[0]).order) }
ret.sort_by! { |pckt| pckt[1] }
ret.map! { |pckt| pckt[0] }
return ret
end
def self.index(pocket)
return self.all_pockets.index(pocket)
end
# @param other [Symbol, self, String]
# @return [self]
def self.get(other)
validate other => [Symbol, self, String, Integer]
return other if other.is_a?(self)
other = self.all_pockets[other - 1] if other.is_a?(Integer)
other = other.to_sym if other.is_a?(String)
raise "Unknown ID #{other}." unless self::DATA.has_key?(other)
return self::DATA[other]
end
# @param other [Symbol, self, String]
# @return [self, nil]
def try_get(other)
return nil if other.nil?
validate other => [Symbol, self, String, Integer]
return other if other.is_a?(self)
other = self.all_pockets[other - 1] if other.is_a?(Integer)
other = other.to_sym if other.is_a?(String)
return (self::DATA.has_key?(other)) ? self::DATA[other] : nil
end
#---------------------------------------------------------------------------
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@icon_position = hash[:icon_position] || 0
@order = hash[:order] || 999
@max_slots = hash[:max_slots] || -1
@auto_sort = hash[:auto_sort] || false
@parent_pocket = hash[:parent_pocket]
end
# @return [String] the translated name of this nature
def name
return _INTL(@real_name)
end
def bag_pocket
return @parent_pocket || @id
end
end
end
#===============================================================================
# NOTE: If :parent_pocket is defined for a BagPocket below, that parent pocket
# is assumed to be one that appears in the Bag. They don't chain.
# i.e. You can't give "MegaStones" a :parent_pocket of "HeldItems", and
# "HeldItems" a :parent_pocket of "Items" (where "Items" is the only one
# of these pockets that appears in the Bag). Both "MegaStones" and
# "HeldItems" should have a :parent_pocket of "Items".
#===============================================================================
GameData::BagPocket.register({
:id => :Items,
:name => _INTL("Other Items"),
:icon_position => 0,
:order => 10
})
GameData::BagPocket.register({
:id => :Mail,
:parent_pocket => :Items
})
GameData::BagPocket.register({
:id => :Medicine,
:name => _INTL("Medicine"),
:icon_position => 1,
:order => 20
})
GameData::BagPocket.register({
:id => :PokeBalls,
:name => _INTL("Poké Balls"),
:icon_position => 2,
:order => 30
})
GameData::BagPocket.register({
:id => :Berries,
:name => _INTL("Berries"),
:icon_position => 3,
:order => 40,
:auto_sort => true
})
GameData::BagPocket.register({
:id => :HeldItems,
:name => _INTL("Held Items"),
:icon_position => 4,
:order => 50
})
GameData::BagPocket.register({
:id => :MegaStones,
:parent_pocket => :HeldItems
})
GameData::BagPocket.register({
:id => :BattleItems,
:name => _INTL("Battle Items"),
:icon_position => 5,
:order => 60
})
# This pocket is hardcoded to allow showing the details of a machine item in
# this pocket in the Bag. The display of this information is toggled by pressing
# the Action input. It is not possible to open the screen menu with the Action
# input in this pocket (although you also can't open it if the pocket auto-sorts
# so that's not a problem).
GameData::BagPocket.register({
:id => :Machines,
:name => _INTL("TMs & HMs"),
:icon_position => 6,
:order => 70,
:auto_sort => true
})
GameData::BagPocket.register({
:id => :KeyItems,
:name => _INTL("Key Items"),
:icon_position => 7,
:order => 80
})

View File

@@ -6,7 +6,10 @@ module GameData
attr_reader :id
attr_reader :real_name
attr_reader :filename
attr_reader :point
attr_reader :margins
attr_reader :point_size
attr_reader :size
attr_reader :points
attr_reader :flags
attr_reader :pbs_file_suffix
@@ -14,23 +17,43 @@ module GameData
DATA_FILENAME = "town_map.dat"
PBS_BASE_FILENAME = "town_map"
SCHEMA = {
"SectionName" => [:id, "u"],
"Name" => [:real_name, "s"],
"Filename" => [:filename, "s"],
"Point" => [:point, "^uusSUUUU"],
"Flags" => [:flags, "*s"]
"SectionName" => [:id, "u"],
"Name" => [:real_name, "s"],
"Filename" => [:filename, "s"],
"Margins" => [:margins, "uu"], # Left/right and top/bottom padding in pixels
"PointSize" => [:point_size, "vv"], # Size of a point in pixels
"Size" => [:size, "vv"], # Width and height in points
"Point" => [:points, "^uusSUUUU"],
"Flags" => [:flags, "*s"]
}
# This schema is for definable properties of individual points (apart from
# position and name which are above).
SUB_SCHEMA = {
"Image" => [:image, "s"],
"Description" => [:real_description, "q"],
"FlySpot" => [:fly_spot, "vuu"], # Map ID, x coord, y coord
"HideFlyIcon" => [:hide_fly_icon, "b"],
"FlyIconOffset" => [:fly_icon_offset, "ii"], # x and y offsets in pixels
"Switch" => [:switch, "v"] # Game Switch ID
}
extend ClassMethodsIDNumbers
include InstanceMethods
def self.sub_schema
return SUB_SCHEMA
end
#---------------------------------------------------------------------------
def initialize(hash)
@id = hash[:id]
@real_name = hash[:real_name] || "???"
@filename = hash[:filename]
@point = hash[:point] || []
@margins = hash[:margins] || [0, 0]
@point_size = hash[:point_size] || [16, 16]
@size = hash[:size] || [30, 20]
@points = hash[:points] || []
@flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || ""
end
@@ -43,5 +66,18 @@ module GameData
def has_flag?(flag)
return @flags.any? { |f| f.downcase == flag.downcase }
end
def get_point_property_for_PBS(key, index = 0)
return [*@points[index][:position], @points[index][:real_name]] if key == "Point"
ret = @points[index][SUB_SCHEMA[key][0]]
ret = nil if ret == false || (ret.is_a?(Array) && ret.length == 0) || ret == ""
case key
when "Margins"
ret = nil if ret == [0, 0]
when "FlySpot"
ret = nil if ret && ret.compact.empty?
end
return ret
end
end
end

View File

@@ -103,132 +103,132 @@ module GameData
end
def display_type(pkmn, move = nil)
=begin
case @function_code
when "TypeDependsOnUserIVs"
return pbHiddenPower(pkmn)[0]
when "TypeAndPowerDependOnUserBerry"
item_data = pkmn.item
if item_data
item_data.flags.each do |flag|
next if !flag[/^NaturalGift_(\w+)_(?:\d+)$/i]
typ = $~[1].to_sym
ret = typ if GameData::Type.exists?(typ)
break
if Settings::SHOW_MODIFIED_MOVE_PROPERTIES
case @function_code
when "TypeDependsOnUserIVs"
return pbHiddenPower(pkmn)[0]
when "TypeAndPowerDependOnUserBerry"
item_data = pkmn.item
if item_data
item_data.flags.each do |flag|
next if !flag[/^NaturalGift_(\w+)_(?:\d+)$/i]
typ = $~[1].to_sym
ret = typ if GameData::Type.exists?(typ)
break
end
end
end
return :NORMAL
when "TypeDependsOnUserPlate"
item_types = {
:FISTPLATE => :FIGHTING,
:SKYPLATE => :FLYING,
:TOXICPLATE => :POISON,
:EARTHPLATE => :GROUND,
:STONEPLATE => :ROCK,
:INSECTPLATE => :BUG,
:SPOOKYPLATE => :GHOST,
:IRONPLATE => :STEEL,
:FLAMEPLATE => :FIRE,
:SPLASHPLATE => :WATER,
:MEADOWPLATE => :GRASS,
:ZAPPLATE => :ELECTRIC,
:MINDPLATE => :PSYCHIC,
:ICICLEPLATE => :ICE,
:DRACOPLATE => :DRAGON,
:DREADPLATE => :DARK,
:PIXIEPLATE => :FAIRY
}
if pkmn.hasItem?
item_types.each do |item, item_type|
return item_type if pkmn.item_id == item && GameData::Type.exists?(item_type)
return :NORMAL
when "TypeDependsOnUserPlate"
item_types = {
:FISTPLATE => :FIGHTING,
:SKYPLATE => :FLYING,
:TOXICPLATE => :POISON,
:EARTHPLATE => :GROUND,
:STONEPLATE => :ROCK,
:INSECTPLATE => :BUG,
:SPOOKYPLATE => :GHOST,
:IRONPLATE => :STEEL,
:FLAMEPLATE => :FIRE,
:SPLASHPLATE => :WATER,
:MEADOWPLATE => :GRASS,
:ZAPPLATE => :ELECTRIC,
:MINDPLATE => :PSYCHIC,
:ICICLEPLATE => :ICE,
:DRACOPLATE => :DRAGON,
:DREADPLATE => :DARK,
:PIXIEPLATE => :FAIRY
}
if pkmn.hasItem?
item_types.each do |item, item_type|
return item_type if pkmn.item_id == item && GameData::Type.exists?(item_type)
end
end
end
when "TypeDependsOnUserMemory"
item_types = {
:FIGHTINGMEMORY => :FIGHTING,
:FLYINGMEMORY => :FLYING,
:POISONMEMORY => :POISON,
:GROUNDMEMORY => :GROUND,
:ROCKMEMORY => :ROCK,
:BUGMEMORY => :BUG,
:GHOSTMEMORY => :GHOST,
:STEELMEMORY => :STEEL,
:FIREMEMORY => :FIRE,
:WATERMEMORY => :WATER,
:GRASSMEMORY => :GRASS,
:ELECTRICMEMORY => :ELECTRIC,
:PSYCHICMEMORY => :PSYCHIC,
:ICEMEMORY => :ICE,
:DRAGONMEMORY => :DRAGON,
:DARKMEMORY => :DARK,
:FAIRYMEMORY => :FAIRY
}
if pkmn.hasItem?
item_types.each do |item, item_type|
return item_type if pkmn.item_id == item && GameData::Type.exists?(item_type)
when "TypeDependsOnUserMemory"
item_types = {
:FIGHTINGMEMORY => :FIGHTING,
:FLYINGMEMORY => :FLYING,
:POISONMEMORY => :POISON,
:GROUNDMEMORY => :GROUND,
:ROCKMEMORY => :ROCK,
:BUGMEMORY => :BUG,
:GHOSTMEMORY => :GHOST,
:STEELMEMORY => :STEEL,
:FIREMEMORY => :FIRE,
:WATERMEMORY => :WATER,
:GRASSMEMORY => :GRASS,
:ELECTRICMEMORY => :ELECTRIC,
:PSYCHICMEMORY => :PSYCHIC,
:ICEMEMORY => :ICE,
:DRAGONMEMORY => :DRAGON,
:DARKMEMORY => :DARK,
:FAIRYMEMORY => :FAIRY
}
if pkmn.hasItem?
item_types.each do |item, item_type|
return item_type if pkmn.item_id == item && GameData::Type.exists?(item_type)
end
end
end
when "TypeDependsOnUserDrive"
item_types = {
:SHOCKDRIVE => :ELECTRIC,
:BURNDRIVE => :FIRE,
:CHILLDRIVE => :ICE,
:DOUSEDRIVE => :WATER
}
if pkmn.hasItem?
item_types.each do |item, item_type|
return item_type if pkmn.item_id == item && GameData::Type.exists?(item_type)
when "TypeDependsOnUserDrive"
item_types = {
:SHOCKDRIVE => :ELECTRIC,
:BURNDRIVE => :FIRE,
:CHILLDRIVE => :ICE,
:DOUSEDRIVE => :WATER
}
if pkmn.hasItem?
item_types.each do |item, item_type|
return item_type if pkmn.item_id == item && GameData::Type.exists?(item_type)
end
end
when "TypeIsUserFirstType"
return pkmn.types[0]
end
when "TypeIsUserFirstType"
return pkmn.types[0]
end
=end
return @type
end
def display_damage(pkmn, move = nil)
=begin
case @function_code
when "TypeDependsOnUserIVs"
return pbHiddenPower(pkmn)[1]
when "TypeAndPowerDependOnUserBerry"
item_data = pkmn.item
if item_data
item_data.flags.each do |flag|
return [$~[1].to_i, 10].max if flag[/^NaturalGift_(?:\w+)_(\d+)$/i]
def display_power(pkmn, move = nil)
if Settings::SHOW_MODIFIED_MOVE_PROPERTIES
case @function_code
when "TypeDependsOnUserIVs"
return pbHiddenPower(pkmn)[1]
when "TypeAndPowerDependOnUserBerry"
item_data = pkmn.item
if item_data
item_data.flags.each do |flag|
return [$~[1].to_i, 10].max if flag[/^NaturalGift_(?:\w+)_(\d+)$/i]
end
end
end
return 1
when "ThrowUserItemAtTarget"
item_data = pkmn.item
if item_data
item_data.flags.each do |flag|
return [$~[1].to_i, 10].max if flag[/^Fling_(\d+)$/i]
return 1
when "ThrowUserItemAtTarget"
item_data = pkmn.item
if item_data
item_data.flags.each do |flag|
return [$~[1].to_i, 10].max if flag[/^Fling_(\d+)$/i]
end
return 10
end
return 10
return 0
when "PowerHigherWithUserHP"
return [150 * pkmn.hp / pkmn.totalhp, 1].max
when "PowerLowerWithUserHP"
n = 48 * pkmn.hp / pkmn.totalhp
return 200 if n < 2
return 150 if n < 5
return 100 if n < 10
return 80 if n < 17
return 40 if n < 33
return 20
when "PowerHigherWithUserHappiness"
return [(pkmn.happiness * 2 / 5).floor, 1].max
when "PowerLowerWithUserHappiness"
return [((255 - pkmn.happiness) * 2 / 5).floor, 1].max
when "PowerHigherWithLessPP"
dmgs = [200, 80, 60, 50, 40]
ppLeft = [[(move&.pp || @total_pp) - 1, 0].max, dmgs.length - 1].min
return dmgs[ppLeft]
end
return 0
when "PowerHigherWithUserHP"
return [150 * pkmn.hp / pkmn.totalhp, 1].max
when "PowerLowerWithUserHP"
n = 48 * pkmn.hp / pkmn.totalhp
return 200 if n < 2
return 150 if n < 5
return 100 if n < 10
return 80 if n < 17
return 40 if n < 33
return 20
when "PowerHigherWithUserHappiness"
return [(pkmn.happiness * 2 / 5).floor, 1].max
when "PowerLowerWithUserHappiness"
return [((255 - pkmn.happiness) * 2 / 5).floor, 1].max
when "PowerHigherWithLessPP"
dmgs = [200, 80, 60, 50, 40]
ppLeft = [[(move&.pp || @total_pp) - 1, 0].max, dmgs.length - 1].min
return dmgs[ppLeft]
end
=end
return @power
end

View File

@@ -30,7 +30,7 @@ module GameData
"NamePlural" => [:real_name_plural, "s"],
"PortionName" => [:real_portion_name, "s"],
"PortionNamePlural" => [:real_portion_name_plural, "s"],
"Pocket" => [:pocket, "v"],
"Pocket" => [:pocket, "y", :BagPocket],
"Price" => [:price, "u"],
"SellPrice" => [:sell_price, "u"],
"BPPrice" => [:bp_price, "u"],
@@ -126,7 +126,7 @@ module GameData
@real_name_plural = hash[:real_name_plural] || "Unnamed"
@real_portion_name = hash[:real_portion_name]
@real_portion_name_plural = hash[:real_portion_name_plural]
@pocket = hash[:pocket] || 1
@pocket = hash[:pocket] || :None
@price = hash[:price] || 0
@sell_price = hash[:sell_price] || (@price / Settings::ITEM_SELL_PRICE_DIVISOR)
@bp_price = hash[:bp_price] || 1
@@ -146,6 +146,15 @@ module GameData
return pbGetMessageFromHash(MessageTypes::ITEM_NAMES, @real_name)
end
def display_name
ret = name
if is_machine?
machine = @move
ret = sprintf("%s %s", ret, GameData::Move.get(@move).name)
end
return ret
end
# @return [String] the translated plural version of the name of this item
def name_plural
return pbGetMessageFromHash(MessageTypes::ITEM_NAME_PLURALS, @real_name_plural)
@@ -168,6 +177,10 @@ module GameData
return pbGetMessageFromHash(MessageTypes::ITEM_DESCRIPTIONS, @real_description)
end
def bag_pocket
return GameData::BagPocket.get(@pocket).bag_pocket
end
def has_flag?(flag)
return @flags.any? { |f| f.downcase == flag.downcase }
end

View File

@@ -7,6 +7,7 @@ module GameData
attr_reader :real_name
attr_reader :outdoor_map
attr_reader :announce_location
attr_reader :location_sign
attr_reader :can_bicycle
attr_reader :always_bicycle
attr_reader :teleport_destination
@@ -37,6 +38,7 @@ module GameData
"Name" => [:real_name, "s"],
"Outdoor" => [:outdoor_map, "b"],
"ShowArea" => [:announce_location, "b"],
"LocationSign" => [:location_sign, "s"],
"Bicycle" => [:can_bicycle, "b"],
"BicycleAlways" => [:always_bicycle, "b"],
"HealingSpot" => [:teleport_destination, "vuu"],
@@ -68,6 +70,7 @@ module GameData
["Name", StringProperty, _INTL("The name of the map, as seen by the player. Can be different to the map's name as seen in RMXP.")],
["Outdoor", BooleanProperty, _INTL("If true, this map is an outdoor map and will be tinted according to time of day.")],
["ShowArea", BooleanProperty, _INTL("If true, the game will display the map's name upon entry.")],
["LocationSign", StringProperty, _INTL("Filename in 'Graphics/UI/Location/' to be used as the location sign.")],
["Bicycle", BooleanProperty, _INTL("If true, the bicycle can be used on this map.")],
["BicycleAlways", BooleanProperty, _INTL("If true, the bicycle will be mounted automatically on this map and cannot be dismounted.")],
["HealingSpot", MapCoordsProperty, _INTL("Map ID of this Pokémon Center's town, and X and Y coordinates of its entrance within that town.")],
@@ -98,6 +101,7 @@ module GameData
@real_name = hash[:real_name]
@outdoor_map = hash[:outdoor_map]
@announce_location = hash[:announce_location]
@location_sign = hash[:location_sign]
@can_bicycle = hash[:can_bicycle]
@always_bicycle = hash[:always_bicycle]
@teleport_destination = hash[:teleport_destination]