I'm trying to make an in-game State Glossary. The end goal is to have it look like the Item Window but instead of showing actor info at the top, it just says "State Glossary" and the selectable stuff is a list of the states in alphabetical order regardless of their IDs. When you select them, another window pops up that shows a description of that state (I can easily do this part).
What I managed thus far
I seem to be successful in copying the Window_Item code and using that for the states but having issues with Scene_Item. I copied it, removed the target_window (don't need it), but the cursor stays still. It doesn't blink or move, and I'm still pretty new to scriping so I have no idea what caused it, and I really don't know how the cursor really works in anything. I normally just fumble, place random hashtags and it eventually fixes itself but that tactic isn't working here.
So what I need
1. To get the cursor working
2. Get the states in Alphabetical order.
Note: I assume to do #2, I would go to line 79, and add the actual names to the arrays instead of the IDs by doing something like @data.push($data_states.name.to_s) and then go to line 102 and change state.name to just state, THEN... sort? Help section talks a lot of code mumbo jumbo, but I assume it sorts 0 - 9, then sorts A - Z, right? Go to line 95 and put state = @Data[index].sort <= Like this?
I broke the script twice having to start over so to save my sanity, I decided to just ask for help lol. Here is the script. I haven't gotten to making the second window.
What I managed thus far
I seem to be successful in copying the Window_Item code and using that for the states but having issues with Scene_Item. I copied it, removed the target_window (don't need it), but the cursor stays still. It doesn't blink or move, and I'm still pretty new to scriping so I have no idea what caused it, and I really don't know how the cursor really works in anything. I normally just fumble, place random hashtags and it eventually fixes itself but that tactic isn't working here.
So what I need
1. To get the cursor working
2. Get the states in Alphabetical order.
Note: I assume to do #2, I would go to line 79, and add the actual names to the arrays instead of the IDs by doing something like @data.push($data_states.name.to_s) and then go to line 102 and change state.name to just state, THEN... sort? Help section talks a lot of code mumbo jumbo, but I assume it sorts 0 - 9, then sorts A - Z, right? Go to line 95 and put state = @Data[index].sort <= Like this?
I broke the script twice having to start over so to save my sanity, I decided to just ask for help lol. Here is the script. I haven't gotten to making the second window.
Ruby:
#==============================================================================
# Window_StateDescription
#==============================================================================
class Window_StateDescription < Window_Base
def initialize
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 16
refresh
end
def refresh
self.contents.clear
# Same as above.
@x = 4
@y = 32
@Y = -10
end
def update
super
return unless self.active
end
end
#==============================================================================
#Window_States
#==============================================================================
class Window_States < Window_Selectable
def initialize
super(0, 64, 640, 416)
@column_max = 2
refresh
self.index = 0
if $fontface != nil
self.contents.font.name = $fontface
self.contents.font.size = 16
elsif $defaultfonttype != nil
self.contents.font.name = $defaultfonttype
self.contents.font.size = 16
end
self.contents.font.bold = true
self.active, self.index = false, 0
refresh
end
#--------------------------------------------------------------------------
# * Get State
#--------------------------------------------------------------------------
def state
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_states.size
@data.push($data_states[i])
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
state = @data[index]
self.contents.font.color = normal_color
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(x + 28, y, 212, 32, state.name, 0)
end
end
#==============================================================================
# Scene_State
#==============================================================================
class Scene_State
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window, item window
#@help_window = Window_Help.new
@item_window = Window_States.new
# Associate help window
#@item_window.help_window = @help_window
# Make target window (set to invisible / inactive)
#@target_window = Window_Target.new
#@target_window.visible = false
#@target_window.active = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
#@help_window.dispose
@item_window.dispose
#@target_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
#@help_window.update
@item_window.update
#@target_window.update
# If item window is active: call update_item
if @item_window.active
update_item
return
end
# If target window is active: call update_target
#if @target_window.active
# update_target
# return
#end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(0)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
#@item = @item_window.item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# If effect scope is an ally
# If effect scope is other than an ally
return
end
end
end