UltimaForum

Wsparcie [XP] - Wyświetlanie obrazka jako tła w HellKiller Questlog

xGamerPLz - Sob 09 Lut, 2013 19:23
Temat postu: Wyświetlanie obrazka jako tła w HellKiller Questlog
Witam! Jak zrobić żeby jako tło do tego skryptu był wyświetlany obrazek "questlog.png"
Skrypt:
Spoiler:


Kod:

=begin
Author: HellKiller
Version: 1.01
=end

Ikona = "032-item01"
OP = 100

class Game_Party
  alias :questlog_hellkiller_initialize :initialize
  attr_accessor :all_quest
  def initialize
    questlog_hellkiller_initialize
    # $quest = ["nazwa", "opis", kasa, "nagroda", trudnosc]
    $quest1 = ["nazwa", "opis", 555, "nagroda", 5]
    @quest = []
    @quest_done = []
    @all_quest = 1
  end
  def quest
    return @quest
  end
  def quest_done
    return @quest_done
  end
  def add_quest(quest)
    @quest.push(quest) if not @quest.include?(quest)
  end
    def add_quest_done(quest)
    @quest_done.push(quest) if @quest.include?(quest)
    @quest.delete(quest)
    end
  end
 
class Quest_Command < Window_Selectable
 
  def initialize
    super(0, 64, 180, 320)
    self.back_opacity = (OP)
    @column_max = 1
    refresh
    self.index = 0
  end
 
  def item
    return @data[self.index]
  end
 
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...$game_party.quest.size
        @data.push($game_party.quest[i])
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $defaultfonttype  # "Items" window font
      self.contents.font.size = $defaultfontsize
      self.back_opacity = (OP)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
 
  def draw_item(index)
    item = @data[index]
    x = 8
    y = index * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.back_opacity = (OP)
    self.contents.draw_text(x , y, 212, 32, item[0], 0)
  end
end

class QuestLog
  def initialize
    @quest = $game_party.quest
  end
 
  def main
    @spriteset = Spriteset_Map.new
    @command_window = Quest_Command.new
    @command_window.x = 0
    @command_window.y = 0
    @index = @command_window.index
    @window_qd = Window_Quest_Done.new
    @window_qd.y = 320
    @window_qu = Window_Quest_Unlock.new
    @window_qu.y = 400
    if @quest.size > 0
    @opis = @quest[@index][1]
    @money = @quest[@index][2]
    @prize = @quest[@index][3]
    @dificulty = @quest[@index][4]
  else
    @opis = ""
    @money = 0
    @prize = ""
    @dificulty = 0
    end
    @window_quest_description = Window_Quest_Description.new(@opis)
    @window_quest_description.x = 180
    @window_qm = Window_Quest_Money.new(@money)
    @window_qm.x = 180
    @window_qm.y = 400
    @window_qp = Window_Quest_Prize.new(@prize)
    @window_qp.x = 180
    @window_qp.y = 320
    @window_qt = Window_Quest_Dificulty.new(@dificulty)
    @window_qt.y = 400
    @window_qt.x = 360
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
   
    @command_window.dispose
    @window_qd.dispose
    @window_qu.dispose
    @window_quest_description.dispose
    @window_qm.dispose
    @window_qp.dispose
    @window_qt.dispose
   
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
  end
 
  def update
    @window_qd.update
    @command_window.update
    @window_qu.update
   
    @window_qp.dispose
    @window_qt.dispose
    @window_qd.dispose
    @window_qu.dispose
    @window_quest_description.dispose
    @window_qm.dispose
    @index = @command_window.index
    @window_qd = Window_Quest_Done.new
    @window_qd.y = 320
    @window_qu = Window_Quest_Unlock.new
    @window_qu.y = 400
    if @quest.size > 0
    @opis = @quest[@index][1]
    @money = @quest[@index][2]
    @prize = @quest[@index][3]
    @dificulty = @quest[@index][4]
  else
    @opis = ""
    @money = 0
    @prize = ""
    @dificulty = 0
    end
    @window_quest_description = Window_Quest_Description.new(@opis)
    @window_quest_description.x = 180
    @window_qm = Window_Quest_Money.new(@money)
    @window_qm.x = 180
    @window_qm.y = 400
    @window_qp = Window_Quest_Prize.new(@prize)
    @window_qp.x = 180
    @window_qp.y = 320
    @window_qt = Window_Quest_Dificulty.new(@dificulty)
    @window_qt.y = 400
    @window_qt.x = 360
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
  end
end


class Window_Quest_Done < Window_Base
 
  def initialize
    super(0, 0, 180, 80)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = (OP)
    self.contents.font.name = $defaultfonttype 
    self.contents.font.size = 16
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Ukończone")
    self.contents.font.color = normal_color
    self.contents.draw_text(20, 0, 120, 32, $game_party.quest_done.size.to_s + " / " + $game_party.all_quest.to_s, 2)
  end
  def update
    refresh
  end
end

class Window_Quest_Unlock < Window_Base
 
  def initialize
    super(0, 0, 180, 80)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = (OP)
    self.contents.font.name = $defaultfonttype 
    self.contents.font.size = 16
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Odblokowano")
    self.contents.font.color = normal_color
    self.contents.draw_text(20, 0, 120, 32, $game_party.quest.size.to_s + " / " + $game_party.all_quest.to_s, 2)
  end
  def update
    refresh
  end
end

class Window_Quest_Description < Window_Base
 
  def initialize(quest)
    super(0, 0, 460, 320)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = (OP)
    self.contents.font.name = $defaultfonttype 
    self.contents.font.size = 16
    @quest = quest
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 120, 32, "Opis")
    self.contents.font.color = system_color
    paragraph = str_paragraph(@quest,430)
    draw_paragraph(0,-110,430,290, paragraph)
  end
  def update
    refresh
  end
end

class Window_Quest_Money < Window_Base
 
  def initialize(quest)
    super(0, 0, 180, 80)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = (OP)
    self.contents.font.name = $defaultfonttype 
    self.contents.font.size = 16
    @quest = quest
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    bitmap = RPG::Cache.icon(Ikona)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.color = normal_color
    self.contents.draw_text(60, 0, 120, 32, @quest.to_s)
  end
  def update
    refresh
  end
end

class Window_Quest_Prize < Window_Base
 
  def initialize(quest)
    super(0, 0, 460, 80)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = (OP)
    self.contents.font.name = $defaultfonttype 
    self.contents.font.size = 16
    @quest = quest
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 80, 32, "Nagroda:")
    self.contents.font.color = normal_color
    self.contents.draw_text(30, 0, 120, 32, @quest)
  end
  def update
    refresh
  end
end

class Window_Quest_Dificulty < Window_Base
 
  def initialize(quest)
    super(0, 0, 300, 80)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = (OP)
    self.contents.font.name = $defaultfonttype 
    self.contents.font.size = 16
    @quest = quest
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 80, 32, "Trudnosc:")
    self.contents.font.color = normal_color
    self.contents.draw_text(90, 0, 120, 32, "Bardzo łatwy") if @quest == 0
    self.contents.draw_text(90, 0, 120, 32, "Łatwy") if @quest == 1
    self.contents.draw_text(90, 0, 120, 32, "Średni") if @quest == 2
    self.contents.draw_text(90, 0, 120, 32, "Trudny") if @quest == 3
    self.contents.draw_text(90, 0, 120, 32, "Bardzo trudny") if @quest == 4
    self.contents.draw_text(90, 0, 120, 32, "Hiper Trudny") if @quest == 5
  end
  def update
    refresh
  end
end


ATP:
Spoiler:


Kod:

=begin

ATP(Advanced Text Paragrapher) V1.0 by Samo, The thief

Ok, Something of The Scripters do normally to draw a text in form of a paragraph is
doing an array [] that contains each line. The Time Has come For
This Microsoft Word Effect!
This Script Just need a Long String and it will paragraph it!

How to call it?

paragraph = str_paragraph(string, width of the paragraph.)

Example :

@my_paragraph = str_paragraph("La la la la la la la la la , This is a Looooong Strriiiing!", 120)


Returns an Array with each line separately.

How to draw it?

draw_paragraph(x,y,width,height, paragraph)

width and height for each line, not for the paragraph.

.::-NOTE-::.

If you put a ' ^ '(must be between spaces), the text will pass to the next line.
This Symbol Won't be drawed.

Reminder: Always use '' instead of ""! It works faster!

=end


class Window_Base < Window
#--------------------------------------------------
  def str_paragraph(str_old, width)
    temp_str = ''
    str = '' + str_old
    words = []
    size = 0
    str_size = 0
    #
    while ((c = str.slice!(/./m)) != nil)
      temp_str += c
      str_size += 1
      if c == ' '
        words.push(temp_str)
        temp_str = ''
      end
      if str.size == 0
        words.push(temp_str)
        temp_str = ''
      end
    end
    lines = []
    for i in 0...words.size
      word = words[i]
      if word == '^ '
        lines.push(temp_str)
        temp_str = ''
        next
      end
      temp_str += word
      size = contents.text_size(temp_str).width
      if size > width - contents.text_size(' ').width
        for i in 1..word.size
          temp_str = temp_str.chop
        end
        lines.push(temp_str)
        temp_str = ''
        temp_str += word
      end
    end
    words = words.compact
    if temp_str != ''
      lines.push(temp_str)
    end
    return lines
  end
#---------------------------------------------------------------------
  def draw_paragraph(x,y,width,height,lines,align = 0)
    for i in 0...lines.size
      self.contents.draw_text(x, y + i * self.contents.font.size + 1, width, height, lines[i], align)
    end
  end
#-----------------------------------------------------------------
end


Ayene - Sob 09 Lut, 2013 22:20

Poza obrazkiem, ma się wyświetlać w tle mapa?
xGamerPLz - Sob 09 Lut, 2013 23:55

tak, ale to już zrobiłem został tylko ten obrazek z którym się okropnie męczę.
Ayene - Nie 10 Lut, 2013 00:23

Znajdź fragment:
Kod:
@spriteset = Spriteset_Map.new

po nim dodaj:
Kod:
@background_sprite = RPG::Cache.picture("questlog")

następnie znajdź:
Kod:
if $scene.is_a?(Scene_Title)

przed nim dodaj:
Kod:
@background_sprite.dispose

Obrazek umieść w folderze Graphics/Picture

BTW, skrypt jest paskudnie niezoptymalizowany. Zżera mnóstwo klatek animacji.

xGamerPLz - Nie 10 Lut, 2013 01:18

Nie wyświetla się obrazek :<
Ayene - Nie 10 Lut, 2013 12:09

Mój błąd. Dodaną wcześniej linijkę:
Kod:
@background_sprite = RPG::Cache.picture("questlog")

zmień na:
Kod:
@background_sprite = Sprite.new
@background_sprite.bitmap = RPG::Cache.picture("questlog")

xGamerPLz - Nie 10 Lut, 2013 21:44

OK! Działa :cmok: ale jak zrobić żeby po otwarciu questloga usunęły się wszystkie obrazki z mapy (fog, maska świetlna itp.)
Ayene - Nie 10 Lut, 2013 23:00

Znajdź fragment:
Kod:
@spriteset = Spriteset_Map.new

zamień na:
Kod:
@spriteset = Spriteset_Map_QuestLog.new

następnie znajdź:
Kod:
if $scene.is_a?(Scene_Title)

dodaj przed:
Kod:
@spriteset.dispose


Na samym dole skryptu dodaj:
Spoiler:

Kod:
class Spriteset_Map_QuestLog
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @viewport1 = Viewport.new(0, 0, 640, 480)
    @tilemap = Tilemap.new(@viewport1)
    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
    for i in 0..6
      autotile_name = $game_map.autotile_names[i]
      @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
    end
    @tilemap.map_data = $game_map.data
    @tilemap.priorities = $game_map.priorities
    @panorama = Plane.new(@viewport1)
    @panorama.z = -1000
    @character_sprites = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
      @character_sprites.push(sprite)
    end
    @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))   
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @tilemap.tileset.dispose
    for i in 0..6
      @tilemap.autotiles[i].dispose
    end
    @tilemap.dispose
    @panorama.dispose
    for sprite in @character_sprites
      sprite.dispose
    end
    @viewport1.dispose
  end
end


xGamerPLz - Pon 11 Lut, 2013 09:46

Wszystko działa, ale po otwarciu dziennika a potem np. ekwipunku wyskakuje, że rgss przestał działać :(
Ayene - Pon 11 Lut, 2013 10:56

A przed wprowadzeniem korekt wszystko działało? Pisałam już że skrypt jest mocno niezoptymalizowany. Nie usuwał domyślnie spriteseta mapy przez co po trzykrotnym wejściu do QuestLoga gra się zawieszała. Korekty, które wprowadziłam nie są na tyle poważne, aby siadał program. Problem leży po stronie samego skryptu na dziennik.
xGamerPLz - Pon 11 Lut, 2013 13:23

Czyli z użycia questlogu nici? Jaki dziennik polecasz? Bo nie ogarniam zbytnio Jaberwocky, a inne mi nie pasują, bo to trudne do ogarnięcia, bo to po otwarciu otwiera się małe okienko z podziałem itp.
Ayene - Czw 21 Lut, 2013 23:27

Przykro mi, ale w kwestii ogarniania to nie jestem dobrym doradcą, bo to który jest dla Ciebie najlepszy / najłatwiejszy, możesz tylko Ty zdecydować. Przejrzyj na spokojnie zasoby, może uda się Tobie coś znaleźć. Pewnie do tych bardziej rozbudowanych skryptów można znaleźć jakieś tutoriale.

Powered by phpBB modified by Przemo © 2003 phpBB Group