Main Menu
  • Welcome to The RPG Maker Resource Kit.

Simple CMS with Window edits + Location

Started by Rune, May 20, 2007, 09:12:48 AM

0 Members and 1 Guest are viewing this topic.

Rune

Here you go, my second released CMS... hope you like :D

Everything here except the location and horizontal menu commands (Window_Command2) is by me, I merely edited Window_MenuStatus and Window_Base

[spoiler=Script]
Just replace this script with Scene_Menu
#===============================#
#               Rune's CMS                   #
#                No.2 Ver 1                       #
#===============================#

$data_mapinfos = load_data('Data/MapInfos.rxdata')

class Window_Steps
 def refresh
 contents.clear
 contents.font.color = system_color
 contents.draw_text(4, 0, 120, 32, 'Location')
 contents.font.color = normal_color
 name = $data_mapinfos[$game_map.map_id].name  
 contents.draw_text(0, 32, 128, 32, name)
 end
end

class Window_Base
 def draw_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
 end
 def draw_actor_name(actor, x, y)
self.contents.font.color = crisis_color
self.contents.draw_text(x, y, 120, 32, actor.name)
 end
 def draw_actor_class(actor, x, y)
self.contents.font.color = Color.new(0, 255, 0)
self.contents.draw_text(x, y, 236, 32, actor.class_name)
 end
 def draw_actor_level(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, "Level")
self.contents.font.color = normal_color
self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
 end
 def make_battler_state_text(battler, width, need_normal)
brackets_width = self.contents.text_size("[]").width
text = ""
for i in battler.states
 if $data_states[i].rating >= 1
if text == ""
 text = $data_states[i].name
else
 new_text = text + "/" + $data_states[i].name
 text_width = self.contents.text_size(new_text).width
 if text_width > width - brackets_width
break
 end
 text = new_text
end
 end
end
if text == ""
 if need_normal
text = "[Normal]"
 end
else
 text = "[" + text + "]"
end
return text
 end
 def draw_actor_state(actor, x, y, width = 120)
text = make_battler_state_text(actor, width, true)
self.contents.font.color = actor.hp == 0 ? knockout_color : crisis_color
self.contents.draw_text(x, y, width, 32, text)
 end
 def draw_actor_exp(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x - 16, y - 8, 24, 32, "Exp")
self.contents.font.color = normal_color
self.contents.draw_text(x - 64, y + 16, 84, 32, actor.exp_s, 2)
self.contents.draw_text(x + 24, y + 16, 12, 32, "/", 1)
self.contents.draw_text(x + 36, y + 16, 84, 32, actor.next_exp_s)
 end
 def draw_actor_hp(actor, x, y, width = 144)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
if width - 32 >= 108
 hp_x = x + width - 108
 flag = true
elsif width - 32 >= 48
 hp_x = x + width - 48
 flag = false
end
self.contents.font.color = actor.hp == 0 ? knockout_color :
 actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x - 44, y + 16, 48, 32, actor.hp.to_s, 2)
if flag
 self.contents.font.color = normal_color
 self.contents.draw_text(hp_x + 4, y + 16, 12, 32, "/", 1)
 self.contents.draw_text(hp_x + 16, y + 16, 48, 32, actor.maxhp.to_s)
end
 end
 def draw_actor_sp(actor, x, y, width = 144)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
if width - 32 >= 108
 sp_x = x + width - 108
 flag = true
elsif width - 32 >= 48
 sp_x = x + width - 48
 flag = false
end
self.contents.font.color = actor.sp == 0 ? knockout_color :
 actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(sp_x - 44, y + 16, 48, 32, actor.sp.to_s, 2)
if flag
 self.contents.font.color = normal_color
 self.contents.draw_text(sp_x + 4, y + 16, 12, 32, "/", 1)
 self.contents.draw_text(sp_x + 16, y + 16, 48, 32, actor.maxsp.to_s)
end
 end
end

class Window_MenuStatus
 def initialize
super(0, 0, 640, 240)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
refresh
self.active = false
self.index = -1
 end
 def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
 x = i * 160
 y = 116
 actor = $game_party.actors[i]
 draw_actor_graphic(actor, x + 16, y - 60)
 draw_actor_name(actor, x + 32, y - 120)
 draw_actor_class(actor, x + 32, y - 80)
 draw_actor_level(actor, x + 32, y - 100)
 draw_actor_state(actor, x + 16, y - 60)
 draw_actor_exp(actor, x + 16, y + 50)
 draw_actor_hp(actor, x, y - 40)
 draw_actor_sp(actor, x, y)
end
 end
 def update_cursor_rect
if @index < 0
 self.cursor_rect.empty
else
 self.cursor_rect.set(@index * 160, 0, 128, self.height - 32)
end
 end
end

class Window_Command < Window_Selectable
 def initialize(width, commands, column_max = 1, style = 0, inf_scroll = 1)
super(0, 0, width, (commands.size * 1.0 / column_max).ceil * 32 + 32)
@inf_scroll = inf_scroll
@item_max = commands.size
@commands = commands
@column_max = column_max
@style = style
self.contents = Bitmap.new(width - 32, (@item_max * 1.0 / @column_max).ceil * 32)
self.contents.font.name = "Tahoma"
self.contents.font.size = 22
refresh
self.index = 0
 end
 def refresh
self.contents.clear
for i in 0...@item_max
 draw_item(i, normal_color)
end
 end
 def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(index%@column_max * (self.width / @column_max) + 4, 32 * (index/@column_max), self.width / @column_max - 40, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], @style)
 end
 def disable_item(index)
draw_item(index, disabled_color)
 end
 def update_help
@help_window.set_actor($game_party.actors[$scene.actor_index])
 end
end

class Scene_Menu
 def initialize(menu_index = 0)
@menu_index = menu_index
 end
 def main
@spriteset = Spriteset_Map.new
s1 = "Items"
s2 = "Skills"
s3 = "Equip"
s4 = "Status"
s5 = "Save"
s6 = "Exit"
@command_window = Window_Command.new(320, [s1, s2, s3, s4, s5, s6], 3)
@command_window.index = @menu_index
@command_window.x = 160
@command_window.y = 144
if $game_party.actors.size == 0
 @command_window.disable_item(0)
 @command_window.disable_item(1)
 @command_window.disable_item(2)
 @command_window.disable_item(3)
end
if $game_system.save_disabled
 @command_window.disable_item(4)
end
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 144
@steps_window = Window_Steps.new
@steps_window.x = 480
@steps_window.y = 144
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 0
@status_window = Window_MenuStatus.new
@status_window.x = 0
@status_window.y = 240
Graphics.transition
loop do
 Graphics.update
 Input.update
 update
 if $scene != self
break
 end
end
Graphics.freeze
@spriteset.dispose
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
 end
 def update
@spriteset.update
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
if @command_window.active
 update_command
 return
end
if @status_window.active
 update_status
 return
end
 end
 def update_command
if Input.trigger?(Input::B)
 $game_system.se_play($data_system.cancel_se)
 $scene = Scene_Map.new
 return
end
if Input.trigger?(Input::C)
 if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
 end
 case @command_window.index
 when 0
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
 when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
 when 2
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
 when 3
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
 when 4
if $game_system.save_disabled
 $game_system.se_play($data_system.buzzer_se)
 return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
 when 5
$game_system.se_play($data_system.decision_se)
$scene = Scene_End.new
 end
 return
end
 end
 def update_status
if Input.trigger?(Input::B)
 $game_system.se_play($data_system.cancel_se)
 @command_window.active = true
 @status_window.active = false
 @status_window.index = -1
 return
end
if Input.trigger?(Input::C)
 case @command_window.index
 when 1
if $game_party.actors[@status_window.index].restriction >= 2
 $game_system.se_play($data_system.buzzer_se)
 return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@status_window.index)
 when 2
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@status_window.index)
 when 3
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@status_window.index)
 end
 return
end
 end
end

[/spoiler]

[spoiler=Screeny]

[/spoiler]

This script goes well with this script

[EDIT]
Found an error...
Put this at the end of Window_SkillStatus, just before the last end
[spoiler]  def draw_actor_hp(actor, x, y, width = 144)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
        @hp = RPG::Cache.icon("HP.png")
    self.contents.blt(x - 30, y + 4, @hp, Rect.new(0, 0, 24, 24))
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    end
  end
  def draw_actor_sp(actor, x, y, width = 144)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
        @sp = RPG::Cache.icon("SP.png")
    self.contents.blt(x - 30, y + 4, @sp, Rect.new(0, 0, 24, 24))
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end
  end
[/spoiler]

That should make the HP and SP appear right in the Skill window

[EDIT 2]
And add this to the end of Window_BattleStatus, just before the last 'end'
[spoiler]  def draw_actor_name(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, actor.name)
  end
  def draw_actor_hp(actor, x, y, width = 144)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    end
  end
  def draw_actor_sp(actor, x, y, width = 144)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end
  end
  def draw_actor_state(actor, x, y, width = 120)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
    self.contents.draw_text(x, y, width, 32, text)
  end
[/spoiler]

This makes the BattleStatus window look right

[EDIT 3]
Change this with the whole of def refresh in Window_Target
[spoiler]  def refresh
    self.contents.clear
    for i in 0...$game_party.actors.size
      x = 4
      y = i * 116
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x + 16, y + 80)
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)
      draw_actor_level(actor, x + 32, y + 32)
      draw_actor_state(actor, x + 32, y + 48)
      draw_actor_hp(actor, x + 152, y + 16)
      draw_actor_sp(actor, x + 152, y + 48)
    end
  end
[/spoiler]

Should fix the problem with  the target window in Scene_Item, Scene_Skil and whatnot... plus it shows the character's sprite :P

That should be all... T.T'
Sincerely,
Your conscience.

modern algebra

nice little script.

I have no idea why your scripts always sort of move down the page so quickly. I always see them like a month after they were released.

Rune

Maybe because almost all my scripts are $%&*... i'm only a beginner ;9
Sincerely,
Your conscience.

Demonic Blade

#3
ARGH! I have a problem with mine: I'm missing some HP icon... what is that?!

Forget it, problem solved ::) Nice script! It's better than most of the others. It's just so original and cool!
I wonder how many of my-reps are there for a reason, and not just because some jackass wanted to show off in front of some other jackasses...?
Probably a lot of them - and those people sure as hell don't deserve my pity, let alone my disgust.
That's right, let's see some more -Rep'ing! BOOYEAH!!

pliio8

Games in progress:
Tome of Arastovia: 7% complete at 2 hours of gametime

Demonic Blade

Well you just have to have an icon-sized picture named "HP" and one named "SP" (without the queotes of course) in your pictures or icons folder (not sure which one, think it was the icon folder, I stopped working on the project I used it in (problems with the scripting...).
I wonder how many of my-reps are there for a reason, and not just because some jackass wanted to show off in front of some other jackasses...?
Probably a lot of them - and those people sure as hell don't deserve my pity, let alone my disgust.
That's right, let's see some more -Rep'ing! BOOYEAH!!