• Anmelden

1

Montag, 15. August 2011, 00:50

Leichte Modifikationen an Caesar's Questlog-Skript

Hallo, ich benötige leichte Modifikationen am Questlog-Skript von Caesar:

Spoiler

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#//////////////////////////////////Questlog 3.0/////////////////////////////////
#~~~~~~~~~~~~~~~~~~by Caesar~~~~~~~~~~~~~~~~~
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#===================Parameter==================
# Wenn true, werden neue Quests oben eingefügt, ansonsten unten
INSERT_AT_TOP = true
# Zeilenhöhe in der Questbeschreibung
LINE_HEIGHT = 24
# Windowskin der Questlog-Fenster (nil = default)
WINDOWSKIN = nil
# "Überschrift" des Questlogs
HEADER_TEXT = "Questlog"
# Geschwindigkeit beim Scrollen (Pixel / Frame)
SCROLL_SPEED = 7
# Styles für die Beschreibungen der Quests
STYLES = {
"h1" => "<size=45><font=Cambria><b>|</b></font></size><down=40>",
"h2" => "<big><b><font=Cambria>|</font></b></big><down=32>",
"disabled" => "<color=disabled_color>|</color>",
"highlight" => "<color=#eeee32>|</color>",
"system" => "<color=system_color>|</color>"
}
# Dieser Process wird ausgeführt, sobald das Questlog geschlossen wird;
# (Default: Spieler kommt wieder auf die Map)
ON_CLOSE = Proc.new {$scene = Scene_Map.new}
#============================================
class Scene_Questlog
def main
#@window_header = Window_Help.new
#@window_header.x = 65
#@window_header.y = 28
#@window_header.z = 500
#@window_header.width = 510
#@window_header.windowskin = RPG::Cache.windowskin(WINDOWSKIN) unless
#WINDOWSKIN.nil?
#@window_header.contents = Bitmap.new(478, 32)
#@window_header.contents.font.size = 30
#@window_header.contents.draw_text(0, 0, 510, 32, HEADER_TEXT, 1)
@window_titles = Window_Questlog_Titles.new
@window_titles.windowskin = RPG::Cache.windowskin(WINDOWSKIN) unless
WINDOWSKIN.nil?
@window_description = Window_Questlog_Description.new(
$game_system.questlog.quests.map{|q| q.description})
@window_description.windowskin = RPG::Cache.windowskin(WINDOWSKIN) unless
WINDOWSKIN.nil?
@index = @window_titles.index
spriteset = Spriteset_Map.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
#@window_header.dispose
@window_titles.dispose
@window_description.dispose
spriteset.dispose
end
#----------------
def update
@window_titles.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
ON_CLOSE.call
return
end
if Input.press?(Input::R)
@window_description.scroll_down
elsif Input.press?(Input::L)
@window_description.scroll_up
end
if @index != @window_titles.index
@window_description.index = @index = @window_titles.index
end
end
end
#=============
class Quest
attr_reader :title
attr_reader :description
def initialize(title, description)
@title = title
@description = description
end
end
#============
class Questlog
attr_reader :quests
def initialize
@quests = []
end
#-----------
def add(quest, description="")
return add(Quest.new(quest, description)) unless quest.is_a?(Quest)
i = index(quest.title)
return @quests[i] = quest if i != nil
if INSERT_AT_TOP
# insert quest at top of the list
@quests.unshift(quest)
else
# insert quest at bottom of the list
@quests.push(quest)
end
end
#-----------
def remove(title)
@quests.delete_if{ |quest| quest.title == title}
end
#-----------
def count
return @quests.length
end
#------------
def index(title)
for i in 0..@quests.length-1
return i if @quests[i].title == title
end
return nil
end
#------------
def Questlog.add(title, description="")
$game_system.questlog.add(title, description)
end
#------------
def Questlog.remove(title)
$game_system.questlog.remove(title)
end
end
#=============
class Window_Questlog_Description < Window_Base
attr_reader :index
#------------------
def initialize(descriptions)
super(275, 60, 300, 360)
@descriptions = descriptions
@cache = Array.new(descriptions.size)
self.contents = Bitmap.new(width-32, height-32)
self.index = 0
self.z = 500
end
#-----------
def index=(index)
return if index == @index or @descriptions.empty?
@index = index
self.oy = 0
# bitmaps are only rendered once and than cached to reach more efficiency
if @cache[index].nil?
buffer = Bitmap.new(width-32, 2000)
docheight = buffer.draw_html(0, 0, 270, 2000, @descriptions[index])
@cache[index] = self.contents = Bitmap.new(width-32, docheight)
self.contents.blt(0, 0, buffer, Rect.new(0, 0, self.width-32, docheight))
else
self.contents = @cache[index]
end
end
#-----------
def scroll_down
self.oy += SCROLL_SPEED if self.height + self.oy - 32 < self.contents.height
end
#------------
def scroll_up
self.oy -= SCROLL_SPEED
self.oy = 0 if self.oy < 0
end
end
#=============
class Window_Questlog_Titles < Window_Base
attr_reader :index
def initialize
super(65, 60, 210, 360)
self.z = 500
@item_max = $game_system.questlog.count
self.contents = Bitmap.new(width-32, @item_max > 0 ? @item_max*32 : 32)
@index = 0
refresh
end
#-------------
def index=(index)
@index = index
update_cursor_rect
end
#-------------
def top_row=(row)
if row < 0
row = 0
end
if row > @item_max - 1
row = @item_max - 1
end
self.oy = row * 32
end
#-------------
def page_row_max
return (self.height - 32) / 32
end
#-------------
def page_item_max
return page_row_max * @column_max
end
#-------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
row = @index
top_row = self.oy / 32
if row < top_row
self.top_row = row
end
if row > top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
self.cursor_rect.set(0, @index * 32 - self.oy, self.width - 32, 32)
end
#-------------
def refresh
self.contents.clear
for i in 0...$game_system.questlog.count
quest = $game_system.questlog.quests[i]
y = i*32
self.contents.draw_html(4, y, 150, 32, quest.title)
end
end
#------------
def update
super
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::DOWN) and
(Input.trigger?(Input::DOWN) or @index < @item_max - 1)
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % @item_max
end
if Input.repeat?(Input::UP) and
(Input.trigger?(Input::UP) or @index > 0)
$game_system.se_play($data_system.cursor_se)
@index = (@index - 1 + @item_max) % @item_max
end
end
update_cursor_rect
end
end
#===========
class Scene_Map
def call_questlog
$game_temp.questlog_calling = false
$game_player.straighten
$scene = Scene_Questlog.new
end
end
#===========
class Game_System
attr_accessor :questlog
alias questlog_init initialize
def initialize
questlog_init
@questlog = Questlog.new
end
end
#===========
class Game_Temp
attr_accessor :questlog_calling
alias questlog_init initialize
def initialize
questlog_init
@questlog_calling = false
end
end
#========================
class Scene_Load < Scene_File
# if a game that does not yet contain the questlog is loaded
# a new (empty) questlog instance is created
alias questlog_read_save_data read_save_data
def read_save_data(file)
questlog_read_save_data(file)
$game_system.questlog = Questlog.new if $game_system.questlog.nil?
end
end
zum Lesen den Text mit der Maus markieren


Folgende Änderung benötige ich: Die Questlog-Fenster sollen nicht auf der Map, sondern im Menü angezeigt werden (mit schwarzem Hintergrund und ohne übergeblendeten Lichteffekt).
Ich dachte, das sei leicht machbar, aber anscheinend bin ich irgendwie zu dumm dafür :)
Und nun die zweite Sache: Das Auswahlfeld, mit dem man durch die Questtitel navigieren kann, wird nach öffnen des Questlogs immer erst ca. 1-2 Frames verspätet angezeigt. Da ich auf sowas immer Wert lege, möchte ich, dass das Auswahlfeld aber bereits angezeigt wird, wenn sich der Questlog öffnet (so wie in allen anderen Teilen der normalen Menüs).
Zu guter letzt liegt die Schrift bei den Questtiteln nicht zentral im Auswahlfeld (sie ist leicht nach oben verschoben). Wie kann das behoben werden?

Danke bereits im Voraus!

Irrlicht

Leuchtendes Irgendwas

Motto: Keep shining!

  • Nachricht senden

2

Dienstag, 16. August 2011, 10:27

Huhu,

Zu Punkt 1:
Versuche mal folgende 2 Zeilen auszukommentieren:
Zeile 47: spriteset = Spriteset_Map.new
Zeile 61: spriteset.dispose

Zu Punkt 2:
Versuch mal Zeile 178 durch folgende zu ersetzen:
alt: @index = 0
neu: self.index = (@item_max == 0) ? -1 : 0

Zu Punkt 3:
Versuch mal Zeile Zeile 255 etwas zu korrigieren:
y = i*32 + 1
Anstatt der + 1 kannst du auch andere Werte versuchen, sodass die Schrift am Ende möglichst mittig ist.

Ich selbst hab jetzt zugegebenermaßen noch nichts davon selbst ausprobiert, das werd ich allerdings erst nachher nachholen können.

3

Dienstag, 16. August 2011, 10:40

Super, hat alles geklappt. Bei Punkt 3 halt mit ner +6 statt +1. Vielen Dank!

Ich hab wahrscheinlich zum Questlog-Skript noch paar andere Fragen, die ich demnächst hier posten werde. :)


Edit: Hier gleich die nächste Frage: Gibt es eine Möglichkeit, Questbeschreibungen zu zentrieren bzw. im Blocksatz ausrichten zu lassen? Ist das sehr kompliziert und muss dazu ggf. die HTML-Rendering-Engine verändert werden oder ist es einfach zu realisieren?

Social Bookmarks